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