--- trunk/OOPSE/libmdtools/DumpWriter.cpp 2004/01/15 14:22:16 947 +++ trunk/OOPSE/libmdtools/DumpWriter.cpp 2004/01/16 21:51:51 951 @@ -28,7 +28,6 @@ DumpWriter::DumpWriter( SimInfo* the_entry_plug ){ if(worldRank == 0 ){ #endif // is_mpi - dumpFile.open(entry_plug->sampleName, ios::out | ios::trunc ); if( !dumpFile ){ @@ -92,11 +91,17 @@ void DumpWriter::sortByGlobalIndex(){ indexArray.clear(); - for(int i = 0; i < mpiSim->getMyNlocal();i++) + for(int i = 0; i < mpiSim->getMyNlocal();i++) indexArray.push_back(make_pair(i, atoms[i]->getGlobalIndex())); sort(indexArray.begin(), indexArray.end(), indexSortingCriterion); + + //for (int i = 0; i < mpiSim->getMyNlocal(); i++) { + // printf("node %d has global %d at local %d\n", worldRank, indexArray[i].second, indexArray[i].first); + //} + } + #endif void DumpWriter::writeDump(double currentTime){ @@ -105,6 +110,8 @@ void DumpWriter::writeDump(double currentTime){ vector fileStreams; #ifdef IS_MPI + printf("Hello from node %d\n", worldRank); + sortByGlobalIndex(); if(worldRank == 0 ){ finalOut.open( entry_plug->finalName, ios::out | ios::trunc ); @@ -136,6 +143,7 @@ void DumpWriter::writeFinal(double currentTime){ #ifdef IS_MPI if(worldRank == 0 ){ +#endif // is_mpi finalOut.open( entry_plug->finalName, ios::out | ios::trunc ); @@ -147,6 +155,7 @@ void DumpWriter::writeFinal(double currentTime){ simError(); } +#ifdef IS_MPI } #endif // is_mpi @@ -385,17 +394,25 @@ void DumpWriter::writeFrame( vector& outFil } else { haveError = 0; - which_atom = i; + which_atom = i; - local_index = indexArray[currentIndex].first; - - if (which_atom == indexArray[currentIndex].second) { - - atomTypeString = atoms[local_index]->getType(); + //local_index = -1; - atoms[local_index]->getPos(pos); - atoms[local_index]->getVel(vel); - + //for (j=0; (jgetMyNlocal()) && (local_index < 0); j++) { + // if (atoms[j]->getGlobalIndex() == which_atom) local_index = j; + //} + + //if (local_index != -1) { + + local_index = indexArray[currentIndex].first; + + if (which_atom == indexArray[currentIndex].second) { + + atomTypeString = atoms[local_index]->getType(); + + atoms[local_index]->getPos(pos); + atoms[local_index]->getVel(vel); + atomData6[0] = pos[0]; atomData6[1] = pos[1]; atomData6[2] = pos[2]; @@ -427,51 +444,51 @@ void DumpWriter::writeFrame( vector& outFil } } else { - sprintf(painCave.errMsg, - "Atom %d not found on processor %d\n", - i, worldRank ); - haveError= 1; - simError(); - } + sprintf(painCave.errMsg, + "Atom %d not found on processor %d, currentIndex = %d, local_index = %d\n", + which_atom, worldRank, currentIndex, local_index ); + haveError= 1; + simError(); + } if(haveError) DieDieDie(); - currentIndex ++; + currentIndex++; } // If we've survived to here, format the line: if (!isDirectional) { sprintf( writeLine, - "%s\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t", - atomTypeString, - atomData6[0], - atomData6[1], - atomData6[2], - atomData6[3], - atomData6[4], - atomData6[5]); - - strcat( writeLine, "0.0\t0.0\t0.0\t0.0\t0.0\t0.0\t0.0\n" ); + "%s\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t", + atomTypeString, + atomData6[0], + atomData6[1], + atomData6[2], + atomData6[3], + atomData6[4], + atomData6[5]); + strcat( writeLine, "0.0\t0.0\t0.0\t0.0\t0.0\t0.0\t0.0\n" ); + } else { - sprintf( writeLine, - "%s\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\n", - atomTypeString, - atomData13[0], - atomData13[1], - atomData13[2], - atomData13[3], - atomData13[4], - atomData13[5], - atomData13[6], - atomData13[7], - atomData13[8], - atomData13[9], - atomData13[10], - atomData13[11], - atomData13[12]); + sprintf( writeLine, + "%s\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\n", + atomTypeString, + atomData13[0], + atomData13[1], + atomData13[2], + atomData13[3], + atomData13[4], + atomData13[5], + atomData13[6], + atomData13[7], + atomData13[8], + atomData13[9], + atomData13[10], + atomData13[11], + atomData13[12]); } @@ -484,11 +501,11 @@ void DumpWriter::writeFrame( vector& outFil sprintf( checkPointMsg, "Sucessfully took a dump.\n"); - + MPIcheckPoint(); - + delete[] potatoes; - + } else { // worldRank != 0, so I'm a remote node. @@ -505,24 +522,33 @@ void DumpWriter::writeFrame( vector& outFil if (AtomToProcMap[i] == worldRank) { if (myPotato + 3 >= MAXTAG) { - + // The potato was going to exceed the maximum value, // so wrap this processor potato back to 0 (and block until // node 0 says we can go: - + MPI_Recv(&myPotato, 1, MPI_INT, 0, 0, MPI_COMM_WORLD, &istatus); } which_atom = i; - local_index = indexArray[currentIndex].first; + + //local_index = -1; + + //for (j=0; (jgetMyNlocal()) && (local_index < 0); j++) { + // if (atoms[j]->getGlobalIndex() == which_atom) local_index = j; + //} + + //if (local_index != -1) { + + local_index = indexArray[currentIndex].first; - if (which_atom == indexArray[currentIndex].second) { + if (which_atom == indexArray[currentIndex].second) { atomTypeString = atoms[local_index]->getType(); - - atoms[local_index]->getPos(pos); - atoms[local_index]->getVel(vel); - + + atoms[local_index]->getPos(pos); + atoms[local_index]->getVel(vel); + atomData6[0] = pos[0]; atomData6[1] = pos[1]; atomData6[2] = pos[2]; @@ -554,13 +580,13 @@ void DumpWriter::writeFrame( vector& outFil } } else { - sprintf(painCave.errMsg, - "Atom %d not found on processor %d\n", - i, worldRank ); - haveError= 1; - simError(); - } - + sprintf(painCave.errMsg, + "Atom %d not found on processor %d, currentIndex = %d, local_index = %d\n", + which_atom, worldRank, currentIndex, local_index ); + haveError= 1; + simError(); + } + strncpy(MPIatomTypeString, atomTypeString, MINIBUFFERSIZE); // null terminate the string before sending (just in case):