SOCA
CheckpointModel.h
Go to the documentation of this file.
1 /*
2  * (C) Copyright 2017-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 MAINS_CHECKPOINTMODEL_H_
9 #define MAINS_CHECKPOINTMODEL_H_
10 
11 #include <string>
12 
13 #include "soca/Traits.h"
14 
15 #include "soca/Geometry/Geometry.h"
16 #include "soca/Model/Model.h"
17 #include "soca/State/State.h"
18 
19 #include "eckit/config/LocalConfiguration.h"
20 #include "oops/base/PostProcessor.h"
21 #include "oops/mpi/mpi.h"
22 #include "oops/runs/Application.h"
23 #include "oops/util/DateTime.h"
24 #include "oops/util/Duration.h"
25 #include "oops/util/Logger.h"
26 
27 namespace soca {
28 
29  class CheckpointModel : public oops::Application {
30  public:
31  explicit CheckpointModel(const eckit::mpi::Comm & comm = oops::mpi::world())
32  : Application(comm) {}
33  static const std::string classname() {return "soca::CheckpointModel";}
34 
35  int execute(const eckit::Configuration & fullConfig) const {
36  // Setup resolution
37  const eckit::LocalConfiguration resolConfig(fullConfig, "resolution");
38  const Geometry resol(resolConfig, this->getComm());
39 
40  // Setup Model
41  const eckit::LocalConfiguration modelConfig(fullConfig, "model");
42  const Model model(resol, modelConfig);
43 
44  // Setup state to write in the restart
45  const eckit::LocalConfiguration backgroundConfig(fullConfig,
46  "background");
47  State xb(resol, backgroundConfig);
48  oops::Log::test() << "input background: " << std::endl << xb << std::endl;
49 
50  // Setup state to write in the restart
51  const eckit::LocalConfiguration analysisConfig(fullConfig, "analysis");
52  State xa(resol, analysisConfig);
53  oops::Log::test() << "analysis: " << std::endl << xa << std::endl;
54 
55  // Initialize model
56  model.initialize(xb);
57 
58  // Set background to analysis
59  xb = xa;
60 
61  // Finalize model (dump restart)
62  model.finalize(xb);
63 
64  oops::Log::test() << "output background: " << std::endl << xb
65  << std::endl;
66 
67  return 0;
68  }
69  // -----------------------------------------------------------------------------
70  private:
71  std::string appname() const {
72  return "soca::CheckpointModel<";
73  }
74  // -----------------------------------------------------------------------------
75  };
76 
77 } // namespace soca
78 #endif // MAINS_CHECKPOINTMODEL_H_
std::string appname() const
int execute(const eckit::Configuration &fullConfig) const
static const std::string classname()
CheckpointModel(const eckit::mpi::Comm &comm=oops::mpi::world())
Geometry handles geometry for SOCA model.
Definition: Geometry.h:48
SOCA model definition.
Definition: Model.h:48
void finalize(State &) const
Finish model integration.
Definition: Model.cc:69
void initialize(State &) const
Prepare model integration.
Definition: Model.cc:57
SOCA model state.
Definition: State.h:48