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