Actual source code: ex4.c
petsc-3.10.5 2019-03-28
2: static char help[] = "Tests PetscOptionsGetViewer() via checking output of PetscViewerASCIIPrintf().\n\n";
4: #include <petscviewer.h>
6: int main(int argc,char **args)
7: {
8: PetscViewer viewer;
9: PetscErrorCode ierr;
10: PetscViewerFormat format;
11: PetscBool iascii;
13: PetscInitialize(&argc,&args,(char*)0,help);if (ierr) return ierr;
14: PetscOptionsGetViewer(PETSC_COMM_WORLD,NULL,"-myviewer",&viewer,&format,NULL);
15: PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&iascii);
16: if (iascii) {
17: PetscViewerPushFormat(viewer,format);
18: PetscViewerASCIIPrintf(viewer,"Testing PetscViewerASCIIPrintf %d\n", 0);
19: PetscViewerPopFormat(viewer);
20: PetscViewerDestroy(&viewer);
21: PetscOptionsGetViewer(PETSC_COMM_WORLD,NULL,"-myviewer",&viewer,&format,NULL);
22: PetscViewerPushFormat(viewer,format);
23: PetscViewerASCIIPrintf(viewer,"Testing PetscViewerASCIIPrintf %d\n", 1);
24: PetscViewerPopFormat(viewer);
25: }
26: PetscViewerDestroy(&viewer);
27: PetscFinalize();
28: return ierr;
29: }
32: /*TEST
34: test:
35: args: -myviewer ascii:ex4w1.tmp
36: filter: cat ex4w1.tmp
37: output_file: output/ex4w.out
39: test:
40: suffix: 2
41: args: -myviewer ascii:ex4w2.tmp::
42: filter: cat ex4w2.tmp
43: output_file: output/ex4w.out
45: test:
46: suffix: 3
47: args: -myviewer ascii:ex4w3.tmp::write
48: filter: cat ex4w3.tmp
49: output_file: output/ex4w.out
51: test:
52: suffix: 4
53: args: -myviewer ascii:ex4a1.tmp::append
54: filter: cat ex4a1.tmp
55: output_file: output/ex4a.out
57: TEST*/