1 static char help[] = "Tests PetscOptionsCreateViewer() via checking output of PetscViewerASCIIPrintf().\n\n";
2
3 #include <petscviewer.h>
4
main(int argc,char ** args)5 int main(int argc, char **args)
6 {
7 PetscViewer viewer;
8 PetscViewerFormat format;
9 PetscBool isascii;
10
11 PetscFunctionBeginUser;
12 PetscCall(PetscInitialize(&argc, &args, NULL, help));
13 PetscCall(PetscOptionsCreateViewer(PETSC_COMM_WORLD, NULL, NULL, "-myviewer", &viewer, &format, NULL));
14 PetscCall(PetscObjectTypeCompare((PetscObject)viewer, PETSCVIEWERASCII, &isascii));
15 if (isascii) {
16 PetscCall(PetscViewerPushFormat(viewer, format));
17 PetscCall(PetscViewerASCIIPrintf(viewer, "Testing PetscViewerASCIIPrintf %d\n", 0));
18 PetscCall(PetscViewerPopFormat(viewer));
19 PetscCall(PetscViewerDestroy(&viewer));
20 PetscCall(PetscOptionsCreateViewer(PETSC_COMM_WORLD, NULL, NULL, "-myviewer", &viewer, &format, NULL));
21 PetscCall(PetscViewerPushFormat(viewer, format));
22 PetscCall(PetscViewerASCIIPrintf(viewer, "Testing PetscViewerASCIIPrintf %d\n", 1));
23 PetscCall(PetscViewerPopFormat(viewer));
24 }
25 PetscCall(PetscViewerDestroy(&viewer));
26 PetscCall(PetscFinalize());
27 return 0;
28 }
29
30 /*TEST
31
32 test:
33 args: -myviewer ascii:ex4w1.tmp
34 filter: cat ex4w1.tmp
35 output_file: output/ex4w.out
36
37 test:
38 suffix: 2
39 args: -myviewer ascii:ex4w2.tmp::
40 filter: cat ex4w2.tmp
41 output_file: output/ex4w.out
42
43 test:
44 suffix: 3
45 args: -myviewer ascii:ex4w3.tmp::write
46 filter: cat ex4w3.tmp
47 output_file: output/ex4w.out
48
49 test:
50 suffix: 4
51 args: -myviewer ascii:ex4a1.tmp::append
52 filter: cat ex4a1.tmp
53 output_file: output/ex4a.out
54
55 test:
56 suffix: daos
57 requires: !windows_compilers
58 args: -myviewer ascii:daos:ex4a1.tmp::append
59 filter: cat daos:ex4a1.tmp
60 output_file: output/ex4a.out
61
62 TEST*/
63