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