2: static char help[] = "Tests catching of floating point exceptions.\n\n"; 4: #include <petscsys.h> 6: int CreateError(PetscReal x) 7: { 11: x = 1.0/x; 12: PetscPrintf(PETSC_COMM_SELF,"x = %g\n",(double)x); 13: return(0); 14: } 16: int main(int argc,char **argv) 17: { 19: PetscInitialize(&argc,&argv,(char*)0,help);if (ierr) return ierr; 20: PetscPrintf(PETSC_COMM_SELF,"This is a contrived example to test floating pointing\n"); 21: PetscPrintf(PETSC_COMM_SELF,"It is not a true error.\n"); 22: PetscPrintf(PETSC_COMM_SELF,"Run with -fp_trap to catch the floating point error\n"); 23: CreateError(0.0); 24: return 0; 25: } 27: /* 29: Because this example may produce different output on different machines we filter out everything. 30: This makes the test ineffective but currently we don't have a good way to know which machines should handle 31: the floating point exceptions properly. 33: */ 34: /*TEST 36: test: 37: args: -fp_trap -error_output_stdout 38: filter: Error: true 40: TEST*/