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 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) { 17 PetscCall(PetscViewerASCIIPrintf(viewer, "test line %" PetscInt_FMT "\n", i)); 18 } 19 PetscCall(PetscViewerDestroy(&viewer)); 20 PetscCall(PetscFinalize()); 21 return 0; 22 } 23 24 /*TEST 25 26 test: 27 28 TEST*/ 29