[petsc-users] PETSC_VERSION_GT doesn't behave as I would have expected

Eike Mueller em459 at bath.ac.uk
Wed Jul 1 12:22:17 CDT 2026


Dear Stefano,

I’m using the PETSc main branch since I’ve done a developer install of Firedrake. The code I use relies on PETSC_VERSION_GT to support different PETSc versions. But Nils has fixed this now, by simply requiring a sufficiently high PETSc version in CMake. With that, there is no longer any need for PETSC_VERSION_GT in the source code.

All the best,

Eike

On 1 Jul 2026, at 12:10, Stefano Zampini <stefano.zampini at gmail.com> wrote:

CAUTION:  This email came from outside of the University. To keep your account safe, only click on links and open attachments if you know the person who sent the email, or you expected to receive this communication.



Thank you for the prompt reply! So does that mean that in this case PETSC_VERSION_GT (or any of the related functions) shouldn’t be used, since PETSc assumes that I’ll keep track of versions and PETSC_VERSION_MAJOR etc. are essentially meaningless?

They are not meaningless, as packages using PETSc use them to distinguish between software releases.
If you instead work with the development version of PETSc (i.e. git clone + git checkout main + branch off main), then yes, they are in some sense meaningless, because the model behind is that main is always ahead of any release

Maybe this model can be tweaked a bit and assume that main cannot be ahead of future major releases, but it is not clear to me if it will buy us anything.

What is your specific use case?


All the best,

Eike

On 1 Jul 2026, at 11:57, Stefano Zampini <stefano.zampini at gmail.com<mailto:stefano.zampini at gmail.com>> wrote:

You don't often get email from stefano.zampini at gmail.com<mailto:stefano.zampini at gmail.com>. Learn why this is important<https://urldefense.us/v3/__https://aka.ms/LearnAboutSenderIdentification__;!!G_uCfscf7eWS!YQTN7SVBlprILJigcY_ch3FjaIk5ZO3_qLH6wPNmJH5yxvCkknQ0RViS6w1xHPdd34yIaJJnrvSAcvBpD0hd5w$ >
CAUTION:  This email came from outside of the University. To keep your account safe, only click on links and open attachments if you know the person who sent the email, or you expected to receive this communication.

Dear Eike

PETSC_VERSION_RELEASE is 1 only for tarballs or if you track/branched off the release branch
Otherwise, if you branched off main, it is 0.
The model behind is that new developments won't need to care about older versions.
This means that, if you use a development version of PETSc obtained from git, we assume you'll keep updating it.
Does it make sense to you?

Il giorno mer 1 lug 2026 alle ore 11:51 Eike Mueller via petsc-users <petsc-users at mcs.anl.gov<mailto:petsc-users at mcs.anl.gov>> ha scritto:
Dear PETSc developers,

I’m using a code which checks

#if PETSC_VERSION_GT(3, 24, 5)
   // do something
#endif

For my PETSc installation I have:

#define PETSC_VERSION_RELEASE    0
#define PETSC_VERSION_MAJOR      3
#define PETSC_VERSION_MINOR      24
#define PETSC_VERSION_SUBMINOR   4

Looking at petscversion.h, I believe that PETSC_VERSION_GT(3, 24, 5) will always evaluate to true since PETSC_VERSION_RELEASE==0. This confused me, since there is no mention of PETSC_VERSION_RELEASE in the documentation at https://urldefense.us/v3/__https://petsc.org/release/manual/versionchecking/__;!!G_uCfscf7eWS!YQTN7SVBlprILJigcY_ch3FjaIk5ZO3_qLH6wPNmJH5yxvCkknQ0RViS6w1xHPdd34yIaJJnrvSAcvAuTOnbSg$ <https://urldefense.us/v3/__https://petsc.org/release/manual/versionchecking/__;!!G_uCfscf7eWS!fqRtEQeeX09t_o3xjWfEQaGE6FLfl_LQJL5iDNuMqoG9vC1TBTGaRNcGyGudQlPsSk2TVNBaw04iNpZYFiAKbA$>

Is this intended behaviour? Is there a good way of checking the version irrespective of RELEASE? I can of course always copy and modify the definition of PETSC_VERSION_LT and remove the PETSC_VERSION_RELEASE == 1 bit, but that’s probably not the best solution.

Thanks a lot,

Eike


--
Stefano



--
Stefano

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20260701/4c98d06b/attachment.html>


More information about the petsc-users mailing list