Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#570: Remove 'uses_forcing_file' and 'forcing_file'(_path) #826

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions include/bmi/AbstractCLibBmiAdapter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,14 @@ namespace models {
* @param type_name The name of the backing BMI module/model type.
* @param library_file_path The string path to the shared library file for external module.
* @param bmi_init_config The string path to the BMI initialization config file for the module.
* @param forcing_file_path The string path for the forcing file the module should use, empty if it does not
* use one directly.
* @param allow_exceed_end Whether the backing model is allowed to execute beyond its advertised end_time.
* @param has_fixed_time_step Whether the model has a fixed time step size.
* @param registration_func The name for the @see bmi_registration_function.
* @param output The output stream handler.
*/
AbstractCLibBmiAdapter(const std::string &type_name, std::string library_file_path, std::string bmi_init_config,
std::string forcing_file_path, bool allow_exceed_end, bool has_fixed_time_step,
std::string registration_func, utils::StreamHandler output);
bool allow_exceed_end, bool has_fixed_time_step, std::string registration_func,
utils::StreamHandler output);

/**
* Class destructor.
Expand Down
5 changes: 1 addition & 4 deletions include/bmi/Bmi_Adapter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace models {
class Bmi_Adapter : public ::bmi::Bmi {
public:

Bmi_Adapter(std::string model_name, std::string bmi_init_config, std::string forcing_file_path, bool allow_exceed_end,
Bmi_Adapter(std::string model_name, std::string bmi_init_config, bool allow_exceed_end,
bool has_fixed_time_step, utils::StreamHandler output);

Bmi_Adapter(Bmi_Adapter const&) = delete;
Expand Down Expand Up @@ -156,9 +156,6 @@ namespace models {
double bmi_model_time_convert_factor;
/** Pointer to stored time step size value of backing model, if it is fixed and has been retrieved. */
std::shared_ptr<double> bmi_model_time_step_size = nullptr;
/** Whether this particular model implementation directly reads input data from the forcing file. */
bool bmi_model_uses_forcing_file;
std::string forcing_file_path;
/** Message from an exception (if encountered) on the first attempt to initialize the backing model. */
std::string init_exception_msg;
/** Pointer to collection of input variable names for backing model, used by ``GetInputVarNames()``. */
Expand Down
12 changes: 3 additions & 9 deletions include/bmi/Bmi_C_Adapter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,12 @@ namespace models {
*
* @param type_name The name of the backing BMI module/model type.
* @param library_file_path The string path to the shared library file for external module.
* @param forcing_file_path The string path for the forcing file the module should use, empty if it does not
* use one directly.
* @param allow_exceed_end Whether the backing model is allowed to execute beyond its advertised end_time.
* @param has_fixed_time_step Whether the model has a fixed time step size.
* @param registration_func The name for the @see bmi_registration_function.
* @param output The output stream handler.
*/
explicit Bmi_C_Adapter(const std::string &type_name, std::string library_file_path, std::string forcing_file_path,
explicit Bmi_C_Adapter(const std::string &type_name, std::string library_file_path,
bool allow_exceed_end, bool has_fixed_time_step,
const std::string& registration_func, utils::StreamHandler output);

Expand All @@ -49,15 +47,13 @@ namespace models {
* @param type_name The name of the backing BMI module/model type.
* @param library_file_path The string path to the shared library file for external module.
* @param bmi_init_config The string path to the BMI initialization config file for the module.
* @param forcing_file_path The string path for the forcing file the module should use, empty if it does not
* use one directly.
* @param allow_exceed_end Whether the backing model is allowed to execute beyond its advertised end_time.
* @param has_fixed_time_step Whether the model has a fixed time step size.
* @param registration_func The name for the @see bmi_registration_function.
* @param output The output stream handler.
*/
Bmi_C_Adapter(const std::string &type_name, std::string library_file_path, std::string bmi_init_config,
std::string forcing_file_path, bool allow_exceed_end, bool has_fixed_time_step,
bool allow_exceed_end, bool has_fixed_time_step,
std::string registration_func, utils::StreamHandler output);

protected:
Expand All @@ -76,16 +72,14 @@ namespace models {
* @param type_name The name of the backing BMI module/model type.
* @param library_file_path The string path to the shared library file for external module.
* @param bmi_init_config The string path to the BMI initialization config file for the module.
* @param forcing_file_path The string path for the forcing file the module should use, empty if it does not
* use one directly.
* @param allow_exceed_end Whether the backing model is allowed to execute beyond its advertised end_time.
* @param has_fixed_time_step Whether the model has a fixed time step size.
* @param registration_func The name for the @see bmi_registration_function.
* @param output The output stream handler.
* @param do_initialization Whether initialization should be performed during construction or deferred.
*/
Bmi_C_Adapter(const std::string &type_name, std::string library_file_path, std::string bmi_init_config,
std::string forcing_file_path, bool allow_exceed_end, bool has_fixed_time_step,
bool allow_exceed_end, bool has_fixed_time_step,
std::string registration_func, utils::StreamHandler output, bool do_initialization);

public:
Expand Down
12 changes: 3 additions & 9 deletions include/bmi/Bmi_Cpp_Adapter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,13 @@ namespace models {
*
* @param type_name The name of the backing BMI module/model type.
* @param library_file_path The string path to the shared library file for external module.
* @param forcing_file_path The string path for the forcing file the module should use, empty if it does not
* use one directly.
* @param allow_exceed_end Whether the backing model is allowed to execute beyond its advertised end_time.
* @param has_fixed_time_step Whether the model has a fixed time step size.
* @param creator_func The name for the @see creator_function .
* @param destoryer_func The name for the @see destroyer_function .
* @param output The output stream handler.
*/
explicit Bmi_Cpp_Adapter(const std::string &type_name, std::string library_file_path, std::string forcing_file_path,
explicit Bmi_Cpp_Adapter(const std::string &type_name, std::string library_file_path,
bool allow_exceed_end, bool has_fixed_time_step,
std::string creator_func, std::string destroyer_func,
utils::StreamHandler output);
Expand All @@ -54,16 +52,14 @@ namespace models {
* @param type_name The name of the backing BMI module/model type.
* @param library_file_path The string path to the shared library file for external module.
* @param bmi_init_config The string path to the BMI initialization config file for the module.
* @param forcing_file_path The string path for the forcing file the module should use, empty if it does not
* use one directly.
* @param allow_exceed_end Whether the backing model is allowed to execute beyond its advertised end_time.
* @param has_fixed_time_step Whether the model has a fixed time step size.
* @param creator_func The name for the @see creator_function .
* @param destoryer_func The name for the @see destroyer_function .
* @param output The output stream handler.
*/
Bmi_Cpp_Adapter(const std::string& type_name, std::string library_file_path, std::string bmi_init_config,
std::string forcing_file_path, bool allow_exceed_end, bool has_fixed_time_step,
bool allow_exceed_end, bool has_fixed_time_step,
std::string creator_func, std::string destroyer_func,
utils::StreamHandler output);

Expand All @@ -83,8 +79,6 @@ namespace models {
* @param type_name The name of the backing BMI module/model type.
* @param library_file_path The string path to the shared library file for external module.
* @param bmi_init_config The string path to the BMI initialization config file for the module.
* @param forcing_file_path The string path for the forcing file the module should use, empty if it does not
* use one directly.
* @param allow_exceed_end Whether the backing model is allowed to execute beyond its advertised end_time.
* @param has_fixed_time_step Whether the model has a fixed time step size.
* @param creator_func The name for the @see creator_function .
Expand All @@ -93,7 +87,7 @@ namespace models {
* @param do_initialization Whether initialization should be performed during construction or deferred.
*/
Bmi_Cpp_Adapter(const std::string& type_name, std::string library_file_path, std::string bmi_init_config,
std::string forcing_file_path, bool allow_exceed_end, bool has_fixed_time_step,
bool allow_exceed_end, bool has_fixed_time_step,
std::string creator_func, std::string destroyer_func,
utils::StreamHandler output, bool do_initialization);

Expand Down
6 changes: 2 additions & 4 deletions include/bmi/Bmi_Fortran_Adapter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,18 @@ namespace models {
public:

explicit Bmi_Fortran_Adapter(const std::string &type_name, std::string library_file_path,
std::string forcing_file_path,
bool allow_exceed_end, bool has_fixed_time_step,
const std::string &registration_func, utils::StreamHandler output)
: Bmi_Fortran_Adapter(type_name, library_file_path, "", forcing_file_path, allow_exceed_end,
: Bmi_Fortran_Adapter(type_name, library_file_path, "", allow_exceed_end,
has_fixed_time_step,
registration_func, output) {}

Bmi_Fortran_Adapter(const std::string &type_name, std::string library_file_path, std::string bmi_init_config,
std::string forcing_file_path, bool allow_exceed_end, bool has_fixed_time_step,
bool allow_exceed_end, bool has_fixed_time_step,
std::string registration_func,
utils::StreamHandler output) : AbstractCLibBmiAdapter(type_name,
library_file_path,
bmi_init_config,
forcing_file_path,
allow_exceed_end,
has_fixed_time_step,
registration_func,
Expand Down
4 changes: 0 additions & 4 deletions include/bmi/Bmi_Py_Adapter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@ namespace models {
Bmi_Py_Adapter(const std::string &type_name, std::string bmi_init_config, const std::string &bmi_python_type,
bool allow_exceed_end, bool has_fixed_time_step, utils::StreamHandler output);

Bmi_Py_Adapter(const std::string &type_name, std::string bmi_init_config, const std::string &bmi_python_type,
std::string forcing_file_path, bool allow_exceed_end, bool has_fixed_time_step,
utils::StreamHandler output);

Bmi_Py_Adapter(Bmi_Py_Adapter const&) = delete;
Bmi_Py_Adapter(Bmi_Py_Adapter&&) = delete;

Expand Down
11 changes: 1 addition & 10 deletions include/realizations/catchment/Bmi_Formulation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
#define BMI_REALIZATION_CFG_PARAM_REQ__INIT_CONFIG "init_config"
#define BMI_REALIZATION_CFG_PARAM_REQ__MAIN_OUT_VAR "main_output_variable"
#define BMI_REALIZATION_CFG_PARAM_REQ__MODEL_TYPE "model_type_name"
#define BMI_REALIZATION_CFG_PARAM_REQ__USES_FORCINGS "uses_forcing_file"

// Then the optional
#define BMI_REALIZATION_CFG_PARAM_OPT__USES_FORCINGS "uses_forcing_file"
#define BMI_REALIZATION_CFG_PARAM_OPT__FORCING_FILE "forcing_file"
#define BMI_REALIZATION_CFG_PARAM_OPT__VAR_STD_NAMES "variables_names_map"
// TODO: change this (and output_header_fields) to something like output_file_variables to distinguish from BMI output variables
Expand Down Expand Up @@ -129,8 +129,6 @@ namespace realization {
*/
virtual const double get_model_end_time() = 0;

virtual const std::string &get_forcing_file_path() const = 0;

/**
* Get the name of the specific type of the backing model object.
*
Expand Down Expand Up @@ -189,13 +187,6 @@ namespace realization {

virtual bool is_bmi_output_variable(const std::string &var_name) = 0;

/**
* Whether the backing model uses/reads the forcing file directly for getting input data.
*
* @return Whether the backing model uses/reads the forcing file directly for getting input data.
*/
virtual bool is_bmi_using_forcing_file() const = 0;

/**
* Test whether the backing model has been initialize using the BMI standard ``Initialize`` function.
*
Expand Down
25 changes: 1 addition & 24 deletions include/realizations/catchment/Bmi_Module_Formulation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,6 @@ namespace realization {
*/
std::shared_ptr<models::bmi::Bmi_Adapter> get_bmi_model();

const std::string &get_forcing_file_path() const override;

const time_t &get_bmi_model_start_time_forcing_offset_s() override;

/**
Expand Down Expand Up @@ -345,13 +343,6 @@ namespace realization {
*/
bool is_bmi_model_time_step_fixed() override;

/**
* Whether the backing model uses/reads the forcing file directly for getting input data.
*
* @return Whether the backing model uses/reads the forcing file directly for getting input data.
*/
bool is_bmi_using_forcing_file() const override;

/**
* Test whether the backing model object has been initialize using the BMI standard ``Initialize`` function.
*
Expand All @@ -374,15 +365,6 @@ namespace realization {

void set_bmi_model_time_step_fixed(bool is_fix_time_step);

/**
* Set whether the backing model uses/reads the forcing file directly for getting input data.
*
* @param uses_forcing_file Whether the backing model uses/reads forcing file directly for getting input data.
*/
void set_bmi_using_forcing_file(bool uses_forcing_file);

void set_forcing_file_path(const std::string &forcing_path);

/**
* Set whether the backing model object has been initialize using the BMI standard ``Initialize`` function.
*
Expand Down Expand Up @@ -455,12 +437,10 @@ namespace realization {
time_t bmi_model_start_time_forcing_offset_s;
/** A configured mapping of BMI model variable names to standard names for use inside the framework. */
std::map<std::string, std::string> bmi_var_names_map;
/** Whether the backing model uses/reads the forcing file directly for getting input data. */
bool bmi_using_forcing_file;
std::string forcing_file_path;
bool model_initialized = false;

std::vector<std::string> OPTIONAL_PARAMETERS = {
BMI_REALIZATION_CFG_PARAM_OPT__USES_FORCINGS
BMI_REALIZATION_CFG_PARAM_OPT__FORCING_FILE,
BMI_REALIZATION_CFG_PARAM_OPT__VAR_STD_NAMES,
BMI_REALIZATION_CFG_PARAM_OPT__OUT_VARS,
Expand All @@ -474,7 +454,6 @@ namespace realization {
BMI_REALIZATION_CFG_PARAM_REQ__INIT_CONFIG,
BMI_REALIZATION_CFG_PARAM_REQ__MAIN_OUT_VAR,
BMI_REALIZATION_CFG_PARAM_REQ__MODEL_TYPE,
BMI_REALIZATION_CFG_PARAM_REQ__USES_FORCINGS
};

};
Expand All @@ -498,9 +477,7 @@ namespace realization {
// Required parameters first
set_bmi_init_config(properties.at(BMI_REALIZATION_CFG_PARAM_REQ__INIT_CONFIG).as_string());
set_bmi_main_output_var(properties.at(BMI_REALIZATION_CFG_PARAM_REQ__MAIN_OUT_VAR).as_string());
set_forcing_file_path(properties.at(BMI_REALIZATION_CFG_PARAM_REQ__FORCING_FILE).as_string());
set_model_type_name(properties.at(BMI_REALIZATION_CFG_PARAM_REQ__MODEL_TYPE).as_string());
set_bmi_using_forcing_file(properties.at(BMI_REALIZATION_CFG_PARAM_REQ__USES_FORCINGS).as_boolean());

// Then optional ...

Expand Down
4 changes: 0 additions & 4 deletions include/realizations/catchment/Bmi_Multi_Formulation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,6 @@ namespace realization {
const std::shared_ptr<Bmi_Formulation>& out_module,
const std::shared_ptr<Bmi_Formulation>& in_module);

const std::string &get_forcing_file_path() const override;

/**
* Get the inclusive beginning of the period of time over which this instance can provide data for this forcing.
*
Expand Down Expand Up @@ -425,8 +423,6 @@ namespace realization {

bool is_bmi_output_variable(const std::string &var_name) override;

bool is_bmi_using_forcing_file() const override;

/**
* Test whether all backing models have been initialize using the BMI standard ``Initialize`` function.
*
Expand Down
2 changes: 0 additions & 2 deletions src/bmi/AbstractCLibBmiAdapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ AbstractCLibBmiAdapter::AbstractCLibBmiAdapter(
const std::string& type_name,
std::string library_file_path,
std::string bmi_init_config,
std::string forcing_file_path,
bool allow_exceed_end,
bool has_fixed_time_step,
std::string registration_func,
Expand All @@ -21,7 +20,6 @@ AbstractCLibBmiAdapter::AbstractCLibBmiAdapter(
: Bmi_Adapter(
type_name,
std::move(bmi_init_config),
std::move(forcing_file_path),
allow_exceed_end,
has_fixed_time_step,
output
Expand Down
3 changes: 0 additions & 3 deletions src/bmi/Bmi_Adapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,12 @@ namespace bmi {
Bmi_Adapter::Bmi_Adapter(
std::string model_name,
std::string bmi_init_config,
std::string forcing_file_path,
bool allow_exceed_end,
bool has_fixed_time_step,
utils::StreamHandler output
)
: model_name(std::move(model_name))
, bmi_init_config(std::move(bmi_init_config))
, bmi_model_uses_forcing_file(!forcing_file_path.empty())
, forcing_file_path(std::move(forcing_file_path))
, bmi_model_has_fixed_time_step(has_fixed_time_step)
, allow_model_exceed_end_time(allow_exceed_end)
, output(std::move(output))
Expand Down
Loading
Loading