xref: /petsc/src/sys/objects/version.c (revision d71ae5a4db6382e7f06317b8d368875286fe9008)
127710113SBarry Smith #include <petscsys.h>
227710113SBarry Smith /*@C
327710113SBarry Smith     PetscGetVersion - Gets the PETSc version information in a string.
427710113SBarry Smith 
527710113SBarry Smith     Input Parameter:
627710113SBarry Smith .   len - length of the string
727710113SBarry Smith 
827710113SBarry Smith     Output Parameter:
927710113SBarry Smith .   version - version string
1027710113SBarry Smith 
1127710113SBarry Smith     Level: developer
1227710113SBarry Smith 
13811af0c4SBarry Smith     Note:
14811af0c4SBarry Smith     For doing runtime checking of supported versions we recommend using `PetscGetVersionNumber()` instead of this routine.
15811af0c4SBarry Smith 
1627710113SBarry Smith     Fortran Note:
1727710113SBarry Smith     This routine is not supported in Fortran.
1827710113SBarry Smith 
19db781477SPatrick Sanan .seealso: `PetscGetProgramName()`, `PetscGetVersionNumber()`
2027710113SBarry Smith @*/
2127710113SBarry Smith 
22*d71ae5a4SJacob Faibussowitsch PetscErrorCode PetscGetVersion(char version[], size_t len)
23*d71ae5a4SJacob Faibussowitsch {
248cf9f3d7SBarry Smith   PetscFunctionBegin;
2527710113SBarry Smith #if (PETSC_VERSION_RELEASE == 1)
269566063dSJacob Faibussowitsch   PetscCall(PetscSNPrintf(version, len, "Petsc Release Version %d.%d.%d, %s ", PETSC_VERSION_MAJOR, PETSC_VERSION_MINOR, PETSC_VERSION_SUBMINOR, PETSC_VERSION_DATE));
2727710113SBarry Smith #else
289566063dSJacob Faibussowitsch   PetscCall(PetscSNPrintf(version, len, "Petsc Development GIT revision: %s  GIT Date: %s", PETSC_VERSION_GIT, PETSC_VERSION_DATE_GIT));
2927710113SBarry Smith #endif
3027710113SBarry Smith   PetscFunctionReturn(0);
3127710113SBarry Smith }
3227710113SBarry Smith 
335f309d01SBarry Smith /*@C
345f309d01SBarry Smith     PetscGetVersionNumber - Gets the PETSc version information from the library
355f309d01SBarry Smith 
365f309d01SBarry Smith     Not collective
375f309d01SBarry Smith 
38d8d19677SJose E. Roman     Output Parameters:
395f309d01SBarry Smith +   major - the major version (optional, pass NULL if not requested)
405f309d01SBarry Smith .   minor - the minor version (optional, pass NULL if not requested)
415f309d01SBarry Smith .   subminor - the subminor version (patch number)  (optional, pass NULL if not requested)
425f309d01SBarry Smith -   release - indicates the library is from a release, not random git repository  (optional, pass NULL if not requested)
435f309d01SBarry Smith 
445f309d01SBarry Smith     Level: developer
455f309d01SBarry Smith 
4695452b02SPatrick Sanan     Notes:
47811af0c4SBarry Smith     The C macros `PETSC_VERSION_MAJOR`, `PETSC_VERSION_MINOR`, `PETSC_VERSION_SUBMINOR`, `PETSC_VERSION_RELEASE` provide the information at
485f309d01SBarry Smith     compile time. This can be used to confirm that the shared library being loaded at runtime has the appropriate version updates.
495f309d01SBarry Smith 
50811af0c4SBarry Smith     This function can be called before `PetscInitialize()`
518cf9f3d7SBarry Smith 
52db781477SPatrick Sanan .seealso: `PetscGetProgramName()`, `PetscGetVersion()`, `PetscInitialize()`
535f309d01SBarry Smith @*/
54*d71ae5a4SJacob Faibussowitsch PetscErrorCode PetscGetVersionNumber(PetscInt *major, PetscInt *minor, PetscInt *subminor, PetscInt *release)
55*d71ae5a4SJacob Faibussowitsch {
565f309d01SBarry Smith   if (major) *major = PETSC_VERSION_MAJOR;
575f309d01SBarry Smith   if (minor) *minor = PETSC_VERSION_MINOR;
585f309d01SBarry Smith   if (subminor) *subminor = PETSC_VERSION_SUBMINOR;
595f309d01SBarry Smith   if (release) *release = PETSC_VERSION_RELEASE;
608cf9f3d7SBarry Smith   return 0;
615f309d01SBarry Smith }
62