Actual source code: ex4.c

petsc-3.8.4 2018-03-24
Report Typos and Errors

  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: }