8 #ifndef OOPS_BASE_OBSAUXINCREMENTS_H_
9 #define OOPS_BASE_OBSAUXINCREMENTS_H_
19 #include "oops/util/Logger.h"
20 #include "oops/util/ObjectCounter.h"
21 #include "oops/util/Printable.h"
22 #include "oops/util/Serializable.h"
30 template <
typename OBS>
32 public util::Serializable,
33 private util::ObjectCounter<ObsAuxIncrements<OBS> > {
39 static const std::string
classname() {
return "oops::ObsAuxIncrements";}
62 void read(
const eckit::Configuration &);
63 void write(
const eckit::Configuration &)
const;
68 void serialize(std::vector<double> &)
const override;
69 void deserialize(
const std::vector<double> &,
size_t &)
override;
72 void print(std::ostream &)
const override;
73 std::vector<std::unique_ptr<ObsAuxIncrement_> >
auxs_;
78 template <
typename OBS>
80 Log::trace() <<
"operator+=(ObsAuxControls, ObsAuxIncrements) starting" << std::endl;
82 for (std::size_t jobs = 0; jobs < xx.
size(); ++jobs) {
83 xx[jobs].obsauxcontrol() += dx[jobs].obsauxincrement();
85 Log::trace() <<
"operator+=(ObsAuxControls, ObsAuxIncrements) done" << std::endl;
91 template<
typename OBS>
95 Log::trace() <<
"ObsAuxIncrements<OBS>::ObsAuxIncrements starting" << std::endl;
97 std::vector<eckit::LocalConfiguration> obsconf = conf.getSubConfigurations();
98 for (std::size_t jobs = 0; jobs < obsconf.size(); ++jobs) {
99 eckit::LocalConfiguration obsauxconf = obsconf[jobs].getSubConfiguration(
"obs bias");
101 obsauxparams.validateAndDeserialize(obsauxconf);
103 std::unique_ptr<ObsAuxIncrement_>(
new ObsAuxIncrement_(odb[jobs], obsauxparams)));
104 bytes +=
auxs_[jobs]->serialSize();
106 this->setObjectSize(bytes*
sizeof(
double));
107 Log::trace() <<
"ObsAuxIncrements<OBS>::ObsAuxIncrements done" << std::endl;
110 template<
typename OBS>
112 : auxs_(other.size())
114 Log::trace() <<
"ObsAuxIncrements<OBS>::ObsAuxIncrements copy starting" << std::endl;
117 for (std::size_t jobs = 0; jobs < other.
size(); ++jobs) {
119 bytes +=
auxs_[jobs]->serialSize();
121 this->setObjectSize(bytes*
sizeof(
double));
122 Log::trace() <<
"ObsAuxIncrements<OBS>::ObsAuxIncrements copy done" << std::endl;
125 template<
typename OBS>
127 Log::trace() <<
"ObsAuxIncrements<OBS>::~ObsAuxIncrements starting" << std::endl;
128 for (std::size_t jobs = 0; jobs < auxs_.size(); ++jobs) auxs_[jobs].reset();
129 Log::trace() <<
"ObsAuxIncrements<OBS>::~ObsAuxIncrements done" << std::endl;
132 template<
typename OBS>
134 Log::trace() <<
"ObsAuxIncrements<OBS>::diff starting" << std::endl;
136 for (std::size_t jobs = 0; jobs < size(); ++jobs) {
137 auxs_[jobs]->diff(x1[jobs], x2[jobs]);
139 Log::trace() <<
"ObsAuxIncrements<OBS>::diff done" << std::endl;
142 template<
typename OBS>
144 Log::trace() <<
"ObsAuxIncrements<OBS>::zero starting" << std::endl;
145 for (std::size_t jobs = 0; jobs < size(); ++jobs) {
148 Log::trace() <<
"ObsAuxIncrements<OBS>::zero done" << std::endl;
151 template<
typename OBS>
153 Log::trace() <<
"ObsAuxIncrements<OBS>::operator= starting" << std::endl;
154 ASSERT(size() == rhs.
size());
155 for (std::size_t jobs = 0; jobs < size(); ++jobs) {
156 *auxs_[jobs] = rhs[jobs];
158 Log::trace() <<
"ObsAuxIncrements<OBS>::operator= done" << std::endl;
162 template<
typename OBS>
164 Log::trace() <<
"ObsAuxIncrements<OBS>::operator+= starting" << std::endl;
165 ASSERT(size() == rhs.
size());
166 for (std::size_t jobs = 0; jobs < size(); ++jobs) {
167 *auxs_[jobs] += rhs[jobs];
169 Log::trace() <<
"ObsAuxIncrements<OBS>::operator+= done" << std::endl;
173 template<
typename OBS>
175 Log::trace() <<
"ObsAuxIncrements<OBS>::operator-= starting" << std::endl;
176 ASSERT(size() == rhs.
size());
177 for (std::size_t jobs = 0; jobs < size(); ++jobs) {
178 *auxs_[jobs] -= rhs[jobs];
180 Log::trace() <<
"ObsAuxIncrements<OBS>::operator-= done" << std::endl;
184 template<
typename OBS>
186 Log::trace() <<
"ObsAuxIncrements<OBS>::operator*= starting" << std::endl;
187 for (std::size_t jobs = 0; jobs < size(); ++jobs) {
190 Log::trace() <<
"ObsAuxIncrements<OBS>::operator*= done" << std::endl;
194 template<
typename OBS>
196 Log::trace() <<
"ObsAuxIncrements<OBS>::axpy starting" << std::endl;
197 ASSERT(size() == dx.
size());
198 for (std::size_t jobs = 0; jobs < size(); ++jobs) {
199 auxs_[jobs]->axpy(zz, dx[jobs]);
201 Log::trace() <<
"ObsAuxIncrements<OBS>::axpy done" << std::endl;
204 template<
typename OBS>
206 Log::trace() <<
"ObsAuxIncrements<OBS>::dot_product_with starting" << std::endl;
207 ASSERT(size() == dx.
size());
208 double zz =
static_cast<double>(0.0);
209 for (std::size_t jobs = 0; jobs < size(); ++jobs) {
210 zz += auxs_[jobs]->dot_product_with(dx[jobs]);
212 Log::trace() <<
"ObsAuxIncrements<OBS>::dot_product_with done" << std::endl;
216 template<
typename OBS>
218 Log::trace() <<
"ObsAuxIncrements<OBS>::read starting" << std::endl;
219 for (std::size_t jobs = 0; jobs < auxs_.size(); ++jobs) auxs_[jobs]->read(conf);
220 Log::trace() <<
"ObsAuxIncrements<OBS>::read done" << std::endl;
223 template<
typename OBS>
225 Log::trace() <<
"ObsAuxIncrements<OBS>::write starting" << std::endl;
226 for (std::size_t jobs = 0; jobs < auxs_.size(); ++jobs) auxs_[jobs]->
write(conf);
227 Log::trace() <<
"ObsAuxIncrements<OBS>::write done" << std::endl;
230 template<
typename OBS>
232 Log::trace() <<
"ObsAuxIncrements<OBS>::norm starting" << std::endl;
233 double zz =
static_cast<double>(0.0);
234 for (std::size_t jobs = 0; jobs < size(); ++jobs) {
235 zz += auxs_[jobs]->norm();
237 Log::trace() <<
"ObsAuxIncrements<OBS>::norm done" << std::endl;
241 template<
typename OBS>
243 Log::trace() <<
"ObsAuxIncrements<OBS>::serialSize starting" << std::endl;
245 for (std::size_t jobs = 0; jobs < auxs_.size(); ++jobs) {
246 ss += auxs_[jobs]->serialSize();
248 Log::trace() <<
"ObsAuxIncrements<OBS>::serialSize done" << std::endl;
252 template<
typename OBS>
254 Log::trace() <<
"ObsAuxIncrements<OBS>::serialize starting" << std::endl;
255 for (std::size_t jobs = 0; jobs < auxs_.size(); ++jobs) auxs_[jobs]->serialize(vect);
256 Log::trace() <<
"ObsAuxIncrements<OBS>::serialize done" << std::endl;
259 template<
typename OBS>
261 Log::trace() <<
"ObsAuxIncrements<OBS>::deserialize starting" << std::endl;
262 for (std::size_t jobs = 0; jobs < auxs_.size(); ++jobs) {
263 auxs_[jobs]->deserialize(vect, index);
265 Log::trace() <<
"ObsAuxIncrements<OBS>::deserialize done" << std::endl;
269 template<
typename OBS>
271 for (std::size_t jobs = 0; jobs < auxs_.size(); ++jobs) os << *auxs_[jobs];
Holds a vector of ObsAuxControl.
std::size_t size() const
Access.
Auxiliary increment related to observations, templated on <OBS>
ObsAuxIncrement_::Parameters_ Parameters_
Holds a vector of ObsAuxIncrement.
void print(std::ostream &) const override
void deserialize(const std::vector< double > &, size_t &) override
size_t serialSize() const override
Serialize-Deserialize.
ObsAuxIncrements & operator*=(const double &)
ObsAuxControls< OBS > ObsAuxControls_
ObsAuxIncrement_ & operator[](const std::size_t ii)
ObsAuxIncrements(const ObsSpaces_ &, const eckit::Configuration &)
Constructor, destructor.
double dot_product_with(const ObsAuxIncrements &) const
ObsSpaces< OBS > ObsSpaces_
void write(const eckit::Configuration &) const
void serialize(std::vector< double > &) const override
static const std::string classname()
ObsAuxIncrements & operator+=(const ObsAuxIncrements &)
const ObsAuxIncrement_ & operator[](const std::size_t ii) const
ObsAuxIncrements & operator=(const ObsAuxIncrements &)
void read(const eckit::Configuration &)
I/O and diagnostics.
std::vector< std::unique_ptr< ObsAuxIncrement_ > > auxs_
ObsAuxIncrement< OBS > ObsAuxIncrement_
std::size_t size() const
Access.
void diff(const ObsAuxControls_ &, const ObsAuxControls_ &)
Linear algebra operators.
ObsAuxIncrements & operator-=(const ObsAuxIncrements &)
void axpy(const double &, const ObsAuxIncrements &)
The namespace for the main oops code.
State< MODEL > & operator+=(State< MODEL > &xx, const Increment< MODEL > &dx)
Add on dx incrment to model state xx.
subroutine write(self, filename_in)