From bfcdabcd04c25991fbdd2aa22eac183fdc7c71fe Mon Sep 17 00:00:00 2001 From: tradke Date: Mon, 10 Feb 2003 17:19:25 +0000 Subject: Tolerate negative variable indices which should be treated as a no-op for the corresponding input array entry. git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGH/PUGHInterp/trunk@49 1c20744c-e24a-42ec-9533-f5004cb800e5 --- src/InterpGridArrays.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/InterpGridArrays.c b/src/InterpGridArrays.c index 3fc2ab0..39de534 100644 --- a/src/InterpGridArrays.c +++ b/src/InterpGridArrays.c @@ -267,8 +267,8 @@ int PUGHInterp_InterpGridArrays (const cGH *GH, /* allocate some temporary arrays */ origin_local = malloc (2 * N_dims * sizeof (CCTK_REAL)); delta = origin_local + N_dims; - input_arrays = malloc (N_input_arrays * sizeof (void *)); - input_array_dims = malloc ((N_dims + 2*N_input_arrays) * sizeof (CCTK_INT)); + input_arrays = calloc (N_input_arrays, sizeof (void *)); + input_array_dims = calloc (N_dims + 2*N_input_arrays, sizeof (CCTK_INT)); input_array_types = input_array_dims + N_dims; input_array_time_levels = input_array_dims + N_dims + N_input_arrays; @@ -309,6 +309,13 @@ int PUGHInterp_InterpGridArrays (const cGH *GH, (but their dimensionality can be less) */ for (i = retval = 0; i < N_input_arrays; i++) { + /* tolerate negative variable indices which should be treated as no-ops + for the corresponding input array entries */ + if (input_array_indices[i] < 0) + { + continue; + } + if (CCTK_GroupDynamicData (GH, CCTK_GroupIndexFromVarI(input_array_indices[i]), &group_data) < 0) -- cgit v1.2.3