xref: /petsc/src/sys/objects/version.c (revision 95452b02e12c0ee11232c7ff2b24b568a8e07e43)
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 
1327710113SBarry Smith     Fortran Note:
1427710113SBarry Smith     This routine is not supported in Fortran.
1527710113SBarry Smith 
168cf9f3d7SBarry Smith     For doing runtime checking off supported versions we recommend using PetscGetVersionNumber() instead of this routine.
178cf9f3d7SBarry Smith 
1827710113SBarry Smith     Developer Note: The version information is also listed in
1927710113SBarry Smith $    src/docs/tex/manual/intro.tex,
2027710113SBarry Smith $    src/docs/tex/manual/manual.tex.
2127710113SBarry Smith $    src/docs/website/index.html.
2227710113SBarry Smith 
235f309d01SBarry Smith .seealso: PetscGetProgramName(), PetscGetVersionNumber()
2427710113SBarry Smith 
2527710113SBarry Smith @*/
2627710113SBarry Smith 
2727710113SBarry Smith PetscErrorCode PetscGetVersion(char version[], size_t len)
2827710113SBarry Smith {
2927710113SBarry Smith   PetscErrorCode ierr;
308cf9f3d7SBarry Smith 
318cf9f3d7SBarry Smith   PetscFunctionBegin;
3227710113SBarry Smith #if (PETSC_VERSION_RELEASE == 1)
33e4643290SSatish Balay   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);
3427710113SBarry Smith #else
357078edc9SSatish Balay   ierr = PetscSNPrintf(version,len,"Petsc Development GIT revision: %s  GIT Date: %s",PETSC_VERSION_GIT, PETSC_VERSION_DATE_GIT);CHKERRQ(ierr);
3627710113SBarry Smith #endif
3727710113SBarry Smith   PetscFunctionReturn(0);
3827710113SBarry Smith }
3927710113SBarry Smith 
405f309d01SBarry Smith /*@C
415f309d01SBarry Smith     PetscGetVersionNumber - Gets the PETSc version information from the library
425f309d01SBarry Smith 
435f309d01SBarry Smith     Not collective
445f309d01SBarry Smith 
455f309d01SBarry Smith     Output Parameter:
465f309d01SBarry Smith +   major - the major version (optional, pass NULL if not requested)
475f309d01SBarry Smith .   minor - the minor version (optional, pass NULL if not requested)
485f309d01SBarry Smith .   subminor - the subminor version (patch number)  (optional, pass NULL if not requested)
495f309d01SBarry Smith -   release - indicates the library is from a release, not random git repository  (optional, pass NULL if not requested)
505f309d01SBarry Smith 
515f309d01SBarry Smith     Level: developer
525f309d01SBarry Smith 
53*95452b02SPatrick Sanan     Notes:
54*95452b02SPatrick Sanan     The C macros PETSC_VERSION_MAJOR, PETSC_VERSION_MINOR, PETSC_VERSION_SUBMINOR, PETSC_VERSION_RELEASE provide the information at
555f309d01SBarry Smith        compile time. This can be used to confirm that the shared library being loaded at runtime has the appropriate version updates.
565f309d01SBarry Smith 
578cf9f3d7SBarry Smith        This function can be called before PetscInitialize()
588cf9f3d7SBarry Smith 
598cf9f3d7SBarry Smith .seealso: PetscGetProgramName(), PetscGetVersion(), PetscInitialize()
605f309d01SBarry Smith 
615f309d01SBarry Smith @*/
625f309d01SBarry Smith PetscErrorCode PetscGetVersionNumber(PetscInt *major, PetscInt *minor, PetscInt *subminor,PetscInt *release)
635f309d01SBarry Smith {
645f309d01SBarry Smith   if (major) *major = PETSC_VERSION_MAJOR;
655f309d01SBarry Smith   if (minor) *minor = PETSC_VERSION_MINOR;
665f309d01SBarry Smith   if (subminor) *subminor = PETSC_VERSION_SUBMINOR;
675f309d01SBarry Smith   if (release) *release = PETSC_VERSION_RELEASE;
688cf9f3d7SBarry Smith   return 0;
695f309d01SBarry Smith }
7027710113SBarry Smith 
71