ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/branches/development/src/io/DumpWriter.cpp
(Generate patch)

Comparing:
trunk/src/io/DumpWriter.cpp (file contents), Revision 1442 by gezelter, Mon May 10 17:28:26 2010 UTC vs.
branches/development/src/io/DumpWriter.cpp (file contents), Revision 1665 by gezelter, Tue Nov 22 20:38:56 2011 UTC

# Line 36 | Line 36
36   * [1]  Meineke, et al., J. Comp. Chem. 26, 252-271 (2005).            
37   * [2]  Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006).          
38   * [3]  Sun, Lin & Gezelter, J. Chem. Phys. 128, 24107 (2008).          
39 < * [4]  Vardeman & Gezelter, in progress (2009).                        
39 > * [4]  Kuang & Gezelter,  J. Chem. Phys. 133, 164101 (2010).
40 > * [5]  Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011).
41   */
42  
43   #include "io/DumpWriter.hpp"
# Line 60 | Line 61 | namespace OpenMD {
61      Globals* simParams = info->getSimParams();
62      needCompression_ = simParams->getCompressDumpFile();
63      needForceVector_ = simParams->getOutputForceVector();
64 +    needParticlePot_ = simParams->getOutputParticlePotential();
65      createDumpFile_ = true;
66   #ifdef HAVE_LIBZ
67      if (needCompression_) {
# Line 138 | Line 140 | namespace OpenMD {
140      
141      needCompression_ = simParams->getCompressDumpFile();
142      needForceVector_ = simParams->getOutputForceVector();
143 +    needParticlePot_ = simParams->getOutputParticlePotential();
144      
145   #ifdef HAVE_LIBZ
146      if (needCompression_) {
# Line 306 | Line 309 | namespace OpenMD {
309      }
310      
311      const int masterNode = 0;
312 <
312 >    int nProc;
313 >    MPI_Comm_size(MPI_COMM_WORLD, &nProc);
314      if (worldRank == masterNode) {      
315        os << "  <Snapshot>\n";  
316        writeFrameProperties(os, info_->getSnapshotManager()->getCurrentSnapshot());
# Line 314 | Line 318 | namespace OpenMD {
318          
319        os << buffer;
320  
317      int nProc;
318      MPI_Comm_size(MPI_COMM_WORLD, &nProc);
321        for (int i = 1; i < nProc; ++i) {
322  
323          // receive the length of the string buffer that was
324          // prepared by processor i
325  
326 +        MPI_Bcast(&i, 1, MPI_INT,masterNode,MPI_COMM_WORLD);
327          int recvLength;
328          MPI_Recv(&recvLength, 1, MPI_INT, i, 0, MPI_COMM_WORLD, &istatus);
329          char* recvBuffer = new char[recvLength];
# Line 337 | Line 340 | namespace OpenMD {
340        os.flush();
341      } else {
342        int sendBufferLength = buffer.size() + 1;
343 <      MPI_Send(&sendBufferLength, 1, MPI_INT, masterNode, 0, MPI_COMM_WORLD);
344 <      MPI_Send((void *)buffer.c_str(), sendBufferLength, MPI_CHAR, masterNode, 0, MPI_COMM_WORLD);
343 >      int myturn = 0;
344 >      for (int i = 1; i < nProc; ++i){
345 >        MPI_Bcast(&myturn,1, MPI_INT,masterNode,MPI_COMM_WORLD);
346 >        if (myturn == worldRank){
347 >          MPI_Send(&sendBufferLength, 1, MPI_INT, masterNode, 0, MPI_COMM_WORLD);
348 >          MPI_Send((void *)buffer.c_str(), sendBufferLength, MPI_CHAR, masterNode, 0, MPI_COMM_WORLD);
349 >        }
350 >      }
351      }
352  
353   #endif // is_mpi
# Line 458 | Line 467 | namespace OpenMD {
467          line += tempBuffer;
468        }      
469      }
470 +    if (needParticlePot_) {
471 +      type += "u";
472 +      RealType particlePot;
473 +
474 +      particlePot = integrableObject->getParticlePot();
475 +
476 +      if (isinf(particlePot) || isnan(particlePot)) {      
477 +        sprintf( painCave.errMsg,
478 +                 "DumpWriter detected a numerical error writing the particle "
479 +                 " potential for object %d", index);      
480 +        painCave.isFatal = 1;
481 +        simError();
482 +      }
483 +      sprintf(tempBuffer, " %13e", particlePot);
484 +      line += tempBuffer;
485 +    }
486      
487      sprintf(tempBuffer, "%10d %7s %s\n", index, type.c_str(), line.c_str());
488      return std::string(tempBuffer);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines