Skip to content

Commit

Permalink
Fix I/O bug in Amr class (#2609)
Browse files Browse the repository at this point in the history
The file stream for the header must be closed before the parent directory
can be renamed.

Closes #2608
  • Loading branch information
WeiqunZhang committed Jan 31, 2022
1 parent 6563835 commit 89153db
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Src/Amr/AMReX_Amr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1037,7 +1037,8 @@ Amr::writePlotFileDoit (std::string const& pltfile, bool regular)
} else {
ParallelDescriptor::Barrier("Amr::writePlotFile::end");
if(ParallelDescriptor::IOProcessor()) {
std::rename(pltfileTemp.c_str(), pltfile.c_str());
HeaderFile.close();
std::rename(pltfileTemp.c_str(), pltfile.c_str());
}
ParallelDescriptor::Barrier("Renaming temporary plotfile.");
//
Expand Down Expand Up @@ -1865,6 +1866,7 @@ Amr::checkPoint ()
} else {
ParallelDescriptor::Barrier("Amr::checkPoint::end");
if(ParallelDescriptor::IOProcessor()) {
HeaderFile.close();
std::rename(ckfileTemp.c_str(), ckfile.c_str());
}
ParallelDescriptor::Barrier("Renaming temporary checkPoint file.");
Expand Down

0 comments on commit 89153db

Please sign in to comment.