[petsc-users] Using fortran modules in petsc
Haren, S.W. van (Steven)
vanharen at nrg.eu
Tue Jul 26 13:18:09 CDT 2011
Dear all,
I try to use fortran modules to have the same variable declarations over my main program and all my subroutines.
My module file looks like:
module variables
#include "finclude/petscsys.h"
#include "finclude/petscvec.h"
#include "finclude/petscmat.h"
#include "finclude/petscpc.h"
#include "finclude/petscksp.h"
#include "finclude/petscviewer.h"
type::mesh_type
PetscScalar x1,x2,y1,y2,Lx,Ly,deltax,deltay,ratiox,ratioy
PetscInt Nx,Ny,Npx,Npy,Np,Nux_b,Nux_in,Nux_t,Nuy_b,Nuy_in,Nuy_t,Nu_t,Nb
PetscInt Nvx_b,Nvx_in,Nvx_t,Nvy_b,Nvy_in,Nvy_t,Nv_t,N1,N2,N3,N4
end type mesh_type
type(mesh_type)::mesh
etc................
My main program looks like:
program main
use variables
implicit none
etc.................
Then a subroutine looks like:
subroutine parameters(mesh,flowParameters,ierr)
use variables
implicit none
etc...................
I have my makefile set up to first compile the module, then the main program, and then all the subroutines. The module and the main program compile just fine. However, if I try to use one of the variables from the module in the subroutine I get the following compiler error:
print *,ierr
1
Error: Name 'ierr' at (1) is an ambiguous reference to 'ierr' from current program unit
Any tips to resolve this issue would be very helpful. I could manually declare all the variables in the main program and all the subroutines (this is how I did it before and it works fine). However, my program is growing and for efficiency reasons I would really like to have all the variable declarations in one single file.
Kind regards,
Steven
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/ms-tnef
Size: 4823 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20110726/efea8d4e/attachment.bin>
More information about the petsc-users
mailing list