FV3 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 <string>
16 
17 #include <boost/scoped_ptr.hpp>
18 
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 eckit {
25  class Configuration;
26 }
27 
28 namespace oops {
29 
30 // -----------------------------------------------------------------------------
31 
32 template <typename MODEL>
33 class ObsAuxControl : public util::Printable,
34  private util::ObjectCounter<ObsAuxControl<MODEL> > {
35  typedef typename MODEL::ObsAuxControl ObsAuxControl_;
36 
37  public:
38  static const std::string classname() {return "oops::ObsAuxControl";}
39 
40  explicit ObsAuxControl(const eckit::Configuration &);
41  explicit ObsAuxControl(const ObsAuxControl &, const bool copy = true);
43 
44 /// Interfacing
45  const ObsAuxControl_ & obsauxcontrol() const {return *aux_;}
47 
48 /// I/O and diagnostics
49  void read(const eckit::Configuration &);
50  void write(const eckit::Configuration &) const;
51  double norm() const;
52 
53  private:
55  void print(std::ostream &) const;
56  boost::scoped_ptr<ObsAuxControl_> aux_;
57 };
58 
59 // =============================================================================
60 
61 template<typename MODEL>
62 ObsAuxControl<MODEL>::ObsAuxControl(const eckit::Configuration & conf) : aux_()
63 {
64  Log::trace() << "ObsAuxControl<MODEL>::ObsAuxControl starting" << std::endl;
65  util::Timer timer(classname(), "ObsAuxControl");
66  aux_.reset(new ObsAuxControl_(conf));
67  Log::trace() << "ObsAuxControl<MODEL>::ObsAuxControl done" << std::endl;
68 }
69 
70 // -----------------------------------------------------------------------------
71 
72 template<typename MODEL>
73 ObsAuxControl<MODEL>::ObsAuxControl(const ObsAuxControl & other, const bool copy) : aux_()
74 {
75  Log::trace() << "ObsAuxControl<MODEL>::ObsAuxControl copy starting" << std::endl;
76  util::Timer timer(classname(), "ObsAuxControl");
77  aux_.reset(new ObsAuxControl_(*other.aux_, copy));
78  Log::trace() << "ObsAuxControl<MODEL>::ObsAuxControl copy done" << std::endl;
79 }
80 
81 // -----------------------------------------------------------------------------
82 
83 template<typename MODEL>
85  Log::trace() << "ObsAuxControl<MODEL>::~ObsAuxControl starting" << std::endl;
86  util::Timer timer(classname(), "~ObsAuxControl");
87  aux_.reset();
88  Log::trace() << "ObsAuxControl<MODEL>::~ObsAuxControl done" << std::endl;
89 }
90 
91 // -----------------------------------------------------------------------------
92 
93 template<typename MODEL>
94 void ObsAuxControl<MODEL>::read(const eckit::Configuration & conf) {
95  Log::trace() << "ObsAuxControl<MODEL>::read starting" << std::endl;
96  util::Timer timer(classname(), "read");
97  aux_->read(conf);
98  Log::trace() << "ObsAuxControl<MODEL>::read done" << std::endl;
99 }
100 
101 // -----------------------------------------------------------------------------
102 
103 template<typename MODEL>
104 void ObsAuxControl<MODEL>::write(const eckit::Configuration & conf) const {
105  Log::trace() << "ObsAuxControl<MODEL>::write starting" << std::endl;
106  util::Timer timer(classname(), "write");
107  aux_->write(conf);
108  Log::trace() << "ObsAuxControl<MODEL>::write done" << std::endl;
109 }
110 
111 // -----------------------------------------------------------------------------
112 
113 template<typename MODEL>
115  Log::trace() << "ObsAuxControl<MODEL>::norm starting" << std::endl;
116  util::Timer timer(classname(), "norm");
117  double zz = aux_->norm();
118  Log::trace() << "ObsAuxControl<MODEL>::norm done" << std::endl;
119  return zz;
120 }
121 
122 // -----------------------------------------------------------------------------
123 
124 template<typename MODEL>
125 void ObsAuxControl<MODEL>::print(std::ostream & os) const {
126  Log::trace() << "ObsAuxControl<MODEL>::print starting" << std::endl;
127  util::Timer timer(classname(), "print");
128  os << *aux_;
129  Log::trace() << "ObsAuxControl<MODEL>::print done" << std::endl;
130 }
131 
132 // -----------------------------------------------------------------------------
133 
134 } // namespace oops
135 
136 #endif // OOPS_INTERFACE_OBSAUXCONTROL_H_
boost::scoped_ptr< ObsAuxControl_ > aux_
subroutine, public copy(self, rhs)
ObsAuxControl & operator=(const ObsAuxControl &)
Definition: conf.py:1
void read(const eckit::Configuration &)
I/O and diagnostics.
void write(const eckit::Configuration &) const
The namespace for the main oops code.
void print(std::ostream &) const
ObsAuxControl(const eckit::Configuration &)
MODEL::ObsAuxControl ObsAuxControl_
static const std::string classname()
const ObsAuxControl_ & obsauxcontrol() const
Interfacing.