aboutsummaryrefslogtreecommitdiff
path: root/src/ReduceArraysGlobally.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ReduceArraysGlobally.c')
-rw-r--r--src/ReduceArraysGlobally.c32
1 files changed, 21 insertions, 11 deletions
diff --git a/src/ReduceArraysGlobally.c b/src/ReduceArraysGlobally.c
index 23f4a91..b5418f9 100644
--- a/src/ReduceArraysGlobally.c
+++ b/src/ReduceArraysGlobally.c
@@ -180,7 +180,6 @@ static int ReduceArraysGlobally (const cGH *GH,
CCTK_INT * min_array_subscript;
CCTK_INT * array_lsh;
CCTK_INT * input_array_dims;
-
CCTK_INT * input_array_gz;
/* temporary complex variables*/
@@ -223,12 +222,15 @@ static int ReduceArraysGlobally (const cGH *GH,
dim = input_dims;
/* allocate memory for the array of the dimensions of the input arrays */
- lower_array_bounds = (CCTK_INT *)malloc (dim *sizeof(CCTK_INT));
- min_array_subscript = (CCTK_INT *)malloc (dim *sizeof(CCTK_INT));
- array_lsh = (CCTK_INT *)malloc (dim *sizeof(CCTK_INT));
- input_array_dims = (CCTK_INT *)malloc (dim *sizeof(CCTK_INT));
- input_array_gz = (CCTK_INT *)malloc (dim *sizeof(CCTK_INT));
-
+ if (dim>0)
+ {
+ lower_array_bounds = (CCTK_INT *)malloc (dim *sizeof(CCTK_INT));
+ min_array_subscript = (CCTK_INT *)malloc (dim *sizeof(CCTK_INT));
+ array_lsh = (CCTK_INT *)malloc (dim *sizeof(CCTK_INT));
+ input_array_dims = (CCTK_INT *)malloc (dim *sizeof(CCTK_INT));
+ input_array_gz = (CCTK_INT *)malloc (dim *sizeof(CCTK_INT));
+ }
+
/* calculate index ranges */
for ( i=0; i < dim; i++)
{
@@ -769,12 +771,20 @@ static int ReduceArraysGlobally (const cGH *GH,
break;
#endif
}
- }
- num_points = total_num_points;
- weight_sum = total_weight_sum;
free (local_outvals);
+ }
+ num_points = total_num_points;
+ weight_sum = total_weight_sum;
#endif
-
+ if (dim >0)
+ {
+ free (lower_array_bounds);
+ free (min_array_subscript);
+ free (array_lsh);
+ free (input_array_dims);
+ free (input_array_gz);
+ }
+
if (perform_division == 0)
{
if (weight_on == 1)