Flow123d  master-f44eb46
application.cc
Go to the documentation of this file.
1 /*!
2  *
3  * Copyright (C) 2015 Technical University of Liberec. All rights reserved.
4  *
5  * This program is free software; you can redistribute it and/or modify it under
6  * the terms of the GNU General Public License version 3 as published by the
7  * Free Software Foundation. (http://www.gnu.org/licenses/gpl-3.0.en.html)
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12  *
13  *
14  * @file application_base.cc
15  * @brief
16  */
17 
18 #include "application.hh"
19 
20 #include "system/sys_profiler.hh"
21 #include "system/logger_options.hh"
22 #include "system/file_path.hh"
23 #include "system/system.hh"
24 #include <signal.h>
25 #include <iostream>
26 
27 #ifdef FLOW123D_HAVE_PETSC
28 //#include <petsc.h>
29 #include <petscsys.h>
30 #include <petsc/private/petscimpl.h> /* to gain access to the private PetscVFPrintf */
31 #endif
32 
33 #ifdef FLOW123D_HAVE_PERMON
34 #include <permonsys.h>
35 #endif
36 
37 #include <string.h> // for strsignal
38 
39 #include <iostream> // for cout
40 #include <sstream> // for operator<<, endl
41 #include "mpi.h" // for MPI_Comm_size
42 #include "petscerror.h" // for CHKERRQ, Petsc...
43 #include "system/exc_common.hh" // for ExcAssertMsg
44 #include "system/asserts.hh" // for ASSERT_PERMANENT, msg
45 #include "system/logger.hh" // for Logger, operat...
46 #include "system/system.hh" // for SystemInfo
47 
48 
49 
50 
51 /// Function that catches all program signals.
52 /// Note: context variable required by PETSc function PetscPushSignalHandler
53 PetscErrorCode petsc_signal_handler(int signal, FMT_UNUSED void *context)
54 {
55  if (signal == SIGINT) {
56  cout << "SIGINT\n";
57  }
58  if (signal == SIGFPE || // FPE: Floating Point Exception,probably divide by zero
59  signal == SIGILL || // Illegal instruction: Likely due to memory corruption
60  signal == SIGPIPE || // Broken Pipe: Likely while reading or writing to a socket
61  signal == SIGSEGV ) // SEGV: Segmentation Violation, probably memory access out of range
62  {
63  // Signals handled by us.
64  THROW( ExcSignal() << EI_Signal(signal) << EI_SignalName(strsignal(signal)) );
65  } else {
66  return PetscSignalHandlerDefault(signal,(void*)0);
67  }
68  return 0;
69 }
70 
71 void system_signal_handler(int signal) {
72  petsc_signal_handler(signal, nullptr);
73 }
74 
75 
77 : log_filename_(""),
78  signal_handler_off_(false),
79  problem_(nullptr),
80  main_input_filename_(""),
81  //passed_argc_(0),
82  //passed_argv_(0),
83  use_profiler(true),
84  profiler_path(""),
85  yaml_balance_output_(false)
86 
87 {
88  // initialize python stuff if we have
89  // nonstandard python home (release builds)
90  PythonLoader::initialize();
91 
92 }
93 
94 
95 
96 
99 
100 
101 void Application::system_init( MPI_Comm comm, const string &log_filename ) {
102  int ierr;
103 
104  sys_info.comm=comm;
105 
106 
107  //Xio::init(); //Initialize XIO library
108 
109  // TODO : otevrit docasne log file jeste pred ctenim vstupu (kvuli zachyceni chyb), po nacteni dokoncit
110  // inicializaci systemu
111 
112  ierr=MPI_Comm_rank(comm, &(sys_info.my_proc));
113  ierr+=MPI_Comm_size(comm, &(sys_info.n_proc));
115  ASSERT_PERMANENT( ierr == MPI_SUCCESS ).error("MPI not initialized.\n");
116 
117  // determine logfile name or switch it off
118  stringstream log_name;
119 
120  if ( log_filename == "//" ) {
121  // -l option without given name -> turn logging off
122  sys_info.log=NULL;
124  } else {
125  // construct full log name
126  //log_name << log_filename << "." << sys_info.my_proc << ".old.log";
127 
128  //sys_info.log_fname = FilePath(log_name.str(), FilePath::output_file);
129  //sys_info.log=xfopen(sys_info.log_fname.c_str(),"wt");
130 
132  }
133 
136 }
137 
138 
139 FILE *Application::petsc_output_ =NULL;
140 
141 #ifdef FLOW123D_HAVE_PETSC
142 PetscErrorCode Application::petscvfprintf(FILE *fd, const char format[], va_list Argp) {
143  PetscErrorCode ierr;
144 
145  PetscFunctionBegin;
146  if (fd != stdout && fd != stderr) { /* handle regular files */
147  ierr = PetscVFPrintfDefault(fd,format,Argp); CHKERRQ(ierr);
148  } else {
149  const int buf_size = 65000;
150  char buff[65000];
151  size_t length;
152  ierr = PetscVSNPrintf(buff,buf_size,format,&length,Argp);CHKERRQ(ierr);
153 
154  /* now send buff to whatever stream or whatever you want */
155  fwrite(buff, sizeof(char), length, petsc_output_);
156  }
157  PetscFunctionReturn(0);
158 }
159 #endif
160 
161 
162 void Application::petsc_initialize(int argc, char ** argv) {
163 #ifdef FLOW123D_HAVE_PETSC
164  if (petsc_redirect_file_ != "") {
165  petsc_output_ = fopen(petsc_redirect_file_.c_str(), "w");
166  if (! petsc_output_)
167  THROW(FilePath::ExcFileOpen() << FilePath::EI_Path(petsc_redirect_file_));
168  PetscVFPrintf = this->petscvfprintf;
169  }
170 
171 
172  PetscInitialize(&argc,&argv,PETSC_NULL,PETSC_NULL);
173  if (! signal_handler_off_) {
174  // PETSc do not catch SIGINT, but someone on the way does, we try to fix it.
175  signal(SIGINT, system_signal_handler);
176  PetscPushSignalHandler(petsc_signal_handler, nullptr);
177  }
178 
179  int mpi_size;
180  MPI_Comm_size(PETSC_COMM_WORLD, &mpi_size);
181  MessageOut() << "MPI size: " << mpi_size << std::endl;
182 #endif
183 }
184 
185 
186 
188 #ifdef FLOW123D_HAVE_PETSC
189  if ( petsc_initialized )
190  {
191  PetscErrorCode ierr=0;
192 
193  ierr = PetscFinalize(); CHKERRQ(ierr);
194 
195  if (petsc_output_) fclose(petsc_output_);
196 
197  petsc_initialized = false;
198 
199  return ierr;
200  }
201 #endif
202 
203  return 0;
204 }
205 
206 
207 void Application::permon_initialize(int argc, char ** argv) {
208 #ifdef FLOW123D_HAVE_PERMON
209  PermonInitialize(&argc,&argv,PETSC_NULL,PETSC_NULL);
210 #endif
211 }
212 
214 #ifdef FLOW123D_HAVE_PERMON
215  if ( permon_initialized )
216  {
217  PetscErrorCode ierr=0;
218 
219  ierr = PermonFinalize(); CHKERRQ(ierr);
220 
221  permon_initialized = false;
222 
223  return ierr;
224  }
225 #endif
226 
227  return 0;
228 }
229 
230 
231 #include "rev_num.h"
232 
233 /// named version of the program
234 //#define _PROGRAM_VERSION_ "0.0.0"
235 
236 //#ifndef _PROGRAM_REVISION_
237 // #define _PROGRAM_REVISION_ "(unknown revision)"
238 //#endif
239 
240 //#ifndef _PROGRAM_BRANCH_
241 // #define _PROGRAM_BRANCH_ "(unknown branch)"
242 //#endif
243 
244 #ifndef FLOW123D_COMPILER_FLAGS_
245  #define FLOW123D_COMPILER_FLAGS_ "(unknown compiler flags)"
246 #endif
247 
248 
249 namespace it = Input::Type;
250 
252  Input::Type::RevNumData rev_num_data;
253 
254  rev_num_data.version = string(FLOW123D_VERSION_NAME_);
255  rev_num_data.revision = string(FLOW123D_GIT_REVISION_);
256  rev_num_data.branch = string(FLOW123D_GIT_BRANCH_);
257  rev_num_data.url = string(FLOW123D_GIT_URL_);
258 
259  return rev_num_data;
260 }
261 
262 
263 // this should be part of a system class containing all support information
265  static it::Record type = it::Record("Root", "Root record of JSON input for Flow123d.")
266  .declare_key("flow123d_version", it::String(), it::Default::obligatory(),
267  "Version of Flow123d for which the input file was created."
268  "Flow123d only warn about version incompatibility. "
269  "However, external tools may use this information to provide conversion "
270  "of the input file to the structure required by another version of Flow123d.")
272  "Simulation problem to be solved.")
273  .declare_key("pause_after_run", it::Bool(), it::Default("false"),
274  "If true, the program will wait for key press before it terminates.")
275  .close();
276 
277  return type;
278 }
279 
280 
281 
282 
283 
284 
285 
287  // Say Hello
288  // make strings from macros in order to check type
289  Input::Type::RevNumData rev_num_data = get_rev_num_data();
290 
291 
292  string build = string(__DATE__) + ", " + string(__TIME__)
293  + " flags: " + string(FLOW123D_COMPILER_FLAGS_);
294 
295 
296  MessageOut().fmt("This is Flow123d, version {} commit: {}\n",
297  rev_num_data.version, rev_num_data.revision);
298  MessageOut().fmt("Branch: {}\nBuild: {}\nFetch URL: {}\n",
299  rev_num_data.branch, build, rev_num_data.url );
300 
301 }
302 
303 
304 
306  if (main_input_filename_ == "") {
307  cout << "Usage error: The main input file has to be specified through -s parameter.\n\n";
308  cout << program_arguments_desc_ << "\n";
309  exit( exit_failure );
310  }
311 
312  // read main input file
313  FilePath fpath(main_input_filename_, FilePath::FileType::input_file);
314 
315  Input::ReaderToStorage json_reader(fpath, get_input_type() );
317 
318  return root_record;
319 }
320 
321 
322 
323 void Application::parse_cmd_line(const int argc, char ** argv) {
324  namespace po = boost::program_options;
325 
326 
327 
328  // Declare the supported options.
329  po::options_description desc("Allowed options");
330  desc.add_options()
331  ("help", "produce help message")
332  ("solve,s", po::value< string >(), "Main input file to solve.")
333  ("input_dir,i", po::value< string >()->default_value("input"), "Directory for the $INPUT_DIR$ placeholder in the main input file.")
334  ("output_dir,o", po::value< string >()->default_value("output"), "Directory for all produced output files.")
335  ("log,l", po::value< string >()->default_value("flow123"), "Set base name for log files.")
336  ("version", "Display version and build information and exit.")
337  ("no_log", "Turn off logging.")
338  ("no_signal_handler", "Turn off signal handling. Useful for debugging with valgrind.")
339  ("no_profiler,no-profiler", "Turn off profiler output.")
340  ("profiler_path,profiler-path", po::value< string >(), "Path to the profiler file")
341  ("input_format", po::value< string >(), "Writes full structure of the main input file into given file.")
342  ("petsc_redirect", po::value<string>(), "Redirect all PETSc stdout and stderr to given file.")
343  ("yaml_balance", "Redirect balance output to YAML format too (simultaneously with the selected balance output format).");
344 
345 
346 
347  // Can not use positional arguments together with PETSC options.
348  // Use our own solution trying to use the first unrecognized option as the main input file.
349 
350  // parse the command line
351  po::variables_map vm;
352  auto parser = po::basic_command_line_parser<char>(argc, argv)
353  .options(desc)
354  .allow_unregistered();
355  po::parsed_options parsed = parser.run();
356  po::store(parsed, vm);
357  po::notify(vm);
358 
359 
360  // get unknown options
361  vector<string> to_pass_further = po::collect_unrecognized(parsed.options, po::include_positional);
362 
363 
364 
365  /*
366  passed_argc_ = to_pass_further.size();
367  passed_argv_ = new char * [passed_argc_+1];
368 
369  // first copy the program executable in argv[0]
370  int arg_i=0;
371  if (argc > 0) passed_argv_[arg_i++] = xstrcpy( argv[0] );
372 
373  for(int i=0; i < passed_argc_; i++) {
374  passed_argv_[arg_i++] = xstrcpy( to_pass_further[i].c_str() );
375  }
376  passed_argc_ = arg_i;
377  */
378 
379  // possibly turn off profilling
380  if (vm.count("no_profiler")) {
381  use_profiler=false;
382  }
383 
384  if (vm.count("profiler_path")) {
385  profiler_path = vm["profiler_path"].as<string>();
386  }
387 
388  // if there is "help" option
389  if (vm.count("help")) {
390  display_version();
391  cout << endl;
392  cout << "Usage:" << endl;
393  cout << " flow123d -s <main_input>.yaml <other options> <PETSC options>" << endl;
394  cout << " flow123d <main_input>.yaml <other options> <PETSC options>" << endl;
395  cout << desc << "\n";
396  THROW(ExcNoRunOption());
397  }
398 
399 
400  if (vm.count("version")) {
401  display_version();
402  THROW(ExcNoRunOption());
403  }
404 
405 
406 
407  // if there is "input_format" option
408  if (vm.count("input_format")) {
409  // write ist to json file
410  ofstream json_stream;
411  FilePath(vm["input_format"].as<string>(), FilePath::output_file).open_stream(json_stream);
412  // create the root Record
413  it::Record root_type = get_input_type();
414  root_type.finish();
416  json_stream << Input::Type::OutputJSONMachine( root_type, get_rev_num_data() );
417  json_stream.close();
418  THROW(ExcNoRunOption());
419  }
420 
421 
422  if (vm.count("petsc_redirect")) {
423  this->petsc_redirect_file_ = vm["petsc_redirect"].as<string>();
424  }
425 
426  if (vm.count("no_signal_handler")) {
427  this->signal_handler_off_ = true;
428  }
429 
430  // if there is "solve" option
431  string input_filename = "";
432 
433  // check for positional main input file
434  if (to_pass_further.size()) {
435  string file_candidate = to_pass_further[0];
436  if (file_candidate[0] != '-') {
437  // pop the first option
438  input_filename = file_candidate;
439  to_pass_further.erase(to_pass_further.begin());
440  }
441  }
442 
443 
444  if (vm.count("solve")) {
445  input_filename = vm["solve"].as<string>();
446  }
447 
448 
449  if (input_filename == "")
450  THROW(ExcMessage() << EI_Message("Main input file not specified (option -s)."));
451 
452  // preserves output of balance in YAML format
453  if (vm.count("yaml_balance")) Balance::set_yaml_output();
454 
455  string input_dir;
456  string output_dir;
457  if (vm.count("input_dir")) {
458  input_dir = vm["input_dir"].as<string>();
459  }
460  if (vm.count("output_dir")) {
461  output_dir = vm["output_dir"].as<string>();
462  }
463 
464 
465 
466  // assumes working directory "."
467  try {
468  main_input_filename_ = FilePath::set_dirs_from_input(input_filename, input_dir, output_dir );
469  } catch (FilePath::ExcMkdirFail &e) {
470  use_profiler = false; // avoid profiler output
471  throw e;
472  }
473 
474  if (vm.count("log")) {
475  this->log_filename_ = vm["log"].as<string>();
476  }
477 
478  if (vm.count("no_log")) {
479  this->log_filename_="//"; // override; do not open log files
480  }
481 
482  ostringstream tmp_stream(program_arguments_desc_);
483  tmp_stream << desc;
484  // TODO: catch specific exceptions and output usage messages
485 }
486 
487 /**
488  * Contains basic structure of application (initialization, run and finalization).
489  * Method is call after constructor and allows to call virtual methods.
490  */
491 
492 void Application::init(int argc, char ** argv) {
493  // parse our own command line arguments, leave others for PETSc
494 
495  this->parse_cmd_line(argc, argv);
496 
497  string build = string(__DATE__) + ", " + string(__TIME__)
498  + " flags: " + string(FLOW123D_COMPILER_FLAGS_);
499 
500  Input::Type::RevNumData rev_num_data = get_rev_num_data();
501  Profiler::instance()->set_program_info("Flow123d",
502  rev_num_data.version, rev_num_data.branch, rev_num_data.revision, build);
503 
504  //Profiler::instance();
505 
506  armadillo_setup(); // set catching armadillo exceptions and reporting stacktrace
507 
508  this->petsc_initialize(argc, argv);
509  petsc_initialized = true;
510 
511  this->permon_initialize(argc, argv);
512  permon_initialized = true;
513 
514  this->system_init(PETSC_COMM_WORLD, log_filename_); // Petsc, open log, read ini file
515 
516 
517 }
518 
519 
520 
522  START_TIMER("Application::run");
523  display_version();
524 
525  START_TIMER("Read Input");
526  // get main input record handle
527  Input::Record i_rec = read_input();
528  END_TIMER("Read Input");
529 
530  {
531  using namespace Input;
532  // check input file version against the version of executable
533  std::regex version_re("([^.]*)[.]([^.]*)[.]([^.]*)");
534  std::smatch match;
535  std::string version(FLOW123D_VERSION_NAME_);
536  vector<string> ver_fields(3);
537  if ( std::regex_match(version, match, version_re) ) {
538  ver_fields[0]=match[1];
539  ver_fields[1]=match[2];
540  ver_fields[2]=match[3];
541  } else {
542  ASSERT_PERMANENT(0)(version).error("Bad Flow123d version format\n");
543  }
544 
545  std::string input_version = i_rec.val<string>("flow123d_version");
546  vector<string> iver_fields(3);
547  if ( std::regex_match(input_version, match, version_re) ) {
548  iver_fields[0]=match[1];
549  iver_fields[1]=match[2];
550  iver_fields[2]=match[3];
551  } else {
552  THROW( ExcVersionFormat() << EI_InputVersionStr(input_version) );
553  }
554 
555  if ( iver_fields[0] != ver_fields[0] || iver_fields[1] > ver_fields[1] ) {
556  WarningOut().fmt("Input file with version: '{}' is no compatible with the program version: '{}' \n",
557  input_version, version);
558  }
559 
560  // should flow123d wait for pressing "Enter", when simulation is completed
561  sys_info.pause_after_run = i_rec.val<bool>("pause_after_run");
562  // read record with problem configuration
563  Input::AbstractRecord i_problem = i_rec.val<AbstractRecord>("problem");
564 
565  if (i_problem.type() == HC_ExplicitSequential::get_input_type() ) {
566 
567  problem_ = new HC_ExplicitSequential(i_problem);
568 
569  // run simulation
571  } else {
572  THROW( ExcUnknownProblem() );
573  }
574 
575  }
576 
577  this->after_run();
578 }
579 
580 
581 
582 
585  printf("\nPress <ENTER> for closing the window\n");
586  getchar();
587  }
588 }
589 
590 
591 void _transform_profiler_data (const string &json_filepath, const string &output_file_suffix, const string &formatter) {
592  namespace py = pybind11;
593 
594  if (json_filepath == "") return;
595 
596  // grab module and function by importing module profiler_formatter_module.py
597  auto python_module = PythonLoader::load_module_by_name ("profiler.profiler_formatter_module");
598  //
599  // def convert (json_location, output_file, formatter):
600  //
601  auto convert_method = python_module.attr("convert");
602  // execute method with arguments
603  convert_method(json_filepath, (json_filepath + output_file_suffix), formatter);
604 
605 }
606 
607 
608 
609 
610 
612  if (problem_) delete problem_;
613 
614  if (use_profiler) {
615  // TODO: make a static output method that does nothing if the instance does not exist yet.
616  string profiler_json;
617  if (petsc_initialized) {
618  // log profiler data to this stream
619  profiler_json = Profiler::instance()->output(PETSC_COMM_WORLD, profiler_path);
620  } else {
621  profiler_json = Profiler::instance()->output(profiler_path);
622  }
623 
624  // call python script which transforms json file at given location
625  // Profiler::instance()->transform_profiler_data (".csv", "CSVFormatter");
626  _transform_profiler_data (profiler_json, ".txt", "SimpleTableFormatter2");
627 
628  // finally uninitialize
630  }
631 
632  // TODO: have context manager classes for petsc and permon initialization
633  // create a local variable in Application::run or so
634  permon_finalize();
635  petcs_finalize();
636 }
637 
638 
639 
640 
PetscErrorCode petsc_signal_handler(int signal, FMT_UNUSED void *context)
Definition: application.cc:53
void _transform_profiler_data(const string &json_filepath, const string &output_file_suffix, const string &formatter)
Definition: application.cc:591
void system_signal_handler(int signal)
Definition: application.cc:71
#define FLOW123D_COMPILER_FLAGS_
named version of the program
Definition: application.cc:245
Input::Type::RevNumData get_rev_num_data()
Definition: application.cc:251
void armadillo_setup()
Definitions of ASSERTS.
#define ASSERT_PERMANENT(expr)
Allow use shorter versions of macro names if these names is not used with external library.
Definition: asserts.hh:348
static bool permon_initialized
Definition: application.hh:95
string main_input_filename_
filename of main input file
Definition: application.hh:221
Input::Record read_input()
Definition: application.cc:305
static FILE * petsc_output_
File handler for redirecting PETSc output.
Definition: application.hh:208
static const int exit_failure
Definition: application.hh:91
string program_arguments_desc_
Description of possible command line arguments.
Definition: application.hh:227
string log_filename_
Definition: application.hh:201
void init(int argc, char **argv)
Definition: application.cc:492
int petcs_finalize()
Definition: application.cc:187
void display_version()
Definition: application.cc:286
~Application()
Destructor.
Definition: application.cc:611
void system_init(MPI_Comm comm, const string &log_filename)
Definition: application.cc:101
bool use_profiler
If true, we do output of profiling information.
Definition: application.hh:230
string profiler_path
location of the profiler report file
Definition: application.hh:233
void permon_initialize(int argc, char **argv)
Definition: application.cc:207
static Input::Type::Record & get_input_type()
Root of the Input::Type tree. Description of whole input structure.
Definition: application.cc:264
string petsc_redirect_file_
Definition: application.hh:205
void petsc_initialize(int argc, char **argv)
Definition: application.cc:162
Input::Record root_record
root input record
Definition: application.hh:239
void after_run()
Definition: application.cc:583
void parse_cmd_line(const int argc, char **argv)
Definition: application.cc:323
HC_ExplicitSequential * problem_
Get version of program and other base data from rev_num.h and store them to map.
Definition: application.hh:218
static bool petsc_initialized
Definition: application.hh:94
int permon_finalize()
Definition: application.cc:213
bool signal_handler_off_
Turn off signal handling useful to debug with valgrind.
Definition: application.hh:211
static void set_yaml_output()
Set global variable to output balance files into YAML format (in addition to the table format).
Definition: balance.cc:66
static Input::Type::Abstract & get_input_type()
Dedicated class for storing path to input and output files.
Definition: file_path.hh:54
@ output_file
Definition: file_path.hh:69
void open_stream(Stream &stream) const
Definition: file_path.cc:211
static string set_dirs_from_input(const string main_yaml, const string input, const string output)
Method for set input and output directories.
Definition: file_path.cc:137
Class for solution of steady or unsteady flow with sequentially coupled explicit transport.
static const Input::Type::Record & get_input_type()
Accessor to the polymorphic input data of a type given by an AbstracRecord object.
Definition: accessors.hh:458
Reader for (slightly) modified input files.
T get_root_interface() const
Returns the root accessor.
Accessor to the data with type Type::Record.
Definition: accessors.hh:291
const Ret val(const string &key) const
Class for declaration of the input of type Bool.
Definition: type_base.hh:452
Class Input::Type::Default specifies default value of keys of a Input::Type::Record.
Definition: type_record.hh:61
static Default obligatory()
The factory function to make an empty default value which is obligatory.
Definition: type_record.hh:110
Class for create JSON machine readable documentation.
Definition: type_output.hh:252
Record type proxy class.
Definition: type_record.hh:182
FinishStatus finish(FinishStatus finish_type=FinishStatus::regular_) override
Finish declaration of the Record type.
Definition: type_record.cc:243
Record & close() const
Close the Record for further declarations of keys.
Definition: type_record.cc:304
Record & declare_key(const string &key, std::shared_ptr< TypeBase > type, const Default &default_value, const string &description, TypeBase::attribute_map key_attributes=TypeBase::attribute_map())
Declares a new key of the Record.
Definition: type_record.cc:503
Class for declaration of the input data that are in string format.
Definition: type_base.hh:582
static void delete_unfinished_types()
Finishes and marks all types registered in type repositories and unused in IST.
Definition: type_base.cc:107
static LoggerOptions & get_instance()
Getter of singleton instance object.
int setup_mpi(MPI_Comm comm)
Set rank of actual process by MPI communicator.
void set_log_file(std::string log_file_base)
Initialize instance object in format 'log_file_base.process.log'.
static void uninitialize()
void output(MPI_Comm, ostream &)
static Profiler * instance(bool clear=false)
void set_program_info(string, string, string, string, string)
#define THROW(whole_exception_expr)
Wrapper for throw. Saves the throwing point.
Definition: exceptions.hh:53
#define WarningOut()
Macro defining 'warning' record of log.
Definition: logger.hh:278
#define MessageOut()
Macro defining 'message' record of log.
Definition: logger.hh:275
manipulators::Array< T, Delim > format(T const &deduce, Delim delim=", ")
Definition: logger.hh:325
#define MPI_SUCCESS
Definition: mpi.c:17
#define MPI_Comm_size
Definition: mpi.h:235
int MPI_Comm
Definition: mpi.h:141
#define MPI_Comm_rank
Definition: mpi.h:236
Abstract linear system class.
Definition: balance.hh:40
void printf(BasicWriter< Char > &w, BasicCStringRef< Char > format, ArgList args)
Definition: printf.h:444
#define FMT_UNUSED
Definition: posix.h:75
Stores version of program and other base data of application.
Definition: type_output.hh:44
std::string branch
Actual branch of application.
Definition: type_output.hh:47
std::string url
Url of application.
Definition: type_output.hh:48
std::string revision
Actual revision of application.
Definition: type_output.hh:46
std::string version
Actual version of application.
Definition: type_output.hh:45
FILE * log
Definition: system.hh:76
int my_proc
Definition: system.hh:79
int n_proc
Definition: system.hh:78
MPI_Comm comm
Definition: system.hh:81
int pause_after_run
Definition: system.hh:74
int verbosity
Definition: system.hh:73
#define END_TIMER(tag)
Ends a timer with specified tag.
#define START_TIMER(tag)
Starts a timer with specified tag.
SystemInfo sys_info
Definition: system.cc:41