Debian Codegraph @

packages/seacas/applications/epu/EP_SystemInterface.h

raw
1 /*
2 * Copyright(C) 1999-2022, 2024, 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 #pragma once
9
10 #include "GetLongOpt.h" // for GetLongOption
11 #include <climits> // for INT_MAX
12 #include <iosfwd> // for ostream
13 #include <string> // for string
14 #include <utility> // for pair
15 #include <vector> // for vector
16
17 namespace Excn {
18 using StringIdVector = std::vector<std::pair<std::string, int>>;
19
20 class SystemInterface
21 {
22 public:
23 explicit SystemInterface(int rank = 0);
24
25 bool parse_options(int argc, char **argv);
26
27 int debug() const { return debugLevel_; }
28 int processor_count() const { return processorCount_; }
29 int start_part() const { return startPart_; }
30 int part_count() const;
31 int screen_width() const { return screenWidth_; }
32
33 int step_min() const { return stepMin_; }
34 int step_max() const { return stepMax_; }
35 int step_interval() const { return stepInterval_; }
36 int subcycle() const { return subcycle_; }
37 int cycle() const { return cycle_; }
38 int selected_change_set() const { return selectedChangeSet_; }
39
40 void subcycle_join(bool tf) { subcycleJoin_ = tf; }
41 void subcycle(int cycles) { subcycle_ = cycles; }
42 void processor_count(int count) { processorCount_ = count; }
43 void step_min(int my_step_min) { stepMin_ = my_step_min; }
44 void step_max(int my_step_max) { stepMax_ = my_step_max; }
45 void step_interval(int interval) { stepInterval_ = interval; }
46 void set_output_filename(const std::string &filename) const { outputFilename_ = filename; }
47 std::string output_filename() const { return outputFilename_; }
48
49 std::string cwd() const { return cwd_; }
50 std::string basename() const { return basename_; }
51 std::string exodus_suffix() const { return inExtension_; }
52 std::string output_suffix() const;
53
54 std::string root_dir() const { return rootDirectory_; }
55 std::string sub_dir() const { return subDirectory_; }
56
57 bool add_nodal_communication_map() const { return addNodalCommunicationMap_; }
58 bool add_processor_id_field() const { return addProcessorIdField_; }
59 bool add_processor_id_map() const { return addProcessorIdMap_; }
60 bool sum_shared_nodes() const { return sumSharedNodes_; }
61 bool use_netcdf4() const { return useNetcdf4_; }
62 bool use_netcdf5() const { return useNetcdf5_; }
63 void set_use_netcdf4() const { useNetcdf4_ = true; }
64 bool append() const { return append_; }
65 bool map_element_ids() const { return mapIds_; }
66 bool map_edge_ids() const { return mapEdgeIds_; }
67 bool map_face_ids() const { return mapFaceIds_; }
68 bool omit_nodesets() const { return omitNodesets_; }
69 bool omit_sidesets() const { return omitSidesets_; }
70 bool omit_edgeblocks() const { return omitEdgeBlocks_; }
71 bool omit_faceblocks() const { return omitFaceBlocks_; }
72 bool int64() const { return intIs64Bit_; }
73 void set_int64() const { intIs64Bit_ = true; }
74 int compress_data() const { return compressionLevel_; }
75 bool zlib() const { return zlib_; }
76 bool szip() const { return szip_; }
77 bool zstd() const { return zstd_; }
78 bool bz2() const { return bz2_; }
79 int quantize_nsd() const { return quantizeNSD_; }
80 bool quantize() const { return quantizeNSD_ > 0; }
81 bool subcycle_join() const { return subcycleJoin_; }
82 bool output_shared_nodes() const { return outputSharedNodes_; }
83 bool is_auto() const { return auto_; }
84 bool keep_temporary() const { return keepTemporary_; }
85 bool remove_file_per_rank_files() const;
86 bool verify_valid_file() const { return verifyValidFile_; }
87 int max_open_files() const
88 {
89 return maxOpenFiles_;
90 } // Used to test auto-subcyling without thousands of files...
91
92 StringIdVector global_var_names() const { return globalVarNames_; }
93 StringIdVector node_var_names() const { return nodeVarNames_; }
94 StringIdVector elem_var_names() const { return elemVarNames_; }
95 StringIdVector nset_var_names() const { return nsetVarNames_; }
96 StringIdVector sset_var_names() const { return ssetVarNames_; }
97 StringIdVector edblk_var_names() const { return edblkVarNames_; }
98 StringIdVector fablk_var_names() const { return fablkVarNames_; }
99
100 //! Dumps representation of data in this class to cerr
101 void dump(std::ostream &str) const;
102
103 static void show_version(int rank = 0);
104
105 private:
106 void enroll_options();
107 bool decompose_filename(const std::string &cs);
108
109 /*! The defined formats for the count attribute are:<br>
110 - <missing> -- default -- 1 <= count <= oo (all steps)
111 - "X" -- X <= count <= X (just step X). -1 for last step.
112 - "X:Y" -- X to Y by 1
113 - "X:" -- X to oo by 1
114 - ":Y" -- 1 to Y by 1
115 - "::Z" -- 1 to oo by Z
116
117 The count and step must always be >= 0
118 */
119 void parse_step_option(const char *tokens);
120
121 GetLongOption options_; //!< Options parsing
122
123 std::string inExtension_{};
124 std::string outExtension_{};
125 std::string cwd_{};
126 std::string rootDirectory_{};
127 std::string subDirectory_{};
128 std::string basename_{};
129
130 // Used for a storage area only. Needed for subcyle and auto-join option
131 // Not directly settable through the user-interFace (maybe should be?)
132 mutable std::string outputFilename_{};
133
134 int myRank_{0};
135 int processorCount_{1};
136 int startPart_{};
137 int partCount_{-1};
138 int debugLevel_{};
139 int screenWidth_{};
140 int stepMin_{1};
141 int stepMax_{INT_MAX};
142 int stepInterval_{1};
143 int subcycle_{-1};
144 int cycle_{-1};
145 int compressionLevel_{0};
146 int quantizeNSD_{0};
147 int maxOpenFiles_{0};
148 int selectedChangeSet_{-1};
149 bool zlib_{false};
150 bool szip_{false};
151 bool zstd_{false};
152 bool bz2_{false};
153 bool sumSharedNodes_{false};
154 bool addProcessorIdField_{false};
155 bool addProcessorIdMap_{false};
156 bool mapIds_{true};
157 bool mapEdgeIds_{true};
158 bool mapFaceIds_{true};
159 bool omitNodesets_{false};
160 bool omitSidesets_{false};
161 bool omitEdgeBlocks_{false};
162 bool omitFaceBlocks_{false};
163 mutable bool useNetcdf4_{false};
164 bool useNetcdf5_{false};
165 bool append_{false};
166 mutable bool intIs64Bit_{false};
167 bool subcycleJoin_{false};
168 bool outputSharedNodes_{false};
169 bool auto_{false};
170 bool keepTemporary_{false};
171 bool removeFilePerRankFiles_{false};
172 bool verifyValidFile_{false};
173 bool addNodalCommunicationMap_{false};
174
175 StringIdVector globalVarNames_{};
176 StringIdVector nodeVarNames_{};
177 StringIdVector elemVarNames_{};
178 StringIdVector nsetVarNames_{};
179 StringIdVector ssetVarNames_{};
180 StringIdVector edblkVarNames_{};
181 StringIdVector fablkVarNames_{};
182 };
183
184 inline int SystemInterface::part_count() const
185 {
186 return partCount_ > 0 ? partCount_ : processorCount_;
187 }
188 } // namespace Excn