--- trunk/src/io/DumpReader.cpp 2005/01/12 22:41:40 246 +++ trunk/src/io/DumpReader.cpp 2005/03/01 14:45:45 381 @@ -80,7 +80,7 @@ DumpReader::DumpReader(SimInfo* info, const std::strin inFile_ = fopen(filename_.c_str(), "r"); if (inFile_ == NULL) { - sprintf(painCave.errMsg, "Cannot open file: %s\n", filename_.c_str()); + sprintf(painCave.errMsg, "DumpReader: Cannot open file: %s\n", filename_.c_str()); painCave.isFatal = 1; simError(); } @@ -108,7 +108,7 @@ DumpReader::~DumpReader() { error = fclose(inFile_); if (error) { - sprintf(painCave.errMsg, "Error closing %s\n", filename_.c_str()); + sprintf(painCave.errMsg, "DumpReader Error: Error closing %s\n", filename_.c_str()); painCave.isFatal = 1; simError(); } @@ -155,7 +155,7 @@ void DumpReader::scanFile(void) { if (feof(inFile_)) { sprintf(painCave.errMsg, - "File \"%s\" ended unexpectedly at line %d\n", + "DumpReader Error: File \"%s\" ended unexpectedly at line %d\n", filename_.c_str(), lineNum); painCave.isFatal = 1; @@ -172,7 +172,7 @@ void DumpReader::scanFile(void) { if (feof(inFile_)) { sprintf(painCave.errMsg, - "File \"%s\" ended unexpectedly at line %d\n", + "DumpReader Error: File \"%s\" ended unexpectedly at line %d\n", filename_.c_str(), lineNum); painCave.isFatal = 1; @@ -185,7 +185,7 @@ void DumpReader::scanFile(void) { if (feof(inFile_)) { sprintf(painCave.errMsg, - "File \"%s\" ended unexpectedly at line %d," + "DumpReader Error: File \"%s\" ended unexpectedly at line %d," " with atom %d\n", filename_.c_str(), lineNum, j); @@ -219,6 +219,32 @@ void DumpReader::readFrame(int whichFrame) { } void DumpReader::readFrame(int whichFrame) { + int storageLayout = info_->getSnapshotManager()->getStorageLayout(); + + if (storageLayout & DataStorage::dslPosition) { + needPos_ = true; + } else { + needPos_ = false; + } + + if (storageLayout & DataStorage::dslVelocity) { + needVel_ = true; + } else { + needVel_ = false; + } + + if (storageLayout & DataStorage::dslAmat || storageLayout & DataStorage::dslElectroFrame) { + needQuaternion_ = true; + } else { + needQuaternion_ = false; + } + + if (storageLayout & DataStorage::dslAngularMomentum) { + needAngMom_ = true; + } else { + needAngMom_ = false; + } + readSet(whichFrame); } @@ -254,7 +280,7 @@ void DumpReader::readSet(int whichFrame) { "does not match the meta-data file's nIntegrable, %d.\n", filename_.c_str(), nTotObjs, - info_->getNIntegrableObjects()); + info_->getNGlobalIntegrableObjects()); painCave.isFatal = 1; simError(); @@ -265,7 +291,7 @@ void DumpReader::readSet(int whichFrame) { eof_test = fgets(read_buffer, sizeof(read_buffer), inFile_); if (eof_test == NULL) { - sprintf(painCave.errMsg, "error in reading commment in %s\n", + sprintf(painCave.errMsg, "DumpReader Error: error in reading commment in %s\n", filename_.c_str()); painCave.isFatal = 1; simError(); @@ -284,7 +310,7 @@ void DumpReader::readSet(int whichFrame) { if (eof_test == NULL) { sprintf(painCave.errMsg, - "error in reading file %s\n" + "DumpReader Error: error in reading file %s\n" "natoms = %d; index = %d\n" "error reading the line from the file.\n", filename_.c_str(), @@ -324,7 +350,7 @@ void DumpReader::readSet(int whichFrame) { eof_test = fgets(read_buffer, sizeof(read_buffer), inFile_); if (eof_test == NULL) { - sprintf(painCave.errMsg, "Error reading 1st line of %s \n ", + sprintf(painCave.errMsg, "DumpReader Error: Error reading 1st line of %s \n ", filename_.c_str()); painCave.isFatal = 1; simError(); @@ -353,7 +379,7 @@ void DumpReader::readSet(int whichFrame) { eof_test = fgets(read_buffer, sizeof(read_buffer), inFile_); if (eof_test == NULL) { - sprintf(painCave.errMsg, "error in reading commment in %s\n", + sprintf(painCave.errMsg, "DumpReader Error: error in reading commment in %s\n", filename_.c_str()); painCave.isFatal = 1; simError(); @@ -376,7 +402,7 @@ void DumpReader::readSet(int whichFrame) { mol = info_->getMoleculeByGlobalIndex(i); if (mol == NULL) { - sprintf(painCave.errMsg, "Molecule not found on node %d!", worldRank); + sprintf(painCave.errMsg, "DumpReader Error: Molecule not found on node %d!", worldRank); painCave.isFatal = 1; simError(); } @@ -388,7 +414,7 @@ void DumpReader::readSet(int whichFrame) { if (eof_test == NULL) { sprintf(painCave.errMsg, - "error in reading file %s\n" + "DumpReader Error: error in reading file %s\n" "natoms = %d; index = %d\n" "error reading the line from the file.\n", filename_.c_str(), @@ -412,7 +438,7 @@ void DumpReader::readSet(int whichFrame) { if (eof_test == NULL) { sprintf(painCave.errMsg, - "error in reading file %s\n" + "DumpReader Error: error in reading file %s\n" "natoms = %d; index = %d\n" "error reading the line from the file.\n", filename_.c_str(), @@ -443,7 +469,7 @@ void DumpReader::readSet(int whichFrame) { mol = info_->getMoleculeByGlobalIndex(i); if (mol == NULL) { - sprintf(painCave.errMsg, "Molecule not found on node %d!", worldRank); + sprintf(painCave.errMsg, "DumpReader Error: Molecule not found on node %d!", worldRank); painCave.isFatal = 1; simError(); } @@ -485,7 +511,7 @@ void DumpReader::parseDumpLine(char *line, StuntDouble if (nTokens < 14) { sprintf(painCave.errMsg, - "Not enough Tokens.\n"); + "DumpReader Error: Not enough Tokens.\n%s\n", line); painCave.isFatal = 1; simError(); } @@ -493,19 +519,28 @@ void DumpReader::parseDumpLine(char *line, StuntDouble std::string name = tokenizer.nextToken(); if (name != integrableObject->getType()) { - + + sprintf(painCave.errMsg, + "DumpReader Error: Atom type [%s] in %s does not match Atom Type [%s] in .md file.\n", + name.c_str(), filename_.c_str(), integrableObject->getType().c_str()); + painCave.isFatal = 1; + simError(); } pos[0] = tokenizer.nextTokenAsDouble(); pos[1] = tokenizer.nextTokenAsDouble(); pos[2] = tokenizer.nextTokenAsDouble(); - integrableObject->setPos(pos); + if (needPos_) { + integrableObject->setPos(pos); + } vel[0] = tokenizer.nextTokenAsDouble(); vel[1] = tokenizer.nextTokenAsDouble(); vel[2] = tokenizer.nextTokenAsDouble(); - integrableObject->setVel(vel); - + if (needVel_) { + integrableObject->setVel(vel); + } + if (integrableObject->isDirectional()) { q[0] = tokenizer.nextTokenAsDouble(); @@ -517,20 +552,23 @@ void DumpReader::parseDumpLine(char *line, StuntDouble if (qlen < oopse::epsilon) { //check quaternion is not equal to 0 sprintf(painCave.errMsg, - "initial quaternion error (q0^2 + q1^2 + q2^2 + q3^2 ~ 0).\n"); + "DumpReader Error: initial quaternion error (q0^2 + q1^2 + q2^2 + q3^2 ~ 0).\n"); painCave.isFatal = 1; simError(); } q.normalize(); - - integrableObject->setQ(q); - + if (needQuaternion_) { + integrableObject->setQ(q); + } + ji[0] = tokenizer.nextTokenAsDouble(); ji[1] = tokenizer.nextTokenAsDouble(); ji[2] = tokenizer.nextTokenAsDouble(); - integrableObject->setJ(ji); + if (needAngMom_) { + integrableObject->setJ(ji); + } } } @@ -551,7 +589,7 @@ void DumpReader::parseCommentLine(char* line, Snapshot //comment line should at least contain 10 tokens: current time(1 token) and h-matrix(9 tokens) if (nTokens < 10) { sprintf(painCave.errMsg, - "Not enough tokens in comment line: %s", line); + "DumpReader Error: Not enough tokens in comment line: %s", line); painCave.isFatal = 1; simError(); } @@ -572,7 +610,7 @@ void DumpReader::parseCommentLine(char* line, Snapshot hmat(2, 2) = tokenizer.nextTokenAsDouble(); s->setHmat(hmat); - //read chi and integrablOfChidt, they should apprear in pair + //read chi and integralOfChidt, they should apprear in pair if (tokenizer.countTokens() >= 2) { chi = tokenizer.nextTokenAsDouble(); integralOfChiDt = tokenizer.nextTokenAsDouble();