xref: /petsc/src/sys/objects/version.c (revision 5f309d014d30c8e30ef8d484fee079cd79b2cbfc)
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     Developer Note: The version information is also listed in
17 $    src/docs/tex/manual/intro.tex,
18 $    src/docs/tex/manual/manual.tex.
19 $    src/docs/website/index.html.
20 
21 .seealso: PetscGetProgramName(), PetscGetVersionNumber()
22 
23 @*/
24 
25 #undef __FUNCT__
26 #define __FUNCT__ "PetscGetVersion"
27 PetscErrorCode PetscGetVersion(char version[], size_t len)
28 {
29   PetscErrorCode ierr;
30 #if (PETSC_VERSION_RELEASE == 1)
31   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);
32 #else
33   ierr = PetscSNPrintf(version,len,"Petsc Development GIT revision: %s  GIT Date: %s",PETSC_VERSION_GIT, PETSC_VERSION_DATE_GIT);CHKERRQ(ierr);
34 #endif
35   PetscFunctionReturn(0);
36 }
37 
38 #undef __FUNCT__
39 #define __FUNCT__ "PetscGetVersionNumber"
40 /*@C
41     PetscGetVersionNumber - Gets the PETSc version information from the library
42 
43     Not collective
44 
45     Output Parameter:
46 +   major - the major version (optional, pass NULL if not requested)
47 .   minor - the minor version (optional, pass NULL if not requested)
48 .   subminor - the subminor version (patch number)  (optional, pass NULL if not requested)
49 -   release - indicates the library is from a release, not random git repository  (optional, pass NULL if not requested)
50 
51     Level: developer
52 
53     Notes: The C macros PETSC_VERSION_MAJOR, PETSC_VERSION_MINOR, PETSC_VERSION_SUBMINOR, PETSC_VERSION_RELEASE provide the information at
54        compile time. This can be used to confirm that the shared library being loaded at runtime has the appropriate version updates.
55 
56 .seealso: PetscGetProgramName(), PetscGetVersion()
57 
58 @*/
59 PetscErrorCode PetscGetVersionNumber(PetscInt *major, PetscInt *minor, PetscInt *subminor,PetscInt *release)
60 {
61   PetscFunctionBegin;
62   if (major) *major = PETSC_VERSION_MAJOR;
63   if (minor) *minor = PETSC_VERSION_MINOR;
64   if (subminor) *subminor = PETSC_VERSION_SUBMINOR;
65   if (release) *release = PETSC_VERSION_RELEASE;
66   PetscFunctionReturn(0);
67 }
68 
69