FV3 Bundle
HofX.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_RUNS_HOFX_H_
12 #define OOPS_RUNS_HOFX_H_
13 
14 #include <string>
15 
16 #include <boost/scoped_ptr.hpp>
17 #include <boost/shared_ptr.hpp>
18 
19 #include "eckit/config/LocalConfiguration.h"
21 #include "oops/base/Observations.h"
22 #include "oops/base/Observer.h"
23 #include "oops/base/ObsFilters.h"
24 #include "oops/base/ObsOperators.h"
25 #include "oops/base/ObsSpaces.h"
27 #include "oops/base/StateInfo.h"
29 #include "oops/interface/Model.h"
32 #include "oops/interface/State.h"
33 #include "oops/runs/Application.h"
34 #include "oops/util/DateTime.h"
35 #include "oops/util/Duration.h"
36 #include "oops/util/Logger.h"
37 
38 namespace oops {
39 
40 template <typename MODEL> class HofX : public Application {
50 
51  public:
52 // -----------------------------------------------------------------------------
53  HofX() {
54  instantiateFilterFactory<MODEL>();
55  }
56 // -----------------------------------------------------------------------------
57  virtual ~HofX() {}
58 // -----------------------------------------------------------------------------
59  int execute(const eckit::Configuration & fullConfig) const {
60 // Setup observation window
61  const eckit::LocalConfiguration windowConf(fullConfig, "Assimilation Window");
62  const util::Duration winlen(windowConf.getString("Length"));
63  const util::DateTime winbgn(windowConf.getString("Begin"));
64  const util::DateTime winend(winbgn + winlen);
65  Log::info() << "Observation window is:" << windowConf << std::endl;
66 
67 // Setup resolution
68  const eckit::LocalConfiguration resolConfig(fullConfig, "Geometry");
69  const Geometry_ resol(resolConfig);
70 
71 // Setup Model
72  const eckit::LocalConfiguration modelConfig(fullConfig, "Model");
73  const Model_ model(resol, modelConfig);
74 
75 // Setup initial state
76  const eckit::LocalConfiguration initialConfig(fullConfig, "Initial Condition");
77  Log::info() << "Initial configuration is:" << initialConfig << std::endl;
78  State_ xx(resol, model.variables(), initialConfig);
79  Log::test() << "Initial state: " << xx << std::endl;
80 
81 // Setup augmented state
82  ModelAux_ moderr(resol, initialConfig);
83 
84 // Setup forecast outputs
86 
87  eckit::LocalConfiguration prtConf;
88  fullConfig.get("Prints", prtConf);
89  post.enrollProcessor(new StateInfo<State_>("fc", prtConf));
90 
91 // Setup observations
92  eckit::LocalConfiguration biasConf;
93  fullConfig.get("ObsBias", biasConf);
94  ObsAuxCtrl_ ybias(biasConf);
95 
96 // Setup observations
97  eckit::LocalConfiguration obsconf(fullConfig, "Observations");
98  Log::debug() << "Observations configuration is:" << obsconf << std::endl;
99  ObsSpace_ obsdb(obsconf, winbgn, winend);
100  ObsOperator_ hop(obsdb);
101 
102 // Setup QC filters
103  eckit::LocalConfiguration filterConf;
104  obsconf.get("ObsFilters", filterConf);
105  ObsFilters_ filter(obsdb, obsconf);
106 
107 // Setup Observer
108  boost::shared_ptr<Observer<MODEL, State_> >
109  pobs(new Observer<MODEL, State_>(obsdb, hop, ybias, filter));
110  post.enrollProcessor(pobs);
111 
112 // Compute H(x)
113  model.forecast(xx, moderr, winlen, post);
114  Log::info() << "HofX: Finished observation computation." << std::endl;
115  Log::test() << "Final state: " << xx << std::endl;
116 
117 // Save H(x)
118  boost::scoped_ptr<Observations_> yobs(pobs->release());
119  Log::test() << "H(x): " << *yobs << std::endl;
120  yobs->save("hofx");
121 
122  return 0;
123  }
124 // -----------------------------------------------------------------------------
125  private:
126  std::string appname() const {
127  return "oops::HofX<" + MODEL::name() + ">";
128  }
129 // -----------------------------------------------------------------------------
130 };
131 
132 } // namespace oops
133 
134 #endif // OOPS_RUNS_HOFX_H_
std::string appname() const
Definition: HofX.h:126
Geometry< MODEL > Geometry_
Definition: HofX.h:41
State< MODEL > State_
Definition: HofX.h:49
Model< MODEL > Model_
Definition: HofX.h:42
Observations< MODEL > Observations_
Definition: HofX.h:45
Encapsulates the model state.
Observations Class.
Definition: Observations.h:36
program test
virtual ~HofX()
Definition: HofX.h:57
character(len=32) name
The namespace for the main oops code.
ObsAuxControl< MODEL > ObsAuxCtrl_
Definition: HofX.h:44
ModelAuxControl< MODEL > ModelAux_
Definition: HofX.h:43
logical debug
Definition: mpp.F90:1297
ObsSpaces< MODEL > ObsSpace_
Definition: HofX.h:48
Handles writing-out of forecast fields.
Definition: StateInfo.h:28
subroutine, public info(self)
int execute(const eckit::Configuration &fullConfig) const
Definition: HofX.h:59
HofX()
Definition: HofX.h:53
Encapsulates the nonlinear forecast model.
ObsOperators< MODEL > ObsOperator_
Definition: HofX.h:47
Computes observation equivalent during model run.
Definition: Observer.h:43
Control model post processing.
Definition: PostProcessor.h:31
ObsFilters< MODEL > ObsFilters_
Definition: HofX.h:46
void enrollProcessor(PostBase_ *pp)
Definition: PostProcessor.h:39