diff options
Diffstat (limited to 'src/ReductionNorm1.c')
-rw-r--r-- | src/ReductionNorm1.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/ReductionNorm1.c b/src/ReductionNorm1.c index 4c4209b..1394a4a 100644 --- a/src/ReductionNorm1.c +++ b/src/ReductionNorm1.c @@ -28,6 +28,7 @@ static int ReductionNorm1 (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 */], @@ -209,6 +210,7 @@ static int ReductionNorm1 (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 */], @@ -352,8 +354,16 @@ static int ReductionNorm1 (const cGH *GH, { local_outvals = malloc (total_outvals * sizeof (CCTK_REAL)); - /* outvals[] contains now the local sum */ - memcpy (local_outvals, outvals, total_outvals * sizeof (CCTK_REAL)); + if (have_local_points) + { + /* outvals[] contains now the local sum */ + memcpy (local_outvals, outvals, total_outvals * sizeof (CCTK_REAL)); + } + else + { + /* initialize local values to zero */ + memset (local_outvals, 0, total_outvals * sizeof (CCTK_REAL)); + } if (proc < 0) { CACTUS_MPI_ERROR (MPI_Allreduce (local_outvals, outvals, total_outvals, |