| 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]; |
| 78 |
|
double atomOrientData[7]; |
| 79 |
|
int isDirectional; |
| 80 |
|
char* atomTypeString; |
| 81 |
+ |
char MPIatomTypeString[MINIBUFFERSIZE]; |
| 82 |
|
int me; |
| 83 |
|
int atomTypeTag; |
| 84 |
|
int atomIsDirectionalTag; |
| 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 |
|
|
| 163 |
– |
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++ ) { |
| 191 |
– |
// 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 |
|
|
| 214 |
< |
atomTypeTag = 4*i; |
| 198 |
< |
atomIsDirectionalTag = 4*i + 1; |
| 199 |
< |
atomTransDataTag = 4*i + 2; |
| 200 |
< |
atomOrientDataTag = 4*i + 3; |
| 201 |
< |
|
| 202 |
< |
MPI_Recv(atomTypeString, MINIBUFFERSIZE, MPI_CHAR, which_node, |
| 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 |
|
|
| 391 |
|
atomTransDataTag = 4*i + 2; |
| 392 |
|
atomOrientDataTag = 4*i + 3; |
| 393 |
|
|
| 394 |
< |
MPI_Send(atomTypeString, MINIBUFFERSIZE, MPI_CHAR, 0, |
| 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 |
|
|
| 403 |
|
MPI_Send(&isDirectional, 1, MPI_INT, 0, |
| 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 |
|
|
| 447 |
|
double atomOrientData[7]; |
| 448 |
|
int isDirectional; |
| 449 |
|
char* atomTypeString; |
| 450 |
+ |
char MPIatomTypeString[MINIBUFFERSIZE]; |
| 451 |
|
int atomTypeTag; |
| 452 |
|
int atomIsDirectionalTag; |
| 453 |
|
int atomTransDataTag; |
| 589 |
|
atomTransDataTag = 4*i + 2; |
| 590 |
|
atomOrientDataTag = 4*i + 3; |
| 591 |
|
|
| 592 |
< |
MPI_Recv(atomTypeString, MINIBUFFERSIZE, MPI_CHAR, which_node, |
| 592 |
> |
MPI_Recv(MPIatomTypeString, MINIBUFFERSIZE, MPI_CHAR, which_node, |
| 593 |
|
atomTypeTag, MPI_COMM_WORLD, &istatus); |
| 594 |
|
|
| 595 |
+ |
strncpy(atomTypeString, MPIatomTypeString, MINIBUFFERSIZE); |
| 596 |
+ |
|
| 597 |
|
MPI_Recv(&isDirectional, 1, MPI_INT, which_node, |
| 598 |
|
atomIsDirectionalTag, MPI_COMM_WORLD, &istatus); |
| 599 |
|
|
| 765 |
|
atomTransDataTag = 4*i + 2; |
| 766 |
|
atomOrientDataTag = 4*i + 3; |
| 767 |
|
|
| 768 |
< |
MPI_Send(atomTypeString, MINIBUFFERSIZE, MPI_CHAR, 0, |
| 768 |
> |
strncpy(MPIatomTypeString, atomTypeString, MINIBUFFERSIZE); |
| 769 |
> |
|
| 770 |
> |
MPI_Send(MPIatomTypeString, MINIBUFFERSIZE, MPI_CHAR, 0, |
| 771 |
|
atomTypeTag, MPI_COMM_WORLD); |
| 772 |
|
|
| 773 |
|
MPI_Send(&isDirectional, 1, MPI_INT, 0, |