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#
Examples#
src/sys/tutorials/ex7.c
src/sys/tutorials/ex6.c
src/sys/classes/random/tutorials/ex2.c
src/vec/vec/utils/tagger/tutorials/ex1.c
src/vec/is/sf/tutorials/ex1.c
src/ts/tutorials/ex20td.c
src/ts/tutorials/ex36A.c
src/ts/tutorials/ex11.c
src/ts/tutorials/ex16fwd.c
src/ts/tutorials/ex20opt_ic.c
Index of all Sys routines
Table of Contents for all manual pages
Index of all manual pages