Skip to content

Commit a999325

Browse files
committed
interpolator adjoint deal with missing values.
1 parent 7eab74e commit a999325

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

src/orca-jedi/interpolator/Interpolator.cc

+9-8
Original file line numberDiff line numberDiff line change
@@ -304,27 +304,28 @@ void Interpolator::applyAD(const oops::Variables& vars, Increment& inc,
304304
atlas::option::name(gv_varname) |
305305
atlas::option::levels(varSizes[jvar]));
306306

307+
// Copying observation array vector to an atlas observation field (tgt_field)
308+
// DJL not sure if the missing value aspect does anything here
307309
auto field_view = atlas::array::make_view<double, 2>(tgt_field);
308310
// field_view.assign(0.0);
309-
311+
atlas::field::MissingValue mv(inc.incrementFields()[gv_varname]);
312+
bool has_mv = static_cast<bool>(mv);
310313
for (std::size_t klev=0; klev < varSizes[jvar]; ++klev) {
311314
for (std::size_t iloc=0; iloc < nlocs_; iloc++) {
312-
// if (has_mv && mv(field_view(iloc, klev))) {
313-
//// result[out_idx] = util::missingValue(result[out_idx]);
314-
// } else {
315+
if (has_mv && mv(field_view(iloc, klev))) {
316+
field_view(iloc, klev) = util::missingValue<double>();
317+
} else {
315318
oops::Log::debug() << "DJL iloc " << iloc << " klev " << klev << " out_idx "
316319
<< out_idx << " resultin[out_idx] " << resultin[out_idx] << std::endl;
317-
field_view(iloc, klev) = resultin[out_idx];
318-
// }
320+
field_view(iloc, klev) = resultin[out_idx];
321+
}
319322
++out_idx;
320323
}
321324
}
322325

323326
// halo exchange update ghost points DJL
324327
geom->functionSpace().haloExchange(inc.incrementFields()[gv_varname]);
325328

326-
// atlas::field::MissingValue mv(inc.incrementFields()[gv_varname]);
327-
// bool has_mv = static_cast<bool>(mv);
328329
interpolator_.execute_adjoint(inc.incrementFields()[gv_varname], tgt_field);
329330

330331
} // jvar

0 commit comments

Comments
 (0)