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

Fix a build error when Python is turned off #404

Merged
merged 4 commits into from
Apr 5, 2022
Merged
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
19 changes: 15 additions & 4 deletions test/realizations/catchments/Bmi_Multi_Formulation_Test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// Don't bother with the rest if none of these are active (although what are we really doing here, then?)
#if NGEN_BMI_C_LIB_ACTIVE || NGEN_BMI_FORTRAN_ACTIVE || ACTIVATE_PYTHON

#include "all.h"
#include "Bmi_Testing_Util.hpp"
#include <exception>
#include <map>
Expand Down Expand Up @@ -440,11 +441,11 @@ void Bmi_Multi_Formulation_Test::SetUp() {

/* ********************************** First example scenario (Fortran / C) ********************************** */
#ifndef NGEN_BMI_C_LIB_ACTIVE
throw std::runtime_error("Error: can't run multi BMI tests for scenario at index 0 without BMI C functionality active");
throw std::runtime_error("Error: can't run multi BMI tests for scenario at index 0 without BMI C functionality active" SOURCE_LOC);
#endif // NGEN_BMI_C_LIB_ACTIVE

#ifndef NGEN_BMI_FORTRAN_ACTIVE
throw std::runtime_error("Error: can't run multi BMI tests for scenario at index 0 without BMI Fortran functionality active");
throw std::runtime_error("Error: can't run multi BMI tests for scenario at index 0 without BMI Fortran functionality active" SOURCE_LOC);
#endif // NGEN_BMI_FORTRAN_ACTIVE


Expand All @@ -453,11 +454,11 @@ void Bmi_Multi_Formulation_Test::SetUp() {
/* ********************************** Second example scenario ********************************** */

#ifndef NGEN_BMI_FORTRAN_ACTIVE
throw std::runtime_error("Error: can't run multi BMI tests for scenario at index 1 without BMI Fortran functionality active");
throw std::runtime_error("Error: can't run multi BMI tests for scenario at index 1 without BMI Fortran functionality active" SOURCE_LOC);
#endif // NGEN_BMI_FORTRAN_ACTIVE

#ifndef ACTIVATE_PYTHON
throw std::runtime_error("Error: can't run multi BMI tests for scenario at index 1 without BMI C functionality active");
throw std::runtime_error("Error: can't run multi BMI tests for scenario at index 1 without BMI Python functionality active" SOURCE_LOC);
#endif // ACTIVATE_PYTHON

initializeTestExample(1, "cat-27", {std::string(BMI_FORTRAN_TYPE), std::string(BMI_PYTHON_TYPE)});
Expand Down Expand Up @@ -657,6 +658,12 @@ TEST_F(Bmi_Multi_Formulation_Test, GetResponse_3_b) {
* Test of get response in example 3, which uses a deferred provider, checking the values for several iterations.
*/
TEST_F(Bmi_Multi_Formulation_Test, GetResponse_3_c) {

/* Note that a runtime check in SetUp() prevents this from executing when it can't, but
this needs to be here to prevent compile-time errors if either of these flags is not
enabled. */
#if ACTIVATE_PYTHON && NGEN_BMI_FORTRAN_ACTIVE

int ex_index = 3;

Bmi_Multi_Formulation formulation(catchment_ids[ex_index], std::make_unique<CsvPerFeatureForcingProvider>(*forcing_params_examples[ex_index]), utils::StreamHandler());
Expand All @@ -666,6 +673,7 @@ TEST_F(Bmi_Multi_Formulation_Test, GetResponse_3_b) {
for (int i = 0; i < 39; i++) {
// Note that we need to get this before the "current" get_response ...
mod_1_output_2 = get_friend_nested_var_value<Bmi_Py_Formulation>(formulation, 1, "OUTPUT_VAR_2");

response = formulation.get_response(i, 3600);
// But we need to get this after the "current" get_response ...
mod_0_input_1 = get_friend_nested_var_value<Bmi_Fortran_Formulation>(formulation, 0, "INPUT_VAR_1");
Expand All @@ -674,6 +682,9 @@ TEST_F(Bmi_Multi_Formulation_Test, GetResponse_3_b) {
EXPECT_EQ(mod_0_input_1, mod_1_output_2);
}
}

#endif // ACTIVATE_PYTHON && NGEN_BMI_FORTRAN_ACTIVE

}

/**
Expand Down