SOCA
Model.cc
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 #include <vector>
9 
10 #include "soca/Traits.h"
11 
12 #include "soca/Geometry/Geometry.h"
13 #include "soca/Model/Model.h"
16 #include "soca/State/State.h"
17 
18 #include "eckit/config/Configuration.h"
19 #include "eckit/exception/Exceptions.h"
20 
21 #include "oops/util/DateTime.h"
22 #include "oops/util/Logger.h"
23 
24 using oops::Log;
25 
26 namespace soca {
27  // -----------------------------------------------------------------------------
28  static oops::interface::ModelMaker<Traits, Model> makermodel_("SOCA");
29  // -----------------------------------------------------------------------------
30  Model::Model(const Geometry & resol, const eckit::Configuration & model)
31  : keyConfig_(0),
32  tstep_(0),
33  geom_(new Geometry(resol)),
34  vars_(model, "model variables"),
35  setup_mom6_(true)
36  {
37  Log::trace() << "Model::Model" << std::endl;
38  Log::trace() << "Model vars: " << vars_ << std::endl;
39  tstep_ = util::Duration(model.getString("tstep"));
40  setup_mom6_ = model.getBool("setup_mom6", true);
41  const eckit::Configuration * configc = &model;
42  if (setup_mom6_)
43  {
44  soca_model_setup_f90(&configc, geom_->toFortran(), keyConfig_);
45  }
46  Log::trace() << "Model created" << std::endl;
47  }
48  // -----------------------------------------------------------------------------
50  if (setup_mom6_)
51  {
53  }
54  Log::trace() << "Model destructed" << std::endl;
55  }
56  // -----------------------------------------------------------------------------
57  void Model::initialize(State & xx) const {
59  Log::debug() << "Model::initialize" << std::endl;
60  }
61  // -----------------------------------------------------------------------------
62  void Model::step(State & xx, const ModelBias &) const {
63  Log::trace() << "Model::Time: " << xx.validTime() << std::endl;
64  util::DateTime * modeldate = &xx.validTime();
66  xx.validTime() += tstep_;
67  }
68  // -----------------------------------------------------------------------------
69  void Model::finalize(State & xx) const {
71  Log::debug() << "Model::finalize" << std::endl;
72  }
73  // -----------------------------------------------------------------------------
74  int Model::saveTrajectory(State & xx, const ModelBias &) const {
75  int ftraj = 0;
76  xx.validTime() += tstep_;
77  return ftraj;
78  }
79  // -----------------------------------------------------------------------------
80  void Model::print(std::ostream & os) const {
81  os << "Model::print not implemented";
82  }
83  // -----------------------------------------------------------------------------
84 } // namespace soca
Geometry handles geometry for SOCA model.
Definition: Geometry.h:48
Model error for the SOCA model.
Definition: ModelBias.h:43
Model(const Geometry &, const eckit::Configuration &)
Definition: Model.cc:30
~Model()
Definition: Model.cc:49
void step(State &, const ModelBias &) const
Model integration.
Definition: Model.cc:62
int keyConfig_
Definition: Model.h:71
int saveTrajectory(State &, const ModelBias &) const
Definition: Model.cc:74
bool setup_mom6_
Definition: Model.h:73
util::Duration tstep_
Definition: Model.h:72
void print(std::ostream &) const
Definition: Model.cc:80
void finalize(State &) const
Finish model integration.
Definition: Model.cc:69
void initialize(State &) const
Prepare model integration.
Definition: Model.cc:57
std::unique_ptr< const Geometry > geom_
Definition: Model.h:74
const oops::Variables vars_
Definition: Model.h:75
SOCA model state.
Definition: State.h:48
const util::DateTime & validTime() const
Definition: State.cc:218
int & toFortran()
Definition: State.h:88
void soca_model_init_f90(const F90model &, const F90flds &)
static oops::interface::ModelMaker< Traits, Model > makermodel_("SOCA")
void soca_model_setup_f90(const eckit::Configuration *const *, const F90geom &, F90model &)
void soca_model_finalize_f90(const F90model &, const F90flds &)
void soca_model_delete_f90(F90model &)
void soca_model_propagate_f90(const F90model &, const F90flds &, util::DateTime *const *)