--- trunk/src/io/DumpReader.cpp 2012/09/10 18:38:44 1796 +++ trunk/src/io/DumpReader.cpp 2014/05/31 22:35:05 2000 @@ -35,7 +35,7 @@ * * [1] Meineke, et al., J. Comp. Chem. 26, 252-271 (2005). * [2] Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006). - * [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 24107 (2008). + * [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 234107 (2008). * [4] Kuang & Gezelter, J. Chem. Phys. 133, 164101 (2010). * [5] Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011). */ @@ -43,6 +43,10 @@ #define _LARGEFILE_SOURCE64 #define _FILE_OFFSET_BITS 64 +#ifdef IS_MPI +#include +#endif + #include #include @@ -60,11 +64,7 @@ #include "utils/StringTokenizer.hpp" #include "brains/Thermo.hpp" -#ifdef IS_MPI -#include -#endif - namespace OpenMD { DumpReader::DumpReader(SimInfo* info, const std::string& filename) @@ -103,10 +103,10 @@ namespace OpenMD { #ifdef IS_MPI if (worldRank == 0) { -#endif +#endif + + inFile_->~istream(); - delete inFile_; - #ifdef IS_MPI } @@ -128,7 +128,7 @@ namespace OpenMD { } void DumpReader::scanFile(void) { - int lineNo = 0; + std::streampos prevPos; std::streampos currPos; @@ -142,6 +142,7 @@ namespace OpenMD { bool foundOpenSnapshotTag = false; bool foundClosedSnapshotTag = false; + int lineNo = 0; while(inFile_->getline(buffer, bufferSize)) { ++lineNo; @@ -202,7 +203,7 @@ namespace OpenMD { #ifdef IS_MPI } - MPI::COMM_WORLD.Bcast(&nframes_, 1, MPI::INT, 0); + MPI_Bcast(&nframes_, 1, MPI_INT, 0, MPI_COMM_WORLD); #endif // is_mpi @@ -227,7 +228,9 @@ namespace OpenMD { needVel_ = false; } - if (storageLayout & DataStorage::dslAmat || storageLayout & DataStorage::dslElectroFrame) { + if (storageLayout & DataStorage::dslAmat || + storageLayout & DataStorage::dslDipole || + storageLayout & DataStorage::dslQuadrupole) { needQuaternion_ = true; } else { needQuaternion_ = false; @@ -286,18 +289,18 @@ namespace OpenMD { } int sendBufferSize = sendBuffer.size(); - MPI::COMM_WORLD.Bcast(&sendBufferSize, 1, MPI::INT, masterNode); - MPI::COMM_WORLD.Bcast((void *)sendBuffer.c_str(), sendBufferSize, - MPI::CHAR, masterNode); + MPI_Bcast(&sendBufferSize, 1, MPI_INT, masterNode, MPI_COMM_WORLD); + MPI_Bcast((void *)sendBuffer.c_str(), sendBufferSize, + MPI_CHAR, masterNode, MPI_COMM_WORLD); sstream.str(sendBuffer); } else { int sendBufferSize; - MPI::COMM_WORLD.Bcast(&sendBufferSize, 1, MPI::INT, masterNode); + MPI_Bcast(&sendBufferSize, 1, MPI_INT, masterNode, MPI_COMM_WORLD); char * recvBuffer = new char[sendBufferSize+1]; assert(recvBuffer); recvBuffer[sendBufferSize] = '\0'; - MPI::COMM_WORLD.Bcast(recvBuffer, sendBufferSize, MPI::CHAR, masterNode); + MPI_Bcast(recvBuffer, sendBufferSize, MPI_CHAR, masterNode, MPI_COMM_WORLD); sstream.str(recvBuffer); delete [] recvBuffer; } @@ -507,6 +510,13 @@ namespace OpenMD { sd->setElectricField(eField); break; } + case 's' : { + + RealType sPot; + sPot = tokenizer.nextTokenAsDouble(); + sd->setSitePotential(sPot); + break; + } default: { sprintf(painCave.errMsg, "DumpReader Error: %s is an unrecognized type\n", type.c_str()); @@ -517,7 +527,6 @@ namespace OpenMD { } } - } @@ -525,7 +534,7 @@ namespace OpenMD { StringTokenizer tokenizer(line); int nTokens; - + nTokens = tokenizer.countTokens(); if (nTokens < 2) { @@ -557,8 +566,11 @@ namespace OpenMD { if (i >> siteIndex) { // chew up this token and parse as an int: siteIndex = tokenizer.nextTokenAsInt(); - RigidBody* rb = static_cast(sd); - sd = rb->getAtoms()[siteIndex]; + + if (sd->isRigidBody()) { + RigidBody* rb = static_cast(sd); + sd = rb->getAtoms()[siteIndex]; + } } /** @@ -607,6 +619,13 @@ namespace OpenMD { sd->setElectricField(eField); break; } + case 's' : { + + RealType sPot; + sPot = tokenizer.nextTokenAsDouble(); + sd->setSitePotential(sPot); + break; + } default: { sprintf(painCave.errMsg, "DumpReader Error: %s is an unrecognized type\n", type.c_str()); @@ -619,7 +638,7 @@ namespace OpenMD { } - void DumpReader::readStuntDoubles(std::istream& inputStream) { + void DumpReader::readStuntDoubles(std::istream& inputStream) { inputStream.getline(buffer, bufferSize); std::string line(buffer); @@ -645,14 +664,12 @@ namespace OpenMD { void DumpReader::readSiteData(std::istream& inputStream) { - inputStream.getline(buffer, bufferSize); std::string line(buffer); - - if (line.find("") == std::string::npos) { - // site data isn't required for a simulation, so skip - return; - } + // We already found the starting tag or we wouldn't be + // here, so just start parsing until we get to the ending + // tag: + while(inputStream.getline(buffer, bufferSize)) { line = buffer;