Actual source code: ex81.c

  1: static char help[] = "Tests PetscLogView() called with no PetscGlobalArgc and PetscGlobalArgs.\n\n";

  3: #include <petscsys.h>
  4: #include <petscvec.h>

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

 12:   PetscFunctionBegin;
 13:   PetscCall(PetscInitialize(NULL, NULL, NULL, help));
 14:   PetscCall(PetscLogDefaultBegin());
 15:   PetscCall(PetscViewerCreate(PETSC_COMM_SELF, &viewer));
 16:   PetscCall(PetscViewerSetType(viewer, PETSCVIEWERASCII));
 17:   for (PetscInt i = 1; i < argc; ++i) {
 18:     PetscCall(PetscStrcmp(args[i], "foo", &flg));
 19:     if (flg) break;
 20:   }
 21:   if (flg) {
 22:     PetscCall(VecCreate(PETSC_COMM_SELF, &vec));
 23:     PetscCall(VecDestroy(&vec));
 24:   }
 25:   PetscCall(PetscLogView(viewer));
 26:   PetscCall(PetscViewerDestroy(&viewer));
 27:   PetscCall(PetscFinalize());
 28:   return 0;
 29: }

 31: /*TEST

 33:   testset:
 34:     requires: defined(PETSC_USE_LOG)
 35:     nsize: 1
 36:     filter: grep -E "^              (Vector|Viewer)"
 37:     test:
 38:       suffix: 1
 39:       output_file: output/ex81_1.out
 40:     test:
 41:       suffix: 2
 42:       args: foo
 43:       output_file: output/ex81_2.out

 45:  TEST*/