1 2 static char help[] = "Appends to an ASCII file.\n\n"; 3 4 #include <petscviewer.h> 5 6 int main(int argc, char **args) { 7 PetscViewer viewer; 8 PetscInt i; 9 10 PetscFunctionBeginUser; 11 PetscCall(PetscInitialize(&argc, &args, (char *)0, 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 26 TEST*/ 27