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 { 8 PetscViewer viewer; 9 PetscInt i; 10 11 PetscFunctionBeginUser; 12 PetscCall(PetscInitialize(&argc, &args, (char *)0, help)); 13 PetscCall(PetscViewerCreate(PETSC_COMM_WORLD, &viewer)); 14 PetscCall(PetscViewerSetType(viewer, PETSCVIEWERASCII)); 15 PetscCall(PetscViewerFileSetMode(viewer, FILE_MODE_APPEND)); 16 PetscCall(PetscViewerFileSetName(viewer, "test.txt")); 17 for (i = 0; i < 10; ++i) PetscCall(PetscViewerASCIIPrintf(viewer, "test line %" PetscInt_FMT "\n", i)); 18 PetscCall(PetscViewerDestroy(&viewer)); 19 PetscCall(PetscFinalize()); 20 return 0; 21 } 22 23 /*TEST 24 25 test: 26 27 TEST*/ 28