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

Comparing trunk/OOPSE/libmdtools/DumpWriter.cpp (file contents):
Revision 934 by tim, Tue Jan 13 20:04:28 2004 UTC vs.
Revision 947 by gezelter, Thu Jan 15 14:22:16 2004 UTC

# Line 40 | Line 40 | DumpWriter::DumpWriter( SimInfo* the_entry_plug ){
40        simError();
41      }
42  
43    finalOut.open( entry_plug->finalName, ios::out | ios::trunc );
44    if( !finalOut ){
45      sprintf( painCave.errMsg,
46               "Could not open \"%s\" for final dump output.\n",
47               entry_plug->finalName );
48      painCave.isFatal = 1;
49      simError();
50    }
51
43   #ifdef IS_MPI
44    }
45  
# Line 68 | Line 59 | DumpWriter::~DumpWriter( ){
59   #endif // is_mpi
60  
61      dumpFile.close();
71    finalOut.close();
62  
63   #ifdef IS_MPI
64    }
# Line 111 | Line 101 | void DumpWriter::writeDump(double currentTime){
101  
102   void DumpWriter::writeDump(double currentTime){
103  
104 +  ofstream finalOut;
105    vector<ofstream*> fileStreams;
106  
107   #ifdef IS_MPI
108    if(worldRank == 0 ){
109 <    finalOut.seekp(0);
109 >    
110 >    finalOut.open( entry_plug->finalName, ios::out | ios::trunc );
111 >    if( !finalOut ){
112 >      sprintf( painCave.errMsg,
113 >               "Could not open \"%s\" for final dump output.\n",
114 >               entry_plug->finalName );
115 >      painCave.isFatal = 1;
116 >      simError();
117 >    }
118    }
119   #endif // is_mpi
120  
# Line 123 | Line 122 | void DumpWriter::writeDump(double currentTime){
122    fileStreams.push_back(&dumpFile);
123  
124    writeFrame(fileStreams, currentTime);
125 +
126 + #ifdef IS_MPI
127 +  finalOut.close();
128 + #endif
129          
130   }
131  
132   void DumpWriter::writeFinal(double currentTime){
133  
134 +  ofstream finalOut;
135    vector<ofstream*> fileStreams;
136  
137   #ifdef IS_MPI
138    if(worldRank == 0 ){
139 <    finalOut.seekp(0);
139 >
140 >    finalOut.open( entry_plug->finalName, ios::out | ios::trunc );
141 >
142 >    if( !finalOut ){
143 >      sprintf( painCave.errMsg,
144 >               "Could not open \"%s\" for final dump output.\n",
145 >               entry_plug->finalName );
146 >      painCave.isFatal = 1;
147 >      simError();
148 >    }
149 >
150    }
151   #endif // is_mpi
152    
153    fileStreams.push_back(&finalOut);  
154    writeFrame(fileStreams, currentTime);
155 +
156 + #ifdef IS_MPI
157 +  finalOut.close();
158 + #endif
159    
160   }
161  
# Line 146 | Line 164 | void DumpWriter::writeFrame( vector<ofstream*>& outFil
164    const int BUFFERSIZE = 2000;
165    const int MINIBUFFERSIZE = 100;
166  
167 <  char tempBuffer[BUFFERSIZE];
167 >  char tempBuffer[BUFFERSIZE];  
168    char writeLine[BUFFERSIZE];
169  
170    int i, k;
171  
172   #ifdef IS_MPI
173    
174 +  /*********************************************************************
175 +   * Documentation?  You want DOCUMENTATION?
176 +   *
177 +   * Why all the potatoes below?  
178 +   *
179 +   * To make a long story short, the original version of DumpWriter
180 +   * worked in the most inefficient way possible.  Node 0 would
181 +   * poke each of the node for an individual atom's formatted data
182 +   * as node 0 worked its way down the global index. This was particularly
183 +   * inefficient since the method blocked all processors at every atom
184 +   * (and did it twice!).
185 +   *
186 +   * An intermediate version of DumpWriter could be described from Node
187 +   * zero's perspective as follows:
188 +   *
189 +   *  1) Have 100 of your friends stand in a circle.
190 +   *  2) When you say go, have all of them start tossing potatoes at
191 +   *     you (one at a time).
192 +   *  3) Catch the potatoes.
193 +   *
194 +   * It was an improvement, but MPI has buffers and caches that could
195 +   * best be described in this analogy as "potato nets", so there's no
196 +   * need to block the processors atom-by-atom.
197 +   *
198 +   * This new and improved DumpWriter works in an even more efficient
199 +   * way:
200 +   *
201 +   *  1) Have 100 of your friend stand in a circle.
202 +   *  2) When you say go, have them start tossing 5-pound bags of
203 +   *     potatoes at you.
204 +   *  3) Once you've caught a friend's bag of potatoes,
205 +   *     toss them a spud to let them know they can toss another bag.
206 +   *
207 +   * How's THAT for documentation?
208 +   *
209 +   *********************************************************************/
210 +
211    int *potatoes;
212    int myPotato;
213  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines