On Fri, 3 Nov 2017, Ed D'Azevedo wrote: > Dear PETSc expert, > > I have a question on the correct way to use Fortran module in petsc. > > In this url on "UsingFortran" > > > http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Sys/UsingFortran.html#UsingFortran > > > it mentions including both the "petsc/finclude/petscXXX.h" file and the > Fortran "use" statement. > > The example show the following: > > > #include "petsc/finclude/petscvec.h" > use petscvec > > Vec b > type(tVec) x
Just to note: its either of the above 2 statements. > > > My understanding of Fortran syntax is there cannot be "parameter" statements > before the module "use" statement or in other words "use" statement cannot > follow "parameter" statement. > > Do I understand correctly then all ".h" include header files under > "petsc/finclude/" should not have "parameter" statements but just pure cpp > macro statements such as "#define" or "#ifdef"? yes. balay@asterix /home/balay/petsc ((v3.8)) $ grep parameter include/petsc/finclude/* include/petsc/finclude/petscsys.h:! F90 uses real(), conjg() when KIND parameter is used. balay@asterix /home/balay/petsc ((v3.8)) $ > > One may imagine substituting "parameter" statements with '#define' such as > instead of > > parameter (NOT_SET_VALUES=0) > > #define NOT_SET_VALUES 0 > > #define not_set_values 0 > > In the petsc version 3.6.2 under include/petsc/finclude, there seems to be > some files such as petscvec.h and petscmat.h that contain "parameter" > statements. The above doc corresponds to petsc-3.8 (with major changes for fortran module usage) - which is an upgrade we recommend for fortran usage. > > > > If there should be "parameter" statements in the petsc/finclude header files, > perhaps the order of the code should be to list all F90 module "use" > statements first, then include 'petsc/finclude' header files? For older releases - we split paramaters and #defines into different set of includes. So one would use to get only the #defines #define "petscdef.h" Satish > > > ! > ------------------------------------------------------------------------------ > > ! parameter statements after the module use statement > > ! > ------------------------------------------------------------------------------ > > use petscvec > > #include "petsc/finclude/petscvec.h" > > Vec b > type(tVec) x > > >