Actual source code: ex1.c
petsc-3.12.5 2020-03-29
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: PetscViewerDestroy(&viewer);
25: PetscFinalize();
26: return ierr;
27: }
29: /*TEST
31: test:
33: TEST*/