PETSc version 3.17.0
Fix/Edit manual page

# PetscCallAbort

Checks error code returned from PETSc function, if non-zero it aborts immediately

### Synopsis

    #include <petscerror.h>
    void PetscCallAbort(MPI_Comm comm, PetscErrorCode ierr)

Collective on comm

### 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

      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)
        }
      };

### See Also

SETERRABORT(), PetscTraceBackErrorHandler(), PetscPushErrorHandler(), PetscError(),
SETERRQ(), CHKMEMQ, PetscCallMPI()

### Level

intermediate

### Location

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