Actual source code: ex80.c

  1: static char help[] = "Tests PetscLogView() called from different places.\n\n";

  3: #include <petscvec.h>

  5: int main(int argc, char **args)
  6: {
  7:   Vec         vec;
  8:   PetscViewer viewer[2];
  9:   PetscBool   flg = PETSC_FALSE;

 11:   PetscFunctionBegin;
 12:   PetscCall(PetscInitialize(&argc, &args, NULL, help));
 13:   PetscCall(PetscLogDefaultBegin());
 14:   PetscCall(PetscViewerCreate(PETSC_COMM_SELF, viewer));
 15:   PetscCall(PetscViewerCreate(PETSC_COMM_SELF, viewer + 1));
 16:   PetscCall(PetscViewerDestroy(viewer + 1));
 17:   PetscCall(PetscViewerSetType(viewer[0], PETSCVIEWERASCII));
 18:   PetscCall(PetscOptionsGetBool(NULL, NULL, "-with_vec", &flg, NULL));
 19:   if (flg) {
 20:     PetscCall(VecCreate(PETSC_COMM_SELF, &vec));
 21:     PetscCall(VecDestroy(&vec));
 22:   }
 23:   flg = PETSC_FALSE;
 24:   PetscCall(PetscOptionsGetBool(NULL, NULL, "-with_options", &flg, NULL));
 25:   if (!flg) {
 26:     PetscCall(PetscLogView(viewer[0]));
 27:     PetscCall(PetscLogView(viewer[0]));
 28:     PetscCall(PetscLogView(viewer[0]));
 29:   } else {
 30:     PetscCall(PetscLogViewFromOptions());
 31:     PetscCall(PetscLogViewFromOptions());
 32:     PetscCall(PetscLogViewFromOptions());
 33:   }
 34:   PetscCall(PetscViewerDestroy(viewer));
 35:   PetscCall(PetscFinalize());
 36:   return 0;
 37: }

 39: /*TEST

 41:   testset:
 42:     requires: defined(PETSC_USE_LOG)
 43:     nsize: 1
 44:     temporaries: default.log flamegraph.log
 45:     filter: grep Viewer | uniq
 46:     test:
 47:       args: -log_view ascii,:flamegraph.log:ascii_flamegraph,:default.log -with_vec {{false true}shared output}
 48:   # test:
 49:   #   TODO: broken (wrong count when PetscLogViewFromOptions() is called by the user)
 50:   #   args: -log_view ascii,:flamegraph.log:ascii_flamegraph,:default.log -with_vec {{false true}shared output} -with_options

 52:  TEST*/