summaryrefslogtreecommitdiff
path: root/src/main/Coord.c
diff options
context:
space:
mode:
authortradke <tradke@17b73243-c579-4c4c-a9d2-2d5706c11dac>2000-09-18 09:56:45 +0000
committertradke <tradke@17b73243-c579-4c4c-a9d2-2d5706c11dac>2000-09-18 09:56:45 +0000
commit15b9031b532de6634e90c9f22d29fddfef205842 (patch)
tree914acaaad5cf3c7d7c9335d7c1024970175aa226 /src/main/Coord.c
parentf507c325c34afcc78dc63d68f83480689f4d834a (diff)
Fixing BR 431 and 432.
git-svn-id: http://svn.cactuscode.org/flesh/trunk@1824 17b73243-c579-4c4c-a9d2-2d5706c11dac
Diffstat (limited to 'src/main/Coord.c')
-rw-r--r--src/main/Coord.c75
1 files changed, 53 insertions, 22 deletions
diff --git a/src/main/Coord.c b/src/main/Coord.c
index 1295583c..0680c932 100644
--- a/src/main/Coord.c
+++ b/src/main/Coord.c
@@ -642,10 +642,29 @@ int CCTK_CoordRange(cGH *GH,
int i;
int retval=0;
struct Coordpropslist *curr;
- struct Coordsystem *data=NULL;
- struct Coordprops coord;
+ struct Coordsystem *data;
+ struct Coordprops *coord;
- if (CoordSystemHash)
+
+ if (lower == NULL || upper == NULL)
+ {
+ CCTK_Warn (2, __LINE__, __FILE__, "Cactus",
+ "CCTK_CoordRange: NULL pointer(s) passed for lower/upper");
+ retval = -1;
+ }
+ else if (coorddir <= 0 && coordname == NULL)
+ {
+ CCTK_Warn (2, __LINE__, __FILE__, "Cactus",
+ "CCTK_CoordRange: No coordinate name given");
+ retval = -2;
+ }
+ else if (systemname == NULL)
+ {
+ CCTK_Warn (2, __LINE__, __FILE__, "Cactus",
+ "CCTK_CoordRange: No coordinate system name given");
+ retval = -3;
+ }
+ else if (CoordSystemHash)
{
data = (struct Coordsystem *)Util_HashData(CoordSystemHash,
strlen(systemname),
@@ -656,54 +675,66 @@ int CCTK_CoordRange(cGH *GH,
{
if (coorddir>0)
{
- coord = data->coords[coorddir-1];
+ coord = &data->coords[coorddir-1];
}
else
{
+ coord = NULL;
for (i=0;i<data->dimension;i++)
{
if (CCTK_Equals(data->coords[i].name,coordname))
{
- coord = data->coords[i];
+ coord = &data->coords[i];
+ break;
}
}
+ if (coord == NULL)
+ {
+ CCTK_VWarn(2, __LINE__, __FILE__, "Cactus",
+ "CCTK_CoordRange: Coordinate name '%s' not registered",
+ coordname);
+ retval = -4;
+ }
}
- for (curr=coord.list;curr;curr=coord.list->next)
+ if (coord)
{
+ for (curr=coord->list;curr;curr=curr->next)
+ {
#ifdef DEBUG_COORD
- printf("curr = %x\n",curr);
- printf("lower = %f\n",curr->lower);
- printf("upper = %f\n",curr->upper);
- printf("next = %x\n",coord.list->next);
+ printf("curr = %p\n",curr);
+ printf("lower = %f\n",curr->lower);
+ printf("upper = %f\n",curr->upper);
+ printf("next = %p\n",curr->next);
#endif
-
- if (curr->GH == GH)
- {
- *lower = curr->lower;
- *upper = curr->upper;
+
+ if (curr->GH == GH)
+ {
+ *lower = curr->lower;
+ *upper = curr->upper;
#ifdef DEBUG_COORD
- printf("Returning range (%f,%f) (from %x)\n",
- *lower,*upper,curr);
+ printf("Returning range (%f,%f) (from %p)\n", *lower,*upper,curr);
#endif
+ }
}
}
}
else
{
- CCTK_VWarn(2,__LINE__,__FILE__,"Cactus",
- "CCTK_CoordRange: Coordinate system %s not registered",
+ CCTK_VWarn(2, __LINE__, __FILE__, "Cactus",
+ "CCTK_CoordRange: Coordinate system '%s' not registered",
systemname);
- retval = -2;
+ retval = -5;
}
}
else
{
- CCTK_Warn(2,__LINE__,__FILE__,"Cactus",
+ CCTK_Warn(2, __LINE__, __FILE__, "Cactus",
"CCTK_CoordRange: No coordinate systems registered");
- retval = -1;
+ retval = -6;
}
+
return retval;
}