--- trunk/OOPSE/libmdtools/DumpWriter.cpp 2003/03/26 22:24:49 415 +++ trunk/OOPSE/libmdtools/DumpWriter.cpp 2003/03/26 23:14:02 416 @@ -4,6 +4,7 @@ #ifdef IS_MPI #include +#include #include "mpiSimulation.hpp" #define TAKE_THIS_TAG 0 #endif //is_mpi @@ -11,8 +12,6 @@ #include "ReadWrite.hpp" #include "simError.h" -#define GAME_OVER -1 - DumpWriter::DumpWriter( SimInfo* the_entry_plug ){ entry_plug = the_entry_plug; @@ -66,7 +65,7 @@ void DumpWriter::writeDump( double currentTime ){ char tempBuffer[BUFFERSIZE]; char writeLine[BUFFERSIZE]; - int i; + int i, j, which_node, done, game_over, which_atom; double q[4]; DirectionalAtom* dAtom; int nAtoms = entry_plug->n_atoms; @@ -120,9 +119,10 @@ void DumpWriter::writeDump( double currentTime ){ outFile.flush(); #else // is_mpi + + MPI::Status istatus; + int *AtomToProcMap = mpiSim->getAtomToProcMap(); - MPI_Status istatus[MPI_STATUS_SIZE]; - // write out header and node 0's coordinates if( worldRank == 0 ){ @@ -133,12 +133,12 @@ void DumpWriter::writeDump( double currentTime ){ << entry_plug->box_y << "\t" << entry_plug->box_z << "\n"; - for (i = 0 ; i < mpiPlug->nAtomsGlobal; i++ ) { + for (i = 0 ; i < mpiSim->getTotAtoms(); i++ ) { // Get the Node number which has this molecule: which_node = AtomToProcMap[i]; - if (which_node == mpiPlug->myNode) { + if (which_node == mpiSim->getMyNode()) { sprintf( tempBuffer, "%s\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t", @@ -173,7 +173,7 @@ void DumpWriter::writeDump( double currentTime ){ } else { MPI::COMM_WORLD.Send(&i, 1, MPI_INT, which_node, TAKE_THIS_TAG); - MPI::COMM_WORLD.Receive(writeLine, BUFFERSIZE, MPI_CHAR, which_node, + MPI::COMM_WORLD.Recv(writeLine, BUFFERSIZE, MPI_CHAR, which_node, TAKE_THIS_TAG, istatus); } @@ -181,18 +181,19 @@ void DumpWriter::writeDump( double currentTime ){ } // kill everyone off: - for (j = 0; j < mpiPlug->numberProcessors; j++) { - MPI::COMM_WORLD.Send(GAME_OVER, 1, MPI_INT, j, TAKE_THIS_TAG); + game_over = -1; + for (j = 0; j < mpiSim->getNumberProcessors(); j++) { + MPI::COMM_WORLD.Send(&game_over, 1, MPI_INT, j, TAKE_THIS_TAG); } } else { done = 0; while (!done) { - MPI::COMM_WORLD.Receive(&which_atom, 1, MPI_INT, 0, + MPI::COMM_WORLD.Recv(&which_atom, 1, MPI_INT, 0, TAKE_THIS_TAG, istatus); - if (which_atom == GAME_OVER) { + if (which_atom == -1) { done=1; continue; } else { @@ -241,10 +242,21 @@ void DumpWriter::writeFinal(){ } void DumpWriter::writeFinal(){ - + char finalName[500]; ofstream finalOut; + + const int BUFFERSIZE = 2000; + char tempBuffer[BUFFERSIZE]; + char writeLine[BUFFERSIZE]; + + double q[4]; + DirectionalAtom* dAtom; + int nAtoms = entry_plug->n_atoms; + Atom** atoms = entry_plug->atoms; + int i, j, which_node, done, game_over, which_atom; + #ifdef IS_MPI if(worldRank == 0 ){ #endif // is_mpi @@ -278,7 +290,7 @@ void DumpWriter::writeFinal(){ finalOut << entry_plug->box_x << "\t" << entry_plug->box_y << "\t" << entry_plug->box_z << "\n"; - + for( i=0; igetAtomToProcMap(); + // write out header and node 0's coordinates if( worldRank == 0 ){ @@ -329,12 +342,12 @@ void DumpWriter::writeFinal(){ << entry_plug->box_y << "\t" << entry_plug->box_z << "\n"; - for (i = 0 ; i < mpiPlug->nAtomsGlobal; i++ ) { + for (i = 0 ; i < mpiSim->getTotAtoms(); i++ ) { // Get the Node number which has this molecule: which_node = AtomToProcMap[i]; - if (which_node == mpiPlug->myNode) { + if (which_node == mpiSim->getMyNode()) { sprintf( tempBuffer, "%s\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t", @@ -369,7 +382,7 @@ void DumpWriter::writeFinal(){ } else { MPI::COMM_WORLD.Send(&i, 1, MPI_INT, which_node, TAKE_THIS_TAG); - MPI::COMM_WORLD.Receive(writeLine, BUFFERSIZE, MPI_CHAR, which_node, + MPI::COMM_WORLD.Recv(writeLine, BUFFERSIZE, MPI_CHAR, which_node, TAKE_THIS_TAG, istatus); } @@ -377,18 +390,19 @@ void DumpWriter::writeFinal(){ } // kill everyone off: - for (j = 0; j < mpiPlug->numberProcessors; j++) { - MPI::COMM_WORLD.Send(GAME_OVER, 1, MPI_INT, j, TAKE_THIS_TAG); + game_over = -1; + for (j = 0; j < mpiSim->getNumberProcessors(); j++) { + MPI::COMM_WORLD.Send(&game_over, 1, MPI_INT, j, TAKE_THIS_TAG); } } else { done = 0; while (!done) { - MPI::COMM_WORLD.Receive(&which_atom, 1, MPI_INT, 0, - TAKE_THIS_TAG, istatus); + MPI::COMM_WORLD.Recv(&which_atom, 1, MPI_INT, 0, + TAKE_THIS_TAG, istatus); - if (which_atom == GAME_OVER) { + if (which_atom == -1) { done=1; continue; } else {