aboutsummaryrefslogtreecommitdiff
path: root/src/ReductionMax.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ReductionMax.c')
-rw-r--r--src/ReductionMax.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/ReductionMax.c b/src/ReductionMax.c
index bc02aa0..a1fceb8 100644
--- a/src/ReductionMax.c
+++ b/src/ReductionMax.c
@@ -11,6 +11,7 @@
#include <stdlib.h>
#include <string.h>
+#include <float.h>
#include "pugh_reductions.h"
@@ -27,6 +28,7 @@ static int ReductionMaxVal (const cGH *GH,
int iterator[/* dim */],
const int points_per_dim[/* dim */],
int num_points,
+ int have_local_points,
int num_inarrays,
const int intypes[/* num_inarrays */],
const void *const inarrays[/* num_inarrays */],
@@ -205,6 +207,7 @@ static int ReductionMaxVal (const cGH *GH,
int iterator[/* dim */],
const int points_per_dim[/* dim */],
int num_points,
+ int have_local_points,
int num_inarrays,
const int intypes[/* num_inarrays */],
const void *const inarrays[/* num_inarrays */],
@@ -321,8 +324,19 @@ static int ReductionMaxVal (const cGH *GH,
{
local_outvals = malloc (total_outvals * sizeof (CCTK_REAL));
- /* outvals[] contains now the local maximum */
- memcpy (local_outvals, outvals, total_outvals * sizeof (CCTK_REAL));
+ if (have_local_points)
+ {
+ /* outvals[] contains now the local maximum */
+ memcpy (local_outvals, outvals, total_outvals * sizeof (CCTK_REAL));
+ }
+ else
+ {
+ /* initialize local values to be smallest possible fp number */
+ for (i = 0; i < total_outvals; i++)
+ {
+ local_outvals[i] = -DBL_MAX;
+ }
+ }
if (proc < 0)
{
CACTUS_MPI_ERROR (MPI_Allreduce (local_outvals, outvals, total_outvals,