1 #include <petscsys.h> 2 /*@C 3 PetscGetVersion - Gets the PETSc version information in a string. 4 5 Not Collective; No Fortran Support 6 7 Input Parameter: 8 . len - length of the string 9 10 Output Parameter: 11 . version - version string 12 13 Level: developer 14 15 Note: 16 For doing runtime checking of supported versions we recommend using `PetscGetVersionNumber()` instead of this routine. 17 18 .seealso: `PetscGetProgramName()`, `PetscGetVersionNumber()` 19 @*/ 20 PetscErrorCode PetscGetVersion(char version[], size_t len) 21 { 22 PetscFunctionBegin; 23 #if (PETSC_VERSION_RELEASE == 1) 24 PetscCall(PetscSNPrintf(version, len, "Petsc Release Version %d.%d.%d, %s ", PETSC_VERSION_MAJOR, PETSC_VERSION_MINOR, PETSC_VERSION_SUBMINOR, PETSC_VERSION_DATE)); 25 #else 26 PetscCall(PetscSNPrintf(version, len, "Petsc Development GIT revision: %s GIT Date: %s", PETSC_VERSION_GIT, PETSC_VERSION_DATE_GIT)); 27 #endif 28 PetscFunctionReturn(PETSC_SUCCESS); 29 } 30 31 /*@C 32 PetscGetVersionNumber - Gets the PETSc version information from the library 33 34 Not Collective 35 36 Output Parameters: 37 + major - the major version (optional, pass `NULL` if not requested) 38 . minor - the minor version (optional, pass `NULL` if not requested) 39 . subminor - the subminor version (patch number) (optional, pass `NULL` if not requested) 40 - release - indicates the library is from a release, not random git repository (optional, pass `NULL` if not requested) 41 42 Level: developer 43 44 Notes: 45 The C macros `PETSC_VERSION_MAJOR`, `PETSC_VERSION_MINOR`, `PETSC_VERSION_SUBMINOR`, `PETSC_VERSION_RELEASE` provide the information at 46 compile time. This can be used to confirm that the shared library being loaded at runtime has the appropriate version updates. 47 48 This function can be called before `PetscInitialize()` 49 50 .seealso: `PetscGetProgramName()`, `PetscGetVersion()`, `PetscInitialize()` 51 @*/ 52 PetscErrorCode PetscGetVersionNumber(PetscInt *major, PetscInt *minor, PetscInt *subminor, PetscInt *release) 53 { 54 if (major) *major = PETSC_VERSION_MAJOR; 55 if (minor) *minor = PETSC_VERSION_MINOR; 56 if (subminor) *subminor = PETSC_VERSION_SUBMINOR; 57 if (release) *release = PETSC_VERSION_RELEASE; 58 return PETSC_SUCCESS; 59 } 60