Skip to content

Commit a70f66d

Browse files
committed
EAMxx: enabling count conditional diags
1 parent 9d377fd commit a70f66d

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

components/eamxx/src/diagnostics/conditional_sampling.cpp

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,10 @@ void ConditionalSampling::set_grids(const std::shared_ptr<const GridsManager> gr
211211
const auto &gn = m_params.get<std::string>("grid_name");
212212
const auto g = grids_manager->get_grid("physics");
213213

214-
add_field<Required>(m_input_f, gn);
214+
// Special case: if the input field is "count", we don't need to add it
215+
if (m_input_f != "count") {
216+
add_field<Required>(m_input_f, gn);
217+
}
215218

216219
// Special case: if condition field is "lev", we don't add it as a required field
217220
// since it's geometric information from the grid, not an actual field
@@ -239,6 +242,10 @@ void ConditionalSampling::initialize_impl(const RunType /*run_type*/) {
239242
m_diagnostic_output.get_header().set_extra_data("mask_data", diag_mask);
240243
m_diagnostic_output.get_header().set_extra_data("mask_value", m_mask_val);
241244

245+
// Special case: if the input field is "count", let's create a field of 1 inside m_diagnostic_output
246+
if (m_input_f == "count") {
247+
m_diagnostic_output.deep_copy(1.0);
248+
}
242249
// Special case: if condition field is "lev", we don't need to check layout compatibility
243250
// since "lev" is geometric information, not an actual field
244251
if (m_condition_f == "lev") {
@@ -259,7 +266,13 @@ void ConditionalSampling::initialize_impl(const RunType /*run_type*/) {
259266
}
260267

261268
void ConditionalSampling::compute_diagnostic_impl() {
262-
const auto &f = get_field_in(m_input_f);
269+
Field &f;
270+
if (m_input_f == "count") {
271+
// Special case: if the input field is "count", we use the diagnostic output as the input
272+
f = m_diagnostic_output;
273+
} else {
274+
f = get_field_in(m_input_f);
275+
}
263276
const auto &d = m_diagnostic_output;
264277

265278
// Validate operator

0 commit comments

Comments
 (0)