--- trunk/OOPSE/libmdtools/DumpWriter.cpp 2003/03/27 01:49:45 417 +++ trunk/OOPSE/libmdtools/DumpWriter.cpp 2003/03/27 15:07:29 419 @@ -65,7 +65,7 @@ void DumpWriter::writeDump( double currentTime ){ char tempBuffer[BUFFERSIZE]; char writeLine[BUFFERSIZE]; - int i, j, which_node, done, game_over, which_atom; + int i, j, which_node, done, game_over, which_atom, local_index; double q[4]; DirectionalAtom* dAtom; int nAtoms = entry_plug->n_atoms; @@ -191,46 +191,55 @@ void DumpWriter::writeDump( double currentTime ){ done = 0; while (!done) { MPI::COMM_WORLD.Recv(&which_atom, 1, MPI_INT, 0, - TAKE_THIS_TAG, istatus); - + TAKE_THIS_TAG, istatus); + if (which_atom == -1) { done=1; continue; } else { - - //format the line - sprintf( tempBuffer, - "%s\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t", - atoms[which_atom]->getType(), - atoms[which_atom]->getX(), - atoms[which_atom]->getY(), - atoms[which_atom]->getZ(), - atoms[which_atom]->get_vx(), - atoms[which_atom]->get_vy(), - atoms[which_atom]->get_vz()); // check here. - strcpy( writeLine, tempBuffer ); + local_index=-1; + for (j=0; j < mpiSim->getMyNlocal(); j++) { + if (atoms[j]->getGlobalIndex() == which_atom) local_index = j; + } + if (local_index != -1) { + //format the line + sprintf( tempBuffer, + "%s\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t", + atoms[local_index]->getType(), + atoms[local_index]->getX(), + atoms[local_index]->getY(), + atoms[local_index]->getZ(), + atoms[local_index]->get_vx(), + atoms[local_index]->get_vy(), + atoms[local_index]->get_vz()); // check here. + strcpy( writeLine, tempBuffer ); - if( atoms[which_atom]->isDirectional() ){ - - dAtom = (DirectionalAtom *)atoms[which_atom]; - dAtom->getQ( q ); - - sprintf( tempBuffer, - "%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\n", - q[0], - q[1], - q[2], - q[3], - dAtom->getJx(), - dAtom->getJy(), - dAtom->getJz()); - strcat( writeLine, tempBuffer ); - } - else - strcat( writeLine, "0.0\t0.0\t0.0\t0.0\t0.0\t0.0\t0.0\n" ); - - MPI::COMM_WORLD.Send(writeLine, BUFFERSIZE, MPI_CHAR, 0, - TAKE_THIS_TAG); + if( atoms[local_index]->isDirectional() ){ + + dAtom = (DirectionalAtom *)atoms[local_index]; + dAtom->getQ( q ); + + sprintf( tempBuffer, + "%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\n", + q[0], + q[1], + q[2], + q[3], + dAtom->getJx(), + dAtom->getJy(), + dAtom->getJz()); + strcat( writeLine, tempBuffer ); + } + else + strcat( writeLine, "0.0\t0.0\t0.0\t0.0\t0.0\t0.0\t0.0\n" ); + + MPI::COMM_WORLD.Send(writeLine, BUFFERSIZE, MPI_CHAR, 0, + TAKE_THIS_TAG); + } else { + strcpy( writeLine, "ATOM NOT FOUND ON THIS PROCESSOR"); + MPI::COMM_WORLD.Send(writeLine, BUFFERSIZE, MPI_CHAR, 0, + TAKE_THIS_TAG); + } } } } @@ -254,7 +263,7 @@ void DumpWriter::writeFinal(){ DirectionalAtom* dAtom; int nAtoms = entry_plug->n_atoms; Atom** atoms = entry_plug->atoms; - int i, j, which_node, done, game_over, which_atom; + int i, j, which_node, done, game_over, which_atom, local_index; #ifdef IS_MPI @@ -407,42 +416,53 @@ void DumpWriter::writeFinal(){ continue; } else { - //format the line - sprintf( tempBuffer, - "%s\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t", - atoms[which_atom]->getType(), - atoms[which_atom]->getX(), - atoms[which_atom]->getY(), - atoms[which_atom]->getZ(), - atoms[which_atom]->get_vx(), - atoms[which_atom]->get_vy(), - atoms[which_atom]->get_vz()); // check here. - strcpy( writeLine, tempBuffer ); + local_index=-1; + for (j=0; j < mpiSim->getMyNlocal(); j++) { + if (atoms[j]->getGlobalIndex() == which_atom) local_index = j; + } + if (local_index != -1) { + + //format the line + sprintf( tempBuffer, + "%s\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t", + atoms[local_index]->getType(), + atoms[local_index]->getX(), + atoms[local_index]->getY(), + atoms[local_index]->getZ(), + atoms[local_index]->get_vx(), + atoms[local_index]->get_vy(), + atoms[local_index]->get_vz()); // check here. + strcpy( writeLine, tempBuffer ); - if( atoms[which_atom]->isDirectional() ){ + if( atoms[local_index]->isDirectional() ){ + + dAtom = (DirectionalAtom *)atoms[local_index]; + dAtom->getQ( q ); - dAtom = (DirectionalAtom *)atoms[which_atom]; - dAtom->getQ( q ); - - sprintf( tempBuffer, - "%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\n", - q[0], - q[1], - q[2], - q[3], - dAtom->getJx(), - dAtom->getJy(), - dAtom->getJz()); - strcat( writeLine, tempBuffer ); - } - else - strcat( writeLine, "0.0\t0.0\t0.0\t0.0\t0.0\t0.0\t0.0\n" ); - - MPI::COMM_WORLD.Send(writeLine, BUFFERSIZE, MPI_CHAR, 0, - TAKE_THIS_TAG); + sprintf( tempBuffer, + "%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\n", + q[0], + q[1], + q[2], + q[3], + dAtom->getJx(), + dAtom->getJy(), + dAtom->getJz()); + strcat( writeLine, tempBuffer ); + } + else + strcat( writeLine, "0.0\t0.0\t0.0\t0.0\t0.0\t0.0\t0.0\n" ); + + MPI::COMM_WORLD.Send(writeLine, BUFFERSIZE, MPI_CHAR, 0, + TAKE_THIS_TAG); + } else { + strcpy( writeLine, "ATOM NOT FOUND ON THIS PROCESSOR"); + MPI::COMM_WORLD.Send(writeLine, BUFFERSIZE, MPI_CHAR, 0, + TAKE_THIS_TAG); + } } } - } + } finalOut.flush(); sprintf( checkPointMsg, "Sucessfully took a dump.\n");