MCPcopy Create free account
hub / github.com/CoolProp/CoolProp / REFPROP_supported

Method REFPROP_supported

src/Backends/REFPROP/REFPROPMixtureBackend.cpp:234–301  ·  view source on GitHub ↗

initialise with true

Source from the content-addressed store, hash-verified

232std::size_t REFPROPMixtureBackend::instance_counter = 0; // initialise with 0
233bool REFPROPMixtureBackend::_REFPROP_supported = true; // initialise with true
234bool REFPROPMixtureBackend::REFPROP_supported() {
235 /*
236 * Here we build the bridge from macro definitions
237 * into the actual code. This is also going to be
238 * the central place to handle error messages on
239 * unsupported platforms.
240 */
241
242 // Abort check if Refprop has been loaded.
243 if (RefpropdllInstance != nullptr) return true;
244
245 // Store result of previous check.
246 if (_REFPROP_supported) {
247 // Either Refprop is supported or it is the first check.
248 std::string rpv(STRINGIFY(RPVersion));
249 if (rpv.compare("NOTAVAILABLE") != 0) {
250 // Function names were defined in "REFPROP_lib.h",
251 // This platform theoretically supports Refprop.
252 std::string err;
253
254 bool loaded_REFPROP = false;
255
256 auto root = get_envvar("COOLPROP_REFPROP_ROOT");
257 const std::string alt_rp_path = get_config_string(ALTERNATIVE_REFPROP_PATH);
258 const std::string alt_rp_name = get_config_string(ALTERNATIVE_REFPROP_LIBRARY_PATH);
259
260 if (root) {
261 loaded_REFPROP = ::load_REFPROP(err, root.value().c_str(), "");
262 SETPATHdll(const_cast<char*>(root.value().c_str()), 400);
263 }
264 if (!loaded_REFPROP) {
265 if (!alt_rp_name.empty()) {
266 loaded_REFPROP = ::load_REFPROP(err, "", alt_rp_name);
267 } else {
268 if (alt_rp_path.empty()) {
269 loaded_REFPROP = ::load_REFPROP(err, refpropPath, "");
270 } else {
271 loaded_REFPROP = ::load_REFPROP(err, alt_rp_path, "");
272 }
273 }
274 }
275
276 if (loaded_REFPROP) {
277 return true;
278 } else {
279 std::cout << "Good news: It is possible to use REFPROP on your system! However, the library \n"
280 << "could not be loaded. Please make sure that REFPROP is available on your system.\n\n"
281 << "Neither found in current location nor found in system PATH.\n"
282 << "If you already obtained a copy of REFPROP from http://www.nist.gov/srd/, \n"
283 << "add location of REFPROP to the PATH environment variable or your library path.\n\n"
284 << "In case you do not use Windows, have a look at https://github.com/jowr/librefprop.so \n"
285 << "to find instructions on how to compile your own version of the REFPROP library.\n\n"
286 << format("COOLPROP_REFPROP_ROOT: %s\n", (root) ? root.value().c_str() : "?")
287 << format("ALTERNATIVE_REFPROP_PATH: %s\n", alt_rp_path.c_str()) << format("ERROR: %s\n", err.c_str());
288 _REFPROP_supported = false;
289 return false;
290 }
291 } else {

Callers

nothing calls this directly

Calls 4

get_envvarFunction · 0.85
get_config_stringFunction · 0.85
valueMethod · 0.80
formatFunction · 0.50

Tested by

no test coverage detected