Actual source code: ex1.c


  2: static char help[] = "Appends to an ASCII file.\n\n";

  4: #include <petscviewer.h>

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

 11:   PetscInitialize(&argc,&args,(char*)0,help);
 12:   PetscViewerCreate(PETSC_COMM_WORLD, &viewer);
 13:   PetscViewerSetType(viewer, PETSCVIEWERASCII);
 14:   PetscViewerFileSetMode(viewer, FILE_MODE_APPEND);
 15:   PetscViewerFileSetName(viewer, "test.txt");
 16:   for (i = 0; i < 10; ++i) {
 17:     PetscViewerASCIIPrintf(viewer, "test line %" PetscInt_FMT "\n", i);
 18:   }
 19:   PetscViewerDestroy(&viewer);
 20:   PetscFinalize();
 21:   return 0;
 22: }

 24: /*TEST

 26:    test:

 28: TEST*/