ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/libmdtools/DumpWriter.cpp
(Generate patch)

Comparing trunk/OOPSE/libmdtools/DumpWriter.cpp (file contents):
Revision 910 by gezelter, Thu Jan 8 18:05:37 2004 UTC vs.
Revision 913 by chuckv, Thu Jan 8 22:25:52 2004 UTC

# Line 66 | Line 66 | void DumpWriter::writeDump( double currentTime ){
66   void DumpWriter::writeDump( double currentTime ){
67  
68    const int BUFFERSIZE = 2000;
69 <  const int MINIBUFFERSIZE = 10;
69 >  const int MINIBUFFERSIZE = 100;
70  
71    char tempBuffer[BUFFERSIZE];
72    char writeLine[BUFFERSIZE];
# Line 158 | Line 158 | void DumpWriter::writeDump( double currentTime ){
158  
159   #else // is_mpi
160  
161 <  // first thing first, suspend fatalities.
162 <  painCave.isEventLoop = 1;
161 >  /* code to find maximum tag value */
162 >  int *tagub, flag, MAXTAG;
163 >  MPI_Attr_get(MPI_COMM_WORLD, MPI_TAG_UB, &tagub, &flag);
164 >  if (flag) {
165 >    MAXTAG = *tagub;
166 >  } else {
167 >    MAXTAG = 32767;
168 >  }
169  
164  int myStatus; // 1 = wakeup & success; 0 = error; -1 = AllDone
170    int haveError;
171  
172    MPI_Status istatus;
# Line 188 | Line 193 | void DumpWriter::writeDump( double currentTime ){
193      outFile << entry_plug->the_integrator->getAdditionalParameters();
194      outFile << endl;
195      outFile.flush();
196 +
197 +    tag = 0;
198 +
199      for (i = 0 ; i < mpiSim->getTotAtoms(); i++ ) {
192      // Get the Node number which has this atom;
200  
201 +      if (tag + 2 >= MAXTAG) {
202 +        // The tag was going to exceed the maximum value, so wrap around to 0:
203 +        tag = 0;
204 +        // Send the newly zeroed tag on to the other nodes:
205 +        MPI_Bcast(&tag, 1, MPI_INT, 0, MPI_COMM_WORLD);
206 +      }
207 +      
208 +      // Get the Node number which has this atom;
209 +      
210        which_node = AtomToProcMap[i];
211 <
211 >      
212        if (which_node != 0) {
213          
198        atomTypeTag          = 4*i;
199        atomIsDirectionalTag = 4*i + 1;
200        atomTransDataTag     = 4*i + 2;
201        atomOrientDataTag    = 4*i + 3;
202
214          MPI_Recv(MPIatomTypeString, MINIBUFFERSIZE, MPI_CHAR, which_node,
215                   atomTypeTag, MPI_COMM_WORLD, &istatus);
216          
217          strncpy(atomTypeString, MPIatomTypeString, MINIBUFFERSIZE);
218 +        
219 +        // Null terminate the atomTypeString just in case:
220  
221 +        atomTypeString[strlen(atomTypeString) - 1] = '\0';
222 +
223          MPI_Recv(&isDirectional, 1, MPI_INT, which_node,
224                   atomIsDirectionalTag, MPI_COMM_WORLD, &istatus);
225          
# Line 379 | Line 394 | void DumpWriter::writeDump( double currentTime ){
394  
395          strncpy(MPIatomTypeString, atomTypeString, MINIBUFFERSIZE);
396  
397 +        // null terminate the string before sending (just in case):
398 +        MPIatomTypeString[MINIBUFFERSIZE-1] = '\0';
399 +
400          MPI_Send(MPIatomTypeString, MINIBUFFERSIZE, MPI_CHAR, 0,
401                   atomTypeTag, MPI_COMM_WORLD);
402          
# Line 415 | Line 433 | void DumpWriter::writeFinal(double finalTime){
433    ofstream finalOut;
434  
435    const int BUFFERSIZE = 2000;
436 <  const int MINIBUFFERSIZE = 10;
436 >  const int MINIBUFFERSIZE = 100;
437    char tempBuffer[BUFFERSIZE];
438    char writeLine[BUFFERSIZE];
439  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines