mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Only warn and show parallel logging fallout on demand.
This commit adds an option that allows to enable detecting parallel logging fallout (option --enable-logging-fallout-warning). It is now false by default (previous behavior was as if the option was true). If option is true a warning will be printed for any process with nonzero rank that does try to log to *.PRT or *.DBG and the logged output will be appended to these files at the end.
This commit is contained in:
parent
52270e7ac7
commit
4b6144bb65
@ -58,12 +58,14 @@ NEW_PROP_TAG(OutputMode);
|
||||
NEW_PROP_TAG(EnableDryRun);
|
||||
NEW_PROP_TAG(OutputInterval);
|
||||
NEW_PROP_TAG(UseAmg);
|
||||
NEW_PROP_TAG(EnableLoggingFalloutWarning);
|
||||
|
||||
SET_STRING_PROP(EclFlowProblem, OutputMode, "all");
|
||||
|
||||
// TODO: enumeration parameters. we use strings for now.
|
||||
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);
|
||||
|
||||
END_PROPERTIES
|
||||
@ -106,6 +108,9 @@ namespace Opm
|
||||
"Specify if the simulation ought to be actually run, or just pretended to be");
|
||||
EWOMS_REGISTER_PARAM(TypeTag, int, OutputInterval,
|
||||
"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();
|
||||
|
||||
ISTLSolverType::registerParameters();
|
||||
@ -422,10 +427,11 @@ namespace Opm
|
||||
const std::string& output_dir = eclState().getIOConfig().getOutputDir();
|
||||
fs::path output_path(output_dir);
|
||||
fs::path deck_filename(EWOMS_GET_PARAM(TypeTag, std::string, EclDeckFileName));
|
||||
std::string basename = boost::to_upper_copy(deck_filename.stem().string());
|
||||
std::string basename = boost::to_upper_copy(fs::path(deck_filename).stem().string());
|
||||
std::for_each(fs::directory_iterator(output_path),
|
||||
fs::directory_iterator(),
|
||||
detail::ParallelFileMerger(output_path, basename));
|
||||
detail::ParallelFileMerger(output_path, basename,
|
||||
EWOMS_GET_PARAM(TypeTag, bool, EnableLoggingFalloutWarning));
|
||||
}
|
||||
|
||||
void setupEbosSimulator()
|
||||
|
@ -48,10 +48,15 @@ public:
|
||||
/// \param output_dir The output directory to use for reading/Writing.
|
||||
/// \param deckanme The name of the deck.
|
||||
ParallelFileMerger(const fs::path& output_dir,
|
||||
const std::string& deckname)
|
||||
const std::string& deckname,
|
||||
bool show_fallout = false)
|
||||
: debugFileRegex_(deckname+"\\.\\d+\\.DBG"),
|
||||
logFileRegex_(deckname+"\\.\\d+\\.PRT"),
|
||||
fileWarningRegex_(deckname+"\\.(\\d+)\\.[^.]+")
|
||||
fileWarningRegex_(deckname+"\\.(\\d+)\\.[^.]+"),
|
||||
show_fallout_(show_fallout)
|
||||
{
|
||||
std::cout<<"show_fallout="<<show_fallout_<<" "<<deckname<<std::endl;
|
||||
if ( show_fallout_ )
|
||||
{
|
||||
auto debugPath = output_dir;
|
||||
debugPath /= (deckname + ".DBG");
|
||||
@ -62,6 +67,7 @@ public:
|
||||
logStream_.reset(new fs::ofstream(logPath,
|
||||
std::ofstream::app));
|
||||
}
|
||||
}
|
||||
|
||||
void operator()(const fs::path& file)
|
||||
{
|
||||
@ -74,16 +80,26 @@ public:
|
||||
|
||||
if( boost::regex_match(filename, logFileRegex_) )
|
||||
{
|
||||
if ( show_fallout_ ){
|
||||
appendFile(*logStream_, file, rank);
|
||||
}else{
|
||||
fs::remove(filename);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (boost::regex_match(filename, debugFileRegex_) )
|
||||
{
|
||||
if ( show_fallout_ ){
|
||||
appendFile(*debugStream_, file, rank);
|
||||
}else
|
||||
{
|
||||
fs::remove(filename);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( show_fallout_ ){
|
||||
std::cerr << "WARNING: Unrecognized file with name "
|
||||
<< filename
|
||||
<< " that might stem from a parallel run."
|
||||
@ -92,6 +108,7 @@ public:
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private:
|
||||
/// \brief Append contents of a file to a stream
|
||||
/// \brief of The output stream to use.
|
||||
@ -129,6 +146,8 @@ private:
|
||||
std::unique_ptr<fs::ofstream> debugStream_;
|
||||
/// \brief Stream to *.PRT file
|
||||
std::unique_ptr<fs::ofstream> logStream_;
|
||||
/// \brief Whether to show any logging fallout
|
||||
bool show_fallout_;
|
||||
};
|
||||
} // end namespace detail
|
||||
} // end namespace OPM
|
||||
|
Loading…
Reference in New Issue
Block a user