249 ERRORMSG(
"Bad config file in DiscParticle::read_meta." <<
endl);
253 bool iserror =
false;
259 std::vector<RecordInfo *>::iterator rec =
RecordList.begin();
269 for (
unsigned int sf=0; sf <
Config->getNumFiles(); ++sf) {
271 std::string filename =
Config->getFilename(sf) +
".meta";
272 DiscMeta outputMeta(filename.c_str());
273 if (outputMeta.
size() == 0)
278 for ( ; metaline != outputMeta.
end(); ++metaline) {
280 int linesread = (*metaline).first;
281 int numtokens = (*metaline).second.first;
282 std::string *tokens = (*metaline).second.second;
285 if (tokens[0] ==
"Type") {
286 if (numtokens > 1 && sf == 0)
288 }
else if (tokens[0] ==
"SMPs" && numtokens == 2) {
289 unsigned int checkfileSMPs = atoi(tokens[1].c_str());
290 if (
Config->fileSMPs() != checkfileSMPs) {
291 ERRORMSG(
"SMP number mismatch in file " << filename);
296 }
else if (tokens[0] ==
"NextOffset" && numtokens == 2) {
298 }
else if (tokens[0] ==
"Records" && numtokens == 2) {
299 unsigned int numrec = atoi(tokens[1].c_str());
301 ERRORMSG(
"Illegal Records value in file '" << filename <<
"' ");
307 for (
int r=0; r < atoi(tokens[1].c_str()); ++r)
310 }
else if (tokens[0] ==
"RecordAttribs" && numtokens == 3) {
311 unsigned int recnum = atoi(tokens[1].c_str());
312 int attribs = atoi(tokens[2].c_str());
314 ERRORMSG(
"Illegal record number '" << recnum <<
"'" <<
endl);
316 }
else if (sf > 0 && attribs !=
RecordList[recnum]->attributes) {
317 ERRORMSG(
"Illegal number of attributes in file " << filename);
318 ERRORMSG(
" (" << attribs <<
" != ");
324 }
else if (tokens[0] ==
"RecordLocPtcl" && numtokens == 3) {
325 unsigned int recnum = atoi(tokens[1].c_str());
326 int nump = atoi(tokens[2].c_str());
328 ERRORMSG(
"Illegal record number '" << recnum <<
"'" <<
endl);
331 RecordList[recnum]->localparticles.push_back(nump);
333 }
else if (tokens[0] ==
"RecordGlobPtcl" && numtokens == 3) {
334 unsigned int recnum = atoi(tokens[1].c_str());
335 int nump = atoi(tokens[2].c_str());
337 ERRORMSG(
"Illegal record number '" << recnum <<
"'" <<
endl);
339 }
else if (sf > 0 && nump !=
RecordList[recnum]->globalparticles) {
340 ERRORMSG(
"Illegal number of global particles in file "<<filename);
347 }
else if (tokens[0] ==
"RecordElemByte" && numtokens >= 2) {
348 unsigned int recnum = atoi(tokens[1].c_str());
350 ERRORMSG(
"Illegal record number '" << recnum <<
"'" <<
endl);
353 for (
int b=2; b < numtokens; ++b) {
354 int bytesize = atoi(tokens[b].c_str());
355 if (sf > 0 && bytesize !=
RecordList[recnum]->bytesize[b-2]) {
356 ERRORMSG(
"Illegal byte size for attribute " << b-2);
357 ERRORMSG(
" in file " << filename <<
"(" << bytesize);
361 }
else if (sf == 0) {
362 RecordList[recnum]->bytesize.push_back(bytesize);
367 static_cast<unsigned int>(
RecordList[recnum]->attributes))) {
368 ERRORMSG(
"Incorrect number of byte size values in file ");
373 }
else if (tokens[0] ==
"RecordDiscType" && numtokens >= 2) {
374 unsigned int recnum = atoi(tokens[1].c_str());
376 ERRORMSG(
"Illegal record number '" << recnum <<
"'" <<
endl);
379 for (
int b=2; b < numtokens; ++b) {
380 if (sf > 0 && tokens[b] !=
RecordList[recnum]->disctypes[b-2]) {
381 ERRORMSG(
"Inconsistent DiscType for attribute " << b-2);
382 ERRORMSG(
" in file " << filename <<
"(" << tokens[b]);
386 }
else if (sf == 0) {
387 RecordList[recnum]->disctypes.push_back(tokens[b]);
392 static_cast<unsigned int>(
RecordList[recnum]->attributes))) {
393 ERRORMSG(
"Incorrect number of DiscType values in file ");
398 }
else if (tokens[0] ==
"RecordOffset" && numtokens >= 2) {
399 unsigned int recnum = atoi(tokens[1].c_str());
401 ERRORMSG(
"Illegal record number '" << recnum <<
"'" <<
endl);
404 std::vector<Offset_t> offsetvec;
405 for (
int b=2; b < numtokens; ++b) {
406 Offset_t offset = atol(tokens[b].c_str());
407 if (sf > 0 && offset !=
RecordList[recnum]->offset[sf][b-2]) {
408 ERRORMSG(
"Illegal offset for attribute " << b-2);
409 ERRORMSG(
" in file " << filename <<
"(");
410 ERRORMSG(
static_cast<long>(offset) <<
" != ");
414 }
else if (sf == 0) {
415 offsetvec.push_back(offset);
419 if (offsetvec.size() != (
RecordList[recnum]->attributes==0 ? 1u :
420 static_cast<unsigned int>(
RecordList[recnum]->attributes))) {
421 ERRORMSG(
"Incorrect number of offset values in file ");
425 RecordList[recnum]->offset.push_back(offsetvec);
436 ERRORMSG(
"Format error on line " << linesread <<
" in file ");
448 int numinform =
Config->getNumOtherSMP();
449 for (
int s=0; s <= numinform; ++s) {
450 int smp =
Config->mySMP();
452 smp =
Config->getOtherSMP(s);
453 for (
unsigned int n=0; n <
Config->getNumSMPNodes(smp); ++n) {
454 int node =
Config->getSMPNode(smp, n);
459 int errint = iserror;
466 for (
unsigned int r=0; r <
RecordList.size(); ++r) {
467 int filesnum =
RecordList[r]->localparticles.size();
471 for (
unsigned int p=0; p <
RecordList[r]->localparticles.size(); ++p)
473 for (
unsigned int b=0; b <
RecordList[r]->bytesize.size(); ++b)
477 std::string unknowndtype =
"u";
478 for (
unsigned int dr =
RecordList[r]->disctypes.size();
480 RecordList[r]->disctypes.push_back(unknowndtype);
482 for (
unsigned int t=0; t <
RecordList[r]->bytesize.size(); ++t)
484 for (
unsigned int z=0; z <
RecordList[r]->offset.size(); ++z) {
485 for (
unsigned int o=0; o <
RecordList[r]->offset[z].size(); ++o) {
502 int node =
Config->getSMPBox0();
508 int errint = 0, numrec = 0, val = 0;
510 iserror = (errint != 0);
516 for (
int r=0; r < numrec; ++r) {
518 int filesnum =
RecordList[r]->localparticles.size();
525 for (
int p=0; p < filesnum; ++p) {
529 for (
int b=0; b < numattr; ++b) {
533 for (
int t=0; t < numattr; ++t) {
538 for (
int z=0; z < filesnum; ++z) {
539 std::vector<Offset_t> offsetvec;
542 for (
int o=0; o < numattr; ++o) {
545 offsetvec.push_back(offset);
559 std::vector<RecordInfo *>::iterator rec =
RecordList.begin();
575 std::vector<int> numvec;
576 std::vector<Offset_t> offsetvec;
582 ERRORMSG(
" in .data file for DiscParticle::write_data." <<
endl);
588 int numattr = info->attributes;
591 for (
int a=0;
a < numattr; ++
a) {
595 for (
unsigned int n=0; n < msgvec.size(); ++n) {
600 msgvec[n]->get(nump);
601 numvec.push_back(nump);
609 void *msgdata = msgvec[n]->remove();
612 unsigned int totalbytes = nump * info->bytesize[
a];
613 if (fwrite(msgdata, 1, totalbytes, outputData) != totalbytes) {
614 ERRORMSG(
"Write error in DiscParticle::write_data" <<
endl);
628 if ((
a+1) == numattr)
634 info->offset.push_back(offsetvec);
635 info->localparticles.push_back(totalnum);