MCPcopy Create free account
hub / github.com/AMReX-Codes/amrex / read_header

Method read_header

Src/Base/AMReX_FArrayBox.cpp:447–521  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

445//
446
447FABio*
448FABio::read_header (std::istream& is,
449 FArrayBox& f)
450{
451// BL_PROFILE("FArrayBox::read_header_is");
452 int nvar;
453 Box bx;
454 FABio* fio = nullptr;
455 RealDescriptor* rd = nullptr;
456 char c;
457
458 is >> c;
459 if(c != 'F') { amrex::Error("FABio::read_header(): expected \'F\'"); }
460 is >> c;
461 if(c != 'A') { amrex::Error("FABio::read_header(): expected \'A\'"); }
462 is >> c;
463 if(c != 'B') { amrex::Error("FABio::read_header(): expected \'B\'"); }
464
465 is >> c;
466 if(c == ':') { // ---- The "old" FAB format.
467 int typ_in, wrd_in;
468 is >> typ_in;
469 is >> wrd_in;
470
471 char machine[128];
472 is >> machine;
473 is >> bx;
474 is >> nvar;
475 AMREX_ASSERT(nvar >= 0 && nvar < std::numeric_limits<int>::max());
476 //
477 // Set the FArrayBox to the appropriate size.
478 //
479 if (f.box() != bx || f.nComp() != nvar) {
480 f.resize(bx,nvar);
481 }
482 is.ignore(BL_IGNORE_MAX, '\n');
483 switch (typ_in)
484 {
485 case FABio::FAB_ASCII: fio = new FABio_ascii; break;
486 case FABio::FAB_8BIT: fio = new FABio_8bit; break;
487 case FABio::FAB_NATIVE:
488 case FABio::FAB_NATIVE_32:
489 case FABio::FAB_IEEE:
490 rd = RealDescriptor::newRealDescriptor(typ_in,
491 wrd_in,
492 machine,
493 FArrayBox::ordering);
494 fio = new FABio_binary(rd);
495 break;
496 default:
497 amrex::Error("FABio::read_header(): Unrecognized FABio header");
498 }
499 } else { // ---- The "new" FAB format.
500 is.putback(c);
501 rd = new RealDescriptor;
502 is >> *rd;
503 is >> bx;
504 is >> nvar;

Callers

nothing calls this directly

Calls 3

boxMethod · 0.45
nCompMethod · 0.45
resizeMethod · 0.45

Tested by

no test coverage detected