FV3 Bundle
oops/interface/ModelAuxControl.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_MODELAUXCONTROL_H_
12 #define OOPS_INTERFACE_MODELAUXCONTROL_H_
13 
14 #include <iostream>
15 #include <string>
16 
17 #include <boost/scoped_ptr.hpp>
18 
20 #include "oops/util/Logger.h"
21 #include "oops/util/ObjectCounter.h"
22 #include "oops/util/Printable.h"
23 #include "oops/util/Timer.h"
24 
25 namespace eckit {
26  class Configuration;
27 }
28 
29 namespace oops {
30 
31 // -----------------------------------------------------------------------------
32 
33 template <typename MODEL>
34 class ModelAuxControl : public util::Printable,
35  private util::ObjectCounter<ModelAuxControl<MODEL> > {
36  typedef typename MODEL::ModelAuxControl ModelAuxControl_;
38 
39  public:
40  static const std::string classname() {return "oops::ModelAuxControl";}
41 
42  ModelAuxControl(const Geometry_ &, const eckit::Configuration &);
43  ModelAuxControl(const Geometry_ &, const ModelAuxControl &);
44  explicit ModelAuxControl(const ModelAuxControl &, const bool copy = true);
46 
47 /// Interfacing
48  const ModelAuxControl_ & modelauxcontrol() const {return *aux_;}
50 
51 /// I/O and diagnostics
52  void read(const eckit::Configuration &);
53  void write(const eckit::Configuration &) const;
54  double norm() const;
55 
56  private:
58  void print(std::ostream &) const;
59  boost::scoped_ptr<ModelAuxControl_> aux_;
60 };
61 
62 // =============================================================================
63 
64 template<typename MODEL>
66  const eckit::Configuration & conf) : aux_()
67 {
68  Log::trace() << "ModelAuxControl<MODEL>::ModelAuxControl starting" << std::endl;
69  util::Timer timer(classname(), "ModelAuxControl");
70  aux_.reset(new ModelAuxControl_(resol.geometry(), conf));
71  Log::trace() << "ModelAuxControl<MODEL>::ModelAuxControl done" << std::endl;
72 }
73 
74 // -----------------------------------------------------------------------------
75 
76 template<typename MODEL>
78  const ModelAuxControl & other) : aux_()
79 {
80  Log::trace() << "ModelAuxControl<MODEL>::ModelAuxControl interpolated starting" << std::endl;
81  util::Timer timer(classname(), "ModelAuxControl");
82  aux_.reset(new ModelAuxControl_(resol.geometry(), *other.aux_));
83  Log::trace() << "ModelAuxControl<MODEL>::ModelAuxControl interpolated done" << std::endl;
84 }
85 
86 // -----------------------------------------------------------------------------
87 
88 template<typename MODEL>
90  const bool copy) : aux_()
91 {
92  Log::trace() << "ModelAuxControl<MODEL>::ModelAuxControl copy starting" << std::endl;
93  util::Timer timer(classname(), "ModelAuxControl");
94  aux_.reset(new ModelAuxControl_(*other.aux_, copy));
95  Log::trace() << "ModelAuxControl<MODEL>::ModelAuxControl copy done" << std::endl;
96 }
97 
98 // -----------------------------------------------------------------------------
99 
100 template<typename MODEL>
102  Log::trace() << "ModelAuxControl<MODEL>::~ModelAuxControl starting" << std::endl;
103  util::Timer timer(classname(), "~ModelAuxControl");
104  aux_.reset();
105  Log::trace() << "ModelAuxControl<MODEL>::~ModelAuxControl done" << std::endl;
106 }
107 
108 // -----------------------------------------------------------------------------
109 
110 template<typename MODEL>
111 void ModelAuxControl<MODEL>::read(const eckit::Configuration & conf) {
112  Log::trace() << "ModelAuxControl<MODEL>::read starting" << std::endl;
113  util::Timer timer(classname(), "read");
114  aux_->read(conf);
115  Log::trace() << "ModelAuxControl<MODEL>::read done" << std::endl;
116 }
117 
118 // -----------------------------------------------------------------------------
119 
120 template<typename MODEL>
121 void ModelAuxControl<MODEL>::write(const eckit::Configuration & conf) const {
122  Log::trace() << "ModelAuxControl<MODEL>::write starting" << std::endl;
123  util::Timer timer(classname(), "write");
124  aux_->write(conf);
125  Log::trace() << "ModelAuxControl<MODEL>::write done" << std::endl;
126 }
127 
128 // -----------------------------------------------------------------------------
129 
130 template<typename MODEL>
132  Log::trace() << "ModelAuxControl<MODEL>::norm starting" << std::endl;
133  util::Timer timer(classname(), "norm");
134  double zz = aux_->norm();
135  Log::trace() << "ModelAuxControl<MODEL>::norm done" << std::endl;
136  return zz;
137 }
138 
139 // -----------------------------------------------------------------------------
140 
141 template<typename MODEL>
142 void ModelAuxControl<MODEL>::print(std::ostream & os) const {
143  Log::trace() << "ModelAuxControl<MODEL>::print starting" << std::endl;
144  util::Timer timer(classname(), "print");
145  os << *aux_;
146  Log::trace() << "ModelAuxControl<MODEL>::print done" << std::endl;
147 }
148 
149 // -----------------------------------------------------------------------------
150 
151 } // namespace oops
152 
153 #endif // OOPS_INTERFACE_MODELAUXCONTROL_H_
ModelAuxControl(const Geometry_ &, const eckit::Configuration &)
MODEL::ModelAuxControl ModelAuxControl_
subroutine, public copy(self, rhs)
void read(const eckit::Configuration &)
I/O and diagnostics.
Definition: conf.py:1
void write(const eckit::Configuration &) const
The namespace for the main oops code.
boost::scoped_ptr< ModelAuxControl_ > aux_
ModelAuxControl & operator=(const ModelAuxControl &)
const ModelAuxControl_ & modelauxcontrol() const
Interfacing.
const Geometry_ & geometry() const
Interfacing.
void print(std::ostream &) const
static const std::string classname()