From c59f01e6a4796ad9fc70e88dbb556c3a696ffc8b Mon Sep 17 00:00:00 2001 From: tradke Date: Mon, 5 Nov 2001 15:05:51 +0000 Subject: Added const qualifier to the 'cGH *' argument of some more IO functions. git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGHIO/IsoSurfacer/trunk@51 bfcf8e34-485d-4d46-a995-1fd6fa6fb178 --- src/IsoSurfacer.c | 59 +++++++++++++++++++++++++++++++-------------------- src/IsoSurfacerInit.h | 6 +++--- src/Sockets.c | 38 ++++++++++++++++++++++++--------- 3 files changed, 67 insertions(+), 36 deletions(-) diff --git a/src/IsoSurfacer.c b/src/IsoSurfacer.c index 366e552..7db611b 100644 --- a/src/IsoSurfacer.c +++ b/src/IsoSurfacer.c @@ -47,27 +47,29 @@ if( (p += strlen(tmps)) >= lfs ) \ } \ strcpy(&(outs)[q], (tmps)) /* ***** Some function forward declarations ***** */ -static void CollectData(cGH *GH, polypatch *perprocessor, polypatch *totals); -static void WriteBin(cGH *GH, polypatch *totals,isosurfacerGH *myGH, +static void CollectData(const cGH *GH, polypatch *perprocessor, polypatch *totals); +static void WriteBin(const cGH *GH, polypatch *totals,isosurfacerGH *myGH, const char *fullname, CCTK_REAL4 isolevel); -static void WriteVRML(cGH *GH, polypatch *totals, +static void WriteVRML(const cGH *GH, polypatch *totals, const char *fullname, CCTK_REAL4 isolevel); -static void WriteASCII(cGH *GH, polypatch *totals, +static void WriteASCII(const cGH *GH, polypatch *totals, const char *fullname, CCTK_REAL4 isolevel); -static void WriteUCD(cGH *GH, polypatch *totals, +static void WriteUCD(const cGH *GH, polypatch *totals, const char *fullname, CCTK_REAL4 isolevel); -static void WriteSock(cGH *GH, polypatch *totals, isosurfacerGH *myGH, +static void WriteSock(const cGH *GH, polypatch *totals, isosurfacerGH *myGH, const char *fullname, int isoindex, CCTK_REAL4 isolevel); -static void WriteHDF5(cGH *GH, polypatch *totals, isosurfacerGH *myGH, +static void WriteHDF5(const cGH *GH, polypatch *totals, isosurfacerGH *myGH, const char *fullname, int isoindex, CCTK_REAL4 isolevel); /***************************************************************************/ -static int IsoSurfacerHandleCommands(cGH *GH) +static int IsoSurfacerHandleCommands(const cGH *GH) { DECLARE_CCTK_PARAMETERS - IsoCommand *Iso_PollCommand(cGH *cctkGH,IsoCommand *cmd); + IsoCommand *Iso_PollCommand(const cGH *cctkGH,IsoCommand *cmd); IsoCommand command; +#ifdef CCTK_MPI CCTK_REAL new_isovalue; +#endif isosurfacerGH *myGH = (isosurfacerGH *) GH->extensions [CCTK_GHExtensionHandle ("IsoSurfacer")]; if(!myGH->RunIsoSurfacer) return 0; /* not running */ @@ -156,7 +158,7 @@ static int IsoSurfacerHandleCommands(cGH *GH) return 0; } -static int doIso(int vindex, cGH *GH, isosurfacerGH *myGH) +static int doIso(int vindex, const cGH *GH, isosurfacerGH *myGH) { char *fullname; @@ -177,7 +179,7 @@ static int doIso(int vindex, cGH *GH, isosurfacerGH *myGH) } -static void computeIso(int vindex, cGH *GH, isosurfacerGH *myGH) +static void computeIso(int vindex, const cGH *GH, isosurfacerGH *myGH) { DECLARE_CCTK_PARAMETERS /* is it really required to have this static here?? */ @@ -186,6 +188,16 @@ static void computeIso(int vindex, cGH *GH, isosurfacerGH *myGH) int nx,ny,nz; CCTK_REAL *xcoords,*ycoords,*zcoords,*data; int timelevel=0; + /*** FIXME: can CCTK_Reduce() have a 'const cGH *' parameter ?? ***/ + union + { + const cGH *const_ptr; + cGH *non_const_ptr; + } GH_fake_const; + + + GH_fake_const.const_ptr = GH; + if(!myGH->RunIsoSurfacer) return; /* not running */ @@ -211,10 +223,10 @@ static void computeIso(int vindex, cGH *GH, isosurfacerGH *myGH) if(myGH->formats & (SOCK|ISOHDF5|BIN)){ int handle; handle = CCTK_ReductionHandle ("minimum"); - CCTK_Reduce (GH, 0,handle,1,CCTK_VARIABLE_REAL, + CCTK_Reduce (GH_fake_const.non_const_ptr, 0,handle,1,CCTK_VARIABLE_REAL, &(myGH->minval),1, vindex); handle = CCTK_ReductionHandle ("maximum"); - CCTK_Reduce (GH, 0, handle, 1, CCTK_VARIABLE_REAL, + CCTK_Reduce (GH_fake_const.non_const_ptr, 0, handle, 1, CCTK_VARIABLE_REAL, &(myGH->maxval), 1, vindex); } @@ -274,7 +286,7 @@ static void computeIso(int vindex, cGH *GH, isosurfacerGH *myGH) free (fullname); } -int IsoSurfacer(cGH *GH){ +int IsoSurfacer(const cGH *GH){ DECLARE_CCTK_PARAMETERS int i,n; isosurfacerGH *myGH = (isosurfacerGH *) GH->extensions [CCTK_GHExtensionHandle ("IsoSurfacer")]; @@ -301,7 +313,7 @@ int IsoSurfacer(cGH *GH){ /***************************************************************************/ -void CollectData(cGH *GH, polypatch *perprocessor, polypatch *totals) { +void CollectData(const cGH *GH, polypatch *perprocessor, polypatch *totals) { DECLARE_CCTK_PARAMETERS #ifdef CCTK_MPI @@ -417,6 +429,7 @@ void CollectData(cGH *GH, polypatch *perprocessor, polypatch *totals) { } #else /* !MPI */ + GH = GH; *totals = *perprocessor; #endif /* MPI */ } @@ -428,7 +441,7 @@ int IsoWriteDataToClients(char *metadata, IsoType type, void *data); -void WriteSock(cGH *GH, polypatch *totals, isosurfacerGH *myGH, +void WriteSock(const cGH *GH, polypatch *totals, isosurfacerGH *myGH, const char *fullname, int isoindex, CCTK_REAL4 IsoValue) { @@ -467,7 +480,7 @@ void WriteSock(cGH *GH, polypatch *totals, isosurfacerGH *myGH, /***************************************************************************/ -static void WriteHDF5(cGH *GH, polypatch *totals, isosurfacerGH *myGH, +static void WriteHDF5(const cGH *GH, polypatch *totals, isosurfacerGH *myGH, const char *fullname, int isoindex, CCTK_REAL4 IsoValue) { DECLARE_CCTK_PARAMETERS @@ -505,7 +518,7 @@ static void WriteHDF5(cGH *GH, polypatch *totals, isosurfacerGH *myGH, /***************************************************************************/ void -WriteBin(cGH *GH, polypatch *totals, isosurfacerGH *myGH, const char *fullname, +WriteBin(const cGH *GH, polypatch *totals, isosurfacerGH *myGH, const char *fullname, CCTK_REAL4 isolevel) { /* Write Isosurfaces in Manuel's own format which can @@ -566,7 +579,7 @@ WriteBin(cGH *GH, polypatch *totals, isosurfacerGH *myGH, const char *fullname, /***************************************************************************/ void -WriteVRML(cGH *GH, polypatch *totals, const char *fullname, +WriteVRML(const cGH *GH, polypatch *totals, const char *fullname, CCTK_REAL4 isolevel) { /* Write isosurfaces in VRML 1.0 ASCII format @@ -634,7 +647,7 @@ WriteVRML(cGH *GH, polypatch *totals, const char *fullname, /***************************************************************************/ void -WriteASCII(cGH *GH, polypatch *totals, const char *fullname, +WriteASCII(const cGH *GH, polypatch *totals, const char *fullname, CCTK_REAL4 isolevel) { /* Write Iso's in Paul's ASCII format */ @@ -692,7 +705,7 @@ WriteASCII(cGH *GH, polypatch *totals, const char *fullname, /***************************************************************************/ void -WriteUCD(cGH *GH, polypatch *totals, const char *fullname, +WriteUCD(const cGH *GH, polypatch *totals, const char *fullname, CCTK_REAL4 isolevel) { /* Write Iso's in AVS ascii UCD format */ @@ -760,7 +773,7 @@ WriteUCD(cGH *GH, polypatch *totals, const char *fullname, /***************************************************************************/ /* this is pretty redundant. Should be removed and just use doIso() */ -int IsoSurfacer_TimeForOutput(cGH *GH, int i){ +int IsoSurfacer_TimeForOutput(const cGH *GH, int i){ /* Get the GH extensions for IOUtil and IOASCII */ isosurfacerGH *myGH = (isosurfacerGH *)GH->extensions[CCTK_GHExtensionHandle("IsoSurfacer")]; if (!myGH ||!myGH->RunIsoSurfacer) @@ -771,7 +784,7 @@ int IsoSurfacer_TimeForOutput(cGH *GH, int i){ return doIso(i, GH, myGH); } -int IsoSurfacer_TriggerOutput(cGH *GH,int variable){ +int IsoSurfacer_TriggerOutput(const cGH *GH,int variable){ isosurfacerGH *myGH; myGH = (isosurfacerGH *) GH->extensions [CCTK_GHExtensionHandle ("IsoSurfacer")]; if(!myGH || !myGH->RunIsoSurfacer) return 0; diff --git a/src/IsoSurfacerInit.h b/src/IsoSurfacerInit.h index 0a710e2..caedf79 100644 --- a/src/IsoSurfacerInit.h +++ b/src/IsoSurfacerInit.h @@ -15,9 +15,9 @@ /* prototypes of functions to be registered */ void *IsoSurfacer_SetupGH (tFleshConfig *config, int convergence_level,cGH *GH); int IsoSurfacer_InitGH (cGH *GH); -int IsoSurfacer (cGH *GH); -int IsoSurfacer_TriggerOutput (cGH *GH, int); -int IsoSurfacer_TimeForOutput (cGH *GH, int); +int IsoSurfacer (const cGH *GH); +int IsoSurfacer_TriggerOutput (const cGH *GH, int); +int IsoSurfacer_TimeForOutput (const cGH *GH, int); #endif diff --git a/src/Sockets.c b/src/Sockets.c index 51fc9a7..8917797 100644 --- a/src/Sockets.c +++ b/src/Sockets.c @@ -94,7 +94,7 @@ typedef struct ISOSocket static int byteswap(void *buf,CCTK_INT8 nelements,int elementsize); -IsoCommand *Iso_PollCommand(cGH *GH,IsoCommand *cmd); +IsoCommand *Iso_PollCommand(const cGH *GH,IsoCommand *cmd); int Iso_Write(isoSocket *connection, const char *buffer, size_t count); static SOCKET Iso_MakeSocket (unsigned long port, int *hunt); @@ -102,10 +102,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 Iso_SetupServer(const cGH *GH,isosurfacerGH *myGH, int dataport, int controlport, int queue_size, int hunt); int Iso_ShutdownServer(void); -int Iso_Poll(cGH *GH, long sec, long usec); +int Iso_Poll(const cGH *GH, long sec, long usec); int Iso_Read(isoSocket *connection, char *buffer, size_t count); int IsoWriteDataToClients(const char *metadata, CCTK_INT8 size, @@ -164,7 +164,7 @@ static char *advertised_filename = NULL; @endhistory @@*/ -int Iso_SetupServer(cGH *GH,isosurfacerGH *myGH,int dataport, int controlport, int queue_size, int hunt) +int Iso_SetupServer(const cGH *GH,isosurfacerGH *myGH,int dataport, int controlport, int queue_size, int hunt) { int realdport; int realcport; @@ -301,7 +301,7 @@ int Iso_ShutdownServer(void) @endhistory @@*/ -int Iso_Poll(cGH *GH, long sec, long usec) +int Iso_Poll(const cGH *GH, long sec, long usec) { #ifdef HAVE_SOCKLEN_T @@ -315,6 +315,15 @@ int Iso_Poll(cGH *GH, long sec, long usec) struct sockaddr_in clientname; struct timeval timeout; struct timeval *real_timeout; + /*** FIXME: can CCTK_Abort() have a 'const cGH *' parameter ?? ***/ + union + { + const cGH *const_ptr; + cGH *non_const_ptr; + } GH_fake_const; + + + GH_fake_const.const_ptr = GH; if(CCTK_MyProc(GH) != 0) return 0; /* not the root processor */ @@ -336,7 +345,7 @@ int Iso_Poll(cGH *GH, long sec, long usec) if (ERROR_CHECK(select (FD_SETSIZE, &read_fd_set, NULL, NULL, real_timeout))) { perror ("select"); - CCTK_Abort(GH, EXIT_FAILURE); + CCTK_Abort(GH_fake_const.non_const_ptr, EXIT_FAILURE); } /* Service all the sockets with input pending. */ @@ -351,7 +360,7 @@ int Iso_Poll(cGH *GH, long sec, long usec) if (ERROR_CHECK(new)) { perror ("accept"); - CCTK_Abort(GH, EXIT_FAILURE); + CCTK_Abort(GH_fake_const.non_const_ptr, EXIT_FAILURE); } fprintf (stderr, "Isosurfacer: data connect to port %u from host %s, port %hd.\n", @@ -373,7 +382,7 @@ int Iso_Poll(cGH *GH, long sec, long usec) if (ERROR_CHECK(new)) { perror ("accept"); - CCTK_Abort(GH, EXIT_FAILURE); + CCTK_Abort(GH_fake_const.non_const_ptr, EXIT_FAILURE); } fprintf (stderr, "Isosurfacer: control connect to port %u from host %s, port %hd.\n", @@ -387,13 +396,22 @@ int Iso_Poll(cGH *GH, long sec, long usec) return 0; } -IsoCommand *Iso_PollCommand(cGH *GH,IsoCommand *cmd) +IsoCommand *Iso_PollCommand(const cGH *GH,IsoCommand *cmd) { fd_set read_fd_set; struct timeval timeout; struct timeval *real_timeout; isoSocket *this; + /*** FIXME: can CCTK_Abort() have a 'const cGH *' parameter ?? ***/ + union + { + const cGH *const_ptr; + cGH *non_const_ptr; + } GH_fake_const; + + + GH_fake_const.const_ptr = GH; if(CCTK_MyProc(GH) != 0) return 0; /* not the root processor */ @@ -408,7 +426,7 @@ IsoCommand *Iso_PollCommand(cGH *GH,IsoCommand *cmd) if (ERROR_CHECK(select (FD_SETSIZE, &read_fd_set, NULL, NULL, real_timeout))){ perror ("select"); - CCTK_Abort(GH, EXIT_FAILURE); + CCTK_Abort(GH_fake_const.non_const_ptr, EXIT_FAILURE); } /* get next command on the control socket list */ for(this = controlsocklist; this; this = this->next){ -- cgit v1.2.3