aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortradke <tradke@b32723a9-ab3a-4a60-88e2-2e5d99d7c17a>2004-05-14 17:09:35 +0000
committertradke <tradke@b32723a9-ab3a-4a60-88e2-2e5d99d7c17a>2004-05-14 17:09:35 +0000
commitb6a4d28eb800dc1b10335f7cc12d1b0ea32ac388 (patch)
treeef6e2c24373dc684db38dc7b7ef4a9256834338e
parent43ab51690c928f935a44da4f6460a55fe4fc3bb1 (diff)
Fixed a bug in the 1D line / 2D slice center setup.
git-svn-id: http://svn.cactuscode.org/arrangements/CactusBase/IOUtil/trunk@206 b32723a9-ab3a-4a60-88e2-2e5d99d7c17a
-rw-r--r--src/Utils.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/src/Utils.c b/src/Utils.c
index af74e7a..7c06e83 100644
--- a/src/Utils.c
+++ b/src/Utils.c
@@ -384,7 +384,7 @@ int IOUtil_1DLines (const cGH *GH,
/* line always starts at the first point */
slice_center[dir][dim] = 0;
}
- else if (have_origin_index)
+ else if (origin_index[dir][dim] >= 0)
{
/* FIXME: check upper index bounds also ?? */
slice_center[dir][dim] = origin_index[dir][dim];
@@ -476,7 +476,7 @@ int IOUtil_2DPlanes (const cGH *GH,
const CCTK_REAL *origin_phys,
int *slice_center)
{
- int have_coords, len, coord_system_handle, dir;
+ int have_coords, have_origin_index, len, coord_system_handle, dir;
char *coord_system_name;
CCTK_INT *coord_handles;
CCTK_REAL *lower, *upper;
@@ -501,16 +501,15 @@ int IOUtil_2DPlanes (const cGH *GH,
}
}
- for (dir = 0; dir < num_dims && origin_index; dir++)
+ /* check that origin_index[] is valid */
+ have_origin_index = origin_index != NULL;
+ for (dir = 0; dir < num_dims && have_origin_index; dir++)
{
- if (origin_index[dir] < 0)
- {
- origin_index = NULL;
- }
+ have_origin_index = origin_index[dir] >= 0;
}
/* if no coordinate system is available then origin_index[] must be given */
- if (! have_coords && ! origin_index)
+ if (! have_coords && ! have_origin_index)
{
CCTK_VWarn (3, __LINE__, __FILE__, CCTK_THORNSTRING,
"IOUtil_2DPlanes: Found no default Cartesian coordinate system "
@@ -528,7 +527,7 @@ int IOUtil_2DPlanes (const cGH *GH,
/* get the ranges in every direction */
lower = calloc (2 * num_dims, sizeof (CCTK_REAL));
upper = lower + num_dims;
- if (! origin_index)
+ if (have_coords)
{
for (dir = 0; dir < num_dims; dir++)
{
@@ -547,7 +546,7 @@ int IOUtil_2DPlanes (const cGH *GH,
according to origin_index[] or origin_phys[] */
for (dir = 0; dir < num_dims; dir++)
{
- if (origin_index)
+ if (origin_index && origin_index[dir] >= 0)
{
slice_center[dir] = origin_index[dir];
}