Skip to content

Commit c8d3372

Browse files
committed
Tidying up.
1 parent a7c038c commit c8d3372

File tree

5 files changed

+18
-71
lines changed

5 files changed

+18
-71
lines changed

src/orca-jedi/increment/Increment.cc

+8-16
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,6 @@
3737
#include "atlas/mesh.h"
3838
#include "atlas-orca/grid/OrcaGrid.h"
3939

40-
#include <boost/uuid/uuid.hpp> // uuid class DJL
41-
#include <boost/uuid/uuid_generators.hpp> // generators DJL
42-
#include <boost/uuid/uuid_io.hpp> // streaming operators etc. DJL
43-
44-
4540
namespace orcamodel {
4641

4742
// -----------------------------------------------------------------------------
@@ -232,8 +227,6 @@ void Increment::diff(const State & x1, const State & x2) {
232227
atlas::field::MissingValue mv2(field2);
233228
bool has_mv2 = static_cast<bool>(mv2);
234229
bool has_mv = has_mv1 || has_mv2;
235-
oops::Log::debug() << "DJL Increment::diff mv1 " << mv1 << " mv2 " << mv2 << " has_mv "
236-
<< has_mv << std::endl;
237230

238231
std::string fieldName1 = field1.name();
239232
std::string fieldName2 = field2.name();
@@ -284,18 +277,11 @@ void Increment::setval(const double & val) {
284277
if (!has_mv || (has_mv && !mv(field_view(j, k)))) {
285278
field_view(j, k) = val;
286279
}
287-
} else {
288-
field_view(j, k) = -99; /// DJL
289280
}
290281
}
291282
}
292283
}
293284

294-
// DJL write debug fields to file
295-
boost::uuids::uuid uuid = boost::uuids::random_generator()();
296-
writeFieldsToFile("incsetval"+ boost::uuids::to_string(uuid) +".nc", *geom_,
297-
validTime(), incrementFields_);
298-
299285
oops::Log::trace() << "Increment(ORCA)::setval done" << std::endl;
300286
}
301287

@@ -559,7 +545,7 @@ void Increment::read(const eckit::Configuration & conf) {
559545
throw eckit::NotImplemented(err_message, Here());
560546
}
561547

562-
/// \brief write out increments fields to a file using params specified filename.
548+
/// \brief Write out increments fields to a file using params specified filename.
563549
void Increment::write(const OrcaIncrementParameters & params) const {
564550
oops::Log::debug() << "orcamodel::increment::write" << std::endl;
565551

@@ -572,10 +558,16 @@ void Increment::write(const OrcaIncrementParameters & params) const {
572558
oops::Log::debug() << "Increment::write to filename "
573559
<< nemo_field_path << std::endl;
574560

561+
for (size_t i=0; i < vars_.size(); ++i) {
562+
auto gv_varname = vars_[i].name();
563+
// halo exchange update ghost points
564+
geom_->functionSpace().haloExchange(incrementFields_[gv_varname]);
565+
}
566+
575567
writeFieldsToFile(nemo_field_path, *geom_, time_, incrementFields_);
576568
}
577569

578-
/// \brief write out increments fields to a file using config specified filename.
570+
/// \brief Write out increments fields to a file using config specified filename.
579571
void Increment::write(const eckit::Configuration & config) const {
580572
write(oops::validateAndDeserialize<OrcaIncrementParameters>(config));
581573
}

src/orca-jedi/interpolator/Interpolator.cc

+2-42
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,6 @@
3131

3232
#include "orca-jedi/interpolator/Interpolator.h"
3333

34-
#include <boost/uuid/uuid.hpp> // uuid class DJL
35-
#include <boost/uuid/uuid_generators.hpp> // generators DJL
36-
#include <boost/uuid/uuid_io.hpp> // streaming operators etc. DJL
37-
38-
#include "orca-jedi/utilities/IOUtils.h" // DJL
39-
40-
4134
namespace eckit {
4235
class Configuration;
4336
}
@@ -193,7 +186,6 @@ template void Interpolator::executeInterpolation<float>(
193186
void Interpolator::apply(const oops::Variables& vars, const Increment& inc,
194187
const std::vector<bool> & mask,
195188
std::vector<double>& result) const {
196-
// DJL question can the atlas templates help?
197189
// input is inc output is result
198190
const size_t nvars = vars.size();
199191

@@ -226,7 +218,6 @@ void Interpolator::apply(const oops::Variables& vars, const Increment& inc,
226218
auto field_view = atlas::array::make_view<double, 2>(tgt_field);
227219
atlas::field::MissingValue mv(inc.incrementFields()[gv_varname]);
228220
bool has_mv = static_cast<bool>(mv);
229-
oops::Log::debug() << "DJL Interpolator::apply mv " << mv << " has_mv " << has_mv << std::endl;
230221
for (std::size_t klev=0; klev < varSizes[jvar]; ++klev) {
231222
for (std::size_t iloc=0; iloc < nlocs_; iloc++) {
232223
if (has_mv && mv(field_view(iloc, klev))) {
@@ -254,10 +245,6 @@ void Interpolator::applyAD(const oops::Variables& vars, Increment& inc,
254245
oops::Log::trace() << "orcamodel::Interpolator::applyAD start "
255246
<< std::endl;
256247

257-
oops::Log::debug() << "DJL ** Interpolator::applyAD this needs checking **" << std::endl;
258-
259-
// ** Trying to do the opposite of apply DJL
260-
261248
const size_t nvars = vars.size();
262249

263250
for (size_t j=0; j < nvars; ++j) {
@@ -277,65 +264,38 @@ void Interpolator::applyAD(const oops::Variables& vars, Increment& inc,
277264
inc.geometry()->variableSizes(vars);
278265
size_t nvals = 0;
279266

280-
// DJL write debug fields to file
281-
boost::uuids::uuid uuid = boost::uuids::random_generator()();
282-
std::shared_ptr<const Geometry> geom = inc.geometry();
283-
writeFieldsToFile("applyADpre"+ boost::uuids::to_string(uuid) +".nc", *geom,
284-
inc.validTime(), inc.incrementFields());
285-
286267
for (size_t jvar=0; jvar < nvars; ++jvar) nvals += nlocs_ * varSizes[jvar];
287-
// result.resize(nvals);
288-
289268

290269
std::size_t out_idx = 0;
291270
for (size_t jvar=0; jvar < nvars; ++jvar) {
292-
oops::Log::debug() << "DJL ** jvar " << jvar << " " << nvars
293-
<< "varSizes " << varSizes[jvar]
294-
<< std::endl;
295271
auto gv_varname = vars[jvar].name();
296-
// atlas::Field tgt_field = atlasObsFuncSpace_.createField<double>(
297-
// atlas::option::name(gv_varname) |
298-
// atlas::option::levels(varSizes[jvar]));
299-
// atlas::Field incField = inc.incrementFields()[jvar];
300-
301272
auto tgt_field = atlasObsFuncSpace_.createField<double>(
302273
atlas::option::name(gv_varname) |
303274
atlas::option::levels(varSizes[jvar]));
304275

305276
// Copying observation array vector to an atlas observation field (tgt_field)
306-
// DJL not sure if the missing value aspect does anything here
307277
auto field_view = atlas::array::make_view<double, 2>(tgt_field);
308-
// field_view.assign(0.0);
309278
atlas::field::MissingValue mv(inc.incrementFields()[gv_varname]);
310279
bool has_mv = static_cast<bool>(mv);
311-
oops::Log::debug() << "DJL Interpolator::applyAD mv "
312-
<< mv << " has_mv " << has_mv << std::endl;
313280

314281
for (std::size_t klev=0; klev < varSizes[jvar]; ++klev) {
315282
for (std::size_t iloc=0; iloc < nlocs_; iloc++) {
316283
if (has_mv && mv(field_view(iloc, klev))) {
317284
field_view(iloc, klev) = util::missingValue<double>();
318285
} else {
319-
oops::Log::debug() << "DJL iloc " << iloc << " klev " << klev << " out_idx "
320-
<< out_idx << " resultin[out_idx] " << resultin[out_idx] << std::endl;
321286
field_view(iloc, klev) = resultin[out_idx];
322287
}
323288
++out_idx;
324289
}
325290
}
326291

327-
// halo exchange update ghost points DJL
292+
// halo exchange update ghost points
293+
std::shared_ptr<const Geometry> geom = inc.geometry();
328294
geom->functionSpace().haloExchange(inc.incrementFields()[gv_varname]);
329295

330296
interpolator_.execute_adjoint(inc.incrementFields()[gv_varname], tgt_field);
331297
} // jvar
332298

333-
// DJL write debug fields to file
334-
// boost::uuids::uuid uuid = boost::uuids::random_generator()();
335-
// std::shared_ptr<const Geometry> geom = inc.geometry();
336-
writeFieldsToFile("applyAD"+ boost::uuids::to_string(uuid) +".nc", *geom, inc.validTime(),
337-
inc.incrementFields());
338-
339299
oops::Log::trace() << "orcamodel::Interpolator::applyAD done "
340300
<< std::endl;
341301
}

src/orca-jedi/state/State.cc

+5-3
Original file line numberDiff line numberDiff line change
@@ -164,14 +164,14 @@ State & State::operator=(const State & rhs) {
164164

165165
// Interactions with Increments
166166

167+
/// \brief Add increment to state.
168+
/// \brief Requires increment and state to have the same field names (currently).
169+
/// \param Increment.
167170
State & State::operator+=(const Increment & dx) {
168171
oops::Log::trace() << "State(ORCA)::add increment starting" << std::endl;
169172

170173
ASSERT(this->validTime() == dx.validTime());
171174

172-
// DJL assumes state and increments have the same fields in the field set
173-
// DJL add something to enforce/check this
174-
175175
auto ghost = atlas::array::make_view<int32_t, 1>(
176176
geom_->mesh().nodes().ghost());
177177
for (int i = 0; i< stateFields_.size(); i++)
@@ -187,6 +187,8 @@ State & State::operator+=(const Increment & dx) {
187187
oops::Log::debug() << "orcamodel::Increment::add:: state field name = " << fieldName
188188
<< " increment field name = " << fieldNamei
189189
<< std::endl;
190+
ASSERT(fieldName == fieldNamei);
191+
190192
auto field_view = atlas::array::make_view<double, 2>(field);
191193
auto field_viewi = atlas::array::make_view<double, 2>(fieldi);
192194
for (atlas::idx_t j = 0; j < field_view.shape(0); ++j) {

src/tests/testinput/3dvar_ice_obs.yaml

+3-7
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ cost function:
4444
obsdataout:
4545
engine:
4646
type: H5File
47-
obsfile: testoutput/test_3dvar_obsdataout.nc
47+
obsfile: testoutput/obsdataout_3dvar_ice.nc
4848
simulated variables: [ice_area_fraction]
4949
get values:
5050
time interpolation: linear
@@ -91,17 +91,13 @@ variational:
9191
write increment: true
9292
increment:
9393
state component:
94-
output path: testoutput/increments_ice.nc
94+
output path: testoutput/increments_3dvar_ice.nc
9595
date: 2021-06-30T00:00:00Z
96-
# type: in
9796
final:
9897
diagnostics:
9998
departures: oman
10099
output:
101100
date: 2021-06-30T00:00:00Z
102101
state variables: [ ice_area_fraction ]
103102
nemo field file: testoutput/3dvar_ice2.nc
104-
output nemo field file: testoutput/3dvar_ice_analysis.nc
105-
# steps: ["2021-06-29T12:00:00Z"]
106-
#test:
107-
# reference filename: testoutput/test_3dvar_ice_obs.ref
103+
output nemo field file: testoutput/analysis_3dvar_ice.nc

src/tests/testinput/dirac.yaml

-3
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,3 @@ background:
3636
output dirac:
3737
date: 2021-06-30T12:00:00Z
3838
output path: testoutput/dirac_cov_%id%.nc
39-
40-
#test:
41-
# reference filename: testoutput/test_dirac.ref

0 commit comments

Comments
 (0)