From aa6a9439ca3eb6f547ca8ec1c03d81d1394f2b96 Mon Sep 17 00:00:00 2001 From: schnetter Date: Tue, 28 Apr 2009 19:48:06 +0000 Subject: Correct indexing error in parallel arrays git-svn-id: http://svn.cactuscode.org/arrangements/CactusNumerical/InterpToArray/trunk@12 6ca9aeac-0e4f-0410-a746-fe4df63e9d0c --- src/interp.c | 90 ++++++++++++++++++++++++++++++++++++------------------------ 1 file changed, 54 insertions(+), 36 deletions(-) diff --git a/src/interp.c b/src/interp.c index e98398f..fa3ad16 100644 --- a/src/interp.c +++ b/src/interp.c @@ -59,11 +59,11 @@ InterpToArray (CCTK_ARGUMENTS) npoints = 1; coordsx = malloc (npoints * sizeof * coordsx); - assert (coordsx); + assert (npoints==0 || coordsx); coordsy = malloc (npoints * sizeof * coordsy); - assert (coordsy); + assert (npoints==0 || coordsy); coordsz = malloc (npoints * sizeof * coordsz); - assert (coordsz); + assert (npoints==0 || coordsz); coords[0] = coordsx; coords[1] = coordsy; coords[2] = coordsz; @@ -125,11 +125,11 @@ InterpToArray (CCTK_ARGUMENTS) npoints = array1d_npoints_i; coordsx = malloc (npoints * sizeof * coordsx); - assert (coordsx); + assert (npoints==0 || coordsx); coordsy = malloc (npoints * sizeof * coordsy); - assert (coordsy); + assert (npoints==0 || coordsy); coordsz = malloc (npoints * sizeof * coordsz); - assert (coordsz); + assert (npoints==0 || coordsz); coords[0] = coordsx; coords[1] = coordsy; coords[2] = coordsz; @@ -224,11 +224,11 @@ InterpToArray (CCTK_ARGUMENTS) npoints = array2d_npoints_i * array2d_npoints_j; coordsx = malloc (npoints * sizeof * coordsx); - assert (coordsx); + assert (npoints==0 || coordsx); coordsy = malloc (npoints * sizeof * coordsy); - assert (coordsy); + assert (npoints==0 || coordsy); coordsz = malloc (npoints * sizeof * coordsz); - assert (coordsz); + assert (npoints==0 || coordsz); coords[0] = coordsx; coords[1] = coordsy; coords[2] = coordsz; @@ -294,11 +294,11 @@ InterpToArray (CCTK_ARGUMENTS) npoints = array3d_npoints_i * array3d_npoints_j * array3d_npoints_k; coordsx = malloc (npoints * sizeof * coordsx); - assert (coordsx); + assert (npoints==0 || coordsx); coordsy = malloc (npoints * sizeof * coordsy); - assert (coordsy); + assert (npoints==0 || coordsy); coordsz = malloc (npoints * sizeof * coordsz); - assert (coordsz); + assert (npoints==0 || coordsz); coords[0] = coordsx; coords[1] = coordsy; coords[2] = coordsz; @@ -371,21 +371,24 @@ InterpToArray (CCTK_ARGUMENTS) npoints = dyndata.lsh[0]; coordsx = malloc (npoints * sizeof * coordsx); - assert (coordsx); + assert (npoints==0 || coordsx); coordsy = malloc (npoints * sizeof * coordsy); - assert (coordsy); + assert (npoints==0 || coordsy); coordsz = malloc (npoints * sizeof * coordsz); - assert (coordsz); + assert (npoints==0 || coordsz); coords[0] = coordsx; coords[1] = coordsy; coords[2] = coordsz; n = 0; - for (i=0; i