![]() |
libSUFR
a LIBrary of Some Useful Fortran Routines
|
Procedures to handle command-line options and arguments. More...
Data Types | |
type | cl_options |
Struct to store command-line options. More... | |
Functions/Subroutines | |
subroutine | get_command_argument_i (narg, arg, status) |
Get an integer from the command line. | |
subroutine | get_command_argument_l (narg, arg, status) |
Get a long integer from the command line. | |
subroutine | get_command_argument_d (narg, arg, status) |
Get a double-precision real from the command line. | |
subroutine | get_command_argument_r (narg, arg, status) |
Get a single-precision real from the command line. | |
subroutine | read_all_commandline_arguments (verbose, narg_max, nargs, arguments) |
Read all the command-line arguments and return them in a character array. | |
subroutine | get_commandline_argument_types (verbose, nargs, arguments, types) |
Determine the type of each command-line argument found: | |
subroutine | split_short_cl_options (verbose, narg_max, nargs, arguments, types) |
If short command-line options are found (i.e., starting with one dash), split them, e.g. "-bar" -> "-b -a -r". | |
subroutine | get_commandline_options_values (verbose, narg_max, nopts, options, values, optypes, cl_option) |
Obtain command-line arguments and reduce them to options, values and types. | |
subroutine | print_commandline_options_values (nopts, options, values, optypes, cl_option) |
Print all command-line options and values found to stdOut for debugging. | |
logical function | cl_option_present (option, verbose) |
Check whether a command-line option is present. | |
logical function | cl_option_var_string (option, string) |
Retrieve the string argument/variable of a command-line option, if it exists. | |
logical function | cl_option_var_int (option, intarg) |
Retrieve the integer argument/variable of a command-line option, if it exists. | |
logical function | cl_option_var_dbl (option, dblarg) |
Retrieve the floating-point argument/variable of a command-line option, if it exists. | |
Procedures to handle command-line options and arguments.
logical function sufr_command_line::cl_option_present | ( | character, dimension(*), intent(in) | option, |
integer, intent(in), optional | verbose ) |
Check whether a command-line option is present.
option | Option to verify the presence of |
verbose | Verbosity: 0-print nothing, 1-print warnings, 2-print information, 3-print debugging info |
cl_option_present | The cl option is present (true/false). |
Definition at line 484 of file command_line.f90.
References cl_option_present(), and get_commandline_options_values().
Referenced by cl_option_present().
logical function sufr_command_line::cl_option_var_dbl | ( | character, dimension(*), intent(in) | option, |
real(double), intent(out) | dblarg ) |
Retrieve the floating-point argument/variable of a command-line option, if it exists.
option | Option to get the argument from |
dblarg | Argument/variable floating-point (output) |
cl_option_var_dbl | Bool that indicates whether an option argument was present. |
Definition at line 611 of file command_line.f90.
References cl_option_var_dbl(), sufr_kinds::double, and get_commandline_options_values().
Referenced by cl_option_var_dbl().
logical function sufr_command_line::cl_option_var_int | ( | character, dimension(*), intent(in) | option, |
integer, intent(out) | intarg ) |
Retrieve the integer argument/variable of a command-line option, if it exists.
option | Option to get the argument from |
intarg | Argument/variable integer (output) |
cl_option_var_int | Bool that indicates whether an option argument was present. |
Definition at line 569 of file command_line.f90.
References cl_option_var_int(), and get_commandline_options_values().
Referenced by cl_option_var_int().
logical function sufr_command_line::cl_option_var_string | ( | character, dimension(*), intent(in) | option, |
character, dimension(*), intent(out) | string ) |
Retrieve the string argument/variable of a command-line option, if it exists.
option | Option to get the argument from |
string | Argument/variable string (output) |
cl_option_var_string | Bool that indicates whether an option argument was present. |
Definition at line 528 of file command_line.f90.
References cl_option_var_string(), and get_commandline_options_values().
Referenced by cl_option_var_string().
subroutine sufr_command_line::get_command_argument_d | ( | integer, intent(in) | narg, |
real(double), intent(out) | arg, | ||
integer, intent(out), optional | status ) |
Get a double-precision real from the command line.
nArg | Number of command-line argument (1,2,...) |
arg | Value of the argument (output) |
status | Exit status: 0: ok, !=0: not ok (output) |
Definition at line 96 of file command_line.f90.
References sufr_kinds::double.
subroutine sufr_command_line::get_command_argument_i | ( | integer, intent(in) | narg, |
integer, intent(out) | arg, | ||
integer, intent(out), optional | status ) |
Get an integer from the command line.
nArg | Number of command-line argument (1,2,...) |
arg | Value of the argument (output) |
status | Exit status: 0: ok, !=0: not ok (output) |
Definition at line 46 of file command_line.f90.
subroutine sufr_command_line::get_command_argument_l | ( | integer, intent(in) | narg, |
integer(long), intent(out) | arg, | ||
integer, intent(out), optional | status ) |
Get a long integer from the command line.
nArg | Number of command-line argument (1,2,...) |
arg | Value of the argument (output) |
status | Exit status: 0: ok, !=0: not ok (output) |
Definition at line 70 of file command_line.f90.
References sufr_kinds::long.
subroutine sufr_command_line::get_command_argument_r | ( | integer, intent(in) | narg, |
real, intent(out) | arg, | ||
integer, intent(out), optional | status ) |
Get a single-precision real from the command line.
nArg | Number of command-line argument (1,2,...) |
arg | Value of the argument (output) |
status | Exit status: 0: ok, !=0: not ok (output) |
Definition at line 122 of file command_line.f90.
subroutine sufr_command_line::get_commandline_argument_types | ( | integer, intent(in) | verbose, |
integer, intent(in) | nargs, | ||
character, dimension(*), intent(in) | arguments, | ||
integer, dimension(nargs), intent(out) | types ) |
Determine the type of each command-line argument found:
verbose | Verbosity: 0-print nothing, 1-print warnings, 2-print information, 3-print debugging info |
nargs | Number of command-line arguments |
arguments | Array of command-line arguments |
types | Array with command-line argument types: 10: normal option (no value), 20/21: short option (one dash) (output) without/with value, 22: value for short option, 30/31: long option (two dashes) without/with value 33: value for long option |
Definition at line 194 of file command_line.f90.
Referenced by get_commandline_options_values().
subroutine sufr_command_line::get_commandline_options_values | ( | integer, intent(in) | verbose, |
integer, intent(in) | narg_max, | ||
integer, intent(out) | nopts, | ||
character, dimension(*), intent(out) | options, | ||
character, dimension(*), intent(out) | values, | ||
integer, dimension(narg_max), intent(out) | optypes, | ||
type(cl_options), dimension(narg_max), intent(out) | cl_option ) |
Obtain command-line arguments and reduce them to options, values and types.
verbose | Verbosity: 0-print nothing, 1-print warnings, 2-print information, 3-print debugging info |
narg_max | Maximum number of command-line arguments |
nopts | Number of options found (without counting their variables) (output) |
options | Array of command-line options found (output) |
values | Array of command-line values found (i.e., the parameters that belong to an option) (output) |
optypes | Array of option types: 10: normal option (no value), 20/21: short option (one dash) without/with value, (output) 30/31: long option (two dashes) without/with value |
cl_option | Struct containing command-line option names, values, has_val, short and long (output) |
Definition at line 372 of file command_line.f90.
References get_commandline_argument_types(), read_all_commandline_arguments(), and split_short_cl_options().
Referenced by cl_option_present(), cl_option_var_dbl(), cl_option_var_int(), and cl_option_var_string().
subroutine sufr_command_line::print_commandline_options_values | ( | integer, intent(in) | nopts, |
character, dimension(*), intent(in) | options, | ||
character, dimension(*), intent(in) | values, | ||
integer, dimension(nopts), intent(in) | optypes, | ||
type(cl_options), dimension(nopts), intent(in) | cl_option ) |
Print all command-line options and values found to stdOut for debugging.
nopts | Number of options found (without counting their variables) (output) |
options | Array of command-line options found (output) |
values | Array of command-line values found (i.e., the parameters that belong to an option) (output) |
optypes | Array of option types: 10: normal option (no value), 20/21: short option (one dash) without/with value, (output) 30/31: long option (two dashes) without/with value |
cl_option | Struct containing command-line option names, values, has_val, short and long (output) |
Definition at line 456 of file command_line.f90.
subroutine sufr_command_line::read_all_commandline_arguments | ( | integer, intent(in) | verbose, |
integer, intent(in) | narg_max, | ||
integer, intent(out) | nargs, | ||
character, dimension(*), intent(out) | arguments ) |
Read all the command-line arguments and return them in a character array.
verbose | Verbosity: 0-print nothing, 1-print warnings, 2-print information, 3-print debugging info |
narg_max | Maximum array size for arguments |
nargs | Number of command-line arguments found (output) |
arguments | Array of command-line arguments found (output) |
Definition at line 148 of file command_line.f90.
Referenced by get_commandline_options_values().
subroutine sufr_command_line::split_short_cl_options | ( | integer, intent(in) | verbose, |
integer, intent(in) | narg_max, | ||
integer, intent(out) | nargs, | ||
character, dimension(*), intent(inout) | arguments, | ||
integer, dimension(narg_max), intent(inout) | types ) |
If short command-line options are found (i.e., starting with one dash), split them, e.g. "-bar" -> "-b -a -r".
verbose | Verbosity: 0-print nothing, 1-print warnings, 2-print information, 3-print debugging info |
narg_max | Maximum number of command-line arguments |
nargs | Actual number of command-line arguments (I/O) (output) |
arguments | Array of command-line arguments (I/O) (output) |
types | Array with command-line argument types: 10: normal option (no value), 20/21: short option (one dash) (output) without/with value, 22: value for short option, 30/31: long option (two dashes) without/with value 33: value for long option |
Definition at line 261 of file command_line.f90.
References sufr_system::quit_program().
Referenced by get_commandline_options_values().