:orphan:
# PetscCallAbort
Checks error code returned from PETSc function, if non-zero it aborts immediately by calling `MPI_Abort()` 
## Synopsis
```
#include <petscerror.h>
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
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/include/petscerror.h.html#PetscCallAbort">include/petscerror.h</A>

## Examples
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/tutorials/ex42.c.html">src/ksp/ksp/tutorials/ex42.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/tutorials/ex43.c.html">src/ksp/ksp/tutorials/ex43.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/tutorials/ex70.c.html">src/ksp/ksp/tutorials/ex70.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/snes/tutorials/ex24.c.html">src/snes/tutorials/ex24.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ts/tutorials/ex11.c.html">src/ts/tutorials/ex11.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ts/tutorials/ex18.c.html">src/ts/tutorials/ex18.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ts/tutorials/ex76.c.html">src/ts/tutorials/ex76.c</A><BR>


---
[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)  
