OOPS
PseudoModel.h
Go to the documentation of this file.
1 /*
2  * (C) Copyright 2018-2020 UCAR.
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  */
7 
8 #ifndef OOPS_GENERIC_PSEUDOMODEL_H_
9 #define OOPS_GENERIC_PSEUDOMODEL_H_
10 
11 #include <string>
12 #include <vector>
13 
14 #include "oops/base/Geometry.h"
15 #include "oops/base/State.h"
16 #include "oops/generic/ModelBase.h"
18 #include "oops/util/Duration.h"
19 #include "oops/util/Logger.h"
20 
21 namespace eckit {
22  class Configuration;
23 }
24 
25 namespace oops {
26 
27 /// Generic implementation of the pseudo model (steps through time by reading states)
28 template <typename MODEL>
29 class PseudoModel : public ModelBase<MODEL> {
33 
34  public:
35  static const std::string classname() {return "oops::PseudoModel";}
36 
37  PseudoModel(const Geometry_ &, const eckit::Configuration &);
38 
39 /// initialize forecast
40  void initialize(State_ &) const override;
41 /// one forecast step
42  void step(State_ &, const ModelAux_ &) const override;
43 /// finalize forecast
44  void finalize(State_ &) const override;
45 
46 /// model time step
47  const util::Duration & timeResolution() const override {return tstep_;}
48 
49 /// model variables
50  const oops::Variables & variables() const override {return vars_;}
51 
52  private:
53  void print(std::ostream &) const override;
54  const util::Duration tstep_;
56  std::vector<eckit::LocalConfiguration> confs_;
57  mutable size_t currentstate_;
58 };
59 
60 // -----------------------------------------------------------------------------
61 
62 template<typename MODEL>
63 PseudoModel<MODEL>::PseudoModel(const Geometry_ & resol, const eckit::Configuration & conf)
64  : tstep_(util::Duration(conf.getString("tstep"))), vars_(conf, "state variables"),
65  confs_(conf.getSubConfigurations("states")),
66  currentstate_(0) {
67  Log::trace() << "PseudoModel<MODEL>::PseudoModel done" << std::endl;
68 }
69 
70 // -----------------------------------------------------------------------------
71 
72 template<typename MODEL>
74  currentstate_ = 0;
75  Log::trace() << "PseudoModel<MODEL>::initialize done" << std::endl;
76 }
77 
78 // -----------------------------------------------------------------------------
79 
80 template<typename MODEL>
81 void PseudoModel<MODEL>::step(State_ & xx, const ModelAux_ & merr) const {
82  Log::trace() << "PseudoModel<MODEL>:step Starting " << std::endl;
83  xx.updateTime(tstep_);
84  xx.read(confs_[currentstate_++]);
85  Log::trace() << "PseudoModel<MODEL>::step done" << std::endl;
86 }
87 
88 // -----------------------------------------------------------------------------
89 
90 template<typename MODEL>
92  Log::trace() << "PseudoModel<MODEL>::finalize done" << std::endl;
93 }
94 
95 // -----------------------------------------------------------------------------
96 
97 template<typename MODEL>
98 void PseudoModel<MODEL>::print(std::ostream & os) const {
99  os << "Pseudo model reading states from files with " << tstep_ << " time resolution";
100 }
101 
102 } // namespace oops
103 
104 #endif // OOPS_GENERIC_PSEUDOMODEL_H_
Geometry class used in oops; subclass of interface class interface::Geometry.
Auxiliary state related to model (could be e.g. model bias), not used at the moment.
Base class for generic implementations of the forecasting models. Use this class as a base class for ...
Generic implementation of the pseudo model (steps through time by reading states)
Definition: PseudoModel.h:29
const oops::Variables vars_
Definition: PseudoModel.h:55
void step(State_ &, const ModelAux_ &) const override
one forecast step
Definition: PseudoModel.h:81
std::vector< eckit::LocalConfiguration > confs_
Definition: PseudoModel.h:56
static const std::string classname()
Definition: PseudoModel.h:35
PseudoModel(const Geometry_ &, const eckit::Configuration &)
Definition: PseudoModel.h:63
State< MODEL > State_
Definition: PseudoModel.h:32
ModelAuxControl< MODEL > ModelAux_
Definition: PseudoModel.h:31
Geometry< MODEL > Geometry_
Definition: PseudoModel.h:30
void initialize(State_ &) const override
initialize forecast
Definition: PseudoModel.h:73
const oops::Variables & variables() const override
model variables
Definition: PseudoModel.h:50
const util::Duration tstep_
Definition: PseudoModel.h:54
size_t currentstate_
Definition: PseudoModel.h:57
const util::Duration & timeResolution() const override
model time step
Definition: PseudoModel.h:47
void finalize(State_ &) const override
finalize forecast
Definition: PseudoModel.h:91
void print(std::ostream &) const override
Print; used for logging.
Definition: PseudoModel.h:98
State class used in oops; subclass of interface class interface::State.
void updateTime(const util::Duration &dt)
Update this State's valid time by dt.
void read(const eckit::Configuration &)
Read this State from file.
Definition: FieldL95.h:22
The namespace for the main oops code.
Definition: TLML95.h:34