OOPS
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/mpi/mpi.h"
25 #include "oops/runs/Application.h"
26 #include "oops/util/DateTime.h"
27 #include "oops/util/Duration.h"
28 #include "oops/util/Logger.h"
29 
30 namespace oops {
31 
32 template <typename MODEL> class Forecast : public Application {
37 
38  public:
39 // -----------------------------------------------------------------------------
40  explicit Forecast(const eckit::mpi::Comm & comm = oops::mpi::world()) : Application(comm) {}
41 // -----------------------------------------------------------------------------
42  virtual ~Forecast() {}
43 // -----------------------------------------------------------------------------
44  int execute(const eckit::Configuration & fullConfig) const {
45 // Setup resolution
46  const eckit::LocalConfiguration resolConfig(fullConfig, "geometry");
47  const Geometry_ resol(resolConfig, this->getComm());
48 
49 // Setup Model
50  const eckit::LocalConfiguration modelConfig(fullConfig, "model");
51  const Model_ model(resol, modelConfig);
52 
53 // Setup initial state
54  const eckit::LocalConfiguration initialConfig(fullConfig, "initial condition");
55  State_ xx(resol, initialConfig);
56  Log::test() << "Initial state: " << xx << std::endl;
57 
58 // Setup augmented state
59  const ModelAux_ moderr(resol, fullConfig.getSubConfiguration("model aux control"));
60 
61 // Setup times
62  const util::Duration fclength(fullConfig.getString("forecast length"));
63  const util::DateTime bgndate(xx.validTime());
64  const util::DateTime enddate(bgndate + fclength);
65  Log::info() << "Running forecast from " << bgndate << " to " << enddate << std::endl;
66 
67 // Setup forecast outputs
69 
70  eckit::LocalConfiguration prtConfig;
71  if (fullConfig.has("prints")) {
72  prtConfig = eckit::LocalConfiguration(fullConfig, "prints");
73  }
74  post.enrollProcessor(new StateInfo<State_>("fc", prtConfig));
75 
76  const eckit::LocalConfiguration outConfig(fullConfig, "output");
77  post.enrollProcessor(new StateWriter<State_>(outConfig));
78 
79 // Run forecast
80  model.forecast(xx, moderr, fclength, post);
81 
82  Log::test() << "Final state: " << xx << std::endl;
83 
84  return 0;
85  }
86 // -----------------------------------------------------------------------------
87  private:
88  std::string appname() const {
89  return "oops::Forecast<" + MODEL::name() + ">";
90  }
91 // -----------------------------------------------------------------------------
92 };
93 
94 } // namespace oops
95 #endif // OOPS_RUNS_FORECAST_H_
oops::Forecast::~Forecast
virtual ~Forecast()
Definition: Forecast.h:42
oops::State::validTime
const util::DateTime validTime() const
Time.
Definition: oops/interface/State.h:60
oops
The namespace for the main oops code.
Definition: ErrorCovarianceL95.cc:22
oops::Forecast::Model_
Model< MODEL > Model_
Definition: Forecast.h:34
mpi.h
model
Definition: l95/defaults/model.py:1
oops::Forecast::ModelAux_
ModelAuxControl< MODEL > ModelAux_
Definition: Forecast.h:35
oops::ModelAuxControl
Definition: oops/interface/ModelAuxControl.h:35
oops::Forecast::Geometry_
Geometry< MODEL > Geometry_
Definition: Forecast.h:33
oops::StateWriter
Handles writing-out of forecast fields.
Definition: StateWriter.h:26
oops::Forecast::appname
std::string appname() const
Definition: Forecast.h:88
oops::Forecast
Definition: Forecast.h:32
oops::PostProcessor::enrollProcessor
void enrollProcessor(PostBase_ *pp)
Definition: PostProcessor.h:38
Application.h
oops::Application::getComm
const eckit::mpi::Comm & getComm() const
Definition: Application.h:36
PostProcessor.h
oops::StateInfo
Handles writing-out of forecast fields.
Definition: StateInfo.h:28
oops::Geometry
Geometry class used in oops; subclass of interface class above.
Definition: oops/interface/Geometry.h:189
Model.h
oops::Forecast::Forecast
Forecast(const eckit::mpi::Comm &comm=oops::mpi::world())
Definition: Forecast.h:40
StateInfo.h
oops::State
Encapsulates the model state.
Definition: CostJbState.h:28
oops::Application
Definition: Application.h:29
oops::PostProcessor
Control model post processing.
Definition: PostProcessor.h:30
oops::Forecast::State_
State< MODEL > State_
Definition: Forecast.h:36
State.h
oops::mpi::world
const eckit::mpi::Comm & world()
Default communicator with all MPI tasks (ie MPI_COMM_WORLD)
Definition: oops/mpi/mpi.cc:22
StateWriter.h
oops::Forecast::execute
int execute(const eckit::Configuration &fullConfig) const
Definition: Forecast.h:44
oops::Model
Encapsulates the nonlinear forecast model Note: to see methods that need to be implemented in the for...
Definition: oops/interface/Model.h:54
ModelAuxControl.h
Geometry.h