diff --git a/Cantera/src/base/checkFinite.cpp b/Cantera/src/base/checkFinite.cpp index 4910b1a0a..b20096b99 100644 --- a/Cantera/src/base/checkFinite.cpp +++ b/Cantera/src/base/checkFinite.cpp @@ -29,6 +29,12 @@ #include #endif +#ifdef WIN32 +#include +#pragma warning(disable:4290) +#pragma warning(disable:4996) +#endif + using namespace std; @@ -38,6 +44,21 @@ namespace mdp { /* * @param tmp number to be checked */ +#ifdef WIN32 + void checkFinite(const double tmp) throw(std::range_error) { + if (_finite(tmp)) { + if(_isnan(tmp)) { + printf("ERROR: we have encountered a nan!\n"); + } else if (_fpclass(tmp) == _FPCLASS_PINF) { + printf("ERROR: we have encountered a pos inf!\n"); + } else { + printf("ERROR: we have encountered a neg inf!\n"); + } + const std::string s = "checkFinite()"; + throw std::range_error(s); + } + } +#else void checkFinite(const double tmp) throw(std::range_error) { if (! finite(tmp)) { if(isnan(tmp)) { @@ -51,6 +72,7 @@ namespace mdp { throw std::range_error(s); } } +#endif // Utility routine to link checkFinte() to fortran program @@ -91,6 +113,25 @@ namespace mdp { * * @param tmp number to be checked */ +#ifdef WIN32 +void checkZeroFinite(const double tmp) throw(std::range_error) { + if ((tmp == 0.0) || (! _finite(tmp))) { + if (tmp == 0.0) { + printf("ERROR: we have encountered a zero!\n"); + } else if(_isnan(tmp)) { + printf("ERROR: we have encountered a nan!\n"); + } else if (_fpclass(tmp) == _FPCLASS_PINF) { + printf("ERROR: we have encountered a pos inf!\n"); + } else { + printf("ERROR: we have encountered a neg inf!\n"); + } + char sbuf[64]; + sprintf(sbuf, "checkZeroFinite: zero or indef exceeded: %g\n", + tmp); + throw std::range_error(sbuf); + } + } +#else void checkZeroFinite(const double tmp) throw(std::range_error) { if ((tmp == 0.0) || (! finite(tmp))) { if (tmp == 0.0) { @@ -108,5 +149,5 @@ namespace mdp { throw std::range_error(sbuf); } } - +#endif } diff --git a/Cantera/src/base/mdp_allo.cpp b/Cantera/src/base/mdp_allo.cpp index 3ed6490ff..28d646fee 100644 --- a/Cantera/src/base/mdp_allo.cpp +++ b/Cantera/src/base/mdp_allo.cpp @@ -23,6 +23,10 @@ using namespace std; +#ifdef WIN32 +#pragma warning(disable:4996) +#endif + namespace mdp { /* * Allocate global storage for 2 debugging ints that are used in IO of diff --git a/Cantera/src/base/mdp_allo.h b/Cantera/src/base/mdp_allo.h index 7dc744407..ef41f9b95 100644 --- a/Cantera/src/base/mdp_allo.h +++ b/Cantera/src/base/mdp_allo.h @@ -18,6 +18,10 @@ #ifndef MDP_ALLO_H #define MDP_ALLO_H +#ifdef WIN32 +#pragma warning(disable:4290) +#endif + #include /*