| 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, 24107 (2008).           | 
| 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 | 
– | 
 | 
| 42 | 
  | 
  | 
| 43 | 
+ | 
#ifdef IS_MPI  | 
| 44 | 
+ | 
#include <mpi.h>  | 
| 45 | 
+ | 
#endif | 
| 46 | 
+ | 
  | 
| 47 | 
  | 
#include <sys/types.h>  | 
| 48 | 
  | 
#include <sys/stat.h>  | 
| 49 | 
  | 
  | 
| 62 | 
  | 
#include "utils/StringTokenizer.hpp" | 
| 63 | 
  | 
#include "restraints/ObjectRestraint.hpp" | 
| 64 | 
  | 
#include "restraints/MolecularRestraint.hpp"  | 
| 62 | 
– | 
  | 
| 63 | 
– | 
#ifdef IS_MPI  | 
| 64 | 
– | 
  | 
| 65 | 
– | 
#include <mpi.h>  | 
| 66 | 
– | 
#endif | 
| 65 | 
  | 
 | 
| 66 | 
  | 
namespace OpenMD {  | 
| 67 | 
  | 
 | 
| 68 | 
  | 
  void RestReader::scanFile(){ | 
| 69 | 
< | 
    int lineNo = 0;  | 
| 69 | 
> | 
 | 
| 70 | 
  | 
    std::streampos prevPos; | 
| 71 | 
< | 
    std::streampos  currPos; | 
| 71 | 
> | 
    std::streampos currPos; | 
| 72 | 
  | 
     | 
| 73 | 
  | 
#ifdef IS_MPI  | 
| 74 | 
  | 
     | 
| 80 | 
  | 
      prevPos = currPos; | 
| 81 | 
  | 
       | 
| 82 | 
  | 
      bool foundOpenSnapshotTag = false; | 
| 83 | 
< | 
       | 
| 83 | 
> | 
      int lineNo = 0;        | 
| 84 | 
  | 
      while(!foundOpenSnapshotTag && inFile_->getline(buffer, bufferSize)) { | 
| 85 | 
  | 
        ++lineNo; | 
| 86 | 
  | 
         | 
| 88 | 
  | 
        currPos = inFile_->tellg();  | 
| 89 | 
  | 
        if (line.find("<Snapshot>")!= std::string::npos) { | 
| 90 | 
  | 
          foundOpenSnapshotTag = true; | 
| 91 | 
< | 
          framePos_ = prevPos; | 
| 91 | 
> | 
          framePos_ = (long long) prevPos; | 
| 92 | 
  | 
        } | 
| 93 | 
  | 
        prevPos = currPos; | 
| 94 | 
  | 
      } | 
| 95 | 
  | 
       | 
| 96 | 
  | 
#ifdef IS_MPI  | 
| 97 | 
  | 
    } | 
| 98 | 
< | 
    MPI_Bcast(&framePos_, 1, MPI_INT, 0, MPI_COMM_WORLD);  | 
| 98 | 
> | 
    MPI_Bcast(&framePos_, 1, MPI_LONG_LONG, 0, MPI_COMM_WORLD); | 
| 99 | 
  | 
#endif // is_mpi  | 
| 100 | 
  | 
  }  | 
| 101 | 
  | 
 | 
| 130 | 
  | 
      } | 
| 131 | 
  | 
       | 
| 132 | 
  | 
      int sendBufferSize = sendBuffer.size(); | 
| 133 | 
< | 
      MPI_Bcast(&sendBufferSize, 1, MPI_INT, masterNode, MPI_COMM_WORLD);      | 
| 134 | 
< | 
      MPI_Bcast((void *)sendBuffer.c_str(), sendBufferSize, MPI_CHAR, masterNode, MPI_COMM_WORLD);      | 
| 133 | 
> | 
      MPI_Bcast(&sendBufferSize, 1, MPI_INT, masterNode, MPI_COMM_WORLD); | 
| 134 | 
> | 
      MPI_Bcast((void *)sendBuffer.c_str(), sendBufferSize,  | 
| 135 | 
> | 
                MPI_CHAR, masterNode, MPI_COMM_WORLD); | 
| 136 | 
  | 
       | 
| 137 | 
  | 
      sstream.str(sendBuffer); | 
| 138 | 
  | 
    } else { | 
| 139 | 
  | 
      int sendBufferSize; | 
| 140 | 
< | 
      MPI_Bcast(&sendBufferSize, 1, MPI_INT, masterNode, MPI_COMM_WORLD);      | 
| 140 | 
> | 
      MPI_Bcast(&sendBufferSize, 1, MPI_INT, masterNode, MPI_COMM_WORLD); | 
| 141 | 
  | 
      char * recvBuffer = new char[sendBufferSize+1]; | 
| 142 | 
  | 
      assert(recvBuffer); | 
| 143 | 
  | 
      recvBuffer[sendBufferSize] = '\0'; | 
| 144 | 
< | 
      MPI_Bcast(recvBuffer, sendBufferSize, MPI_CHAR, masterNode, MPI_COMM_WORLD);      | 
| 144 | 
> | 
      MPI_Bcast(recvBuffer, sendBufferSize, MPI_CHAR, masterNode, | 
| 145 | 
> | 
                MPI_COMM_WORLD); | 
| 146 | 
  | 
      sstream.str(recvBuffer); | 
| 147 | 
  | 
      delete [] recvBuffer; | 
| 148 | 
  | 
    }       | 
| 367 | 
  | 
         | 
| 368 | 
  | 
      // is this io restrained? | 
| 369 | 
  | 
      GenericData* data = sd->getPropertyByName("Restraint"); | 
| 370 | 
– | 
      ObjectRestraint* oRest; | 
| 370 | 
  | 
       | 
| 371 | 
  | 
      if (data != NULL) { | 
| 372 | 
  | 
        // make sure we can reinterpret the generic data as restraint data: | 
| 374 | 
  | 
        if (restData != NULL) { | 
| 375 | 
  | 
          // make sure we can reinterpet the restraint data as a pointer to | 
| 376 | 
  | 
            // an ObjectRestraint: | 
| 377 | 
< | 
          oRest = dynamic_cast<ObjectRestraint*>(restData->getData()); | 
| 377 | 
> | 
          ObjectRestraint* oRest = dynamic_cast<ObjectRestraint*>(restData->getData()); | 
| 378 | 
  | 
          if (oRest != NULL) {           | 
| 379 | 
  | 
            if (sd->isDirectional()) { | 
| 380 | 
  | 
              oRest->setReferenceStructure(pos, q.toRotationMatrix3()); |