30 options_(argv[0],
" -- BioDynaMo command line options\n") {
45 "Please add all your command line options before:\n 1) Using "
46 "the Get() method.\n 2) Creating a Simulation object.");
48 return cxxopts::OptionAdder(
options_, std::move(group));
56 char** argv_copy = (
char**)malloc((
argc_ + 1) *
sizeof(
char*));
57 int argc_copy =
argc_;
58 for (
int i = 0; i <
argc_; ++i) {
59 size_t length = strlen(
argv_[i]) + 1;
60 argv_copy[i] = (
char*)malloc(length);
61 memcpy(argv_copy[i],
argv_[i], length);
63 argv_copy[
argc_] = NULL;
72 parser_ =
new cxxopts::ParseResult(
options_.parse(argc_copy, argv_copy));
73 }
catch (
const cxxopts::option_not_exists_exception& option) {
74 Log::Fatal(
"CommandLineOptions::ParseResult", option.what(),
75 " Perhaps you are constructing multiple Simulation objects with "
76 "different CommandLineOptions.");
86 for (
int i = 0; i <
argc_; ++i) {
96 return parser_->count(option) == 0 ? false :
true;
102 (
"h, help",
"Print this help message.")
103 (
"version",
"Print version number of BioDynaMo.")
104 (
"opencl",
"Enable GPU acceleration through OpenCL.")
105 (
"cuda",
"Enable GPU acceleration through CUDA.")
106 (
"visualize",
"Enable exporting of visualization.")
107 (
"vis-frequency",
"Set the frequency of exporting the visualization.", value<uint32_t>()->default_value(
"10"),
"FREQ")
108 (
"v, verbose",
"Verbose mode. Causes BioDynaMo to print debugging messages. Multiple "
109 "-v options increases the verbosity. The maximum is 3.", value<bool>())
110 (
"r, restore",
"Restores the simulation from the checkpoint found in FILE and "
111 "continues simulation from that point.", value<string>()->default_value(
""),
"FILE")
112 (
"b, backup",
"Periodically create full simulation backup to the specified file. "
113 "NOTA BENE: File will be overridden if it exists.", value<string>()->default_value(
""),
"FILE")
114 (
"c, config",
"The TOML or JSON configuration that should be used. The JSON file must be in JSON merge patch format (https://tools.ietf.org/html/rfc7386). This option can be used multiple times.", value<std::vector<string>>()->default_value(
""),
"FILE")
115 (
"inline-config",
"JSON configuration string passed directly on the command line. Overwrites values specified in config file. The JSON string must be in JSON merge patch format (https://tools.ietf.org/html/rfc7386). This option can be used multiple times.", value<std::vector<string>>()->default_value(
""),
"JSON_STRING")
116 (
"output-default-json",
"Prints a JSON string with all parameters and their default values and exits.")
117 (
"toml-to-json",
"Converts a TOML file to a JSON patch. After printing the JSON patch the application will exit.", value<string>()->default_value(
""),
"TOML_FILE");
123 auto pos = s.find_last_of(
'/');
124 if (pos == std::string::npos) {
127 sim_name_ = s.substr(pos + 1, s.length() - 1);
135 auto it = std::find(groups.begin(), groups.end(),
"Core");
136 std::rotate(it, it + 1, groups.end());
137 std::cout <<
options_.help(groups) << std::endl;
141 if (
IsSet(
"version")) {
142 std::cout <<
"BioDynaMo Version: " << Version::String() << std::endl;
150 TString slevel =
"Warning";
151 TEnvRec* rec = gEnv->Lookup(
"Root.ErrorIgnoreLevel");
153 if (rec->GetLevel() == kEnvUser)
154 slevel = rec->GetValue();
156 if (!slevel.CompareTo(
"Print", TString::kIgnoreCase))
158 else if (!slevel.CompareTo(
"Info", TString::kIgnoreCase))
160 else if (!slevel.CompareTo(
"Warning", TString::kIgnoreCase))
162 else if (!slevel.CompareTo(
"Error", TString::kIgnoreCase))
165 if (
IsSet(
"verbose")) {
166 auto verbosity =
parser_->count(
"verbose");
185 gErrorIgnoreLevel = ll;
187 if (
parser_->count(
"output-default-json")) {
189 std::cout <<
"Below you can find a JSON string with all available "
190 "parameters and their default values.\n"
191 <<
"Have a look at https://biodynamo.org/bioapi/ for more "
192 "details about each parameter."
198 auto toml_file = (*parser_)[
"toml-to-json"].as<std::string>();
199 if (toml_file !=
"") {
201 Log::Fatal(
"CommandLineOptions::HandleCoreOptions",
202 "Specified TOML file (", toml_file,
") does not exist.");
204 auto toml = cpptoml::parse_file(toml_file);
213 for (
int i = 0; i < clo.
argc_; ++i) {
214 os << clo.
argv_[i] <<
" ";