Actual source code: ex1.c

petsc-master 2017-07-27
Report Typos and Errors

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

  4: /*T
  5:    Concepts: viewers^append
  6: T*/

  8:  #include <petscviewer.h>

 10: int main(int argc,char **args)
 11: {
 12:   PetscViewer    viewer;
 13:   PetscInt       i;

 16:   PetscInitialize(&argc,&args,(char*)0,help);if (ierr) return ierr;
 17:   PetscViewerCreate(PETSC_COMM_WORLD, &viewer);
 18:   PetscViewerSetType(viewer, PETSCVIEWERASCII);
 19:   PetscViewerFileSetMode(viewer, FILE_MODE_APPEND);
 20:   PetscViewerFileSetName(viewer, "test.txt");
 21:   for (i = 0; i < 10; ++i) {
 22:     PetscViewerASCIIPrintf(viewer, "test line %d\n", i);
 23:   }
 24:   PetscFinalize();
 25:   return ierr;
 26: }