aboutsummaryrefslogtreecommitdiff
path: root/src/DumpVar.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/DumpVar.c')
-rw-r--r--src/DumpVar.c43
1 files changed, 27 insertions, 16 deletions
diff --git a/src/DumpVar.c b/src/DumpVar.c
index 117bf5f..d57b6ac 100644
--- a/src/DumpVar.c
+++ b/src/DumpVar.c
@@ -222,26 +222,37 @@ static int WriteGS (const cGH *GH, const ioRequest *request, IOFile file)
CCTK_VarDataPtrI (GH, request->timelevel, request->vindex),
hdatatypesize);
- i = CCTK_ReductionHandle ("sum");
- if (CCTK_ReduceArray (GH, -1, i, nprocs, request->hdatatype,
- buffer, 1, 1, request->hdatatype, nprocs, buffer))
+ if (nprocs > 1)
{
- CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
- "WriteGS: Failed to reduce grid scalar '%s'", fullname);
- }
- else
- {
- retval = 0;
- for (i = 1; i < nprocs; i++)
- {
- retval |= memcmp (buffer, buffer + i*hdatatypesize, hdatatypesize);
+ i = CCTK_ReductionHandle ("sum");
+ if (i >= 0)
+ {
+ i = CCTK_ReduceArray (GH, -1, i, nprocs, request->hdatatype,
+ buffer, 1, 1, request->hdatatype, nprocs, buffer);
}
- if (retval)
+ if (i < 0)
{
CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
- "WriteGS: value of grid scalar variable '%s' (timelevel %d) "
- "differs between processors, only value from processor 0 "
- "will be written", fullname, request->timelevel);
+ "WriteGS: Cannot check whether values on different "
+ "processors are the same for grid scalar '%s'", fullname);
+
+ /* copy this processor's value to the start of buffer */
+ memcpy (buffer, buffer + myproc*hdatatypesize, hdatatypesize);
+ }
+ else
+ {
+ retval = 0;
+ for (i = 1; i < nprocs; i++)
+ {
+ retval |= memcmp (buffer, buffer + i*hdatatypesize, hdatatypesize);
+ }
+ if (retval)
+ {
+ CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "WriteGS: value of grid scalar variable '%s' (timelevel %d)"
+ " differs between processors, only value from processor 0 "
+ "will be written", fullname, request->timelevel);
+ }
}
}