aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortradke <tradke@7842ec3a-9562-4be5-9c5b-06ba18f2b668>2002-01-09 17:47:09 +0000
committertradke <tradke@7842ec3a-9562-4be5-9c5b-06ba18f2b668>2002-01-09 17:47:09 +0000
commit3be3dc1e992d6b7d6daa62791a1f3311df6b2a3c (patch)
tree0e744aa311e5ee7b1aa6dadd97a9e2a5a406b569
parent0e4fea9852942c1c5ffec40f96a1bac571607921 (diff)
Fixed parsing of hyperslab parameters for individual variables.
git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGHIO/IOHDF5Util/trunk@46 7842ec3a-9562-4be5-9c5b-06ba18f2b668
-rw-r--r--src/ParseVars.c97
1 files changed, 43 insertions, 54 deletions
diff --git a/src/ParseVars.c b/src/ParseVars.c
index e4db7ff..1d46f5b 100644
--- a/src/ParseVars.c
+++ b/src/ParseVars.c
@@ -118,13 +118,11 @@ static void IOHDF5Util_ParseOutputRequest (int vindex,
/* parse the hyperslab information */
matched = CCTK_RegexMatch (optstring,
- "\\["
- "\\{([0-9]+)\\}" /* dimension */
- "\\{([0-9,()]+)\\}" /* direction */
- "\\{([0-9,]+)\\}" /* origin */
- "\\{([-0-9,]+)\\}" /* length */
- "\\{([0-9,]+)\\}" /* downsample */
- "\\]",
+ "\\{([0-9]*)\\}" /* dimension */
+ "\\{([0-9,()]+)*\\}" /* direction */
+ "\\{([0-9,]+)*\\}" /* origin */
+ "\\{([-0-9,]+)*\\}" /* length */
+ "\\{([0-9,]+)*\\}", /* downsample */
6, gmatch);
if (matched <= 0)
{
@@ -135,23 +133,21 @@ static void IOHDF5Util_ParseOutputRequest (int vindex,
}
/* SLAB DIMENSION */
- new_request->sdim = 0;
bytes = (int) (gmatch[1].rm_eo - gmatch[1].rm_so);
if (gmatch[1].rm_so != -1 && bytes > 0)
{
new_request->sdim = atoi (optstring + gmatch[1].rm_so);
- }
- if (new_request->sdim <= 0 || new_request->sdim > new_request->vdim)
- {
- CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING,
- "Invalid or no dimension given in hyperslab parameter '%s'",
- optstring);
- free (new_request);
- return;
+ if (new_request->sdim <= 0 || new_request->sdim > new_request->vdim)
+ {
+ CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "Invalid dimension given %d in hyperslab parameter '%s'",
+ new_request->sdim, optstring);
+ free (new_request);
+ return;
+ }
}
/* DIRECTION */
- i = 0;
bytes = (int) (gmatch[2].rm_eo - gmatch[2].rm_so);
if (gmatch[2].rm_so != -1 && bytes > 0)
{
@@ -213,23 +209,15 @@ static void IOHDF5Util_ParseOutputRequest (int vindex,
}
}
}
- if (i < new_request->vdim)
- {
- CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING,
- "Direction vectors are incomplete or missing in hyperslab "
- "parameter '%s'.", optstring);
- free (new_request);
- return;
- }
/* ORIGIN */
- i = 0;
bytes = (int) (gmatch[3].rm_eo - gmatch[3].rm_so);
if (gmatch[3].rm_so != -1 && bytes > 0)
{
substring = strdup (optstring + gmatch[3].rm_so);
substring[bytes] = 0;
+ i = 0;
token = substring;
while ((separator = strchr (token, ',')) != NULL)
{
@@ -243,24 +231,25 @@ static void IOHDF5Util_ParseOutputRequest (int vindex,
}
new_request->origin[i++] = atoi (token);
free (substring);
- }
- if (i < new_request->vdim)
- {
- CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING,
- "Origin vector is incomplete or missing in hyperslab "
- "parameter '%s'.", optstring);
- free (new_request);
- return;
+
+ if (i < new_request->vdim)
+ {
+ CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "Origin vector is incomplete or missing in hyperslab "
+ "parameter '%s'.", optstring);
+ free (new_request);
+ return;
+ }
}
/* LENGTH */
- i = 0;
bytes = (int) (gmatch[4].rm_eo - gmatch[4].rm_so);
if(gmatch[4].rm_so != -1 && bytes > 0)
{
substring = strdup (optstring + gmatch[4].rm_so);
substring[bytes] = 0;
+ i = 0;
token = substring;
while ((separator = strchr (token, ',')) != NULL)
{
@@ -274,24 +263,25 @@ static void IOHDF5Util_ParseOutputRequest (int vindex,
}
new_request->length[i++] = atoi (token);
free (substring);
- }
- if (i < new_request->sdim)
- {
- CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING,
- "Length vector is incomplete or missing in hyperslab "
- "parameter '%s'.", optstring);
- free (new_request);
- return;
+
+ if (i < new_request->sdim)
+ {
+ CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "Length vector is incomplete or missing in hyperslab "
+ "parameter '%s'.", optstring);
+ free (new_request);
+ return;
+ }
}
/* DOWNSAMPLING */
- i = 0;
bytes = (int) (gmatch[5].rm_eo - gmatch[5].rm_so);
if(gmatch[5].rm_so != -1 && bytes > 0)
{
substring = strdup (optstring + gmatch[5].rm_so);
substring[bytes] = 0;
+ i = 0;
token = substring;
while ((separator = strchr (token, ',')) != NULL)
{
@@ -305,14 +295,15 @@ static void IOHDF5Util_ParseOutputRequest (int vindex,
}
new_request->downsample[i++] = atoi (token);
free (substring);
- }
- if (i < new_request->sdim)
- {
- CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING,
- "Downsampling vector is incomplete or missing in hyperslab "
- "parameter '%s'.", optstring);
- free (new_request);
- return;
+
+ if (i < new_request->sdim)
+ {
+ CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "Downsampling vector is incomplete or missing in hyperslab "
+ "parameter '%s'.", optstring);
+ free (new_request);
+ return;
+ }
}
/* assign the output request */
@@ -336,8 +327,6 @@ static void IOHDF5Util_ParseOutputRequest (int vindex,
printf(" %d ", new_request->direction[i]);
printf("\n\n");
#endif
-
- USE_CCTK_PARAMETERS
}