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; |
91 |
|
|
95 |
– |
|
96 |
– |
|
92 |
|
#ifdef IS_MPI |
93 |
|
if( worldRank == 0 ){ |
94 |
|
#endif // is_mpi |
107 |
|
painCave.isFatal = 1; |
108 |
|
simError(); |
109 |
|
} |
115 |
– |
framePos.push_back(currPos); |
110 |
|
|
111 |
|
while( !feof( inFile ) ){ |
112 |
+ |
|
113 |
+ |
framePos.push_back(currPos); |
114 |
|
|
115 |
|
i = atoi(readBuffer); |
116 |
|
|
145 |
|
currPos = new fpos_t; |
146 |
|
fgetpos( inFile, currPos ); |
147 |
|
fgets( readBuffer, sizeof( readBuffer ), inFile ); |
152 |
– |
framePos.push_back(currPos); |
148 |
|
lineNum++; |
149 |
|
} |
150 |
|
|
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 |
194 |
|
eof_test = fgets(read_buffer, sizeof(read_buffer), inFile); |
195 |
|
if( eof_test == NULL ){ |
196 |
|
sprintf( painCave.errMsg, |
197 |
< |
"InitializeFromFile error: error reading 1st line of \"%s\"\n", |
197 |
> |
"DumpReader error: error reading 1st line of \"%s\"\n", |
198 |
|
inFileName.c_str() ); |
199 |
|
painCave.isFatal = 1; |
200 |
|
simError(); |
204 |
|
|
205 |
|
if( nTotObjs != simnfo->getTotIntegrableObjects() ){ |
206 |
|
sprintf( painCave.errMsg, |
207 |
< |
"Initialize from File error. %s n_atoms, %d, " |
207 |
> |
"DumpReader error. %s n_atoms, %d, " |
208 |
|
"does not match the BASS file's n_atoms, %d.\n", |
209 |
|
inFileName.c_str(), nTotObjs, simnfo->getTotIntegrableObjects()); |
210 |
|
painCave.isFatal = 1; |
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 |
< |
"Initialize from File error. %s n_atoms, %d, " |
294 |
> |
"DumpReadererror. %s n_atoms, %d, " |
295 |
|
"does not match the BASS file's n_atoms, %d.\n", |
296 |
|
inFileName.c_str(), nTotObjs, simnfo->getTotIntegrableObjects()); |
297 |
|
haveError= 1; |
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 |
|
|
464 |
|
|
465 |
|
if( strcmp( foo, sd->getType() ) ){ |
466 |
|
sprintf( painCave.errMsg, |
467 |
< |
"Initialize from file error. Does not" |
467 |
> |
"DumpReader error. Does not" |
468 |
|
" match the BASS atom %s.\n", |
469 |
|
sd->getType() ); |
470 |
|
return strdup( painCave.errMsg ); |
740 |
|
int j, myStatus; |
741 |
|
|
742 |
|
myStatus = 0; |
743 |
< |
for (j = 0; j < mpiSim->getNumberProcessors(); j++) { |
743 |
> |
for (j = 0; j < mpiSim->getNProcessors(); j++) { |
744 |
|
MPI_Send( &myStatus, 1, MPI_INT, j, |
745 |
|
TAKE_THIS_TAG_INT, MPI_COMM_WORLD); |
746 |
|
} |
756 |
|
MPI_Finalize(); |
757 |
|
exit (0); |
758 |
|
} |
759 |
< |
#endif |
759 |
> |
#endif |