OOPS
TLML95.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 LORENZ95_TLML95_H_
12 #define LORENZ95_TLML95_H_
13 
14 #include <map>
15 #include <ostream>
16 #include <string>
17 
18 #include <boost/noncopyable.hpp>
19 
20 #include "oops/base/Variables.h"
22 #include "oops/util/Duration.h"
23 #include "oops/util/ObjectCounter.h"
24 #include "oops/util/Printable.h"
25 
26 #include "lorenz95/L95Traits.h"
27 #include "lorenz95/ModelL95.h"
28 
29 // Forward declarations
30 namespace eckit {
31  class Configuration;
32 }
33 
34 namespace util {
35  class DateTime;
36 }
37 
38 namespace lorenz95 {
39  class FieldL95;
40 
41 // -----------------------------------------------------------------------------
42 
44  OOPS_CONCRETE_PARAMETERS(TLML95Parameters, LinearModelParametersBase)
45 
46  public:
47  oops::RequiredParameter<util::Duration> tstep{"tstep", this};
48  oops::RequiredParameter<ModelL95Parameters> trajectory{"trajectory", this};
49  // wsmigaj: This option in present in YAML files used in tests, but it isn't used either in
50  // TLML95 or on the oops::LinearModel interface. Leaving it in place in case it turns out it is
51  // used by some other fragment of code that loads the configuration of the linear model.
52  oops::OptionalParameter<std::string> variableChange{"variable change", this};
53 };
54 
55 // -----------------------------------------------------------------------------
56 /// Lorenz 95 linear model definition.
57 
58 class TLML95: public oops::interface::LinearModelBase<L95Traits>,
59  private util::ObjectCounter<TLML95> {
60  public:
62 
63  static const std::string classname() {return "lorenz95::TLML95";}
64 
65  TLML95(const Resolution &, const Parameters_ &);
66  ~TLML95();
67 
68 /// Model trajectory computation
69  void setTrajectory(const StateL95 &, StateL95 &, const ModelBias &) override;
70 
71 /// Run TLM and its adjoint
72  void initializeTL(IncrementL95 &) const override;
73  void stepTL(IncrementL95 &, const ModelBiasCorrection &) const override;
74  void finalizeTL(IncrementL95 &) const override;
75 
76  void initializeAD(IncrementL95 &) const override;
77  void stepAD(IncrementL95 &, ModelBiasCorrection &) const override;
78  void finalizeAD(IncrementL95 &) const override;
79 
80 /// Other utilities
81  const util::Duration & timeResolution() const override {return tstep_;}
82  const oops::Variables & variables() const override {return vars_;}
83 
84  private:
85  const ModelTrajectory * getTrajectory(const util::DateTime &) const;
86  void tendenciesTL(const FieldL95 &, const double &, const FieldL95 &, FieldL95 &) const;
87  void tendenciesAD(FieldL95 &, double &, const FieldL95 &, const FieldL95 &) const;
88  void print(std::ostream &) const override;
89 
90  typedef std::map< util::DateTime, ModelTrajectory * >::iterator trajIter;
91  typedef std::map< util::DateTime, ModelTrajectory * >::const_iterator trajICst;
92 
93 // Data
95  const util::Duration tstep_;
96  const double dt_;
97  std::map< util::DateTime, ModelTrajectory * > traj_;
100 };
101 
102 // -----------------------------------------------------------------------------
103 
104 } // namespace lorenz95
105 
106 #endif // LORENZ95_TLML95_H_
Class to represent fields for the L95 model.
Definition: FieldL95.h:34
Increment Class: Difference between two states.
Definition: IncrementL95.h:58
Model error for Lorenz 95 model.
Lorenz 95 model configuration and computations.
Definition: ModelL95.h:51
L95 model trajectory.
Handles resolution.
Definition: Resolution.h:43
L95 model state.
Definition: StateL95.h:53
Lorenz 95 linear model definition.
Definition: TLML95.h:59
const ModelTrajectory * getTrajectory(const util::DateTime &) const
Definition: TLML95.cc:62
void setTrajectory(const StateL95 &, StateL95 &, const ModelBias &) override
Model trajectory computation.
Definition: TLML95.cc:53
std::map< util::DateTime, ModelTrajectory * > traj_
Definition: TLML95.h:97
const Resolution resol_
Definition: TLML95.h:94
static const std::string classname()
Definition: TLML95.h:63
TLML95Parameters Parameters_
Definition: TLML95.h:61
void stepTL(IncrementL95 &, const ModelBiasCorrection &) const override
Definition: TLML95.cc:78
void print(std::ostream &) const override
Print, used in logging.
Definition: TLML95.cc:188
void initializeAD(IncrementL95 &) const override
Definition: TLML95.cc:75
void finalizeAD(IncrementL95 &) const override
Definition: TLML95.cc:76
void stepAD(IncrementL95 &, ModelBiasCorrection &) const override
Definition: TLML95.cc:108
const oops::Variables vars_
Definition: TLML95.h:99
const util::Duration & timeResolution() const override
Other utilities.
Definition: TLML95.h:81
void initializeTL(IncrementL95 &) const override
Run TLM and its adjoint.
Definition: TLML95.cc:73
void tendenciesTL(const FieldL95 &, const double &, const FieldL95 &, FieldL95 &) const
Definition: TLML95.cc:147
void tendenciesAD(FieldL95 &, double &, const FieldL95 &, const FieldL95 &) const
Definition: TLML95.cc:164
const util::Duration tstep_
Definition: TLML95.h:95
const oops::Variables & variables() const override
LinearModel variables (only used in 4DVar)
Definition: TLML95.h:82
std::map< util::DateTime, ModelTrajectory * >::const_iterator trajICst
Definition: TLML95.h:91
const ModelL95 lrmodel_
Definition: TLML95.h:98
TLML95(const Resolution &, const Parameters_ &)
Definition: TLML95.cc:36
std::map< util::DateTime, ModelTrajectory * >::iterator trajIter
Definition: TLML95.h:90
void finalizeTL(IncrementL95 &) const override
Definition: TLML95.cc:74
const double dt_
Definition: TLML95.h:96
oops::RequiredParameter< ModelL95Parameters > trajectory
Definition: TLML95.h:48
oops::RequiredParameter< util::Duration > tstep
Definition: TLML95.h:47
oops::OptionalParameter< std::string > variableChange
Definition: TLML95.h:52
Base class for classes storing linear model-specific parameters.
Base class for MODEL-specific implementations of the LinearModel interface. interface::LinearModelBas...
Definition: FieldL95.h:22
The namespace for the L95 model.
Definition: TLML95.h:34