PetscErrorCode#
Datatype used to return PETSc error codes.
Synopsis#
typedef /*
Needed so that C++ lambdas can deduce the return type as PetscErrorCode from
PetscFunctionReturn(PETSC_SUCCESS). Otherwise we get
error: return type '(unnamed enum at include/petscsystypes.h:50:1)' must match previous
return type 'int' when lambda expression has unspecified explicit return type
PetscFunctionReturn(PETSC_SUCCESS);
^
*//*MC
PetscClassId - A unique id used to identify each PETSc class.
Note:
Use `PetscClassIdRegister()` to obtain a new value for a new class being created. Usually
XXXInitializePackage() calls it for each class it defines.
Developer Note:
Internal integer stored in the `_p_PetscObject` data structure. These are all computed by an offset from the lowest one, `PETSC_SMALLEST_CLASSID`.
.seealso: `PetscClassIdRegister()`, `PetscLogEventRegister()`, `PetscHeaderCreate()`
M*//*MC
PetscMPIInt - datatype used to represent `int` parameters to MPI functions.
Notes:
This is always a 32-bit integer even if PETSc was built with `--with-64-bit-indices`.
Hence, it is not guaranteed that it is the same as `PetscInt`.
`PetscMPIIntCast`(a,&b) checks if the given `PetscInt` a will fit in a `PetscMPIInt`, if not it
generates a `PETSC_ERR_ARG_OUTOFRANGE` error.
.seealso: [](stylePetscCount), `PetscBLASInt`, `PetscInt`, `PetscMPIIntCast()`
M*//* Limit MPI to 32-bits */ {
PETSC_MPI_INT_MIN = INT_MIN,
PETSC_MPI_INT_MAX = INT_MAX
};
Notes#
Virtually all PETSc functions return an error code. It is the callers responsibility to check
the value of the returned error code after each PETSc call to determine if any errors
occurred. A set of convenience macros (e.g., PetscCall() or PetscCallVoid()) are provided
for this purpose. Failing to properly check for errors is not supported, as errors may leave
PETSc in an undetermined state.
One can retrieve the error string corresponding to a particular error code using
PetscErrorMessage().
The user can also configure PETSc with the --with-strict-petscerrorcode option to enable
compiler warnings when the returned error codes are not captured and checked. Users are
heavily encouraged to opt-in to this option, as it will become enabled by default in a
future release.
Developer Notes#
These are the generic error codes. These error codes are used in many different places in the
PETSc source code. The C-string versions are at defined in PetscErrorStrings[] in
src/sys/error/err.c, while the Fortran versions are defined in
src/sys/ftn-mod/petscerror.h. Any changes here must also be made in both locations.
See Also#
PetscErrorMessage(), PetscCall(), SETERRQ()
Level#
developer
Location#
Index of all Sys routines
Table of Contents for all manual pages
Index of all manual pages