FV3 Bundle
EnsForecasts.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_ENSFORECASTS_H_
12 #define OOPS_RUNS_ENSFORECASTS_H_
13 
14 #include <string>
15 
16 #include "eckit/config/Configuration.h"
18 #include "oops/base/StateInfo.h"
19 #include "oops/base/StateWriter.h"
21 #include "oops/interface/Model.h"
23 #include "oops/interface/State.h"
24 #include "oops/runs/Application.h"
25 #include "oops/util/DateTime.h"
26 #include "oops/util/Duration.h"
27 #include "oops/util/Logger.h"
28 
29 namespace oops {
30 
31 template <typename MODEL> class EnsForecast : public Application {
36 
37  public:
38 // -----------------------------------------------------------------------------
40 // -----------------------------------------------------------------------------
41  virtual ~EnsForecast() {}
42 // -----------------------------------------------------------------------------
43  int execute(const eckit::Configuration & fullConfig) const {
44 // Setup resolution
45  const eckit::Configuration resolConfig(fullConfig, "resolution");
46  const Geometry_ resol(resolConfig);
47 
48 // Setup Model
49  const eckit::Configuration modelConfig(fullConfig, "model");
50  const Model_ model(resol, modelConfig);
51 
52  unsigned nm = config.getElementSize("member");
53  for (unsigned jj = 0; jj < nm; ++jj) {
54 // Setup initial state
55  const eckit::Configuration initialConfig(fullConfig, "member", jj);
56  State_ xx(resol, model.variables(), initialConfig);
57  Log::test() << "Initial state: " << xx << std::endl;
58 
59 // Setup augmented state
60  const ModelAux_ moderr(initialConfig);
61 
62 // Setup times
63  const util::Duration fclength(fullConfig.getString("forecast_length"));
64  const util::DateTime bgndate(xx.validTime());
65  const util::DateTime enddate(bgndate + fclength);
66  Log::info() << "Running forecast " << jj << " from " << bgndate
67  << " to " << enddate << std::endl;
68 
69 // Setup forecast outputs
71 
72  const eckit::Configuration prtConfig(fullConfig, "prints", true);
73  post.enrollProcessor(new StateInfo<State_>("fc", prtConfig));
74 
75  const eckit::Configuration outConfig(fullConfig, "output");
76  post.enrollProcessor(new StateWriter<State_>(bgndate, outConfig));
77 
78 // Run forecast
79  model.forecast(xx, moderr, fclength, post);
80 
81  Log::test() << "Final state " << jj << " : " << xx << std::endl;
82  }
83  return 0;
84  }
85 // -----------------------------------------------------------------------------
86  private:
87  std::string appname() const {
88  return "oops::EnsForecast<" + MODEL::name() + ">";
89  }
90 // -----------------------------------------------------------------------------
91 };
92 
93 } // namespace oops
94 #endif // OOPS_RUNS_ENSFORECASTS_H_
Geometry< MODEL > Geometry_
Definition: EnsForecasts.h:32
Handles writing-out of forecast fields.
Definition: StateWriter.h:26
State< MODEL > State_
Definition: EnsForecasts.h:35
virtual ~EnsForecast()
Definition: EnsForecasts.h:41
Encapsulates the model state.
program test
character(len=32) name
The namespace for the main oops code.
Handles writing-out of forecast fields.
Definition: StateInfo.h:28
subroutine, public info(self)
Encapsulates the nonlinear forecast model.
Model< MODEL > Model_
Definition: EnsForecasts.h:33
ModelAuxControl< MODEL > ModelAux_
Definition: EnsForecasts.h:34
Control model post processing.
Definition: PostProcessor.h:31
int execute(const eckit::Configuration &fullConfig) const
Definition: EnsForecasts.h:43
void enrollProcessor(PostBase_ *pp)
Definition: PostProcessor.h:39
std::string appname() const
Definition: EnsForecasts.h:87