--- trunk/mdtools/md_code/DumpWriter.cpp 2002/12/16 21:42:14 214 +++ trunk/mdtools/md_code/DumpWriter.cpp 2003/01/30 20:03:37 254 @@ -1,12 +1,19 @@ #include #include #include + +#ifdef IS_MPI #include +#include "mpiSimulation.hpp" +#endif //is_mpi #include "ReadWrite.hpp" #include "simError.h" + + + DumpWriter::DumpWriter( SimInfo* the_entry_plug ){ #ifdef IS_MPI @@ -123,7 +130,7 @@ void DumpWriter::writeDump( double currentTime ){ // write out header and node 0's coordinates if( worldRank == 0 ){ - outFile << entry_plug->mpiSim->getTotAtoms() << "\n"; + outFile << mpiSim->getTotAtoms() << "\n"; outFile << currentTime << "\t" << entry_plug->box_x << "\t" @@ -163,13 +170,13 @@ void DumpWriter::writeDump( double currentTime ){ else strcat( writeLine, "0.0\t0.0\t0.0\t0.0\t0.0\t0.0\t0.0\n" ); - outfile << writeLine; + outFile << writeLine; masterIndex++; } outFile.flush(); } - for (procIndex = 1; procIndex < entry_plug->mpiSim->getNumberProcessors(); + for (procIndex = 1; procIndex < mpiSim->getNumberProcessors(); procIndex++){ if( worldRank == 0 ){ @@ -201,9 +208,9 @@ void DumpWriter::writeDump( double currentTime ){ // recieve the nodes writeLines - for ( i = nodeAtomStart; i <= nodeAtomEnd, i++){ + for ( i = nodeAtomsStart; i <= nodeAtomsEnd; i++){ - mpiErr = MPI_Recv(&read_buffer,BUFFERSIZE,MPI_CHAR,procIndex, + mpiErr = MPI_Recv(writeLine,BUFFERSIZE,MPI_CHAR,procIndex, MPI_ANY_TAG,MPI_COMM_WORLD,istatus ); outFile << writeLine; @@ -213,8 +220,8 @@ void DumpWriter::writeDump( double currentTime ){ else if( worldRank == procIndex ){ - nodeAtomStart = entry_plug->mpiSim->getMyAtomStart(); - nodeAtomEnd = entry_plug->mpiSim->getMyAtomEnd(); + nodeAtomsStart = mpiSim->getMyAtomStart(); + nodeAtomsEnd = mpiSim->getMyAtomEnd(); mpiErr = MPI_Send(&nodeAtomsStart,1,MPI_INT,0,MPI_ANY_TAG, MPI_COMM_WORLD); @@ -223,7 +230,7 @@ void DumpWriter::writeDump( double currentTime ){ mpiErr = MPI_Recv(&sendError,1,MPI_INT,0,MPI_ANY_TAG, MPI_COMM_WORLD, istatus); - if (sendError) mpiCheckpoint(); + if (sendError) MPIcheckPoint(); // send current node's configuration line by line. @@ -266,7 +273,7 @@ void DumpWriter::writeDump( double currentTime ){ sprintf(checkPointMsg,"Node %d sent dump configuration.", procIndex); - mpiCheckPoint(); + MPIcheckPoint(); } #endif // is_mpi @@ -311,8 +318,8 @@ void DumpWriter::writeFinal(){ #ifdef IS_MPI } - sprintf(checkPointMsg,"Opened file for final configuration\n",procIndex); - mpiCheckPoint(); + sprintf(checkPointMsg,"Opened file for final configuration\n"); + MPIcheckPoint(); #endif //is_mpi @@ -322,10 +329,9 @@ void DumpWriter::writeFinal(){ finalOut << nAtoms << "\n"; - finalOut << currentTime << "\t" - << entry_plug->box_x << "\t" - << entry_plug->box_y << "\t" - << entry_plug->box_z << "\n"; + finalOut << entry_plug->box_x << "\t" + << entry_plug->box_y << "\t" + << entry_plug->box_z << "\n"; for( i=0; impiSim->getTotAtoms() << "\n"; + finalOut << mpiSim->getTotAtoms() << "\n"; - finalOut << currentTime << "\t" - << entry_plug->box_x << "\t" - << entry_plug->box_y << "\t" - << entry_plug->box_z << "\n"; - + finalOut << entry_plug->box_x << "\t" + << entry_plug->box_y << "\t" + << entry_plug->box_z << "\n"; + masterIndex = 0; for( i=0; impiSim->getNumberProcessors(); + for (procIndex = 1; procIndex < mpiSim->getNumberProcessors(); procIndex++){ if( worldRank == 0 ){ @@ -456,9 +461,9 @@ void DumpWriter::writeFinal(){ // recieve the nodes writeLines - for ( i = nodeAtomStart; i <= nodeAtomEnd, i++){ + for ( i = nodeAtomsStart; i <= nodeAtomsEnd; i++){ - mpiErr = MPI_Recv(&read_buffer,BUFFERSIZE,MPI_CHAR,procIndex, + mpiErr = MPI_Recv(writeLine,BUFFERSIZE,MPI_CHAR,procIndex, MPI_ANY_TAG,MPI_COMM_WORLD,istatus ); finalOut << writeLine; @@ -470,8 +475,8 @@ void DumpWriter::writeFinal(){ else if( worldRank == procIndex ){ - nodeAtomStart = entry_plug->mpiSim->getMyAtomStart(); - nodeAtomEnd = entry_plug->mpiSim->getMyAtomEnd(); + nodeAtomsStart = mpiSim->getMyAtomStart(); + nodeAtomsEnd = mpiSim->getMyAtomEnd(); mpiErr = MPI_Send(&nodeAtomsStart,1,MPI_INT,0,MPI_ANY_TAG, MPI_COMM_WORLD); @@ -480,7 +485,7 @@ void DumpWriter::writeFinal(){ mpiErr = MPI_Recv(&sendError,1,MPI_INT,0,MPI_ANY_TAG, MPI_COMM_WORLD, istatus); - if (sendError) mpiCheckpoint(); + if (sendError) MPIcheckPoint(); // send current node's configuration line by line. @@ -523,7 +528,7 @@ void DumpWriter::writeFinal(){ sprintf(checkPointMsg,"Node %d sent dump configuration.", procIndex); - mpiCheckPoint(); + MPIcheckPoint(); } if( worldRank == 0 ) finalOut.close();