--- trunk/OOPSE/libmdtools/DumpWriter.cpp 2004/04/22 03:29:30 1129 +++ trunk/OOPSE/libmdtools/DumpWriter.cpp 2004/06/03 21:06:51 1231 @@ -216,12 +216,12 @@ void DumpWriter::writeFrame( vector& outFil int nProc; int j, which_node, done, which_atom, local_index, currentIndex; - double atomData6[6]; - double atomData13[13]; + double atomData[13]; int isDirectional; char* atomTypeString; char MPIatomTypeString[MINIBUFFERSIZE]; int nObjects; + int msgLen; // the length of message actually recieved at master nodes #endif //is_mpi double q[4], ji[3]; @@ -294,11 +294,11 @@ void DumpWriter::writeFrame( vector& outFil } else strcat( writeLine, "0.0\t0.0\t0.0\t0.0\t0.0\t0.0\t0.0\n" ); + + for(k = 0; k < outFile.size(); k++) + *outFile[k] << writeLine; } - - for(k = 0; k < outFile.size(); k++) - *outFile[k] << writeLine; } #else // is_mpi @@ -325,7 +325,7 @@ void DumpWriter::writeFrame( vector& outFil // Node 0 needs a list of the magic potatoes for each processor; - nProc = mpiSim->getNumberProcessors(); + nProc = mpiSim->getNProcessors(); potatoes = new int[nProc]; //write out the comment lines @@ -353,7 +353,7 @@ void DumpWriter::writeFrame( vector& outFil currentIndex = 0; - for (i = 0 ; i < mpiSim->getTotNmol(); i++ ) { + for (i = 0 ; i < mpiSim->getNMolGlobal(); i++ ) { // Get the Node number which has this atom; @@ -379,7 +379,7 @@ void DumpWriter::writeFrame( vector& outFil for(int l = 0; l < nCurObj; l++){ - if (potatoes[which_node] + 3 >= MAXTAG) { + if (potatoes[which_node] + 2 >= MAXTAG) { // The potato was going to exceed the maximum value, // so wrap this processor potato back to 0: @@ -395,24 +395,62 @@ void DumpWriter::writeFrame( vector& outFil myPotato++; - MPI_Recv(&isDirectional, 1, MPI_INT, which_node, - myPotato, MPI_COMM_WORLD, &istatus); - + MPI_Recv(atomData, 13, MPI_DOUBLE, which_node, myPotato, MPI_COMM_WORLD, &istatus); myPotato++; - if (isDirectional) { - MPI_Recv(atomData13, 13, MPI_DOUBLE, which_node, - myPotato, MPI_COMM_WORLD, &istatus); - } else { - MPI_Recv(atomData6, 6, MPI_DOUBLE, which_node, - myPotato, MPI_COMM_WORLD, &istatus); + MPI_Get_count(&istatus, MPI_DOUBLE, &msgLen); + + if(msgLen == 13) + isDirectional = 1; + else + isDirectional = 0; + + // 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, + atomData[0], + atomData[1], + atomData[2], + atomData[3], + atomData[4], + atomData[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, + atomData[0], + atomData[1], + atomData[2], + atomData[3], + atomData[4], + atomData[5], + atomData[6], + atomData[7], + atomData[8], + atomData[9], + atomData[10], + atomData[11], + atomData[12]); + } + + for(k = 0; k < outFile.size(); k++) + *outFile[k] << writeLine; - myPotato++; - } + }// end for(int l =0) potatoes[which_node] = myPotato; - } else { + } + else { haveError = 0; @@ -427,13 +465,13 @@ void DumpWriter::writeFrame( vector& outFil sd->getPos(pos); sd->getVel(vel); - atomData6[0] = pos[0]; - atomData6[1] = pos[1]; - atomData6[2] = pos[2]; + atomData[0] = pos[0]; + atomData[1] = pos[1]; + atomData[2] = pos[2]; - atomData6[3] = vel[0]; - atomData6[4] = vel[1]; - atomData6[5] = vel[2]; + atomData[3] = vel[0]; + atomData[4] = vel[1]; + atomData[5] = vel[2]; isDirectional = 0; @@ -445,62 +483,66 @@ void DumpWriter::writeFrame( vector& outFil sd->getJ( ji ); for (int j = 0; j < 6 ; j++) - atomData13[j] = atomData6[j]; + atomData[j] = atomData[j]; - atomData13[6] = q[0]; - atomData13[7] = q[1]; - atomData13[8] = q[2]; - atomData13[9] = q[3]; + atomData[6] = q[0]; + atomData[7] = q[1]; + atomData[8] = q[2]; + atomData[9] = q[3]; - atomData13[10] = ji[0]; - atomData13[11] = ji[1]; - atomData13[12] = ji[2]; + atomData[10] = ji[0]; + atomData[11] = ji[1]; + atomData[12] = ji[2]; } - } + // 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, + atomData[0], + atomData[1], + atomData[2], + atomData[3], + atomData[4], + atomData[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, + atomData[0], + atomData[1], + atomData[2], + atomData[3], + atomData[4], + atomData[5], + atomData[6], + atomData[7], + atomData[8], + atomData[9], + atomData[10], + atomData[11], + atomData[12]); + + } + + for(k = 0; k < outFile.size(); k++) + *outFile[k] << writeLine; + + + }//end for(iter = integrableObject.begin()) 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" ); - - } 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]); - - } - - for(k = 0; k < outFile.size(); k++) - *outFile[k] << writeLine; - } + + }//end for(i = 0; i < mpiSim->getNmol()) for(k = 0; k < outFile.size(); k++) outFile[k]->flush(); @@ -521,7 +563,7 @@ void DumpWriter::writeFrame( vector& outFil myPotato = 0; currentIndex = 0; - for (i = 0 ; i < mpiSim->getTotNmol(); i++ ) { + for (i = 0 ; i < mpiSim->getNMolGlobal(); i++ ) { // Am I the node which has this integrableObject? @@ -549,7 +591,7 @@ void DumpWriter::writeFrame( vector& outFil for( iter = integrableObjects.begin(); iter != integrableObjects.end(); iter++){ - if (myPotato + 3 >= MAXTAG) { + if (myPotato + 2 >= MAXTAG) { // The potato was going to exceed the maximum value, // so wrap this processor potato back to 0 (and block until @@ -566,13 +608,13 @@ void DumpWriter::writeFrame( vector& outFil sd->getPos(pos); sd->getVel(vel); - atomData6[0] = pos[0]; - atomData6[1] = pos[1]; - atomData6[2] = pos[2]; + atomData[0] = pos[0]; + atomData[1] = pos[1]; + atomData[2] = pos[2]; - atomData6[3] = vel[0]; - atomData6[4] = vel[1]; - atomData6[5] = vel[2]; + atomData[3] = vel[0]; + atomData[4] = vel[1]; + atomData[5] = vel[2]; isDirectional = 0; @@ -583,17 +625,15 @@ void DumpWriter::writeFrame( vector& outFil sd->getQ( q ); sd->getJ( ji ); - for (int j = 0; j < 6 ; j++) - atomData13[j] = atomData6[j]; - atomData13[6] = q[0]; - atomData13[7] = q[1]; - atomData13[8] = q[2]; - atomData13[9] = q[3]; + atomData[6] = q[0]; + atomData[7] = q[1]; + atomData[8] = q[2]; + atomData[9] = q[3]; - atomData13[10] = ji[0]; - atomData13[11] = ji[1]; - atomData13[12] = ji[2]; + atomData[10] = ji[0]; + atomData[11] = ji[1]; + atomData[12] = ji[2]; } @@ -606,20 +646,15 @@ void DumpWriter::writeFrame( vector& outFil myPotato, MPI_COMM_WORLD); myPotato++; - - MPI_Send(&isDirectional, 1, MPI_INT, 0, - myPotato, MPI_COMM_WORLD); - myPotato++; - if (isDirectional) { - MPI_Send(atomData13, 13, MPI_DOUBLE, 0, + MPI_Send(atomData, 13, MPI_DOUBLE, 0, myPotato, MPI_COMM_WORLD); } else { - MPI_Send(atomData6, 6, MPI_DOUBLE, 0, + MPI_Send(atomData, 6, MPI_DOUBLE, 0, myPotato, MPI_COMM_WORLD); }