2: static char help[] = "Tests catching of floating point exceptions.\n\n"; 4: #include petscsys.h 8: int CreateError(PetscReal x) 9: { 12: x = 1.0/x; 13: PetscPrintf(PETSC_COMM_SELF,"x = %G\n",x); 14: return(0); 15: } 19: int main(int argc,char **argv) 20: { 22: PetscInitialize(&argc,&argv,(char *)0,help); 23: PetscPrintf(PETSC_COMM_SELF,"This is a contrived example to test floating pointing\n"); 24: PetscPrintf(PETSC_COMM_SELF,"It is not a true error.\n"); 25: PetscPrintf(PETSC_COMM_SELF,"Run with -fp_trap to catch the floating point error\n"); 26: CreateError(0.0); 27: return 0; 28: } 29: