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 |
|
} |
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; |
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; |
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); |
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 |
|
|
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(); |
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(), |
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(); |
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(); |
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 |
|
} |
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(), |
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(), |
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 |
|
} |
511 |
|
|
512 |
|
if (nTokens < 14) { |
513 |
|
sprintf(painCave.errMsg, |
514 |
< |
"Not enough Tokens.\n"); |
514 |
> |
"DumpReader Error: Not enough Tokens.\n"); |
515 |
|
painCave.isFatal = 1; |
516 |
|
simError(); |
517 |
|
} |
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(); |
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 |
|
} |
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 |
|
} |
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(); |