--- trunk/OOPSE/libmdtools/DumpReader.cpp 2004/04/19 17:44:48 1119 +++ trunk/OOPSE/libmdtools/DumpReader.cpp 2004/06/11 17:16:21 1268 @@ -84,15 +84,10 @@ void DumpReader::scanFile( void ){ void DumpReader::scanFile( void ){ - int vectorSize; - int i, j, k; + int i, j; int lineNum = 0; char readBuffer[2000]; - char* foo; fpos_t *currPos; - double time; - - #ifdef IS_MPI if( worldRank == 0 ){ @@ -176,7 +171,8 @@ void DumpReader :: readSet( int whichFrame ){ void DumpReader :: readSet( int whichFrame ){ - int i, j; + int i; + unsigned int j; #ifdef IS_MPI int done, which_node, which_atom; // loop counter @@ -273,7 +269,9 @@ void DumpReader :: readSet( int whichFrame ){ int *MolToProcMap = mpiSim->getMolToProcMap(); int localIndex; int nCurObj; + int nitems; + nTotObjs = simnfo->getTotIntegrableObjects(); haveError = 0; if (worldRank == 0) { fsetpos(inFile, framePos[whichFrame]); @@ -286,12 +284,12 @@ void DumpReader :: readSet( int whichFrame ){ simError(); } - nTotObjs = atoi( read_buffer ); + nitems = atoi( read_buffer ); // Check to see that the number of integrable objects in the intial configuration file is the // same as declared in simBass. - if( nTotObjs != simnfo->getTotIntegrableObjects()){ + if( nTotObjs != nitems){ sprintf( painCave.errMsg, "DumpReadererror. %s n_atoms, %d, " "does not match the BASS file's n_atoms, %d.\n", @@ -325,7 +323,7 @@ void DumpReader :: readSet( int whichFrame ){ simError(); } - for (i=0 ; i < mpiSim->getTotNmol(); i++) { + for (i=0 ; i < mpiSim->getNMolGlobal(); i++) { which_node = MolToProcMap[i]; if(which_node == 0){ //molecules belong to master node @@ -354,7 +352,7 @@ void DumpReader :: readSet( int whichFrame ){ if(haveError) nodeZeroError(); - parseDumpLine(read_buffer, integrableObjects[i]); + parseDumpLine(read_buffer, integrableObjects[j]); } @@ -363,10 +361,10 @@ void DumpReader :: readSet( int whichFrame ){ else{ //molecule belongs to slave nodes - MPI_Recv(&nCurObj, 1, MPI_INT, 0, + MPI_Recv(&nCurObj, 1, MPI_INT, which_node, TAKE_THIS_TAG_INT, MPI_COMM_WORLD, &istatus); - for(j=0; j < integrableObjects.size(); j++){ + for(j=0; j < nCurObj; j++){ eof_test = fgets(read_buffer, sizeof(read_buffer), inFile); if(eof_test == NULL){ @@ -393,7 +391,17 @@ void DumpReader :: readSet( int whichFrame ){ } else{ //actions taken at slave nodes - for (i=0 ; i < mpiSim->getTotNmol(); i++) { + MPI_Bcast(read_buffer, BUFFERSIZE, MPI_CHAR, 0, MPI_COMM_WORLD); + + parseErr = parseCommentLine( read_buffer, simnfo); + + if( parseErr != NULL ){ + strcpy( painCave.errMsg, parseErr ); + haveError = 1; + simError(); + } + + for (i=0 ; i < mpiSim->getNMolGlobal(); i++) { which_node = MolToProcMap[i]; if(which_node == worldRank){ @@ -411,8 +419,8 @@ void DumpReader :: readSet( int whichFrame ){ nCurObj = integrableObjects.size(); - MPI_Recv(&nCurObj, 1, MPI_INT, 0, - TAKE_THIS_TAG_INT, MPI_COMM_WORLD, &istatus); + MPI_Send(&nCurObj, 1, MPI_INT, 0, + TAKE_THIS_TAG_INT, MPI_COMM_WORLD); for(j = 0; j < integrableObjects.size(); j++){ @@ -604,6 +612,12 @@ char* DumpReader::parseDumpLine(char* readLine, StuntD qSqr = (q[0] * q[0]) + (q[1] * q[1]) + (q[2] * q[2]) + (q[3] * q[3]); + if (fabs(qSqr) < 1e-6) { + sprintf(painCave.errMsg, + "initial quaternion error (q0^2 + q1^2 + q2^2 + q3^2 ~ 0).\n"); + return strdup(painCave.errMsg); + } + qLength = sqrt( qSqr ); q[0] = q[0] / qLength; q[1] = q[1] / qLength; @@ -732,7 +746,7 @@ void DumpReader::nodeZeroError( void ){ int j, myStatus; myStatus = 0; - for (j = 0; j < mpiSim->getNumberProcessors(); j++) { + for (j = 0; j < mpiSim->getNProcessors(); j++) { MPI_Send( &myStatus, 1, MPI_INT, j, TAKE_THIS_TAG_INT, MPI_COMM_WORLD); } @@ -748,4 +762,4 @@ void DumpReader::anonymousNodeDie( void ){ MPI_Finalize(); exit (0); } -#endif \ No newline at end of file +#endif