diff options
author | tradke <tradke@0888f3d4-9f52-45d2-93bc-d00801ff5e46> | 2000-08-02 17:27:11 +0000 |
---|---|---|
committer | tradke <tradke@0888f3d4-9f52-45d2-93bc-d00801ff5e46> | 2000-08-02 17:27:11 +0000 |
commit | 8cac1b4a2b14ce2d19f4e6146c05abfabecdd111 (patch) | |
tree | bffc5629941ffea218659bb98f983e843e71a613 | |
parent | 0062c24cb004a59d96e75b4f516b7a83b5e7145d (diff) |
Fixed parsing variables.
git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGHIO/IOStreamedHDF5/trunk@18 0888f3d4-9f52-45d2-93bc-d00801ff5e46
-rw-r--r-- | src/ParseGeometry.c | 240 | ||||
-rw-r--r-- | src/ParseVars.c | 44 |
2 files changed, 142 insertions, 142 deletions
diff --git a/src/ParseGeometry.c b/src/ParseGeometry.c index b8fdd3e..64f84d9 100644 --- a/src/ParseGeometry.c +++ b/src/ParseGeometry.c @@ -48,59 +48,59 @@ int GeometryParser(const char *before, char **outname, StreamGeo_t *geo) sprintf(info,"\n\nGeometryParser \nargument: >%s<\n",before); if((matched = CCTK_RegexMatch(before, - "\\=(.*)\\=\\[?(.*)?\\]?", 3, pmatch)) != 0) { + "\\=(.*)\\=\\[?(.*)?\\]?", 3, pmatch)) != 0) { /* Regex broken on origin: \\w not matched */ -/* "(\\w*::\\w*)\\[?(.*)?\\]?", 3, pmatch)) != 0) {*/ +/* "(\\w*::\\w*)\\[?(.*)?\\]?", 3, pmatch)) != 0) {*/ #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); + 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)) + (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)); - geo->sdim = geo->vdim; - } - else - { - sprintf(info,"%sOUTNAME : no appropriate gridfunction found:>%s< \n", - info,*outname); - geo->vdim = -1; - geo->sdim = -1; - } + 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)); + geo->sdim = geo->vdim; + } + else + { + sprintf(info,"%sOUTNAME : no appropriate gridfunction found:>%s< \n", + info,*outname); + geo->vdim = -1; + geo->sdim = -1; + } } else { - CCTK_WARN(1,"No variable name found in StreamedHDF5::out_vars"); - retval = -1; + CCTK_WARN(1,"No variable name found in StreamedHDF5::out_vars"); + retval = -1; } 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 = (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); + sprintf(info,"%sGEOMETRY: No geometry specified -> use default\n",info); } } else { @@ -110,8 +110,8 @@ int GeometryParser(const char *before, char **outname, StreamGeo_t *geo) /* Pattern match the hyperslab string geo_s*/ if (geo_s) { if((matched = CCTK_RegexMatch(geo_s, - "\\{(.*)\\},\\{(.*)\\},\\{(.*)\\},\\{(.*)\\},\\{(.*)\\}", - 6, gmatch)) != 0) + "\\{(.*)\\},\\{(.*)\\},\\{(.*)\\},\\{(.*)\\},\\{(.*)\\}", + 6, gmatch)) != 0) { /* SLAB DIMENSION */ @@ -123,46 +123,46 @@ int GeometryParser(const char *before, char **outname, StreamGeo_t *geo) 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); + + if (deb) + sprintf(info,"%sDIMENSION: >%s< \n",info,dim_s); - dim = atoi(dim_s); - geo->sdim = dim; + dim = atoi(dim_s); + geo->sdim = dim; } else { - if (deb) - sprintf(info,"%s","DIMENSION: No dimension\n"); - retval = -1; + 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) + { + 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; - } + 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< \n", - info,dir_s); - retval = -1; + sprintf(info,"%sDIRECTION: dimension not consistent: >%s< \n", + info,dir_s); + retval = -1; } free(dir_s); @@ -177,26 +177,26 @@ int GeometryParser(const char *before, char **outname, StreamGeo_t *geo) (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 (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; + sprintf(info,"%sORIGIN: dimension not consistent: >%s< \n", + info,ori_s); + ierr = -1; } free(ori_s); @@ -211,26 +211,26 @@ int GeometryParser(const char *before, char **outname, StreamGeo_t *geo) (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 (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< \n", - info,len_s); - retval =-1; + sprintf(info,"%sLENGTH: dimension not consistent: >%s< \n", + info,len_s); + retval =-1; } free(len_s); @@ -246,27 +246,27 @@ int GeometryParser(const char *before, char **outname, StreamGeo_t *geo) (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->downs[idim++]=atoi(token); - } - geo->downs[idim] = atoi(argument); - if (idim==dim-1) ierr =0; - else if (idim==0) { - for (iidim=1;iidim<dim;iidim++) - geo->downs[iidim] = geo->downs[0]; - ierr = 0; - } + if (deb) + sprintf(info,"%sDOWNSAMPLING: >%s< \n",info,down_s); + + + idim=0; + argument = down_s; + while((token = Util_StrSep(&argument,","))) { + geo->downs[idim++]=atoi(token); + } + geo->downs[idim] = atoi(argument); + if (idim==dim-1) ierr =0; + else if (idim==0) { + for (iidim=1;iidim<dim;iidim++) + geo->downs[iidim] = geo->downs[0]; + ierr = 0; + } } if (ierr<0) { - sprintf(info,"%sDOWNSAMPLING: dimension not consistent: >%s< \n", - info,down_s); - ierr =-1; + sprintf(info,"%sDOWNSAMPLING: dimension not consistent: >%s< \n", + info,down_s); + ierr =-1; } free(down_s); } @@ -275,7 +275,7 @@ int GeometryParser(const char *before, char **outname, StreamGeo_t *geo) sprintf(info, "%sGeometry Data: \n",info); sprintf(info, "%s Argument/Slab dimension: %d / %d \n", - info,geo->vdim,geo->sdim); + 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]); diff --git a/src/ParseVars.c b/src/ParseVars.c index f441234..3e3837e 100644 --- a/src/ParseVars.c +++ b/src/ParseVars.c @@ -96,9 +96,9 @@ void ParseVarsForOutput (StreamedHDF5GH *h5GH, const char *var_list) { int ilab; for (ilab=0;ilab<CCTK_NumVars();ilab++) { - h5GH->geo_output[ilab]= geo_tmp; - h5GH->do_output[ilab] = 1; - } + h5GH->geo_output[ilab]= geo_tmp; + h5GH->do_output[ilab] = 1; + } } else { @@ -122,16 +122,16 @@ void ParseVarsForOutput (StreamedHDF5GH *h5GH, const char *var_list) first = CCTK_FirstVarIndexI(groupnum); last = first+CCTK_NumVarsInGroupI(groupnum)-1; for (index=first;index<=last;index++) { - h5GH->geo_output[index]=geo_tmp; - h5GH->do_output[index] =1; - } + h5GH->geo_output[index]=geo_tmp; + h5GH->do_output[index] =1; + } } } else - { - h5GH->geo_output[varnum]= geo_tmp; - h5GH->do_output[varnum] = 1; - } + { + h5GH->geo_output[varnum]= geo_tmp; + h5GH->do_output[varnum] = 1; + } } } if(before) @@ -160,21 +160,21 @@ void ParseVarsForOutput (StreamedHDF5GH *h5GH, const char *var_list) if (ierr<0) printf("GeometryParser failed: >%s<\n",before); /* Special cases */ - if (CCTK_Equals(splitstring,"all")) { + if (CCTK_Equals(outname,"all")) { int ilab; for (ilab=0;ilab<CCTK_NumVars();ilab++) { - h5GH->geo_output[ilab]=geo_tmp; - h5GH->do_output [ilab]=1; + h5GH->geo_output[ilab]=geo_tmp; + h5GH->do_output [ilab]=1; } } else { - varnum = CCTK_VarIndex(splitstring); + varnum = CCTK_VarIndex(outname); if (varnum < 0) { - groupnum = CCTK_GroupIndex(splitstring); + groupnum = CCTK_GroupIndex(outname); if (groupnum < 0) { char *msg; - msg = (char *)malloc((100+strlen(splitstring))*sizeof(char)); - sprintf(msg,"Ignoring %s in IO string (invalid token)",splitstring); + 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 { @@ -182,14 +182,14 @@ void ParseVarsForOutput (StreamedHDF5GH *h5GH, const char *var_list) first = CCTK_FirstVarIndexI(groupnum); last = first+CCTK_NumVarsInGroupI(groupnum)-1; for (index=first;index<=last;index++) { - h5GH->geo_output[index]=geo_tmp; - h5GH->do_output[index] =1; - } + h5GH->geo_output[index]=geo_tmp; + h5GH->do_output[index] =1; + } } } else { - h5GH->geo_output[varnum]=geo_tmp; - h5GH->do_output[varnum] =1; + h5GH->geo_output[varnum]=geo_tmp; + h5GH->do_output[varnum] =1; } } } |