aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--schedule.ccl10
-rw-r--r--src/NaNCheck.c15
2 files changed, 18 insertions, 7 deletions
diff --git a/schedule.ccl b/schedule.ccl
index 8ffb2c7..89c6cbd 100644
--- a/schedule.ccl
+++ b/schedule.ccl
@@ -5,10 +5,16 @@ if (*check_vars && check_every > 0)
{
STORAGE: NaNmask NaNsFound
- schedule NaNChecker_ResetCounter at POSTSTEP before NaNChecker_NaNCheck
+ schedule NaNChecker_ResetCounter at INITIAL
{
LANG: C
- OPTIONS: level
+ OPTIONS: global
+ } "Reset the NaNChecker::NaNsFound counter"
+
+ schedule NaNChecker_ResetCounter at PRESTEP
+ {
+ LANG: C
+ OPTIONS: global
} "Reset the NaNChecker::NaNsFound counter"
schedule NaNChecker_NaNCheck at POSTSTEP
diff --git a/src/NaNCheck.c b/src/NaNCheck.c
index 70a37df..dfa59be 100644
--- a/src/NaNCheck.c
+++ b/src/NaNCheck.c
@@ -131,7 +131,7 @@ void NaNChecker_NaNCheck (CCTK_ARGUMENTS)
{
DECLARE_CCTK_ARGUMENTS;
DECLARE_CCTK_PARAMETERS;
- int i, nelems, sum_handle;
+ int i, nelems;
t_nanchecker_info info;
@@ -141,7 +141,7 @@ void NaNChecker_NaNCheck (CCTK_ARGUMENTS)
}
info.GH = cctkGH;
- info.count = *NaNsFound = 0;
+ info.count = 0;
info.bitmask = 0;
info.report_max = report_max;
info.action_if_found = action_if_found;
@@ -182,9 +182,14 @@ void NaNChecker_NaNCheck (CCTK_ARGUMENTS)
CCTK_TraverseString (check_vars, CheckForNaN, &info, CCTK_GROUP_OR_VAR);
- sum_handle = CCTK_ReductionHandle ("sum");
- CCTK_ReduceLocalScalar (cctkGH, -1, sum_handle, &info.count, NaNsFound,
- CCTK_VARIABLE_INT);
+ /* reduce the NaN counter globally and accumulate in NaNChecker::NaNsFound */
+ {
+ int sum_handle = CCTK_ReductionHandle ("sum");
+ CCTK_INT count = 0;
+ CCTK_ReduceLocalScalar (cctkGH, -1, sum_handle, &info.count, &count,
+ CCTK_VARIABLE_INT);
+ *NaNsFound += count;
+ }
}