diff options
author | tradke <tradke@7842ec3a-9562-4be5-9c5b-06ba18f2b668> | 2000-11-29 01:17:14 +0000 |
---|---|---|
committer | tradke <tradke@7842ec3a-9562-4be5-9c5b-06ba18f2b668> | 2000-11-29 01:17:14 +0000 |
commit | 5f9e18c0eeb6a40a8d066b78d40ad10bd87e27b9 (patch) | |
tree | ee503b106123c5060b3b6a16a5b24d0b1e786ebf | |
parent | 27d64bac96cfd0b3896763d2abad84dd08a93381 (diff) |
Use the flesh routine CCTK_TraverseString() for parsing the output variable
list. This saves a lot of redundant code in ParseGeometry.c. The rest went
into ParseVars.c.
Also re-enabled parsing of hyperslab parameters. Now you can give eg.
IOStreamedHDF5::out_vars = "wavetoy::phi[{hyperslab dimensionality}
{(direction vector for hdim0)
(direction vector for hdim1) etc.}
{origin vector}
{lengths into each hdim}
{downsampling into each hdim}]"
Hyperslab default parameters are not yet used because I don't know how
to specify defaults for the directions.
git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGHIO/IOHDF5Util/trunk@15 7842ec3a-9562-4be5-9c5b-06ba18f2b668
-rw-r--r-- | src/ParseGeometry.c | 347 | ||||
-rw-r--r-- | src/ParseVars.c | 450 | ||||
-rw-r--r-- | src/make.code.defn | 2 |
3 files changed, 325 insertions, 474 deletions
diff --git a/src/ParseGeometry.c b/src/ParseGeometry.c deleted file mode 100644 index 166e09a..0000000 --- a/src/ParseGeometry.c +++ /dev/null @@ -1,347 +0,0 @@ - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include "cctk.h" -#include "cctk_Arguments.h" -#include "cctk_Parameters.h" -#include "cctk_GNU.h" -#include "util_String.h" - -#include "ioHDF5UtilGH.h" - -/* Do not apply the USE marcro, parser will get confused - by curly braces in quoted strings */ - -/* CCTK_NO_AUTOUSE_MACRO */ - -/*$#define HEAVYDEBUG$*/ - - -int GeometryParserH5stream(const char *before, char **outname, ioHDF5Geo_t *geo) -{ - DECLARE_CCTK_PARAMETERS - - regmatch_t pmatch[3],gmatch[6]; - int matched, ierr=0,retval=0, verb=0, deb=0; - - const char *argument; - char *varname=NULL, *geo_s=NULL; - const char *token=NULL; - char *dim_s=NULL, *ori_s=NULL, *dir_s=NULL; - char *len_s=NULL, *down_s=NULL; - - int dim = 0, idim, iidim; - int index; - - char info[8000]; - - /* Debugging switches */ -#if 0 - if (CCTK_Equals(h5verbose,"debug")) { - deb =1; - verb =1; - } - if (CCTK_Equals(h5verbose,"yes")) - verb =1; -#endif - - sprintf(info,"\n\nHDF5stream GeometryParser \nargument: >%s<\n",before); - - if((matched = CCTK_RegexMatch(before, - "([A-Za-z][A-Za-z0-9_]*::[A-Za-z][A-Za-z0-9_]*)\\[?(.*)?\\]?", 3, pmatch)) != 0) { - if (matched<0) CCTK_WARN(1,"Error matching in GeometryParser"); -#ifdef HEAVYDEBUG - printf("matched %d rm_so/rm_eo: %d %d; %d %d\n", - matched, - (int)pmatch[1].rm_so,(int)pmatch[1].rm_eo, - (int)pmatch[2].rm_so,(int)pmatch[2].rm_eo); -#endif - - if(pmatch[1].rm_so != -1 && - (pmatch[1].rm_eo-pmatch[1].rm_so > 0)) - { - varname = (char*) malloc((int)(pmatch[1].rm_eo-pmatch[1].rm_so+1) - *sizeof(char)); - strncpy(varname,before+pmatch[1].rm_so, - (int)(pmatch[1].rm_eo-pmatch[1].rm_so)); - varname[(int)(pmatch[1].rm_eo-pmatch[1].rm_so)]='\0'; - - *outname = varname; - sprintf(info,"%sOUTNAME : >%s< \n",info,*outname); - - if ((index = CCTK_VarIndex(varname))>=0) { - geo->vdim = CCTK_GroupDimI(CCTK_GroupIndexFromVarI(index)); - } - else - { - sprintf(info,"%sOUTNAME : no appropriate gridfunction found:>%s< \n", - info,*outname); - geo->vdim = -1; - } - } - else - { - CCTK_WARN(1,"No variable name found in IOStreamedHDF5::out_vars"); - retval = -1; - return(retval); - } - - if(pmatch[2].rm_so != -1 && - (pmatch[2].rm_eo-pmatch[2].rm_so > 0)) - { - geo_s = (char*) malloc((int)(pmatch[2].rm_eo-pmatch[2].rm_so+1) - *sizeof(char)); - strncpy(geo_s,before+pmatch[2].rm_so, - (int)(pmatch[2].rm_eo-pmatch[2].rm_so)); - geo_s[(int)(pmatch[2].rm_eo-pmatch[2].rm_so)]='\0'; - sprintf(info,"%sGEOMETRY: >%s< \n",info,geo_s); - } else { - sprintf(info,"%sGEOMETRY: No geometry specified -> use default\n",info); - } - } - else { - retval=-1; - return(retval); - } - - /* Pattern match the hyperslab string geo_s*/ - if (geo_s) { - if((matched = CCTK_RegexMatch(geo_s, - "\\{(.*)\\},\\{(.*)\\},\\{(.*)\\},\\{(.*)\\},\\{(.*)\\}", - 6, gmatch)) != 0) - { - - /* SLAB DIMENSION */ - if(gmatch[1].rm_so != -1 && - (gmatch[1].rm_eo-gmatch[1].rm_so > 0)) - { - dim_s = (char*) malloc((int)(gmatch[1].rm_eo-gmatch[1].rm_so+1) - *sizeof(char)); - strncpy(dim_s,geo_s+gmatch[1].rm_so, - (int)(gmatch[1].rm_eo-gmatch[1].rm_so)); - dim_s[(int)(gmatch[1].rm_eo-gmatch[1].rm_so)]='\0'; - - if (deb) - sprintf(info,"%sDIMENSION: >%s< \n",info,dim_s); - - dim = atoi(dim_s); - geo->sdim = dim; - } - else { - if (deb) - sprintf(info,"%s","DIMENSION: No dimension\n"); - retval = -1; - } - free(dim_s); - - /* DIRECTION */ - ierr = -1; - if(gmatch[2].rm_so != -1 && - (gmatch[2].rm_eo-gmatch[2].rm_so > 0)) - { - dir_s = (char*) malloc((int)(gmatch[2].rm_eo-gmatch[2].rm_so+1) - *sizeof(char)); - strncpy(dir_s,geo_s+gmatch[2].rm_so, - (int)(gmatch[2].rm_eo-gmatch[2].rm_so)); - dir_s[(int)(gmatch[2].rm_eo-gmatch[2].rm_so)]='\0'; - - if (deb) - sprintf(info,"%sDIRECTION: >%s< \n",info,dir_s); - - idim = 0; - argument = dir_s; - while((token = Util_StrSep(&argument,","))) { - geo->direction[idim++]=atoi(token); - } - geo->direction[idim] = atoi(argument); - if (idim==dim-1) ierr = 0; - } - if (ierr<0) { - sprintf(info,"%sDIRECTION: dimension not consistent: >%s< (Use default)\n", - info,dir_s); - } - free(dir_s); - - /* ORIGIN */ - ierr = -1; - if(gmatch[3].rm_so != -1 && - (gmatch[3].rm_eo-gmatch[3].rm_so > 0)) - { - ori_s = (char*) malloc((int)(gmatch[3].rm_eo-gmatch[3].rm_so+1) - *sizeof(char)); - strncpy(ori_s,geo_s+gmatch[3].rm_so, - (int)(gmatch[3].rm_eo-gmatch[3].rm_so)); - ori_s[(int)(gmatch[3].rm_eo-gmatch[3].rm_so)]='\0'; - - if (deb) - sprintf(info,"%sDIRECTION: >%s< \n",info,ori_s); - - idim=0; - argument = ori_s; - while((token = Util_StrSep(&argument,","))) { - geo->origin[idim++]=atoi(token); - } - geo->origin[idim] = atoi(argument); - if (idim==(geo->vdim-1)) ierr = 0; - else if (idim==0) { - for (iidim=1;iidim<geo->vdim;iidim++) - geo->origin[iidim] = geo->origin[0]; - ierr = 0; - } - } - if (ierr<0) { - sprintf(info,"%sORIGIN: dimension not consistent: >%s< \n", - info,ori_s); - ierr = -1; - } - free(ori_s); - - /* LENGTH */ - ierr = -1; - if(gmatch[4].rm_so != -1 && - (gmatch[4].rm_eo-gmatch[4].rm_so > 0)) - { - len_s = (char*) malloc((int)(gmatch[4].rm_eo-gmatch[4].rm_so+1) - *sizeof(char)); - strncpy(len_s,geo_s+gmatch[4].rm_so, - (int)(gmatch[4].rm_eo-gmatch[4].rm_so)); - len_s[(int)(gmatch[4].rm_eo-gmatch[4].rm_so)]='\0'; - - if (deb) - sprintf(info,"%sLENGTH: >%s< \n",info,len_s); - - idim = 0; - argument = len_s; - while((token = Util_StrSep(&argument,","))) { - geo->length[idim++]=atoi(token); - } - geo->length[idim] = atoi(argument); - if (idim==dim-1) ierr = 0; - else if (idim==0) { - for (iidim=1;iidim<dim;iidim++) - geo->length[iidim] = geo->length[0]; - ierr = 0; - } - } - if (ierr<0) { - sprintf(info,"%sLENGTH: dimension not consistent: >%s< (Use Default)\n", - info,len_s); - } - free(len_s); - - - /* DOWNSAMPLING */ - ierr = -1; - if(gmatch[5].rm_so != -1 && - (gmatch[5].rm_eo-gmatch[5].rm_so > 0)) { - - down_s = (char*) malloc((int)(gmatch[5].rm_eo-gmatch[5].rm_so+1) - *sizeof(char)); - strncpy(down_s,geo_s+gmatch[5].rm_so, - (int)(gmatch[5].rm_eo-gmatch[5].rm_so)); - down_s[(int)(gmatch[5].rm_eo-gmatch[5].rm_so)]='\0'; - - if (deb) - sprintf(info,"%sDOWNSAMPLING: >%s< \n",info,down_s); - - - idim=0; - argument = down_s; - while((token = Util_StrSep(&argument,","))) { - geo->downsample[idim++]=atoi(token); - } - geo->downsample[idim] = atoi(argument); - if (idim==dim-1) ierr =0; - else if (idim==0) { - for (iidim=1;iidim<dim;iidim++) - geo->downsample[iidim] = geo->downsample[0]; - ierr = 0; - } - } - if (ierr<0) { - sprintf(info,"%sDOWNSAMPLING: dimension not consistent: >%s< \n", - info,down_s); - ierr =-1; - } - free(down_s); - } - if (geo_s) free(geo_s); - } - - if (verb) { - sprintf(info, "%sGeometry Data: \n",info); - sprintf(info, "%s Argument/Slab dimension: %d / %d \n", - info,geo->vdim,geo->sdim); - sprintf(info, "%s Origin: ",info); - for (idim=0;idim<geo->vdim;idim++) - sprintf(info,"%s %d ",info,geo->origin[idim]); - sprintf(info,"%s\n Downs : ",info); - for (idim=0;idim<geo->sdim;idim++) - sprintf(info,"%s %d ",info,geo->downsample[idim]); - sprintf(info,"%s\n Length: ",info); - for (idim=0;idim<geo->sdim;idim++) - sprintf(info,"%s %d ",info,geo->length[idim]); - sprintf(info,"%s\n Dirs : ",info); - for (idim=0;idim<geo->sdim;idim++) - sprintf(info,"%s %d ",info,geo->direction[idim]); - sprintf(info,"%s\n\n",info); - - printf("%s",info); - } - - USE_CCTK_PARAMETERS - - return(retval); -} - -void IOHDF5Util_DefaultGeo (ioHDF5Geo_t *geo) -{ - DECLARE_CCTK_PARAMETERS - int idim; - const char *argument, *token; - - - for (idim=0;idim<IOHDF5_MAXDIM;idim++) - { - geo->direction[idim] = idim; - geo->origin[idim] = 0; - geo->length[idim] =-1; - geo->downsample[idim] = 1; - } - geo->vdim = -1; - geo->sdim = slabdim; - - /* Origin */ - idim=0; - argument = origin; - while((token = Util_StrSep(&argument,","))) { - geo->origin[idim++]=atoi(token); - } - geo->downsample[idim] = atoi(argument); - - /* Direction */ - idim=0; - argument = direction; - while((token = Util_StrSep(&argument,","))) { - geo->direction[idim++]=atoi(token); - } - geo->downsample[idim] = atoi(argument); - - /* Downsample */ - idim=0; - argument = downsampling; - while((token = Util_StrSep(&argument,","))) { - geo->downsample[idim++]=atoi(token); - } - geo->downsample[idim] = atoi(argument); - - /* Length */ - idim=0; - argument = length; - while((token = Util_StrSep(&argument,","))) { - geo->length[idim++]=atoi(token); - } - geo->length[idim] = atoi(argument); -} diff --git a/src/ParseVars.c b/src/ParseVars.c index d3ca305..67ac1df 100644 --- a/src/ParseVars.c +++ b/src/ParseVars.c @@ -9,8 +9,6 @@ @endhistory @@*/ -/*#define DEBUG_IO*/ - #include <stdlib.h> #include <string.h> #include <stdio.h> @@ -18,13 +16,30 @@ #include "cctk.h" #include "util_String.h" #include "cctk_Parameters.h" - +#include "cctk_GNU.h" #include "ioHDF5UtilGH.h" -static char *rcsid = "$Header$"; +/* the rcs ID and its dummy function to use it */ +static char *rcsid = "$Id$"; CCTK_FILEVERSION(BetaThorns_IOStreamedHDF5_ParseVars_c) + +/* prototypes of routines defined in this source file */ +void IOHDF5Util_ParseVarsForOutput (const char *output_varstring, + ioHDF5Geo_t *output_request_list[]); +static void IOHDF5Util_ParseOutputRequest (int vindex, + const char *optstring, + void *arg); +static ioHDF5Geo_t *IOHDF5Util_DefaultIORequest (int vindex); + +/* prototypes of external routines for which no header files exist */ +int CCTK_RegexMatch (const char *string, + const char *pattern, + const int nmatch, + regmatch_t *pmatch); + + /* =============================================================== utility routines used by other IO thorns ===============================================================*/ @@ -54,159 +69,342 @@ CCTK_FILEVERSION(BetaThorns_IOStreamedHDF5_ParseVars_c) @endvar @@*/ -int IOHDF5Util_ParseVarsForOutput (const char *var_list, - char do_output[], - ioHDF5Geo_t geo_output[]) +void IOHDF5Util_ParseVarsForOutput (const char *output_varstring, + ioHDF5Geo_t *output_request_list[]) { - char *outname=NULL; - char *before=NULL; - char *after=NULL; - char *splitstring; - int first,groupnum,i,last,index,varnum; - ioHDF5Geo_t geo_tmp; - int ierr=0; -int GeometryParserH5stream(const char *before, char **outname, ioHDF5Geo_t *geo); - - - /* First initialise every variable to no output */ - for (i=0; i<CCTK_NumVars(); i++) + int i; + + + /* free current list of output requests */ + for (i = CCTK_NumVars () - 1; i >= 0; i--) { - do_output[i] = 0; + if (output_request_list[i]) + { + free (output_request_list[i]->origin); + free (output_request_list[i]); + output_request_list[i] = NULL; + } } - /* Initialize geometry structure with default */ + /* generate new list of output requests */ + CCTK_TraverseString (output_varstring, IOHDF5Util_ParseOutputRequest, + output_request_list, CCTK_GROUP_OR_VAR); +} + - IOHDF5Util_DefaultGeo (&geo_tmp); +static void IOHDF5Util_ParseOutputRequest (int vindex, + const char *optstring, + void *arg) +{ + DECLARE_CCTK_PARAMETERS + regmatch_t gmatch[6], *dmatch; + int matched; + char *token, *separator; + char *substring, *parsestring, *regexstring; + int i, j; + int bytes; + ioHDF5Geo_t **output_requests, *new_request; - splitstring = (char *) var_list; - /* split string at blanks */ - while(Util_SplitString(&before,&after,splitstring," ")==0) { + output_requests = (ioHDF5Geo_t **) arg; -#ifdef DEBUG_IO - printf(" String is -%s-\n",splitstring); - printf(" Split is -%s- and -%s-\n",before,after); -#endif + /* allocate a new IO request structure and initialize it with defaults */ + new_request = IOHDF5Util_DefaultIORequest (vindex); + + if (! optstring) + { + output_requests[vindex] = new_request; + return; + } + + /* parse the hyperslab information */ + matched = CCTK_RegexMatch (optstring, + "\\[" + "\\{([0-9]+)\\}" /* dimension */ + "\\{([0-9,()]+)\\}" /* direction */ + "\\{([0-9,]+)\\}" /* origin */ + "\\{([-0-9,]+)\\}" /* length */ + "\\{([0-9,]+)\\}" /* downsample */ + "\\]", + 6, gmatch); + if (matched <= 0) + { + CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING, + "Couldn't parse hyperslab parameter '%s'", optstring); + free (new_request); + return; + } + + /* 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 (CCTK_Equals(before," ")) continue; + /* DIRECTION */ + i = 0; + bytes = (int) (gmatch[2].rm_eo - gmatch[2].rm_so); + if (gmatch[2].rm_so != -1 && bytes > 0) + { + substring = strdup (optstring + gmatch[2].rm_so); + substring[bytes] = 0; - if (strlen(before) > 0) + dmatch = (regmatch_t *) malloc ((new_request->sdim + 1) * + sizeof (regmatch_t)); + regexstring = (char *) malloc (new_request->sdim * sizeof ("\\(([0-9,]+)\\)")); + regexstring[0] = 0; + for (i = 0; i < new_request->sdim; i++) { - /* Extract geometry information */ - ierr=GeometryParserH5stream(before, &outname, &geo_tmp); - if ((ierr<0)||(outname==NULL)) { - CCTK_WARN(1,"GeometryParserH5stream failed."); - return(-1); - } + strcat (regexstring, "\\(([0-9,]+)\\)"); + } + matched = CCTK_RegexMatch (substring, regexstring, new_request->sdim + 1, + dmatch); + free (regexstring); + if (matched != new_request->sdim) + { + CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING, + "Couldn't parse direction vectors in hyperslab " + "parameter '%s'.", optstring); + free (dmatch); + free (new_request); + return; + } - /* Look for any special tokens */ - if (CCTK_Equals(outname,"all")) - { - int ilab; - for (ilab=0;ilab<CCTK_NumVars();ilab++) { - geo_output[ilab]= geo_tmp; - do_output[ilab] = 1; - } - } - else + for (j = 0; j < new_request->sdim; j++) + { + i = 0; + bytes = (int) (dmatch[j + 1].rm_eo - dmatch[j + 1].rm_so); + if (dmatch[j + 1].rm_so != -1 && bytes > 0) { - /* See if this name is implementation::variable */ - varnum = CCTK_VarIndex(outname); - if ( varnum < 0 ) + parsestring = strdup (substring + dmatch[j + 1].rm_so); + parsestring[bytes] = 0; + + token = parsestring; + while ((separator = strchr (token, ',')) != NULL) { - /* See if this name is implementation::group */ - groupnum = CCTK_GroupIndex(outname); - if (groupnum < 0) + *separator = 0; + new_request->direction[j * new_request->vdim + i] = atoi (token); + if (++i >= new_request->vdim) { - char *msg; - msg = (char *)malloc((100+strlen(outname))*sizeof(char)); - sprintf(msg,"Ignoring <%s> in IO string (invalid token)",outname); - CCTK_WARN(2,msg); - free(msg); - } - else - { - /* We have a group so now need all the variables in the group */ - first = CCTK_FirstVarIndexI(groupnum); - last = first+CCTK_NumVarsInGroupI(groupnum)-1; - for (index=first;index<=last;index++) { - geo_output[index]=geo_tmp; - do_output[index] =1; - } + break; } - } - else - { - geo_output[varnum]= geo_tmp; - do_output[varnum] = 1; + token = separator + 1; } + new_request->direction[j * new_request->vdim + i++] = atoi (token); + free (parsestring); + } + free (substring); + 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; } } - if(before) + } + 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; + + token = substring; + while ((separator = strchr (token, ',')) != NULL) { - free(before); - before = NULL; + *separator = 0; + new_request->origin[i] = atoi (token); + if (++i >= new_request->vdim) + { + break; + } + token = separator + 1; } - if(outname) + 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; + } + + /* 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; + + token = substring; + while ((separator = strchr (token, ',')) != NULL) { - free(outname); - outname = NULL; + *separator = 0; + new_request->length[i] = atoi (token); + if (++i >= new_request->sdim) + { + break; + } + token = separator + 1; } - if(splitstring != var_list) + 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; + } + + /* 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; + + token = substring; + while ((separator = strchr (token, ',')) != NULL) { - free(splitstring); + *separator = 0; + new_request->downsample[i] = atoi (token); + if (++i >= new_request->sdim) + { + break; + } + token = separator + 1; } - - splitstring = after; + 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; + } + + /* assign the output request */ + output_requests[vindex] = new_request; + +#ifdef IOHDF5UTIL_DEBUG + printf("Geometry Data: \n"); + printf(" Argument/Slab dimension: %d / %d \n", new_request->vdim,new_request->sdim); + printf(" Origin: "); + for (i=0;i<new_request->vdim;i++) + printf("%s %d ", new_request->origin[i]); + printf("\n Downs : "); + for (i=0;i<new_request->sdim;i++) + printf(" %d ", new_request->downsample[i]); + printf("\n Length: "); + for (i=0;i<new_request->sdim;i++) + printf(" %d ", new_request->length[i]); + printf("\n Dirs : "); + for (i=0;i<new_request->sdim;i++) + printf(" %d ", new_request->direction[i]); + printf("\n\n"); +#endif + + USE_CCTK_PARAMETERS +} + + +static ioHDF5Geo_t *IOHDF5Util_DefaultIORequest (int vindex) +{ + DECLARE_CCTK_PARAMETERS + int i; + ioHDF5Geo_t *request; + const char *argument, *token; + + + /* allocate a new IO request structure */ + request = (ioHDF5Geo_t *) malloc (sizeof (ioHDF5Geo_t)); + + /* get the variable's dimension + set it also to be the default hyperslab dimension */ + request->vdim = request->sdim = CCTK_GroupDimFromVarI (vindex); + + request->origin = (int *) calloc (4 + request->sdim, + request->vdim * sizeof (int)); + request->length = request->origin + 1 * request->vdim; + request->downsample = request->origin + 2 * request->vdim; + request->actlen = request->origin + 3 * request->vdim; + request->direction = request->origin + 4 * request->vdim; + + for (i = 0; i < request->vdim; i++) + { + request->length[i] = -1; + request->downsample[i] = 1; + request->direction[i * request->vdim + i] = 1; } - if (strlen(splitstring)>0) { +#if 0 + FIXME: parse default hyperslab parameters + /* Origin */ + i=0; + argument = origin; + while((token = Util_StrSep(&argument,","))) { + request->origin[i++]=atoi(token); + } + request->downsample[i] = atoi(argument); - /* Extract geometry information */ - ierr=GeometryParserH5stream(splitstring, &outname, &geo_tmp); - if (ierr<0) printf("GeometryParser failed: >%s<\n",before); + /* Direction */ + i=0; + argument = direction; + while((token = Util_StrSep(&argument,","))) { + request->direction[i++]=atoi(token); + } + request->downsample[i] = atoi(argument); - /* Special cases */ - if (CCTK_Equals(outname,"all")) { - int ilab; - for (ilab=0;ilab<CCTK_NumVars();ilab++) { - geo_output[ilab]=geo_tmp; - do_output [ilab]=1; - } - } else { - - varnum = CCTK_VarIndex(outname); - if (varnum < 0) { - groupnum = CCTK_GroupIndex(outname); - if (groupnum < 0) { - char *msg; - msg = (char *)malloc((100+strlen(outname))*sizeof(char)); - sprintf(msg,"Ignoring %s in IO string (invalid token)",outname); - CCTK_WARN(2,msg); - free(msg); - } else { - /* We have a group so now need all the variables in the group */ - first = CCTK_FirstVarIndexI(groupnum); - last = first+CCTK_NumVarsInGroupI(groupnum)-1; - for (index=first;index<=last;index++) { - geo_output[index]=geo_tmp; - do_output[index] =1; - } - } - } - else { - geo_output[varnum]=geo_tmp; - do_output[varnum] =1; - } - } + /* Downsample */ + i=0; + argument = downsampling; + while((token = Util_StrSep(&argument,","))) { + request->downsample[i++]=atoi(token); } + request->downsample[i] = atoi(argument); - if (before) free(before); - if (after) free(after); - if(splitstring != var_list) - { - free(splitstring); + /* Length */ + i=0; + argument = length; + while((token = Util_StrSep(&argument,","))) { + request->length[i++]=atoi(token); } - return(0); + request->length[i] = atoi(argument); +#endif + + return (request); } diff --git a/src/make.code.defn b/src/make.code.defn index a3caec7..4f85730 100644 --- a/src/make.code.defn +++ b/src/make.code.defn @@ -2,4 +2,4 @@ # $Header$ # Source files in this directory -SRCS = Startup.c DumpUtils.c DumpVar.c RecoverVar.c ParseVars.c ParseGeometry.c +SRCS = Startup.c DumpUtils.c DumpVar.c RecoverVar.c ParseVars.c |