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]; |
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; |
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 |
|
|
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 |
|
|
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 |
|
|