# | Line 35 | Line 35 | |
---|---|---|
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 | */ | |
# | Line 43 | Line 43 | |
43 | #define _LARGEFILE_SOURCE64 | |
44 | #define _FILE_OFFSET_BITS 64 | |
45 | ||
46 | + | #ifdef IS_MPI |
47 | + | #include <mpi.h> |
48 | + | #endif |
49 | + | |
50 | #include <sys/types.h> | |
51 | #include <sys/stat.h> | |
52 | ||
# | Line 60 | Line 64 | |
64 | #include "utils/StringTokenizer.hpp" | |
65 | #include "brains/Thermo.hpp" | |
66 | ||
63 | – | #ifdef IS_MPI |
64 | – | #include <mpi.h> |
65 | – | #endif |
67 | ||
67 | – | |
68 | namespace OpenMD { | |
69 | ||
70 | DumpReader::DumpReader(SimInfo* info, const std::string& filename) | |
# | Line 103 | Line 103 | namespace OpenMD { | |
103 | #ifdef IS_MPI | |
104 | ||
105 | if (worldRank == 0) { | |
106 | < | #endif |
106 | > | #endif |
107 | > | |
108 | > | inFile_->~istream(); |
109 | ||
108 | – | delete inFile_; |
109 | – | |
110 | #ifdef IS_MPI | |
111 | ||
112 | } | |
# | Line 128 | Line 128 | namespace OpenMD { | |
128 | } | |
129 | ||
130 | void DumpReader::scanFile(void) { | |
131 | < | int lineNo = 0; |
131 | > | |
132 | std::streampos prevPos; | |
133 | std::streampos currPos; | |
134 | ||
# | Line 142 | Line 142 | namespace OpenMD { | |
142 | bool foundOpenSnapshotTag = false; | |
143 | bool foundClosedSnapshotTag = false; | |
144 | ||
145 | + | int lineNo = 0; |
146 | while(inFile_->getline(buffer, bufferSize)) { | |
147 | ++lineNo; | |
148 | ||
# | Line 202 | Line 203 | namespace OpenMD { | |
203 | #ifdef IS_MPI | |
204 | } | |
205 | ||
206 | < | MPI::COMM_WORLD.Bcast(&nframes_, 1, MPI::INT, 0); |
206 | > | MPI_Bcast(&nframes_, 1, MPI_INT, 0, MPI_COMM_WORLD); |
207 | ||
208 | #endif // is_mpi | |
209 | ||
# | Line 227 | Line 228 | namespace OpenMD { | |
228 | needVel_ = false; | |
229 | } | |
230 | ||
231 | < | if (storageLayout & DataStorage::dslAmat || storageLayout & DataStorage::dslElectroFrame) { |
231 | > | if (storageLayout & DataStorage::dslAmat || |
232 | > | storageLayout & DataStorage::dslDipole || |
233 | > | storageLayout & DataStorage::dslQuadrupole) { |
234 | needQuaternion_ = true; | |
235 | } else { | |
236 | needQuaternion_ = false; | |
# | Line 286 | Line 289 | namespace OpenMD { | |
289 | } | |
290 | ||
291 | int sendBufferSize = sendBuffer.size(); | |
292 | < | MPI::COMM_WORLD.Bcast(&sendBufferSize, 1, MPI::INT, masterNode); |
293 | < | MPI::COMM_WORLD.Bcast((void *)sendBuffer.c_str(), sendBufferSize, |
294 | < | MPI::CHAR, masterNode); |
292 | > | MPI_Bcast(&sendBufferSize, 1, MPI_INT, masterNode, MPI_COMM_WORLD); |
293 | > | MPI_Bcast((void *)sendBuffer.c_str(), sendBufferSize, |
294 | > | MPI_CHAR, masterNode, MPI_COMM_WORLD); |
295 | ||
296 | sstream.str(sendBuffer); | |
297 | } else { | |
298 | int sendBufferSize; | |
299 | < | MPI::COMM_WORLD.Bcast(&sendBufferSize, 1, MPI::INT, masterNode); |
299 | > | MPI_Bcast(&sendBufferSize, 1, MPI_INT, masterNode, MPI_COMM_WORLD); |
300 | char * recvBuffer = new char[sendBufferSize+1]; | |
301 | assert(recvBuffer); | |
302 | recvBuffer[sendBufferSize] = '\0'; | |
303 | < | MPI::COMM_WORLD.Bcast(recvBuffer, sendBufferSize, MPI::CHAR, masterNode); |
303 | > | MPI_Bcast(recvBuffer, sendBufferSize, MPI_CHAR, masterNode, MPI_COMM_WORLD); |
304 | sstream.str(recvBuffer); | |
305 | delete [] recvBuffer; | |
306 | } | |
# | Line 507 | Line 510 | namespace OpenMD { | |
510 | sd->setElectricField(eField); | |
511 | break; | |
512 | } | |
513 | + | case 's' : { |
514 | + | |
515 | + | RealType sPot; |
516 | + | sPot = tokenizer.nextTokenAsDouble(); |
517 | + | sd->setSitePotential(sPot); |
518 | + | break; |
519 | + | } |
520 | default: { | |
521 | sprintf(painCave.errMsg, | |
522 | "DumpReader Error: %s is an unrecognized type\n", type.c_str()); | |
# | Line 517 | Line 527 | namespace OpenMD { | |
527 | ||
528 | } | |
529 | } | |
520 | – | |
530 | } | |
531 | ||
532 | ||
# | Line 525 | Line 534 | namespace OpenMD { | |
534 | ||
535 | StringTokenizer tokenizer(line); | |
536 | int nTokens; | |
537 | < | |
537 | > | |
538 | nTokens = tokenizer.countTokens(); | |
539 | ||
540 | if (nTokens < 2) { | |
# | Line 557 | Line 566 | namespace OpenMD { | |
566 | if (i >> siteIndex) { | |
567 | // chew up this token and parse as an int: | |
568 | siteIndex = tokenizer.nextTokenAsInt(); | |
569 | < | RigidBody* rb = static_cast<RigidBody*>(sd); |
570 | < | sd = rb->getAtoms()[siteIndex]; |
569 | > | |
570 | > | if (sd->isRigidBody()) { |
571 | > | RigidBody* rb = static_cast<RigidBody*>(sd); |
572 | > | sd = rb->getAtoms()[siteIndex]; |
573 | > | } |
574 | } | |
575 | ||
576 | /** | |
# | Line 607 | Line 619 | namespace OpenMD { | |
619 | sd->setElectricField(eField); | |
620 | break; | |
621 | } | |
622 | + | case 's' : { |
623 | + | |
624 | + | RealType sPot; |
625 | + | sPot = tokenizer.nextTokenAsDouble(); |
626 | + | sd->setSitePotential(sPot); |
627 | + | break; |
628 | + | } |
629 | default: { | |
630 | sprintf(painCave.errMsg, | |
631 | "DumpReader Error: %s is an unrecognized type\n", type.c_str()); | |
# | Line 619 | Line 638 | namespace OpenMD { | |
638 | } | |
639 | ||
640 | ||
641 | < | void DumpReader::readStuntDoubles(std::istream& inputStream) { |
641 | > | void DumpReader::readStuntDoubles(std::istream& inputStream) { |
642 | ||
643 | inputStream.getline(buffer, bufferSize); | |
644 | std::string line(buffer); | |
# | Line 645 | Line 664 | namespace OpenMD { | |
664 | ||
665 | void DumpReader::readSiteData(std::istream& inputStream) { | |
666 | ||
648 | – | inputStream.getline(buffer, bufferSize); |
667 | std::string line(buffer); | |
650 | – | |
651 | – | if (line.find("<SiteData>") == std::string::npos) { |
652 | – | // site data isn't required for a simulation, so skip |
653 | – | return; |
654 | – | } |
668 | ||
669 | + | // We already found the starting <SiteData> tag or we wouldn't be |
670 | + | // here, so just start parsing until we get to the ending |
671 | + | // </SiteData> tag: |
672 | + | |
673 | while(inputStream.getline(buffer, bufferSize)) { | |
674 | line = buffer; | |
675 |
– | Removed lines |
+ | Added lines |
< | Changed lines |
> | Changed lines |