From b6a4d28eb800dc1b10335f7cc12d1b0ea32ac388 Mon Sep 17 00:00:00 2001 From: tradke Date: Fri, 14 May 2004 17:09:35 +0000 Subject: 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 --- src/Utils.c | 19 +++++++++---------- 1 file 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]; } -- cgit v1.2.3