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