--- trunk/OOPSE/libmdtools/DumpWriter.cpp 2004/01/08 18:05:37 910 +++ trunk/OOPSE/libmdtools/DumpWriter.cpp 2004/01/08 22:25:52 913 @@ -66,7 +66,7 @@ void DumpWriter::writeDump( double currentTime ){ void DumpWriter::writeDump( double currentTime ){ const int BUFFERSIZE = 2000; - const int MINIBUFFERSIZE = 10; + const int MINIBUFFERSIZE = 100; char tempBuffer[BUFFERSIZE]; char writeLine[BUFFERSIZE]; @@ -158,10 +158,15 @@ void DumpWriter::writeDump( double currentTime ){ #else // is_mpi - // first thing first, suspend fatalities. - painCave.isEventLoop = 1; + /* code to find maximum tag value */ + int *tagub, flag, MAXTAG; + MPI_Attr_get(MPI_COMM_WORLD, MPI_TAG_UB, &tagub, &flag); + if (flag) { + MAXTAG = *tagub; + } else { + MAXTAG = 32767; + } - int myStatus; // 1 = wakeup & success; 0 = error; -1 = AllDone int haveError; MPI_Status istatus; @@ -188,23 +193,33 @@ void DumpWriter::writeDump( double currentTime ){ outFile << entry_plug->the_integrator->getAdditionalParameters(); outFile << endl; outFile.flush(); + + tag = 0; + for (i = 0 ; i < mpiSim->getTotAtoms(); i++ ) { - // Get the Node number which has this atom; + if (tag + 2 >= MAXTAG) { + // The tag was going to exceed the maximum value, so wrap around to 0: + tag = 0; + // Send the newly zeroed tag on to the other nodes: + MPI_Bcast(&tag, 1, MPI_INT, 0, MPI_COMM_WORLD); + } + + // Get the Node number which has this atom; + which_node = AtomToProcMap[i]; - + if (which_node != 0) { - atomTypeTag = 4*i; - atomIsDirectionalTag = 4*i + 1; - atomTransDataTag = 4*i + 2; - atomOrientDataTag = 4*i + 3; - MPI_Recv(MPIatomTypeString, MINIBUFFERSIZE, MPI_CHAR, which_node, atomTypeTag, MPI_COMM_WORLD, &istatus); strncpy(atomTypeString, MPIatomTypeString, MINIBUFFERSIZE); + + // Null terminate the atomTypeString just in case: + atomTypeString[strlen(atomTypeString) - 1] = '\0'; + MPI_Recv(&isDirectional, 1, MPI_INT, which_node, atomIsDirectionalTag, MPI_COMM_WORLD, &istatus); @@ -379,6 +394,9 @@ void DumpWriter::writeDump( double currentTime ){ strncpy(MPIatomTypeString, atomTypeString, MINIBUFFERSIZE); + // null terminate the string before sending (just in case): + MPIatomTypeString[MINIBUFFERSIZE-1] = '\0'; + MPI_Send(MPIatomTypeString, MINIBUFFERSIZE, MPI_CHAR, 0, atomTypeTag, MPI_COMM_WORLD); @@ -415,7 +433,7 @@ void DumpWriter::writeFinal(double finalTime){ ofstream finalOut; const int BUFFERSIZE = 2000; - const int MINIBUFFERSIZE = 10; + const int MINIBUFFERSIZE = 100; char tempBuffer[BUFFERSIZE]; char writeLine[BUFFERSIZE];