Skip to content

Commit

Permalink
only do rename on IOProcessor
Browse files Browse the repository at this point in the history
  • Loading branch information
asalmgren committed Jan 12, 2024
1 parent f0a9d39 commit 86c6b09
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions Source/IO/NCPlotFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,18 @@ REMORA::WriteNCPlotFile(int which_step) const

//
// Check if this file/directory already exists and if so,
// move the existing file/directory to filename.old
// have the IOProcessor move the existing
// file/directory to filename.old
//
if ( (!REMORA::write_history_file) || (which_step == 0) ) {
if (amrex::FileExists(FullPath)) {
std::string newoldname(FullPath + ".old." + amrex::UniqueString());
amrex::Print() << "WriteNCPlotFile: " << FullPath
<< " exists. Renaming to: " << newoldname << std::endl;
if (std::rename(FullPath.c_str(), newoldname.c_str())) {
amrex::Abort("WriteNCPlotfile:: std::rename failed");
if (amrex::ParallelDescriptor::IOProcessor()) {
if ( (!REMORA::write_history_file) || (which_step == 0) ) {
if (amrex::FileExists(FullPath)) {
std::string newoldname(FullPath + ".old." + amrex::UniqueString());
amrex::Print() << "WriteNCPlotFile: " << FullPath
<< " exists. Renaming to: " << newoldname << std::endl;
if (std::rename(FullPath.c_str(), newoldname.c_str())) {
amrex::Abort("WriteNCPlotfile:: std::rename failed");
}
}
}
}
Expand Down

0 comments on commit 86c6b09

Please sign in to comment.