Programming in *.f90 free format with PETSc

Ben Tay zonexo at gmail.com
Wed Aug 8 19:07:08 CDT 2007


Hi,

when I changed my global.F to global.f90, I was told that 
PETSC_COMM_SELF, PETSC_NULL_INTEGER and PETSC_NULL_CHARACTER does not 
have a type.

I declare

MPI_Comm PETSC_COMM_SELF and it works

So, what about the other 2? You mention to use

integer NORM_MAX
parameter NORM_MAX=3

What values do I use then?

Thanks



Satish Balay wrote:
> 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