[petsc-users] petsc with fortran modules

Ed D'Azevedo dazevedoef at ornl.gov
Fri Nov 3 17:33:56 CDT 2017


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


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"?

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.



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?


! 
------------------------------------------------------------------------------

! parameter statements after the module use statement

! 
------------------------------------------------------------------------------

    use petscvec

#include "petsc/finclude/petscvec.h"

    Vec b
    type(tVec) x


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20171103/e74c8462/attachment.html>


More information about the petsc-users mailing list