diff options
Diffstat (limited to 'src/IsoSurfacerInit.c')
-rw-r--r-- | src/IsoSurfacerInit.c | 57 |
1 files changed, 53 insertions, 4 deletions
diff --git a/src/IsoSurfacerInit.c b/src/IsoSurfacerInit.c index c74698f..bac32cc 100644 --- a/src/IsoSurfacerInit.c +++ b/src/IsoSurfacerInit.c @@ -11,7 +11,7 @@ #include <cctk.h> #include <cctk_Parameters.h> - +#include "CactusPUGH/PUGH/src/include/pugh.h" #include "IsoSurfacerInit.h" /***************************************************************/ @@ -44,8 +44,12 @@ int IsoSurfacer_InitGH (cGH *GH){ */ int n,i; isosurfacerGH *myGH; + int Iso_SetupServer(cGH *GH, isosurfacerGH *myGH, + int dataport, int clientport, int queue_size, int hunt); + + myGH = (isosurfacerGH *) GH->extensions [CCTK_GHExtensionHandle ("IsoSurfacer")]; - + printf("IsoInit\n"); /* initialize values */ myGH->funcName=0; @@ -75,6 +79,10 @@ int IsoSurfacer_InitGH (cGH *GH){ if(strstr(output_format,"HDF5")) myGH->formats|=ISOHDF5; if(strstr(output_format,"VRML")) myGH->formats|=VRML; + /* OK, now we test to see if the 'isosurfacer' string + overrides everything set up by the new params */ + IsoSurfacer_ParseIsoString(isosurfacer,GH,myGH); + if(myGH->funcName==0 || myGH->formats==0) myGH->RunIsoSurfacer = 0; else @@ -87,6 +95,7 @@ int IsoSurfacer_InitGH (cGH *GH){ CCTK_WARN (1, "Problem creating IsoSurfacer output directory"); free (cmd); } + Iso_SetupServer(GH,myGH,dataport,controlport, 5, 1); /* needs to move into InitGH */ /* otherwise, the outdir need not be created if it is '.' */ return 1; } @@ -106,7 +115,47 @@ int IsoSurfacer_rfrTraverseGH (cGH *GH, int rfrpoint) { return 0; } +/* Parse string from original isosurfacer. + Typical string is + "{(wavetoy::phi) (0.35) (SOCK) (1,1,1,1)}" + + Since we are limiting ourselves to single-iso-functionality + right now, we only peel off the first reference to an isosurface + at this point. We can ignore the other params since they are + redundant (already functionally covered by IOBase params) +*/ +int IsoSurfacer_ParseIsoString(char *isostring,cGH *GH,isosurfacerGH *myGH){ + char *s,*snext,*si; + int len; + if(!isostring) return 0; + if((len=strlen(isostring))<4) return 0; /* nothing to write home about here... */ + s = (char *)malloc(len+1); + strcpy(s,isostring); /* we are going to do some destructive parsing here */ + isostring = s; /* remember this string for when we free it */ - - + /* Now we parse */ + snext=strchr(s,'('); /* move to first '(' */ + s=snext+1; + snext=strchr(s,')'); /* find next ',' or ')' which would terminate the list */ + si=strchr(s,','); + if(si) *si='\0'; + else if(snext) *snext='\0'; + else {free(isostring); return 0; } /* parse failure */ + myGH->funcName=(char*)malloc(strlen(s)+1); + strcpy(myGH->funcName,s); /* got the varname for the output var */ + /* OK, now we go find the isoval */ + s = strchr(snext+1,'('); + if(s) s++; else return 1; + snext=strchr(s,')'); /* find next ',' or ')' which would terminate the list */ + si=strchr(s,','); + if(si) *si='\0'; + else if(snext) *snext='\0'; + else return 1; /* parse failure, but we at least have the right varname.*/ + myGH->isovalue = atof(s); + /* we are all done now. The rest is ignored because it contains + redundant or obsolete information which doesnt really fit into + the new parser model */ + free(isostring); /* free our temporary storage */ + return 1; /* parse was successful */ +} |