IODA Bundle
oops/interface/ObsAuxControl.h
Go to the documentation of this file.
1 /*
2  * (C) Copyright 2009-2016 ECMWF.
3  *
4  * This software is licensed under the terms of the Apache Licence Version 2.0
5  * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
6  * In applying this licence, ECMWF does not waive the privileges and immunities
7  * granted to it by virtue of its status as an intergovernmental organisation nor
8  * does it submit to any jurisdiction.
9  */
10 
11 #ifndef OOPS_INTERFACE_OBSAUXCONTROL_H_
12 #define OOPS_INTERFACE_OBSAUXCONTROL_H_
13 
14 #include <iostream>
15 #include <memory>
16 #include <string>
17 
19 #include "oops/util/Logger.h"
20 #include "oops/util/ObjectCounter.h"
21 #include "oops/util/Printable.h"
22 #include "oops/util/Timer.h"
23 
24 namespace oops {
25  class Variables;
26 
27 // -----------------------------------------------------------------------------
28 
29 template <typename OBS>
30 class ObsAuxControl : public util::Printable,
31  private util::ObjectCounter<ObsAuxControl<OBS> > {
32  typedef typename OBS::ObsAuxControl ObsAuxControl_;
33 
34  public:
35  typedef typename ObsAuxControl_::Parameters_ Parameters_;
36 
37  static const std::string classname() {return "oops::ObsAuxControl";}
38 
40  explicit ObsAuxControl(const ObsAuxControl &, const bool copy = true);
42 
43 /// Interfacing
44  const ObsAuxControl_ & obsauxcontrol() const {return *aux_;}
46 
47 /// I/O and diagnostics
48  void read(const Parameters_ &);
49  void write(const Parameters_ &) const;
50  double norm() const;
51 
52 /// Other
53  const Variables & requiredVars() const;
54  const Variables & requiredHdiagnostics() const;
55 
56 /// Operator
58 
59  private:
60  void print(std::ostream &) const;
61  std::unique_ptr<ObsAuxControl_> aux_;
62 };
63 
64 // =============================================================================
65 
66 template<typename OBS>
68  const Parameters_ & params) : aux_()
69 {
70  Log::trace() << "ObsAuxControl<OBS>::ObsAuxControl starting" << std::endl;
71  util::Timer timer(classname(), "ObsAuxControl");
72  aux_.reset(new ObsAuxControl_(os.obsspace(), params));
73  Log::trace() << "ObsAuxControl<OBS>::ObsAuxControl done" << std::endl;
74 }
75 
76 // -----------------------------------------------------------------------------
77 
78 template<typename OBS>
79 ObsAuxControl<OBS>::ObsAuxControl(const ObsAuxControl & other, const bool copy) : aux_()
80 {
81  Log::trace() << "ObsAuxControl<OBS>::ObsAuxControl copy starting" << std::endl;
82  util::Timer timer(classname(), "ObsAuxControl");
83  aux_.reset(new ObsAuxControl_(*other.aux_, copy));
84  Log::trace() << "ObsAuxControl<OBS>::ObsAuxControl copy done" << std::endl;
85 }
86 
87 // -----------------------------------------------------------------------------
88 
89 template<typename OBS>
91  Log::trace() << "ObsAuxControl<OBS>::~ObsAuxControl starting" << std::endl;
92  util::Timer timer(classname(), "~ObsAuxControl");
93  aux_.reset();
94  Log::trace() << "ObsAuxControl<OBS>::~ObsAuxControl done" << std::endl;
95 }
96 
97 // -----------------------------------------------------------------------------
98 
99 template<typename OBS>
101  Log::trace() << "ObsAuxControl<OBS>::read starting" << std::endl;
102  util::Timer timer(classname(), "read");
103  aux_->read(params);
104  Log::trace() << "ObsAuxControl<OBS>::read done" << std::endl;
105 }
106 
107 // -----------------------------------------------------------------------------
108 
109 template<typename OBS>
111  Log::trace() << "ObsAuxControl<OBS>::write starting" << std::endl;
112  util::Timer timer(classname(), "write");
113  aux_->write(params);
114  Log::trace() << "ObsAuxControl<OBS>::write done" << std::endl;
115 }
116 
117 // -----------------------------------------------------------------------------
118 
119 template<typename OBS>
120 double ObsAuxControl<OBS>::norm() const {
121  Log::trace() << "ObsAuxControl<OBS>::norm starting" << std::endl;
122  util::Timer timer(classname(), "norm");
123  double zz = aux_->norm();
124  Log::trace() << "ObsAuxControl<OBS>::norm done" << std::endl;
125  return zz;
126 }
127 
128 // -----------------------------------------------------------------------------
129 
130 template<typename OBS>
132  Log::trace() << "ObsAuxControl<OBS>::requiredVars starting" << std::endl;
133  util::Timer timer(classname(), "requiredVars");
134  Log::trace() << "ObsAuxControl<OBS>::requiredVars done" << std::endl;
135  return aux_->requiredVars();
136 }
137 
138 // -----------------------------------------------------------------------------
139 
140 template<typename OBS>
142  Log::trace() << "ObsAuxControl<OBS>::requiredHdiagnostics starting" << std::endl;
143  util::Timer timer(classname(), "requiredHdiagnostics");
144  Log::trace() << "ObsAuxControl<OBS>::requiredHdiagnostics done" << std::endl;
145  return aux_->requiredHdiagnostics();
146 }
147 
148 // -----------------------------------------------------------------------------
149 template<typename OBS>
151  Log::trace() << "ObsAuxControl<OBS>::operator= starting" << std::endl;
152  util::Timer timer(classname(), "operator=");
153  *aux_ = *rhs.aux_;
154  Log::trace() << "ObsAuxControl<OBS>::operator= done" << std::endl;
155  return *this;
156 }
157 
158 // -----------------------------------------------------------------------------
159 
160 template<typename OBS>
161 void ObsAuxControl<OBS>::print(std::ostream & os) const {
162  Log::trace() << "ObsAuxControl<OBS>::print starting" << std::endl;
163  util::Timer timer(classname(), "print");
164  os << *aux_;
165  Log::trace() << "ObsAuxControl<OBS>::print done" << std::endl;
166 }
167 
168 // -----------------------------------------------------------------------------
169 
170 } // namespace oops
171 
172 #endif // OOPS_INTERFACE_OBSAUXCONTROL_H_
void read(const Parameters_ &)
I/O and diagnostics.
void write(const Parameters_ &) const
ObsAuxControl & operator=(const ObsAuxControl &)
Operator.
const Variables & requiredVars() const
Other.
ObsAuxControl_::Parameters_ Parameters_
static const std::string classname()
const ObsAuxControl_ & obsauxcontrol() const
Interfacing.
std::unique_ptr< ObsAuxControl_ > aux_
void print(std::ostream &) const
ObsAuxControl(const ObsSpace< OBS > &, const Parameters_ &params)
const Variables & requiredHdiagnostics() const
ObsSpace_ & obsspace() const
Interfacing.
IODA_DL void copy(const ObjectSelection &from, ObjectSelection &to, const ScaleMapping &scale_map)
Generic data copying function.
Definition: Copying.cpp:63
The namespace for the main oops code.