Actual source code: ex4.c
petsc-3.6.1 2015-08-06
2: static char help[] = "Tests PetscOptionsGetViewer() via checking output of PetscViewerASCIIPrintf().\n\n";
4: #include <petscviewer.h>
8: int main(int argc,char **args)
9: {
10: PetscViewer viewer;
11: PetscErrorCode ierr;
12: PetscViewerFormat format;
13: PetscBool iascii;
15: PetscInitialize(&argc,&args,(char*)0,help);
16: PetscOptionsGetViewer(PETSC_COMM_WORLD,NULL,"-myviewer",&viewer,&format,NULL);
17: PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&iascii);
18: if (iascii) {
19: PetscViewerPushFormat(viewer,format);
20: PetscViewerASCIIPrintf(viewer,"Testing PetscViewerASCIIPrintf %d\n", 0);
21: PetscViewerPopFormat(viewer);
22: PetscViewerDestroy(&viewer);
23: PetscOptionsGetViewer(PETSC_COMM_WORLD,NULL,"-myviewer",&viewer,&format,NULL);
24: PetscViewerPushFormat(viewer,format);
25: PetscViewerASCIIPrintf(viewer,"Testing PetscViewerASCIIPrintf %d\n", 1);
26: PetscViewerPopFormat(viewer);
27: }
28: PetscViewerDestroy(&viewer);
29: PetscFinalize();
30: return 0;
31: }