Skip to content

Commit ff74dc2

Browse files
aaraneyhellkite500
authored andcommitted
fix: check if model supports mass balance checks only if feature is enabled.
1 parent c7ab4c8 commit ff74dc2

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/utilities/bmi/mass_balance.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,9 @@ auto NgenMassBalance::check_support(const ModelPtr& model) -> expected<void, Pro
137137

138138
auto NgenMassBalance::initialize(const ModelPtr& model, const Properties& properties) -> expected<void, ProtocolError>
139139
{
140-
//Ensure the model is capable of mass balance using the protocol
141-
check_support(model).or_else( error_or_warning );
142-
143140
//now check if the user has requested to use mass balance
144141
auto protocol_it = properties.find(CONFIGURATION_KEY);
145-
if ( supported && protocol_it != properties.end() ) {
142+
if ( protocol_it != properties.end() ) {
146143
geojson::PropertyMap mass_bal = protocol_it->second.get_values();
147144

148145
auto _it = mass_bal.find(TOLERANCE_KEY);
@@ -184,11 +181,15 @@ auto NgenMassBalance::initialize(const ModelPtr& model, const Properties& proper
184181
//no mass balance requested, or not supported, so don't check it
185182
check = false;
186183
}
184+
if ( check ) {
185+
//Ensure the model is capable of mass balance using the protocol
186+
check_support(model).or_else( error_or_warning );
187+
}
187188
return {}; // important to return for the expected to be properly created!
188189
}
189190

190191
bool NgenMassBalance::is_supported() const {
191192
return this->supported;
192193
}
193194

194-
}}} // end namespace models::bmi::protocols
195+
}}} // end namespace models::bmi::protocols

0 commit comments

Comments
 (0)