50bool Foam::sigFpe::sigActive_ =
false;
51bool Foam::sigFpe::nanActive_ =
false;
59 #ifndef Foam_no_sigFpe
61 _controlfp(
oldFpe_, 0xFFFFFFFF);
70static bool isTrue(
const char* envName,
bool deflt)
76 return static_cast<bool>(sw);
86void Foam::sigFpe::sigHandler(
int)
107 wasActive_(
sigFpe::active())
144 return isTrue(
"FOAM_SIGFPE", switchFpe_);
152 #ifdef Foam_no_sigFpe
156 Info<<
"trapFpe: Floating point exception trapping ";
157 Info<<
"- disabled on this platform" <<
endl;
164 const unsigned int newFpe =
166 oldFpe_ & ~(_EM_ZERODIVIDE | _EM_INVALID | _EM_OVERFLOW)
169 _controlfp(newFpe, _MCW_EM);
177 Info<<
"trapFpe: Floating point exception trapping ";
181 Info<<
"enabled (FOAM_SIGFPE)." <<
endl;
185 Info<<
"- not supported on this platform" <<
endl;
193 if (
isTrue(
"FOAM_SETNAN", switchNan_))
197 Info<<
"setNaN : Initialise allocated memory to NaN "
198 <<
"- not supported on this platform" <<
endl;
210 Info<<
"sigFpe : Disabling floating point exception trapping"
227 list = std::numeric_limits<scalar>::signaling_NaN();
Useful combination of include files which define Sin, Sout and Serr and the use of IO streams general...
static bool isTrue(const char *envName, bool deflt)
static unsigned int oldFpe_
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
File-local code for setting/resetting signal handlers.
static void shutdown()
Simple shutdown (finalize) of JobInfo.
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
bool good() const noexcept
True if the Switch represents a valid enumeration.
static Switch find(const std::string &str)
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
static void printStack(Ostream &os)
Helper function to print a stack.
ignore()
Constructor deactivates any previously active SIGFPE handler.
~ignore()
Destructor restores the original state of SIGFPE handler.
void restore()
Restore the original state of SIGFPE handler.
Set up trapping for floating point exceptions (signal FPE).
static void fillNan(UList< scalar > &list)
Fill data block with NaN values.
static void unset(bool verbose=false)
Deactivate SIGFPE signal handler and NaN memory initialisation.
static bool requested()
Check if SIGFPE signals handler is to be enabled.
bool set() const
Are all the vector set.
int optimisationSwitch(const char *name, const int deflt=0)
Lookup optimisation switch or add default value.
string getEnv(const std::string &envName)
Get environment value for given envName.
prefixOSstream Perr
OSstream wrapped stderr (std::cerr) with parallel prefix.
static void setHandler(const char *what, int sigNum, void(*handler)(int))
messageStream Info
Information stream (stdout output on master, null elsewhere)
Ostream & endl(Ostream &os)
Add newline and flush stream.
static void resetHandler(const char *what, int sigNum)