aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjshalf <jshalf@bfcf8e34-485d-4d46-a995-1fd6fa6fb178>2000-10-09 07:37:58 +0000
committerjshalf <jshalf@bfcf8e34-485d-4d46-a995-1fd6fa6fb178>2000-10-09 07:37:58 +0000
commit52dbed6e928d2882b0c0f7005a0e269755dea5a2 (patch)
tree34dd14f5afff2e6c0ecfbb3c002a6b0fb9354080
parent749d477a67a3d9b8a314d62030c646606f1a001f (diff)
Finally got it to send some data to IsoView.
FYI: htonl() doesn't always do what is expected of it... Used wavetoy binary source to test. Critical params for the .par file were isosurfacer::output_format="SOCK" isosurfacer::output_var = "WAVETOY::phi" isosurfacer::isovalue=0.35: Now must fix the steering part. git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGHIO/IsoSurfacer/trunk@10 bfcf8e34-485d-4d46-a995-1fd6fa6fb178
-rw-r--r--src/IsoSurfacer.c34
-rw-r--r--src/Sockets.c80
2 files changed, 73 insertions, 41 deletions
diff --git a/src/IsoSurfacer.c b/src/IsoSurfacer.c
index 2950949..d761ada 100644
--- a/src/IsoSurfacer.c
+++ b/src/IsoSurfacer.c
@@ -1,22 +1,13 @@
/*@@
@file IsoSurfacer.c
- @date Wed Oct 8 11:30:45 MET 1997
- @author Manuel Panea <mpd@rzg.mpg.de>
+ @date Wed Oct 8 11:30:45 MET 2000
+ @author Joe Blow
@desc
- An interface to isosurfacer routines which allows parallel
- isosurface finding. The heart of this thorn is @seeroutine
- FindIsoSurface which takes a GF and returns a vertex* and
- polygon* for the local (including ownership) chunk of data.
- The vertices should be based on the x-y-z arrays.<p>
-
- Note by John Shalf:
- Currently the lists are collected using a MPI_Gatherv(). I just
- implemented this for provisional testing. If the isosurfaces get
- sufficiently complex, they will flood the master processor with
- too much data. In this case we'd need to switch to a more
- sophisticated method to collect them. (so the potential problem
- with the current implementation has been noted and will be dealt
- with at a later time.)
+ Gutted original isosurfacer code from SC97.
+ Has completely new implementation for marching
+ cubes and sockets are integrated in Sockets.c
+ rather than coming from TCP++ or other external
+ modules.
@enddesc
@@*/
@@ -114,7 +105,7 @@ static int IsoSurfacerHandleCommands(cGH *GH)
char *obj = catenated+64,
*val = catenated+128; */
- puts("Nuthin to do (yet)");
+ /* puts("Nuthin to do (yet)"); */
/* Here it just needs to read from the control socket
and then change the isosurface appropriately */
return 0;
@@ -122,8 +113,8 @@ static int IsoSurfacerHandleCommands(cGH *GH)
static int doIso(int index, cGH *GH, isosurfacerGH *myGH)
{
- /* need to rediscover how to mess with this */
char *fullname = CCTK_FullName (index);
+ /* printf("Check doIso: fullname[%s]:[%s]",fullname,myGH->funcName);*/
if(!strcmp(fullname,myGH->funcName)){
if(myGH->firstIteration<=GH->cctk_iteration &&
!((GH->cctk_iteration-myGH->firstIteration) % myGH->outfreq)){
@@ -132,6 +123,7 @@ static int doIso(int index, cGH *GH, isosurfacerGH *myGH)
}
}
free(fullname);
+ /* puts("\tfailed"); */
return 0;
}
@@ -189,7 +181,6 @@ static void computeIso(int index, cGH *GH, isosurfacerGH *myGH)
polybackup=myGH->totals.polys; myGH->totals.polys = tmppolys;
vertbackup=myGH->totals.verts; myGH->totals.verts = tmpverts;
}
-
if (verbose)
printf(" | IsoSurfacer: GF=%s, value %f,",
fullname, myGH->isovalue);
@@ -323,7 +314,7 @@ void CollectData(cGH *GH, polypatch *perprocessor, polypatch *totals) {
totals->npolys /= 3;
/*
- Kludge by M. Panea:
+ Kludge:
Allocate 3 more than necessary so as to divert
the output of processors
with nverts=0 to a dummy area in the upper part of totals->verts.
@@ -391,7 +382,8 @@ void WriteSock(cGH *GH, polypatch *totals, isosurfacerGH *myGH,
fullname,myGH->isovalue,
GH->cctk_iteration,
myGH->minval,myGH->maxval);
- puts(tmpstring);
+ /*puts("sock out+++++++++++++++++");
+ puts(tmpstring); */
/********Now write vertices**********/
*tmpstring='v';
verts = totals->nverts > 0 ? totals->verts : tmpverts;
diff --git a/src/Sockets.c b/src/Sockets.c
index 2d36b02..fea3c92 100644
--- a/src/Sockets.c
+++ b/src/Sockets.c
@@ -118,6 +118,38 @@ static SOCKET maxsock;
static isoSocket *controlsocklist = NULL;
static isoSocket *datasocklist = NULL;
+static chosen_controlport = 0;
+static chosen_dataport = 0;
+
+
+
+/********************************************************************
+ ********************* Internal Routines **********************
+ ********************************************************************/
+static int byteswap(void *buf,CCTK_INT8 nelements,int elementsize)
+{
+ char *buffer;
+ CCTK_INT8 i;
+ int s,d;
+#ifdef WORDS_BIGENDIAN
+ return 0;
+#else
+ buffer=(char *)buf;
+ if(elementsize<=1) return 0;
+
+ for(i=0;i<nelements;i++,buffer+=elementsize){
+ // do the swap thing on each element
+ for(s=0,d=elementsize-1;s<d;s++,d--){
+ char c=buffer[s];
+ buffer[s]=buffer[d];
+ buffer[d]=c;
+ }
+ }
+ return 1;
+#endif
+}
+
+
/********************************************************************
********************* External Routines **********************
********************************************************************/
@@ -168,7 +200,8 @@ int Iso_SetupServer(int dataport, int controlport, int queue_size, int hunt)
printf("Isosurfacer listening for control connetcions on %s port %d/\n", hostname, hunt ? realcport : controlport);
printf("Isosurfacer listening for data connections on %s port %d/\n", hostname, hunt ? realdport : dataport);
-
+ chosen_controlport = hunt ? realcport:controlport;
+ chosen_dataport = hunt ? realdport:dataport;
minsock = datasock > controlsock ? controlsock : datasock;
maxsock = datasock > controlsock ? datasock : controlsock;
@@ -280,7 +313,8 @@ int Iso_Poll(cGH *cctkGH, long sec, long usec)
CCTK_Abort(cctkGH, EXIT_FAILURE);
}
fprintf (stderr,
- "Isosurfacer: data connect from host %s, port %hd.\n",
+ "Isosurfacer: data connect to port %u from host %s, port %hd.\n",
+ chosen_dataport,
inet_ntoa (clientname.sin_addr),
ntohs (clientname.sin_port));
@@ -301,7 +335,8 @@ int Iso_Poll(cGH *cctkGH, long sec, long usec)
CCTK_Abort(cctkGH, EXIT_FAILURE);
}
fprintf (stderr,
- "Isosurfacer: control connect from host %s, port %hd.\n",
+ "Isosurfacer: control connect to port %u from host %s, port %hd.\n",
+ chosen_controlport,
inet_ntoa (clientname.sin_addr),
ntohs (clientname.sin_port));
@@ -333,8 +368,8 @@ int IsoWriteDataToClients(const char *metadata,
CCTK_INT4 *data=(CCTK_INT4*)dataP;
int retval;
CCTK_INT4 i;
- CCTK_INT4 datatype;
- CCTK_INT4 datasize;
+ CCTK_INT4 datatype=type;
+ CCTK_INT8 datasize=size;
isoSocket *this;
isoSocket *next;
@@ -342,26 +377,30 @@ int IsoWriteDataToClients(const char *metadata,
CCTK_REAL4 tmpverts[3] = {0.0,0.0,0.0};
/* Convert the data to network byte order */
- for(i = 0; i < size; i++)
- {
- data[i] = htons(data[i]);
- }
-
- datatype = type;
-
- datatype = htons(datatype);
-
- datasize = htonl(datasize);
+ byteswap(data,size,4);
+ /* for(i = 0; i < size; i++)
+ {
+ I wish htons/htonl actually worked as you'd expect them to
+ data[i] = htons(data[i]);
+ }*/
+ /* printf("Pre-Swap Datasize=%lld:%llx\n",datasize,datasize); */
+ byteswap(&datatype,1,4);
+ byteswap(&datasize,1,8);
+ /* printf("PostSwap Datasize=%lld:%llx\n",datasize,datasize); */
+ /* unfortunately short is 16 bits and long is 32 bits on some systems
+ datatype = htons(datatype);
+ datasize = htonl(datasize); */
/* Send data down all connected sockets. */
for(this = datasocklist; this; this = next)
{
next = this->next;
- Iso_Write(this, (void *)&datasize, 8);
- Iso_Write(this, (void *)&datatype, 4);
+ retval=Iso_Write(this, (void*)(&datasize), 8);
+ /* printf("RetVal on size write=%d\n",retval); */
+ Iso_Write(this, (void*)(&datatype), 4);
Iso_Write(this, metadata, 64);
- retval = Iso_Write(this, (void *)data, size);
+ retval = Iso_Write(this, (void *)data, size*4);
if(retval < 0)
{
@@ -370,12 +409,13 @@ int IsoWriteDataToClients(const char *metadata,
}
/* Convert the data back */
+ byteswap(data,size,4);
+#if 0
for(i = 0; i < size; i++)
{
data[i] = htons(data[i]);
}
-
-
+#endif
}