From c525f0edb0828eb8ba17736a8ff7d2e5a1a3f1d2 Mon Sep 17 00:00:00 2001 From: brucefan1983 Date: Wed, 14 Aug 2024 23:58:19 +0800 Subject: [PATCH 1/3] detect nan and inf from input file --- src/utilities/error.cu | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/utilities/error.cu b/src/utilities/error.cu index e34fad802..71f25ffcb 100644 --- a/src/utilities/error.cu +++ b/src/utilities/error.cu @@ -161,6 +161,14 @@ int get_int_from_token(const std::string& token, const char* filename, const int std::cout << " Error message: " << e.what() << std::endl; exit(1); } + if (std::isinf(value)) { + std::cout << "This number is inf.\n"; + exit(1); + } + if (std::isnan(value)) { + std::cout << "This number is nan.\n"; + exit(1); + } return value; } @@ -176,6 +184,14 @@ float get_float_from_token(const std::string& token, const char* filename, const std::cout << " Error message: " << e.what() << std::endl; exit(1); } + if (std::isinf(value)) { + std::cout << "This number is inf.\n"; + exit(1); + } + if (std::isnan(value)) { + std::cout << "This number is nan.\n"; + exit(1); + } return value; } @@ -191,5 +207,13 @@ double get_double_from_token(const std::string& token, const char* filename, con std::cout << " Error message: " << e.what() << std::endl; exit(1); } + if (std::isinf(value)) { + std::cout << "This number is inf.\n"; + exit(1); + } + if (std::isnan(value)) { + std::cout << "This number is nan.\n"; + exit(1); + } return value; } From eaa10613f2ed3824fdd36fa8cdd9c93706180afb Mon Sep 17 00:00:00 2001 From: brucefan1983 Date: Wed, 14 Aug 2024 23:59:54 +0800 Subject: [PATCH 2/3] include header --- src/utilities/error.cu | 1 + 1 file changed, 1 insertion(+) diff --git a/src/utilities/error.cu b/src/utilities/error.cu index 71f25ffcb..899f9fb2a 100644 --- a/src/utilities/error.cu +++ b/src/utilities/error.cu @@ -14,6 +14,7 @@ */ #include "error.cuh" +#include #include #include #include From 74c8d18e251dbc7651302ce9c7b8d3697d0f044f Mon Sep 17 00:00:00 2001 From: brucefan1983 Date: Thu, 15 Aug 2024 14:14:58 +0800 Subject: [PATCH 3/3] no isnan for int --- src/utilities/error.cu | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/utilities/error.cu b/src/utilities/error.cu index 899f9fb2a..296474980 100644 --- a/src/utilities/error.cu +++ b/src/utilities/error.cu @@ -162,14 +162,6 @@ int get_int_from_token(const std::string& token, const char* filename, const int std::cout << " Error message: " << e.what() << std::endl; exit(1); } - if (std::isinf(value)) { - std::cout << "This number is inf.\n"; - exit(1); - } - if (std::isnan(value)) { - std::cout << "This number is nan.\n"; - exit(1); - } return value; }