ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-2.0/src/io/DumpReader.cpp
(Generate patch)

Comparing trunk/OOPSE-2.0/src/io/DumpReader.cpp (file contents):
Revision 1930 by gezelter, Wed Jan 12 22:41:40 2005 UTC vs.
Revision 2082 by tim, Mon Mar 7 22:39:33 2005 UTC

# Line 80 | Line 80 | DumpReader::DumpReader(SimInfo* info, const std::strin
80          inFile_ = fopen(filename_.c_str(), "r");
81  
82          if (inFile_ == NULL) {
83 <            sprintf(painCave.errMsg, "Cannot open file: %s\n", filename_.c_str());
83 >            sprintf(painCave.errMsg, "DumpReader: Cannot open file: %s\n", filename_.c_str());
84              painCave.isFatal = 1;
85              simError();
86          }
# Line 108 | Line 108 | DumpReader::~DumpReader() {
108          error = fclose(inFile_);
109  
110          if (error) {
111 <            sprintf(painCave.errMsg, "Error closing %s\n", filename_.c_str());
111 >            sprintf(painCave.errMsg, "DumpReader Error: Error closing %s\n", filename_.c_str());
112              painCave.isFatal = 1;            
113              simError();
114          }
115  
116 <        MemoryUtils::deleteVectorOfPointer(framePos_);
116 >        MemoryUtils::deletePointers(framePos_);
117  
118   #ifdef IS_MPI
119  
# Line 155 | Line 155 | void DumpReader::scanFile(void) {
155  
156          if (feof(inFile_)) {
157              sprintf(painCave.errMsg,
158 <                    "File \"%s\" ended unexpectedly at line %d\n",
158 >                    "DumpReader Error: File \"%s\" ended unexpectedly at line %d\n",
159                      filename_.c_str(),
160                      lineNum);
161              painCave.isFatal = 1;
# Line 172 | Line 172 | void DumpReader::scanFile(void) {
172  
173              if (feof(inFile_)) {
174                  sprintf(painCave.errMsg,
175 <                        "File \"%s\" ended unexpectedly at line %d\n",
175 >                        "DumpReader Error: File \"%s\" ended unexpectedly at line %d\n",
176                          filename_.c_str(),
177                          lineNum);
178                  painCave.isFatal = 1;
# Line 185 | Line 185 | void DumpReader::scanFile(void) {
185  
186                  if (feof(inFile_)) {
187                      sprintf(painCave.errMsg,
188 <                            "File \"%s\" ended unexpectedly at line %d,"
188 >                            "DumpReader Error: File \"%s\" ended unexpectedly at line %d,"
189                                  " with atom %d\n", filename_.c_str(),
190                              lineNum,
191                              j);
# Line 219 | Line 219 | void DumpReader::readFrame(int whichFrame) {
219   }
220  
221   void DumpReader::readFrame(int whichFrame) {
222 +    int storageLayout = info_->getSnapshotManager()->getStorageLayout();
223 +
224 +    if (storageLayout & DataStorage::dslPosition) {
225 +        needPos_ = true;
226 +    } else {
227 +        needPos_ = false;
228 +    }
229 +
230 +    if (storageLayout & DataStorage::dslVelocity) {
231 +        needVel_ = true;
232 +    } else {
233 +        needVel_ = false;
234 +    }
235 +
236 +    if (storageLayout & DataStorage::dslAmat || storageLayout & DataStorage::dslElectroFrame) {
237 +        needQuaternion_ = true;
238 +    } else {
239 +        needQuaternion_ = false;
240 +    }
241 +
242 +    if (storageLayout & DataStorage::dslAngularMomentum) {
243 +        needAngMom_ = true;
244 +    } else {
245 +        needAngMom_ = false;    
246 +    }
247 +
248      readSet(whichFrame);
249   }
250  
# Line 254 | Line 280 | void DumpReader::readSet(int whichFrame) {
280                      "does not match the meta-data file's nIntegrable, %d.\n",
281                  filename_.c_str(),
282                  nTotObjs,
283 <                info_->getNIntegrableObjects());
283 >                info_->getNGlobalIntegrableObjects());
284  
285          painCave.isFatal = 1;
286          simError();
# Line 265 | Line 291 | void DumpReader::readSet(int whichFrame) {
291      eof_test = fgets(read_buffer, sizeof(read_buffer), inFile_);
292  
293      if (eof_test == NULL) {
294 <        sprintf(painCave.errMsg, "error in reading commment in %s\n",
294 >        sprintf(painCave.errMsg, "DumpReader Error: error in reading commment in %s\n",
295                  filename_.c_str());
296          painCave.isFatal = 1;
297          simError();
# Line 284 | Line 310 | void DumpReader::readSet(int whichFrame) {
310  
311              if (eof_test == NULL) {
312                  sprintf(painCave.errMsg,
313 <                        "error in reading file %s\n"
313 >                        "DumpReader Error: error in reading file %s\n"
314                              "natoms  = %d; index = %d\n"
315                              "error reading the line from the file.\n",
316                          filename_.c_str(),
# Line 324 | Line 350 | void DumpReader::readSet(int whichFrame) {
350          eof_test = fgets(read_buffer, sizeof(read_buffer), inFile_);
351  
352          if (eof_test == NULL) {
353 <            sprintf(painCave.errMsg, "Error reading 1st line of %s \n ",
353 >            sprintf(painCave.errMsg, "DumpReader Error: Error reading 1st line of %s \n ",
354                      filename_.c_str());
355              painCave.isFatal = 1;
356              simError();
# Line 353 | Line 379 | void DumpReader::readSet(int whichFrame) {
379          eof_test = fgets(read_buffer, sizeof(read_buffer), inFile_);
380  
381          if (eof_test == NULL) {
382 <            sprintf(painCave.errMsg, "error in reading commment in %s\n",
382 >            sprintf(painCave.errMsg, "DumpReader Error: error in reading commment in %s\n",
383                      filename_.c_str());
384              painCave.isFatal = 1;
385              simError();
# Line 376 | Line 402 | void DumpReader::readSet(int whichFrame) {
402                  mol = info_->getMoleculeByGlobalIndex(i);
403  
404                  if (mol == NULL) {
405 <                    sprintf(painCave.errMsg, "Molecule not found on node %d!", worldRank);
405 >                    sprintf(painCave.errMsg, "DumpReader Error: Molecule not found on node %d!", worldRank);
406                          painCave.isFatal = 1;
407                      simError();
408                  }
# Line 388 | Line 414 | void DumpReader::readSet(int whichFrame) {
414  
415                      if (eof_test == NULL) {
416                          sprintf(painCave.errMsg,
417 <                                "error in reading file %s\n"
417 >                                "DumpReader Error: error in reading file %s\n"
418                                      "natoms  = %d; index = %d\n"
419                                      "error reading the line from the file.\n",
420                                  filename_.c_str(),
# Line 412 | Line 438 | void DumpReader::readSet(int whichFrame) {
438  
439                      if (eof_test == NULL) {
440                          sprintf(painCave.errMsg,
441 <                                "error in reading file %s\n"
441 >                                "DumpReader Error: error in reading file %s\n"
442                                      "natoms  = %d; index = %d\n"
443                                      "error reading the line from the file.\n",
444                                  filename_.c_str(),
# Line 443 | Line 469 | void DumpReader::readSet(int whichFrame) {
469                  
470                  mol = info_->getMoleculeByGlobalIndex(i);
471                  if (mol == NULL) {
472 <                    sprintf(painCave.errMsg, "Molecule not found on node %d!", worldRank);
472 >                    sprintf(painCave.errMsg, "DumpReader Error: Molecule not found on node %d!", worldRank);
473                      painCave.isFatal = 1;
474                      simError();
475                  }
# Line 485 | Line 511 | void DumpReader::parseDumpLine(char *line, StuntDouble
511  
512      if (nTokens < 14) {
513              sprintf(painCave.errMsg,
514 <                    "Not enough Tokens.\n");
514 >                    "DumpReader Error: Not enough Tokens.\n%s\n", line);
515              painCave.isFatal = 1;
516              simError();
517      }
# Line 493 | Line 519 | void DumpReader::parseDumpLine(char *line, StuntDouble
519      std::string name = tokenizer.nextToken();
520  
521      if (name != integrableObject->getType()) {
522 <        
522 >
523 >            sprintf(painCave.errMsg,
524 >                    "DumpReader Error: Atom type [%s] in %s does not match Atom Type [%s] in .md file.\n",
525 >                    name.c_str(), filename_.c_str(), integrableObject->getType().c_str());
526 >            painCave.isFatal = 1;
527 >            simError();        
528      }
529  
530      pos[0] = tokenizer.nextTokenAsDouble();
531      pos[1] = tokenizer.nextTokenAsDouble();
532      pos[2] = tokenizer.nextTokenAsDouble();
533 <    integrableObject->setPos(pos);
533 >    if (needPos_) {
534 >        integrableObject->setPos(pos);
535 >    }
536      
537      vel[0] = tokenizer.nextTokenAsDouble();
538      vel[1] = tokenizer.nextTokenAsDouble();
539      vel[2] = tokenizer.nextTokenAsDouble();
540 <    integrableObject->setVel(vel);
541 <
540 >    if (needVel_) {
541 >        integrableObject->setVel(vel);
542 >    }
543 >    
544      if (integrableObject->isDirectional()) {
545          
546          q[0] = tokenizer.nextTokenAsDouble();
# Line 517 | Line 552 | void DumpReader::parseDumpLine(char *line, StuntDouble
552          if (qlen < oopse::epsilon) { //check quaternion is not equal to 0
553              
554              sprintf(painCave.errMsg,
555 <                    "initial quaternion error (q0^2 + q1^2 + q2^2 + q3^2 ~ 0).\n");
555 >                    "DumpReader Error: initial quaternion error (q0^2 + q1^2 + q2^2 + q3^2 ~ 0).\n");
556              painCave.isFatal = 1;
557              simError();
558              
559          }
560  
561          q.normalize();
562 <              
563 <        integrableObject->setQ(q);
564 <        
562 >        if (needQuaternion_) {          
563 >            integrableObject->setQ(q);
564 >        }
565 >
566          ji[0] = tokenizer.nextTokenAsDouble();
567          ji[1] = tokenizer.nextTokenAsDouble();
568          ji[2] = tokenizer.nextTokenAsDouble();
569 <        integrableObject->setJ(ji);
569 >        if (needAngMom_) {
570 >            integrableObject->setJ(ji);
571 >        }
572      }
573  
574   }
# Line 551 | Line 589 | void DumpReader::parseCommentLine(char* line, Snapshot
589      //comment line should at least contain 10 tokens: current time(1 token) and  h-matrix(9 tokens)
590      if (nTokens < 10) {
591              sprintf(painCave.errMsg,
592 <                    "Not enough tokens in comment line: %s", line);
592 >                    "DumpReader Error: Not enough tokens in comment line: %s", line);
593              painCave.isFatal = 1;
594              simError();  
595      }
# Line 572 | Line 610 | void DumpReader::parseCommentLine(char* line, Snapshot
610      hmat(2, 2) = tokenizer.nextTokenAsDouble();
611      s->setHmat(hmat);
612      
613 <    //read chi and integrablOfChidt, they should apprear in pair
613 >    //read chi and integralOfChidt, they should apprear in pair
614      if (tokenizer.countTokens() >= 2) {
615          chi = tokenizer.nextTokenAsDouble();
616          integralOfChiDt = tokenizer.nextTokenAsDouble();            

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines