Actual source code: ex4.c


  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:   PetscViewerFormat format;
 10:   PetscBool         iascii;

 12:   PetscInitialize(&argc,&args,(char*)0,help);
 13:   PetscOptionsGetViewer(PETSC_COMM_WORLD,NULL,NULL,"-myviewer",&viewer,&format,NULL);
 14:   PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&iascii);
 15:   if (iascii) {
 16:     PetscViewerPushFormat(viewer,format);
 17:     PetscViewerASCIIPrintf(viewer,"Testing PetscViewerASCIIPrintf %d\n", 0);
 18:     PetscViewerPopFormat(viewer);
 19:     PetscViewerDestroy(&viewer);
 20:     PetscOptionsGetViewer(PETSC_COMM_WORLD,NULL,NULL,"-myviewer",&viewer,&format,NULL);
 21:     PetscViewerPushFormat(viewer,format);
 22:     PetscViewerASCIIPrintf(viewer,"Testing PetscViewerASCIIPrintf %d\n", 1);
 23:     PetscViewerPopFormat(viewer);
 24:   }
 25:   PetscViewerDestroy(&viewer);
 26:   PetscFinalize();
 27:   return 0;
 28: }

 30: /*TEST

 32:    test:
 33:       args: -myviewer ascii:ex4w1.tmp
 34:       filter: cat ex4w1.tmp
 35:       output_file: output/ex4w.out

 37:    test:
 38:       suffix: 2
 39:       args: -myviewer ascii:ex4w2.tmp::
 40:       filter: cat ex4w2.tmp
 41:       output_file: output/ex4w.out

 43:    test:
 44:       suffix: 3
 45:       args: -myviewer ascii:ex4w3.tmp::write
 46:       filter: cat ex4w3.tmp
 47:       output_file: output/ex4w.out

 49:    test:
 50:       suffix: 4
 51:       args: -myviewer ascii:ex4a1.tmp::append
 52:       filter: cat ex4a1.tmp
 53:       output_file: output/ex4a.out

 55: TEST*/