Actual source code: ex1.c

petsc-3.13.6 2020-09-29
Report Typos and Errors

  2: static char help[] = "Demonstrates PETSc error handlers.\n";

  4:  #include <petscsys.h>

  6: int CreateError(int n)
  7: {
  9:   if (!n) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_USER,"Error Created");
 10:   CreateError(n-1);
 11:   return 0;
 12: }

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



 28: /*TEST

 30:  # Testing errors so only look for errors
 31:    test:
 32:      args: -error_output_stdout
 33:      filter: egrep "(PETSC ERROR)" | egrep "(Error Created|CreateError\(\)|main\(\))" | cut -f1,2,3,4,5,6 -d" "
 34:      TODO:  Does not always produce exactly expected output on all systems for all runs

 36: TEST*/