petsc-master 2020-07-09
Report Typos and Errors

PetscSetFPTrap

Enables traps/exceptions on common floating point errors. This option may not work on certain systems.

Synopsis

#include "petscsys.h"  
PetscErrorCode PetscSetFPTrap(PetscFPTrap flag)
Not Collective

Input Parameters

flag -PETSC_FP_TRAP_ON, PETSC_FP_TRAP_OFF.

Options Database Keys

-fp_trap -Activates floating point trapping

Description

On systems that support it, when called with PETSC_FP_TRAP_ON this routine causes floating point underflow, overflow, divide-by-zero, and invalid-operand (e.g., a NaN) to cause a message to be printed and the program to exit.

Note

On many common systems, the floating point exception state is not preserved from the location where the trap occurred through to the signal handler. In this case, the signal handler will just say that an unknown floating point exception occurred and which function it occurred in. If you run with -fp_trap in a debugger, it will break on the line where the error occurred. On systems that support C99 floating point exception handling You can check which exception occurred using fetestexcept(FE_ALL_EXCEPT). See fenv.h (usually at /usr/include/bits/fenv.h) for the enum values on your system.

Caution

On certain machines, in particular the IBM PowerPC, floating point trapping may be VERY slow!

See Also

PetscFPTrapPush(), PetscFPTrapPop(), PetscDetermineInitialFPTrap()

Level

advanced

Location

src/sys/error/fp.c
Index of all Sys routines
Table of Contents for all manual pages
Index of all manual pages