Actual source code: ex2.c


  2: static char help[] = "Demonstrates PetscOptionsGetViewer().\n\n";

  4: #include <petscviewer.h>

  6: int main(int argc, char **args)
  7: {
  8:   PetscViewer       viewer;
  9:   PetscViewerFormat format;

 11:   PetscFunctionBeginUser;
 12:   PetscCall(PetscInitialize(&argc, &args, (char *)0, help));
 13:   PetscCall(PetscOptionsGetViewer(PETSC_COMM_WORLD, NULL, NULL, "-myviewer", &viewer, &format, NULL));
 14:   PetscCall(PetscViewerPushFormat(viewer, format));
 15:   PetscCall(PetscViewerView(viewer, PETSC_VIEWER_STDOUT_WORLD));
 16:   PetscCall(PetscViewerPopFormat(viewer));
 17:   PetscCall(PetscViewerDestroy(&viewer));
 18:   PetscCall(PetscFinalize());
 19:   return 0;
 20: }

 22: /*TEST

 24:    test:
 25:       args: -myviewer ascii

 27:    testset:
 28:       args: -myviewer hdf5:my.hdf5:hdf5_xdmf
 29:       requires: hdf5
 30:       test:
 31:         suffix: 2a
 32:         args: -viewer_hdf5_base_dimension2 false -viewer_hdf5_sp_output true  -viewer_hdf5_collective false
 33:       test:
 34:         suffix: 2b
 35:         args: -viewer_hdf5_base_dimension2 true  -viewer_hdf5_sp_output false -viewer_hdf5_collective true

 37: TEST*/