Debian Codegraph @

packages/seacas/applications/slice/SL_SystemInterface.C

raw
1 // Copyright(C) 1999-2025 National Technology & Engineering Solutions
2 // of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with
3 // NTESS, the U.S. Government retains certain rights in this software.
4 //
5 // See packages/seacas/LICENSE for details
6 #include "SL_SystemInterface.h"
7
8 #include <algorithm>
9 #include <functional>
10 #include <iostream>
11 #include <vector>
12
13 #include <climits>
14 #include <cstdlib>
15 #include <cstring>
16
17 #include "SL_Version.h"
18 #include <SL_tokenize.h>
19 #include <copyright.h>
20 #include <fmt/format.h>
21 #include <open_file_limit.h>
22
23 namespace {
24 bool str_equal(const std::string &s1, const std::string &s2)
25 {
26 return (s1.size() == s2.size()) &&
27 std::equal(s1.begin(), s1.end(), s2.begin(),
28 [](char a, char b) { return std::tolower(a) == std::tolower(b); });
29 }
30
31 #if 0
32 void parse_variable_names(const char *tokens, StringIdVector *variable_list);
33 void parse_integer_list(const char *tokens, std::vector<int> *list);
34 void parse_omissions(const char *tokens, Omissions *omissions,
35 const std::string &basename, bool require_ids);
36 #endif
37 } // namespace
38
39 SystemInterface::SystemInterface() { enroll_options(); }
40
41 void SystemInterface::enroll_options()
42 {
43 options_.usage("[options] file_to_split [output_file]");
44
45 options_.enroll("help", GetLongOption::NoValue, "Print this summary and exit", nullptr);
46
47 options_.enroll("in_type", GetLongOption::MandatoryValue,
48 "File format for input mesh file (default = exodus)", "exodusii", nullptr, true);
49
50 options_.enroll("processors", GetLongOption::MandatoryValue,
51 "Number of processors to decompose the mesh for", "1");
52
53 options_.enroll(
54 "method", GetLongOption::MandatoryValue,
55 "Decomposition method\n"
56 "\t\t'linear' : #elem/#proc to each processor\n"
57 "\t\t'scattered': Shuffle elements to each processor (cyclic)\n"
58 "\t\t'random' : Random distribution of elements, maintains balance\n"
59 #if USE_METIS
60 "\t\t'rb' : Metis multilevel recursive bisection\n"
61 "\t\t'kway' : Metis multilevel k-way graph partitioning\n"
62 #endif
63 #if USE_ZOLTAN
64 "\t\t'rib' : Zoltan recursive-inertial-bisection\n"
65 "\t\t'rcb' : Zoltan recursive-coordinate-bisection\n"
66 "\t\t'hsfc' : Zoltan hilbert-space-filling curve\n"
67 #endif
68 "\t\t'variable' : Read element-processor assignment from an element variable\n"
69 "\t\t'map' : Read element-processor assignment from an element map [processor_id]\n"
70 "\t\t'file' : Read element-processor assignment from file",
71 "linear");
72
73 options_.enroll(
74 "decomposition_name", GetLongOption::MandatoryValue,
75 "The name of the element variable (method = `variable`)\n"
76 "\t\tor element map (method = `map`) containing the element to processor mapping.\n"
77 "\t\tIf no name is specified, then `processor_id` will be used.\n"
78 "\t\tIf the name is followed by a ',' and an integer or 'auto', then\n"
79 "\t\tthe entries in the map will be divided by the integer value or\n"
80 "\t\t(if auto) by `int((max_entry+1)/proc_count)`.",
81 nullptr);
82
83 options_.enroll("decomposition_file", GetLongOption::MandatoryValue,
84 "File containing element to processor mapping\n"
85 "\t\twhen decomposition method 'file' specified\n"
86 "\t\tThe file contains multiple lines, each line has 1 or 2 integers.\n"
87 "\t\tIf a single integer, it is the processor for the current element\n"
88 "\t\tIf two integers (count proc), they specify that the next\n"
89 "\t\t\t'count' elements are on processor 'proc'",
90 nullptr);
91
92 #if USE_ZOLTAN
93 options_.enroll(
94 "ignore_x", GetLongOption::NoValue,
95 "If using `rcb`, `rib`, or `hsfc`, decompose as if mesh in yz plane. Ignore x dimension.",
96 nullptr);
97 options_.enroll(
98 "ignore_y", GetLongOption::NoValue,
99 "If using `rcb`, `rib`, or `hsfc`, decompose as if mesh in xz plane. Ignore y dimension.",
100 nullptr);
101 options_.enroll(
102 "ignore_z", GetLongOption::NoValue,
103 "If using `rcb`, `rib`, or `hsfc`, decompose as if mesh in xy plane. Ignore z dimension.",
104 nullptr);
105 #endif
106 options_.enroll("contiguous_decomposition", GetLongOption::NoValue,
107 "If the input mesh is contiguous, create contiguous decompositions", nullptr,
108 nullptr);
109
110 options_.enroll("line_decomp", GetLongOption::OptionalValue,
111 "Generate the `lines` or `columns` of elements from the specified surface(s).\n"
112 "\t\tSpecify a comma-separated list of surface/sideset names from which the "
113 "lines will grow.\n"
114 "\t\tOmit or enter 'ALL' for all surfaces in model\n"
115 "\t\tDo not split a line/column across processors.",
116 nullptr, "ALL", true);
117 options_.enroll("output_decomp_map", GetLongOption::NoValue,
118 "Do not output the split files; instead write the decomposition information to "
119 "an element map.\n"
120 "\t\tThe name of the map is specified by `-decomposition_name`",
121 nullptr);
122
123 options_.enroll("output_decomp_field", GetLongOption::NoValue,
124 "Do not output the split files; instead write the decomposition information to "
125 "an element map.\n"
126 "\t\tThe name of the field is specified by `-decomposition_name`",
127 nullptr);
128
129 options_.enroll("output_path", GetLongOption::MandatoryValue,
130 "Path to where decomposed files will be written.\n"
131 "\t\tThe string %P will be replaced with the processor count\n"
132 "\t\tThe string %M will be replaced with the decomposition method.\n"
133 "\t\tDefault is the location of the input mesh",
134 nullptr, nullptr, true);
135
136 options_.enroll("Partial_read_count", GetLongOption::MandatoryValue,
137 "Split the coordinate and connectivity reads into a\n"
138 "\t\tmaximum of this many nodes or elements at a time to reduce memory.",
139 "1000000000");
140
141 options_.enroll("max-files", GetLongOption::MandatoryValue,
142 "Specify maximum number of processor files to write at one time.\n"
143 "\t\tUsually use default value; this is typically used for debugging.",
144 nullptr, nullptr, true);
145
146 options_.enroll("netcdf4", GetLongOption::NoValue,
147 "Output database will be a netcdf4 "
148 "hdf5-based file instead of the "
149 "classical netcdf file format",
150 nullptr);
151
152 options_.enroll("netcdf5", GetLongOption::NoValue,
153 "Output database will be a netcdf5 (CDF5) "
154 "file instead of the classical netcdf file format",
155 nullptr);
156
157 options_.enroll("64-bit", GetLongOption::NoValue, "Use 64-bit integers on output database",
158 nullptr, nullptr, true);
159
160 options_.enroll("zlib", GetLongOption::NoValue,
161 "Use the Zlib / libz compression method if compression is enabled (default) "
162 "[exodus only, enables netcdf-4].",
163 nullptr);
164
165 options_.enroll("szip", GetLongOption::NoValue,
166 "Use SZip compression. [exodus only, enables netcdf-4]", nullptr);
167 options_.enroll("zstd", GetLongOption::NoValue,
168 "Use Zstd compression. [exodus only, enables netcdf-4, experimental]", nullptr);
169 options_.enroll("bzip2", GetLongOption::NoValue,
170 "Use Bzip2 compression. [exodus only, enables netcdf-4, experimental]", nullptr);
171
172 options_.enroll("shuffle", GetLongOption::NoValue,
173 "Use a netcdf4 hdf5-based file and use hdf5s shuffle mode with compression.",
174 nullptr);
175
176 options_.enroll("compress", GetLongOption::MandatoryValue,
177 "Specify the compression level to be used. Values depend on algorithm:\n"
178 "\t\tzlib/bzip2: 0..9\t\tszip: even, 4..32\t\tzstd: -131072..22",
179 nullptr);
180
181 options_.enroll("quantize_nsd", GetLongOption::MandatoryValue,
182 "Use the lossy quantize compression method. Value specifies number of digits to "
183 "retain (1..15) [exodus only]",
184 nullptr, nullptr, true);
185
186 options_.enroll("debug", GetLongOption::MandatoryValue,
187 "debug level (values are or'd)\n"
188 "\t\t 1 = timing information.\n"
189 "\t\t 2 = Communication, NodeSet, Sideset information.\n"
190 "\t\t 4 = Progress information in File/Rank.\n"
191 "\t\t 8 = File/Rank Decomposition information.\n"
192 "\t\t 16 = Chain/Line generation/decomp information.\n"
193 "\t\t 32 = Show decomposition histogram (elements / rank).",
194 "0");
195
196 options_.enroll("version", GetLongOption::NoValue, "Print version and exit", nullptr);
197
198 options_.enroll("copyright", GetLongOption::NoValue, "Show copyright and license data.", nullptr);
199
200 #if 0
201 options_.enroll("omit_blocks", GetLongOption::MandatoryValue,
202 "Omit the specified part/block pairs. The specification is\n"
203 "\t\tp#:block_id1:block_id2,p#:block_id1. For example, to\n"
204 "\t\tOmit block id 1,3,4 from part 1; block 2 3 4 from part 2;\n"
205 "\t\tand block 8 from part5, specify\n"
206 "\t\t\t '-omit_blocks p1:1:3:4,p2:2:3:4,p5:8'",
207 nullptr);
208
209 options_.enroll("omit_nodesets", GetLongOption::OptionalValue,
210 "If no value, then don't transfer any nodesets to output file.\n"
211 "\t\tIf just p#,p#,... specified, then omit sets on specified parts\n"
212 "\t\tIf p#:id1:id2,p#:id2,id4... then omit the sets with the specified\n"
213 "\t\tid in the specified parts.",
214 0, "ALL");
215
216 options_.enroll("omit_sidesets", GetLongOption::OptionalValue,
217 "If no value, then don't transfer any sidesets to output file.\n"
218 "\t\tIf just p#,p#,... specified, then omit sets on specified parts\n"
219 "\t\tIf p#:id1:id2,p#:id2,id4... then omit the sets with the specified\n"
220 "\t\tid in the specified parts.",
221 0, "ALL");
222
223 options_.enroll("steps", GetLongOption::MandatoryValue,
224 "Specify subset of timesteps to transfer to output file.\n"
225 "\t\tFormat is beg:end:step. 1:10:2 --> 1,3,5,7,9\n"
226 "\t\tTo only transfer last step, use '-steps LAST'",
227 "1:");
228
229 options_.enroll("disable_field_recognition", GetLongOption::NoValue,
230 "Do not try to combine scalar fields into higher-order fields such as\n"
231 "\t\tvectors or tensors based on the field suffix",
232 nullptr);
233
234 #endif
235 }
236
237 bool SystemInterface::parse_options(int argc, char **argv)
238 {
239 #if (__SUNPRO_CC == 0x500)
240 using namespace std;
241 #endif
242
243 int option_index = options_.parse(argc, argv);
244 if (option_index < 1) {
245 return false;
246 }
247
248 if (options_.retrieve("help") != nullptr) {
249 options_.usage();
250 fmt::print(stderr, "\n\t Can also set options via SLICE_OPTIONS environment variable.\n");
251 fmt::print(stderr, "\n\tDocumentation: "
252 "https://sandialabs.github.io/seacas-docs/sphinx/html/index.html#slice\n");
253 fmt::print(stderr, "\n\t->->-> Send email to [email protected] for slice support.<-<-<-\n");
254 exit(EXIT_SUCCESS);
255 }
256
257 if (options_.retrieve("version") != nullptr) {
258 // Version is printed up front, just exit...
259 exit(0);
260 }
261
262 if (options_.retrieve("copyright") != nullptr) {
263 fmt::print("{}", copyright("2016-2021"));
264 exit(EXIT_SUCCESS);
265 }
266
267 if (option_index < argc) {
268 inputFile_ = argv[option_index++];
269 }
270 else {
271 fmt::print(stderr, "\nERROR: no input mesh file specified\n\n");
272 return false;
273 }
274
275 if (option_index < argc) {
276 nemesisFile_ = argv[option_index++];
277 }
278 else {
279 nemesisFile_ = inputFile_;
280 }
281
282 // Get options from environment variable also...
283 char *options = getenv("SLICE_OPTIONS");
284 if (options != nullptr) {
285 fmt::print(
286 stderr,
287 "\nThe following options were specified via the SLICE_OPTIONS environment variable:\n"
288 "\t{}\n\n",
289 options);
290 options_.parse(options, GetLongOption::basename(*argv));
291 }
292
293 processorCount_ = options_.get_option_value("processors", processorCount_);
294 partialReadCount_ = options_.get_option_value("Partial_read_count", partialReadCount_);
295 maxFiles_ =
296 options_.get_option_value("max-files", open_file_limit() - 1); // -1 for output exodus file.
297 debugLevel_ = options_.get_option_value("debug", debugLevel_);
298 inputFormat_ = options_.get_option_value("in_type", inputFormat_);
299 decompMethod_ = options_.get_option_value("method", decompMethod_);
300
301 {
302 if (decompMethod_ == "file") {
303 const char *temp = options_.retrieve("decomposition_file");
304 if (temp != nullptr) {
305 decompFile_ = temp;
306 }
307 else {
308 fmt::print(stderr,
309 "\nThe 'file' decomposition method was specified, but no element "
310 "to processor mapping file was specified via the -decomposition_file option\n");
311 return false;
312 }
313 }
314 }
315
316 // Only used in a few methods, but see if set anyway...
317 decompVariable_ = options_.get_option_value("decomposition_name", decompVariable_);
318
319 {
320 const char *temp = options_.retrieve("line_decomp");
321 if (temp != nullptr) {
322 lineSurfaceList_ = temp;
323 lineDecomp_ = true;
324 }
325 }
326
327 outputPath_ = options_.get_option_value("output_path", outputPath_);
328 ints64Bit_ = (options_.retrieve("64-bit") != nullptr);
329
330 if (options_.retrieve("netcdf4") != nullptr) {
331 netcdf4_ = true;
332 netcdf5_ = false;
333 }
334
335 if (options_.retrieve("netcdf5") != nullptr) {
336 netcdf5_ = true;
337 netcdf4_ = false;
338 }
339
340 shuffle_ = (options_.retrieve("shuffle") != nullptr);
341 zlib_ = (options_.retrieve("zlib") != nullptr);
342 szip_ = (options_.retrieve("szip") != nullptr);
343 zstd_ = (options_.retrieve("zstd") != nullptr);
344 bz2_ = (options_.retrieve("bzip2") != nullptr);
345
346 if ((szip_ ? 1 : 0) + (zlib_ ? 1 : 0) + (zstd_ ? 1 : 0) + (bz2_ ? 1 : 0) > 1) {
347 fmt::print(stderr,
348 "ERROR: Only one of 'szip' or 'zlib' or 'zstd' or 'bzip2' can be specified.\n");
349 }
350
351 {
352 const char *temp = options_.retrieve("compress");
353 if (temp != nullptr) {
354 compressionLevel_ = std::strtol(temp, nullptr, 10);
355 if (!szip_ && !zlib_ && !zstd_ && !bz2_) {
356 zlib_ = true;
357 }
358
359 if (zlib_ || bz2_) {
360 if (compressionLevel_ < 0 || compressionLevel_ > 9) {
361 fmt::print(stderr,
362 "ERROR: Bad compression level {}, valid value is between 0 and 9 inclusive "
363 "for gzip/zlib compression.\n",
364 compressionLevel_);
365 return false;
366 }
367 }
368 else if (szip_) {
369 if (compressionLevel_ % 2 != 0) {
370 fmt::print(
371 stderr,
372 "ERROR: Bad compression level {}. Must be an even value for szip compression.\n",
373 compressionLevel_);
374 return false;
375 }
376 if (compressionLevel_ < 4 || compressionLevel_ > 32) {
377 fmt::print(stderr,
378 "ERROR: Bad compression level {}, valid value is between 4 and 32 inclusive "
379 "for szip compression.\n",
380 compressionLevel_);
381 return false;
382 }
383 }
384 }
385 }
386
387 {
388 const char *temp = options_.retrieve("quantize_nsd");
389 if (temp != nullptr) {
390 quantizeNSD_ = std::strtol(temp, nullptr, 10);
391 if (!szip_ && !zlib_ && !zstd_ && !bz2_) {
392 zlib_ = true;
393 }
394 }
395 }
396
397 contig_ = options_.retrieve("contiguous_decomposition") != nullptr;
398 outputDecompMap_ = options_.retrieve("output_decomp_map") != nullptr;
399 outputDecompField_ = options_.retrieve("output_decomp_field") != nullptr;
400 #if USE_ZOLTAN
401 ignore_x_ = options_.retrieve("ignore_x") != nullptr;
402 ignore_y_ = options_.retrieve("ignore_y") != nullptr;
403 ignore_z_ = options_.retrieve("ignore_z") != nullptr;
404 #endif
405
406 if (outputDecompMap_ && outputDecompField_) {
407 fmt::print(
408 stderr,
409 "\nERROR: Cannot specify BOTH `output_decomp_map` and `output_decomp_field` options.\n"
410 " Can only specify one of the two options.\n\n");
411 exit(EXIT_FAILURE);
412 }
413
414 #if 0
415 {
416 const char *temp = options_.retrieve("steps");
417 if (temp != nullptr) {
418 parse_step_option(temp);
419 }
420 }
421
422 {
423 const char *temp = options_.retrieve("omit_blocks");
424 parse_omissions(temp, &blockOmissions_, "block", true);
425 }
426
427 {
428 const char *temp = options_.retrieve("gvar");
429 parse_variable_names(temp, &globalVarNames_);
430 }
431
432 {
433 const char *temp = options_.retrieve("nvar");
434 parse_variable_names(temp, &nodeVarNames_);
435 }
436
437 {
438 const char *temp = options_.retrieve("evar");
439 parse_variable_names(temp, &elemVarNames_);
440 }
441
442 {
443 const char *temp = options_.retrieve("nsetvar");
444 parse_variable_names(temp, &nsetVarNames_);
445 }
446
447 {
448 const char *temp = options_.retrieve("ssetvar");
449 parse_variable_names(temp, &ssetVarNames_);
450 }
451
452 disableFieldRecognition_ = options_.retrieve("disable_field_recognition") != nullptr;
453 #endif
454
455 if (processorCount_ <= 1) {
456 fmt::print(stderr,
457 "\nERROR: The `-processors` argument must be greater than 1.\n The entered "
458 "value of {} is not valid.\n",
459 processorCount_);
460 return false;
461 }
462 return true;
463 }
464
465 void SystemInterface::parse_step_option(const char *tokens)
466 {
467 //: The defined formats for the count attribute are:<br>
468 //: <ul>
469 //: <li><missing> -- default -- 1 <= count <= oo (all steps)</li>
470 //: <li>"X" -- X <= count <= X (just step X). If X == LAST, last step
471 // only</li>
472 //: <li>"X:Y" -- X to Y by 1</li>
473 //: <li>"X:" -- X to oo by 1</li>
474 //: <li>":Y" -- 1 to Y by 1</li>
475 //: <li>"::Z" -- 1 to oo by Z</li>
476 //: <li>"LAST" -- last step only</li>
477 //: </ul>
478 //: The count and step must always be >= 0
479
480 // Break into tokens separated by ":"
481
482 // Default is given in constructor above...
483
484 if (tokens != nullptr) {
485 if (strchr(tokens, ':') != nullptr) {
486 // The string contains a separator
487
488 std::array<int, 3> vals = {stepMin_, stepMax_, stepInterval_};
489
490 int j = 0;
491 for (int &val : vals) {
492 // Parse 'i'th field
493 char tmp_str[128];
494 ;
495 int k = 0;
496
497 while (tokens[j] != '\0' && tokens[j] != ':') {
498 tmp_str[k++] = tokens[j++];
499 }
500
501 tmp_str[k] = '\0';
502 if (strlen(tmp_str) > 0) {
503 val = strtoul(tmp_str, nullptr, 0);
504 }
505
506 if (tokens[j++] == '\0') {
507 break; // Reached end of string
508 }
509 }
510 stepMin_ = abs(vals[0]);
511 stepMax_ = abs(vals[1]);
512 stepInterval_ = abs(vals[2]);
513 }
514 else if (str_equal("LAST", tokens)) {
515 stepMin_ = stepMax_ = -1;
516 }
517 else {
518 // Does not contain a separator, min == max
519 stepMin_ = stepMax_ = strtol(tokens, nullptr, 0);
520 }
521 }
522 }
523 void SystemInterface::dump(std::ostream & /*unused*/) const {}
524
525 void SystemInterface::show_version()
526 {
527 fmt::print("Slice\n"
528 "\t(A code for decomposing finite element meshes for running parallel analyses.)\n"
529 "\t(Version: {}) Modified: {}\n",
530 qainfo[2], qainfo[1]);
531 }
532
533 namespace {
534 #if 0
535 std::string LowerCase(const std::string &name)
536 {
537 std::string s = name;
538 std::transform(s.begin(), s.end(), // source
539 s.begin(), // destination
540 ::tolower); // operation
541 return s;
542 }
543
544 using StringVector = std::vector<std::string>;
545 bool string_id_sort(const std::pair<std::string, int> &t1, const std::pair<std::string, int> &t2)
546 {
547 return t1.first < t2.first || (!(t2.first < t1.first) && t1.second < t2.second);
548 }
549
550 void parse_variable_names(const char *tokens, StringIdVector *variable_list)
551 {
552 // Break into tokens separated by ","
553 if (tokens != nullptr) {
554 std::string token_string(tokens);
555 StringVector var_list;
556 var_list = SLIB::tokenize(token_string, ",");
557
558 // At this point, var_list is either a single string, or a string
559 // separated from 1 or more block ids with ":" delimiter.
560 // For example, sigxx:1:10:100 would indicate that the variable
561 // "sigxx" should be written only for blocks with id 1, 10, and
562 // 100. "sigxx" would indicate that the variable should be
563 // written for all blocks.
564 std::vector<std::string>::iterator I = var_list.begin();
565 while (I != var_list.end()) {
566 StringVector name_id;
567 name_id = SLIB::tokenize(*I, ":");
568 std::string var_name = LowerCase(name_id[0]);
569 if (name_id.size() == 1) {
570 (*variable_list).push_back(std::make_pair(var_name,0));
571 } else {
572 for (size_t i=1; i < name_id.size(); i++) {
573 // Convert string to integer...
574 int id = std::stoi(name_id[i]);
575 (*variable_list).push_back(std::make_pair(var_name,id));
576 }
577 }
578 ++I;
579 }
580 // Sort the list...
581 std::sort(variable_list->begin(), variable_list->end(), string_id_sort);
582 }
583 }
584
585 void parse_integer_list(const char *tokens, std::vector<int> *list)
586 {
587 // Break into tokens separated by ","
588 if (tokens != nullptr) {
589 if (LowerCase(tokens) == "all") {
590 (*list).push_back(0);
591 return;
592 }
593
594 std::string token_string(tokens);
595 StringVector part_list;
596 part_list = SLIB::tokenize(token_string, ",");
597
598 std::vector<std::string>::iterator I = part_list.begin();
599 while (I != part_list.end()) {
600 int id = std::stoi(*I);
601 (*list).push_back(id);
602 ++I;
603 }
604 }
605 }
606
607 void parse_omissions(const char *tokens, Omissions *omissions,
608 const std::string &basename, bool require_ids)
609 {
610 // to Omit block id 1,3,4 from part 1; block 2 3 4 from part 2;
611 // and block 8 from part5, specify
612 // '-omit_blocks p1:1:3:4,p2:2:3:4,p5:8'
613
614 // Break into tokens separated by "," Each token will then be a
615 // ":" separated list of blocks to be omitted for the specified
616 // part.
617
618 // If "require_ids" is true, then there must be at least one id
619 // following the part specification. If false, then it is OK to
620 // just specify a part number and all entities (typically nset or
621 // sset) will be omitted on that part.
622
623 if (tokens == nullptr)
624 return;
625
626 std::string token_string(tokens);
627 StringVector part_block_list;
628 part_block_list = SLIB::tokenize(token_string, ",");
629
630 // Now, for each token in 'part_block_list', split by ":"
631 // The result should be a string starting with 'p' followed by an
632 // integer indicating the part followed by 1 or more strings which
633 // are the block ids of the blocks to be omitted for that part.
634 //
635 // Parts are 1-based. Store the results in the 'omissions' set as
636 // the pair (part#, block_id).
637 std::vector<std::string>::iterator I = part_block_list.begin();
638 while (I != part_block_list.end()) {
639 StringVector part_block;
640 part_block = SLIB::tokenize(*I, ":");
641 if (part_block.empty() || (part_block[0][0] != 'p' && part_block[0][0] != 'P')) {
642 fmt::print(stderr, "ERROR: Bad syntax specifying the part number. Use 'p' + part number\n"
643 " For example -omit_blocks p1:1:2:3,p2:2:3:4\n");
644 exit(EXIT_FAILURE);
645 }
646 if (require_ids && part_block.size() == 1) {
647 fmt::print(stderr, "ERROR: No block ids were found following the part specification.\n"
648 " for part {}\n", part_block[0]);
649 exit(EXIT_FAILURE);
650 }
651
652 // Extract the part number...
653 std::string part(part_block[0],1);
654 int part_num = std::stoi(part) - 1;
655
656 // If no blocks specified for a part, then omit all entities for
657 // this part. Since don't know how many entities there are,
658 // store the id as '0' to signify all.
659 if (part_block.size() == 1) {
660 (*omissions)[part_num].push_back("ALL");
661 } else {
662 // Get the list of blocks to omit for this part...
663 std::vector<std::string>::iterator J = part_block.begin(); ++J; // Skip p#
664 while (J != part_block.end()) {
665 std::string block = *J;
666 std::string name = basename + '_'+ block;
667 (*omissions)[part_num].push_back(name);
668 ++J;
669 }
670 }
671 ++I;
672 }
673 }
674 #endif
675 } // namespace