xref: /petsc/src/sys/tests/ex47.c (revision e6d3c4ed1c11b3b5c034a54a6d566a42f9afdff6)
1 static char help[] = "Example for PetscOptionsInsertFileYAML\n";
2 
3 #include <petscsys.h>
4 #include <petscviewer.h>
5 
6 int main(int argc, char **argv)
7 {
8   char      filename[PETSC_MAX_PATH_LEN];
9   PetscBool flg;
10 
11   PetscFunctionBeginUser;
12   PetscCall(PetscInitialize(&argc, &argv, NULL, help));
13 
14   PetscCall(PetscOptionsGetString(NULL, NULL, "-f", filename, sizeof(filename), &flg));
15   if (flg) PetscCall(PetscOptionsInsertFileYAML(PETSC_COMM_WORLD, NULL, filename, PETSC_TRUE));
16 
17   PetscCall(PetscOptionsGetString(NULL, NULL, "-yaml", filename, sizeof(filename), &flg));
18   if (flg) {
19     PetscBool monitor = PETSC_FALSE;
20 
21     PetscCall(PetscOptionsGetBool(NULL, NULL, "-monitor", &monitor, NULL));
22     if (monitor) PetscCall(PetscOptionsMonitorSet(PetscOptionsMonitorDefault, NULL, NULL));
23     PetscCall(PetscOptionsClear(NULL));
24     PetscCall(PetscOptionsInsertFileYAML(PETSC_COMM_WORLD, NULL, filename, PETSC_TRUE));
25   }
26 
27   PetscCall(PetscOptionsView(NULL, PETSC_VIEWER_STDOUT_WORLD));
28   PetscCall(PetscOptionsClear(NULL));
29   PetscCall(PetscFinalize());
30   return 0;
31 }
32 
33 /*TEST
34 
35    testset:
36      args: -options_left false
37      filter:  grep -E -v "(options_left|options_monitor)"
38      localrunfiles: petsc.yml
39 
40      test:
41         suffix: 1
42         args: -f petsc.yml
43 
44      test:
45         suffix: 2_file
46         output_file: output/ex47_2.out
47         args: -options_file_yaml petsc.yml
48 
49      test:
50         suffix: 2_string
51         output_file: output/ex47_2.out
52         args: -options_string_yaml "`cat petsc.yml`"
53 
54      test:
55         suffix: 2_auto
56         args: -options_monitor
57         args: -options_file ex47-yaml_tag
58         args: -options_file ex47-yaml_doc
59         localrunfiles: ex47-yaml_tag ex47-yaml_doc
60 
61      test:
62         suffix: 2_prefix
63         args: -options_monitor
64         args: -options_file ex47-opt.txt
65         args: -prefix_push p5_ -options_file ex47-opt.yml -prefix_pop
66         args: -prefix_push p5_ -options_file ex47-opt.yml:yaml -prefix_pop
67         args: -prefix_push p6_ -options_file_yaml ex47-opt.yml -prefix_pop
68         args: -prefix_push p7_ -options_string_yaml "`cat ex47-opt.yml`" -prefix_pop
69         args: -prefix_push p7_ -options_string_yaml "`cat ex47-opt.yml`" -prefix_pop
70         args: -prefix_push p8_ -options_string_yaml "`cat ex47-opt.yml`" -prefix_pop
71         args: -prefix_push p9_ -options_file ex47-opt.json -prefix_pop
72         localrunfiles: ex47-opt.txt ex47-opt.yml ex47-opt.json
73 
74    testset:
75      nsize: {{1 2}}
76 
77      test:
78         suffix: 3_empty
79         args: -yaml ex47-empty.yaml
80         localrunfiles: ex47-empty.yaml
81 
82      test:
83         suffix: 3_merge
84         args: -yaml ex47-merge.yaml -monitor
85         localrunfiles: ex47-merge.yaml
86 
87      test:
88         suffix: 3_options
89         args: -yaml ex47-options.yaml
90         localrunfiles: ex47-options.yaml
91 
92      test:
93         suffix: 3_include
94         args: -yaml ex47-include.yaml
95         localrunfiles: ex47-include.yaml ex47-empty.yaml ex47-options.yaml
96 
97      test:
98         suffix: 3_prefix
99         args: -yaml ex47-prefix.yaml
100         localrunfiles: ex47-prefix.yaml
101 
102      test:
103         suffix: 3_multidoc
104         args: -yaml ex47-multidoc.yaml
105         localrunfiles: ex47-multidoc.yaml
106 
107 TEST*/
108