From 53f2a13eb9b2ef36e53ec044bc645e0d90735256 Mon Sep 17 00:00:00 2001 From: Rohith Nair Date: Tue, 9 May 2017 13:58:21 +0200 Subject: [PATCH 1/4] Adds header for .PRT file with the following information 1. Flow binary information 2. host names(s)/ machine names 3. host hardware 4. Operating system 5. User 6. System time and date --- opm/autodiff/FlowMainEbos.hpp | 72 ++++++++++++++++++++++++++++++++--- 1 file changed, 66 insertions(+), 6 deletions(-) mode change 100644 => 100755 opm/autodiff/FlowMainEbos.hpp diff --git a/opm/autodiff/FlowMainEbos.hpp b/opm/autodiff/FlowMainEbos.hpp old mode 100644 new mode 100755 index 354e853b9..164a9749b --- a/opm/autodiff/FlowMainEbos.hpp +++ b/opm/autodiff/FlowMainEbos.hpp @@ -23,6 +23,13 @@ #ifndef OPM_FLOW_MAIN_EBOS_HEADER_INCLUDED #define OPM_FLOW_MAIN_EBOS_HEADER_INCLUDED +#include +#include +#include +#include +#include +#include + #include #include @@ -116,6 +123,7 @@ namespace Opm setupEbosSimulator(); setupOutput(); setupLogging(); + printPRTHeader(); extractMessages(); setupGridAndProps(); runDiagnostics(); @@ -189,7 +197,8 @@ namespace Opm // Print startup message if on output rank. void printStartupMessage() - { + { + if (output_cout_) { const int lineLen = 70; const std::string version = moduleVersionName(); @@ -213,6 +222,7 @@ namespace Opm // Writes to: // param_ // Returns true if ok, false if not. + bool setupParameters(int argc, char** argv) { param_ = ParameterGroup(argc, argv, false, output_cout_); @@ -312,19 +322,64 @@ namespace Opm {Log::MessageType::Warning, msgLimits.getWarningPrintLimit(0)}, {Log::MessageType::Error, msgLimits.getErrorPrintLimit(0)}, {Log::MessageType::Problem, msgLimits.getProblemPrintLimit(0)}, - {Log::MessageType::Bug, msgLimits.getBugPrintLimit(0)}}; + {Log::MessageType::Bug, msgLimits.getBugPrintLimit(0)}, + {Log::MessageType::Probleminfo, msgLimits.getProbleminfoPrintLimit(0)}, + {Log::MessageType::Warninginfo, msgLimits.getWarninginfoPrintLimit(0)}}; prtLog->setMessageLimiter(std::make_shared()); prtLog->setMessageFormatter(std::make_shared(false)); streamLog->setMessageLimiter(std::make_shared(10, limits)); streamLog->setMessageFormatter(std::make_shared(true)); - // Read parameters. if ( output_cout_ ) - { - OpmLog::debug("\n--------------- Reading parameters ---------------\n"); + { + // Read Parameters. + OpmLog::debug("\n--------------- Reading parameters ---------------\n"); } } - + + void printPRTHeader() + { + if ( output_cout_ ) + { + // Print header for PRT file. + const std::string version = moduleVersionName(); + const double megabyte = 1024 * 1024; + unsigned num_cpu = std::thread::hardware_concurrency(); + struct utsname arch; + char userName[64] = {0}; + int getUser = getlogin_r(userName, sizeof(userName)-1); + time_t now = std::time(0); + struct tm tstruct; + char tmstr[80]; + tstruct = *localtime(&now); + strftime(tmstr, sizeof(tmstr), "%d-%m-%Y at %X", &tstruct); + struct sysinfo info; + sysinfo( &info ); + const double mem_size = (size_t)info.totalram * (size_t)info.mem_unit / megabyte; + std::ostringstream ss; + ss << "\n\n\n ######## # ###### # #\n"; + ss << " # # # # # # \n"; + ss << " ##### # # # # # # \n"; + ss << " # # # # # # # # \n"; + ss << " # ####### ###### # # \n\n"; + ss << "Flow is a simulator for fully implicit three-phase black-oil flow,"; + ss << " and is part of OPM.\nFor more information visit: http://opm-project.org \n\n"; + ss << "Flow Version = " + version + "\n"; + if (uname(&arch) == 0) { + ss << "System = " << arch.nodename << " (Number of cores: " << num_cpu; + ss << ", RAM: " << std::fixed << std::setprecision (2) << mem_size << " MB) \n"; + ss << "Architecture = " << arch.sysname << " " << arch.machine << " (Release: " << arch.release; + ss << ", Version: " << arch.version << " )\n"; + } + if (getUser == 0) { + char * userLogin = getlogin(); + ss << "User = " << userLogin << std::endl; + } + ss << "Simulation started on " << tmstr << " hrs\n"; + OpmLog::note(ss.str()); + } + } + void mergeParallelLogFiles() { // force closing of all log files. @@ -746,6 +801,10 @@ namespace Opm return Log::MessageType::Bug; case Message::type::Note: return Log::MessageType::Note; + case Message::type::Probleminfo: + return Log::MessageType::Probleminfo; + case Message::type::Warninginfo: + return Log::MessageType::Warninginfo; } throw std::logic_error("Invalid messages type!\n"); } @@ -793,3 +852,4 @@ namespace Opm } // namespace Opm #endif // OPM_FLOW_MAIN_EBOS_HEADER_INCLUDED + From 94da18514ff033ffb81878bd2202909a00801628 Mon Sep 17 00:00:00 2001 From: Rohith Nair Date: Tue, 9 May 2017 14:00:49 +0200 Subject: [PATCH 2/4] edit --- opm/autodiff/FlowMainEbos.hpp | 1 - 1 file changed, 1 deletion(-) diff --git a/opm/autodiff/FlowMainEbos.hpp b/opm/autodiff/FlowMainEbos.hpp index 164a9749b..679eb14e8 100755 --- a/opm/autodiff/FlowMainEbos.hpp +++ b/opm/autodiff/FlowMainEbos.hpp @@ -28,7 +28,6 @@ #include #include #include -#include #include #include From b95f4fb6a0da7a79238e9ad72fedab6ab36019f9 Mon Sep 17 00:00:00 2001 From: Rohith Nair Date: Tue, 9 May 2017 14:05:01 +0200 Subject: [PATCH 3/4] edit --- opm/autodiff/FlowMainEbos.hpp | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/opm/autodiff/FlowMainEbos.hpp b/opm/autodiff/FlowMainEbos.hpp index 679eb14e8..dbcb93994 100755 --- a/opm/autodiff/FlowMainEbos.hpp +++ b/opm/autodiff/FlowMainEbos.hpp @@ -221,7 +221,6 @@ namespace Opm // Writes to: // param_ // Returns true if ok, false if not. - bool setupParameters(int argc, char** argv) { param_ = ParameterGroup(argc, argv, false, output_cout_); @@ -321,9 +320,7 @@ namespace Opm {Log::MessageType::Warning, msgLimits.getWarningPrintLimit(0)}, {Log::MessageType::Error, msgLimits.getErrorPrintLimit(0)}, {Log::MessageType::Problem, msgLimits.getProblemPrintLimit(0)}, - {Log::MessageType::Bug, msgLimits.getBugPrintLimit(0)}, - {Log::MessageType::Probleminfo, msgLimits.getProbleminfoPrintLimit(0)}, - {Log::MessageType::Warninginfo, msgLimits.getWarninginfoPrintLimit(0)}}; + {Log::MessageType::Bug, msgLimits.getBugPrintLimit(0)}}; prtLog->setMessageLimiter(std::make_shared()); prtLog->setMessageFormatter(std::make_shared(false)); streamLog->setMessageLimiter(std::make_shared(10, limits)); @@ -800,10 +797,6 @@ namespace Opm return Log::MessageType::Bug; case Message::type::Note: return Log::MessageType::Note; - case Message::type::Probleminfo: - return Log::MessageType::Probleminfo; - case Message::type::Warninginfo: - return Log::MessageType::Warninginfo; } throw std::logic_error("Invalid messages type!\n"); } @@ -850,5 +843,4 @@ namespace Opm }; } // namespace Opm -#endif // OPM_FLOW_MAIN_EBOS_HEADER_INCLUDED - +#endif // OPM_FLOW_MAIN_EBOS_HEADER_INCLUDED \ No newline at end of file From 59ec8a1bf5f14f9c6471353abb2f8bd8eaa43554 Mon Sep 17 00:00:00 2001 From: Rohith Nair Date: Wed, 17 May 2017 17:46:10 +0200 Subject: [PATCH 4/4] edit based on comments --- opm/autodiff/FlowMainEbos.hpp | 89 +++++++++++++++++------------------ 1 file changed, 43 insertions(+), 46 deletions(-) diff --git a/opm/autodiff/FlowMainEbos.hpp b/opm/autodiff/FlowMainEbos.hpp index dbcb93994..ae9ab902a 100755 --- a/opm/autodiff/FlowMainEbos.hpp +++ b/opm/autodiff/FlowMainEbos.hpp @@ -24,10 +24,6 @@ #define OPM_FLOW_MAIN_EBOS_HEADER_INCLUDED #include -#include -#include -#include -#include #include #include @@ -197,7 +193,7 @@ namespace Opm // Print startup message if on output rank. void printStartupMessage() { - + if (output_cout_) { const int lineLen = 70; const std::string version = moduleVersionName(); @@ -329,50 +325,45 @@ namespace Opm if ( output_cout_ ) { // Read Parameters. - OpmLog::debug("\n--------------- Reading parameters ---------------\n"); + OpmLog::debug("\n--------------- Reading parameters ---------------\n"); } } void printPRTHeader() { - if ( output_cout_ ) - { - // Print header for PRT file. - const std::string version = moduleVersionName(); - const double megabyte = 1024 * 1024; - unsigned num_cpu = std::thread::hardware_concurrency(); - struct utsname arch; - char userName[64] = {0}; - int getUser = getlogin_r(userName, sizeof(userName)-1); - time_t now = std::time(0); - struct tm tstruct; - char tmstr[80]; - tstruct = *localtime(&now); - strftime(tmstr, sizeof(tmstr), "%d-%m-%Y at %X", &tstruct); - struct sysinfo info; - sysinfo( &info ); - const double mem_size = (size_t)info.totalram * (size_t)info.mem_unit / megabyte; - std::ostringstream ss; - ss << "\n\n\n ######## # ###### # #\n"; - ss << " # # # # # # \n"; - ss << " ##### # # # # # # \n"; - ss << " # # # # # # # # \n"; - ss << " # ####### ###### # # \n\n"; - ss << "Flow is a simulator for fully implicit three-phase black-oil flow,"; - ss << " and is part of OPM.\nFor more information visit: http://opm-project.org \n\n"; - ss << "Flow Version = " + version + "\n"; - if (uname(&arch) == 0) { - ss << "System = " << arch.nodename << " (Number of cores: " << num_cpu; - ss << ", RAM: " << std::fixed << std::setprecision (2) << mem_size << " MB) \n"; - ss << "Architecture = " << arch.sysname << " " << arch.machine << " (Release: " << arch.release; - ss << ", Version: " << arch.version << " )\n"; - } - if (getUser == 0) { - char * userLogin = getlogin(); - ss << "User = " << userLogin << std::endl; - } - ss << "Simulation started on " << tmstr << " hrs\n"; - OpmLog::note(ss.str()); + // Print header for PRT file. + if ( output_cout_ ) { + const std::string version = moduleVersionName(); + const double megabyte = 1024 * 1024; + unsigned num_cpu = std::thread::hardware_concurrency(); + struct utsname arch; + const char* user = getlogin(); + time_t now = std::time(0); + struct tm tstruct; + char tmstr[80]; + tstruct = *localtime(&now); + strftime(tmstr, sizeof(tmstr), "%d-%m-%Y at %X", &tstruct); + const double mem_size = getTotalSystemMemory() / megabyte; + std::ostringstream ss; + ss << "\n\n\n ######## # ###### # #\n"; + ss << " # # # # # # \n"; + ss << " ##### # # # # # # \n"; + ss << " # # # # # # # # \n"; + ss << " # ####### ###### # # \n\n"; + ss << "Flow is a simulator for fully implicit three-phase black-oil flow,"; + ss << " and is part of OPM.\nFor more information visit: http://opm-project.org \n\n"; + ss << "Flow Version = " + version + "\n"; + if (uname(&arch) == 0) { + ss << "System = " << arch.nodename << " (Number of cores: " << num_cpu; + ss << ", RAM: " << std::fixed << std::setprecision (2) << mem_size << " MB) \n"; + ss << "Architecture = " << arch.sysname << " " << arch.machine << " (Release: " << arch.release; + ss << ", Version: " << arch.version << " )\n"; + } + if (user) { + ss << "User = " << user << std::endl; + } + ss << "Simulation started on " << tmstr << " hrs\n"; + OpmLog::note(ss.str()); } } @@ -778,7 +769,13 @@ namespace Opm throw std::invalid_argument( "Cannot find input case " + casename ); } - + + unsigned long long getTotalSystemMemory() + { + long pages = sysconf(_SC_PHYS_PAGES); + long page_size = sysconf(_SC_PAGE_SIZE); + return pages * page_size; + } int64_t convertMessageType(const Message::type& mtype) { @@ -843,4 +840,4 @@ namespace Opm }; } // namespace Opm -#endif // OPM_FLOW_MAIN_EBOS_HEADER_INCLUDED \ No newline at end of file +#endif // OPM_FLOW_MAIN_EBOS_HEADER_INCLUDED