Actual source code: ex1.c
petsc-3.8.4 2018-03-24
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: }