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

Comparing branches/development/src/io/ifstrstream.cpp (file contents):
Revision 1797 by gezelter, Tue Nov 22 20:38:56 2011 UTC vs.
Revision 1798 by gezelter, Thu Sep 13 14:10:11 2012 UTC

# Line 168 | Line 168 | namespace OpenMD {
168    bool ifstrstream::internalOpen(const char* filename, std::ios_base::openmode mode, bool checkFilename){
169      
170   #ifdef IS_MPI        
171 <    int commStatus;
171 >    //int commStatus;
172      long fileSize;
173      char* fbuf;
174      int filenameLen;
# Line 177 | Line 177 | namespace OpenMD {
177      int myRank;
178      int masterNode;
179      
180 <    commStatus = MPI_Comm_rank(MPI_COMM_WORLD, &myRank);
180 >    myRank =  MPI::COMM_WORLD.Get_rank();
181      masterNode = 0;
182      
183      if (myRank == masterNode) {
# Line 186 | Line 186 | namespace OpenMD {
186          
187          //check the filename is the same
188          filenameLen = strlen(filename);
189 <        commStatus = MPI_Bcast(&filenameLen, 1, MPI_INT, masterNode, MPI_COMM_WORLD);    
190 <        commStatus = MPI_Bcast((void*)filename, filenameLen, MPI_CHAR, masterNode, MPI_COMM_WORLD);    
189 >        MPI::COMM_WORLD.Bcast(&filenameLen, 1, MPI::INT, masterNode);
190 >        MPI::COMM_WORLD.Bcast((void*)filename, filenameLen, MPI::CHAR,
191 >                              masterNode);
192          
193          diffFilename = 0;
194 <        commStatus = MPI_Allreduce(&diffFilename, &error, 1,  MPI_INT, MPI_SUM,  MPI_COMM_WORLD);            
195 <        
194 >        MPI::COMM_WORLD.Allreduce(&diffFilename, &error, 1, MPI::INT, MPI::SUM);
195 >
196          //if file names are different just return false
197          if (error > 0)
198            return false;  
# Line 215 | Line 216 | namespace OpenMD {
216          if (fin.fail())
217            fileSize = FileIOError;
218          
219 <        //brocasting the file size
220 <        commStatus = MPI_Bcast(&fileSize, 1, MPI_LONG, masterNode, MPI_COMM_WORLD);                  
219 >        //broadcast the file size
220 >        MPI::COMM_WORLD.Bcast(&fileSize, 1, MPI::LONG, masterNode);
221          
222          if (fileSize < 0) {
223            fin.close();                    
# Line 225 | Line 226 | namespace OpenMD {
226            return false;
227          }
228          
229 <        // make a c-style  std::string and brocasting it
229 >        // make a c-style  std::string and broadcast it
230          fbuf[fileSize] = '\0';
231 <        commStatus = MPI_Bcast(fbuf, fileSize + 1, MPI_CHAR, masterNode, MPI_COMM_WORLD);
231 >        MPI::COMM_WORLD.Bcast(fbuf, fileSize + 1, MPI::CHAR, masterNode);
232          
233          //close the file and delete the buffer
234          fin.close();      
# Line 235 | Line 236 | namespace OpenMD {
236          delete [] fbuf;
237        }else{
238          fileSize = FileNotExists;
239 <        commStatus = MPI_Bcast(&fileSize, 1, MPI_LONG, masterNode, MPI_COMM_WORLD);  
239 >        MPI::COMM_WORLD.Bcast(&fileSize, 1, MPI::LONG, masterNode);
240          return false;
241        }
242        
# Line 243 | Line 244 | namespace OpenMD {
244        
245        //check file name
246        if (checkFilename) {
247 <        commStatus = MPI_Bcast(&filenameLen, 1, MPI_INT, masterNode, MPI_COMM_WORLD);    
247 >        MPI::COMM_WORLD.Bcast(&filenameLen, 1, MPI::INT, masterNode);
248          
249          char * masterFilename = new char[filenameLen];
250 <        commStatus = MPI_Bcast(masterFilename, filenameLen, MPI_CHAR, masterNode, MPI_COMM_WORLD);    
250 >        MPI::COMM_WORLD.Bcast(masterFilename, filenameLen, MPI::CHAR,
251 >                              masterNode);
252          
253          if( strcmp(masterFilename, filename) == 0)
254            diffFilename = 0;
# Line 255 | Line 257 | namespace OpenMD {
257          
258          delete masterFilename;
259          
260 <        commStatus = MPI_Allreduce(&diffFilename, &error, 1,  MPI_INT,  MPI_SUM, MPI_COMM_WORLD);    
260 >        MPI::COMM_WORLD.Allreduce(&diffFilename, &error, 1, MPI::INT, MPI::SUM);
261          
262          if (error > 0)
263            return false;                        
264        }
265        //get file size
266 <      commStatus = MPI_Bcast(&fileSize, 1, MPI_LONG, masterNode, MPI_COMM_WORLD);  
266 >      MPI::COMM_WORLD.Bcast(&fileSize, 1, MPI::LONG, masterNode);
267        
268        if (fileSize >= 0 ) {
269          fbuf = new char[fileSize+1];
270          assert(fbuf);
271          
272          //receive file content
273 <        commStatus = MPI_Bcast(fbuf, fileSize + 1, MPI_CHAR, masterNode, MPI_COMM_WORLD);
273 >        MPI::COMM_WORLD.Bcast(fbuf, fileSize + 1, MPI::CHAR, masterNode);
274          
275          internalStringBuf_.str(fbuf);
276          delete [] fbuf;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines