[petsc-users] Cannot convert error

Barry Smith bsmith at mcs.anl.gov
Wed Sep 19 09:49:08 CDT 2012


On Sep 19, 2012, at 8:12 AM, Eduardo <erocha.ssa at gmail.com> wrote:

> Well, that is true if you develop the whole code yourself. But what if
> you have to use some third-party code that uses an older version of
> Petsc?? The problem is that my own code uses Petsc and some library
> that also uses Petsc (but an older version). You cannot rule out this
> possibility.

   Yes, that is a problem. Hence we do provide the macros to make it as easy as possible to support multiple versions. But we only recommend doing it when you have to.

    Barry

> 
> Eduardo
> 
> On Wed, Sep 19, 2012 at 9:55 AM, Barry Smith <bsmith at mcs.anl.gov> wrote:
>> 
>> On Sep 19, 2012, at 6:49 AM, Jed Brown <jedbrown at mcs.anl.gov> wrote:
>> 
>>> On Wed, Sep 19, 2012 at 6:25 AM, Eduardo <erocha.ssa at gmail.com> wrote:
>>> Is there a macro I can get the Petsc release? I'd like to link my code
>>> with libraries that are using a old version of Petsc. However, in the
>>> future these libraries may change to a newer version. So I want to
>>> write my code with ifdefs so that I can change from one version to the
>>> other easily.
>>> 
>>> See include/petscversion.h
>>> 
>>> Starting in petsc-3.3, there are convenience macros PETSC_VERSION_LT() and PETSC_VERSION_LE(). You can add to your headers:
>>> 
>>> #if !defined(PETSC_VERSION_LT)
>>> #  define PETSC_VERSION_LT (... copy from petscversion.h)
>>> #endif
>>> 
>>> then in your source,
>>> 
>>> #if PETSC_VERSION_LE(3,3,0) /* last version doing it the old way */
>>>  the old way
>>> #else
>>>  the new way
>>> #endif
>> 
>>  Since PETSc is user installable we don't recommend taking this route. We recommend just always developing and user your code with the latest PETSc release.
>> 
>>    Barry
>> 



More information about the petsc-users mailing list