Programming in *.f90 free format with PETSc
Satish Balay
balay at mcs.anl.gov
Tue Aug 7 12:04:11 CDT 2007
Let me reiterate the f90 include usage in modules and the rationale..
<<<<<
#define PETSC_AVOID_DECLARATIONS
#include "include/finclude/petsc.h"
#include "include/finclude/petscvec.h"
<other includes>
#undef PETSC_AVOID_DECLARATIONS
moudle foobar
<other module stuff>
Vec abc
contains
subroutine xyz()
use foobar
implicit none
#include "include/finclude/petsc.h"
#include "include/finclude/petscvec.h"
#include "include/finclude/petscvec.h90"
<other includes>
Vec foobar
call VecNorm(foobar,NORM_MAX,...)
<code>
end subroutine
end module
<<<<<<
- Note: Currently .h90 files should not be listed inside
PETSC_AVOID_DECLARATIONS. They are not necessary there. [I'll fix
this issue in the next patch update].
The fortran includes have 2 types of code:
- Macros: like 'Vec' that get preprocessed into integer*4. These
macros are needed in both the module definition for 'abc', and
in the subroutines 'foobar'.
- Some DECLARATIONS like PETSC_NULL, NORM_MAX etc. These are
declared as parameters
<<<<
integer NORM_MAX
parameter NORM_MAX=3
>>>
Such DELCARATIONS cannot be used inside the module 'data section?'
This is because they become global variables, and will cause duplicate
symbol errors.
Also these declarations should be included in ALL subroutines. So one
should not use PETSC_AVOID_DECLARATIONS in subroutines.
Hence the recommended usage. There is another alternative usage -
creating petsc.mod etc. One can create these files by doing:
cd include/finclude
make all
[I haven't explored this usage completely]
Satish
More information about the petsc-users
mailing list