:orphan: # PetscCallAbort Checks error code returned from PETSc function, if non-zero it aborts immediately by calling `MPI_Abort()` ## Synopsis ``` #include void PetscCallAbort(MPI_Comm comm, PetscErrorCode ierr) ``` Collective ## Input Parameters - ***comm -*** the MPI communicator on which to abort - ***ierr -*** nonzero error code, see the list of standard error codes in include/petscerror.h ## Notes This macro has identical type and usage semantics to `PetscCall()` with the important caveat that this macro does not return. Instead, if ierr is nonzero it calls the PETSc error handler and then immediately calls `MPI_Abort()`. It can therefore be used anywhere. As per `MPI_Abort()` semantics the communicator passed must be valid, although there is currently no attempt made at handling any potential errors from `MPI_Abort()`. Note that while `MPI_Abort()` is required to terminate only those processes which reside on comm, it is often the case that `MPI_Abort()` terminates *all* processes. ## Example Usage ```none PetscErrorCode boom(void) { return PETSC_ERR_MEM; } void foo(void) { PetscCallAbort(PETSC_COMM_WORLD,boom()); // OK, does not return a type } double bar(void) { PetscCallAbort(PETSC_COMM_WORLD,boom()); // OK, does not return a type } PetscCallAbort(MPI_COMM_NULL,boom()); // ERROR, communicator should be valid struct baz { baz() { PetscCallAbort(PETSC_COMM_SELF,boom()); // OK } ~baz() { PetscCallAbort(PETSC_COMM_SELF,boom()); // OK (in fact the only way to handle PETSc errors) } }; ``` ## Fortran Note Use `PetscCallA()`. ## Developer Note This should have the same name in Fortran as in C. ## See Also `SETERRABORT()`, `PetscTraceBackErrorHandler()`, `PetscPushErrorHandler()`, `PetscError()`, `SETERRQ()`, `CHKMEMQ`, `PetscCallMPI()`, `PetscCallCXXAbort()` ## Level intermediate ## Location include/petscerror.h ## Examples src/ksp/ksp/tutorials/ex42.c
src/ksp/ksp/tutorials/ex43.c
src/ksp/ksp/tutorials/ex70.c
src/snes/tutorials/ex24.c
src/ts/tutorials/ex11.c
src/ts/tutorials/ex18.c
src/ts/tutorials/ex76.c
--- [Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/include/petscerror.h) [Index of all Sys routines](index.md) [Table of Contents for all manual pages](/manualpages/index.md) [Index of all manual pages](/manualpages/singleindex.md)