MCPcopy Create free account
hub / github.com/AMReX-Astro/Castro / WriteCheckpointFile

Function WriteCheckpointFile

Util/ConvertCheckpoint/Embiggen.cpp:476–696  ·  view source on GitHub ↗

---------------------------------------------------------------

Source from the content-addressed store, hash-verified

474
475// ---------------------------------------------------------------
476static void WriteCheckpointFile(const std::string& inFileName, const std::string &outFileName) {
477 VisMF::SetNOutFiles(nFiles);
478 // In checkpoint files always write out FABs in NATIVE format.
479 FABio::Format thePrevFormat = FArrayBox::getFormat();
480 FArrayBox::setFormat(FABio::FAB_NATIVE);
481
482 const std::string ckfile = outFileName;
483
484 // Only the I/O processor makes the directory if it doesn't already exist.
485 if(ParallelDescriptor::IOProcessor()) {
486 if( ! amrex::UtilCreateDirectory(ckfile, 0755)) {
487 amrex::CreateDirectoryFailed(ckfile);
488 }
489 }
490 // Force other processors to wait till directory is built.
491 ParallelDescriptor::Barrier();
492
493 // Copy some standard auxiliary files to the new checkpoint.
494 // Only one processor (the I/O processor) needs to do this.
495
496 if (ParallelDescriptor::IOProcessor()) {
497
498 std::ifstream oldCastroHeaderFile;
499
500 std::string oldCastroHeaderName = inFileName + "/CastroHeader";
501 oldCastroHeaderFile.open(oldCastroHeaderName.c_str(), std::ios::binary);
502
503 if (oldCastroHeaderFile.good()) {
504
505 std::ofstream newCastroHeaderFile;
506
507 std::string newCastroHeaderName = outFileName + "/CastroHeader";
508 newCastroHeaderFile.open(newCastroHeaderName.c_str(), std::ios::binary);
509
510 if (newCastroHeaderFile.good()) {
511 newCastroHeaderFile << oldCastroHeaderFile.rdbuf();
512 newCastroHeaderFile.close();
513 }
514
515 oldCastroHeaderFile.close();
516
517 }
518
519 }
520
521 // Write the main header file.
522
523 std::string HeaderFileName = ckfile + "/Header";
524
525 VisMF::IO_Buffer io_buffer(VisMF::IO_Buffer_Size);
526
527 std::ofstream HeaderFile;
528
529 HeaderFile.rdbuf()->pubsetbuf(io_buffer.dataPtr(), io_buffer.size());
530
531 int old_prec(0), i;
532
533 if(ParallelDescriptor::IOProcessor()) {

Callers 1

mainFunction · 0.85

Calls 3

closeMethod · 0.80
sizeMethod · 0.80
emptyMethod · 0.80

Tested by

no test coverage detected