<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p>Dear PETSc expert,</p>
<p>I have a question on the correct way to use Fortran module in
petsc.</p>
<p>In this url on "UsingFortran"<br>
</p>
<p><br>
</p>
<p><font size="+1"><a class="moz-txt-link-freetext" href="http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Sys/UsingFortran.html#UsingFortran">http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Sys/UsingFortran.html#UsingFortran</a></font></p>
<p><font size="+1"><br>
</font></p>
<p><font size="+1">it mentions including both the
"petsc/finclude/petscXXX.h" file and the Fortran "use"
statement. <br>
</font></p>
<p><font size="+1">The example show the following:</font></p>
<p><br>
</p>
<p><font size="+1">#include "petsc/finclude/petscvec.h"<br>
use petscvec</font></p>
<p><font size="+1"> Vec b<br>
type(tVec) x<br>
</font></p>
<p><font size="+1"><br>
</font></p>
<p><font size="+1">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.<br>
</font></p>
<p><font size="+1">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"? <br>
</font></p>
<p><font size="+1">One may imagine substituting "parameter"
statements with '#define' such as instead of <br>
</font></p>
<p><font size="+1">parameter (NOT_SET_VALUES=0)</font></p>
<p><font size="+1">#define NOT_SET_VALUES 0</font></p>
<p><font size="+1">#define not_set_values 0</font></p>
<p><font size="+1">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.
<br>
</font></p>
<p><font size="+1"><br>
</font></p>
<p><font size="+1"><br>
</font></p>
<p><font size="+1">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?</font></p>
<p><br>
<font size="+1"><font size="+1">!
------------------------------------------------------------------------------</font></font></p>
<p><font size="+1">! parameter statements after the module use
statement</font></p>
<p><font size="+1">!
------------------------------------------------------------------------------<br>
</font></p>
<p><font size="+1"> use petscvec<br>
</font></p>
<p><font size="+1">#include "petsc/finclude/petscvec.h"<br>
<br>
</font></p>
<p><font size="+1"> Vec b<br>
type(tVec) x<br>
</font></p>
<p><font size="+1"></font><br>
</p>
</body>
</html>