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 324 by tim, Sun Feb 13 19:10:25 2005 UTC vs.
Revision 1993 by gezelter, Tue Apr 29 17:32:31 2014 UTC

# Line 1 | Line 1
1 < /*
2 < * Copyright (c) 2005 The University of Notre Dame. All Rights Reserved.
1 > /*
2 > * Copyright (c) 2009 The University of Notre Dame. All Rights Reserved.
3   *
4   * The University of Notre Dame grants you ("Licensee") a
5   * non-exclusive, royalty free, license to use, modify and
6   * redistribute this software in source and binary code form, provided
7   * that the following conditions are met:
8   *
9 < * 1. Acknowledgement of the program authors must be made in any
10 < *    publication of scientific results based in part on use of the
11 < *    program.  An acceptable form of acknowledgement is citation of
12 < *    the article in which the program was described (Matthew
13 < *    A. Meineke, Charles F. Vardeman II, Teng Lin, Christopher
14 < *    J. Fennell and J. Daniel Gezelter, "OOPSE: An Object-Oriented
15 < *    Parallel Simulation Engine for Molecular Dynamics,"
16 < *    J. Comput. Chem. 26, pp. 252-271 (2005))
17 < *
18 < * 2. Redistributions of source code must retain the above copyright
9 > * 1. Redistributions of source code must retain the above copyright
10   *    notice, this list of conditions and the following disclaimer.
11   *
12 < * 3. Redistributions in binary form must reproduce the above copyright
12 > * 2. Redistributions in binary form must reproduce the above copyright
13   *    notice, this list of conditions and the following disclaimer in the
14   *    documentation and/or other materials provided with the
15   *    distribution.
# Line 37 | Line 28
28   * arising out of the use of or inability to use software, even if the
29   * University of Notre Dame has been advised of the possibility of
30   * such damages.
31 + *
32 + * SUPPORT OPEN SCIENCE!  If you use OpenMD or its source code in your
33 + * research, please cite the appropriate papers when you publish your
34 + * work.  Good starting points are:
35 + *                                                                      
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, 234107 (2008).          
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 "config.h"
44 +
45 + #ifdef IS_MPI
46 + #include <mpi.h>
47 + #endif
48  
49   #include "io/DumpWriter.hpp"
50   #include "primitives/Molecule.hpp"
51   #include "utils/simError.h"
52 + #include "io/basic_teebuf.hpp"
53 + #ifdef HAVE_ZLIB
54 + #include "io/gzstream.hpp"
55 + #endif
56 + #include "io/Globals.hpp"
57  
58 < #ifdef IS_MPI
59 < #include <mpi.h>
60 < #endif //is_mpi
58 > #ifdef _MSC_VER
59 > #define isnan(x) _isnan((x))
60 > #define isinf(x) (!_finite(x) && !_isnan(x))
61 > #endif
62  
63 < namespace oopse {
63 > using namespace std;
64 > namespace OpenMD {
65  
66 < DumpWriter::DumpWriter(SimInfo* info, const std::string& filename)
67 <                   : info_(info), filename_(filename){
66 >  DumpWriter::DumpWriter(SimInfo* info)
67 >    : info_(info), filename_(info->getDumpFileName()),
68 >      eorFilename_(info->getFinalConfigFileName()){
69 >
70 >    Globals* simParams = info->getSimParams();
71 >    needCompression_   = simParams->getCompressDumpFile();
72 >    needForceVector_   = simParams->getOutputForceVector();
73 >    needParticlePot_   = simParams->getOutputParticlePotential();
74 >    needFlucQ_         = simParams->getOutputFluctuatingCharges();
75 >    needElectricField_ = simParams->getOutputElectricField();
76 >    needSitePotential_ = simParams->getOutputSitePotential();
77 >
78 >    if (needParticlePot_ || needFlucQ_ || needElectricField_ ||
79 >        needSitePotential_) {
80 >      doSiteData_ = true;
81 >    } else {
82 >      doSiteData_ = false;
83 >    }
84 >
85 >    createDumpFile_ = true;
86 > #ifdef HAVE_LIBZ
87 >    if (needCompression_) {
88 >      filename_ += ".gz";
89 >      eorFilename_ += ".gz";
90 >    }
91 > #endif
92 >    
93   #ifdef IS_MPI
94  
95      if (worldRank == 0) {
96   #endif // is_mpi
97 +        
98 +      dumpFile_ = createOStream(filename_);
99  
100 <        dumpFile_.open(filename_.c_str(), std::ios::out | std::ios::trunc);
100 >      if (!dumpFile_) {
101 >        sprintf(painCave.errMsg, "Could not open \"%s\" for dump output.\n",
102 >                filename_.c_str());
103 >        painCave.isFatal = 1;
104 >        simError();
105 >      }
106  
61        if (!dumpFile_) {
62            sprintf(painCave.errMsg, "Could not open \"%s\" for dump output.\n",
63                    filename_.c_str());
64            painCave.isFatal = 1;
65            simError();
66        }
67
107   #ifdef IS_MPI
108  
109      }
110  
72    sprintf(checkPointMsg, "Sucessfully opened output file for dumping.\n");
73    MPIcheckPoint();
74
111   #endif // is_mpi
112  
113 < }
113 >  }
114  
79 DumpWriter::~DumpWriter() {
115  
116 +  DumpWriter::DumpWriter(SimInfo* info, const std::string& filename)
117 +    : info_(info), filename_(filename){
118 +
119 +    Globals* simParams = info->getSimParams();
120 +    eorFilename_ = filename_.substr(0, filename_.rfind(".")) + ".eor";    
121 +
122 +    needCompression_   = simParams->getCompressDumpFile();
123 +    needForceVector_   = simParams->getOutputForceVector();
124 +    needParticlePot_   = simParams->getOutputParticlePotential();
125 +    needFlucQ_         = simParams->getOutputFluctuatingCharges();
126 +    needElectricField_ = simParams->getOutputElectricField();
127 +    needSitePotential_ = simParams->getOutputSitePotential();
128 +
129 +    if (needParticlePot_ || needFlucQ_ || needElectricField_ ||
130 +        needSitePotential_) {
131 +      doSiteData_ = true;
132 +    } else {
133 +      doSiteData_ = false;
134 +    }
135 +
136 +    createDumpFile_ = true;
137 + #ifdef HAVE_LIBZ
138 +    if (needCompression_) {
139 +      filename_ += ".gz";
140 +      eorFilename_ += ".gz";
141 +    }
142 + #endif
143 +    
144   #ifdef IS_MPI
145  
146      if (worldRank == 0) {
147   #endif // is_mpi
148  
149 <        dumpFile_.close();
149 >      
150 >      dumpFile_ = createOStream(filename_);
151  
152 +      if (!dumpFile_) {
153 +        sprintf(painCave.errMsg, "Could not open \"%s\" for dump output.\n",
154 +                filename_.c_str());
155 +        painCave.isFatal = 1;
156 +        simError();
157 +      }
158 +
159   #ifdef IS_MPI
160  
161      }
162  
163   #endif // is_mpi
164  
165 < }
165 >  }
166 >  
167 >  DumpWriter::DumpWriter(SimInfo* info, const std::string& filename, bool writeDumpFile)
168 >    : info_(info), filename_(filename){
169 >    
170 >    Globals* simParams = info->getSimParams();
171 >    eorFilename_ = filename_.substr(0, filename_.rfind(".")) + ".eor";    
172 >    
173 >    needCompression_   = simParams->getCompressDumpFile();
174 >    needForceVector_   = simParams->getOutputForceVector();
175 >    needParticlePot_   = simParams->getOutputParticlePotential();
176 >    needFlucQ_         = simParams->getOutputFluctuatingCharges();
177 >    needElectricField_ = simParams->getOutputElectricField();
178 >    needSitePotential_ = simParams->getOutputSitePotential();
179  
180 < void DumpWriter::writeCommentLine(std::ostream& os, Snapshot* s) {
180 >    if (needParticlePot_ || needFlucQ_ || needElectricField_ ||
181 >        needSitePotential_) {
182 >      doSiteData_ = true;
183 >    } else {
184 >      doSiteData_ = false;
185 >    }
186  
187 <    double currentTime;
188 <    Mat3x3d hmat;
189 <    double chi;
190 <    double integralOfChiDt;
191 <    Mat3x3d eta;
187 > #ifdef HAVE_LIBZ
188 >    if (needCompression_) {
189 >      filename_ += ".gz";
190 >      eorFilename_ += ".gz";
191 >    }
192 > #endif
193      
194 <    currentTime = s->getTime();
105 <    hmat = s->getHmat();
106 <    chi = s->getChi();
107 <    integralOfChiDt = s->getIntegralOfChiDt();
108 <    eta = s->getEta();
194 > #ifdef IS_MPI
195      
196 <    os << currentTime << ";\t"
197 <         << hmat(0, 0) << "\t" << hmat(1, 0) << "\t" << hmat(2, 0) << ";\t"
198 <         << hmat(0, 1) << "\t" << hmat(1, 1) << "\t" << hmat(2, 1) << ";\t"
199 <         << hmat(0, 2) << "\t" << hmat(1, 2) << "\t" << hmat(2, 2) << ";\t";
196 >    if (worldRank == 0) {
197 > #endif // is_mpi
198 >      
199 >      createDumpFile_ = writeDumpFile;
200 >      if (createDumpFile_) {
201 >        dumpFile_ = createOStream(filename_);
202 >      
203 >        if (!dumpFile_) {
204 >          sprintf(painCave.errMsg, "Could not open \"%s\" for dump output.\n",
205 >                  filename_.c_str());
206 >          painCave.isFatal = 1;
207 >          simError();
208 >        }
209 >      }
210 > #ifdef IS_MPI
211 >      
212 >    }
213  
214 <    //write out additional parameters, such as chi and eta
214 >    
215 > #endif // is_mpi
216 >    
217 >  }
218  
219 <    os << chi << "\t" << integralOfChiDt << "\t;";
219 >  DumpWriter::~DumpWriter() {
220  
221 <    os << eta(0, 0) << "\t" << eta(1, 0) << "\t" << eta(2, 0) << ";\t"
120 <         << eta(0, 1) << "\t" << eta(1, 1) << "\t" << eta(2, 1) << ";\t"
121 <         << eta(0, 2) << "\t" << eta(1, 2) << "\t" << eta(2, 2) << ";";
122 <        
123 <    os << std::endl;
124 < }
221 > #ifdef IS_MPI
222  
223 < void DumpWriter::writeFrame(std::ostream& os) {
224 <    const int BUFFERSIZE = 2000;
225 <    const int MINIBUFFERSIZE = 100;
223 >    if (worldRank == 0) {
224 > #endif // is_mpi
225 >      if (createDumpFile_){
226 >        writeClosing(*dumpFile_);
227 >        delete dumpFile_;
228 >      }
229 > #ifdef IS_MPI
230  
231 <    char tempBuffer[BUFFERSIZE];
131 <    char writeLine[BUFFERSIZE];
231 >    }
232  
233 <    Quat4d q;
134 <    Vector3d ji;
135 <    Vector3d pos;
136 <    Vector3d vel;
233 > #endif // is_mpi
234  
235 <    Molecule* mol;
139 <    StuntDouble* integrableObject;
140 <    SimInfo::MoleculeIterator mi;
141 <    Molecule::IntegrableObjectIterator ii;
142 <  
143 <    int nTotObjects;    
144 <    nTotObjects = info_->getNGlobalIntegrableObjects();
235 >  }
236  
237 < #ifndef IS_MPI
237 >  void DumpWriter::writeFrameProperties(std::ostream& os, Snapshot* s) {
238  
239 +    char buffer[1024];
240  
241 <    os << nTotObjects << "\n";
150 <        
151 <    writeCommentLine(os, info_->getSnapshotManager()->getCurrentSnapshot());
241 >    os << "    <FrameData>\n";
242  
243 <    for (mol = info_->beginMolecule(mi); mol != NULL; mol = info_->nextMolecule(mi)) {
243 >    RealType currentTime = s->getTime();
244  
245 <        for (integrableObject = mol->beginIntegrableObject(ii); integrableObject != NULL;
246 <            integrableObject = mol->nextIntegrableObject(ii)) {
247 <                
245 >    if (isinf(currentTime) || isnan(currentTime)) {      
246 >      sprintf( painCave.errMsg,
247 >               "DumpWriter detected a numerical error writing the time");      
248 >      painCave.isFatal = 1;
249 >      simError();
250 >    }
251 >    
252 >    sprintf(buffer, "        Time: %.10g\n", currentTime);
253 >    os << buffer;
254  
255 <            pos = integrableObject->getPos();
256 <            vel = integrableObject->getVel();
255 >    Mat3x3d hmat;
256 >    hmat = s->getHmat();
257  
258 <            sprintf(tempBuffer, "%s\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t",
259 <                    integrableObject->getType().c_str(),
260 <                    pos[0], pos[1], pos[2],
261 <                    vel[0], vel[1], vel[2]);
258 >    for (unsigned int i = 0; i < 3; i++) {
259 >      for (unsigned int j = 0; j < 3; j++) {
260 >        if (isinf(hmat(i,j)) || isnan(hmat(i,j))) {      
261 >          sprintf( painCave.errMsg,
262 >                   "DumpWriter detected a numerical error writing the box");
263 >          painCave.isFatal = 1;
264 >          simError();
265 >        }        
266 >      }
267 >    }
268 >    
269 >    sprintf(buffer, "        Hmat: {{ %.10g, %.10g, %.10g }, { %.10g, %.10g, %.10g }, { %.10g, %.10g, %.10g }}\n",
270 >            hmat(0, 0), hmat(1, 0), hmat(2, 0),
271 >            hmat(0, 1), hmat(1, 1), hmat(2, 1),
272 >            hmat(0, 2), hmat(1, 2), hmat(2, 2));
273 >    os << buffer;
274  
275 <            strcpy(writeLine, tempBuffer);
275 >    pair<RealType, RealType> thermostat = s->getThermostat();
276  
277 <            if (integrableObject->isDirectional()) {
278 <                q = integrableObject->getQ();
279 <                ji = integrableObject->getJ();
277 >    if (isinf(thermostat.first)  || isnan(thermostat.first) ||
278 >        isinf(thermostat.second) || isnan(thermostat.second)) {      
279 >      sprintf( painCave.errMsg,
280 >               "DumpWriter detected a numerical error writing the thermostat");
281 >      painCave.isFatal = 1;
282 >      simError();
283 >    }
284 >    sprintf(buffer, "  Thermostat: %.10g , %.10g\n", thermostat.first,
285 >            thermostat.second);
286 >    os << buffer;
287  
288 <                sprintf(tempBuffer, "%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\n",
289 <                        q[0], q[1], q[2], q[3],
175 <                        ji[0], ji[1], ji[2]);
176 <                strcat(writeLine, tempBuffer);
177 <            } else {
178 <                strcat(writeLine, "0.0\t0.0\t0.0\t0.0\t0.0\t0.0\t0.0\n");
179 <            }
288 >    Mat3x3d eta;
289 >    eta = s->getBarostat();
290  
291 <            os << writeLine;
292 <
293 <        }
291 >    for (unsigned int i = 0; i < 3; i++) {
292 >      for (unsigned int j = 0; j < 3; j++) {
293 >        if (isinf(eta(i,j)) || isnan(eta(i,j))) {      
294 >          sprintf( painCave.errMsg,
295 >                   "DumpWriter detected a numerical error writing the barostat");
296 >          painCave.isFatal = 1;
297 >          simError();
298 >        }        
299 >      }
300      }
301  
302 <    os.flush();
303 < #else // is_mpi
304 <    /*********************************************************************
305 <     * Documentation?  You want DOCUMENTATION?
306 <     *
191 <     * Why all the potatoes below?  
192 <     *
193 <     * To make a long story short, the original version of DumpWriter
194 <     * worked in the most inefficient way possible.  Node 0 would
195 <     * poke each of the node for an individual atom's formatted data
196 <     * as node 0 worked its way down the global index. This was particularly
197 <     * inefficient since the method blocked all processors at every atom
198 <     * (and did it twice!).
199 <     *
200 <     * An intermediate version of DumpWriter could be described from Node
201 <     * zero's perspective as follows:
202 <     *
203 <     *  1) Have 100 of your friends stand in a circle.
204 <     *  2) When you say go, have all of them start tossing potatoes at
205 <     *     you (one at a time).
206 <     *  3) Catch the potatoes.
207 <     *
208 <     * It was an improvement, but MPI has buffers and caches that could
209 <     * best be described in this analogy as "potato nets", so there's no
210 <     * need to block the processors atom-by-atom.
211 <     *
212 <     * This new and improved DumpWriter works in an even more efficient
213 <     * way:
214 <     *
215 <     *  1) Have 100 of your friend stand in a circle.
216 <     *  2) When you say go, have them start tossing 5-pound bags of
217 <     *     potatoes at you.
218 <     *  3) Once you've caught a friend's bag of potatoes,
219 <     *     toss them a spud to let them know they can toss another bag.
220 <     *
221 <     * How's THAT for documentation?
222 <     *
223 <     *********************************************************************/
224 <    const int masterNode = 0;
302 >    sprintf(buffer, "    Barostat: {{ %.10g, %.10g, %.10g }, { %.10g, %.10g, %.10g }, { %.10g, %.10g, %.10g }}\n",
303 >            eta(0, 0), eta(1, 0), eta(2, 0),
304 >            eta(0, 1), eta(1, 1), eta(2, 1),
305 >            eta(0, 2), eta(1, 2), eta(2, 2));
306 >    os << buffer;
307  
308 <    int * potatoes;
309 <    int myPotato;
228 <    int nProc;
229 <    int which_node;
230 <    double atomData[13];
231 <    int isDirectional;
232 <    const char * atomTypeString;
233 <    char MPIatomTypeString[MINIBUFFERSIZE];
234 <    int msgLen; // the length of message actually recieved at master nodes
235 <    int haveError;
236 <    MPI_Status istatus;
237 <    int nCurObj;
238 <    
239 <    // code to find maximum tag value
240 <    int * tagub;
241 <    int flag;
242 <    int MAXTAG;
243 <    MPI_Attr_get(MPI_COMM_WORLD, MPI_TAG_UB, &tagub, &flag);
308 >    os << "    </FrameData>\n";
309 >  }
310  
311 <    if (flag) {
246 <        MAXTAG = *tagub;
247 <    } else {
248 <        MAXTAG = 32767;
249 <    }
311 >  void DumpWriter::writeFrame(std::ostream& os) {
312  
313 <    if (worldRank == masterNode) { //master node (node 0) is responsible for writing the dump file
313 > #ifdef IS_MPI
314 >    MPI_Status istatus;
315 > #endif
316  
317 <        // Node 0 needs a list of the magic potatoes for each processor;
317 >    Molecule* mol;
318 >    StuntDouble* sd;
319 >    SimInfo::MoleculeIterator mi;
320 >    Molecule::IntegrableObjectIterator ii;
321 >    RigidBody::AtomIterator ai;
322  
323 <        MPI_Comm_size(MPI_COMM_WORLD, &nProc);
324 <        potatoes = new int[nProc];
323 > #ifndef IS_MPI
324 >    os << "  <Snapshot>\n";
325 >
326 >    writeFrameProperties(os, info_->getSnapshotManager()->getCurrentSnapshot());
327  
328 <        //write out the comment lines
329 <        for(int i = 0; i < nProc; i++) {
330 <            potatoes[i] = 0;
331 <        }
328 >    os << "    <StuntDoubles>\n";
329 >    for (mol = info_->beginMolecule(mi); mol != NULL;
330 >         mol = info_->nextMolecule(mi)) {
331 >      
332 >      for (sd = mol->beginIntegrableObject(ii); sd != NULL;  
333 >           sd = mol->nextIntegrableObject(ii)) {        
334 >          os << prepareDumpLine(sd);
335 >          
336 >      }
337 >    }    
338 >    os << "    </StuntDoubles>\n";
339  
340 +    if (doSiteData_) {
341 +      os << "    <SiteData>\n";
342 +      for (mol = info_->beginMolecule(mi); mol != NULL;
343 +           mol = info_->nextMolecule(mi)) {
344 +              
345 +        for (sd = mol->beginIntegrableObject(ii); sd != NULL;  
346 +           sd = mol->nextIntegrableObject(ii)) {        
347  
348 <        os << nTotObjects << "\n";
349 <        writeCommentLine(os, info_->getSnapshotManager()->getCurrentSnapshot());
348 >          int ioIndex = sd->getGlobalIntegrableObjectIndex();
349 >          // do one for the IO itself
350 >          os << prepareSiteLine(sd, ioIndex, 0);
351  
352 <        for(int i = 0; i < info_->getNGlobalMolecules(); i++) {
352 >          if (sd->isRigidBody()) {
353 >            
354 >            RigidBody* rb = static_cast<RigidBody*>(sd);
355 >            int siteIndex = 0;
356 >            for (Atom* atom = rb->beginAtom(ai); atom != NULL;  
357 >                 atom = rb->nextAtom(ai)) {                                            
358 >              os << prepareSiteLine(atom, ioIndex, siteIndex);
359 >              siteIndex++;
360 >            }
361 >          }
362 >        }
363 >      }    
364 >      os << "    </SiteData>\n";
365 >    }
366 >    os << "  </Snapshot>\n";
367  
368 <            // Get the Node number which has this atom;
368 >    os.flush();
369 > #else
370  
371 <            which_node = info_->getMolToProc(i);
371 >    const int masterNode = 0;
372 >    int worldRank;
373 >    int nProc;
374  
375 <            if (which_node != masterNode) { //current molecule is in slave node
376 <                if (potatoes[which_node] + 1 >= MAXTAG) {
275 <                    // The potato was going to exceed the maximum value,
276 <                    // so wrap this processor potato back to 0:        
375 >    MPI_Comm_size( MPI_COMM_WORLD, &nProc);
376 >    MPI_Comm_rank( MPI_COMM_WORLD, &worldRank);
377  
278                    potatoes[which_node] = 0;
279                    MPI_Send(&potatoes[which_node], 1, MPI_INT, which_node, 0,
280                             MPI_COMM_WORLD);
281                }
378  
379 <                myPotato = potatoes[which_node];
379 >    if (worldRank == masterNode) {      
380 >      os << "  <Snapshot>\n";  
381 >      writeFrameProperties(os,
382 >                           info_->getSnapshotManager()->getCurrentSnapshot());
383 >      os << "    <StuntDoubles>\n";
384 >    }
385  
386 <                //recieve the number of integrableObject in current molecule
387 <                MPI_Recv(&nCurObj, 1, MPI_INT, which_node, myPotato,
388 <                         MPI_COMM_WORLD, &istatus);
389 <                myPotato++;
386 >    //every node prepares the dump lines for integrable objects belong to itself
387 >    std::string buffer;
388 >    for (mol = info_->beginMolecule(mi); mol != NULL;
389 >         mol = info_->nextMolecule(mi)) {
390 >      for (sd = mol->beginIntegrableObject(ii); sd != NULL;
391 >           sd = mol->nextIntegrableObject(ii)) {        
392 >        buffer += prepareDumpLine(sd);
393 >      }
394 >    }
395 >    
396 >    if (worldRank == masterNode) {      
397 >      os << buffer;
398 >      
399 >      for (int i = 1; i < nProc; ++i) {
400 >        // tell processor i to start sending us data:
401 >        MPI_Bcast(&i, 1, MPI_INT, masterNode, MPI_COMM_WORLD);
402  
403 <                for(int l = 0; l < nCurObj; l++) {
404 <                    if (potatoes[which_node] + 2 >= MAXTAG) {
405 <                        // The potato was going to exceed the maximum value,
406 <                        // so wrap this processor potato back to 0:        
403 >        // receive the length of the string buffer that was
404 >        // prepared by processor i:        
405 >        int recvLength;
406 >        MPI_Recv(&recvLength, 1, MPI_INT, i, MPI_ANY_TAG, MPI_COMM_WORLD,
407 >                 &istatus);
408  
409 <                        potatoes[which_node] = 0;
410 <                        MPI_Send(&potatoes[which_node], 1, MPI_INT, which_node,
411 <                                 0, MPI_COMM_WORLD);
412 <                    }
409 >        // create a buffer to receive the data
410 >        char* recvBuffer = new char[recvLength];
411 >        if (recvBuffer == NULL) {
412 >        } else {
413 >          // receive the data:
414 >          MPI_Recv(recvBuffer, recvLength, MPI_CHAR, i,
415 >                               MPI_ANY_TAG, MPI_COMM_WORLD, &istatus);
416 >          // send it to the file:
417 >          os << recvBuffer;
418 >          // get rid of the receive buffer:
419 >          delete [] recvBuffer;
420 >        }
421 >      }
422 >    } else {
423 >      int sendBufferLength = buffer.size() + 1;
424 >      int myturn = 0;
425 >      for (int i = 1; i < nProc; ++i){
426 >        // wait for the master node to call our number:
427 >        MPI_Bcast(&myturn, 1, MPI_INT, masterNode, MPI_COMM_WORLD);
428 >        if (myturn == worldRank){
429 >          // send the length of our buffer:
430 >          MPI_Send(&sendBufferLength, 1, MPI_INT, masterNode, 0, MPI_COMM_WORLD);
431  
432 <                    MPI_Recv(MPIatomTypeString, MINIBUFFERSIZE, MPI_CHAR,
433 <                             which_node, myPotato, MPI_COMM_WORLD,
434 <                             &istatus);
432 >          // send our buffer:
433 >          MPI_Send((void *)buffer.c_str(), sendBufferLength,
434 >                   MPI_CHAR, masterNode, 0, MPI_COMM_WORLD);
435  
436 <                    atomTypeString = MPIatomTypeString;
436 >        }
437 >      }
438 >    }
439 >    
440 >    if (worldRank == masterNode) {      
441 >      os << "    </StuntDoubles>\n";
442 >    }
443  
444 <                    myPotato++;
444 >    if (doSiteData_) {
445 >      if (worldRank == masterNode) {
446 >        os << "    <SiteData>\n";
447 >      }
448 >      buffer.clear();
449 >      for (mol = info_->beginMolecule(mi); mol != NULL;
450 >           mol = info_->nextMolecule(mi)) {
451 >              
452 >        for (sd = mol->beginIntegrableObject(ii); sd != NULL;  
453 >             sd = mol->nextIntegrableObject(ii)) {      
454 >          
455 >          int ioIndex = sd->getGlobalIntegrableObjectIndex();
456 >          // do one for the IO itself
457 >          buffer += prepareSiteLine(sd, ioIndex, 0);
458  
459 <                    MPI_Recv(atomData, 13, MPI_DOUBLE, which_node, myPotato,
460 <                             MPI_COMM_WORLD, &istatus);
461 <                    myPotato++;
459 >          if (sd->isRigidBody()) {
460 >            
461 >            RigidBody* rb = static_cast<RigidBody*>(sd);
462 >            int siteIndex = 0;
463 >            for (Atom* atom = rb->beginAtom(ai); atom != NULL;  
464 >                 atom = rb->nextAtom(ai)) {                                            
465 >              buffer += prepareSiteLine(atom, ioIndex, siteIndex);
466 >              siteIndex++;
467 >            }
468 >          }
469 >        }
470 >      }
471  
472 <                    MPI_Get_count(&istatus, MPI_DOUBLE, &msgLen);
473 <
474 <                    if (msgLen == 13)
475 <                        isDirectional = 1;
476 <                    else
477 <                        isDirectional = 0;
478 <
479 <                    // If we've survived to here, format the line:
480 <
481 <                    if (!isDirectional) {
482 <                        sprintf(writeLine, "%s\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t",
483 <                                atomTypeString, atomData[0],
484 <                                atomData[1], atomData[2],
485 <                                atomData[3], atomData[4],
486 <                                atomData[5]);
472 >      if (worldRank == masterNode) {    
473 >        os << buffer;
474 >        
475 >        for (int i = 1; i < nProc; ++i) {
476 >          
477 >          // tell processor i to start sending us data:
478 >          MPI_Bcast(&i, 1, MPI_INT, masterNode, MPI_COMM_WORLD);
479 >          
480 >          // receive the length of the string buffer that was
481 >          // prepared by processor i:        
482 >          int recvLength;
483 >          MPI_Recv(&recvLength, 1, MPI_INT, i, MPI_ANY_TAG, MPI_COMM_WORLD,
484 >                   &istatus);
485 >          
486 >          // create a buffer to receive the data
487 >          char* recvBuffer = new char[recvLength];
488 >          if (recvBuffer == NULL) {
489 >          } else {
490 >            // receive the data:
491 >            MPI_Recv(recvBuffer, recvLength, MPI_CHAR, i,
492 >                     MPI_ANY_TAG, MPI_COMM_WORLD, &istatus);
493 >            // send it to the file:
494 >            os << recvBuffer;
495 >            // get rid of the receive buffer:
496 >            delete [] recvBuffer;
497 >          }
498 >        }      
499 >      } else {
500 >        int sendBufferLength = buffer.size() + 1;
501 >        int myturn = 0;
502 >        for (int i = 1; i < nProc; ++i){
503 >          // wait for the master node to call our number:
504 >          MPI_Bcast(&myturn, 1, MPI_INT, masterNode, MPI_COMM_WORLD);
505 >          if (myturn == worldRank){
506 >            // send the length of our buffer:
507 >            MPI_Send(&sendBufferLength, 1, MPI_INT, masterNode, 0, MPI_COMM_WORLD);
508 >            // send our buffer:
509 >            MPI_Send((void *)buffer.c_str(), sendBufferLength,
510 >                     MPI_CHAR, masterNode, 0, MPI_COMM_WORLD);
511 >          }
512 >        }
513 >      }
514 >      
515 >      if (worldRank == masterNode) {    
516 >        os << "    </SiteData>\n";
517 >      }
518 >    }
519 >    
520 >    if (worldRank == masterNode) {
521 >      os << "  </Snapshot>\n";
522 >      os.flush();
523 >    }
524 >    
525 > #endif // is_mpi
526 >    
527 >  }
528  
529 <                        strcat(writeLine,
530 <                               "0.0\t0.0\t0.0\t0.0\t0.0\t0.0\t0.0\n");
531 <                    } else {
532 <                        sprintf(writeLine,
533 <                                "%s\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\n",
534 <                                atomTypeString,
334 <                                atomData[0],
335 <                                atomData[1],
336 <                                atomData[2],
337 <                                atomData[3],
338 <                                atomData[4],
339 <                                atomData[5],
340 <                                atomData[6],
341 <                                atomData[7],
342 <                                atomData[8],
343 <                                atomData[9],
344 <                                atomData[10],
345 <                                atomData[11],
346 <                                atomData[12]);
347 <                    }
529 >  std::string DumpWriter::prepareDumpLine(StuntDouble* sd) {
530 >        
531 >    int index = sd->getGlobalIntegrableObjectIndex();
532 >    std::string type("pv");
533 >    std::string line;
534 >    char tempBuffer[4096];
535  
536 <                    os << writeLine;
536 >    Vector3d pos;
537 >    Vector3d vel;
538 >    pos = sd->getPos();
539  
540 <                } // end for(int l =0)
540 >    if (isinf(pos[0]) || isnan(pos[0]) ||
541 >        isinf(pos[1]) || isnan(pos[1]) ||
542 >        isinf(pos[2]) || isnan(pos[2]) ) {      
543 >      sprintf( painCave.errMsg,
544 >               "DumpWriter detected a numerical error writing the position"
545 >               " for object %d", index);      
546 >      painCave.isFatal = 1;
547 >      simError();
548 >    }
549  
550 <                potatoes[which_node] = myPotato;
354 <            } else { //master node has current molecule
550 >    vel = sd->getVel();        
551  
552 <                mol = info_->getMoleculeByGlobalIndex(i);
552 >    if (isinf(vel[0]) || isnan(vel[0]) ||
553 >        isinf(vel[1]) || isnan(vel[1]) ||
554 >        isinf(vel[2]) || isnan(vel[2]) ) {      
555 >      sprintf( painCave.errMsg,
556 >               "DumpWriter detected a numerical error writing the velocity"
557 >               " for object %d", index);      
558 >      painCave.isFatal = 1;
559 >      simError();
560 >    }
561  
562 <                if (mol == NULL) {
563 <                    sprintf(painCave.errMsg, "Molecule not found on node %d!", worldRank);
564 <                    painCave.isFatal = 1;
565 <                    simError();
362 <                }
363 <                
364 <                for (integrableObject = mol->beginIntegrableObject(ii); integrableObject != NULL;
365 <                    integrableObject = mol->nextIntegrableObject(ii)) {
366 <                        
367 <                    atomTypeString = integrableObject->getType().c_str();
562 >    sprintf(tempBuffer, "%18.10g %18.10g %18.10g %13e %13e %13e",
563 >            pos[0], pos[1], pos[2],
564 >            vel[0], vel[1], vel[2]);                    
565 >    line += tempBuffer;
566  
567 <                    pos = integrableObject->getPos();
568 <                    vel = integrableObject->getVel();
567 >    if (sd->isDirectional()) {
568 >      type += "qj";
569 >      Quat4d q;
570 >      Vector3d ji;
571 >      q = sd->getQ();
572  
573 <                    atomData[0] = pos[0];
574 <                    atomData[1] = pos[1];
575 <                    atomData[2] = pos[2];
573 >      if (isinf(q[0]) || isnan(q[0]) ||
574 >          isinf(q[1]) || isnan(q[1]) ||
575 >          isinf(q[2]) || isnan(q[2]) ||
576 >          isinf(q[3]) || isnan(q[3]) ) {      
577 >        sprintf( painCave.errMsg,
578 >                 "DumpWriter detected a numerical error writing the quaternion"
579 >                 " for object %d", index);      
580 >        painCave.isFatal = 1;
581 >        simError();
582 >      }
583  
584 <                    atomData[3] = vel[0];
377 <                    atomData[4] = vel[1];
378 <                    atomData[5] = vel[2];
584 >      ji = sd->getJ();
585  
586 <                    isDirectional = 0;
586 >      if (isinf(ji[0]) || isnan(ji[0]) ||
587 >          isinf(ji[1]) || isnan(ji[1]) ||
588 >          isinf(ji[2]) || isnan(ji[2]) ) {      
589 >        sprintf( painCave.errMsg,
590 >                 "DumpWriter detected a numerical error writing the angular"
591 >                 " momentum for object %d", index);      
592 >        painCave.isFatal = 1;
593 >        simError();
594 >      }
595  
596 <                    if (integrableObject->isDirectional()) {
597 <                        isDirectional = 1;
596 >      sprintf(tempBuffer, " %13e %13e %13e %13e %13e %13e %13e",
597 >              q[0], q[1], q[2], q[3],
598 >              ji[0], ji[1], ji[2]);
599 >      line += tempBuffer;
600 >    }
601  
602 <                        q = integrableObject->getQ();
603 <                        ji = integrableObject->getJ();
602 >    if (needForceVector_) {
603 >      type += "f";
604 >      Vector3d frc = sd->getFrc();
605 >      if (isinf(frc[0]) || isnan(frc[0]) ||
606 >          isinf(frc[1]) || isnan(frc[1]) ||
607 >          isinf(frc[2]) || isnan(frc[2]) ) {      
608 >        sprintf( painCave.errMsg,
609 >                 "DumpWriter detected a numerical error writing the force"
610 >                 " for object %d", index);      
611 >        painCave.isFatal = 1;
612 >        simError();
613 >      }
614 >      sprintf(tempBuffer, " %13e %13e %13e",
615 >              frc[0], frc[1], frc[2]);
616 >      line += tempBuffer;
617 >      
618 >      if (sd->isDirectional()) {
619 >        type += "t";
620 >        Vector3d trq = sd->getTrq();        
621 >        if (isinf(trq[0]) || isnan(trq[0]) ||
622 >            isinf(trq[1]) || isnan(trq[1]) ||
623 >            isinf(trq[2]) || isnan(trq[2]) ) {      
624 >          sprintf( painCave.errMsg,
625 >                   "DumpWriter detected a numerical error writing the torque"
626 >                   " for object %d", index);      
627 >          painCave.isFatal = 1;
628 >          simError();
629 >        }        
630 >        sprintf(tempBuffer, " %13e %13e %13e",
631 >                trq[0], trq[1], trq[2]);
632 >        line += tempBuffer;
633 >      }      
634 >    }
635  
636 <                        for(int j = 0; j < 6; j++) {
637 <                            atomData[j] = atomData[j];
638 <                        }
636 >    sprintf(tempBuffer, "%10d %7s %s\n", index, type.c_str(), line.c_str());
637 >    return std::string(tempBuffer);
638 >  }
639  
640 <                        atomData[6] = q[0];
641 <                        atomData[7] = q[1];
394 <                        atomData[8] = q[2];
395 <                        atomData[9] = q[3];
640 >  std::string DumpWriter::prepareSiteLine(StuntDouble* sd, int ioIndex, int siteIndex) {
641 >    int storageLayout = info_->getSnapshotManager()->getStorageLayout();
642  
643 <                        atomData[10] = ji[0];
644 <                        atomData[11] = ji[1];
645 <                        atomData[12] = ji[2];
646 <                    }
643 >    std::string id;
644 >    std::string type;
645 >    std::string line;
646 >    char tempBuffer[4096];
647  
648 <                    // If we've survived to here, format the line:
648 >    if (sd->isRigidBody()) {
649 >      sprintf(tempBuffer, "%10d           ", ioIndex);
650 >      id = std::string(tempBuffer);
651 >    } else {
652 >      sprintf(tempBuffer, "%10d %10d", ioIndex, siteIndex);
653 >      id = std::string(tempBuffer);
654 >    }
655 >              
656 >    if (needFlucQ_) {
657 >      if (storageLayout & DataStorage::dslFlucQPosition) {
658 >        type += "c";
659 >        RealType fqPos = sd->getFlucQPos();
660 >        if (isinf(fqPos) || isnan(fqPos) ) {      
661 >          sprintf( painCave.errMsg,
662 >                   "DumpWriter detected a numerical error writing the"
663 >                   " fluctuating charge for object %s", id.c_str());      
664 >          painCave.isFatal = 1;
665 >          simError();
666 >        }
667 >        sprintf(tempBuffer, " %13e ", fqPos);
668 >        line += tempBuffer;
669 >      }
670  
671 <                    if (!isDirectional) {
672 <                        sprintf(writeLine, "%s\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t",
673 <                                atomTypeString, atomData[0],
674 <                                atomData[1], atomData[2],
675 <                                atomData[3], atomData[4],
676 <                                atomData[5]);
677 <
678 <                        strcat(writeLine,
679 <                               "0.0\t0.0\t0.0\t0.0\t0.0\t0.0\t0.0\n");
680 <                    } else {
681 <                        sprintf(writeLine,
682 <                                "%s\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\n",
683 <                                atomTypeString,
417 <                                atomData[0],
418 <                                atomData[1],
419 <                                atomData[2],
420 <                                atomData[3],
421 <                                atomData[4],
422 <                                atomData[5],
423 <                                atomData[6],
424 <                                atomData[7],
425 <                                atomData[8],
426 <                                atomData[9],
427 <                                atomData[10],
428 <                                atomData[11],
429 <                                atomData[12]);
430 <                    }
431 <
432 <
433 <                    os << writeLine;
434 <
435 <                } //end for(iter = integrableObject.begin())
436 <            }
437 <        } //end for(i = 0; i < mpiSim->getNmol())
438 <
439 <        os.flush();
440 <        
441 <        sprintf(checkPointMsg, "Sucessfully took a dump.\n");
442 <        MPIcheckPoint();
671 >      if (storageLayout & DataStorage::dslFlucQVelocity) {
672 >        type += "w";    
673 >        RealType fqVel = sd->getFlucQVel();
674 >        if (isinf(fqVel) || isnan(fqVel) ) {      
675 >          sprintf( painCave.errMsg,
676 >                   "DumpWriter detected a numerical error writing the"
677 >                   " fluctuating charge velocity for object %s", id.c_str());      
678 >          painCave.isFatal = 1;
679 >          simError();
680 >        }
681 >        sprintf(tempBuffer, " %13e ", fqVel);
682 >        line += tempBuffer;
683 >      }
684  
685 <        delete [] potatoes;
686 <    } else {
685 >      if (needForceVector_) {
686 >        if (storageLayout & DataStorage::dslFlucQForce) {          
687 >          type += "g";
688 >          RealType fqFrc = sd->getFlucQFrc();        
689 >          if (isinf(fqFrc) || isnan(fqFrc) ) {      
690 >            sprintf( painCave.errMsg,
691 >                     "DumpWriter detected a numerical error writing the"
692 >                     " fluctuating charge force for object %s", id.c_str());      
693 >            painCave.isFatal = 1;
694 >            simError();
695 >          }
696 >          sprintf(tempBuffer, " %13e ", fqFrc);        
697 >          line += tempBuffer;
698 >        }
699 >      }
700 >    }
701 >    
702 >    if (needElectricField_) {
703 >      if (storageLayout & DataStorage::dslElectricField) {
704 >        type += "e";
705 >        Vector3d eField= sd->getElectricField();
706 >        if (isinf(eField[0]) || isnan(eField[0]) ||
707 >            isinf(eField[1]) || isnan(eField[1]) ||
708 >            isinf(eField[2]) || isnan(eField[2]) ) {      
709 >          sprintf( painCave.errMsg,
710 >                   "DumpWriter detected a numerical error writing the electric"
711 >                   " field for object %s", id.c_str());      
712 >          painCave.isFatal = 1;
713 >          simError();
714 >        }
715 >        sprintf(tempBuffer, " %13e %13e %13e",
716 >                eField[0], eField[1], eField[2]);
717 >        line += tempBuffer;
718 >      }
719 >    }
720  
721 <        // worldRank != 0, so I'm a remote node.  
721 >    if (needSitePotential_) {
722 >      if (storageLayout & DataStorage::dslSitePotential) {          
723 >        type += "s";
724 >        RealType sPot = sd->getSitePotential();        
725 >        if (isinf(sPot) || isnan(sPot) ) {      
726 >          sprintf( painCave.errMsg,
727 >                   "DumpWriter detected a numerical error writing the"
728 >                   " site potential for object %s", id.c_str());      
729 >          painCave.isFatal = 1;
730 >          simError();
731 >        }
732 >        sprintf(tempBuffer, " %13e ", sPot);        
733 >        line += tempBuffer;
734 >      }
735 >    }    
736 >    
737 >    if (needParticlePot_) {
738 >      if (storageLayout & DataStorage::dslParticlePot) {
739 >        type += "u";
740 >        RealType particlePot = sd->getParticlePot();
741 >        if (isinf(particlePot) || isnan(particlePot)) {      
742 >          sprintf( painCave.errMsg,
743 >                   "DumpWriter detected a numerical error writing the particle "
744 >                   " potential for object %s", id.c_str());      
745 >          painCave.isFatal = 1;
746 >          simError();
747 >        }
748 >        sprintf(tempBuffer, " %13e", particlePot);
749 >        line += tempBuffer;
750 >      }
751 >    }
752 >  
753 >    sprintf(tempBuffer, "%s %7s %s\n", id.c_str(), type.c_str(), line.c_str());
754 >    return std::string(tempBuffer);
755 >  }
756  
757 <        // Set my magic potato to 0:
757 >  void DumpWriter::writeDump() {
758 >    writeFrame(*dumpFile_);
759 >  }
760  
761 <        myPotato = 0;
761 >  void DumpWriter::writeEor() {
762  
763 <        for(int i = 0; i < info_->getNGlobalMolecules(); i++) {
763 >    std::ostream* eorStream = NULL;
764  
765 <            // Am I the node which has this integrableObject?
766 <            int whichNode = info_->getMolToProc(i);
767 <            if (whichNode == worldRank) {
768 <                if (myPotato + 1 >= MAXTAG) {
765 > #ifdef IS_MPI
766 >    if (worldRank == 0) {
767 > #endif // is_mpi
768 >      
769 >      eorStream = createOStream(eorFilename_);
770  
771 <                    // The potato was going to exceed the maximum value,
772 <                    // so wrap this processor potato back to 0 (and block until
773 <                    // node 0 says we can go:
771 > #ifdef IS_MPI
772 >    }
773 > #endif
774 >    
775 >    writeFrame(*eorStream);
776 >      
777 > #ifdef IS_MPI
778 >    if (worldRank == 0) {
779 > #endif
780 >      
781 >      writeClosing(*eorStream);
782 >      delete eorStream;
783 >      
784 > #ifdef IS_MPI
785 >    }
786 > #endif // is_mpi  
787  
788 <                    MPI_Recv(&myPotato, 1, MPI_INT, 0, 0, MPI_COMM_WORLD,
465 <                             &istatus);
466 <                }
788 >  }
789  
468                mol = info_->getMoleculeByGlobalIndex(i);
790  
791 <                
792 <                nCurObj = mol->getNIntegrableObjects();
791 >  void DumpWriter::writeDumpAndEor() {
792 >    std::vector<std::streambuf*> buffers;
793 >    std::ostream* eorStream;
794 > #ifdef IS_MPI
795 >    if (worldRank == 0) {
796 > #endif // is_mpi
797 >      buffers.push_back(dumpFile_->rdbuf());
798 >      eorStream = createOStream(eorFilename_);
799 >      buffers.push_back(eorStream->rdbuf());
800 > #ifdef IS_MPI
801 >    }
802 > #endif // is_mpi    
803  
804 <                MPI_Send(&nCurObj, 1, MPI_INT, 0, myPotato, MPI_COMM_WORLD);
805 <                myPotato++;
804 >    TeeBuf tbuf(buffers.begin(), buffers.end());
805 >    std::ostream os(&tbuf);
806 >    writeFrame(os);
807  
808 <                for (integrableObject = mol->beginIntegrableObject(ii); integrableObject != NULL;
809 <                    integrableObject = mol->nextIntegrableObject(ii)) {
808 > #ifdef IS_MPI
809 >    if (worldRank == 0) {
810 > #endif // is_mpi
811 >      writeClosing(*eorStream);
812 >      delete eorStream;
813 > #ifdef IS_MPI
814 >    }
815 > #endif // is_mpi      
816 >  }
817  
818 <                    if (myPotato + 2 >= MAXTAG) {
818 >  std::ostream* DumpWriter::createOStream(const std::string& filename) {
819  
820 <                        // The potato was going to exceed the maximum value,
821 <                        // so wrap this processor potato back to 0 (and block until
822 <                        // node 0 says we can go:
823 <
824 <                        MPI_Recv(&myPotato, 1, MPI_INT, 0, 0, MPI_COMM_WORLD,
825 <                                 &istatus);
487 <                    }
488 <
489 <                    atomTypeString = integrableObject->getType().c_str();
490 <
491 <                    pos = integrableObject->getPos();
492 <                    vel = integrableObject->getVel();
493 <
494 <                    atomData[0] = pos[0];
495 <                    atomData[1] = pos[1];
496 <                    atomData[2] = pos[2];
497 <
498 <                    atomData[3] = vel[0];
499 <                    atomData[4] = vel[1];
500 <                    atomData[5] = vel[2];
501 <
502 <                    isDirectional = 0;
503 <
504 <                    if (integrableObject->isDirectional()) {
505 <                        isDirectional = 1;
506 <
507 <                        q = integrableObject->getQ();
508 <                        ji = integrableObject->getJ();
509 <
510 <                        atomData[6] = q[0];
511 <                        atomData[7] = q[1];
512 <                        atomData[8] = q[2];
513 <                        atomData[9] = q[3];
514 <
515 <                        atomData[10] = ji[0];
516 <                        atomData[11] = ji[1];
517 <                        atomData[12] = ji[2];
518 <                    }
519 <
520 <                    strncpy(MPIatomTypeString, atomTypeString, MINIBUFFERSIZE);
521 <
522 <                    // null terminate the  std::string before sending (just in case):
523 <                    MPIatomTypeString[MINIBUFFERSIZE - 1] = '\0';
524 <
525 <                    MPI_Send(MPIatomTypeString, MINIBUFFERSIZE, MPI_CHAR, 0,
526 <                             myPotato, MPI_COMM_WORLD);
527 <
528 <                    myPotato++;
529 <
530 <                    if (isDirectional) {
531 <                        MPI_Send(atomData, 13, MPI_DOUBLE, 0, myPotato,
532 <                                 MPI_COMM_WORLD);
533 <                    } else {
534 <                        MPI_Send(atomData, 6, MPI_DOUBLE, 0, myPotato,
535 <                                 MPI_COMM_WORLD);
536 <                    }
537 <
538 <                    myPotato++;
539 <                }
540 <                    
541 <            }
542 <            
543 <        }
544 <        sprintf(checkPointMsg, "Sucessfully took a dump.\n");
545 <        MPIcheckPoint();
820 >    std::ostream* newOStream;
821 > #ifdef HAVE_ZLIB
822 >    if (needCompression_) {
823 >      newOStream = new ogzstream(filename.c_str());
824 >    } else {
825 >      newOStream = new std::ofstream(filename.c_str());
826      }
827 + #else
828 +    newOStream = new std::ofstream(filename.c_str());
829 + #endif
830 +    //write out MetaData first
831 +    (*newOStream) << "<OpenMD version=2>" << std::endl;
832 +    (*newOStream) << "  <MetaData>" << std::endl;
833 +    (*newOStream) << info_->getRawMetaData();
834 +    (*newOStream) << "  </MetaData>" << std::endl;
835 +    return newOStream;
836 +  }
837  
838 < #endif // is_mpi
838 >  void DumpWriter::writeClosing(std::ostream& os) {
839  
840 < }
840 >    os << "</OpenMD>\n";
841 >    os.flush();
842 >  }
843  
844 < }//end namespace oopse
844 > }//end namespace OpenMD

Comparing trunk/src/io/DumpWriter.cpp (property svn:keywords):
Revision 324 by tim, Sun Feb 13 19:10:25 2005 UTC vs.
Revision 1993 by gezelter, Tue Apr 29 17:32:31 2014 UTC

# Line 0 | Line 1
1 + Author Id Revision Date

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines