b2api
B2000++ API Reference Manual, VERSION 4.6
 
Loading...
Searching...
No Matches
b2cli.H
Go to the documentation of this file.
1//------------------------------------------------------------------------
2// b2cli.H --
3//
4// Command Line Interface functions for B2000++.
5//
6// written by Mathias Doreille
7// Harald Klimach <harald.klimach@dlr.de>
8// Neda Ebrahimi Pour <neda.ebrahimipour@dlr.de>
9//
10// (c) 2004-2018 SMR Engineering & Development SA
11// 2502 Bienne, Switzerland
12//
13// (c) 2022 Deutsches Zentrum für Luft- und Raumfahrt (DLR) e.V.
14// Linder Höhe, 51147 Köln
15//
16// All Rights Reserved. Proprietary source code. The contents of
17// this file may not be disclosed to third parties, copied or
18// duplicated in any form, in whole or in part, without the prior
19// written permission of SMR or DLR.
20//
21//------------------------------------------------------------------------
22
23#ifndef B2CLI_H_
24#define B2CLI_H_
25
26#include <iostream>
27#include <memory>
28
29#include "b2ppconfig.h"
30#include "utils/b2cmdline.H"
31#include "utils/b2comm.H"
32
37namespace b2000 {
38
40
47class cli {
48public:
49 explicit cli(
50 std::shared_ptr<Communicator> comm, std::ostream& out = std::cout,
51 std::ostream& err = std::cerr)
52 : out{out}, err{err}, comm{comm} {}
53
54 // Output stream to use for this CLI
55 std::ostream& out;
56 // Error stream to use for this CLI
57 std::ostream& err;
58
59 cmdline::CmdOpt<bool> short_help{"h", "", "Print a one-line help message and exit."};
60
61 cmdline::CmdOpt<bool> long_help{"help", "", "Print this help message and exit."};
62
63 cmdline::CmdOpt<bool> version{"version", "", "Print the program version and exit."};
64
65 cmdline::CmdOptRTable var_rtable{
66 "define", "", "Define MDL variable=value to be passed to b2ip++."};
67
69 "adir", "",
70 "Update or add an analysis directive key/value of the form key=value"
71 " or key='value1 value2 ...'."};
72
73 cmdline::CmdOptList<> log_dir_list{
74 "l", "LOG_DIR",
75 "Add a logging directive of the form"
76 " '(critical|error|warning|info|data|debug) of <logger>"
77 " in (err|cerr|out|cout|file:filename|db|raise)'."
78 " The available loggers can be obtained with"
79 " the --list-loggers option."};
80
81 cmdline::CmdOpt<int> max_cpu_time{
82 "max-cpu", "TIME",
83 "Set CPU time limit (in seconds)."
84 " B2000++ aborts when this limit is reached.",
85 -1};
86
87 cmdline::CmdOpt<int> max_vmemory_size{
88 "max-mem", "SIZE",
89 "Set the limit for the virtual memory size (in MBytes)."
90 " B2000++ aborts when this limit is reached",
91 -1};
92
93 cmdline::CmdOpt<bool> get_list_logger{
94 "list-loggers", "",
95 "At the end of the program execution, print a list of the encountered "
96 "loggers."};
97
98 cmdline::CmdOpt<> db_type{
99 "t", "DATABASE_TYPE", "Specify the database version to process.", "b2dbv3"};
100
101#ifdef HAVE_LIB_TBB
102 cmdline::CmdOpt<int> nb_threads{
103 "nb-threads", "N", "Number of threads to use (default = automatic).", -1};
104#endif
105
106 cmdline::CmdOpt<bool> get_list_type{
107 "list-types", "",
108 "Print a list of the available object types at startup and exit "
109 "(for developers)."};
110
111 cmdline::CmdOpt<bool> nocatch{
112 "nocatch", "",
113 "Do not catch the exception or the signal in the main function"
114 " (for debugging purpose)."};
115
116 cmdline::CmdOpt<bool> valgrind{
117 "valgrind", "",
118 "Start b2000++ in valgrind (for debugging purpose,"
119 " must be the first argument)."};
120
122 "gdb", "",
123 "Start b2000++ in gdb (for debugging purpose,"
124 " must be the first argument)."};
125
126 cmdline::CmdOpt<bool> backtrace{
127 "backtrace", "",
128 "Extract backtrace with gdb if unexpected termination"
129 " (for debugging purpose, must be the first argument)."};
130
131#ifdef HAVE_FEENABLEEXCEPT
133 "fexp", "",
134 "Enable traps of floating point exceptions FE_DIVBYZERO, FE_INVALID"
135 " and FE_OVERFLOW (for debugging purposes only)."};
136#endif
137
138 cmdline::CmdOpt<int> timer_max_rank{
139 "timer-maxrank", "N", "Number of ranks to write timing information (default=1)", 1};
140
141 cmdline::CmdArg<> db_name{
142 "DBNAME", "The b2000 database to process or an MDL input file to be read."};
143
145 void PrintVersion() const;
146
149
154 void ProcessCmdOpts(cmdline::CmdLine& cline);
155
157 inline void Abort(int use_err = 1) {
158 comm->Abort(use_err);
159 exit(use_err);
160 }
161
162private:
163 // Pointer to communicator in parallel executions
164 std::shared_ptr<Communicator> comm;
165
167 void ParseOpts(cmdline::CmdLine& cline, bool opts_only = false);
168
169 void ActOnCmd(cmdline::CmdLine& cline);
170}; // class cli
171
172inline void PrintShortHelp(std::ostream& out, const cmdline::CmdLine& cline) {
173 out << "Usage: ";
174 cline.print_short_desc(out);
175 out << std::endl;
176}
177
178} // namespace b2000
179
180#endif // B2CLI_H_
Class to describe the command line interface for b2000.
Definition b2cli.H:47
void ProcessCmdOpts(cmdline::CmdLine &cline)
Definition b2cli.C:63
void Abort(int use_err=1)
Abort the program execution with an error code use_err.
Definition b2cli.H:157
void PrintVersion() const
Print the version number of the running B2000++ to the out stream.
Definition b2cli.C:36
Definition b2cmdline.H:530
Definition b2cmdline.H:641
Definition b2cmdline.H:286
Definition b2cmdline.H:214
Definition b2cmdline.H:242
Definition b2cmdline.H:185
Contains the base classes for implementing Finite Elements.
Definition b2boundary_condition.H:32