MPAS-JEDI
TlmMPAS.cc
Go to the documentation of this file.
1 /*
2  * (C) Copyright 2017 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 "eckit/config/LocalConfiguration.h"
9 
10 #include "oops/util/abor1_cpp.h"
11 #include "oops/util/DateTime.h"
12 #include "oops/util/Logger.h"
13 
14 #include "mpasjedi/GeometryMPAS.h"
15 #include "mpasjedi/IncrementMPAS.h"
16 #include "mpasjedi/StateMPAS.h"
17 #include "mpasjedi/TlmMPAS.h"
18 
19 namespace mpas {
20 
21 // -----------------------------------------------------------------------------
22 static oops::interface::LinearModelMaker<MPASTraits, TlmMPAS> makerMPASTLM_("MPASTLM");
23 // -----------------------------------------------------------------------------
25  const eckit::Configuration & tlConf)
26  : keyConfig_(0), tstep_(), resol_(resol), traj_(),
27  lrmodel_(resol_, eckit::LocalConfiguration(tlConf, "trajectory")),
28  linvars_(tlConf, "tlm variables")
29 
30 {
31  tstep_ = util::Duration(tlConf.getString("tstep"));
32 
34 
35  oops::Log::trace() << "TlmMPAS created" << std::endl;
36 }
37 // -----------------------------------------------------------------------------
40  for (trajIter jtra = traj_.begin(); jtra != traj_.end(); ++jtra) {
41  mpas_model_wipe_traj_f90(jtra->second);
42  }
43  oops::Log::trace() << "TlmMPAS destructed" << std::endl;
44 }
45 // -----------------------------------------------------------------------------
47  const ModelBiasMPAS & bias) {
48 // StateMPAS xlr(resol_, xx);
49  xlr.changeResolution(xx);
50  int ftraj = lrmodel_.saveTrajectory(xlr, bias);
51  traj_[xx.validTime()] = ftraj;
52 
53 // should be in print method
54  std::vector<double> zstat(15);
55 // mpas_traj_minmaxrms_f90(ftraj, zstat[0]);
56  oops::Log::debug() << "TlmMPAS trajectory at time " << xx.validTime()
57  << std::endl;
58  for (unsigned int jj = 0; jj < 5; ++jj) {
59  oops::Log::debug() << " Min=" << zstat[3*jj] << ", Max=" << zstat[3*jj+1]
60  << ", RMS=" << zstat[3*jj+2] << std::endl;
61  }
62 // should be in print method
63 }
64 // -----------------------------------------------------------------------------
67  oops::Log::debug() << "TlmMPAS::initializeTL" << dx << std::endl;
68 }
69 // -----------------------------------------------------------------------------
71  trajICst itra = traj_.find(dx.validTime());
72  if (itra == traj_.end()) {
73  oops::Log::error() << "TlmMPAS: trajectory not available at time "
74  << dx.validTime() << std::endl;
75  ABORT("TlmMPAS: trajectory not available");
76  }
77  oops::Log::debug() << "TlmMPAS::stepTL increment in" << dx << std::endl;
79  itra->second);
80  oops::Log::debug() << "TlmMPAS::stepTL increment out"<< dx << std::endl;
81  dx.validTime() += tstep_;
82 }
83 // -----------------------------------------------------------------------------
85  oops::Log::debug() << "TlmMPAS::finalizeTL" << dx << std::endl;
86 }
87 // -----------------------------------------------------------------------------
89  oops::Log::debug() << "TlmMPAS::initializeAD" << dx << std::endl;
90 }
91 // -----------------------------------------------------------------------------
93  dx.validTime() -= tstep_;
94  trajICst itra = traj_.find(dx.validTime());
95  if (itra == traj_.end()) {
96  oops::Log::error() << "TlmMPAS: trajectory not available at time "
97  << dx.validTime() << std::endl;
98  ABORT("TlmMPAS: trajectory not available");
99  }
100  oops::Log::debug() << "TlmMPAS::stepAD increment in" << dx << std::endl;
102  itra->second);
103  oops::Log::debug() << "TlmMPAS::stepAD increment out" << dx << std::endl;
104 }
105 // -----------------------------------------------------------------------------
108  oops::Log::debug() << "TlmMPAS::finalizeAD" << dx << std::endl;
109 }
110 // -----------------------------------------------------------------------------
111 void TlmMPAS::print(std::ostream & os) const {
112  os << "MPAS TLM Trajectory, nstep=" << traj_.size() << std::endl;
113  typedef std::map< util::DateTime, int >::const_iterator trajICst;
114  if (traj_.size() > 0) {
115  os << "MPAS TLM Trajectory: times are:";
116  for (trajICst jtra = traj_.begin(); jtra != traj_.end(); ++jtra) {
117  os << " " << jtra->first;
118  }
119  }
120 }
121 // -----------------------------------------------------------------------------
122 } // namespace mpas
GeometryMPAS handles geometry for MPAS model.
Definition: GeometryMPAS.h:37
F90geom & toFortran()
Definition: GeometryMPAS.h:45
Increment Class: Difference between two states.
Definition: IncrementMPAS.h:57
const util::DateTime & validTime() const
Model error for the MPAS model.
Definition: ModelBiasMPAS.h:38
int saveTrajectory(StateMPAS &, const ModelBiasMPAS &) const
Definition: ModelMPAS.cc:59
MPAS model state.
Definition: StateMPAS.h:51
void changeResolution(const StateMPAS &xx)
Interpolate full fields.
Definition: StateMPAS.cc:97
const util::DateTime & validTime() const
Definition: StateMPAS.h:89
void finalizeTL(IncrementMPAS &) const override
Definition: TlmMPAS.cc:84
void stepAD(IncrementMPAS &, ModelBiasIncrementMPAS &) const override
Definition: TlmMPAS.cc:92
TlmMPAS(const GeometryMPAS &, const eckit::Configuration &)
Definition: TlmMPAS.cc:24
void stepTL(IncrementMPAS &, const ModelBiasIncrementMPAS &) const override
Definition: TlmMPAS.cc:70
F90model keyConfig_
Definition: TlmMPAS.h:70
void initializeTL(IncrementMPAS &) const override
Run TLM and its adjoint.
Definition: TlmMPAS.cc:65
std::map< util::DateTime, F90traj > traj_
Definition: TlmMPAS.h:73
void print(std::ostream &) const override
Definition: TlmMPAS.cc:111
const ModelMPAS lrmodel_
Definition: TlmMPAS.h:74
void initializeAD(IncrementMPAS &) const override
Definition: TlmMPAS.cc:88
std::map< util::DateTime, int >::iterator trajIter
Definition: TlmMPAS.h:66
const GeometryMPAS resol_
Definition: TlmMPAS.h:72
util::Duration tstep_
Definition: TlmMPAS.h:71
void setTrajectory(const StateMPAS &, StateMPAS &, const ModelBiasMPAS &) override
Model trajectory computation.
Definition: TlmMPAS.cc:46
std::map< util::DateTime, int >::const_iterator trajICst
Definition: TlmMPAS.h:67
void finalizeAD(IncrementMPAS &) const override
Definition: TlmMPAS.cc:106
Definition: Fortran.h:17
static oops::interface::LinearModelMaker< MPASTraits, TlmMPAS > makerMPASTLM_("MPASTLM")
void mpas_model_setup_f90(const eckit::Configuration &, const F90geom &, F90model &)
void mpas_model_delete_f90(F90model &)
void mpas_model_prepare_integration_tl_f90(const F90model &, const F90inc &)
void mpas_model_propagate_tl_f90(const F90model &, const F90inc &, const F90traj &)
void mpas_model_propagate_ad_f90(const F90model &, const F90inc &, const F90traj &)
void mpas_model_wipe_traj_f90(F90traj &)
void mpas_model_prepare_integration_ad_f90(const F90model &, const F90inc &)