| 1 |
/* |
| 2 |
* Copyright(C) 1999-2024 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 <vector> // for vector |
| 15 |
|
| 16 |
namespace Cpup { |
| 17 |
using StringVector = std::vector<std::string>; |
| 18 |
|
| 19 |
class SystemInterface |
| 20 |
{ |
| 21 |
public: |
| 22 |
explicit SystemInterface(int rank = 0); |
| 23 |
|
| 24 |
bool parse_options(int argc, char **argv); |
| 25 |
|
| 26 |
int processor_count() const { return processorCount_; } |
| 27 |
int screen_width() const { return screenWidth_; } |
| 28 |
|
| 29 |
int step_min() const { return stepMin_; } |
| 30 |
int step_max() const { return stepMax_; } |
| 31 |
int step_interval() const { return stepInterval_; } |
| 32 |
|
| 33 |
void step_min(int my_step_min) { stepMin_ = my_step_min; } |
| 34 |
void step_max(int my_step_max) { stepMax_ = my_step_max; } |
| 35 |
void step_interval(int interval) { stepInterval_ = interval; } |
| 36 |
void set_output_filename(const std::string &filename) const { outputFilename_ = filename; } |
| 37 |
std::string output_filename() const; |
| 38 |
|
| 39 |
std::string cwd() const { return cwd_; } |
| 40 |
std::string basename() const { return basename_; } |
| 41 |
std::string cgns_suffix() const { return inExtension_; } |
| 42 |
std::string output_suffix() const; |
| 43 |
|
| 44 |
std::string root_dir() const { return rootDirectory_; } |
| 45 |
std::string sub_dir() const { return subDirectory_; } |
| 46 |
|
| 47 |
bool minimize_open_files() const { return minimizeOpenFiles_; } |
| 48 |
bool is_auto() const { return auto_; } |
| 49 |
int debug() const { return debugLevel_; } |
| 50 |
#if 0 |
| 51 |
int start_part() const { return startPart_; } |
| 52 |
int part_count() const; |
| 53 |
int subcycle() const { return subcycle_; } |
| 54 |
int cycle() const { return cycle_; } |
| 55 |
|
| 56 |
void subcycle_join(bool tf) { subcycleJoin_ = tf; } |
| 57 |
void subcycle(int cycles) { subcycle_ = cycles; } |
| 58 |
void processor_count(int count) { processorCount_ = count; } |
| 59 |
bool add_nodal_communication_map() const { return addNodalCommunicationMap_; } |
| 60 |
bool add_processor_id_field() const { return addProcessorIdField_; } |
| 61 |
bool add_processor_id_map() const { return addProcessorIdMap_; } |
| 62 |
bool disable_field_recognition() const { return false; } |
| 63 |
bool sum_shared_nodes() const { return sumSharedNodes_; } |
| 64 |
bool append() const { return append_; } |
| 65 |
bool map_element_ids() const { return mapIds_; } |
| 66 |
bool omit_nodesets() const { return omitNodesets_; } |
| 67 |
bool omit_sidesets() const { return omitSidesets_; } |
| 68 |
bool subcycle_join() const { return subcycleJoin_; } |
| 69 |
bool keep_temporary() const { return keepTemporary_; } |
| 70 |
bool verify_valid_file() const { return verifyValidFile_; } |
| 71 |
int max_open_files() const |
| 72 |
{ |
| 73 |
return maxOpenFiles_; |
| 74 |
} // Used to test auto-subcyling without thousands of files... |
| 75 |
|
| 76 |
StringIdVector global_var_names() const { return globalVarNames_; } |
| 77 |
StringIdVector node_var_names() const { return nodeVarNames_; } |
| 78 |
StringIdVector elem_var_names() const { return elemVarNames_; } |
| 79 |
StringIdVector nset_var_names() const { return nsetVarNames_; } |
| 80 |
StringIdVector sset_var_names() const { return ssetVarNames_; } |
| 81 |
#endif |
| 82 |
const StringVector &var_names() const { return varNames_; } |
| 83 |
//! Dumps representation of data in this class to cerr |
| 84 |
void dump(std::ostream &str) const; |
| 85 |
|
| 86 |
static void show_version(int rank = 0); |
| 87 |
|
| 88 |
private: |
| 89 |
void enroll_options(); |
| 90 |
bool decompose_filename(const std::string &cs); |
| 91 |
|
| 92 |
/*! The defined formats for the count attribute are:<br> |
| 93 |
- <missing> -- default -- 1 <= count <= oo (all steps) |
| 94 |
- "X" -- X <= count <= X (just step X). -1 for last step. |
| 95 |
- "X:Y" -- X to Y by 1 |
| 96 |
- "X:" -- X to oo by 1 |
| 97 |
- ":Y" -- 1 to Y by 1 |
| 98 |
- "::Z" -- 1 to oo by Z |
| 99 |
|
| 100 |
The count and step must always be >= 0 |
| 101 |
*/ |
| 102 |
void parse_step_option(const char *tokens); |
| 103 |
|
| 104 |
GetLongOption options_; //!< Options parsing |
| 105 |
|
| 106 |
StringVector varNames_; |
| 107 |
std::string inExtension_{}; |
| 108 |
std::string outExtension_{}; |
| 109 |
std::string cwd_{}; |
| 110 |
std::string rootDirectory_{}; |
| 111 |
std::string subDirectory_{}; |
| 112 |
std::string basename_{}; |
| 113 |
|
| 114 |
// Used for a storage area only. Needed for subcyle and auto-join option |
| 115 |
// Not directly settable through the user-interFace (maybe should be?) |
| 116 |
mutable std::string outputFilename_{}; |
| 117 |
|
| 118 |
int myRank_{0}; |
| 119 |
int processorCount_{1}; |
| 120 |
int screenWidth_{}; |
| 121 |
int stepMin_{1}; |
| 122 |
int stepMax_{INT_MAX}; |
| 123 |
int stepInterval_{1}; |
| 124 |
int debugLevel_{}; |
| 125 |
bool auto_{false}; |
| 126 |
bool minimizeOpenFiles_{false}; |
| 127 |
#if 0 |
| 128 |
int startPart_{}; |
| 129 |
int partCount_{-1}; |
| 130 |
int subcycle_{-1}; |
| 131 |
int cycle_{-1}; |
| 132 |
int maxOpenFiles_{0}; |
| 133 |
bool sumSharedNodes_{false}; |
| 134 |
bool addProcessorIdField_{false}; |
| 135 |
bool addProcessorIdMap_{false}; |
| 136 |
bool mapIds_{true}; |
| 137 |
bool omitNodesets_{false}; |
| 138 |
bool omitSidesets_{false}; |
| 139 |
bool append_{false}; |
| 140 |
bool subcycleJoin_{false}; |
| 141 |
bool keepTemporary_{false}; |
| 142 |
bool verifyValidFile_{false}; |
| 143 |
bool addNodalCommunicationMap_{false}; |
| 144 |
|
| 145 |
StringIdVector nodeVarNames_; |
| 146 |
StringIdVector elemVarNames_; |
| 147 |
StringIdVector nsetVarNames_; |
| 148 |
StringIdVector ssetVarNames_; |
| 149 |
#endif |
| 150 |
}; |
| 151 |
|
| 152 |
#if 0 |
| 153 |
inline int SystemInterface::part_count() const |
| 154 |
{ |
| 155 |
return partCount_ > 0 ? partCount_ : processorCount_; |
| 156 |
} |
| 157 |
#endif |
| 158 |
} // namespace Cpup |