--- trunk/OOPSE/libmdtools/DumpWriter.cpp 2004/01/15 14:22:16 947 +++ trunk/OOPSE/libmdtools/DumpWriter.cpp 2004/04/12 20:32:20 1097 @@ -1,3 +1,4 @@ +#define _LARGEFILE_SOURCE64 #define _FILE_OFFSET_BITS 64 #include @@ -28,7 +29,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 +92,12 @@ 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); } + #endif void DumpWriter::writeDump(double currentTime){ @@ -106,7 +107,7 @@ void DumpWriter::writeDump(double currentTime){ #ifdef IS_MPI if(worldRank == 0 ){ - +#endif finalOut.open( entry_plug->finalName, ios::out | ios::trunc ); if( !finalOut ){ sprintf( painCave.errMsg, @@ -115,6 +116,7 @@ void DumpWriter::writeDump(double currentTime){ painCave.isFatal = 1; simError(); } +#ifdef IS_MPI } #endif // is_mpi @@ -136,6 +138,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 +150,7 @@ void DumpWriter::writeFinal(double currentTime){ simError(); } +#ifdef IS_MPI } #endif // is_mpi @@ -223,7 +227,7 @@ void DumpWriter::writeFrame( vector& outFil int nAtoms = entry_plug->n_atoms; #endif //is_mpi - double q[4]; + double q[4], ji[3]; DirectionalAtom* dAtom; Atom** atoms = entry_plug->atoms; double pos[3], vel[3]; @@ -270,6 +274,7 @@ void DumpWriter::writeFrame( vector& outFil dAtom = (DirectionalAtom *)atoms[i]; dAtom->getQ( q ); + dAtom->getJ( ji ); sprintf( tempBuffer, "%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\n", @@ -277,9 +282,9 @@ void DumpWriter::writeFrame( vector& outFil q[1], q[2], q[3], - dAtom->getJx(), - dAtom->getJy(), - dAtom->getJz()); + ji[0], + ji[1], + ji[2]); strcat( writeLine, tempBuffer ); } else @@ -385,17 +390,17 @@ 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) { + local_index = indexArray[currentIndex].first; - atomTypeString = atoms[local_index]->getType(); - - atoms[local_index]->getPos(pos); - atoms[local_index]->getVel(vel); - + 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]; @@ -412,6 +417,7 @@ void DumpWriter::writeFrame( vector& outFil dAtom = (DirectionalAtom *)atoms[local_index]; dAtom->getQ( q ); + dAtom->getJ( ji ); for (int j = 0; j < 6 ; j++) atomData13[j] = atomData6[j]; @@ -421,57 +427,57 @@ void DumpWriter::writeFrame( vector& outFil atomData13[8] = q[2]; atomData13[9] = q[3]; - atomData13[10] = dAtom->getJx(); - atomData13[11] = dAtom->getJy(); - atomData13[12] = dAtom->getJz(); + atomData13[10] = ji[0]; + atomData13[11] = ji[1]; + atomData13[12] = ji[2]; } } 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 +490,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 +511,25 @@ 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 = 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]; @@ -539,6 +546,7 @@ void DumpWriter::writeFrame( vector& outFil dAtom = (DirectionalAtom *)atoms[local_index]; dAtom->getQ( q ); + dAtom->getJ( ji ); for (int j = 0; j < 6 ; j++) atomData13[j] = atomData6[j]; @@ -548,19 +556,19 @@ void DumpWriter::writeFrame( vector& outFil atomData13[8] = q[2]; atomData13[9] = q[3]; - atomData13[10] = dAtom->getJx(); - atomData13[11] = dAtom->getJy(); - atomData13[12] = dAtom->getJz(); + atomData13[10] = ji[0]; + atomData13[11] = ji[1]; + atomData13[12] = ji[2]; } } 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):