Actual source code: ex1.c
1: static char help[] = "Appends to an ASCII file.\n\n";
3: #include <petscviewer.h>
5: int main(int argc, char **args)
6: {
7: PetscViewer viewer;
8: PetscInt i;
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: }
22: /*TEST
24: test:
26: TEST*/