[petsc-users] [Fortran] subroutines inside modules?

Barry Smith bsmith at mcs.anl.gov
Thu Sep 30 10:01:26 CDT 2010


On Sep 30, 2010, at 9:31 AM, Leo van Kampenhout wrote:

> Hi all,
> 
> since it is mandatory to declare all subroutines as "external" in Fortran, is it possible for Modules to have subroutines? I'm unable to declare the subroutine external inside the module itself, nor in the program which is using it.

   What happens when you try to declare it external in the "program which is using it" (I assume you mean subroutine that is using it).

   Barry


> Not declaring it external at all results in the following compilation error:
> 
> /net/users/csg/csg4035/master/workdir/src/main.F:97: undefined reference to `__grid_MOD_readgrid'
> 
> (the module is here is named "grid", the subroutine "readgrid" )
> 
> Thanks,
> Leo
> 



More information about the petsc-users mailing list