mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
cosmetics
This commit is contained in:
parent
9d1cbd5389
commit
cb14b1e690
@ -26,21 +26,18 @@
|
|||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
namespace Opm
|
namespace Opm {
|
||||||
{
|
namespace detail {
|
||||||
namespace detail
|
|
||||||
{
|
|
||||||
|
|
||||||
ParallelFileMerger::ParallelFileMerger(const fs::path& output_dir,
|
ParallelFileMerger::ParallelFileMerger(const fs::path& output_dir,
|
||||||
const std::string& deckname,
|
const std::string& deckname,
|
||||||
bool show_fallout)
|
bool show_fallout)
|
||||||
: 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)
|
, show_fallout_(show_fallout)
|
||||||
{
|
{
|
||||||
if ( show_fallout_ )
|
if (show_fallout_) {
|
||||||
{
|
|
||||||
auto debugPath = output_dir;
|
auto debugPath = output_dir;
|
||||||
debugPath /= (deckname + ".DBG");
|
debugPath /= (deckname + ".DBG");
|
||||||
debugStream_ = std::make_unique<std::ofstream>(debugPath,
|
debugStream_ = std::make_unique<std::ofstream>(debugPath,
|
||||||
@ -57,35 +54,28 @@ void ParallelFileMerger::operator()(const fs::path& file)
|
|||||||
std::smatch matches;
|
std::smatch matches;
|
||||||
std::string filename = file.filename().native();
|
std::string filename = file.filename().native();
|
||||||
|
|
||||||
if ( std::regex_match(filename, matches, fileWarningRegex_) )
|
if (std::regex_match(filename, matches, fileWarningRegex_)) {
|
||||||
{
|
|
||||||
std::string rank = std::regex_replace(filename, fileWarningRegex_, "$1");
|
std::string rank = std::regex_replace(filename, fileWarningRegex_, "$1");
|
||||||
|
|
||||||
if( std::regex_match(filename, logFileRegex_) )
|
if (std::regex_match(filename, logFileRegex_)) {
|
||||||
{
|
if (show_fallout_) {
|
||||||
if ( show_fallout_ ){
|
|
||||||
appendFile(*logStream_, file, rank);
|
appendFile(*logStream_, file, rank);
|
||||||
}else{
|
} else {
|
||||||
fs::remove(file);
|
fs::remove(file);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
if (std::regex_match(filename, debugFileRegex_)) {
|
||||||
{
|
if (show_fallout_) {
|
||||||
if (std::regex_match(filename, debugFileRegex_) )
|
|
||||||
{
|
|
||||||
if ( show_fallout_ ){
|
|
||||||
appendFile(*debugStream_, file, rank);
|
appendFile(*debugStream_, file, rank);
|
||||||
}else{
|
} else {
|
||||||
fs::remove(file);
|
fs::remove(file);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
if (show_fallout_) {
|
||||||
{
|
|
||||||
if ( show_fallout_ ){
|
|
||||||
std::cerr << "WARNING: Unrecognized file with name "
|
std::cerr << "WARNING: Unrecognized file with name "
|
||||||
<< filename
|
<< filename
|
||||||
<< " that might stem from a parallel run."
|
<< " that might stem from a parallel run."
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -94,8 +84,7 @@ void ParallelFileMerger::operator()(const fs::path& file)
|
|||||||
|
|
||||||
void ParallelFileMerger::appendFile(std::ofstream& of, const fs::path& file, const std::string& rank)
|
void ParallelFileMerger::appendFile(std::ofstream& of, const fs::path& file, const std::string& rank)
|
||||||
{
|
{
|
||||||
if( fs::file_size(file) )
|
if (fs::file_size(file)) {
|
||||||
{
|
|
||||||
std::cerr << "WARNING: There has been logging to file "
|
std::cerr << "WARNING: There has been logging to file "
|
||||||
<< file.string() <<" by process "
|
<< file.string() <<" by process "
|
||||||
<< rank << std::endl;
|
<< rank << std::endl;
|
||||||
|
@ -27,11 +27,8 @@
|
|||||||
#include <regex>
|
#include <regex>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
namespace Opm {
|
||||||
namespace Opm
|
namespace detail {
|
||||||
{
|
|
||||||
namespace detail
|
|
||||||
{
|
|
||||||
|
|
||||||
namespace fs = ::std::filesystem;
|
namespace fs = ::std::filesystem;
|
||||||
|
|
||||||
@ -73,6 +70,8 @@ private:
|
|||||||
/// \brief Whether to show any logging fallout
|
/// \brief Whether to show any logging fallout
|
||||||
bool show_fallout_;
|
bool show_fallout_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // end namespace detail
|
} // end namespace detail
|
||||||
} // end namespace Opm
|
} // end namespace Opm
|
||||||
|
|
||||||
#endif // end header guard
|
#endif // end header guard
|
||||||
|
Loading…
Reference in New Issue
Block a user