PetscFunctionReturn#

Last executable line of each PETSc function used for error handling. Replaces return().

Synopsis#

#include <petscerror.h>
void PetscFunctionReturn(...)

Not Collective; No Fortran Support

Notes#

This routine is a macro, so while it does not “return” anything itself, it does return from the function in the literal sense.

Usually the return value is the integer literal 0 (for example in any function returning PetscErrorCode), however it is possible to return any arbitrary type. The arguments of this macro are placed before the return statement as-is.

Any routine which returns via PetscFunctionReturn() must begin with a corresponding PetscFunctionBegin.

For routines which return void use PetscFunctionReturnVoid() instead.

Example Usage#

   PetscErrorCode foo(int *x)
   {
     PetscFunctionBegin; // don't forget the begin!
     *x = 10;
     PetscFunctionReturn(PETSC_SUCCESS);
   }

May return any arbitrary type:

  struct Foo
  {
    int x;
  };

  struct Foo make_foo(int value)
  {
    struct Foo f;

    PetscFunctionBegin;
    f.x = value;
    PetscFunctionReturn(f);
  }

See Also#

PetscFunctionBegin, PetscFunctionBeginUser, PetscFunctionReturnVoid(), PetscStackPopNoCheck()

Level#

beginner

Location#

include/petscerror.h

Examples#

src/dm/dt/dualspace/impls/lagrange/tutorials/ex2.c
src/dm/field/tutorials/ex1.c
src/dm/impls/plex/tutorials/ex10.c
src/dm/impls/plex/tutorials/ex11.c
src/dm/impls/plex/tutorials/ex5.c
src/dm/impls/plex/tutorials/ex6.c
src/dm/impls/plex/tutorials/ex7.c
src/dm/impls/plex/tutorials/ex8.c
src/dm/impls/plex/tutorials/ex9.c
src/dm/impls/stag/tutorials/ex2.c
src/dm/impls/stag/tutorials/ex3.c


Edit on GitLab

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