From d3f05769b53ce9c95d38097b9535d8a0bdbf3180 Mon Sep 17 00:00:00 2001 From: tradke Date: Mon, 24 Nov 2008 10:45:49 +0000 Subject: Bugfix: reset NaN counter at INITIAL/PRESTEP in global mode. Before it was scheduled at POSTSTEP in level mode, and hence called too often to trigger NaNChecker output when a NaN was found on coarse refinement levels. git-svn-id: http://svn.cactuscode.org/arrangements/CactusUtils/NaNChecker/trunk@85 ff385933-4943-42dc-877b-ffc776028de6 --- schedule.ccl | 10 ++++++++-- src/NaNCheck.c | 15 ++++++++++----- 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; + } } -- cgit v1.2.3