diff options
author | jshalf <jshalf@bfcf8e34-485d-4d46-a995-1fd6fa6fb178> | 2000-10-30 03:29:03 +0000 |
---|---|---|
committer | jshalf <jshalf@bfcf8e34-485d-4d46-a995-1fd6fa6fb178> | 2000-10-30 03:29:03 +0000 |
commit | e6d057402882838b675d5b2afbe56ea02ffbba60 (patch) | |
tree | dc7f97c47ba8b6642c7e53b73338db362f96d96b | |
parent | 0df7382c160c68a507a22457d81f62bb66f3df5f (diff) |
Forgot to take PUGH into account for steering.
So now it properly propagates steering information to *ALL*
processes when running in MPI mode.
Also added parameters so that it is fully compatable in terms
of parameters with the old isosurfacer (still testing this though).
git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGHIO/IsoSurfacer/trunk@15 bfcf8e34-485d-4d46-a995-1fd6fa6fb178
-rw-r--r-- | param.ccl | 19 | ||||
-rw-r--r-- | src/IsoSurfacer.c | 51 | ||||
-rw-r--r-- | src/IsoSurfacerInit.c | 57 | ||||
-rw-r--r-- | src/IsoSurfacerInit.h | 1 | ||||
-rw-r--r-- | src/Sockets.c | 70 | ||||
-rw-r--r-- | src/Startup.c | 5 |
6 files changed, 142 insertions, 61 deletions
@@ -28,9 +28,19 @@ INT output_start "First iteration to start drawing isosurfaces. Default=1" STEER .* :: "Some positive integer" } 1 +INT dataport "dataport for socket connection (output port)" +{ + .* :: "Some positive integer" +} 7051 + +INT controlport "controlport for socket connection (input port)" +{ + .* :: "some positive integer" +} 7050 + STRING format_str "If the precision specified in the default format string is less than what you need, then insert your own format for floating point numbers here" { - .* :: A regex which matches everything + .* :: "A regex which matches everything" } "%3.3f" BOOLEAN allow_empty_sends "Allow the Isosurfacer to send zero-length vertex lists to the client application ? Ordinarily these zero-length sends are supressed." STEERABLE = ALWAYS @@ -39,9 +49,14 @@ BOOLEAN allow_empty_sends "Allow the Isosurfacer to send zero-length vertex list STRING outdir "Output directory for isosurface data files" { - .* :: A regex which matches everything + .* :: "A regex which matches everything" } "." +STRING isosurfacer " What to isosurface and how. Format:{(functionName) (isolevel1, isolevel2, ...) (format1, format2, ...) (itiso, resolution, firstIteration, uniqverts)} {} ...:: only for backward compability with old isosurfacer" +{ + .* :: "compatability with original isosurfacer" +} "" + ############################################################################# ### import IOUtil parameters diff --git a/src/IsoSurfacer.c b/src/IsoSurfacer.c index fc421b6..6c20659 100644 --- a/src/IsoSurfacer.c +++ b/src/IsoSurfacer.c @@ -58,8 +58,10 @@ static void WriteHDF5(cGH *GH, polypatch *totals, isosurfacerGH *myGH, /***************************************************************************/ static int IsoSurfacerHandleCommands(cGH *GH) { + IsoCommand *Iso_PollCommand(cGH *cctkGH,IsoCommand *cmd); IsoCommand command; isosurfacerGH *myGH = (isosurfacerGH *) GH->extensions [CCTK_GHExtensionHandle ("IsoSurfacer")]; + if(!myGH->RunIsoSurfacer) return 0; /* not running */ /* Grab all events that are waiting in queue */ /* @@ -108,21 +110,46 @@ static int IsoSurfacerHandleCommands(cGH *GH) /* Here it just needs to read from the control socket and then change the isosurface appropriately */ - IsoCommand *Iso_PollCommand(cGH *cctkGH,IsoCommand *cmd); +#ifdef CCTK_MPI + /* now we need to bcast this value to all procs */ + { + CCTK_REAL tmpval; + pGH *pughGH = PUGH_pGH (GH); + if(pughGH->myproc==0 && Iso_PollCommand(GH,&command)){ +#ifdef VERBOSE + printf("+++++++++Process Command [%s] [%s] [%s]\n", + command.cmd.object,command.cmd.target,command.cmd.value); +#endif + myGH->isovalue=atof(command.cmd.value); /* steer it. */ + } + tmpval=myGH->isovalue; + CACTUS_MPI_ERROR(MPI_Bcast(&tmpval,1, + PUGH_MPI_REAL,0, /* ugh. nor REAL8 */ + pughGH->PUGH_COMM_WORLD)); + myGH->isovalue=tmpval; /* copyback */ + } +#else if(Iso_PollCommand(GH,&command)){ #ifdef VERBOSE printf("+++++++++Process Command [%s] [%s] [%s]\n", command.cmd.object,command.cmd.target,command.cmd.value); #endif myGH->isovalue=atof(command.cmd.value); /* steer it. */ + /* If we have MPI, must propagate the steering info + to all processes */ } +#endif return 0; } static int doIso(int index, cGH *GH, isosurfacerGH *myGH) { - char *fullname = CCTK_FullName (index); + char *fullname; + + if(!myGH->RunIsoSurfacer) return 0; + + fullname = CCTK_FullName (index); /* printf("Check doIso: fullname[%s]:[%s]",fullname,myGH->funcName);*/ if(!strcmp(fullname,myGH->funcName)){ if(myGH->firstIteration<=GH->cctk_iteration && @@ -141,12 +168,16 @@ static void computeIso(int index, cGH *GH, isosurfacerGH *myGH) { DECLARE_CCTK_PARAMETERS /* is it really required to have this static here?? */ - char* fullname = CCTK_FullName (index); + char* fullname; int i,j; int nx,ny,nz; CCTK_REAL *xcoords,*ycoords,*zcoords,*data; int timelevel; timelevel = CCTK_NumTimeLevelsFromVarI (index); + + if(!myGH->RunIsoSurfacer) return; /* not running */ + + fullname = CCTK_FullName (index); if (timelevel > 0) timelevel--; data = (CCTK_REAL *) GH->data [index][timelevel]; @@ -233,6 +264,7 @@ static void computeIso(int index, cGH *GH, isosurfacerGH *myGH) int IsoSurfacer(cGH *GH){ int i,n; isosurfacerGH *myGH = (isosurfacerGH *) GH->extensions [CCTK_GHExtensionHandle ("IsoSurfacer")]; + if(!myGH->RunIsoSurfacer) return 0; /* not running */ IsoSurfacerHandleCommands(GH); /* do a check for new isosurfaces */ /* Perhaps do a bcast for "changed" flags. @@ -276,17 +308,7 @@ void CollectData(cGH *GH, polypatch *perprocessor, polypatch *totals) { static CCTK_INT4 *vpcount = NULL; pGH *pughGH; - pughGH = PUGH_pGH (GH); - -#if 0 - cdtimes.ncalls++; -#ifndef _WIN32 - cdtimes.realtime_begin = times(&cdtimes.tms_begin); -#endif - -#endif - /* Allocate temporary arrays for the MPI_Gatherv() operation */ if(pughGH->myproc == 0) { if(vpcount == NULL) { @@ -704,7 +726,7 @@ WriteUCD(cGH *GH, polypatch *totals, const char *fullname, int IsoSurfacer_TimeForOutput(cGH *GH, int i){ /* Get the GH extensions for IOUtil and IOASCII */ isosurfacerGH *myGH = (isosurfacerGH *)GH->extensions[CCTK_GHExtensionHandle("IsoSurfacer")]; - if (!myGH) + if (!myGH ||!myGH->RunIsoSurfacer) return 0; /* do a check for new isosurfaces */ /* Perhaps do a bcast for "changed" flags. @@ -715,6 +737,7 @@ int IsoSurfacer_TimeForOutput(cGH *GH, int i){ int IsoSurfacer_TriggerOutput(cGH *GH,int variable){ isosurfacerGH *myGH; myGH = (isosurfacerGH *) GH->extensions [CCTK_GHExtensionHandle ("IsoSurfacer")]; + if(!myGH || !myGH->RunIsoSurfacer) return 0; computeIso(variable,GH,myGH); /* FIXME MAYBE myGH->out1D_last[variable] = GH->cctk_iteration; 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 */ +} diff --git a/src/IsoSurfacerInit.h b/src/IsoSurfacerInit.h index 0a710e2..6cde6f3 100644 --- a/src/IsoSurfacerInit.h +++ b/src/IsoSurfacerInit.h @@ -16,6 +16,7 @@ void *IsoSurfacer_SetupGH (tFleshConfig *config, int convergence_level,cGH *GH); int IsoSurfacer_InitGH (cGH *GH); int IsoSurfacer (cGH *GH); +int IsoSurfacer_ParseIsoString(char *isostring,cGH *GH,isosurfacerGH *myGH); int IsoSurfacer_TriggerOutput (cGH *GH, int); int IsoSurfacer_TimeForOutput (cGH *GH, int); diff --git a/src/Sockets.c b/src/Sockets.c index 322b628..cce9e0b 100644 --- a/src/Sockets.c +++ b/src/Sockets.c @@ -11,6 +11,7 @@ @@*/ #include "cctk.h" +#include "CactusPUGH/PUGH/src/include/pugh.h" #include <stdio.h> #include <stdlib.h> @@ -82,11 +83,11 @@ typedef struct ISOSocket isoSocketState state; } isoSocket; -/******************************************************************* +/******************************************************************** ********************* Local Routine Prototypes ********************* ********************************************************************/ -IsoCommand *Iso_PollCommand(cGH *cctkGH,IsoCommand *cmd); +IsoCommand *Iso_PollCommand(cGH *cGH,IsoCommand *cmd); int Iso_Write(isoSocket *connection, const char *buffer, size_t count); static SOCKET Iso_MakeSocket (unsigned long port, int *hunt); @@ -94,11 +95,10 @@ static SOCKET Iso_MakeSocket (unsigned long port, int *hunt); static isoSocket *SocketCreate(unsigned long int filedes, isoSocket **list); static void SocketDestroy(isoSocket *this, isoSocket **list); static void SocketClose(isoSocket *this); - +int Iso_SetupServer(cGH *GH,isosurfacerGH *myGH, + int dataport, int controlport, int queue_size, int hunt); static int InitialiseTCP(void); -static int Iso_ReadFromClient(cGH *cctkGH, isoSocket *this,IsoCommand *cmd); - /******************************************************************** ********************* Other Routine Prototypes ********************* ********************************************************************/ @@ -106,7 +106,11 @@ static int Iso_ReadFromClient(cGH *cctkGH, isoSocket *this,IsoCommand *cmd); /******************************************************************** ********************* Local Data ***************************** ********************************************************************/ - +/* OK, maybe this stuff should go into the isosurfacer GH? + Just general fear of global variables... putting it into the + GH uses the same amount of space as the static vars, but gives + us a sort of a "namespace". +*/ /* Active file descriptors */ static fd_set active_fd_set; @@ -124,7 +128,6 @@ static chosen_controlport = 0; static chosen_dataport = 0; - /******************************************************************** ********************* Internal Routines ********************** ********************************************************************/ @@ -171,12 +174,18 @@ static int byteswap(void *buf,CCTK_INT8 nelements,int elementsize) @endhistory @@*/ -int Iso_SetupServer(int dataport, int controlport, int queue_size, int hunt) +int Iso_SetupServer(cGH *GH,isosurfacerGH *myGH,int dataport, int controlport, int queue_size, int hunt) { char hostname[1025]; int realdport; int realcport; +#ifdef CCTK_MPI + pGH *pughGH; + pughGH = PUGH_pGH(GH); + if(pughGH->myproc!=0) return 0; /* not the root processor */ +#endif + /* Some systems need special logic for starting up TCP. */ InitialiseTCP(); @@ -262,8 +271,9 @@ int Iso_ShutdownServer(void) @endhistory @@*/ -int Iso_Poll(cGH *cctkGH, long sec, long usec) +int Iso_Poll(cGH *GH, long sec, long usec) { + #ifdef HAVE_SOCKLEN_T socklen_t size; #else @@ -278,7 +288,10 @@ int Iso_Poll(cGH *cctkGH, long sec, long usec) isoSocket *this; isoSocket *next; - +#ifdef CCTK_MPI + pGH *pughGH = PUGH_pGH(GH); + if(pughGH->myproc!=0) return 0; /* not the root processor */ +#endif if(sec >=0) { timeout.tv_sec = sec; @@ -297,7 +310,7 @@ int Iso_Poll(cGH *cctkGH, long sec, long usec) if (ERROR_CHECK(select (FD_SETSIZE, &read_fd_set, NULL, NULL, real_timeout))) { perror ("select"); - CCTK_Abort(cctkGH, EXIT_FAILURE); + CCTK_Abort(GH, EXIT_FAILURE); } /* Service all the sockets with input pending. */ @@ -312,7 +325,7 @@ int Iso_Poll(cGH *cctkGH, long sec, long usec) if (ERROR_CHECK(new)) { perror ("accept"); - CCTK_Abort(cctkGH, EXIT_FAILURE); + CCTK_Abort(GH, EXIT_FAILURE); } fprintf (stderr, "Isosurfacer: data connect to port %u from host %s, port %hd.\n", @@ -334,7 +347,7 @@ int Iso_Poll(cGH *cctkGH, long sec, long usec) if (ERROR_CHECK(new)) { perror ("accept"); - CCTK_Abort(cctkGH, EXIT_FAILURE); + CCTK_Abort(GH, EXIT_FAILURE); } fprintf (stderr, "Isosurfacer: control connect to port %u from host %s, port %hd.\n", @@ -348,7 +361,7 @@ int Iso_Poll(cGH *cctkGH, long sec, long usec) return 0; } -IsoCommand *Iso_PollCommand(cGH *cctkGH,IsoCommand *cmd){ +IsoCommand *Iso_PollCommand(cGH *GH,IsoCommand *cmd){ #ifdef HAVE_SOCKLEN_T socklen_t size; #else @@ -361,6 +374,10 @@ IsoCommand *Iso_PollCommand(cGH *cctkGH,IsoCommand *cmd){ isoSocket *this; isoSocket *next; +#ifdef CCTK_MPI + pGH *pughGH = PUGH_pGH(GH); + if(pughGH->myproc!=0) return 0; /* not the root processor */ +#endif /* always a timeout of 0 */ timeout.tv_sec = 0; timeout.tv_usec = 0; @@ -371,7 +388,7 @@ IsoCommand *Iso_PollCommand(cGH *cctkGH,IsoCommand *cmd){ if (ERROR_CHECK(select (FD_SETSIZE, &read_fd_set, NULL, NULL, real_timeout))){ perror ("select"); - CCTK_Abort(cctkGH, EXIT_FAILURE); + CCTK_Abort(GH, EXIT_FAILURE); } /* get next command on the control socket list */ for(this = controlsocklist; this; this = this->next){ @@ -813,29 +830,6 @@ static void SocketClose(isoSocket *this) } } - /*@@ - @routine Iso_ReadFromClient - @date Wed Oct 4 11:27:32 2000 - @author Tom Goodale - @desc - Reads a client command. - @enddesc - @calls - @calledby - @history - - @endhistory - -@@*/ -static int Iso_ReadFromClient(cGH *cctkGH, isoSocket *this,IsoCommand *command) -{ - /* Need to have 64+64+64 buffer here (datastruct) - put the buffer in a union. - */ - - return -1; -} - /****************************************************************************** ****************************************************************************** ******************************************************************************/ diff --git a/src/Startup.c b/src/Startup.c index 987b0e0..75635c4 100644 --- a/src/Startup.c +++ b/src/Startup.c @@ -19,15 +19,14 @@ #include "cctk_Arguments.h" #include "cctk_Parameters.h" -int Iso_SetupServer(int dataport, int clientport, int queue_size, int hunt); +/*int Iso_SetupServer(int dataport, int clientport, int queue_size, int hunt); +Iso_SetupServer(7051, 7050, 5, 1); needs to move into InitGH */ int IsoSurfacer_Startup(void) { int IOMethod; int IsoSurfacer_GHExtension; - Iso_SetupServer(7051, 7050, 5, 1); - IsoSurfacer_GHExtension = CCTK_RegisterGHExtension ("IsoSurfacer"); CCTK_RegisterGHExtensionSetupGH (IsoSurfacer_GHExtension,IsoSurfacer_SetupGH); CCTK_RegisterGHExtensionInitGH (IsoSurfacer_GHExtension, IsoSurfacer_InitGH); |