FV3 Bundle
LinearModelId.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_GENERIC_LINEARMODELID_H_
12 #define OOPS_GENERIC_LINEARMODELID_H_
13 
14 #include <string>
15 #include <vector>
16 
18 #include "oops/base/Variables.h"
23 #include "oops/interface/State.h"
24 #include "oops/util/Duration.h"
25 #include "oops/util/Logger.h"
26 #include "oops/util/ObjectCounter.h"
27 #include "oops/util/Printable.h"
28 #include "oops/util/Timer.h"
29 
30 namespace eckit {
31  class Configuration;
32 }
33 
34 namespace oops {
35 
36 /// Encapsulates the linear forecast model.
37 /*!
38  * Generic implementation of the identity linear model.
39  */
40 
41 // -----------------------------------------------------------------------------
42 
43 template <typename MODEL>
44 class LinearModelId : public LinearModelBase<MODEL> {
45  typedef typename MODEL::Increment Increment_;
46  typedef typename MODEL::Geometry Geometry_;
47  typedef typename MODEL::ModelAuxControl ModelAux_;
48  typedef typename MODEL::ModelAuxIncrement ModelAuxIncr_;
49  typedef typename MODEL::State State_;
50 
51  public:
52  static const std::string classname() {return "oops::LinearModelId";}
53 
54  LinearModelId(const Geometry_ &, const eckit::Configuration &);
56 
57 // Set the linearization trajectory
58  void setTrajectory(const State_ &, State_ &, const ModelAux_ &) override;
59 
60 // Run the TL forecast
61  void initializeTL(Increment_ &) const override;
62  void stepTL(Increment_ & dx, const ModelAuxIncr_ &) const override;
63  void finalizeTL(Increment_ &) const override;
64 
65 // Run the AD forecast:
66  void initializeAD(Increment_ &) const override;
67  void stepAD(Increment_ & dx, ModelAuxIncr_ &) const override;
68  void finalizeAD(Increment_ &) const override;
69 
70 // Information and diagnostics
71  const util::Duration & timeResolution() const override {return tstep_;}
72  const oops::Variables & variables() const override {return vars_;}
73  void print(std::ostream &) const override {}
74 
75  private:
77  const util::Duration tstep_;
79 };
80 
81 // =============================================================================
82 
83 template<typename MODEL>
84 LinearModelId<MODEL>::LinearModelId(const Geometry_ & resol, const eckit::Configuration & tlConf)
85  : resol_(resol), tstep_(util::Duration(tlConf.getString("tstep"))),
86  vars_(std::vector<std::string>{""})
87 {
88  Log::trace() << "LinearModelId<MODEL>::LinearModelId done" << std::endl;
89 }
90 
91 // -----------------------------------------------------------------------------
92 
93 template<typename MODEL>
95  Log::trace() << "LinearModelId<MODEL>::~LinearModelId done" << std::endl;
96 }
97 
98 // -----------------------------------------------------------------------------
99 
100 template<typename MODEL>
102  const ModelAux_ & maux) {
103  Log::trace() << "LinearModelId<MODEL>::setTrajectory not set for identity model" << std::endl;
104 }
105 
106 // -----------------------------------------------------------------------------
107 
108 template<typename MODEL>
110  Log::info() << "LinearModelId<MODEL>:initializeTL Starting " << std::endl;
111  Log::trace() << "LinearModelId<MODEL>::initializeTL done" << std::endl;
112 }
113 
114 // -----------------------------------------------------------------------------
115 
116 template<typename MODEL>
117 void LinearModelId<MODEL>::stepTL(Increment_ & dx, const ModelAuxIncr_ & merr) const {
118  Log::info() << "LinearModelId<MODEL>:stepTL Starting " << std::endl;
119  dx.updateTime(tstep_);
120  Log::trace() << "LinearModelId<MODEL>::stepTL done" << std::endl;
121 }
122 
123 // -----------------------------------------------------------------------------
124 
125 template<typename MODEL>
127  Log::info() << "LinearModelId<MODEL>:finalizeTL Starting " << std::endl;
128  Log::trace() << "LinearModelId<MODEL>::finalizeTL done" << std::endl;
129 }
130 
131 // -----------------------------------------------------------------------------
132 
133 template<typename MODEL>
135  Log::info() << "LinearModelId<MODEL>:initializeAD Starting " << std::endl;
136  Log::trace() << "LinearModelId<MODEL>::initializeAD done" << std::endl;
137 }
138 
139 // -----------------------------------------------------------------------------
140 
141 template<typename MODEL>
143  Log::info() << "LinearModelId<MODEL>:stepAD Starting " << std::endl;
144  dx.updateTime(-tstep_);
145  Log::trace() << "LinearModelId<MODEL>::stepAD done" << std::endl;
146 }
147 
148 // -----------------------------------------------------------------------------
149 
150 template<typename MODEL>
152  Log::info() << "LinearModelId<MODEL>:finalizeAD Starting " << std::endl;
153  Log::trace() << "LinearModelId<MODEL>::finalizeAD done" << std::endl;
154 }
155 
156 // -----------------------------------------------------------------------------
157 } // namespace oops
158 
159 #endif // OOPS_GENERIC_LINEARMODELID_H_
MODEL::Geometry Geometry_
Definition: LinearModelId.h:46
MODEL::Increment Increment_
Definition: LinearModelId.h:45
MODEL::ModelAuxControl ModelAux_
Definition: LinearModelId.h:47
const Variables vars_
Definition: LinearModelId.h:78
const Geometry_ resol_
Definition: LinearModelId.h:76
void finalizeTL(Increment_ &) const override
const oops::Variables & variables() const override
Definition: LinearModelId.h:72
subroutine std(a, mean, stdv, area)
void setTrajectory(const State_ &, State_ &, const ModelAux_ &) override
Encapsulates the linear forecast model.
Definition: LinearModelId.h:44
void initializeTL(Increment_ &) const override
Encapsulates the model state.
void stepTL(Increment_ &dx, const ModelAuxIncr_ &) const override
MODEL::ModelAuxIncrement ModelAuxIncr_
Definition: LinearModelId.h:48
void updateTime(const util::Duration &dt)
The namespace for the main oops code.
MODEL::State State_
Definition: LinearModelId.h:49
subroutine, public info(self)
Base class for encapsulation of the linear forecast model.
const util::Duration & timeResolution() const override
Definition: LinearModelId.h:71
void stepAD(Increment_ &dx, ModelAuxIncr_ &) const override
Increment Class: Difference between two states.
static const std::string classname()
Definition: LinearModelId.h:52
void print(std::ostream &) const override
Definition: LinearModelId.h:73
const util::Duration tstep_
Definition: LinearModelId.h:77
void initializeAD(Increment_ &) const override
void finalizeAD(Increment_ &) const override
LinearModelId(const Geometry_ &, const eckit::Configuration &)
Definition: LinearModelId.h:84