143 {
144 TRACE();
145
150
151
153
154 ifstream ifs(fileName);
155 if(!ifs) {
156 TERMM(1, "could not open property file '" + fileName + "'");
157 }
158 stringstream ss;
159 ss << ifs.rdbuf();
160 if(ss.str().empty()) {
161 TERMM(1, "property file '" + fileName + "' appears to be empty");
162 }
163
164
165 MInt length = ss.str().size() + 1;
166
167
168 vector<MChar> text(length);
169 strcpy(text.data(), ss.str().c_str());
170
171
172 MPI_Bcast(&length, 1, MPI_INT, 0, MPI_COMM_WORLD, AT_,
"length");
173 MPI_Bcast(text.data(), length, MPI_CHAR, 0, MPI_COMM_WORLD, AT_,
"text.data()");
174
175
177 } else {
178
180 MPI_Bcast(&length, 1, MPI_INT, 0, MPI_COMM_WORLD, AT_,
"length");
181
182
183 vector<MChar> text(length);
184 MPI_Bcast(text.data(), length, MPI_CHAR, 0, MPI_COMM_WORLD, AT_,
"text.data()");
185
186
188 }
189
190
191 stringstream ss;
193
194
196 map<MString, MInt> solverAliases;
198
199
200 vector<maia::io::toml::Property> properties;
202
203
205 for(auto&& prop : properties) {
206 if(prop.name() == "noSolvers") {
208 }
209 }
210
211
213
214
216 stringstream errorMessage;
217 errorMessage << "IOToml::readPropertyFile Error: Inconsistent solver List!\n Make sure "
218 "that solvers start with index 0 and are consecutive!"
219 << endl;
220 TERMM(1, errorMessage.str());
221 }
222
223
224 for(auto&& prop : properties) {
225
226 if(!strstr(prop.name().c_str(), ".")) {
227
228
229 DEBUG("IOToml::readPropertyFile: default property : " << prop.name(), MAIA_DEBUG_IO);
232 p->name.append(prop.name());
234 }
235
236 else {
237 const auto pname = prop.name();
238 const char* du;
239 du = strrchr(pname.c_str(), '.') + 1;
240 const MInt singleSolverId = atoi(du);
241
242 if(singleSolverId || *du == '0') {
243
244 const MString name = prop.name().substr(0, prop.name().find(
"."));
245
246 DEBUG("IOToml::readPropertyFile: Found single solver property definition for solver " << singleSolverId,
247 MAIA_DEBUG_IO);
248
249
251 p->solverId = singleSolverId;
252 p->name.append(name);
254 }
255 }
256 }
257
258
260 DEBUG("IOToml::readPropertyFile: property consistency check succeeded", MAIA_DEBUG_IO);
261 } else {
262 stringstream errorMessage;
263 errorMessage << "IOToml::readPropertyFile Error: some properties are not defined for "
264 "all solvers!"
265 << endl;
266 TERMM(1, errorMessage.str());
267 }
268
273
275}
MBool checkPropertyConsistency()
MBool checkZoneConsistency()
void makeProperty(MProperty *, const maia::io::toml::Property &prop)
std::shared_ptr< table > parse()
std::map< MString, MZone * > zoneMap
std::multimap< MString, MProperty * > propertyMap
MInt globalDomainId()
Return global domain id.
int MPI_Bcast(void *buffer, int count, MPI_Datatype datatype, int root, MPI_Comm comm, const MString &name, const MString &varname)
same as MPI_Bcast
void collectProperties(const std::shared_ptr< cpptoml::table > &tab, std::vector< std::string > &names, std::vector< Property > &properties, std::map< std::string, int > &solverAliases)
Recursively traverse TOML table and collect all properties with name, type, and count.
void collectSolverAliases(const std::shared_ptr< cpptoml::table > &tab, std::map< std::string, int > &solverAliases)
Non-recursive search for solver aliases.
propertyMap * propertiesLowercase