[petsc-users] Updating Fortran code to petsc 3.8

Satish Balay balay at mcs.anl.gov
Mon Oct 30 13:16:06 CDT 2017


On Mon, 30 Oct 2017, Randy Michael Churchill wrote:

> >
> >    Please clarify.
> >
> > 1) You can successfully update to 3.8 and compile and run the code?
> 
> I haven't updated all of the code to 3.8, I wanted to make sure there
> wasn't any tricks to maintain backwards compatibility before I change
> everything. I'm only in the process of changing several of the codebase's
> files, updating any "Amat = 0" statements or "if (Amat==0) then"
> statements, which do not compile with 3.8 (they need the specific
> PETSC_NULL_XXX instead of 0). When I make those changes, that section of
> the code compiles (btw, on NERSC Edison, with my own compiled petsc v3.8).
> 
> 
> >
> >
> 2) You do not have a way to support both 3.7 and 3.8 except by putting a
> > large number of #ifdef in the code?
> >
> If I have to change "Amat = 0" to "Amat = PETSC_NULL_MAT" for 3.8, and
> change all of the PETSC_NULL_OBJECT for 3.8, many of those PETSC_NULL_XXX
> references are not included in v3.7, correct? If not, and I want to keep
> backwards compatibility, everywhere there is a PETSC_NULL_OBJECT, I would
> have to do:
> #include <petscversion.h>
> #if PETSC_VERSION_GE(3,8,0)
> call MatNullSpaceCreate(comm, PETSC_TRUE, 0, PETSC_NULL_VEC, nullsp,ierr)
> #else
> call MatNullSpaceCreate(comm, PETSC_TRUE, 0, PETSC_NULL_OBJECT, nullsp,ierr)
> #endif
> 
> If this is the only way to upgrade our codebase to use petsc v3.8, thats
> fine, I just wanted to verify that there wasn't another way, which would be
> cleaner (e.g. perhaps creating an include file with all of the
> PETSC_NULL_XXX definitions which aren't in v3.7, and thus avoid many of
> these #if PETSC_VERSION statements).

Perhaps the following simple addtion will keep the 3.7 compatibility [for this case]

#if PETSC_VERSION_LT(3,8,0)
#define PETSC_NULL_VEC PETSC_NULL_OBJECT
#define PETSC_NULL_MAT PETSC_NULL_OBJECT
#endif

Satish


More information about the petsc-users mailing list