IODA Bundle
GetValuePosts.h
Go to the documentation of this file.
1 /*
2  * (C) Copyright 2021-2021 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_BASE_GETVALUEPOSTS_H_
9 #define OOPS_BASE_GETVALUEPOSTS_H_
10 
11 #include <algorithm>
12 #include <memory>
13 #include <string>
14 #include <utility>
15 #include <vector>
16 
17 #include "oops/base/GetValuePost.h"
18 #include "oops/base/PostBase.h"
19 #include "oops/base/State.h"
21 #include "oops/util/DateTime.h"
22 #include "oops/util/Duration.h"
23 #include "oops/util/Logger.h"
24 
25 namespace oops {
26 
27 /// \brief Fills GeoVaLs with requested variables at requested locations during model run
28 template <typename MODEL, typename OBS>
29 class GetValuePosts : public PostBase<State<MODEL>> {
32  typedef std::shared_ptr<GetValuePost<MODEL, OBS>> GetValuePtr_;
33 
34  public:
35 /// \brief Saves Locations and Variables to be processed
36  GetValuePosts();
37 
38  void append(GetValuePtr_);
39 
40  private:
41 /// \brief initialization before model run: sets up GetValues and allocate GeoVaLs
42  void doInitialize(const State_ &, const util::DateTime &, const util::Duration &) override;
43 /// \brief called at each model step: fill in GeoVaLs for the current time slot
44  void doProcessing(const State_ &) override;
45 
46 // Data
47  std::vector<GetValuePtr_> getvals_;
48 };
49 
50 // -----------------------------------------------------------------------------
51 
52 template <typename MODEL, typename OBS>
54  Log::trace() << "GetValuePosts::GetValuePosts" << std::endl;
55 }
56 
57 // -----------------------------------------------------------------------------
58 
59 template <typename MODEL, typename OBS>
61  Log::trace() << "GetValuePosts::append start" << std::endl;
62  getvals_.push_back(getval);
63  Log::trace() << "GetValuePosts::append done" << std::endl;
64 }
65 
66 // -----------------------------------------------------------------------------
67 
68 template <typename MODEL, typename OBS>
69 void GetValuePosts<MODEL, OBS>::doInitialize(const State_ &, const util::DateTime &,
70  const util::Duration & tstep) {
71  Log::trace() << "GetValuePosts::doInitialize start" << std::endl;
72  for (GetValuePtr_ getval : getvals_) getval->initialize(tstep);
73  Log::trace() << "GetValuePosts::doInitialize done" << std::endl;
74 }
75 
76 // -----------------------------------------------------------------------------
77 
78 template <typename MODEL, typename OBS>
80  Log::trace() << "GetValuePosts::doProcessing start" << std::endl;
81 // Change of variables will go here
82  for (GetValuePtr_ getval : getvals_) getval->process(xx);
83  Log::trace() << "GetValuePosts::doProcessing done" << std::endl;
84 }
85 
86 // -----------------------------------------------------------------------------
87 
88 } // namespace oops
89 
90 #endif // OOPS_BASE_GETVALUEPOSTS_H_
Encapsulates the nonlinear variable change There should not be a factory for ChangeVariable,...
Fills GeoVaLs with requested variables at requested locations during model run.
Definition: GetValuePosts.h:29
ChangeVariables< MODEL > ChangeVariables_
Definition: GetValuePosts.h:30
std::vector< GetValuePtr_ > getvals_
Definition: GetValuePosts.h:47
void doInitialize(const State_ &, const util::DateTime &, const util::Duration &) override
initialization before model run: sets up GetValues and allocate GeoVaLs
Definition: GetValuePosts.h:69
State< MODEL > State_
Definition: GetValuePosts.h:31
void append(GetValuePtr_)
Definition: GetValuePosts.h:60
std::shared_ptr< GetValuePost< MODEL, OBS > > GetValuePtr_
Definition: GetValuePosts.h:32
GetValuePosts()
Saves Locations and Variables to be processed.
Definition: GetValuePosts.h:53
void doProcessing(const State_ &) override
called at each model step: fill in GeoVaLs for the current time slot
Definition: GetValuePosts.h:79
Handles post-processing of model fields.
Definition: PostBase.h:33
State class used in oops; subclass of interface class interface::State.
The namespace for the main oops code.