PetscErrorCode#

Datatype used to return PETSc error codes.

Synopsis#

 {
  PETSC_SUCCESS                   = 0,
  PETSC_ERR_BOOLEAN_MACRO_FAILURE = 1, /* do not use */

  PETSC_ERR_MIN_VALUE = 54, /* should always be one less than the smallest value */

  PETSC_ERR_MEM            = 55, /* unable to allocate requested memory */
  PETSC_ERR_SUP            = 56, /* no support for requested operation */
  PETSC_ERR_SUP_SYS        = 57, /* no support for requested operation on this computer system */
  PETSC_ERR_ORDER          = 58, /* operation done in wrong order */
  PETSC_ERR_SIG            = 59, /* signal received */
  PETSC_ERR_FP             = 72, /* floating point exception */
  PETSC_ERR_COR            = 74, /* corrupted PETSc object */
  PETSC_ERR_LIB            = 76, /* error in library called by PETSc */
  PETSC_ERR_PLIB           = 77, /* PETSc library generated inconsistent data */
  PETSC_ERR_MEMC           = 78, /* memory corruption */
  PETSC_ERR_CONV_FAILED    = 82, /* iterative method (KSP or SNES) failed */
  PETSC_ERR_USER           = 83, /* user has not provided needed function */
  PETSC_ERR_SYS            = 88, /* error in system call */
  PETSC_ERR_POINTER        = 70, /* pointer does not point to valid address */
  PETSC_ERR_MPI_LIB_INCOMP = 87, /* MPI library at runtime is not compatible with MPI user compiled with */

  PETSC_ERR_ARG_SIZ          = 60, /* nonconforming object sizes used in operation */
  PETSC_ERR_ARG_IDN          = 61, /* two arguments not allowed to be the same */
  PETSC_ERR_ARG_WRONG        = 62, /* wrong argument (but object probably ok) */
  PETSC_ERR_ARG_CORRUPT      = 64, /* null or corrupted PETSc object as argument */
  PETSC_ERR_ARG_OUTOFRANGE   = 63, /* input argument, out of range */
  PETSC_ERR_ARG_BADPTR       = 68, /* invalid pointer argument */
  PETSC_ERR_ARG_NOTSAMETYPE  = 69, /* two args must be same object type */
  PETSC_ERR_ARG_NOTSAMECOMM  = 80, /* two args must be same communicators */
  PETSC_ERR_ARG_WRONGSTATE   = 73, /* object in argument is in wrong state, e.g. unassembled mat */
  PETSC_ERR_ARG_TYPENOTSET   = 89, /* the type of the object has not yet been set */
  PETSC_ERR_ARG_INCOMP       = 75, /* two arguments are incompatible */
  PETSC_ERR_ARG_NULL         = 85, /* argument is null that should not be */
  PETSC_ERR_ARG_UNKNOWN_TYPE = 86, /* type name doesn't match any registered type */

  PETSC_ERR_FILE_OPEN       = 65, /* unable to open file */
  PETSC_ERR_FILE_READ       = 66, /* unable to read from file */
  PETSC_ERR_FILE_WRITE      = 67, /* unable to write to file */
  PETSC_ERR_FILE_UNEXPECTED = 79, /* unexpected data in file */

  PETSC_ERR_MAT_LU_ZRPVT = 71, /* detected a zero pivot during LU factorization */
  PETSC_ERR_MAT_CH_ZRPVT = 81, /* detected a zero pivot during Cholesky factorization */

  PETSC_ERR_INT_OVERFLOW   = 84,
  PETSC_ERR_FLOP_COUNT     = 90,
  PETSC_ERR_NOT_CONVERGED  = 91,  /* solver did not converge */
  PETSC_ERR_MISSING_FACTOR = 92,  /* MatGetFactor() failed */
  PETSC_ERR_OPT_OVERWRITE  = 93,  /* attempted to over write options which should not be changed */
  PETSC_ERR_WRONG_MPI_SIZE = 94,  /* example/application run with number of MPI ranks it does not support */
  PETSC_ERR_USER_INPUT     = 95,  /* missing or incorrect user input */
  PETSC_ERR_GPU_RESOURCE   = 96,  /* unable to load a GPU resource, for example cuBLAS */
  PETSC_ERR_GPU            = 97,  /* An error from a GPU call, this may be due to lack of resources on the GPU or a true error in the call */
  PETSC_ERR_MPI            = 98,  /* general MPI error */
  PETSC_ERR_RETURN         = 99,  /* PetscError() incorrectly returned an error code of 0 */
  PETSC_ERR_MEM_LEAK       = 100, /* memory alloc/free imbalance */
  PETSC_ERR_MAX_VALUE      = 101, /* this is always the one more than the largest error code */

  /*
    do not use, exist purely to make the enum bounds equal that of a regular int (so conversion
    to int in main() is not undefined behavior)
  */
  PETSC_ERR_MIN_SIGNED_BOUND_DO_NOT_USE = INT_MIN,
  PETSC_ERR_MAX_SIGNED_BOUND_DO_NOT_USE = INT_MAX
} PETSC_ERROR_CODE_ENUM_NAME;

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(), 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/f90-mod/petscerror.h. Any changes here must also be made in both locations.

See Also#

PetscErrorMessage(), PetscCall(), SETERRQ()

Level#

beginner

Location#

include/petscsystypes.h

Examples#

src/tao/constrained/tutorials/tomographyADMM.c
src/ts/tutorials/ex9.c
src/ts/tutorials/ex8.c

Examples#

src/vec/vec/tutorials/ex6.c
src/ts/tutorials/ex11_sa.c
src/sys/classes/random/tutorials/ex2.c

Examples#

src/snes/tutorials/ex63.c
src/snes/tutorials/ex69.c
src/dm/impls/plex/tutorials/ex10.c
src/snes/tutorials/ex5.c
src/tao/tutorials/ex4.c
src/snes/tutorials/ex7.c
src/tao/unconstrained/tutorials/spectraladjointassimilation.c
src/snes/tutorials/ex14.c
src/snes/tutorials/ex17.c
src/dm/field/tutorials/ex1.c

Examples#

src/ts/tutorials/ex30.c
src/ts/tutorials/ex11.c
src/ts/tutorials/ex29.c
src/ts/tutorials/ex11_sa.c

Examples#

src/tao/unconstrained/tutorials/rosenbrock1.c
src/snes/tutorials/ex99.c
src/tao/unconstrained/tutorials/eptorsion1.c
src/tao/unconstrained/tutorials/rosenbrock2.c
src/tao/unconstrained/tutorials/rosenbrock3.c
src/tao/constrained/tutorials/ex1.c
src/tao/unconstrained/tutorials/minsurf1.c
src/tao/unconstrained/tutorials/eptorsion3.c
src/mat/tutorials/ex18.c
src/mat/tutorials/ex11.c

Examples#

src/tao/unconstrained/tutorials/rosenbrock2.c
src/tao/unconstrained/tutorials/rosenbrock3.c

Examples#

src/ts/tutorials/ex9.c
src/dm/impls/stag/tutorials/ex8.c
src/dm/impls/stag/tutorials/ex4.c

Examples#

src/vec/vec/tutorials/ex21.c

Examples#

src/mat/tutorials/ex15.c
src/dm/impls/plex/tutorials/ex8.c
src/dm/impls/plex/tutorials/ex15.c

Examples#

src/dm/impls/plex/tutorials/ex5.c
src/dm/tutorials/ex22.c
src/ksp/ksp/tutorials/ex10.c
src/ksp/ksp/tutorials/ex72.c
src/ksp/ksp/tutorials/bench_kspsolve.c
src/vec/vec/tutorials/ex19.c
src/dm/impls/plex/tutorials/ex15.c

Examples#

src/mat/tutorials/ex3.c
src/snes/tutorials/ex76.c
src/snes/tutorials/ex69.c
src/tao/unconstrained/tutorials/burgers_spectral.c
src/dm/impls/plex/tutorials/ex6.c
src/snes/tutorials/ex71.c
src/snes/tutorials/ex27.c
src/snes/tutorials/ex17.c
src/snes/tutorials/ex62.c
src/dm/impls/plex/tutorials/ex11.c

Examples#

src/dm/tutorials/swarm_ex3.c
src/dm/tutorials/swarm_ex1.c
src/ts/tutorials/extchem.c

Examples#

src/dm/impls/stag/tutorials/ex3.c
src/ts/tutorials/ex31.c
src/tao/tutorials/ex4.c
src/ts/tutorials/ex11.c
src/tao/constrained/tutorials/maros.c

Examples#

src/dm/impls/plex/tutorials/ex15.c

Examples#

src/snes/tutorials/ex63.c
src/tao/tutorials/ex3.c
src/dm/label/tutorials/ex1.c
src/snes/tutorials/ex5.c
src/dm/tutorials/ex10.c
src/snes/tutorials/ex3k.kokkos.cxx
src/snes/tutorials/ex7.c
src/snes/tutorials/ex75.c
src/mat/tutorials/ex19.c
src/dm/impls/plex/tutorials/ex11.c

Examples#

src/ksp/pc/tutorials/ex4.c
src/snes/tutorials/ex55.c
src/mat/tutorials/ex1.c
src/dm/tutorials/swarm_ex1.c
src/mat/tutorials/ex12.c
src/dm/tutorials/ex21.c
src/snes/tutorials/ex5.c
src/mat/tutorials/ex16.c
src/mat/tutorials/ex10.c
src/snes/tutorials/ex56.c

Examples#

src/dm/impls/stag/tutorials/ex8.c
src/dm/tutorials/ex3.c
src/tao/tutorials/ex3.c
src/tao/pde_constrained/tutorials/hyperbolic.c
src/tao/constrained/tutorials/ex1.c
src/dm/tutorials/swarm_ex1.c
src/tao/pde_constrained/tutorials/parabolic.c
src/dm/impls/stag/tutorials/ex6.c
src/dm/impls/stag/tutorials/ex4.c
src/dm/tutorials/ex20.c

Examples#

src/ksp/ksp/tutorials/ex52.c
src/ts/tutorials/extchem.c
src/ts/tutorials/extchemfield.c
src/ts/tutorials/ex11_sa.c
src/ksp/ksp/tutorials/ex59.c
src/ts/tutorials/ex11.c

Examples#

src/ksp/ksp/tutorials/ex42.c

Examples#

src/snes/tutorials/ex46.c
src/ts/tutorials/ex9.c


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