Actual source code: ex3.c

petsc-3.7.3 2016-08-01
Report Typos and Errors
  2: static char help[] = "Tests catching of floating point exceptions.\n\n";

  4: #include <petscsys.h>

  8: int CreateError(PetscReal x)
  9: {

 13:   x    = 1.0/x;
 14:   PetscPrintf(PETSC_COMM_SELF,"x = %g\n",(double)x);
 15:   return(0);
 16: }

 20: int main(int argc,char **argv)
 21: {
 23:   PetscInitialize(&argc,&argv,(char*)0,help);
 24:   PetscPrintf(PETSC_COMM_SELF,"This is a contrived example to test floating pointing\n");
 25:   PetscPrintf(PETSC_COMM_SELF,"It is not a true error.\n");
 26:   PetscPrintf(PETSC_COMM_SELF,"Run with -fp_trap to catch the floating point error\n");
 27:   CreateError(0.0);
 28:   return 0;
 29: }