edit based on comments

This commit is contained in:
Rohith Nair 2017-05-17 17:46:10 +02:00
parent b95f4fb6a0
commit 59ec8a1bf5

View File

@ -24,10 +24,6 @@
#define OPM_FLOW_MAIN_EBOS_HEADER_INCLUDED #define OPM_FLOW_MAIN_EBOS_HEADER_INCLUDED
#include <sys/utsname.h> #include <sys/utsname.h>
#include <unistd.h>
#include <ctime>
#include <sys/statvfs.h>
#include <sys/sysinfo.h>
#include <opm/simulators/ParallelFileMerger.hpp> #include <opm/simulators/ParallelFileMerger.hpp>
#include <opm/simulators/ensureDirectoryExists.hpp> #include <opm/simulators/ensureDirectoryExists.hpp>
@ -329,50 +325,45 @@ namespace Opm
if ( output_cout_ ) if ( output_cout_ )
{ {
// Read Parameters. // Read Parameters.
OpmLog::debug("\n--------------- Reading parameters ---------------\n"); OpmLog::debug("\n--------------- Reading parameters ---------------\n");
} }
} }
void printPRTHeader() void printPRTHeader()
{ {
if ( output_cout_ ) // Print header for PRT file.
{ if ( output_cout_ ) {
// Print header for PRT file. const std::string version = moduleVersionName();
const std::string version = moduleVersionName(); const double megabyte = 1024 * 1024;
const double megabyte = 1024 * 1024; unsigned num_cpu = std::thread::hardware_concurrency();
unsigned num_cpu = std::thread::hardware_concurrency(); struct utsname arch;
struct utsname arch; const char* user = getlogin();
char userName[64] = {0}; time_t now = std::time(0);
int getUser = getlogin_r(userName, sizeof(userName)-1); struct tm tstruct;
time_t now = std::time(0); char tmstr[80];
struct tm tstruct; tstruct = *localtime(&now);
char tmstr[80]; strftime(tmstr, sizeof(tmstr), "%d-%m-%Y at %X", &tstruct);
tstruct = *localtime(&now); const double mem_size = getTotalSystemMemory() / megabyte;
strftime(tmstr, sizeof(tmstr), "%d-%m-%Y at %X", &tstruct); std::ostringstream ss;
struct sysinfo info; ss << "\n\n\n ######## # ###### # #\n";
sysinfo( &info ); ss << " # # # # # # \n";
const double mem_size = (size_t)info.totalram * (size_t)info.mem_unit / megabyte; ss << " ##### # # # # # # \n";
std::ostringstream ss; ss << " # # # # # # # # \n";
ss << "\n\n\n ######## # ###### # #\n"; ss << " # ####### ###### # # \n\n";
ss << " # # # # # # \n"; ss << "Flow is a simulator for fully implicit three-phase black-oil flow,";
ss << " ##### # # # # # # \n"; ss << " and is part of OPM.\nFor more information visit: http://opm-project.org \n\n";
ss << " # # # # # # # # \n"; ss << "Flow Version = " + version + "\n";
ss << " # ####### ###### # # \n\n"; if (uname(&arch) == 0) {
ss << "Flow is a simulator for fully implicit three-phase black-oil flow,"; ss << "System = " << arch.nodename << " (Number of cores: " << num_cpu;
ss << " and is part of OPM.\nFor more information visit: http://opm-project.org \n\n"; ss << ", RAM: " << std::fixed << std::setprecision (2) << mem_size << " MB) \n";
ss << "Flow Version = " + version + "\n"; ss << "Architecture = " << arch.sysname << " " << arch.machine << " (Release: " << arch.release;
if (uname(&arch) == 0) { ss << ", Version: " << arch.version << " )\n";
ss << "System = " << arch.nodename << " (Number of cores: " << num_cpu; }
ss << ", RAM: " << std::fixed << std::setprecision (2) << mem_size << " MB) \n"; if (user) {
ss << "Architecture = " << arch.sysname << " " << arch.machine << " (Release: " << arch.release; ss << "User = " << user << std::endl;
ss << ", Version: " << arch.version << " )\n"; }
} ss << "Simulation started on " << tmstr << " hrs\n";
if (getUser == 0) { OpmLog::note(ss.str());
char * userLogin = getlogin();
ss << "User = " << userLogin << std::endl;
}
ss << "Simulation started on " << tmstr << " hrs\n";
OpmLog::note(ss.str());
} }
} }
@ -779,6 +770,12 @@ namespace Opm
throw std::invalid_argument( "Cannot find input case " + casename ); 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) int64_t convertMessageType(const Message::type& mtype)
{ {