cosmetics

This commit is contained in:
Arne Morten Kvarving 2023-02-01 15:42:04 +01:00
parent 9d1cbd5389
commit cb14b1e690
2 changed files with 25 additions and 37 deletions

View File

@ -26,21 +26,18 @@
#include <fstream>
#include <iostream>
namespace Opm
{
namespace detail
{
namespace Opm {
namespace detail {
ParallelFileMerger::ParallelFileMerger(const fs::path& output_dir,
const std::string& deckname,
bool show_fallout)
: debugFileRegex_(deckname+"\\.\\d+\\.DBG"),
logFileRegex_(deckname+"\\.\\d+\\.PRT"),
fileWarningRegex_(deckname+"\\.(\\d+)\\.[^.]+"),
show_fallout_(show_fallout)
: debugFileRegex_(deckname+"\\.\\d+\\.DBG")
, logFileRegex_(deckname+"\\.\\d+\\.PRT")
, fileWarningRegex_(deckname+"\\.(\\d+)\\.[^.]+")
, show_fallout_(show_fallout)
{
if ( show_fallout_ )
{
if (show_fallout_) {
auto debugPath = output_dir;
debugPath /= (deckname + ".DBG");
debugStream_ = std::make_unique<std::ofstream>(debugPath,
@ -57,35 +54,28 @@ void ParallelFileMerger::operator()(const fs::path& file)
std::smatch matches;
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");
if( std::regex_match(filename, logFileRegex_) )
{
if ( show_fallout_ ){
if (std::regex_match(filename, logFileRegex_)) {
if (show_fallout_) {
appendFile(*logStream_, file, rank);
}else{
} else {
fs::remove(file);
}
}
else
{
if (std::regex_match(filename, debugFileRegex_) )
{
if ( show_fallout_ ){
} else {
if (std::regex_match(filename, debugFileRegex_)) {
if (show_fallout_) {
appendFile(*debugStream_, file, rank);
}else{
} else {
fs::remove(file);
}
}
else
{
if ( show_fallout_ ){
} else {
if (show_fallout_) {
std::cerr << "WARNING: Unrecognized file with name "
<< filename
<< " that might stem from a parallel run."
<< std::endl;
<< filename
<< " that might stem from a parallel run."
<< 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)
{
if( fs::file_size(file) )
{
if (fs::file_size(file)) {
std::cerr << "WARNING: There has been logging to file "
<< file.string() <<" by process "
<< rank << std::endl;

View File

@ -27,11 +27,8 @@
#include <regex>
#include <string>
namespace Opm
{
namespace detail
{
namespace Opm {
namespace detail {
namespace fs = ::std::filesystem;
@ -73,6 +70,8 @@ private:
/// \brief Whether to show any logging fallout
bool show_fallout_;
};
} // end namespace detail
} // end namespace Opm
#endif // end header guard