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

Comparing trunk/OOPSE-3.0/src/io/DumpWriter.cpp (file contents):
Revision 2008 by tim, Sun Feb 13 19:10:25 2005 UTC vs.
Revision 2060 by tim, Thu Feb 24 20:55:07 2005 UTC

# Line 42 | Line 42
42   #include "io/DumpWriter.hpp"
43   #include "primitives/Molecule.hpp"
44   #include "utils/simError.h"
45 <
45 > #include "io/basic_teebuf.hpp"
46   #ifdef IS_MPI
47   #include <mpi.h>
48   #endif //is_mpi
49  
50   namespace oopse {
51 +
52 + DumpWriter::DumpWriter(SimInfo* info)
53 +                   : info_(info), filename_(info->getDumpFileName()), eorFilename_(info->getFinalConfigFileName()){
54 + #ifdef IS_MPI
55 +
56 +    if (worldRank == 0) {
57 + #endif // is_mpi
58 +
59 +        dumpFile_.open(filename_.c_str(), std::ios::out | std::ios::trunc);
60 +
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 +
68 + #ifdef IS_MPI
69 +
70 +    }
71 +
72 +    sprintf(checkPointMsg, "Sucessfully opened output file for dumping.\n");
73 +    MPIcheckPoint();
74  
75 + #endif // is_mpi
76 +
77 + }
78 +
79 +
80   DumpWriter::DumpWriter(SimInfo* info, const std::string& filename)
81                     : info_(info), filename_(filename){
82   #ifdef IS_MPI
# Line 56 | Line 84 | DumpWriter::DumpWriter(SimInfo* info, const std::strin
84      if (worldRank == 0) {
85   #endif // is_mpi
86  
87 +        eorFilename_ = filename_.substr(0, filename_.rfind(".")) + ".eor";
88          dumpFile_.open(filename_.c_str(), std::ios::out | std::ios::trunc);
89  
90          if (!dumpFile_) {
# Line 120 | Line 149 | void DumpWriter::writeCommentLine(std::ostream& os, Sn
149           << eta(0, 1) << "\t" << eta(1, 1) << "\t" << eta(2, 1) << ";\t"
150           << eta(0, 2) << "\t" << eta(1, 2) << "\t" << eta(2, 2) << ";";
151          
152 <    os << std::endl;
152 >    os << "\n";
153   }
154  
155   void DumpWriter::writeFrame(std::ostream& os) {
# Line 546 | Line 575 | void DumpWriter::writeFrame(std::ostream& os) {
575      }
576  
577   #endif // is_mpi
578 +
579 + }
580 +
581 + void DumpWriter::writeDump() {
582 +    writeFrame(dumpFile_);
583  
584   }
585  
586 + void DumpWriter::writeEor() {
587 +    std::ofstream eorStream;
588 +    
589 + #ifdef IS_MPI
590 +    if (worldRank == 0) {
591 + #endif // is_mpi
592 +
593 +        eorStream.open(eorFilename_.c_str());
594 +        if (!eorStream.is_open()) {
595 +            sprintf(painCave.errMsg, "DumpWriter : Could not open \"%s\" for writing.\n",
596 +                    eorFilename_.c_str());
597 +            painCave.isFatal = 1;
598 +            simError();
599 +        }
600 +
601 + #ifdef IS_MPI
602 +    }
603 + #endif // is_mpi    
604 +
605 +    writeFrame(eorStream);
606 + }
607 +
608 +
609 + void DumpWriter::writeDumpAndEor() {
610 +    std::ofstream eorStream;
611 +    std::vector<std::streambuf*> buffers;
612 + #ifdef IS_MPI
613 +    if (worldRank == 0) {
614 + #endif // is_mpi
615 +
616 +        buffers.push_back(dumpFile_.rdbuf());
617 +
618 +        eorStream.open(eorFilename_.c_str());
619 +        if (!eorStream.is_open()) {
620 +            sprintf(painCave.errMsg, "DumpWriter : Could not open \"%s\" for writing.\n",
621 +                    eorFilename_.c_str());
622 +            painCave.isFatal = 1;
623 +            simError();
624 +        }
625 +
626 +        buffers.push_back(eorStream.rdbuf());
627 +        
628 + #ifdef IS_MPI
629 +    }
630 + #endif // is_mpi    
631 +
632 +    TeeBuf tbuf(buffers.begin(), buffers.end());
633 +    std::ostream os(&tbuf);
634 +
635 +    writeFrame(os);
636 +    
637 + }
638 +
639 +
640 +
641   }//end namespace oopse

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines