| 59 | 
  | 
#ifdef IS_MPI | 
| 60 | 
  | 
  ifstrstream::ifstrstream()  | 
| 61 | 
  | 
    :  std::basic_istream<char, std::char_traits<char> >(0), | 
| 62 | 
< | 
    internalStringBuf_(), isRead(false)  {     | 
| 62 | 
> | 
    internalStringBuf_(), isRead(false)  {    | 
| 63 | 
  | 
    this->init(&internalStringBuf_); | 
| 64 | 
  | 
  } | 
| 65 | 
  | 
#else | 
| 66 | 
  | 
  ifstrstream::ifstrstream()  | 
| 67 | 
  | 
    :  std::basic_istream<char, std::char_traits<char> >(0), | 
| 68 | 
< | 
    internalFileBuf_(), isRead(false)  {     | 
| 68 | 
> | 
    internalFileBuf_(), isRead(false)  {      | 
| 69 | 
  | 
    this->init(&internalFileBuf_); | 
| 70 | 
  | 
  } | 
| 71 | 
  | 
#endif | 
| 80 | 
  | 
#ifdef IS_MPI | 
| 81 | 
  | 
  ifstrstream::ifstrstream(const char* filename, std::ios_base::openmode mode, bool checkFilename) | 
| 82 | 
  | 
    :  std::basic_istream<char, std::char_traits<char> >(0), | 
| 83 | 
< | 
       internalStringBuf_(), isRead(false) { | 
| 83 | 
> | 
    internalStringBuf_(), isRead(false) { | 
| 84 | 
  | 
    this->init(&internalStringBuf_); | 
| 85 | 
  | 
    isRead =  internalOpen(filename,  mode | std::ios_base::in, checkFilename); | 
| 86 | 
  | 
  } | 
| 87 | 
  | 
#else | 
| 88 | 
  | 
  ifstrstream::ifstrstream(const char* filename, std::ios_base::openmode mode, bool checkFilename) | 
| 89 | 
  | 
    :  std::basic_istream<char, std::char_traits<char> >(0), | 
| 90 | 
< | 
       internalFileBuf_(), isRead(false) { | 
| 90 | 
> | 
    internalFileBuf_(), isRead(false) { | 
| 91 | 
  | 
     | 
| 92 | 
  | 
    this->init(&internalFileBuf_); | 
| 93 | 
  | 
    isRead =  internalOpen(filename,  mode | std::ios_base::in, checkFilename); | 
| 97 | 
  | 
   * virtual destructor will close the file (in single mode) and clear | 
| 98 | 
  | 
   * the stream buffer | 
| 99 | 
  | 
   */ | 
| 100 | 
< | 
  ifstrstream::~ifstrstream(){ | 
| 101 | 
< | 
    close(); | 
| 100 | 
> | 
  ifstrstream::~ifstrstream(){    close(); | 
| 101 | 
  | 
  } | 
| 102 | 
  | 
   | 
| 103 | 
  | 
  /** | 
| 182 | 
  | 
    int myRank; | 
| 183 | 
  | 
    int masterNode; | 
| 184 | 
  | 
     | 
| 185 | 
< | 
    myRank =  MPI::COMM_WORLD.Get_rank(); | 
| 185 | 
> | 
    MPI_Comm_rank( MPI_COMM_WORLD, &myRank); | 
| 186 | 
> | 
       | 
| 187 | 
  | 
    masterNode = 0; | 
| 188 | 
  | 
     | 
| 189 | 
  | 
    if (myRank == masterNode) { | 
| 192 | 
  | 
         | 
| 193 | 
  | 
        //check the filename is the same | 
| 194 | 
  | 
        filenameLen = strlen(filename); | 
| 195 | 
< | 
        MPI::COMM_WORLD.Bcast(&filenameLen, 1, MPI::INT, masterNode); | 
| 196 | 
< | 
        MPI::COMM_WORLD.Bcast((void*)filename, filenameLen, MPI::CHAR,  | 
| 197 | 
< | 
                              masterNode); | 
| 195 | 
> | 
        MPI_Bcast(&filenameLen, 1, MPI_INT, masterNode, MPI_COMM_WORLD); | 
| 196 | 
> | 
        MPI_Bcast((void*)filename, filenameLen, MPI_CHAR,  | 
| 197 | 
> | 
                  masterNode, MPI_COMM_WORLD); | 
| 198 | 
  | 
         | 
| 199 | 
  | 
        diffFilename = 0; | 
| 200 | 
< | 
        MPI::COMM_WORLD.Allreduce(&diffFilename, &error, 1, MPI::INT, MPI::SUM); | 
| 200 | 
> | 
        MPI_Allreduce(&diffFilename, &error, 1, MPI_INT, MPI_SUM,  | 
| 201 | 
> | 
                      MPI_COMM_WORLD); | 
| 202 | 
  | 
         | 
| 203 | 
  | 
        //if file names are different just return false | 
| 204 | 
  | 
        if (error > 0) | 
| 224 | 
  | 
          fileSize = FileIOError; | 
| 225 | 
  | 
         | 
| 226 | 
  | 
        //broadcast the file size | 
| 227 | 
< | 
        MPI::COMM_WORLD.Bcast(&fileSize, 1, MPI::LONG, masterNode); | 
| 227 | 
> | 
        MPI_Bcast(&fileSize, 1, MPI_LONG, masterNode, MPI_COMM_WORLD); | 
| 228 | 
  | 
         | 
| 229 | 
  | 
        if (fileSize < 0) { | 
| 230 | 
  | 
          fin.close();                     | 
| 235 | 
  | 
         | 
| 236 | 
  | 
        // make a c-style  std::string and broadcast it | 
| 237 | 
  | 
        fbuf[fileSize] = '\0'; | 
| 238 | 
< | 
        MPI::COMM_WORLD.Bcast(fbuf, fileSize + 1, MPI::CHAR, masterNode); | 
| 238 | 
> | 
        MPI_Bcast(fbuf, fileSize + 1, MPI_CHAR, masterNode, MPI_COMM_WORLD); | 
| 239 | 
  | 
         | 
| 240 | 
  | 
        //close the file and delete the buffer | 
| 241 | 
  | 
        fin.close();       | 
| 243 | 
  | 
        delete[] fbuf; | 
| 244 | 
  | 
      }else{ | 
| 245 | 
  | 
        fileSize = FileNotExists; | 
| 246 | 
< | 
        MPI::COMM_WORLD.Bcast(&fileSize, 1, MPI::LONG, masterNode); | 
| 246 | 
> | 
        MPI_Bcast(&fileSize, 1, MPI_LONG, masterNode, MPI_COMM_WORLD); | 
| 247 | 
  | 
        return false; | 
| 248 | 
  | 
      } | 
| 249 | 
  | 
       | 
| 251 | 
  | 
       | 
| 252 | 
  | 
      //check file name | 
| 253 | 
  | 
      if (checkFilename) { | 
| 254 | 
< | 
        MPI::COMM_WORLD.Bcast(&filenameLen, 1, MPI::INT, masterNode); | 
| 254 | 
> | 
        MPI_Bcast(&filenameLen, 1, MPI_INT, masterNode, MPI_COMM_WORLD); | 
| 255 | 
  | 
         | 
| 256 | 
  | 
        char * masterFilename = new char[filenameLen]; | 
| 257 | 
< | 
        MPI::COMM_WORLD.Bcast(masterFilename, filenameLen, MPI::CHAR,  | 
| 258 | 
< | 
                              masterNode); | 
| 257 | 
> | 
        MPI_Bcast(masterFilename, filenameLen, MPI_CHAR,  | 
| 258 | 
> | 
                  masterNode, MPI_COMM_WORLD); | 
| 259 | 
  | 
         | 
| 260 | 
  | 
        if( strcmp(masterFilename, filename) == 0) | 
| 261 | 
  | 
          diffFilename = 0; | 
| 264 | 
  | 
         | 
| 265 | 
  | 
        delete[] masterFilename; | 
| 266 | 
  | 
         | 
| 267 | 
< | 
        MPI::COMM_WORLD.Allreduce(&diffFilename, &error, 1, MPI::INT, MPI::SUM); | 
| 267 | 
> | 
        MPI_Allreduce(&diffFilename, &error, 1, MPI_INT, MPI_SUM,  | 
| 268 | 
> | 
                      MPI_COMM_WORLD); | 
| 269 | 
  | 
         | 
| 270 | 
  | 
        if (error > 0) | 
| 271 | 
  | 
          return false;                         | 
| 272 | 
  | 
      } | 
| 273 | 
  | 
      //get file size | 
| 274 | 
< | 
      MPI::COMM_WORLD.Bcast(&fileSize, 1, MPI::LONG, masterNode); | 
| 274 | 
> | 
      MPI_Bcast(&fileSize, 1, MPI_LONG, masterNode, MPI_COMM_WORLD); | 
| 275 | 
  | 
       | 
| 276 | 
  | 
      if (fileSize >= 0 ) { | 
| 277 | 
  | 
        fbuf = new char[fileSize+1]; | 
| 278 | 
  | 
        assert(fbuf); | 
| 279 | 
  | 
         | 
| 280 | 
  | 
        //receive file content | 
| 281 | 
< | 
        MPI::COMM_WORLD.Bcast(fbuf, fileSize + 1, MPI::CHAR, masterNode); | 
| 281 | 
> | 
        MPI_Bcast(fbuf, fileSize + 1, MPI_CHAR, masterNode, MPI_COMM_WORLD); | 
| 282 | 
  | 
         | 
| 283 | 
  | 
        internalStringBuf_.str(fbuf); | 
| 284 | 
  | 
        delete [] fbuf; |