add support for trapping floating point exception as an optional compile time feature
we may make this a run time setting by connecting this code to a command.
This commit is contained in:
16
src/main.cpp
16
src/main.cpp
@ -18,6 +18,10 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#if defined(LAMMPS_TRAP_FPE) && defined(_GNU_SOURCE)
|
||||
#include <fenv.h>
|
||||
#endif
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -28,6 +32,18 @@ int main(int argc, char **argv)
|
||||
{
|
||||
MPI_Init(&argc,&argv);
|
||||
|
||||
// enable trapping selected floating point exceptions.
|
||||
// this uses GNU extensions and is only tested on Linux
|
||||
// therefore we make it depend on -D_GNU_SOURCE, too.
|
||||
|
||||
#if defined(LAMMPS_TRAP_FPE) && defined(_GNU_SOURCE)
|
||||
fesetenv(FE_NOMASK_ENV);
|
||||
fedisableexcept(FE_ALL_EXCEPT);
|
||||
feenableexcept(FE_DIVBYZERO);
|
||||
feenableexcept(FE_INVALID);
|
||||
feenableexcept(FE_OVERFLOW);
|
||||
#endif
|
||||
|
||||
#ifdef LAMMPS_EXCEPTIONS
|
||||
try {
|
||||
LAMMPS *lammps = new LAMMPS(argc,argv,MPI_COMM_WORLD);
|
||||
|
||||
Reference in New Issue
Block a user