SETERRQ — PETSc 3.25.0 documentation

Skip to main content
`Ctrl`+`K`

# SETERRQ

Macro to be called when an error has been detected,

## Synopsis

    #include <petscsys.h>
    PetscErrorCode SETERRQ(MPI_Comm comm, PetscErrorCode ierr, char *message, ...)

Collective

## Input Parameters

- comm - An MPI communicator, use `PETSC_COMM_SELF` unless you know all ranks of another communicator will detect the error

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

- message - error message

## Notes

This is rarely needed, one should use `PetscCheck()` and `PetscCall()` and friends to automatically handle error conditions. Once the error handler is called the calling function is then returned from with the given error code.

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

## Fortran Note

`SETERRQ()` may be called from Fortran subroutines but `SETERRA()` must be called from the Fortran main program.

## See Also

`PetscCheck()`, `PetscAssert()`, `PetscTraceBackErrorHandler()`, `PetscPushErrorHandler()`, `PetscError()`, `PetscCall()`, `CHKMEMQ`, `CHKERRA()`, `PetscCallMPI()`, `PetscErrorCode`

## Level

beginner

## Location

include/petscerror.h

Index of all Sys routines
Table of Contents for all manual pages
Index of all manual pages