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

Method writePlotFileDoit

Src/Amr/AMReX_Amr.cpp:968–1089  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

966}
967
968void
969Amr::writePlotFileDoit (std::string const& pltfile, bool regular)
970{
971 auto dPlotFileTime0 = amrex::second();
972
973 int max_level_to_plot = std::min(plot_max_level, finest_level);
974
975 VisMF::SetNOutFiles(plot_nfiles);
976 VisMF::Header::Version currentVersion(VisMF::GetHeaderVersion());
977 VisMF::SetHeaderVersion(plot_headerversion);
978
979 amrex::StreamRetry sretry(pltfile, abort_on_stream_retry_failure,
980 stream_max_tries);
981
982 const std::string pltfileTemp = (AsyncOut::UseAsyncOut()) ? pltfile : (pltfile + ".temp");
983
984 while(sretry.TryFileOutput()) {
985 //
986 // if either the pltfile or pltfileTemp exists, rename them
987 // to move them out of the way. then create pltfile
988 // with the temporary name, then rename it back when
989 // it is finished writing. then stream retry can rename
990 // it to a bad suffix if there were stream errors.
991 //
992
993 if (precreateDirectories) { // ---- make all directories at once
994 amrex::UtilRenameDirectoryToOld(pltfile, false); // dont call barrier
995 amrex::UtilCreateCleanDirectory(pltfileTemp, false); // dont call barrier
996 for(int i(0); i <= max_level_to_plot; ++i) {
997 amr_level[i]->CreateLevelDirectory(pltfileTemp);
998 }
999 ParallelDescriptor::Barrier("Amr::writePlotFile:PCD");
1000 } else {
1001 amrex::UtilRenameDirectoryToOld(pltfile, false); // dont call barrier
1002 amrex::UtilCreateCleanDirectory(pltfileTemp, true); // call barrier
1003 }
1004
1005 std::string HeaderFileName(pltfileTemp + "/Header");
1006
1007 VisMF::IO_Buffer io_buffer(VisMF::GetIOBufferSize());
1008
1009 std::ofstream HeaderFile;
1010
1011 HeaderFile.rdbuf()->pubsetbuf(io_buffer.dataPtr(), io_buffer.size());
1012
1013 int old_prec(0);
1014
1015 if (ParallelDescriptor::IOProcessor()) {
1016 //
1017 // Only the IOProcessor() writes to the header file.
1018 //
1019 HeaderFile.open(HeaderFileName.c_str(), std::ios::out | std::ios::trunc |
1020 std::ios::binary);
1021 if ( ! HeaderFile.good()) {
1022 amrex::FileOpenFailed(HeaderFileName);
1023 }
1024 old_prec = static_cast<int>(HeaderFile.precision(15));
1025 }

Callers

nothing calls this directly

Calls 15

secondFunction · 0.85
UseAsyncOutFunction · 0.85
BarrierFunction · 0.85
IOProcessorFunction · 0.85
IOProcessorNumberFunction · 0.85
PrintClass · 0.85
AbortFunction · 0.85
TryFileOutputMethod · 0.80
CreateLevelDirectoryMethod · 0.80
writePlotFilePreMethod · 0.80
writePlotFilePostMethod · 0.80
ReduceRealMaxFunction · 0.50

Tested by

no test coverage detected