mirror of
https://github.com/OPM/opm-simulators.git
synced 2026-11-03 12:47:42 -06:00
Make ensureOutputDirExists() callable outside readDeck.cpp, and use it.
This is necessary because when using Damaris we must have the output dir ready when we initialize Damaris. In the existing code, this was ensured only from the setupLogging() call.
This commit is contained in:
1 parent
fae71df32d
commit
926c213628
3 files changed
+24
-18
No files matched your search
@@ -435,6 +435,7 @@ private:
|
||||
deckFilename = EWOMS_GET_PARAM(PreTypeTag, std::string, EclDeckFileName);
|
||||
outputDir = EWOMS_GET_PARAM(PreTypeTag, std::string, OutputDir);
|
||||
}
|
||||
ensureOutputDirExists(outputDir);
|
||||
|
||||
#if HAVE_DAMARIS
|
||||
enableDamarisOutput_ = EWOMS_GET_PARAM(PreTypeTag, bool, EnableDamarisOutput);
|
||||
|
||||
@@ -93,23 +93,6 @@ namespace {
|
||||
->setMessageLimiter(std::make_shared<Opm::MessageLimiter>(10, limits));
|
||||
}
|
||||
|
||||
void ensureOutputDirExists_(const std::string& cmdline_output_dir)
|
||||
{
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
if (! fs::is_directory(cmdline_output_dir)) {
|
||||
try {
|
||||
fs::create_directories(cmdline_output_dir);
|
||||
}
|
||||
catch (...) {
|
||||
throw std::runtime_error {
|
||||
fmt::format("Creation of output directory '{}' failed",
|
||||
cmdline_output_dir)
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void loadObjectsFromRestart(const Opm::Deck& deck,
|
||||
const Opm::Parser& parser,
|
||||
const Opm::ParseContext& parseContext,
|
||||
@@ -376,6 +359,24 @@ namespace {
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
void Opm::ensureOutputDirExists(const std::string& cmdline_output_dir)
|
||||
{
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
if (! fs::is_directory(cmdline_output_dir)) {
|
||||
try {
|
||||
fs::create_directories(cmdline_output_dir);
|
||||
}
|
||||
catch (...) {
|
||||
throw std::runtime_error {
|
||||
fmt::format("Creation of output directory '{}' failed",
|
||||
cmdline_output_dir)
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Setup the OpmLog backends
|
||||
Opm::FileOutputMode
|
||||
Opm::setupLogging(const int mpi_rank_,
|
||||
@@ -387,7 +388,7 @@ Opm::setupLogging(const int mpi_rank_,
|
||||
const bool allRanksDbgLog)
|
||||
{
|
||||
if (!cmdline_output_dir.empty()) {
|
||||
ensureOutputDirExists_(cmdline_output_dir);
|
||||
ensureOutputDirExists(cmdline_output_dir);
|
||||
}
|
||||
|
||||
// create logFile
|
||||
|
||||
@@ -57,6 +57,10 @@ enum class FileOutputMode {
|
||||
OUTPUT_ALL = 3,
|
||||
};
|
||||
|
||||
// Ensure that a directory exists, creating it if it does not.
|
||||
void
|
||||
ensureOutputDirExists(const std::string& cmdline_output_dir);
|
||||
|
||||
// Setup the OpmLog backends
|
||||
FileOutputMode
|
||||
setupLogging(int mpi_rank_,
|
||||
|
||||
Reference in new issue
Block a user