adding macro in petscversion.h

Satish Balay balay at mcs.anl.gov
Mon Dec 1 09:51:37 CST 2008


On Mon, 1 Dec 2008, Lisandro Dalcin wrote:

> It it is not too late, I would like to add the following macro in petscversion.h
> 
> #if !defined(PETSC_VERSION_)

I think there should not be this #if test. [Its more appropriate for
petsc4py to check for this flag and redefine for old petsc versions].

> #define PETSC_VERSION_(MAJOR,MINOR,SUBMINOR)   \
>        (PETSC_VERSION_MAJOR    == MAJOR    && \
> 	PETSC_VERSION_MINOR    == MINOR    && \
> 	PETSC_VERSION_SUBMINOR == SUBMINOR && \
> 	PETSC_VERSION_RELEASE  == 1)
> #endif
> 
> In petsc4py, I have to test the version in many places in order to
> provide backward compatibility with previous releases. The new macro
> is really handy for this,
> 
> #if PETSC_VERSION_(2,3,2)
> /* code for the 2.3.2 case */
> #elif PETSC_VERSION_(2,3,3)
> /* code for the 2.3.2 case */
> #elif PETSC_VERSION_(2,4,0)
> /* code for latest release (once done)*/
> #else
> /* code for (future) petsc-dev
> #endif
> 
> What do you think? Should I remove the last "_" in "PETSC_VERSION_".
> Better name?

Barry likes the _ version of the names. They cause problems with
fortran interface - so I don't prefer it. However in this case - this
macro remains a cpp directive - so no fortran interface issue - so
this name is fine by me..

So - its ok by me - to push this new macro..

thanks,
Satish

> 
> Of course, it I want to use this for 2.3.2/2.3.3 releases, I would
> need to manage that in my code, but from 2.4.0 and above, that would
> be already defined for user convenience needing to target the same
> code for multiple PETSc releases.
> 
> 
> 




More information about the petsc-dev mailing list