xref: /petsc/src/sys/objects/version.c (revision cf53795e253c8c9d9d0fbcef4cffd37d916c4e81)
127710113SBarry Smith #include <petscsys.h>
227710113SBarry Smith /*@C
327710113SBarry Smith     PetscGetVersion - Gets the PETSc version information in a string.
427710113SBarry Smith 
5*cf53795eSBarry Smith     Not Collective; No Fortran Support
6*cf53795eSBarry Smith 
727710113SBarry Smith     Input Parameter:
827710113SBarry Smith .   len - length of the string
927710113SBarry Smith 
1027710113SBarry Smith     Output Parameter:
1127710113SBarry Smith .   version - version string
1227710113SBarry Smith 
1327710113SBarry Smith     Level: developer
1427710113SBarry Smith 
15811af0c4SBarry Smith     Note:
16811af0c4SBarry Smith     For doing runtime checking of supported versions we recommend using `PetscGetVersionNumber()` instead of this routine.
17811af0c4SBarry Smith 
18db781477SPatrick Sanan .seealso: `PetscGetProgramName()`, `PetscGetVersionNumber()`
1927710113SBarry Smith @*/
2027710113SBarry Smith 
21d71ae5a4SJacob Faibussowitsch PetscErrorCode PetscGetVersion(char version[], size_t len)
22d71ae5a4SJacob Faibussowitsch {
238cf9f3d7SBarry Smith   PetscFunctionBegin;
2427710113SBarry Smith #if (PETSC_VERSION_RELEASE == 1)
259566063dSJacob Faibussowitsch   PetscCall(PetscSNPrintf(version, len, "Petsc Release Version %d.%d.%d, %s ", PETSC_VERSION_MAJOR, PETSC_VERSION_MINOR, PETSC_VERSION_SUBMINOR, PETSC_VERSION_DATE));
2627710113SBarry Smith #else
279566063dSJacob Faibussowitsch   PetscCall(PetscSNPrintf(version, len, "Petsc Development GIT revision: %s  GIT Date: %s", PETSC_VERSION_GIT, PETSC_VERSION_DATE_GIT));
2827710113SBarry Smith #endif
2927710113SBarry Smith   PetscFunctionReturn(0);
3027710113SBarry Smith }
3127710113SBarry Smith 
325f309d01SBarry Smith /*@C
335f309d01SBarry Smith     PetscGetVersionNumber - Gets the PETSc version information from the library
345f309d01SBarry Smith 
355f309d01SBarry Smith     Not collective
365f309d01SBarry Smith 
37d8d19677SJose E. Roman     Output Parameters:
385f309d01SBarry Smith +   major - the major version (optional, pass NULL if not requested)
395f309d01SBarry Smith .   minor - the minor version (optional, pass NULL if not requested)
405f309d01SBarry Smith .   subminor - the subminor version (patch number)  (optional, pass NULL if not requested)
415f309d01SBarry Smith -   release - indicates the library is from a release, not random git repository  (optional, pass NULL if not requested)
425f309d01SBarry Smith 
435f309d01SBarry Smith     Level: developer
445f309d01SBarry Smith 
4595452b02SPatrick Sanan     Notes:
46811af0c4SBarry Smith     The C macros `PETSC_VERSION_MAJOR`, `PETSC_VERSION_MINOR`, `PETSC_VERSION_SUBMINOR`, `PETSC_VERSION_RELEASE` provide the information at
475f309d01SBarry Smith     compile time. This can be used to confirm that the shared library being loaded at runtime has the appropriate version updates.
485f309d01SBarry Smith 
49811af0c4SBarry Smith     This function can be called before `PetscInitialize()`
508cf9f3d7SBarry Smith 
51db781477SPatrick Sanan .seealso: `PetscGetProgramName()`, `PetscGetVersion()`, `PetscInitialize()`
525f309d01SBarry Smith @*/
53d71ae5a4SJacob Faibussowitsch PetscErrorCode PetscGetVersionNumber(PetscInt *major, PetscInt *minor, PetscInt *subminor, PetscInt *release)
54d71ae5a4SJacob Faibussowitsch {
555f309d01SBarry Smith   if (major) *major = PETSC_VERSION_MAJOR;
565f309d01SBarry Smith   if (minor) *minor = PETSC_VERSION_MINOR;
575f309d01SBarry Smith   if (subminor) *subminor = PETSC_VERSION_SUBMINOR;
585f309d01SBarry Smith   if (release) *release = PETSC_VERSION_RELEASE;
598cf9f3d7SBarry Smith   return 0;
605f309d01SBarry Smith }
61