Hi, I can compile and run with visual fortran by putting all the declarations inside a subroutine e.g.
module ada ... subroutine ddd #define PETSC_AVOID_DECLARATIONS #include "include/finclude/petsc.h" <other includes> #undef PETSC_AVOID_DECLARATIONS .... end subroutine ddd end module ada However, on my school's server which uses ifort, I get errors both using your way and my way e.g. #define PETSC_AVOID_DECLARATIONS #include "include/finclude/petsc.h" #include "include/finclude/petscvec.h" #include "include/finclude/petscmat.h" #include "include/finclude/petscksp.h" #include "include/finclude/petscpc.h" #include "include/finclude/petscmat.h90" #undef PETSC_AVOID_DECLARATIONS program test implicit none integer :: x,y Vec test_vec x=1 print *, x end program test I compile using ifort -r8 -132 -fPIC -g -c -static-libcxa -O3 -I/lsftmp/g0306332/petsc- 2.3.3-p0 -I/lsftmp/g0306332/petsc-2.3.3-p0/bmake/atlas3 -I/lsftmp/g0306332/petsc-2.3.3-p0/include -I/lsftmp/g0306332/petsc-2.3.3-p0 /externalpackages/hypre-2.0.0/atlas3/include -I/lsftmp/g0306332/mpich2/include temp.f90 and get the error msg: fortcom: Warning: Bad # preprocessor line fortcom: Warning: Bad # preprocessor line fortcom: Warning: Bad # preprocessor line fortcom: Warning: Bad # preprocessor line fortcom: Warning: Bad # preprocessor line fortcom: Warning: Bad # preprocessor line fortcom: Warning: Bad # preprocessor line fortcom: Warning: Bad # preprocessor line fortcom: Error: temp.f90, line 18: Syntax error, found IDENTIFIER 'TEST_VEC' when expecting one of: => = . ( : % Vec test_vec ----^ fortcom: Error: temp.f90, line 18: This name does not have a type, and must have an explicit type. [VEC] Vec test_vec ^ fortcom: Error: temp.f90, line 18: This name does not have a type, and must have an explicit type. [TEST_VEC] Vec test_vec ----^ compilation aborted for temp.f90 (code 1) I also tried shifting the declarations after the "program test" line but it also failed. There is no problem if I changed the code to fixed format. Thanks On 8/6/07, Satish Balay <balay at mcs.anl.gov> wrote: > > This is incorrect usage. > > If you are getting errors with the correct usage, send us the error > messages, with your code, and we can sugest fixes. > > - one issue could be > > > > #define PETSC_AVOID_DECLARATIONS > > > #include "include/finclude/petsc.h" > > > #include "include/finclude/petscvec.h90" <--- This should be removed > from here.. > > > <other includes> > > > #undef PETSC_AVOID_DECLARATIONS > > > > > > moudle foobar > > > <other module stuff> > > > end module > > > Satish > > On Mon, 6 Aug 2007, Ben Tay wrote: > > > Hi, > > > > I tried to use > > > > #define PETSC_AVOID_DECLARATIONS > > #include "include/finclude/petsc.h" > > <other includes> > > #undef PETSC_AVOID_DECLARATIONS > > > > > > module ada > > ... > > > > subroutine .... > > > > end module ada > > > > but the compiler says that the module is placed in the wrong order. > Anyway, I > > just move the top 4 lines into the subroutine instead and it worked. > Thanks > > > > module ada > > > > ... > > > > subroutine ddd > > > > #define PETSC_AVOID_DECLARATIONS > > #include "include/finclude/petsc.h" > > <other includes> > > #undef PETSC_AVOID_DECLARATIONS > > > > .... > > > > end subroutine ddd > > > > > > > > > > Satish Balay wrote: > > > you can use .F90 suffix for free-from preprocesed code. [or use > > > compiler options to force it always use free-form] > > > > > > And when using fortran modules use the following organization: > > > > > > > > > #define PETSC_AVOID_DECLARATIONS > > > #include "include/finclude/petsc.h" > > > <other includes> > > > #undef PETSC_AVOID_DECLARATIONS > > > > > > moudle foobar > > > <other module stuff> > > > end module > > > > > > subroutine xyz() > > > use foobar > > > implicit none > > > #include "include/finclude/petsc.h" > > > <other includes> > > > <code> > > > end subroutine > > > <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< > > > > > > Satish > > > > > > On Mon, 6 Aug 2007, Ben Tay wrote: > > > > > > > > > > Hi, > > > > > > > > I've no problem writing out codes in fortran fixed format with > PETSc. > > > > However, > > > > is it possible to do it in fortran free format as well? > > > > > > > > I'm using visual fortran and there's error. > > > > > > > > original : > > > > > > > > test.F > > > > > > > > module global_data > > > > > > > > implicit none > > > > > > > > save > > > > > > > > #include "include/finclude/petsc.h" > > > > #include "include/finclude/petscvec.h" > > > > #include "include/finclude/petscmat.h" > > > > #include "include/finclude/petscksp.h" > > > > #include "include/finclude/petscpc.h" > > > > #include "include/finclude/petscmat.h90" > > > > > > > > Vec xx,b_rhs > > > > > > > > .... > > > > > > > > How can I change this code to fortran free format *.f90? > > > > > > > > Thanks > > > > > > > > > > > > > > > > > > > > > > > > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20070807/bacd3076/attachment.htm>
