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