5 #ifndef _PFASST__CONFIG_HPP_
6 #define _PFASST__CONFIG_HPP_
14 #include <boost/program_options.hpp>
15 namespace po = boost::program_options;
24 static constexpr
const char*
VERSION =
"v0.5.0-rc1-48-g4da93b0-dirty";
45 MPI_Initialized(&initialized);
47 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
69 static const size_t LINE_WIDTH = 100;
81 void operator=(
const options&) =
delete;
92 po::variables_map& get_variables_map();
93 po::options_description& get_all_options();
94 vector<string>& get_unrecognized_args();
109 static void add_option(
const string& group,
const string& option,
const string& help);
126 static void add_option(
const string& group,
const string& option,
const string& help);
152 return options::get_instance().get_variables_map()[name].as<T>();
163 inline T
get_value(
const string& name,
const T& default_val)
165 return options::get_instance().get_variables_map().count(name)
166 ? options::get_instance().get_variables_map()[name].as<T>() : default_val;
183 bool no_params_given = options::get_instance().get_variables_map().empty();
185 if (!if_no_params || (if_no_params && no_params_given)) {
187 s << options::get_instance().get_all_options() << endl;
188 s <<
"Logging options:" << endl
189 <<
" -v [ --verbose ] activates maximum verbosity" << endl
190 <<
" --v=arg activates verbosity upto verbose level `arg`" << endl
191 <<
" (valid range: 0-9)" << endl
192 <<
" -vmodule=arg actives verbose logging for specific module" << endl
193 <<
" (see [1] for details)" << endl << endl
194 <<
"[1]: https://github.com/easylogging/easyloggingpp#vmodule" << endl;
232 ifstream ifs(file_name.c_str(), ios_base::in);
234 throw invalid_argument(
"Config file '" + file_name +
"' not found.");
236 po::store(po::parse_config_file(ifs, options::get_instance().get_all_options()),
237 options::get_instance().get_variables_map());
238 po::notify(options::get_instance().get_variables_map());
255 po::parsed_options parsed = po::command_line_parser(argc, argv)
256 .options(options::get_instance().get_all_options())
257 .allow_unregistered().run();
258 options::get_instance().get_unrecognized_args() = po::collect_unrecognized(parsed.options,
259 po::exclude_positional);
260 po::store(parsed, options::get_instance().get_variables_map());
261 po::notify(options::get_instance().get_variables_map());
263 if (options::get_instance().get_variables_map().count(
"input")) {
264 string input_file = config::get_value<string>(
"input");
268 if (options::get_instance().get_variables_map().count(
"help")) {
302 options::add_option (
"Global",
"help,h",
"display this help message");
303 options::add_option (
"Global",
"quiet,q",
"don't log to stdout");
304 options::add_option<string>(
"Global",
"input",
"INI file with configuration options");
305 options::add_option<string>(
"Global",
"log_prefix",
"a prefix for the log files");
306 options::add_option (
"Global",
"nocolor,c",
"disable colorful logging");
308 options::add_option<double>(
"Duration",
"dt",
"time step size");
309 options::add_option<double>(
"Duration",
"tend",
"final time of simulation");
310 options::add_option<size_t>(
"Duration",
"num_steps",
"number time steps");
311 options::add_option<size_t>(
"Duration",
"num_iters",
"number of iterations");
313 options::add_option<size_t>(
"Quadrature",
"num_nodes",
"number of quadrature nodes");
315 options::add_option<double>(
"Tolerances",
"abs_res_tol",
"absolute residual tolerance");
316 options::add_option<double>(
"Tolerances",
"rel_res_tol",
"relative residual tolerance");
318 options::get_instance().init();
325 #endif // _PFASST__CONFIG_HPP_
po::options_description all_options
int get_rank()
Get MPI rank during initialization.
static void read_config_file(const string &file_name)
Read config parameters from file.
vector< string > unrecognized_args
Runtime config options provider.
po::variables_map variables_map
static void read_commandline(int argc, char *argv[], bool exit_on_help=true)
Read and parse command line parameters.
static bool initialized
internal flag identifying whether the default logger has been initialized.
T get_value(const string &name, const T &default_val)
Get value of specific type T with default value.
static void init()
Initialize options detection and parsing.
static constexpr const char * VERSION
PFASST++ version: closest release tag and a brief git hash.
static string print_help(bool if_no_params=false)
Compile basic help and usage information.
map< string, po::options_description > option_groups