PFASST++
pfasst::config Namespace Reference

Classes

class  options
 Runtime config options provider. More...
 

Functions

int get_rank ()
 Get MPI rank during initialization. More...
 
template<typename T >
get_value (const string &name)
 get value of specific type T More...
 
template<typename T >
get_value (const string &name, const T &default_val)
 Get value of specific type T with default value. More...
 
static string print_help (bool if_no_params=false)
 Compile basic help and usage information. More...
 
static void read_config_file (const string &file_name)
 Read config parameters from file. More...
 
static void read_commandline (int argc, char *argv[], bool exit_on_help=true)
 Read and parse command line parameters. More...
 
static void init ()
 Initialize options detection and parsing. More...
 

Detailed Description

Since
v0.3.0

Function Documentation

int pfasst::config::get_rank ( )

Get MPI rank during initialization.

When running without MPI (ie, without using mpirun/mpiexec), returns 0. When running with MPI, returns the MPI rank.

If the user is running with MPI and MPI_Init hasn't been called yet, this will return 0. I hope this is rare.

Definition at line 40 of file config.hpp.

References pfasst::log::initialized.

Referenced by pfasst::log::format_mpi_rank(), and read_commandline().

+ Here is the caller graph for this function:

template<typename T >
T pfasst::config::get_value ( const string &  name)
inline

get value of specific type T

Template Parameters
Ttype of the retreived value
Parameters
[in]nameName of the (long) option as defined with option in options::add_option()
Returns
Value of type T of desired option.
Exceptions
boost::bad_any_castif option is not given.
See also
boost::any::bad_any_cast

Definition at line 150 of file config.hpp.

template<typename T >
T pfasst::config::get_value ( const string &  name,
const T &  default_val 
)
inline

Get value of specific type T with default value.

Template Parameters
Ttype of the retreived value

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 163 of file config.hpp.

static void pfasst::config::init ( )
inlinestatic

Initialize options detection and parsing.

Prepopulates following groups and parameters:

Group Parameter Type
Global h, help bool
Global q, quiet bool
Global input string
Global log_prefix string
Global c,nocolor bool
Duration dt double
Duration tend double
Duration num_iters size_t
Tolerances abs_res_tol double
Tolerances rel_res_tol double

Definition at line 300 of file config.hpp.

static string pfasst::config::print_help ( bool  if_no_params = false)
static

Compile basic help and usage information.

Depending on if_no_params and presence of given command line parameters the help and usage information is compiled. In case if_no_params is true and there are no parameters given on the command line or if_no_params is false no matter whether parameters are given, the help message is generated.

Parameters
[in]if_no_paramsflag governing compilation of help and usage information
Returns
string containing basic help and usage information; string may be empty

Definition at line 181 of file config.hpp.

Referenced by read_commandline().

+ Here is the caller graph for this function:

static void pfasst::config::read_commandline ( int  argc,
char *  argv[],
bool  exit_on_help = true 
)
inlinestatic

Read and parse command line parameters.

Parameters
[in]argcNumber of command line arguments as provided by main(int, char**).
[in]argvList of command line arguments as provided by main(int, char**).
[in]exit_on_helpWhether to exit the program after displaying help and usage information.
Note
Will call std::exit in case the help parameter has been provided and exit_on_help is true.

Definition at line 253 of file config.hpp.

References get_rank(), print_help(), and read_config_file().

Referenced by pfasst::init().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void pfasst::config::read_config_file ( const string &  file_name)
inlinestatic

Read config parameters from file.

A potential INI file might look like the following:

# Global
quiet=yes
# Duration
dt=0.015625
num_steps=2
num_iters=10
# Tolerances
rel_res_tol=1e-10
# PFASST
num_blocks=1
Parameters
[in]file_namename of the INI-like file containing config parameters; path/name may be relative
Exceptions
invalid_argumentif the given file could not be opened
See also
Boost Program Options Documentation on supported INI-like file format

Definition at line 230 of file config.hpp.

Referenced by read_commandline().

+ Here is the caller graph for this function: