Actual source code: ex2.c

  1: /*$Id: ex2.c,v 1.19 2001/08/07 21:29:12 bsmith Exp $*/

  3: /*
  4:       Tests the signal handler.
  5: */
 6:  #include petsc.h

  8: int CreateError(int n)
  9: {
 10:   int       ierr;
 11:   PetscReal *x = 0;
 12:   if (!n) x[0] = 100.;
 13:   CreateError(n-1);
 14:   return 0;
 15: }

 17: int main(int argc,char **argv)
 18: {
 20:   PetscInitialize(&argc,&argv,(char *)0,0);
 21:   PetscFPrintf(PETSC_COMM_WORLD,stdout,"Demonstrates how PETSc can trap error interruptsn");
 22:   PetscFPrintf(PETSC_COMM_WORLD,stdout,"The error below is contrived to test the code!n");
 23:   PetscSynchronizedFlush(PETSC_COMM_WORLD);
 24:   CreateError(5);
 25:   PetscFinalize();
 26:   return 0;
 27: }
 28: