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

Comparing trunk/src/io/DumpWriter.cpp (file contents):
Revision 1969 by gezelter, Wed Feb 26 14:14:50 2014 UTC vs.
Revision 2020 by gezelter, Mon Sep 22 19:18:35 2014 UTC

# Line 64 | Line 64 | namespace OpenMD {
64   namespace OpenMD {
65  
66    DumpWriter::DumpWriter(SimInfo* info)
67 <    : info_(info), filename_(info->getDumpFileName()), eorFilename_(info->getFinalConfigFileName()){
67 >    : info_(info), filename_(info->getDumpFileName()),
68 >      eorFilename_(info->getFinalConfigFileName()){
69  
70      Globals* simParams = info->getSimParams();
71      needCompression_   = simParams->getCompressDumpFile();
# Line 72 | Line 73 | namespace OpenMD {
73      needParticlePot_   = simParams->getOutputParticlePotential();
74      needFlucQ_         = simParams->getOutputFluctuatingCharges();
75      needElectricField_ = simParams->getOutputElectricField();
76 +    needSitePotential_ = simParams->getOutputSitePotential();
77  
78 <    if (needParticlePot_ || needFlucQ_ || needElectricField_) {
78 >    if (needParticlePot_ || needFlucQ_ || needElectricField_ ||
79 >        needSitePotential_) {
80        doSiteData_ = true;
81      } else {
82        doSiteData_ = false;
# Line 121 | Line 124 | namespace OpenMD {
124      needParticlePot_   = simParams->getOutputParticlePotential();
125      needFlucQ_         = simParams->getOutputFluctuatingCharges();
126      needElectricField_ = simParams->getOutputElectricField();
127 +    needSitePotential_ = simParams->getOutputSitePotential();
128  
129 <    if (needParticlePot_ || needFlucQ_ || needElectricField_) {
129 >    if (needParticlePot_ || needFlucQ_ || needElectricField_ ||
130 >        needSitePotential_) {
131        doSiteData_ = true;
132      } else {
133        doSiteData_ = false;
# Line 170 | Line 175 | namespace OpenMD {
175      needParticlePot_   = simParams->getOutputParticlePotential();
176      needFlucQ_         = simParams->getOutputFluctuatingCharges();
177      needElectricField_ = simParams->getOutputElectricField();
178 +    needSitePotential_ = simParams->getOutputSitePotential();
179  
180 <    if (needParticlePot_ || needFlucQ_ || needElectricField_) {
180 >    if (needParticlePot_ || needFlucQ_ || needElectricField_ ||
181 >        needSitePotential_) {
182        doSiteData_ = true;
183      } else {
184        doSiteData_ = false;
# Line 304 | Line 311 | namespace OpenMD {
311    void DumpWriter::writeFrame(std::ostream& os) {
312  
313   #ifdef IS_MPI
314 <    MPI_Status* istatus;
314 >    MPI_Status istatus;
315   #endif
316  
317      Molecule* mol;
# Line 391 | Line 398 | namespace OpenMD {
398        
399        for (int i = 1; i < nProc; ++i) {
400          // tell processor i to start sending us data:
401 +
402          MPI_Bcast(&i, 1, MPI_INT, masterNode, MPI_COMM_WORLD);
403  
404          // receive the length of the string buffer that was
405          // prepared by processor i:        
406          int recvLength;
407          MPI_Recv(&recvLength, 1, MPI_INT, i, MPI_ANY_TAG, MPI_COMM_WORLD,
408 <                 istatus);
408 >                 &istatus);
409  
410          // create a buffer to receive the data
411          char* recvBuffer = new char[recvLength];
# Line 405 | Line 413 | namespace OpenMD {
413          } else {
414            // receive the data:
415            MPI_Recv(recvBuffer, recvLength, MPI_CHAR, i,
416 <                               MPI_ANY_TAG, MPI_COMM_WORLD, istatus);
416 >                               MPI_ANY_TAG, MPI_COMM_WORLD, &istatus);
417            // send it to the file:
418            os << recvBuffer;
419            // get rid of the receive buffer:
# Line 420 | Line 428 | namespace OpenMD {
428          MPI_Bcast(&myturn, 1, MPI_INT, masterNode, MPI_COMM_WORLD);
429          if (myturn == worldRank){
430            // send the length of our buffer:
431 +
432            MPI_Send(&sendBufferLength, 1, MPI_INT, masterNode, 0, MPI_COMM_WORLD);
433  
434            // send our buffer:
# Line 474 | Line 483 | namespace OpenMD {
483            // prepared by processor i:        
484            int recvLength;
485            MPI_Recv(&recvLength, 1, MPI_INT, i, MPI_ANY_TAG, MPI_COMM_WORLD,
486 <                   istatus);
486 >                   &istatus);
487            
488            // create a buffer to receive the data
489            char* recvBuffer = new char[recvLength];
# Line 482 | Line 491 | namespace OpenMD {
491            } else {
492              // receive the data:
493              MPI_Recv(recvBuffer, recvLength, MPI_CHAR, i,
494 <                     MPI_ANY_TAG, MPI_COMM_WORLD, istatus);
494 >                     MPI_ANY_TAG, MPI_COMM_WORLD, &istatus);
495              // send it to the file:
496              os << recvBuffer;
497              // get rid of the receive buffer:
# Line 711 | Line 720 | namespace OpenMD {
720        }
721      }
722  
723 <
723 >    if (needSitePotential_) {
724 >      if (storageLayout & DataStorage::dslSitePotential) {          
725 >        type += "s";
726 >        RealType sPot = sd->getSitePotential();        
727 >        if (isinf(sPot) || isnan(sPot) ) {      
728 >          sprintf( painCave.errMsg,
729 >                   "DumpWriter detected a numerical error writing the"
730 >                   " site potential for object %s", id.c_str());      
731 >          painCave.isFatal = 1;
732 >          simError();
733 >        }
734 >        sprintf(tempBuffer, " %13e ", sPot);        
735 >        line += tempBuffer;
736 >      }
737 >    }    
738 >    
739      if (needParticlePot_) {
740        if (storageLayout & DataStorage::dslParticlePot) {
741          type += "u";
# Line 737 | Line 761 | namespace OpenMD {
761    }
762  
763    void DumpWriter::writeEor() {
764 <    std::ostream* eorStream;
765 <    
764 >
765 >    std::ostream* eorStream = NULL;
766 >
767   #ifdef IS_MPI
768      if (worldRank == 0) {
769   #endif // is_mpi

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines