[petsc-users] compile fortran module with PETSc

Barry Smith bsmith at mcs.anl.gov
Sat Apr 2 17:27:46 CDT 2016


   If you include any files such as petscmat.h  in the module then you do not need to include them again in the function, but files that end in def.h such as petscmatdef.h may need to be included in both the module and the function. In other words if you include petsc.h in your module then just include in your function files of the form petsc*def.h



   Barry

> On Apr 2, 2016, at 5:20 PM, Josh Lo <ysjosh.lo at gmail.com> wrote:
> 
> Hi,
> 
> I am trying to compile my main source code with module.
> I need PETSc in both main code and module, so I include the header file in both.
> it gives me some error when compiling.
> The error is:
> 
> src/main.F:2.9:
> 
> 
> 
>       use fmodule                                                          
> 
>          2
> 
> Error: Symbol 'mpi_source' at (1) conflicts with symbol from module 'fmodule', use-associated at (2)
> 
> /Users/XXXXXXX/Desktop/project/petsc/petsc_3.6.3_install/include/mpif.h:10:30:
> 
> 
> 
>         PARAMETER (MPI_SOURCE=3,MPI_TAG=4,MPI_ERROR=5)
> 
>                               1
> 
> Error: Cannot change attributes of USE-associated symbol mpi_source at (1)
> 
> 
> 
> 
> it goes on and on, most relates to MPI.
> 
> my main source code is like:
> 
> program main
> USE fmodule
> implicit none
> #include "petsc/finclude/petsc.h"
> 
> .......
> 
> 
> end program main
> 
> the module:
> 
> module fmodule
> #include "petsc/finclude/petsc.h"
>  
> ......
> 
> end module fmodule
> 
> if the I don't include the header file in module, then it is no error,
> but I do need petsc in my module.
> 
> How can I solve this problem?
> 
> 
> Thanks,
> Lo
> 



More information about the petsc-users mailing list