PetscError#
Routine that is called when an error has been detected, usually called through the macro SETERRQ
(PETSC_COMM_SELF
,)or by
PetscCall()`.
Synopsis#
#include "petscsys.h"
PetscErrorCode PetscError(MPI_Comm comm, int line, const char *func, const char *file, PetscErrorCode n, PetscErrorType p, const char *mess, ...)
Collective
Input Parameters#
comm - communicator over which error occurred. ALL MPI processes of this communicator MUST call this routine
line - the line number of the error (usually indicated by
__LINE__
in the calling routine)func - the function name in which the error was detected
file - the file in which the error was detected (usually indicated by
__FILE__
in the calling routine)n - the generic error number
p -
PETSC_ERROR_INITIAL
indicates the error was initially detected,PETSC_ERROR_REPEAT
indicates this is a traceback from a previously detected errormess - formatted message string - aka printf
Options Database Keys#
-error_output_stdout - output the error messages to
stdout
instead of the defaultstderr
-error_output_none - do not output the error messages
Notes#
PETSc error handling is done with error return codes. A non-zero return indicates an error
was detected. The return-value of this routine is what is ultimately returned by
SETERRQ()
.
Numerical errors (potential divide by zero, for example) are not managed by the
error return codes; they are managed via, for example, KSPGetConvergedReason()
that
indicates if the solve was successful or not. The option -ksp_error_if_not_converged
, for
example, turns numerical failures into hard errors managed via PetscError()
.
PETSc provides a rich supply of error handlers, see the list below, and users can also provide their own error handlers.
If the user sets their own error handler (via PetscPushErrorHandler()
) they may return any
arbitrary value from it, but are encouraged to return nonzero values. If the return value is
zero, SETERRQ()
will ignore the value and return PETSC_ERR_RETURN
(a nonzero value)
instead.
Most users need not directly use this routine and the error handlers, but can instead use
the simplified interface PetscCall()
or SETERRQ()
.
Fortran Note#
This routine is used differently from Fortran
PetscError(MPI_Comm comm, PetscErrorCode n, PetscErrorType p, char *message)
Developer Note#
Since this is called after an error condition it should not be calling any error handlers (currently it ignores any error codes) BUT this routine does call regular PETSc functions that may call error handlers, this is problematic and could be fixed by never calling other PETSc routines but this annoying.
See Also#
PetscErrorCode
, PetscPushErrorHandler()
, PetscPopErrorHandler()
, PetscTraceBackErrorHandler()
, PetscAbortErrorHandler()
, PetscMPIAbortErrorHandler()
,
PetscReturnErrorHandler()
, PetscAttachDebuggerErrorHandler()
, PetscEmacsClientErrorHandler()
,
SETERRQ()
, PetscCall()
, CHKMEMQ
, PetscErrorMessage()
, PETSCABORT()
, PetscErrorType
, PETSC_ERROR_INITIAL
, PETSC_ERROR_REPEAT
Level#
intermediate
Location#
Index of all Sys routines
Table of Contents for all manual pages
Index of all manual pages