| 84 |
|
|
| 85 |
|
void DumpReader::scanFile( void ){ |
| 86 |
|
|
| 87 |
< |
int vectorSize; |
| 88 |
< |
int i, j, k; |
| 87 |
> |
int i, j; |
| 88 |
|
int lineNum = 0; |
| 89 |
|
char readBuffer[2000]; |
| 91 |
– |
char* foo; |
| 90 |
|
fpos_t *currPos; |
| 93 |
– |
double time; |
| 94 |
– |
|
| 95 |
– |
|
| 91 |
|
|
| 92 |
|
#ifdef IS_MPI |
| 93 |
|
if( worldRank == 0 ){ |
| 171 |
|
|
| 172 |
|
void DumpReader :: readSet( int whichFrame ){ |
| 173 |
|
|
| 174 |
< |
int i, j; |
| 174 |
> |
int i; |
| 175 |
> |
unsigned int j; |
| 176 |
|
|
| 177 |
|
#ifdef IS_MPI |
| 178 |
|
int done, which_node, which_atom; // loop counter |
| 269 |
|
int *MolToProcMap = mpiSim->getMolToProcMap(); |
| 270 |
|
int localIndex; |
| 271 |
|
int nCurObj; |
| 272 |
+ |
int nitems; |
| 273 |
|
|
| 274 |
+ |
nTotObjs = simnfo->getTotIntegrableObjects(); |
| 275 |
|
haveError = 0; |
| 276 |
|
if (worldRank == 0) { |
| 277 |
|
fsetpos(inFile, framePos[whichFrame]); |
| 284 |
|
simError(); |
| 285 |
|
} |
| 286 |
|
|
| 287 |
< |
nTotObjs = atoi( read_buffer ); |
| 287 |
> |
nitems = atoi( read_buffer ); |
| 288 |
|
|
| 289 |
|
// Check to see that the number of integrable objects in the intial configuration file is the |
| 290 |
|
// same as declared in simBass. |
| 291 |
|
|
| 292 |
< |
if( nTotObjs != simnfo->getTotIntegrableObjects()){ |
| 292 |
> |
if( nTotObjs != nitems){ |
| 293 |
|
sprintf( painCave.errMsg, |
| 294 |
|
"DumpReadererror. %s n_atoms, %d, " |
| 295 |
|
"does not match the BASS file's n_atoms, %d.\n", |
| 323 |
|
simError(); |
| 324 |
|
} |
| 325 |
|
|
| 326 |
< |
for (i=0 ; i < mpiSim->getTotNmol(); i++) { |
| 326 |
> |
for (i=0 ; i < mpiSim->getNMolGlobal(); i++) { |
| 327 |
|
which_node = MolToProcMap[i]; |
| 328 |
|
if(which_node == 0){ |
| 329 |
|
//molecules belong to master node |
| 352 |
|
|
| 353 |
|
if(haveError) nodeZeroError(); |
| 354 |
|
|
| 355 |
< |
parseDumpLine(read_buffer, integrableObjects[i]); |
| 355 |
> |
parseDumpLine(read_buffer, integrableObjects[j]); |
| 356 |
|
|
| 357 |
|
} |
| 358 |
|
|
| 361 |
|
else{ |
| 362 |
|
//molecule belongs to slave nodes |
| 363 |
|
|
| 364 |
< |
MPI_Recv(&nCurObj, 1, MPI_INT, 0, |
| 364 |
> |
MPI_Recv(&nCurObj, 1, MPI_INT, which_node, |
| 365 |
|
TAKE_THIS_TAG_INT, MPI_COMM_WORLD, &istatus); |
| 366 |
|
|
| 367 |
< |
for(j=0; j < integrableObjects.size(); j++){ |
| 367 |
> |
for(j=0; j < nCurObj; j++){ |
| 368 |
|
|
| 369 |
|
eof_test = fgets(read_buffer, sizeof(read_buffer), inFile); |
| 370 |
|
if(eof_test == NULL){ |
| 391 |
|
} |
| 392 |
|
else{ |
| 393 |
|
//actions taken at slave nodes |
| 394 |
< |
for (i=0 ; i < mpiSim->getTotNmol(); i++) { |
| 394 |
> |
MPI_Bcast(read_buffer, BUFFERSIZE, MPI_CHAR, 0, MPI_COMM_WORLD); |
| 395 |
> |
|
| 396 |
> |
parseErr = parseCommentLine( read_buffer, simnfo); |
| 397 |
> |
|
| 398 |
> |
if( parseErr != NULL ){ |
| 399 |
> |
strcpy( painCave.errMsg, parseErr ); |
| 400 |
> |
haveError = 1; |
| 401 |
> |
simError(); |
| 402 |
> |
} |
| 403 |
> |
|
| 404 |
> |
for (i=0 ; i < mpiSim->getNMolGlobal(); i++) { |
| 405 |
|
which_node = MolToProcMap[i]; |
| 406 |
|
|
| 407 |
|
if(which_node == worldRank){ |
| 419 |
|
|
| 420 |
|
nCurObj = integrableObjects.size(); |
| 421 |
|
|
| 422 |
< |
MPI_Recv(&nCurObj, 1, MPI_INT, 0, |
| 423 |
< |
TAKE_THIS_TAG_INT, MPI_COMM_WORLD, &istatus); |
| 422 |
> |
MPI_Send(&nCurObj, 1, MPI_INT, 0, |
| 423 |
> |
TAKE_THIS_TAG_INT, MPI_COMM_WORLD); |
| 424 |
|
|
| 425 |
|
for(j = 0; j < integrableObjects.size(); j++){ |
| 426 |
|
|
| 612 |
|
|
| 613 |
|
qSqr = (q[0] * q[0]) + (q[1] * q[1]) + (q[2] * q[2]) + (q[3] * q[3]); |
| 614 |
|
|
| 615 |
+ |
if (fabs(qSqr) < 1e-6) { |
| 616 |
+ |
sprintf(painCave.errMsg, |
| 617 |
+ |
"initial quaternion error (q0^2 + q1^2 + q2^2 + q3^2 ~ 0).\n"); |
| 618 |
+ |
return strdup(painCave.errMsg); |
| 619 |
+ |
} |
| 620 |
+ |
|
| 621 |
|
qLength = sqrt( qSqr ); |
| 622 |
|
q[0] = q[0] / qLength; |
| 623 |
|
q[1] = q[1] / qLength; |
| 746 |
|
int j, myStatus; |
| 747 |
|
|
| 748 |
|
myStatus = 0; |
| 749 |
< |
for (j = 0; j < mpiSim->getNumberProcessors(); j++) { |
| 749 |
> |
for (j = 0; j < mpiSim->getNProcessors(); j++) { |
| 750 |
|
MPI_Send( &myStatus, 1, MPI_INT, j, |
| 751 |
|
TAKE_THIS_TAG_INT, MPI_COMM_WORLD); |
| 752 |
|
} |
| 762 |
|
MPI_Finalize(); |
| 763 |
|
exit (0); |
| 764 |
|
} |
| 765 |
< |
#endif |
| 765 |
> |
#endif |