Skip to content

Commit 49ea339

Browse files
authored
Retry a few times if directory creation fails (#4537)
This tries to fix the following error reported by @BenWibking Writing checkpoint chk02500 amrex::UtilCreateDirectory:: path errno: chk02500 :: File exists amrex::UtilCreateDirectory:: path errno: chk02500/Level_2 :: Input/output error amrex::Error::0::Couldn't create directory: chk02500/Level_2 !!!
1 parent 195fcf4 commit 49ea339

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

Src/Base/AMReX_Utility.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,13 @@ bool
116116
amrex::UtilCreateDirectory (const std::string& path,
117117
mode_t mode, bool verbose)
118118
{
119-
return FileSystem::CreateDirectories(path, mode, verbose);
119+
double sleep = 0.1;
120+
while (sleep < 2.0) {
121+
if (FileSystem::CreateDirectories(path, mode, verbose)) { return true; }
122+
amrex::Sleep(sleep);
123+
sleep *= 2;
124+
}
125+
return false;
120126
}
121127

122128
void

Src/Base/AMReX_VisMF.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,6 +1114,7 @@ VisMF::Write (const FabArray<FArrayBox>& mf,
11141114
nfi.Stream().write(allFabData, bytesWritten);
11151115
nfi.Stream().flush();
11161116
delete [] allFabData;
1117+
if (! nfi.Stream().good()) { amrex::Error("VisMF::Write failed"); }
11171118

11181119
} else { // ---- write fabs individually
11191120
for(MFIter mfi(mf); mfi.isValid(); ++mfi) {
@@ -1154,6 +1155,8 @@ VisMF::Write (const FabArray<FArrayBox>& mf,
11541155
if (!noFlushAfterWrite) {
11551156
nfi.Stream().flush();
11561157
}
1158+
1159+
if (! nfi.Stream().good()) { amrex::Error("VisMF::Write failed"); }
11571160
}
11581161
}
11591162

@@ -1485,6 +1488,8 @@ VisMF::readFAB (int idx,
14851488
#endif
14861489
}
14871490

1491+
if (!(infs->good())) { amrex::Error("VisMF::readFAB failed"); }
1492+
14881493
VisMF::CloseStream(FullName);
14891494

14901495
return fab;
@@ -1532,6 +1537,8 @@ VisMF::readFAB (FabArray<FArrayBox> &mf,
15321537
fab.readFrom(*infs);
15331538
}
15341539

1540+
if (!(infs->good())) { amrex::Error("VisMF::readFAB failed"); }
1541+
15351542
VisMF::CloseStream(FullName);
15361543
}
15371544

@@ -1831,6 +1838,8 @@ VisMF::Read (FabArray<FArrayBox> &mf,
18311838
}
18321839
}
18331840

1841+
if (! nfi.Stream().good()) { amrex::Error("VisMF::Read failed"); }
1842+
18341843
} // ---- end NFilesIter
18351844
}
18361845

@@ -2524,6 +2533,7 @@ VisMF::AsyncWriteDoit (const FabArray<FArrayBox>& mf, const std::string& mf_name
25242533
fabio->write(ofs, fab, 0, fab.nComp());
25252534
}
25262535
ofs.flush();
2536+
if (!ofs.good()) { amrex::Error("VisMF::AsyncWriteDoit failed"); }
25272537
ofs.close();
25282538
}
25292539

0 commit comments

Comments
 (0)