petsc-3.7.1 2016-05-15
Report Typos and Errors

CHKERRQ

Checks error code, if non-zero it calls the error handler and then returns

Synopsis

#include <petscsys.h>
PetscErrorCode CHKERRQ(PetscErrorCode errorcode)
Not Collective Many br

Input Parameters

errorcode -nonzero error code, see the list of standard error codes in include/petscerror.h Many br

Many br

Notes

Once the error handler is called the calling function is then returned from with the given error code. Many br

Experienced users can set the error handler with PetscPushErrorHandler(). Many br

CHKERRQ(n) is fundamentally a macro replacement for Many brif (n) return(PetscError(...,n,...)); Many br

Although typical usage resembles "void CHKERRQ(PetscErrorCode)" as described above, for certain uses it is Many brhighly inappropriate to use it in this manner as it invokes return(PetscErrorCode). In particular, Many brit cannot be used in functions which return(void) or any other datatype. In these types of functions, Many bryou can use CHKERRV() which returns without an error code (bad idea since the error is ignored or Many brif (n) {PetscError(....); return(YourReturnType);} Many brwhere you may pass back a NULL to indicate an error. You can also call CHKERRABORT(comm,n) to have Many brMPI_Abort() returned immediately. Many br

In Fortran MPI_Abort() is always called Many br

See Also

PetscTraceBackErrorHandler(), PetscPushErrorHandler(), PetscError(), SETERRQ(), CHKMEMQ, SETERRQ1(), SETERRQ2(), SETERRQ2()

Level:beginner
Location:
src/sys/error/../../../include/petscerror.h
Index of all Sys routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/sys/classes/viewer/examples/tutorials/ex1.c.html
src/sys/classes/viewer/examples/tutorials/ex2.c.html
src/sys/classes/random/examples/tutorials/ex1.c.html
src/sys/classes/random/examples/tutorials/ex2.c.html
src/sys/examples/tutorials/ex1.c.html
src/sys/examples/tutorials/ex2.c.html
src/sys/examples/tutorials/ex3.c.html
src/sys/examples/tutorials/ex4.c.html
src/sys/examples/tutorials/ex5.c.html
src/sys/examples/tutorials/ex9.c.html
src/sys/examples/tutorials/ex11.c.html