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

Comparing branches/development/src/io/DumpWriter.cpp (file contents):
Revision 1465 by chuckv, Fri Jul 9 23:08:25 2010 UTC vs.
Revision 1712 by gezelter, Sat May 19 13:30:21 2012 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 +    cerr << "DW npp = " << needParticlePot_ << "\n";
66      createDumpFile_ = true;
67   #ifdef HAVE_LIBZ
68      if (needCompression_) {
# Line 99 | Line 102 | namespace OpenMD {
102  
103      needCompression_ = simParams->getCompressDumpFile();
104      needForceVector_ = simParams->getOutputForceVector();
105 +    needParticlePot_ = simParams->getOutputParticlePotential();
106      createDumpFile_ = true;
107   #ifdef HAVE_LIBZ
108      if (needCompression_) {
# Line 138 | Line 142 | namespace OpenMD {
142      
143      needCompression_ = simParams->getCompressDumpFile();
144      needForceVector_ = simParams->getOutputForceVector();
145 +    needParticlePot_ = simParams->getOutputParticlePotential();
146      
147   #ifdef HAVE_LIBZ
148      if (needCompression_) {
# Line 306 | Line 311 | namespace OpenMD {
311      }
312      
313      const int masterNode = 0;
314 <
314 >    int nProc;
315 >    MPI_Comm_size(MPI_COMM_WORLD, &nProc);
316      if (worldRank == masterNode) {      
317        os << "  <Snapshot>\n";  
318        writeFrameProperties(os, info_->getSnapshotManager()->getCurrentSnapshot());
# Line 314 | Line 320 | namespace OpenMD {
320          
321        os << buffer;
322  
317      int nProc;
318      MPI_Comm_size(MPI_COMM_WORLD, &nProc);
323        for (int i = 1; i < nProc; ++i) {
324  
325          // receive the length of the string buffer that was
326          // prepared by processor i
327  
328 +        MPI_Bcast(&i, 1, MPI_INT,masterNode,MPI_COMM_WORLD);
329          int recvLength;
330          MPI_Recv(&recvLength, 1, MPI_INT, i, 0, MPI_COMM_WORLD, &istatus);
331          char* recvBuffer = new char[recvLength];
# Line 337 | Line 342 | namespace OpenMD {
342        os.flush();
343      } else {
344        int sendBufferLength = buffer.size() + 1;
345 <      MPI_Send(&sendBufferLength, 1, MPI_INT, masterNode, 0, MPI_COMM_WORLD);
346 <      MPI_Send((void *)buffer.c_str(), sendBufferLength, MPI_CHAR, masterNode, 0, MPI_COMM_WORLD);
345 >      int myturn = 0;
346 >      for (int i = 1; i < nProc; ++i){
347 >        MPI_Bcast(&myturn,1, MPI_INT,masterNode,MPI_COMM_WORLD);
348 >        if (myturn == worldRank){
349 >          MPI_Send(&sendBufferLength, 1, MPI_INT, masterNode, 0, MPI_COMM_WORLD);
350 >          MPI_Send((void *)buffer.c_str(), sendBufferLength, MPI_CHAR, masterNode, 0, MPI_COMM_WORLD);
351 >        }
352 >      }
353      }
354  
355   #endif // is_mpi
# Line 458 | Line 469 | namespace OpenMD {
469          line += tempBuffer;
470        }      
471      }
472 +    if (needParticlePot_) {
473 +      type += "u";
474 +      RealType particlePot;
475 +
476 +      particlePot = integrableObject->getParticlePot();
477 +
478 +      if (isinf(particlePot) || isnan(particlePot)) {      
479 +        sprintf( painCave.errMsg,
480 +                 "DumpWriter detected a numerical error writing the particle "
481 +                 " potential for object %d", index);      
482 +        painCave.isFatal = 1;
483 +        simError();
484 +      }
485 +      sprintf(tempBuffer, " %13e", particlePot);
486 +      line += tempBuffer;
487 +    }
488      
489      sprintf(tempBuffer, "%10d %7s %s\n", index, type.c_str(), line.c_str());
490      return std::string(tempBuffer);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines