Go to the documentation of this file.
50 bool Foam::sigFpe::sigActive_ =
false;
51 bool Foam::sigFpe::nanActive_ =
false;
59 #ifndef Foam_no_sigFpe
61 _controlfp(
oldFpe_, 0xFFFFFFFF);
70 static bool isTrue(
const char* envName,
bool deflt)
91 void Foam::sigFpe::sigHandler(
int)
112 wasActive_(
sigFpe::active())
149 return isTrue(
"FOAM_SIGFPE", switchFpe_);
157 #ifdef Foam_no_sigFpe
161 Info<<
"trapFpe: Floating point exception trapping ";
162 Info<<
"- disabled on this platform" <<
endl;
169 const unsigned int newFpe =
171 oldFpe_ & ~(_EM_ZERODIVIDE | _EM_INVALID | _EM_OVERFLOW)
174 _controlfp(newFpe, _MCW_EM);
182 Info<<
"trapFpe: Floating point exception trapping ";
186 Info<<
"enabled (FOAM_SIGFPE)." <<
endl;
190 Info<<
"- not supported on this platform" <<
endl;
198 if (
isTrue(
"FOAM_SETNAN", switchNan_))
202 Info<<
"setNaN : Initialise allocated memory to NaN "
203 <<
"- not supported on this platform" <<
endl;
215 Info<<
"sigFpe : Disabling floating point exception trapping"
232 list = std::numeric_limits<scalar>::signaling_NaN();
static void set(bool verbose=false)
Activate SIGFPE signal handler when FOAM_SIGFPE is set.
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
static void printStack(Ostream &os)
Helper function to print a stack.
Useful combination of include files which define Sin, Sout and Serr and the use of IO streams general...
static void resetHandler(const char *what, int sigNum)
ignore()
Constructor deactivates any previously active SIGFPE handler.
bool valid() const noexcept
True if the Switch represents a valid enumeration.
static void unset(bool verbose=false)
Deactivate SIGFPE signal handler and NaN memory initialisation.
Ostream & endl(Ostream &os)
Add newline and flush stream.
string getEnv(const std::string &envName)
Get environment value for given envName.
static void fillNan(UList< scalar > &list)
Fill data block with NaN values.
messageStream Info
Information stream (uses stdout - output is on the master only)
~ignore()
Destructor restores the original state of SIGFPE handler.
File-local code for setting/resetting signal handlers.
int optimisationSwitch(const char *name, const int deflt=0)
Lookup optimisation switch or add default value.
Set up trapping for floating point exceptions (signal FPE).
static bool requested()
Check if SIGFPE signals handler is to be enabled.
prefixOSstream Perr
An Ostream wrapper for parallel output to std::cerr.
static void setHandler(const char *what, int sigNum, void(*handler)(int))
void restore()
Restore the original state of SIGFPE handler.
static unsigned int oldFpe_
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
void signalEnd() const
Update job info and relocate the file from running to finished.
static bool isTrue(const char *envName, bool deflt)