Merge pull request #1708 from blattms/warn-parallel-logging-fallout

Warn about parallel logging fallout only on request / Use uppercase logfiles

Fixes OPM/opm-common#606
This commit is contained in:
Bård Skaflestad
2019-01-17 16:13:25 +01:00
committed by GitHub
2 changed files with 61 additions and 22 deletions

View File

@@ -59,12 +59,14 @@ NEW_PROP_TAG(OutputMode);
NEW_PROP_TAG(EnableDryRun); NEW_PROP_TAG(EnableDryRun);
NEW_PROP_TAG(OutputInterval); NEW_PROP_TAG(OutputInterval);
NEW_PROP_TAG(UseAmg); NEW_PROP_TAG(UseAmg);
NEW_PROP_TAG(EnableLoggingFalloutWarning);
SET_STRING_PROP(EclFlowProblem, OutputMode, "all"); SET_STRING_PROP(EclFlowProblem, OutputMode, "all");
// TODO: enumeration parameters. we use strings for now. // TODO: enumeration parameters. we use strings for now.
SET_STRING_PROP(EclFlowProblem, EnableDryRun, "auto"); SET_STRING_PROP(EclFlowProblem, EnableDryRun, "auto");
// Do not merge parallel output files or warn about them
SET_BOOL_PROP(EclFlowProblem, EnableLoggingFalloutWarning, false);
SET_INT_PROP(EclFlowProblem, OutputInterval, 1); SET_INT_PROP(EclFlowProblem, OutputInterval, 1);
END_PROPERTIES END_PROPERTIES
@@ -106,6 +108,9 @@ namespace Opm
"Specify if the simulation ought to be actually run, or just pretended to be"); "Specify if the simulation ought to be actually run, or just pretended to be");
EWOMS_REGISTER_PARAM(TypeTag, int, OutputInterval, EWOMS_REGISTER_PARAM(TypeTag, int, OutputInterval,
"Specify the number of report steps between two consecutive writes of restart data"); "Specify the number of report steps between two consecutive writes of restart data");
EWOMS_REGISTER_PARAM(TypeTag, bool, EnableLoggingFalloutWarning,
"Developer option to see whether logging was on non-root processors. In that case it will be appended to the *.DBG or *.PRT files");
Simulator::registerParameters(); Simulator::registerParameters();
// register the parameters inherited from ebos // register the parameters inherited from ebos
@@ -310,10 +315,15 @@ namespace Opm
std::ostringstream debugFileStream; std::ostringstream debugFileStream;
std::ostringstream logFileStream; std::ostringstream logFileStream;
if (boost::to_upper_copy(path(fpath.extension()).string()) == ".DATA") { // Strip extension "." or ".DATA"
baseName = path(fpath.stem()).string(); std::string extension = boost::to_upper_copy(fpath.extension().string());
} else { if ( extension == ".DATA" || extension == "." )
baseName = path(fpath.filename()).string(); {
baseName = boost::to_upper_copy(fpath.stem().string());
}
else
{
baseName = boost::to_upper_copy(fpath.filename().string());
} }
const std::string& output_dir = eclState().getIOConfig().getOutputDir(); const std::string& output_dir = eclState().getIOConfig().getOutputDir();
@@ -414,9 +424,21 @@ namespace Opm
const std::string& output_dir = eclState().getIOConfig().getOutputDir(); const std::string& output_dir = eclState().getIOConfig().getOutputDir();
fs::path output_path(output_dir); fs::path output_path(output_dir);
fs::path deck_filename(EWOMS_GET_PARAM(TypeTag, std::string, EclDeckFileName)); fs::path deck_filename(EWOMS_GET_PARAM(TypeTag, std::string, EclDeckFileName));
std::string basename;
// Strip extension "." and ".DATA"
std::string extension = boost::to_upper_copy(deck_filename.extension().string());
if ( extension == ".DATA" || extension == "." )
{
basename = boost::to_upper_copy(deck_filename.stem().string());
}
else
{
basename = boost::to_upper_copy(deck_filename.filename().string());
}
std::for_each(fs::directory_iterator(output_path), std::for_each(fs::directory_iterator(output_path),
fs::directory_iterator(), fs::directory_iterator(),
detail::ParallelFileMerger(output_path, deck_filename.stem().string())); detail::ParallelFileMerger(output_path, basename,
EWOMS_GET_PARAM(TypeTag, bool, EnableLoggingFalloutWarning)));
} }
void setupEbosSimulator() void setupEbosSimulator()

View File

@@ -48,19 +48,24 @@ public:
/// \param output_dir The output directory to use for reading/Writing. /// \param output_dir The output directory to use for reading/Writing.
/// \param deckanme The name of the deck. /// \param deckanme The name of the deck.
ParallelFileMerger(const fs::path& output_dir, ParallelFileMerger(const fs::path& output_dir,
const std::string& deckname) const std::string& deckname,
bool show_fallout = false)
: debugFileRegex_(deckname+"\\.\\d+\\.DBG"), : debugFileRegex_(deckname+"\\.\\d+\\.DBG"),
logFileRegex_(deckname+"\\.\\d+\\.PRT"), logFileRegex_(deckname+"\\.\\d+\\.PRT"),
fileWarningRegex_(deckname+"\\.(\\d+)\\.[^.]+") fileWarningRegex_(deckname+"\\.(\\d+)\\.[^.]+"),
show_fallout_(show_fallout)
{ {
auto debugPath = output_dir; if ( show_fallout_ )
debugPath /= (deckname + ".DBG"); {
debugStream_.reset(new fs::ofstream(debugPath, auto debugPath = output_dir;
std::ofstream::app)); debugPath /= (deckname + ".DBG");
auto logPath = output_dir; debugStream_.reset(new fs::ofstream(debugPath,
logPath /= ( deckname + ".PRT"); std::ofstream::app));
logStream_.reset(new fs::ofstream(logPath, auto logPath = output_dir;
std::ofstream::app)); logPath /= ( deckname + ".PRT");
logStream_.reset(new fs::ofstream(logPath,
std::ofstream::app));
}
} }
void operator()(const fs::path& file) void operator()(const fs::path& file)
@@ -74,20 +79,30 @@ public:
if( boost::regex_match(filename, logFileRegex_) ) if( boost::regex_match(filename, logFileRegex_) )
{ {
appendFile(*logStream_, file, rank); if ( show_fallout_ ){
appendFile(*logStream_, file, rank);
}else{
fs::remove(file);
}
} }
else else
{ {
if (boost::regex_match(filename, debugFileRegex_) ) if (boost::regex_match(filename, debugFileRegex_) )
{ {
appendFile(*debugStream_, file, rank); if ( show_fallout_ ){
appendFile(*debugStream_, file, rank);
}else{
fs::remove(file);
}
} }
else else
{ {
std::cerr << "WARNING: Unrecognized file with name " if ( show_fallout_ ){
<< filename std::cerr << "WARNING: Unrecognized file with name "
<< " that might stem from a parallel run." << filename
<< std::endl; << " that might stem from a parallel run."
<< std::endl;
}
} }
} }
} }
@@ -129,6 +144,8 @@ private:
std::unique_ptr<fs::ofstream> debugStream_; std::unique_ptr<fs::ofstream> debugStream_;
/// \brief Stream to *.PRT file /// \brief Stream to *.PRT file
std::unique_ptr<fs::ofstream> logStream_; std::unique_ptr<fs::ofstream> logStream_;
/// \brief Whether to show any logging fallout
bool show_fallout_;
}; };
} // end namespace detail } // end namespace detail
} // end namespace OPM } // end namespace OPM