Skip to content

Commit

Permalink
Abolish old NGEN_BMI_FORTRAN_ACTIVE
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilMiller authored and donaldwj committed May 7, 2024
1 parent c33fdaa commit 01cd25b
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .gitpod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ tasks:
./compiler.sh
popd
pip install pyyaml bmipy
cmake -S . -B cmake_build -DNGEN_WITH_BMI_C=ON -DBMI_FORTRAN_ACTIVE=1 -DNGEN_ACTIVATE_ROUTING=1
cmake -S . -B cmake_build -DNGEN_WITH_BMI_C=ON -DNGEN_WITH_BMI_FORTRAN=ON -DNGEN_ACTIVATE_ROUTING=1
cmake --build cmake_build --target all
- name: Workshell
before: |
Expand Down
2 changes: 0 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,6 @@ endif()
# -----------------------------------------------------------------------------
# Configure whether Fortran BMI functionality is active
if(NGEN_WITH_BMI_FORTRAN)
add_compile_definitions(NGEN_BMI_FORTRAN_ACTIVE)

add_external_subdirectory(
SOURCE "${NGEN_EXT_DIR}/iso_c_fortran_bmi"
OUTPUT "${NGEN_EXT_DIR}/iso_c_fortran_bmi/cmake_build"
Expand Down
4 changes: 2 additions & 2 deletions include/bmi/Bmi_Fortran_Adapter.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef NGEN_BMI_FORTRAN_ADAPTER_HPP
#define NGEN_BMI_FORTRAN_ADAPTER_HPP

#ifdef NGEN_BMI_FORTRAN_ACTIVE
#ifdef NGEN_WITH_BMI_FORTRAN

#include "AbstractCLibBmiAdapter.hpp"
#include "Bmi_Fortran_Common.h"
Expand Down Expand Up @@ -813,6 +813,6 @@ namespace models {
}
}

#endif // NGEN_BMI_FORTRAN_ACTIVE
#endif // NGEN_WITH_BMI_FORTRAN

#endif //NGEN_BMI_FORTRAN_ADAPTER_HPP
4 changes: 2 additions & 2 deletions include/bmi/Bmi_Fortran_Common.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef NGEN_BMI_FORTRAN_COMMON_H
#define NGEN_BMI_FORTRAN_COMMON_H

#ifdef NGEN_BMI_FORTRAN_ACTIVE
#ifdef NGEN_WITH_BMI_FORTRAN

/**
* The extern free functions from the Nextgen common Fortran static library for integrating with Fortran BMI modules.
Expand Down Expand Up @@ -129,6 +129,6 @@ extern "C" {
extern int get_grid_nodes_per_face(void *fortran_bmi_handle, int *grid, int *nodes_per_face);
}

#endif // NGEN_BMI_FORTRAN_ACTIVE
#endif // NGEN_WITH_BMI_FORTRAN

#endif //NGEN_BMI_FORTRAN_COMMON_H
4 changes: 2 additions & 2 deletions include/realizations/catchment/Bmi_Fortran_Formulation.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef NGEN_BMI_FORTRAN_FORMULATION_HPP
#define NGEN_BMI_FORTRAN_FORMULATION_HPP

#ifdef NGEN_BMI_FORTRAN_ACTIVE
#ifdef NGEN_WITH_BMI_FORTRAN

#include "Bmi_Module_Formulation.hpp"
#include "Bmi_Fortran_Adapter.hpp"
Expand Down Expand Up @@ -92,6 +92,6 @@ namespace realization {

}

#endif // NGEN_BMI_FORTRAN_ACTIVE
#endif // NGEN_WITH_BMI_FORTRAN

#endif //NGEN_BMI_FORTRAN_FORMULATION_HPP
2 changes: 1 addition & 1 deletion src/NGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ int main(int argc, char *argv[]) {
#ifdef NETCDF_ACTIVE
std::cout<<" NetCDF lumped forcing enabled"<<std::endl;
#endif
#ifdef NGEN_BMI_FORTRAN_ACTIVE
#ifdef NGEN_WITH_BMI_FORTRAN
std::cout<<" Fortran BMI enabled"<<std::endl;
#endif
#ifdef NGEN_WITH_BMI_C
Expand Down
4 changes: 2 additions & 2 deletions src/bmi/Bmi_Fortran_Adapter.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#ifdef NGEN_BMI_FORTRAN_ACTIVE
#ifdef NGEN_WITH_BMI_FORTRAN
#include "bmi/Bmi_Fortran_Adapter.hpp"

using namespace models::bmi;
Expand Down Expand Up @@ -280,4 +280,4 @@ void Bmi_Fortran_Adapter::GetGridNodesPerFace(int grid, int *nodes_per_face) {
}
}

#endif // NGEN_BMI_FORTRAN_ACTIVE
#endif // NGEN_WITH_BMI_FORTRAN
4 changes: 2 additions & 2 deletions src/realizations/catchment/Bmi_Fortran_Formulation.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#ifdef NGEN_BMI_FORTRAN_ACTIVE
#ifdef NGEN_WITH_BMI_FORTRAN

#include "Bmi_Fortran_Formulation.hpp"
#include "Constants.h"
Expand Down Expand Up @@ -167,4 +167,4 @@ double Bmi_Fortran_Formulation::get_response(time_step_t t_index, time_step_t t_
return get_var_value_as_double( get_bmi_main_output_var());
}

#endif // NGEN_BMI_FORTRAN_ACTIVE
#endif // NGEN_WITH_BMI_FORTRAN
6 changes: 3 additions & 3 deletions src/realizations/catchment/Bmi_Multi_Formulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ void Bmi_Multi_Formulation::create_multi_formulation(geojson::PropertyMap proper
}
if (type_name == "bmi_fortran") {

#ifdef NGEN_BMI_FORTRAN_ACTIVE
#ifdef NGEN_WITH_BMI_FORTRAN
module = init_nested_module<Bmi_Fortran_Formulation>(i, identifier, formulation_config.at("params").get_values());
#else // NGEN_BMI_FORTRAN_ACTIVE
#else
inactive_type_requested = true;
#endif // NGEN_BMI_FORTRAN_ACTIVE
#endif
}
if (type_name == "bmi_python") {
#ifdef ACTIVATE_PYTHON
Expand Down
4 changes: 2 additions & 2 deletions src/realizations/catchment/Formulation_Constructors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ namespace realization {
#ifdef NGEN_NGEN_WITH_BMI_C
{"bmi_c", create_formulation_constructor<Bmi_C_Formulation>()},
#endif // NGEN_NGEN_WITH_BMI_C
#ifdef NGEN_BMI_FORTRAN_ACTIVE
#ifdef NGEN_WITH_BMI_FORTRAN
{"bmi_fortran", create_formulation_constructor<Bmi_Fortran_Formulation>()},
#endif // NGEN_BMI_FORTRAN_ACTIVE
#endif // NGEN_WITH_BMI_FORTRAN
{"bmi_multi", create_formulation_constructor<Bmi_Multi_Formulation>()},
#ifdef ACTIVATE_PYTHON
{"bmi_python", create_formulation_constructor<Bmi_Py_Formulation>()},
Expand Down
18 changes: 9 additions & 9 deletions test/realizations/catchments/Bmi_Multi_Formulation_Test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define NGEN_BMI_MULTI_FORMULATION_TEST_CPP

// Don't bother with the rest if none of these are active (although what are we really doing here, then?)
#if NGEN_NGEN_WITH_BMI_C || NGEN_BMI_FORTRAN_ACTIVE || ACTIVATE_PYTHON
#if NGEN_NGEN_WITH_BMI_C || NGEN_WITH_BMI_FORTRAN || ACTIVATE_PYTHON

#include "all.h"
#include "Bmi_Testing_Util.hpp"
Expand Down Expand Up @@ -467,18 +467,18 @@ void Bmi_Multi_Formulation_Test::SetUp() {
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_NGEN_WITH_BMI_C

#ifndef NGEN_BMI_FORTRAN_ACTIVE
#ifndef NGEN_WITH_BMI_FORTRAN
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
#endif // NGEN_WITH_BMI_FORTRAN


initializeTestExample(0, "cat-27", {std::string(BMI_FORTRAN_TYPE), std::string(BMI_C_TYPE)}, {});

/* ********************************** Second example scenario ********************************** */

#ifndef NGEN_BMI_FORTRAN_ACTIVE
#ifndef NGEN_WITH_BMI_FORTRAN
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
#endif // NGEN_WITH_BMI_FORTRAN

#ifndef ACTIVATE_PYTHON
throw std::runtime_error("Error: can't run multi BMI tests for scenario at index 1 without BMI Python functionality active" SOURCE_LOC);
Expand Down Expand Up @@ -719,7 +719,7 @@ TEST_F(Bmi_Multi_Formulation_Test, GetResponse_3_b) {
/* 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
#if ACTIVATE_PYTHON && NGEN_WITH_BMI_FORTRAN

int ex_index = 3;

Expand All @@ -740,7 +740,7 @@ TEST_F(Bmi_Multi_Formulation_Test, GetResponse_3_b) {
}
}

#endif // ACTIVATE_PYTHON && NGEN_BMI_FORTRAN_ACTIVE
#endif // ACTIVATE_PYTHON && NGEN_WITH_BMI_FORTRAN

}

Expand Down Expand Up @@ -859,11 +859,11 @@ TEST_F(Bmi_Multi_Formulation_Test, GetIdAndCatchmentId) {
formulation.create_formulation(config_prop_ptree[ex_index]);
ASSERT_EQ(formulation.get_id(), "cat-27");
ASSERT_EQ(get_friend_catchment_id(formulation), "cat-27");
#ifdef NGEN_BMI_FORTRAN_ACTIVE
#ifdef NGEN_WITH_BMI_FORTRAN
ASSERT_EQ(get_friend_nested_catchment_id<Bmi_Fortran_Formulation>(formulation, 0), "cat-27");
#endif
//ASSERT_EQ(formulation.get_catchment_id(), "id");
}
#endif // NGEN_NGEN_WITH_BMI_C || NGEN_BMI_FORTRAN_ACTIVE || ACTIVATE_PYTHON
#endif // NGEN_NGEN_WITH_BMI_C || NGEN_WITH_BMI_FORTRAN || ACTIVATE_PYTHON

#endif // NGEN_BMI_MULTI_FORMULATION_TEST_CPP

0 comments on commit 01cd25b

Please sign in to comment.