aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortradke <tradke@ff385933-4943-42dc-877b-ffc776028de6>2003-07-25 09:58:53 +0000
committertradke <tradke@ff385933-4943-42dc-877b-ffc776028de6>2003-07-25 09:58:53 +0000
commit9f4ca03b6558cd9ccac93c34e43523fb2a88b95b (patch)
tree1931f2ec24810e1f48a86a985dbe9b5324cf2c6d
parentd14d12c65f433ea0525e35c41809f3dcb6b482bb (diff)
Need to reduce the NaN count values on all processors if NaNmask output was
requested. Otherwise CCTK_OutputVarAsByMethod() would deadlock. git-svn-id: http://svn.cactuscode.org/arrangements/CactusUtils/NaNChecker/trunk@47 ff385933-4943-42dc-877b-ffc776028de6
-rw-r--r--src/NaNCheck.c40
1 files changed, 23 insertions, 17 deletions
diff --git a/src/NaNCheck.c b/src/NaNCheck.c
index dde9228..a1089e0 100644
--- a/src/NaNCheck.c
+++ b/src/NaNCheck.c
@@ -69,7 +69,7 @@ typedef struct
int verbose;
int report_max;
const char *action_if_found;
- int count;
+ CCTK_INT count, sum;
CCTK_INT *NaNmask;
int bitmask;
#ifdef HAVE_FINITE
@@ -109,8 +109,7 @@ static int last_iteration_output = -1;
@@*/
int NaNChecker_NaNCheck (const cGH *GH)
{
- int i, nelems, retval;
- const char *method;
+ int i, nelems, sum_handle, retval;
t_nanchecker_info info;
DECLARE_CCTK_PARAMETERS
@@ -121,7 +120,7 @@ int NaNChecker_NaNCheck (const cGH *GH)
}
info.GH = GH;
- info.count = 0;
+ info.count = info.sum = 0;
info.bitmask = 0;
info.report_max = report_max;
info.action_if_found = action_if_found;
@@ -164,22 +163,29 @@ int NaNChecker_NaNCheck (const cGH *GH)
retval = CCTK_TraverseString (check_vars, CheckForNaN, &info,
CCTK_GROUP_OR_VAR);
- if (info.count > 0)
+ if (info.NaNmask && info.bitmask)
{
- /* if NaNs were found then output NaN mask with the 'IOHDF5' I/O method */
- if (info.NaNmask && info.bitmask)
- {
- if (info.verbose)
- {
- CCTK_INFO ("Write out NaN mask using the 'IOHDF5' I/O method");
- }
- CCTK_OutputVarAsByMethod (GH, "NaNChecker::NaNmask[downsample={1 1 1}]",
- "IOHDF5", "NaNmask");
+ sum_handle = CCTK_ReductionHandle ("sum");
+ CCTK_ReduceLocalScalar (GH, -1, sum_handle, &info.count, &info.sum,
+ CCTK_VARIABLE_INT);
+ }
- /* save the iteration of the last NaNmask output */
- last_iteration_output = GH->cctk_iteration;
+ /* if NaNs were found then output NaN mask with the 'IOHDF5' I/O method */
+ if (info.sum > 0)
+ {
+ if (info.verbose)
+ {
+ CCTK_INFO ("Write out NaN mask using the 'IOHDF5' I/O method");
}
+ CCTK_OutputVarAsByMethod (GH, "NaNChecker::NaNmask[downsample={1 1 1}]",
+ "IOHDF5", "NaNmask");
+
+ /* save the iteration of the last NaNmask output */
+ last_iteration_output = GH->cctk_iteration;
+ }
+ if (info.count > 0)
+ {
if (CCTK_Equals (info.action_if_found, "terminate"))
{
CCTK_WARN (1, "'action_if_found' parameter is set to 'terminate' - "
@@ -568,7 +574,7 @@ static void PrintWarning (const char *error_type,
#define CHECK_DATA(cctk_type) \
{ \
int _i; \
- const cctk_type *_data = (const cctk_type *) data; \
+ const cctk_type *_data = data; \
\
\
/* now loop over all elements and check against NaN's */ \