1 static char help[] = "Appends to an ASCII file.\n\n";
2
3 #include <petscviewer.h>
4
main(int argc,char ** args)5 int main(int argc, char **args)
6 {
7 PetscViewer viewer;
8 PetscInt i;
9
10 PetscFunctionBeginUser;
11 PetscCall(PetscInitialize(&argc, &args, NULL, help));
12 PetscCall(PetscViewerCreate(PETSC_COMM_WORLD, &viewer));
13 PetscCall(PetscViewerSetType(viewer, PETSCVIEWERASCII));
14 PetscCall(PetscViewerFileSetMode(viewer, FILE_MODE_APPEND));
15 PetscCall(PetscViewerFileSetName(viewer, "test.txt"));
16 for (i = 0; i < 10; ++i) PetscCall(PetscViewerASCIIPrintf(viewer, "test line %" PetscInt_FMT "\n", i));
17 PetscCall(PetscViewerDestroy(&viewer));
18 PetscCall(PetscFinalize());
19 return 0;
20 }
21
22 /*TEST
23
24 test:
25 output_file: output/empty.out
26
27 TEST*/
28