xref: /petsc/src/sys/tutorials/ex17.c (revision 66af8762ec03dbef0e079729eb2a1734a35ed7ff)
1 static char help[] = "Demonstrates PetscGetVersonNumber().\n\n";
2 
3 #include <petscsys.h>
4 int main(int argc, char **argv)
5 {
6   char     version[128];
7   PetscInt major, minor, subminor;
8 
9   /*
10     Every PETSc routine should begin with the PetscInitialize() routine.
11     argc, argv - These command line arguments are taken to extract the options
12                  supplied to PETSc and options supplied to MPI.
13     help       - When PETSc executable is invoked with the option -help,
14                  it prints the various options that can be applied at
15                  runtime.  The user can use the "help" variable place
16                  additional help messages in this printout.
17   */
18   PetscFunctionBeginUser;
19   PetscCall(PetscInitialize(&argc, &argv, (char *)0, help));
20   PetscCall(PetscGetVersion(version, sizeof(version)));
21 
22   PetscCall(PetscGetVersionNumber(&major, &minor, &subminor, NULL));
23   PetscCheck(major == PETSC_VERSION_MAJOR, PETSC_COMM_SELF, PETSC_ERR_PLIB, "Library major %d does not equal include %d", (int)major, PETSC_VERSION_MAJOR);
24   PetscCheck(minor == PETSC_VERSION_MINOR, PETSC_COMM_SELF, PETSC_ERR_PLIB, "Library minor %d does not equal include %d", (int)minor, PETSC_VERSION_MINOR);
25   PetscCheck(subminor == PETSC_VERSION_SUBMINOR, PETSC_COMM_SELF, PETSC_ERR_PLIB, "Library subminor %d does not equal include %d", (int)subminor, PETSC_VERSION_SUBMINOR);
26 
27   PetscCall(PetscFinalize());
28   return 0;
29 }
30 
31 /*TEST
32 
33    test:
34 
35 TEST*/
36