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