--- trunk/src/io/DumpWriter.cpp 2010/05/10 17:28:26 1442 +++ branches/development/src/io/DumpWriter.cpp 2011/09/14 21:15:17 1629 @@ -60,6 +60,7 @@ namespace OpenMD { Globals* simParams = info->getSimParams(); needCompression_ = simParams->getCompressDumpFile(); needForceVector_ = simParams->getOutputForceVector(); + needParticlePot_ = simParams->getOutputParticlePotential(); createDumpFile_ = true; #ifdef HAVE_LIBZ if (needCompression_) { @@ -138,6 +139,7 @@ namespace OpenMD { needCompression_ = simParams->getCompressDumpFile(); needForceVector_ = simParams->getOutputForceVector(); + needParticlePot_ = simParams->getOutputParticlePotential(); #ifdef HAVE_LIBZ if (needCompression_) { @@ -306,7 +308,8 @@ namespace OpenMD { } const int masterNode = 0; - + int nProc; + MPI_Comm_size(MPI_COMM_WORLD, &nProc); if (worldRank == masterNode) { os << " \n"; writeFrameProperties(os, info_->getSnapshotManager()->getCurrentSnapshot()); @@ -314,13 +317,12 @@ namespace OpenMD { os << buffer; - int nProc; - MPI_Comm_size(MPI_COMM_WORLD, &nProc); for (int i = 1; i < nProc; ++i) { // receive the length of the string buffer that was // prepared by processor i + MPI_Bcast(&i, 1, MPI_INT,masterNode,MPI_COMM_WORLD); int recvLength; MPI_Recv(&recvLength, 1, MPI_INT, i, 0, MPI_COMM_WORLD, &istatus); char* recvBuffer = new char[recvLength]; @@ -337,8 +339,14 @@ namespace OpenMD { os.flush(); } else { int sendBufferLength = buffer.size() + 1; - MPI_Send(&sendBufferLength, 1, MPI_INT, masterNode, 0, MPI_COMM_WORLD); - MPI_Send((void *)buffer.c_str(), sendBufferLength, MPI_CHAR, masterNode, 0, MPI_COMM_WORLD); + int myturn = 0; + for (int i = 1; i < nProc; ++i){ + MPI_Bcast(&myturn,1, MPI_INT,masterNode,MPI_COMM_WORLD); + if (myturn == worldRank){ + MPI_Send(&sendBufferLength, 1, MPI_INT, masterNode, 0, MPI_COMM_WORLD); + MPI_Send((void *)buffer.c_str(), sendBufferLength, MPI_CHAR, masterNode, 0, MPI_COMM_WORLD); + } + } } #endif // is_mpi @@ -458,6 +466,22 @@ namespace OpenMD { line += tempBuffer; } } + if (needParticlePot_) { + type += "u"; + RealType particlePot; + + particlePot = integrableObject->getParticlePot(); + + if (isinf(particlePot) || isnan(particlePot)) { + sprintf( painCave.errMsg, + "DumpWriter detected a numerical error writing the particle " + " potential for object %d", index); + painCave.isFatal = 1; + simError(); + } + sprintf(tempBuffer, " %13e", particlePot); + line += tempBuffer; + } sprintf(tempBuffer, "%10d %7s %s\n", index, type.c_str(), line.c_str()); return std::string(tempBuffer);