xref: /petsc/src/sys/tests/ex5.c (revision 40badf4fbc550ac1f60bd080eaff6de6d55b946d)
1 
2 static char help[] = "Tests retrieving unused PETSc options.\n\n";
3 
4 #include <petscsys.h>
5 
6 int main(int argc,char **argv)
7 {
8   PetscErrorCode ierr;
9   PetscInt       i,N,M;
10   char           **names,**values;
11   PetscBool      set;
12 
13   ierr = PetscInitialize(&argc,&argv,(char*)0,help);if (ierr) return ierr;
14 
15   CHKERRQ(PetscOptionsGetInt(NULL,NULL,"-get_an_integer",&M,&set));
16   if (set) CHKERRQ(PetscPrintf(PETSC_COMM_WORLD,"Option used: name:-get_an_integer value: %" PetscInt_FMT "\n",M));
17   CHKERRQ(PetscOptionsLeftGet(NULL,&N,&names,&values));
18   for (i=0; i<N; i++) {
19     if (values[i]) {
20       CHKERRQ(PetscPrintf(PETSC_COMM_WORLD,"Option left: name:-%s value: %s\n",names[i],values[i]));
21     } else {
22       CHKERRQ(PetscPrintf(PETSC_COMM_WORLD,"Option left: name:-%s (no value)\n",names[i]));
23     }
24   }
25   CHKERRQ(PetscOptionsLeftRestore(NULL,&N,&names,&values));
26 
27   ierr = PetscFinalize();
28   return ierr;
29 }
30 
31 /*TEST
32 
33    test:
34       suffix: debug
35       requires: defined(PETSC_USE_DEBUG)
36       args: -unused_petsc_option_1 -unused_petsc_option_2 -get_an_integer 10 -options_left no
37       filter: egrep -v \(malloc_dump\|options_left\|nox\|vecscatter_mpi1\|saws_port_auto_select\|saws_port_auto_select_silent\)
38 
39    test:
40       suffix: opt
41       requires: !defined(PETSC_USE_DEBUG)
42       args: -checkstack -unused_petsc_option_1 -unused_petsc_option_2 -get_an_integer 10 -options_left no
43       filter: egrep -v \(malloc_dump\|options_left\|nox\|vecscatter_mpi1\|saws_port_auto_select\|saws_port_auto_select_silent\)
44 
45  TEST*/
46