Actual source code: ex1.c

petsc-3.7.3 2016-08-01
Report Typos and Errors
  2: static char help[] = "Demonstrates PETSc error handlers.\n";

  4: #include <petscsys.h>

  8: int CreateError(int n)
  9: {
 11:   if (!n) SETERRQ(PETSC_COMM_SELF,1,"Error Created");
 12:   CreateError(n-1);
 13:   return 0;
 14: }

 18: int main(int argc,char **argv)
 19: {
 21:   PetscInitialize(&argc,&argv,(char*)0,help);
 22:   PetscFPrintf(PETSC_COMM_WORLD,stdout,"Demonstrates PETSc Error Handlers\n");
 23:   PetscFPrintf(PETSC_COMM_WORLD,stdout,"The error is a contrived error to test error handling\n");
 24:   PetscSynchronizedFlush(PETSC_COMM_WORLD,PETSC_STDOUT);
 25:   CreateError(5);
 26:   PetscFinalize();
 27:   return 0;
 28: }