[petsc-users] petsc with fortran modules

Matthew Knepley knepley at gmail.com
Fri Nov 3 19:25:46 CDT 2017


On Fri, Nov 3, 2017 at 6:33 PM, Ed D'Azevedo <dazevedoef at ornl.gov> 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
>
>
> 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"?
>
> All the parameter statements are in the module.

   Matt

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


-- 
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener

https://www.cse.buffalo.edu/~knepley/ <http://www.caam.rice.edu/~mk51/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20171103/579931c8/attachment-0001.html>


More information about the petsc-users mailing list