| 1 |
/* |
| 2 |
* Copyright(C) 1999-2025 National Technology & Engineering Solutions |
| 3 |
* of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with |
| 4 |
* NTESS, the U.S. Government retains certain rights in this software. |
| 5 |
* |
| 6 |
* See packages/seacas/LICENSE for details |
| 7 |
*/ |
| 8 |
#include <cstdlib> // for exit, strtod, EXIT_SUCCESS, etc |
| 9 |
#include <cstring> // for strcmp |
| 10 |
#include <fmt/core.h> |
| 11 |
#include <iostream> // for operator<<, basic_ostream, etc |
| 12 |
#include <stdio.h> |
| 13 |
#include <string> // for string, char_traits |
| 14 |
#include <vector> // for vector |
| 15 |
|
| 16 |
#include "Ioss_GetLongOpt.h" // for GetLongOption, etc |
| 17 |
#include "Ioss_Sort.h" |
| 18 |
#include "Ioss_Utils.h" // for Utils |
| 19 |
#include "shell_interface.h" |
| 20 |
#include "tokenize.h" |
| 21 |
|
| 22 |
IOShell::Interface::Interface(std::string app_version) : version(std::move(app_version)) |
| 23 |
{ |
| 24 |
enroll_options(); |
| 25 |
} |
| 26 |
|
| 27 |
void IOShell::Interface::enroll_options() |
| 28 |
{ |
| 29 |
options_.usage("[options] input_file[s] output_file"); |
| 30 |
|
| 31 |
options_.enroll("help", Ioss::GetLongOption::OptType::NoValue, "Print this summary and exit", |
| 32 |
nullptr); |
| 33 |
|
| 34 |
options_.enroll("in_type", Ioss::GetLongOption::OptType::MandatoryValue, |
| 35 |
"Database type for input file: generated" |
| 36 |
#if defined(SEACAS_HAVE_PAMGEN) |
| 37 |
"|pamgen" |
| 38 |
#endif |
| 39 |
#if defined(SEACAS_HAVE_EXODUS) |
| 40 |
"|exodus" |
| 41 |
#endif |
| 42 |
#if defined(SEACAS_HAVE_CGNS) |
| 43 |
"|cgns" |
| 44 |
#endif |
| 45 |
".\n\t\tIf not specified, guess from extension or exodus is the default.", |
| 46 |
"unknown"); |
| 47 |
|
| 48 |
options_.enroll("out_type", Ioss::GetLongOption::OptType::MandatoryValue, |
| 49 |
"Database type for output file:" |
| 50 |
#if defined(SEACAS_HAVE_EXODUS) |
| 51 |
" exodus" |
| 52 |
#if defined(SEACAS_HAVE_EXONULL) |
| 53 |
" exonull" |
| 54 |
#endif |
| 55 |
#endif |
| 56 |
#if defined(SEACAS_HAVE_CGNS) |
| 57 |
" cgns" |
| 58 |
#endif |
| 59 |
#if defined(SEACAS_HAVE_FAODEL) |
| 60 |
" faodel" |
| 61 |
#endif |
| 62 |
" null.\n\t\tIf not specified, guess from extension or exodus is the default.", |
| 63 |
"unknown"); |
| 64 |
options_.enroll("compare", Ioss::GetLongOption::OptType::NoValue, |
| 65 |
"Compare the contents of the INPUT and OUTPUT files.", nullptr); |
| 66 |
options_.enroll( |
| 67 |
"relative", Ioss::GetLongOption::OptType::MandatoryValue, |
| 68 |
"Relative tolerance to use if comparing real field data. (diff > abs && diff > rel).", |
| 69 |
nullptr); |
| 70 |
options_.enroll( |
| 71 |
"absolute", Ioss::GetLongOption::OptType::MandatoryValue, |
| 72 |
"Absolute tolerance to use if comparing real field data. (diff > abs && diff > rel)", |
| 73 |
nullptr); |
| 74 |
options_.enroll("floor", Ioss::GetLongOption::OptType::MandatoryValue, |
| 75 |
"Only compare values if `|a| > floor || |b| > floor`", nullptr); |
| 76 |
options_.enroll("ignore_qa_info", Ioss::GetLongOption::OptType::NoValue, |
| 77 |
"If comparing databases, do not compare the qa and info records.", nullptr, |
| 78 |
nullptr, true); |
| 79 |
|
| 80 |
options_.enroll("ignore_node_map", Ioss::GetLongOption::OptType::NoValue, |
| 81 |
"Do not read the global node id map (if any) from the input database.", nullptr, |
| 82 |
nullptr); |
| 83 |
options_.enroll("ignore_element_map", Ioss::GetLongOption::OptType::NoValue, |
| 84 |
"Do not read the global element id map (if any) from the input database.", |
| 85 |
nullptr, nullptr); |
| 86 |
options_.enroll("ignore_edge_map", Ioss::GetLongOption::OptType::NoValue, |
| 87 |
"Do not read the global edge id map (if any) from the input database.", nullptr, |
| 88 |
nullptr); |
| 89 |
options_.enroll("ignore_face_map", Ioss::GetLongOption::OptType::NoValue, |
| 90 |
"Do not read the global face id map (if any) from the input database.", nullptr, |
| 91 |
nullptr, true); |
| 92 |
|
| 93 |
options_.enroll("64-bit", Ioss::GetLongOption::OptType::NoValue, |
| 94 |
"Use 64-bit integers on output database", nullptr); |
| 95 |
|
| 96 |
options_.enroll("32-bit", Ioss::GetLongOption::OptType::NoValue, |
| 97 |
"Use 32-bit integers on output database." |
| 98 |
" This is the default unless input database uses 64-bit integers", |
| 99 |
nullptr); |
| 100 |
|
| 101 |
options_.enroll("float", Ioss::GetLongOption::OptType::NoValue, |
| 102 |
"Use 32-bit floating point values on output database; default is 64-bits", |
| 103 |
nullptr); |
| 104 |
|
| 105 |
options_.enroll("netcdf3", Ioss::GetLongOption::OptType::NoValue, |
| 106 |
"Output database will be a classical netcdf (CDF3) file.", nullptr); |
| 107 |
|
| 108 |
options_.enroll("netcdf4", Ioss::GetLongOption::OptType::NoValue, |
| 109 |
"Output database will be a netcdf4 " |
| 110 |
"hdf5-based file instead of the " |
| 111 |
"classical netcdf file format", |
| 112 |
nullptr); |
| 113 |
|
| 114 |
options_.enroll("netcdf5", Ioss::GetLongOption::OptType::NoValue, |
| 115 |
"Output database will be a netcdf5 (CDF5) " |
| 116 |
"file instead of the classical netcdf file format", |
| 117 |
nullptr, nullptr, true); |
| 118 |
|
| 119 |
options_.enroll("shuffle", Ioss::GetLongOption::OptType::NoValue, |
| 120 |
"Use a netcdf4 hdf5-based file and use hdf5s shuffle mode with compression.", |
| 121 |
nullptr); |
| 122 |
|
| 123 |
options_.enroll("compress", Ioss::GetLongOption::OptType::MandatoryValue, |
| 124 |
"Specify the compression level to be used. Values depend on algorithm:\n" |
| 125 |
"\t\tzlib/bzip2: 0..9\t\tszip: even, 4..32\t\tzstd: -131072..22", |
| 126 |
nullptr); |
| 127 |
|
| 128 |
options_.enroll( |
| 129 |
"zlib", Ioss::GetLongOption::OptType::NoValue, |
| 130 |
"Use the Zlib / libz compression method if compression is enabled (default) [exodus only].", |
| 131 |
nullptr); |
| 132 |
|
| 133 |
options_.enroll( |
| 134 |
"szip", Ioss::GetLongOption::OptType::NoValue, |
| 135 |
"Use the SZip library if compression is enabled. Not as portable as zlib [exodus only]", |
| 136 |
nullptr); |
| 137 |
|
| 138 |
options_.enroll("zstd", Ioss::GetLongOption::OptType::NoValue, |
| 139 |
"Use the Zstandard compression method if compression is enabled [exodus only].", |
| 140 |
nullptr); |
| 141 |
|
| 142 |
options_.enroll("bzip2", Ioss::GetLongOption::OptType::NoValue, |
| 143 |
"Use the Bzip2 compression method if compression is enabled [exodus only].", |
| 144 |
nullptr); |
| 145 |
|
| 146 |
options_.enroll("quantize_nsd", Ioss::GetLongOption::OptType::MandatoryValue, |
| 147 |
"Use the lossy quantize compression method. Value specifies number of digits to " |
| 148 |
"retain (1..15) [exodus only]", |
| 149 |
nullptr, nullptr, true); |
| 150 |
|
| 151 |
#if defined(SEACAS_HAVE_MPI) |
| 152 |
options_.enroll( |
| 153 |
"compose", Ioss::GetLongOption::OptType::OptionalValue, |
| 154 |
"If no argument, specify single-file output; if 'external', then file-per-processor.\n" |
| 155 |
"\t\tAll other options are ignored and just exist for backward-compatibility", |
| 156 |
nullptr, "true"); |
| 157 |
|
| 158 |
#if !defined(NO_ZOLTAN_SUPPORT) |
| 159 |
options_.enroll( |
| 160 |
"rcb", Ioss::GetLongOption::OptType::NoValue, |
| 161 |
"Use recursive coordinate bisection method to decompose the input mesh in a parallel run.", |
| 162 |
nullptr); |
| 163 |
options_.enroll( |
| 164 |
"rib", Ioss::GetLongOption::OptType::NoValue, |
| 165 |
"Use recursive inertial bisection method to decompose the input mesh in a parallel run.", |
| 166 |
nullptr); |
| 167 |
|
| 168 |
options_.enroll( |
| 169 |
"hsfc", Ioss::GetLongOption::OptType::NoValue, |
| 170 |
"Use hilbert space-filling curve method to decompose the input mesh in a parallel run.", |
| 171 |
nullptr); |
| 172 |
#endif |
| 173 |
|
| 174 |
#if !defined(NO_PARMETIS_SUPPORT) |
| 175 |
options_.enroll( |
| 176 |
"metis_sfc", Ioss::GetLongOption::OptType::NoValue, |
| 177 |
"Use the metis space-filling-curve method to decompose the input mesh in a parallel run.", |
| 178 |
nullptr); |
| 179 |
|
| 180 |
options_.enroll( |
| 181 |
"kway", Ioss::GetLongOption::OptType::NoValue, |
| 182 |
"Use the metis kway graph-based method to decompose the input mesh in a parallel run.", |
| 183 |
nullptr); |
| 184 |
|
| 185 |
options_.enroll("kway_geom", Ioss::GetLongOption::OptType::NoValue, |
| 186 |
"Use the metis kway graph-based method with geometry speedup to decompose the " |
| 187 |
"input mesh in a parallel run.", |
| 188 |
nullptr); |
| 189 |
#endif |
| 190 |
|
| 191 |
options_.enroll("linear", Ioss::GetLongOption::OptType::NoValue, |
| 192 |
"Use the linear method to decompose the input mesh in a parallel run.\n" |
| 193 |
"\t\tElements in order first n/p to proc 0, next to proc 1.", |
| 194 |
nullptr); |
| 195 |
|
| 196 |
options_.enroll("cyclic", Ioss::GetLongOption::OptType::NoValue, |
| 197 |
"Use the cyclic method to decompose the input mesh in a parallel run.\n" |
| 198 |
"\t\tElements handed out to id % proc_count", |
| 199 |
nullptr); |
| 200 |
|
| 201 |
options_.enroll("random", Ioss::GetLongOption::OptType::NoValue, |
| 202 |
"Use the random method to decompose the input mesh in a parallel run.\n" |
| 203 |
"\t\tElements assigned randomly to processors in a way that preserves balance\n" |
| 204 |
"\t\t(do *not* use for a real run)", |
| 205 |
nullptr); |
| 206 |
|
| 207 |
options_.enroll("map", Ioss::GetLongOption::OptType::OptionalValue, |
| 208 |
"Read the decomposition data from the specified element map.\n" |
| 209 |
"\t\tIf no map name is specified, then `processor_id` will be used.\n" |
| 210 |
"\t\tIf the name is followed by a ',' and an integer or 'auto', then\n" |
| 211 |
"\t\tthe entries in the map will be divided by the integer value or\n" |
| 212 |
"\t\t(if auto) by `int((max_entry+1)/proc_count)`.", |
| 213 |
nullptr); |
| 214 |
|
| 215 |
options_.enroll("variable", Ioss::GetLongOption::OptType::OptionalValue, |
| 216 |
"Read the decomposition data from the specified element variable.\n" |
| 217 |
"\t\tIf no variable name is specified, then `processor_id` will be used.\n" |
| 218 |
"\t\tIf the name is followed by a ',' and an integer or 'auto', then\n" |
| 219 |
"\t\tthe entries in the variable will be divided by the integer value or\n" |
| 220 |
"\t\t(if auto) by `int((max_entry+1)/proc_count)`.", |
| 221 |
nullptr); |
| 222 |
|
| 223 |
options_.enroll("line_decomp", Ioss::GetLongOption::OptType::OptionalValue, |
| 224 |
"Generate the `lines` or `columns` of elements from the specified surface(s).\n" |
| 225 |
"\t\tSpecify a comma-separated list of surface/sideset names from which the " |
| 226 |
"lines will grow.\n" |
| 227 |
"\t\tDo not split a line/column across processors.\n" |
| 228 |
"\t\tOmit or enter 'ALL' for all surfaces in model.", |
| 229 |
nullptr, "ALL"); |
| 230 |
|
| 231 |
options_.enroll("external", Ioss::GetLongOption::OptType::NoValue, |
| 232 |
"Files are decomposed externally into a file-per-processor in a parallel run.", |
| 233 |
nullptr); |
| 234 |
|
| 235 |
options_.enroll("add_processor_id_field", Ioss::GetLongOption::OptType::NoValue, |
| 236 |
"Add a cell-centered field whose value is the processor id of that cell", |
| 237 |
nullptr); |
| 238 |
|
| 239 |
options_.enroll("serialize_io_size", Ioss::GetLongOption::OptType::MandatoryValue, |
| 240 |
"Number of processors that can perform simultaneous IO operations in " |
| 241 |
"a parallel run;\n\t\t0 to disable", |
| 242 |
nullptr, nullptr, true); |
| 243 |
#endif |
| 244 |
|
| 245 |
options_.enroll("select_change_sets", Ioss::GetLongOption::OptType::MandatoryValue, |
| 246 |
"Read only the specified change set(s) (comma-separated list) from the input " |
| 247 |
"file. Use \"ALL\" for all change sets (default).", |
| 248 |
nullptr); |
| 249 |
options_.enroll( |
| 250 |
"extract_change_set", Ioss::GetLongOption::OptType::MandatoryValue, |
| 251 |
"Write the data from the specified change_set (formerly group) to the output file.", nullptr); |
| 252 |
options_.enroll("extract_group", Ioss::GetLongOption::OptType::MandatoryValue, |
| 253 |
"[deprecated] Use `--extract_change_set`.", nullptr); |
| 254 |
|
| 255 |
options_.enroll( |
| 256 |
"split_times", Ioss::GetLongOption::OptType::MandatoryValue, |
| 257 |
"If non-zero, then put <$val> timesteps in each file. Then close file and start new file.", |
| 258 |
nullptr); |
| 259 |
|
| 260 |
options_.enroll( |
| 261 |
"split_cyclic", Ioss::GetLongOption::OptType::MandatoryValue, |
| 262 |
"If non-zero, then the `split_times` timesteps will be put into <$val> files\n\t\tand " |
| 263 |
"then recycle filenames.", |
| 264 |
nullptr); |
| 265 |
|
| 266 |
options_.enroll("file_per_state", Ioss::GetLongOption::OptType::NoValue, |
| 267 |
"put transient data for each timestep in separate file (EXPERIMENTAL)", nullptr); |
| 268 |
|
| 269 |
options_.enroll("minimize_open_files", Ioss::GetLongOption::OptType::NoValue, |
| 270 |
"close output file after each timestep", nullptr, nullptr, true); |
| 271 |
|
| 272 |
options_.enroll("Maximum_Time", Ioss::GetLongOption::OptType::MandatoryValue, |
| 273 |
"Maximum time on input database to transfer to output database", nullptr); |
| 274 |
|
| 275 |
options_.enroll("Minimum_Time", Ioss::GetLongOption::OptType::MandatoryValue, |
| 276 |
"Minimum time on input database to transfer to output database", nullptr); |
| 277 |
|
| 278 |
options_.enroll("time_scale", Ioss::GetLongOption::OptType::MandatoryValue, |
| 279 |
"The output time = input_time * time_scale + time_offset", nullptr); |
| 280 |
|
| 281 |
options_.enroll("time_offset", Ioss::GetLongOption::OptType::MandatoryValue, |
| 282 |
"The output time = input_time * time_scale + time_offset", nullptr); |
| 283 |
|
| 284 |
options_.enroll("select_times", Ioss::GetLongOption::OptType::MandatoryValue, |
| 285 |
"comma-separated list of times that should be transferred to output database", |
| 286 |
nullptr); |
| 287 |
|
| 288 |
options_.enroll("append_after_time", Ioss::GetLongOption::OptType::MandatoryValue, |
| 289 |
"add steps on input database after specified time on output database", nullptr); |
| 290 |
|
| 291 |
options_.enroll("append_after_step", Ioss::GetLongOption::OptType::MandatoryValue, |
| 292 |
"add steps on input database after specified step on output database", nullptr); |
| 293 |
|
| 294 |
options_.enroll("flush_interval", Ioss::GetLongOption::OptType::MandatoryValue, |
| 295 |
"Specify the number of steps between database flushes.\n" |
| 296 |
"\t\tIf not specified, then the default database-dependent setting is used.\n" |
| 297 |
"\t\tA value of 0 disables flushing.", |
| 298 |
nullptr); |
| 299 |
options_.enroll("delete_timesteps", Ioss::GetLongOption::OptType::NoValue, |
| 300 |
"Do not transfer any timesteps or transient data to the output database", |
| 301 |
nullptr); |
| 302 |
|
| 303 |
options_.enroll("delete_qa_records", Ioss::GetLongOption::OptType::NoValue, |
| 304 |
"Do not output qa records to output database.", nullptr); |
| 305 |
options_.enroll("delete_info_records", Ioss::GetLongOption::OptType::NoValue, |
| 306 |
"Do not output info records to output database.", nullptr, nullptr, true); |
| 307 |
|
| 308 |
options_.enroll("field_suffix_separator", Ioss::GetLongOption::OptType::MandatoryValue, |
| 309 |
"Character used to separate a field suffix from the field basename\n" |
| 310 |
"\t\twhen recognizing vector, tensor fields. Enter '0' for no separator", |
| 311 |
"_"); |
| 312 |
|
| 313 |
options_.enroll("disable_field_recognition", Ioss::GetLongOption::OptType::NoValue, |
| 314 |
"Do not combine fields into vector, tensor fields based on basename and suffix.\n" |
| 315 |
"\t\tKeep all fields on database as scalars", |
| 316 |
nullptr); |
| 317 |
|
| 318 |
options_.enroll("custom_field", Ioss::GetLongOption::OptType::MandatoryValue, |
| 319 |
"A comma-separated list of field suffices defining a custom field that should be " |
| 320 |
"recognized.\n" |
| 321 |
"\t\tPrimarily used for testing", |
| 322 |
nullptr); |
| 323 |
|
| 324 |
options_.enroll("surface_split_scheme", Ioss::GetLongOption::OptType::MandatoryValue, |
| 325 |
"Method used to split sidesets into homogeneous blocks\n" |
| 326 |
"\t\tOptions are: TOPOLOGY(default), BLOCK, NO_SPLIT", |
| 327 |
nullptr); |
| 328 |
|
| 329 |
options_.enroll("native_variable_names", Ioss::GetLongOption::OptType::NoValue, |
| 330 |
"Do not lowercase variable names and replace spaces with underscores.\n" |
| 331 |
"\t\tVariable names are left as they appear in the input mesh file", |
| 332 |
nullptr); |
| 333 |
|
| 334 |
options_.enroll("retain_empty_blocks", Ioss::GetLongOption::OptType::NoValue, |
| 335 |
"If any empty element blocks on input file, keep them and write to output file.\n" |
| 336 |
"\t\tDefault is to ignore empty blocks.", |
| 337 |
nullptr); |
| 338 |
|
| 339 |
options_.enroll("omit_blocks", Ioss::GetLongOption::OptType::MandatoryValue, |
| 340 |
"comma-separated list of element block names that should NOT be transferred to " |
| 341 |
"output database\n" |
| 342 |
"\t\tNote that currently any nodes connected to only empty blocks will be " |
| 343 |
"retained in the output.", |
| 344 |
nullptr); |
| 345 |
|
| 346 |
options_.enroll("omit_sets", Ioss::GetLongOption::OptType::MandatoryValue, |
| 347 |
"comma-separated list of nodeset/edgeset/faceset/elemset/sideset names\n" |
| 348 |
"\t\tthat should NOT be transferred to output database", |
| 349 |
nullptr); |
| 350 |
|
| 351 |
options_.enroll("boundary_sideset", Ioss::GetLongOption::OptType::NoValue, |
| 352 |
"Output a sideset for all boundary faces of the model", nullptr, nullptr, true); |
| 353 |
|
| 354 |
options_.enroll( |
| 355 |
"delay", Ioss::GetLongOption::OptType::MandatoryValue, |
| 356 |
"Sleep for <$val> seconds between timestep output to simulate application calculation time", |
| 357 |
nullptr); |
| 358 |
|
| 359 |
#ifdef SEACAS_HAVE_KOKKOS |
| 360 |
options_.enroll("data_storage", Ioss::GetLongOption::OptType::MandatoryValue, |
| 361 |
"Data type used internally to store field data\n" |
| 362 |
"\t\tOptions are: POINTER, STD_VECTOR, KOKKOS_VIEW_1D, KOKKOS_VIEW_2D, " |
| 363 |
"KOKKOS_VIEW_2D_LAYOUTRIGHT_HOSTSPACE", |
| 364 |
"POINTER"); |
| 365 |
#else |
| 366 |
options_.enroll("data_storage", Ioss::GetLongOption::OptType::MandatoryValue, |
| 367 |
"Data type used internally to store field data\n" |
| 368 |
"\t\tOptions are: POINTER, STD_VECTOR", |
| 369 |
"POINTER"); |
| 370 |
#endif |
| 371 |
|
| 372 |
options_.enroll("debug", Ioss::GetLongOption::OptType::NoValue, "turn on debugging output", |
| 373 |
nullptr); |
| 374 |
options_.enroll("detect_nans", Ioss::GetLongOption::OptType::NoValue, |
| 375 |
"check all real field data for NaNs", nullptr); |
| 376 |
|
| 377 |
options_.enroll("quiet", Ioss::GetLongOption::OptType::NoValue, "minimize output", nullptr); |
| 378 |
|
| 379 |
options_.enroll("statistics", Ioss::GetLongOption::OptType::NoValue, |
| 380 |
"output parallel io timing statistics", nullptr); |
| 381 |
|
| 382 |
options_.enroll("memory_statistics", Ioss::GetLongOption::OptType::NoValue, |
| 383 |
"output memory usage throughout code execution", nullptr); |
| 384 |
|
| 385 |
options_.enroll( |
| 386 |
"memory_read", Ioss::GetLongOption::OptType::NoValue, |
| 387 |
"EXPERIMENTAL: file read into memory by netcdf library; ioss accesses memory version", |
| 388 |
nullptr); |
| 389 |
|
| 390 |
options_.enroll( |
| 391 |
"memory_write", Ioss::GetLongOption::OptType::NoValue, |
| 392 |
"EXPERIMENTAL: file written to memory, netcdf library streams to disk at file close", |
| 393 |
nullptr); |
| 394 |
|
| 395 |
options_.enroll("reverse", Ioss::GetLongOption::OptType::NoValue, |
| 396 |
"define CGNS zones in reverse order. Used for testing (TEST)", nullptr); |
| 397 |
|
| 398 |
options_.enroll("version", Ioss::GetLongOption::OptType::NoValue, "Print version and exit", |
| 399 |
nullptr); |
| 400 |
|
| 401 |
options_.enroll("copyright", Ioss::GetLongOption::OptType::NoValue, |
| 402 |
"Show copyright and license data.", nullptr); |
| 403 |
} |
| 404 |
|
| 405 |
bool IOShell::Interface::parse_options(int argc, char **argv, int my_processor) |
| 406 |
{ |
| 407 |
// Get options from environment variable also... |
| 408 |
char *options = getenv("IO_SHELL_OPTIONS"); |
| 409 |
if (options != nullptr) { |
| 410 |
fmt::print( |
| 411 |
stderr, |
| 412 |
"\nThe following options were specified via the IO_SHELL_OPTIONS environment variable:\n" |
| 413 |
"\t{}\n\n", |
| 414 |
options); |
| 415 |
options_.parse(options, Ioss::GetLongOption::basename(*argv)); |
| 416 |
} |
| 417 |
|
| 418 |
int option_index = options_.parse(argc, argv); |
| 419 |
if (option_index < 1) { |
| 420 |
return false; |
| 421 |
} |
| 422 |
|
| 423 |
if (options_.retrieve("help") != nullptr) { |
| 424 |
if (my_processor == 0) { |
| 425 |
options_.usage(std::cerr); |
| 426 |
fmt::print(stderr, "\n\tCan also set options via IO_SHELL_OPTIONS environment variable.\n\n"); |
| 427 |
fmt::print(stderr, |
| 428 |
"\tDocumentation: " |
| 429 |
"https://sandialabs.github.io/seacas-docs/sphinx/html/index.html#io-shell\n\n"); |
| 430 |
fmt::print(stderr, "\t->->-> Send email to [email protected] for {} support.<-<-<-\n", |
| 431 |
options_.program_name()); |
| 432 |
} |
| 433 |
exit(EXIT_SUCCESS); |
| 434 |
} |
| 435 |
|
| 436 |
if (options_.retrieve("version") != nullptr) { |
| 437 |
fmt::print(stderr, "IO_SHELL\tVersion: {}\n", version); |
| 438 |
exit(0); |
| 439 |
} |
| 440 |
|
| 441 |
ints_64_bit = (options_.retrieve("64-bit") != nullptr); |
| 442 |
ints_32_bit = (options_.retrieve("32-bit") != nullptr); |
| 443 |
reals_32_bit = (options_.retrieve("float") != nullptr); |
| 444 |
|
| 445 |
if (options_.retrieve("netcdf3") != nullptr) { |
| 446 |
netcdf3 = true; |
| 447 |
netcdf4 = false; |
| 448 |
netcdf5 = false; |
| 449 |
ints_32_bit = true; |
| 450 |
zlib = false; |
| 451 |
} |
| 452 |
|
| 453 |
if (options_.retrieve("netcdf4") != nullptr) { |
| 454 |
netcdf3 = false; |
| 455 |
netcdf4 = true; |
| 456 |
netcdf5 = false; |
| 457 |
} |
| 458 |
|
| 459 |
if (options_.retrieve("netcdf5") != nullptr) { |
| 460 |
netcdf3 = false; |
| 461 |
netcdf4 = false; |
| 462 |
netcdf5 = true; |
| 463 |
} |
| 464 |
|
| 465 |
shuffle = (options_.retrieve("shuffle") != nullptr); |
| 466 |
if (options_.retrieve("szip") != nullptr) { |
| 467 |
szip = true; |
| 468 |
zlib = false; |
| 469 |
zstd = false; |
| 470 |
bz2 = false; |
| 471 |
} |
| 472 |
if (options_.retrieve("zstd") != nullptr) { |
| 473 |
szip = false; |
| 474 |
zlib = false; |
| 475 |
zstd = true; |
| 476 |
bz2 = false; |
| 477 |
} |
| 478 |
if (options_.retrieve("zlib") != nullptr) { |
| 479 |
szip = false; |
| 480 |
zlib = true; |
| 481 |
zstd = false; |
| 482 |
bz2 = false; |
| 483 |
} |
| 484 |
if (options_.retrieve("bzip2") != nullptr) { |
| 485 |
szip = false; |
| 486 |
zlib = false; |
| 487 |
zstd = false; |
| 488 |
bz2 = true; |
| 489 |
} |
| 490 |
|
| 491 |
if (szip + zlib + zstd + bz2 > 1) { |
| 492 |
if (my_processor == 0) { |
| 493 |
fmt::print(stderr, |
| 494 |
"ERROR: Only one of 'szip' or 'zlib' or 'zstd' or 'bzip2' can be specified.\n"); |
| 495 |
} |
| 496 |
return false; |
| 497 |
} |
| 498 |
|
| 499 |
{ |
| 500 |
const char *temp = options_.retrieve("quantize_nsd"); |
| 501 |
if (temp != nullptr) { |
| 502 |
quant = true; |
| 503 |
quantize_nsd = std::strtol(temp, nullptr, 10); |
| 504 |
if (szip + zlib + zstd + bz2 == 0) { |
| 505 |
zlib = true; |
| 506 |
} |
| 507 |
} |
| 508 |
} |
| 509 |
|
| 510 |
{ |
| 511 |
const char *temp = options_.retrieve("compress"); |
| 512 |
if (temp != nullptr) { |
| 513 |
compression_level = std::strtol(temp, nullptr, 10); |
| 514 |
|
| 515 |
if (szip + zlib + zstd + bz2 == 0) { |
| 516 |
zlib = true; |
| 517 |
if (my_processor == 0) { |
| 518 |
fmt::print(stderr, "INFO: Compression level specified, but no algorithm. Defaulting to " |
| 519 |
"'zlib' and setting netcdf-4 file type.\n"); |
| 520 |
} |
| 521 |
} |
| 522 |
|
| 523 |
if (zlib) { |
| 524 |
if (compression_level < 0 || compression_level > 9) { |
| 525 |
if (my_processor == 0) { |
| 526 |
fmt::print(stderr, |
| 527 |
"ERROR: Bad compression level {}, valid value is between 0 and 9 inclusive " |
| 528 |
"for gzip/zlib compression.\n", |
| 529 |
compression_level); |
| 530 |
} |
| 531 |
return false; |
| 532 |
} |
| 533 |
} |
| 534 |
else if (szip) { |
| 535 |
if (compression_level % 2 != 0) { |
| 536 |
if (my_processor == 0) { |
| 537 |
fmt::print( |
| 538 |
stderr, |
| 539 |
"ERROR: Bad compression level {}. Must be an even value for szip compression.\n", |
| 540 |
compression_level); |
| 541 |
} |
| 542 |
return false; |
| 543 |
} |
| 544 |
if (compression_level < 4 || compression_level > 32) { |
| 545 |
if (my_processor == 0) { |
| 546 |
fmt::print(stderr, |
| 547 |
"ERROR: Bad compression level {}, valid value is between 4 and 32 inclusive " |
| 548 |
"for szip compression.\n", |
| 549 |
compression_level); |
| 550 |
} |
| 551 |
return false; |
| 552 |
} |
| 553 |
} |
| 554 |
} |
| 555 |
} |
| 556 |
|
| 557 |
compare = (options_.retrieve("compare") != nullptr); |
| 558 |
ignore_qa_info = (options_.retrieve("ignore_qa_info") != nullptr); |
| 559 |
ignore_node_map = (options_.retrieve("ignore_node_map") != nullptr); |
| 560 |
ignore_elem_map = (options_.retrieve("ignore_element_map") != nullptr); |
| 561 |
ignore_edge_map = (options_.retrieve("ignore_edge_map") != nullptr); |
| 562 |
ignore_face_map = (options_.retrieve("ignore_face_map") != nullptr); |
| 563 |
delete_qa = (options_.retrieve("delete_qa_records") != nullptr); |
| 564 |
delete_info = (options_.retrieve("delete_info_records") != nullptr); |
| 565 |
|
| 566 |
{ |
| 567 |
const char *temp = options_.retrieve("absolute"); |
| 568 |
if (temp != nullptr) { |
| 569 |
abs_tolerance = std::strtod(temp, nullptr); |
| 570 |
} |
| 571 |
} |
| 572 |
{ |
| 573 |
const char *temp = options_.retrieve("relative"); |
| 574 |
if (temp != nullptr) { |
| 575 |
rel_tolerance = std::strtod(temp, nullptr); |
| 576 |
} |
| 577 |
} |
| 578 |
{ |
| 579 |
const char *temp = options_.retrieve("floor"); |
| 580 |
if (temp != nullptr) { |
| 581 |
tol_floor = std::strtod(temp, nullptr); |
| 582 |
} |
| 583 |
} |
| 584 |
|
| 585 |
#if defined(SEACAS_HAVE_MPI) |
| 586 |
add_processor_id_field = (options_.retrieve("add_processor_id_field") != nullptr); |
| 587 |
|
| 588 |
#if !defined(NO_ZOLTAN_SUPPORT) |
| 589 |
if (options_.retrieve("rcb") != nullptr) { |
| 590 |
decomp_method = "RCB"; |
| 591 |
} |
| 592 |
|
| 593 |
if (options_.retrieve("rib") != nullptr) { |
| 594 |
decomp_method = "RIB"; |
| 595 |
} |
| 596 |
|
| 597 |
if (options_.retrieve("hsfc") != nullptr) { |
| 598 |
decomp_method = "HSFC"; |
| 599 |
} |
| 600 |
#endif |
| 601 |
|
| 602 |
#if !defined(NO_PARMETIS_SUPPORT) |
| 603 |
if (options_.retrieve("metis_sfc") != nullptr) { |
| 604 |
decomp_method = "METIS_SFC"; |
| 605 |
} |
| 606 |
|
| 607 |
if (options_.retrieve("kway") != nullptr) { |
| 608 |
decomp_method = "KWAY"; |
| 609 |
} |
| 610 |
|
| 611 |
if (options_.retrieve("kway_geom") != nullptr) { |
| 612 |
decomp_method = "KWAY_GEOM"; |
| 613 |
} |
| 614 |
#endif |
| 615 |
|
| 616 |
if (options_.retrieve("linear") != nullptr) { |
| 617 |
decomp_method = "LINEAR"; |
| 618 |
} |
| 619 |
|
| 620 |
if (options_.retrieve("map") != nullptr) { |
| 621 |
decomp_method = "MAP"; |
| 622 |
decomp_extra = options_.get_option_value("map", decomp_extra); |
| 623 |
} |
| 624 |
|
| 625 |
if (options_.retrieve("variable") != nullptr) { |
| 626 |
decomp_method = "VARIABLE"; |
| 627 |
decomp_extra = options_.get_option_value("variable", decomp_extra); |
| 628 |
} |
| 629 |
|
| 630 |
if (options_.retrieve("line_decomp") != nullptr) { |
| 631 |
line_decomp = true; |
| 632 |
decomp_extra = options_.get_option_value("line_decomp", decomp_extra); |
| 633 |
} |
| 634 |
|
| 635 |
if (options_.retrieve("cyclic") != nullptr) { |
| 636 |
decomp_method = "CYCLIC"; |
| 637 |
} |
| 638 |
|
| 639 |
if (options_.retrieve("random") != nullptr) { |
| 640 |
decomp_method = "RANDOM"; |
| 641 |
} |
| 642 |
|
| 643 |
if (options_.retrieve("external") != nullptr) { |
| 644 |
decomp_method = "EXTERNAL"; |
| 645 |
} |
| 646 |
|
| 647 |
serialize_io_size = options_.get_option_value("serialize_io_size", serialize_io_size); |
| 648 |
|
| 649 |
#endif |
| 650 |
|
| 651 |
split_times = options_.get_option_value("split_times", split_times); |
| 652 |
split_cyclic = options_.get_option_value("split_cyclic", split_cyclic); |
| 653 |
if (split_cyclic > 26) { |
| 654 |
split_cyclic = 26; |
| 655 |
} |
| 656 |
|
| 657 |
minimize_open_files = (options_.retrieve("minimize_open_files") != nullptr); |
| 658 |
debug = (options_.retrieve("debug") != nullptr); |
| 659 |
detect_nans = (options_.retrieve("detect_nans") != nullptr); |
| 660 |
file_per_state = (options_.retrieve("file_per_state") != nullptr); |
| 661 |
reverse = (options_.retrieve("reverse") != nullptr); |
| 662 |
quiet = (options_.retrieve("quiet") != nullptr); |
| 663 |
statistics = (options_.retrieve("statistics") != nullptr); |
| 664 |
memory_statistics = (options_.retrieve("memory_statistics") != nullptr); |
| 665 |
in_memory_read = (options_.retrieve("memory_read") != nullptr); |
| 666 |
in_memory_write = (options_.retrieve("memory_write") != nullptr); |
| 667 |
delete_timesteps = (options_.retrieve("delete_timesteps") != nullptr); |
| 668 |
lower_case_variable_names = (options_.retrieve("native_variable_names") == nullptr); |
| 669 |
disable_field_recognition = (options_.retrieve("disable_field_recognition") != nullptr); |
| 670 |
retain_empty_blocks = (options_.retrieve("retain_empty_blocks") != nullptr); |
| 671 |
boundary_sideset = (options_.retrieve("boundary_sideset") != nullptr); |
| 672 |
|
| 673 |
inFiletype = options_.get_option_value("in_type", inFiletype); |
| 674 |
outFiletype = options_.get_option_value("out_type", outFiletype); |
| 675 |
|
| 676 |
#if defined(SEACAS_HAVE_MPI) |
| 677 |
// Should be only for parallel-aware-exodus, but not sure yet how to avoid the coupling to get |
| 678 |
// that define here |
| 679 |
compose_output = options_.get_option_value("compose", compose_output); |
| 680 |
#endif |
| 681 |
|
| 682 |
{ |
| 683 |
const char *temp = options_.retrieve("custom_field"); |
| 684 |
if (temp != nullptr) { |
| 685 |
customField = temp; |
| 686 |
} |
| 687 |
} |
| 688 |
|
| 689 |
selectedChangeSets = options_.get_option_value("select_change_sets", selectedChangeSets); |
| 690 |
changeSetName = options_.get_option_value("extract_group", changeSetName); |
| 691 |
changeSetName = options_.get_option_value("extract_change_set", changeSetName); |
| 692 |
|
| 693 |
{ |
| 694 |
const char *temp = options_.retrieve("field_suffix_separator"); |
| 695 |
if (temp != nullptr) { |
| 696 |
fieldSuffixSeparator = temp[0]; |
| 697 |
} |
| 698 |
} |
| 699 |
|
| 700 |
{ |
| 701 |
const char *temp = options_.retrieve("omit_blocks"); |
| 702 |
if (temp != nullptr) { |
| 703 |
auto omit_str = Ioss::tokenize(std::string(temp), ","); |
| 704 |
for (const auto &str : omit_str) { |
| 705 |
omitted_blocks.push_back(str); |
| 706 |
} |
| 707 |
} |
| 708 |
} |
| 709 |
|
| 710 |
{ |
| 711 |
const char *temp = options_.retrieve("omit_sets"); |
| 712 |
if (temp != nullptr) { |
| 713 |
auto omit_str = Ioss::tokenize(std::string(temp), ","); |
| 714 |
for (const auto &str : omit_str) { |
| 715 |
omitted_sets.push_back(str); |
| 716 |
} |
| 717 |
} |
| 718 |
} |
| 719 |
|
| 720 |
{ |
| 721 |
const char *temp = options_.retrieve("surface_split_scheme"); |
| 722 |
if (temp != nullptr) { |
| 723 |
if (std::strcmp(temp, "TOPOLOGY") == 0) { |
| 724 |
surface_split_type = 1; |
| 725 |
} |
| 726 |
else if (std::strcmp(temp, "ELEMENT_BLOCK") == 0) { |
| 727 |
surface_split_type = 2; |
| 728 |
} |
| 729 |
else if (std::strcmp(temp, "BLOCK") == 0) { |
| 730 |
surface_split_type = 2; |
| 731 |
} |
| 732 |
else if (std::strcmp(temp, "NO_SPLIT") == 0) { |
| 733 |
surface_split_type = 3; |
| 734 |
} |
| 735 |
} |
| 736 |
} |
| 737 |
|
| 738 |
{ |
| 739 |
const char *temp = options_.retrieve("data_storage"); |
| 740 |
if (temp != nullptr) { |
| 741 |
data_storage_type = 0; |
| 742 |
if (std::strcmp(temp, "POINTER") == 0) { |
| 743 |
data_storage_type = 1; |
| 744 |
} |
| 745 |
#ifdef SEACAS_HAVE_KOKKOS |
| 746 |
else if (std::strcmp(temp, "KOKKOS_VIEW_1D") == 0) { |
| 747 |
data_storage_type = 3; |
| 748 |
} |
| 749 |
else if (std::strcmp(temp, "KOKKOS_VIEW_2D") == 0) { |
| 750 |
data_storage_type = 4; |
| 751 |
} |
| 752 |
else if (std::strcmp(temp, "KOKKOS_VIEW_2D_LAYOUTRIGHT_HOSTSPACE") == 0) { |
| 753 |
data_storage_type = 5; |
| 754 |
} |
| 755 |
#endif |
| 756 |
|
| 757 |
if (data_storage_type == 0) { |
| 758 |
if (my_processor == 0) { |
| 759 |
fmt::print(stderr, "ERROR: Option data_storage must be one of\n"); |
| 760 |
#ifdef SEACAS_HAVE_KOKKOS |
| 761 |
fmt::print(stderr, " POINTER, KOKKOS_VIEW_1D, KOKKOS_VIEW_2D, or " |
| 762 |
"KOKKOS_VIEW_2D_LAYOUTRIGHT_HOSTSPACE\n"); |
| 763 |
#else |
| 764 |
fmt::print(stderr, " POINTER\n"); |
| 765 |
#endif |
| 766 |
} |
| 767 |
return false; |
| 768 |
} |
| 769 |
} |
| 770 |
} |
| 771 |
|
| 772 |
maximum_time = options_.get_option_value("Maximum_Time", maximum_time); |
| 773 |
minimum_time = options_.get_option_value("Minimum_Time", minimum_time); |
| 774 |
time_scale = options_.get_option_value("time_scale", time_scale); |
| 775 |
time_offset = options_.get_option_value("time_offset", time_offset); |
| 776 |
|
| 777 |
{ |
| 778 |
const char *temp = options_.retrieve("select_times"); |
| 779 |
if (temp != nullptr) { |
| 780 |
auto time_str = Ioss::tokenize(std::string(temp), ","); |
| 781 |
for (const auto &str : time_str) { |
| 782 |
auto time = std::stod(str); |
| 783 |
selected_times.push_back(time); |
| 784 |
} |
| 785 |
Ioss::sort(selected_times.begin(), selected_times.end()); |
| 786 |
} |
| 787 |
} |
| 788 |
|
| 789 |
append_time = options_.get_option_value("append_after_time", append_time); |
| 790 |
flush_interval = options_.get_option_value("flush_interval", flush_interval); |
| 791 |
timestep_delay = options_.get_option_value("delay", timestep_delay); |
| 792 |
append_step = options_.get_option_value("append_after_step", append_step); |
| 793 |
|
| 794 |
if (options_.retrieve("copyright") != nullptr) { |
| 795 |
if (my_processor == 0) { |
| 796 |
Ioss::Utils::copyright(std::cerr, "1999-2022"); |
| 797 |
} |
| 798 |
exit(EXIT_SUCCESS); |
| 799 |
} |
| 800 |
|
| 801 |
if (!changeSetName.empty() && !selectedChangeSets.empty()) { |
| 802 |
if (my_processor == 0) { |
| 803 |
fmt::print( |
| 804 |
stderr, |
| 805 |
"ERROR: Only one of 'extract_change_set' or 'select_change_sets'can be specified.\n"); |
| 806 |
} |
| 807 |
return false; |
| 808 |
} |
| 809 |
|
| 810 |
// Parse remaining options as directory paths. |
| 811 |
if (option_index < argc - 1) { |
| 812 |
while (option_index < argc - 1) { |
| 813 |
inputFile.emplace_back(argv[option_index++]); |
| 814 |
} |
| 815 |
outputFile = argv[option_index]; |
| 816 |
} |
| 817 |
else { |
| 818 |
if (my_processor == 0) { |
| 819 |
fmt::print(stderr, "\nERROR: input and output filename not specified\n\n"); |
| 820 |
} |
| 821 |
return false; |
| 822 |
} |
| 823 |
|
| 824 |
// If inFileType and/or outFileType not specified, see if can infer from file suffix type... |
| 825 |
if (inFiletype == "unknown") { |
| 826 |
inFiletype = Ioss::Utils::get_type_from_file(inputFile[0]); |
| 827 |
} |
| 828 |
if (outFiletype == "unknown") { |
| 829 |
outFiletype = Ioss::Utils::get_type_from_file(outputFile); |
| 830 |
} |
| 831 |
return true; |
| 832 |
} |