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 1711 by gezelter, Sat May 19 02:58:35 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 138 | Line 141 | namespace OpenMD {
141      
142      needCompression_ = simParams->getCompressDumpFile();
143      needForceVector_ = simParams->getOutputForceVector();
144 +    needParticlePot_ = simParams->getOutputParticlePotential();
145      
146   #ifdef HAVE_LIBZ
147      if (needCompression_) {
# Line 306 | Line 310 | namespace OpenMD {
310      }
311      
312      const int masterNode = 0;
313 <
313 >    int nProc;
314 >    MPI_Comm_size(MPI_COMM_WORLD, &nProc);
315      if (worldRank == masterNode) {      
316        os << "  <Snapshot>\n";  
317        writeFrameProperties(os, info_->getSnapshotManager()->getCurrentSnapshot());
# Line 314 | Line 319 | namespace OpenMD {
319          
320        os << buffer;
321  
317      int nProc;
318      MPI_Comm_size(MPI_COMM_WORLD, &nProc);
322        for (int i = 1; i < nProc; ++i) {
323  
324          // receive the length of the string buffer that was
325          // prepared by processor i
326  
327 +        MPI_Bcast(&i, 1, MPI_INT,masterNode,MPI_COMM_WORLD);
328          int recvLength;
329          MPI_Recv(&recvLength, 1, MPI_INT, i, 0, MPI_COMM_WORLD, &istatus);
330          char* recvBuffer = new char[recvLength];
# Line 337 | Line 341 | namespace OpenMD {
341        os.flush();
342      } else {
343        int sendBufferLength = buffer.size() + 1;
344 <      MPI_Send(&sendBufferLength, 1, MPI_INT, masterNode, 0, MPI_COMM_WORLD);
345 <      MPI_Send((void *)buffer.c_str(), sendBufferLength, MPI_CHAR, masterNode, 0, MPI_COMM_WORLD);
344 >      int myturn = 0;
345 >      for (int i = 1; i < nProc; ++i){
346 >        MPI_Bcast(&myturn,1, MPI_INT,masterNode,MPI_COMM_WORLD);
347 >        if (myturn == worldRank){
348 >          MPI_Send(&sendBufferLength, 1, MPI_INT, masterNode, 0, MPI_COMM_WORLD);
349 >          MPI_Send((void *)buffer.c_str(), sendBufferLength, MPI_CHAR, masterNode, 0, MPI_COMM_WORLD);
350 >        }
351 >      }
352      }
353  
354   #endif // is_mpi
# Line 458 | Line 468 | namespace OpenMD {
468          line += tempBuffer;
469        }      
470      }
471 +    if (needParticlePot_) {
472 +      type += "u";
473 +      RealType particlePot;
474 +
475 +      particlePot = integrableObject->getParticlePot();
476 +
477 +      if (isinf(particlePot) || isnan(particlePot)) {      
478 +        sprintf( painCave.errMsg,
479 +                 "DumpWriter detected a numerical error writing the particle "
480 +                 " potential for object %d", index);      
481 +        painCave.isFatal = 1;
482 +        simError();
483 +      }
484 +      sprintf(tempBuffer, " %13e", particlePot);
485 +      line += tempBuffer;
486 +    }
487      
488      sprintf(tempBuffer, "%10d %7s %s\n", index, type.c_str(), line.c_str());
489      return std::string(tempBuffer);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines