Skip to content

Commit

Permalink
Further simplify the get_variable_time_begin function.
Browse files Browse the repository at this point in the history
  • Loading branch information
stcui007 authored and mattw-nws committed Sep 5, 2023
1 parent 2187c68 commit 8ae0100
Showing 1 changed file with 3 additions and 19 deletions.
22 changes: 3 additions & 19 deletions include/realizations/catchment/Bmi_Multi_Formulation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,26 +239,10 @@ namespace realization {

time_t get_variable_time_begin(const std::string &variable_name) {
std::string var_name = variable_name;
// when unspecified, assume all data is available for the same range.
// If no var_name, use forcing ...
if(var_name == "*" || var_name == ""){
// when unspecified, assume all data is available for the same range.
// Find one that successfully returns...
for(std::map<std::string,std::shared_ptr<data_access::GenericDataProvider>>::iterator iter = availableData.begin(); iter != availableData.end(); ++iter)
{
var_name = iter->first;
auto it = std::find(forcing->get_available_variable_names().begin(), forcing->get_available_variable_names().end(), var_name);
if (it == forcing->get_available_variable_names().end()) {
var_name = forcing->get_available_variable_names()[0];
}
//TODO: Find a probably more performant way than trial and exception here.
try {
time_t rv = availableData[var_name]->get_data_start_time();
return rv;
}
catch (...){
continue;
}
break;
}
return forcing->get_data_start_time();
}
// If not found ...
if (availableData.empty() || availableData.find(var_name) == availableData.end()) {
Expand Down

0 comments on commit 8ae0100

Please sign in to comment.