[petsc-users] KSP in common blocks

Smith, Barry F. bsmith at mcs.anl.gov
Mon Mar 26 10:29:31 CDT 2018


   Unfortunately due to a "feature" of Fortran you can no longer store PETSc objects in common blocks; you can use modules, for example, if you need to access the objects from multiple routines without passing them as arguments.

    Barry

   We changed our examples to reflect this problem.

   Yes some compilers allow them in common blocks but others do not. 

> On Mar 26, 2018, at 7:15 AM, Sanjay Govindjee <s_g at berkeley.edu> wrote:
> 
> In upgrading to PETSc v3.8.x, we are seeing a compilation error with gfortran (version 6.2.0, users report the same problem with version 7.x).   The compile error is thrown when, say, type KSP variables are put in common blocks; we do not see any errors with this construct
> when using ifort (Intel compiler version 14.0.3).
> 
> The compile error is easily reproduced.  For example in src/ksp/ksp/examples/tutorials, below the line
> 
>     KSP ksp
> 
> just add the line
> 
>     common /mycom/ ksp
> 
> gfortran then complains with:
> 
>        KSP             ksp
>                                 1
> Error: Derived type variable ‘ksp’ in COMMON at (1) has neither the SEQUENCE nor the BIND(C) attribute
> 
> ifort is perfectly happy and produces executable code.  Any ideas on how to fix this problem?
> 
> -sanjay
> 



More information about the petsc-users mailing list