Skip to content

Commit 89153db

Browse files
authored
Fix I/O bug in Amr class (#2609)
The file stream for the header must be closed before the parent directory can be renamed. Closes #2608
1 parent 6563835 commit 89153db

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Src/Amr/AMReX_Amr.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1037,7 +1037,8 @@ Amr::writePlotFileDoit (std::string const& pltfile, bool regular)
10371037
} else {
10381038
ParallelDescriptor::Barrier("Amr::writePlotFile::end");
10391039
if(ParallelDescriptor::IOProcessor()) {
1040-
std::rename(pltfileTemp.c_str(), pltfile.c_str());
1040+
HeaderFile.close();
1041+
std::rename(pltfileTemp.c_str(), pltfile.c_str());
10411042
}
10421043
ParallelDescriptor::Barrier("Renaming temporary plotfile.");
10431044
//
@@ -1865,6 +1866,7 @@ Amr::checkPoint ()
18651866
} else {
18661867
ParallelDescriptor::Barrier("Amr::checkPoint::end");
18671868
if(ParallelDescriptor::IOProcessor()) {
1869+
HeaderFile.close();
18681870
std::rename(ckfileTemp.c_str(), ckfile.c_str());
18691871
}
18701872
ParallelDescriptor::Barrier("Renaming temporary checkPoint file.");

0 commit comments

Comments
 (0)