[petsc-users] Call multiple error handler

Barry Smith bsmith at mcs.anl.gov
Tue Jan 10 07:20:04 CST 2017


   I do not understand what you mean. I hope this is C.

   By default when an error is detected PetscError using PetscTraceBackErrorHandler returns up the stack printing the function/line number then returning to the next function which prints the function/line number until it gets up to the function main where it calls MPI_Abort. 

 Now if one of the functions in the stack of functions is a user function that DOES NOT check a return code with CHKERRQ(ierr) then bad stuff happens because PetscError will print part of the stack of functions but then the user code (that ignores the error code) continues running generally causing bad and confusing things to happen.  This is why we recommend always using CHKERRQ() in user code. 

  From the perspective of PETSc error handling there really isn't any difference between user code and PETSc code. 

>  However, I want my application to be aborted with the PetscMPIAbortErrorHandler when an error occures.  

Do you mean that in your code when you detect an error you want SETERRQ() to call PetscMPIAbortErrorHandler()  but in PETSc code you want it to try to return through the stack printing the PETSc function/line numbers? You can do this by making your own macro mySETERRQ() that is defined to be a call to PetscMPIAbortErrorHandler and using mySETERRQ() to mark errors in your code.  Though I do not recommend this, better to use CHKERRQ() in your code and get error tracebacks for PETSc code and your code.

  Barry



> On Jan 10, 2017, at 6:42 AM, Florian Lindner <mailinglists at xgm.de> wrote:
> 
> Hello,
> 
> I really enjoy the verbosity (line number) of the default PetscTraceBackErrorHandler. However, I want my application to
> be aborted with the PetscMPIAbortErrorHandler when an error occures.
> 
> Can I instruct PETSc to call first one handler, then another one?
> 
> Thanks,
> Florian



More information about the petsc-users mailing list