1 2 static char help[] = "Demonstrates PETSc error handlers.\n"; 3 4 #include <petscsys.h> 5 6 int CreateError(int n) 7 { 8 PetscCheck(n, PETSC_COMM_SELF, PETSC_ERR_USER, "Error Created"); 9 PetscCall(CreateError(n - 1)); 10 return 0; 11 } 12 13 int main(int argc, char **argv) 14 { 15 PetscFunctionBeginUser; 16 PetscCall(PetscInitialize(&argc, &argv, (char *)0, help)); 17 PetscCall(PetscFPrintf(PETSC_COMM_WORLD, stdout, "Demonstrates PETSc Error Handlers\n")); 18 PetscCall(PetscFPrintf(PETSC_COMM_WORLD, stdout, "The error is a contrived error to test error handling\n")); 19 PetscCall(PetscSynchronizedFlush(PETSC_COMM_WORLD, PETSC_STDOUT)); 20 PetscCall(CreateError(5)); 21 PetscCall(PetscFinalize()); 22 return 0; 23 } 24 25 /*TEST 26 27 # Testing errors so only look for errors 28 test: 29 args: -error_output_stdout 30 filter: egrep "(PETSC ERROR)" | egrep "(Error Created|CreateError\(\)|main\(\))" | cut -f1,2,3,4,5,6 -d " " 31 TODO: Does not always produce exactly expected output on all systems for all runs 32 33 TEST*/ 34