xref: /petsc/src/sys/tests/ex23.c (revision 5becb6a3a7fe6fe66ca978502f4679a4b24b29fc)
1 
2 static char help[] = "Tests string options with spaces";
3 
4 #include <petscsys.h>
5 
6 int main(int argc,char **argv)
7 {
8   PetscBool      ts_view       = PETSC_FALSE;
9   PetscInt       ts_max_steps  = 0, snes_max_it = 0;
10   PetscReal      ts_max_time = 0.;
11   PetscBool      foo_view       = PETSC_FALSE;
12   PetscInt       foo_max_steps  = 0, bar_max_it = 0;
13   PetscReal      foo_max_time = 0.;
14 
15   PetscCall(PetscInitialize(&argc,&argv,NULL,help));
16   PetscCall(PetscOptionsGetBool(NULL,0,"-ts_view",&ts_view,NULL));
17   PetscCall(PetscOptionsGetReal(NULL,0,"-ts_max_time",&ts_max_time,NULL));
18   PetscCall(PetscOptionsGetInt(NULL,0,"-ts_max_steps",&ts_max_steps,NULL));
19   PetscCall(PetscOptionsGetBool(NULL,0,"-foo_view",&foo_view,NULL));
20   PetscCall(PetscOptionsGetReal(NULL,0,"-foo_max_time",&foo_max_time,NULL));
21   PetscCall(PetscOptionsGetInt(NULL,0,"-foo_max_steps",&foo_max_steps,NULL));
22   PetscCall(PetscOptionsGetInt(NULL,0,"-snes_max_it",&snes_max_it,NULL));
23   PetscCall(PetscOptionsGetInt(NULL,0,"-bar_max_it",&bar_max_it,NULL));
24   PetscCall(PetscPrintf(PETSC_COMM_WORLD,"-ts_view = %s\n-ts_max_time = %f\n-ts_max_steps = %" PetscInt_FMT "\n-snes_max_it = %" PetscInt_FMT "\n",ts_view ? "true" : "false",(double)ts_max_time,ts_max_steps,snes_max_it));
25   PetscCall(PetscFinalize());
26   return 0;
27 }
28 
29 /*TEST
30 
31    test:
32       args: -options_file_yaml ex23options
33       localrunfiles: ex23options
34 
35    test:
36       suffix: string
37       args: -options_string_yaml "
38         foo: &foo
39           view: true
40           max: &foomax
41             steps: 3
42             time: 1.4
43         bar: &bar
44           max_it: 5
45         ts:
46           <<: *foo
47           max:
48             <<: *foomax
49             steps: 10
50         snes: *bar"
51 
52 TEST*/
53