11 #ifndef OOPS_ASSIMILATION_CONTROLINCREMENT_H_
12 #define OOPS_ASSIMILATION_CONTROLINCREMENT_H_
20 #include "eckit/config/Configuration.h"
25 #include "oops/util/dot_product.h"
26 #include "oops/util/Logger.h"
27 #include "oops/util/ObjectCounter.h"
28 #include "oops/util/Printable.h"
29 #include "oops/util/Serializable.h"
49 template<
typename MODEL,
typename OBS>
51 public util::Serializable,
52 private util::ObjectCounter<ControlIncrement<MODEL, OBS> > {
60 static const std::string
classname() {
return "oops::ControlIncrement";}
79 void read(
const eckit::Configuration &);
80 void write(
const eckit::Configuration &)
const;
99 void serialize(std::vector<double> &)
const override;
100 void deserialize(
const std::vector<double> &,
size_t &)
override;
106 void print(std::ostream &)
const override;
117 template<
typename MODEL,
typename OBS>
119 : increment_(*jb.jbState().newStateIncrement()),
120 modbias_(jb.resolution(), jb.jbModBias().config()),
121 obsbias_(jb.jbObsBias().obspaces(), jb.jbObsBias().config()),
122 windowBegin_(jb.windowBegin()), windowEnd_(jb.windowEnd())
124 Log::trace() <<
"ControlIncrement:ControlIncrement created." << std::endl;
127 template<
typename MODEL,
typename OBS>
129 : increment_(other.increment_, copy), modbias_(other.modbias_, copy),
130 obsbias_(other.obsbias_, copy), windowBegin_(other.windowBegin_), windowEnd_(other.windowEnd_)
132 Log::trace() <<
"ControlIncrement:ControlIncrement copied." << std::endl;
135 template<
typename MODEL,
typename OBS>
137 const eckit::Configuration & tlConf)
138 : increment_(other.increment_, tlConf), modbias_(other.modbias_, tlConf),
139 obsbias_(other.obsbias_, tlConf), windowBegin_(other.windowBegin_), windowEnd_(other.windowEnd_)
141 Log::trace() <<
"ControlIncrement:ControlIncrement copied." << std::endl;
144 template<
typename MODEL,
typename OBS>
147 : increment_(geom, other.increment_), modbias_(other.modbias_, true),
148 obsbias_(other.obsbias_, true), windowBegin_(other.windowBegin_), windowEnd_(other.windowEnd_)
150 Log::trace() <<
"ControlIncrement:ControlIncrement copied." << std::endl;
153 template<
typename MODEL,
typename OBS>
180 template<
typename MODEL,
typename OBS>
188 template<
typename MODEL,
typename OBS>
195 template<
typename MODEL,
typename OBS>
202 template<
typename MODEL,
typename OBS>
204 increment_.read(config);
205 modbias_.read(config);
206 obsbias_.read(config);
209 template<
typename MODEL,
typename OBS>
211 increment_.write(config);
212 modbias_.write(config);
213 obsbias_.write(config);
216 template <
typename MODEL,
typename OBS>
223 template<
typename MODEL,
typename OBS>
227 zz += dot_product(modbias_, x2.
modbias_);
228 zz += dot_product(obsbias_, x2.
obsbias_);
232 template<
typename MODEL,
typename OBS>
235 ss += increment_.serialSize();
236 ss += modbias_.serialSize();
237 ss += obsbias_.serialSize();
241 template<
typename MODEL,
typename OBS>
243 vec.reserve(vec.size() + this->serialSize());
245 vec.push_back(-111.0);
246 increment_.serialize(vec);
248 vec.push_back(-222.0);
249 modbias_.serialize(vec);
251 vec.push_back(-333.0);
252 obsbias_.serialize(vec);
254 vec.push_back(-444.0);
257 template<
typename MODEL,
typename OBS>
259 ASSERT(vec.at(indx) == -111.0);
262 increment_.deserialize(vec, indx);
264 ASSERT(vec.at(indx) == -222.0);
267 modbias_.deserialize(vec, indx);
269 ASSERT(vec.at(indx) == -333.0);
272 obsbias_.deserialize(vec, indx);
273 ASSERT(vec.at(indx) == -444.0);
277 template<
typename MODEL,
typename OBS>
279 increment_.shift_forward(windowBegin_);
283 template<
typename MODEL,
typename OBS>
285 increment_.shift_backward(windowEnd_);
292 #endif // OOPS_ASSIMILATION_CONTROLINCREMENT_H_