From f64ffd336dbea7eaa1ad5848dd79ce59b35594a1 Mon Sep 17 00:00:00 2001 From: Matt Williamson Date: Wed, 3 Aug 2022 20:54:13 +0000 Subject: [PATCH] Added extensionless solution also. --- data/example_bmi_multi_realization_config.json | 4 ++-- .../catchment/AbstractCLibBmiAdapter.hpp | 12 +++++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/data/example_bmi_multi_realization_config.json b/data/example_bmi_multi_realization_config.json index 77c6be6c92..c3cb954a18 100644 --- a/data/example_bmi_multi_realization_config.json +++ b/data/example_bmi_multi_realization_config.json @@ -14,7 +14,7 @@ "name": "bmi_fortran", "params": { "model_type_name": "bmi_fortran_noahowp", - "library_file": "./extern/noah-owp-modular/cmake_build/libsurfacebmi.so", + "library_file": "./extern/noah-owp-modular/cmake_build/libsurfacebmi", "forcing_file": "", "init_config": "./data/bmi/fortran/noah-owp-modular-init-{{id}}.namelist.input", "allow_exceed_end_time": true, @@ -36,7 +36,7 @@ "name": "bmi_c", "params": { "model_type_name": "bmi_c_cfe", - "library_file": "./extern/cfe/cmake_build/libcfebmi.so", + "library_file": "./extern/cfe/cmake_build/libcfebmi", "forcing_file": "", "init_config": "./data/bmi/c/cfe/{{id}}_bmi_config.ini", "allow_exceed_end_time": true, diff --git a/include/realizations/catchment/AbstractCLibBmiAdapter.hpp b/include/realizations/catchment/AbstractCLibBmiAdapter.hpp index 3c3a73ea85..ccf0dd92d8 100644 --- a/include/realizations/catchment/AbstractCLibBmiAdapter.hpp +++ b/include/realizations/catchment/AbstractCLibBmiAdapter.hpp @@ -94,9 +94,19 @@ namespace models { std::string alt_bmi_lib_file; if(bmi_lib_file.substr(idx) == ".so"){ alt_bmi_lib_file = bmi_lib_file.substr(0,idx) + ".dylib"; - } else { + } else if(bmi_lib_file.substr(idx) == ".dylib"){ alt_bmi_lib_file = bmi_lib_file.substr(0,idx) + ".so"; + } else { + // Try appending instead of replacing... + #ifdef __APPLE__ + alt_bmi_lib_file = bmi_lib_file + ".dylib"; + #else + #ifdef __GNUC__ + alt_bmi_lib_file = bmi_lib_file + ".so"; + #endif // __GNUC__ + #endif // __APPLE__ } + //TODO: Try looking in e.g. /usr/lib, /usr/local/lib, $LD_LIBRARY_PATH... try pre-pending "lib"... if (utils::FileChecker::file_is_readable(alt_bmi_lib_file)) { bmi_lib_file = alt_bmi_lib_file; } else {