FV3 Bundle
StateFV3JEDI.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 
9 #include <algorithm>
10 #include <string>
11 #include <vector>
12 
13 
14 #include "eckit/config/LocalConfiguration.h"
15 #include "oops/base/Variables.h"
17 #include "oops/util/abor1_cpp.h"
18 #include "oops/util/DateTime.h"
19 #include "oops/util/Duration.h"
20 #include "oops/util/Logger.h"
21 
22 #include "ioda/Locations.h"
23 #include "ufo/GeoVaLs.h"
24 
25 #include "src/State/StateFV3JEDI.h"
26 #include "GeometryFV3JEDI.h"
27 #include "GetValuesTrajFV3JEDI.h"
28 #include "IncrementFV3JEDI.h"
29 #include "ModelBiasFV3JEDI.h"
30 #include "ModelFV3JEDI.h"
31 #include "StateFV3JEDIFortran.h"
32 #include "UtilitiesFV3JEDI.h"
33 
34 namespace fv3jedi {
35 
36 // -----------------------------------------------------------------------------
37 /// Constructor, destructor
38 // -----------------------------------------------------------------------------
40  const oops::Variables & vars,
41  const util::DateTime & time):
42  geom_(new GeometryFV3JEDI(geom)), vars_(vars), time_(time)
43 {
44  const eckit::Configuration * conf = &vars_.toFortran();
46  oops::Log::trace() << "StateFV3JEDI::StateFV3JEDI created." << std::endl;
47 }
48 // -----------------------------------------------------------------------------
50  const oops::Variables & varsin,
51  const eckit::Configuration & file):
52  geom_(new GeometryFV3JEDI(geom)), vars_(varsin), time_(util::DateTime()) {
53  const std::vector<std::string> *vv;
54 
55  if (file.has("variables"))
56  vv = new std::vector<std::string>(file.getStringVector("variables"));
57  else
58  ABORT("State variables not found in configuration");
59 
60  oops::Variables vars(*vv);
61 
62  const eckit::Configuration * cvars = &vars.toFortran();
63  fv3jedi_state_create_f90(keyState_, geom_->toFortran(), &cvars);
64 
65  const eckit::Configuration * conf = &file;
66  util::DateTime * dtp = &time_;
67 
68  if (file.has("analytic_init")) {
69  stageFv3Files(file);
72  } else {
73  fv3jedi_state_read_file_f90(geom_->toFortran(), keyState_, &conf, &dtp);
74  }
75 
76  oops::Log::trace() << "StateFV3JEDI::StateFV3JEDI created and read in."
77  << std::endl;
78 }
79 // -----------------------------------------------------------------------------
81  const StateFV3JEDI & other):
82  geom_(new GeometryFV3JEDI(resol)), vars_(other.vars_), time_(other.time_)
83 {
84  const eckit::Configuration * conf = &vars_.toFortran();
87  oops::Log::trace() << "StateFV3JEDI::StateFV3JEDI created by interpolation."
88  << std::endl;
89 }
90 // -----------------------------------------------------------------------------
92  geom_(other.geom_), vars_(other.vars_), time_(other.time_)
93 {
94  const eckit::Configuration * conf = &vars_.toFortran();
97  oops::Log::trace() << "StateFV3JEDI::StateFV3JEDI copied." << std::endl;
98 }
99 // -----------------------------------------------------------------------------
102  oops::Log::trace() << "StateFV3JEDI::StateFV3JEDI destructed." << std::endl;
103 }
104 // -----------------------------------------------------------------------------
105 /// Basic operators
106 // -----------------------------------------------------------------------------
109  time_ = rhs.time_;
110  return *this;
111 }
112 // -----------------------------------------------------------------------------
113 /// Get state values at observation locations
114 // -----------------------------------------------------------------------------
116  const oops::Variables & vars,
117  ufo::GeoVaLs & gom) const {
118  oops::Log::trace() << "StateFV3JEDI::getValues starting." << std::endl;
119  const eckit::Configuration * conf = &vars.toFortran();
121  locs.toFortran(), &conf,
122  gom.toFortran());
123  oops::Log::trace() << "StateFV3JEDI::getValues done." << std::endl;
124 }
125 // -----------------------------------------------------------------------------
127  const oops::Variables & vars,
128  ufo::GeoVaLs & gom,
129  const GetValuesTrajFV3JEDI & traj) const {
130  oops::Log::trace() << "StateFV3JEDI::getValues traj starting." << std::endl;
131  const eckit::Configuration * conf = &vars.toFortran();
133  &conf, gom.toFortran(), traj.toFortran());
134  oops::Log::trace() << "StateFV3JEDI::getValues traj done." << std::endl;
135 }
136 // -----------------------------------------------------------------------------
137 /// Interpolate full state
138 // -----------------------------------------------------------------------------
140  oops::Log::trace() << "StateFV3JEDI change resolution starting" << std::endl;
142  oops::Log::trace() << "StateFV3JEDI change resolution done" << std::endl;
143 }
144 // -----------------------------------------------------------------------------
145 /// Interactions with Increments
146 // -----------------------------------------------------------------------------
148  oops::Log::trace() << "StateFV3JEDI add increment starting" << std::endl;
149  ASSERT(this->validTime() == dx.validTime());
151  oops::Log::trace() << "StateFV3JEDI add increment done" << std::endl;
152  return *this;
153 }
154 // -----------------------------------------------------------------------------
155 /// I/O and diagnostics
156 // -----------------------------------------------------------------------------
157 void StateFV3JEDI::read(const eckit::Configuration & config) {
158  oops::Log::trace() << "StateFV3JEDI read starting" << std::endl;
159  const eckit::Configuration * conf = &config;
160  util::DateTime * dtp = &time_;
161  fv3jedi_state_read_file_f90(geom_->toFortran(), keyState_, &conf, &dtp);
162  oops::Log::trace() << "StateFV3JEDI read done" << std::endl;
163 }
164 // -----------------------------------------------------------------------------
165 void StateFV3JEDI::analytic_init(const eckit::Configuration & config,
166  const GeometryFV3JEDI & geom) {
167  oops::Log::trace() << "StateFV3JEDI analytic init starting" << std::endl;
168  const eckit::Configuration * conf = &config;
169  util::DateTime * dtp = &time_;
170  stageFv3Files(config);
172  removeFv3Files();
173  oops::Log::trace() << "StateFV3JEDI analytic init done" << std::endl;
174 }
175 // -----------------------------------------------------------------------------
176 void StateFV3JEDI::write(const eckit::Configuration & config) const {
177  oops::Log::trace() << "StateFV3JEDI write starting" << std::endl;
178  const eckit::Configuration * conf = &config;
179  const util::DateTime * dtp = &time_;
180  fv3jedi_state_write_file_f90(geom_->toFortran(), keyState_, &conf, &dtp);
181  oops::Log::trace() << "StateFV3JEDI write done" << std::endl;
182 }
183 // -----------------------------------------------------------------------------
184 void StateFV3JEDI::print(std::ostream & os) const {
185  oops::Log::trace() << "StateFV3JEDI print starting" << std::endl;
186  os << std::endl << " Valid time: " << validTime();
187  int nx = 0;
188  int ny = 0;
189  int nf = 8;
191  os << std::endl << "Cube faces = " << nx << "x" << ny
192  << ", Number of state fields = " << nf;
193  std::vector<double> zstat(3*nf);
194  fv3jedi_state_gpnorm_f90(keyState_, nf, zstat[0]);
195  for (int jj = 0; jj < nf; ++jj) {
196  os << std::endl <<"State=" << jj+1 <<" Min=" << zstat[3*jj]
197  << ", Max=" << zstat[3*jj+1] << ", RMS=" << zstat[3*jj+2];
198  }
199  oops::Log::trace() << "StateFV3JEDI print done" << std::endl;
200 }
201 // -----------------------------------------------------------------------------
202 /// For accumulator
203 // -----------------------------------------------------------------------------
205  oops::Log::trace() << "StateFV3JEDI zero starting" << std::endl;
207  oops::Log::trace() << "StateFV3JEDI zero done" << std::endl;
208 }
209 // -----------------------------------------------------------------------------
210 void StateFV3JEDI::accumul(const double & zz, const StateFV3JEDI & xx) {
211  oops::Log::trace() << "StateFV3JEDI accumul starting" << std::endl;
213  oops::Log::trace() << "StateFV3JEDI accumul done" << std::endl;
214 }
215 // -----------------------------------------------------------------------------
216 double StateFV3JEDI::norm() const {
217  oops::Log::trace() << "StateFV3JEDI norm starting" << std::endl;
218  double zz = 0.0;
220  return zz;
221  oops::Log::trace() << "StateFV3JEDI norm done" << std::endl;
222 }
223 // -----------------------------------------------------------------------------
224 
225 } // namespace fv3jedi
void print(std::ostream &) const
void accumul(const double &, const StateFV3JEDI &)
void removeFv3Files()
void stageFv3Files(const eckit::Configuration &conf)
void fv3jedi_state_gpnorm_f90(const F90state &, const int &, double &)
void fv3jedi_state_copy_f90(const F90state &, const F90state &)
void fv3jedi_state_getvalues_f90(const F90geom &, const F90state &, const F90locs &, const eckit::Configuration *const *, const F90goms &, const F90ootrj &)
void fv3jedi_state_analytic_init_f90(const F90state &, const F90geom &, const eckit::Configuration *const *, util::DateTime *const *)
Definition: conf.py:1
integer, parameter nx
void zero()
For accumulator.
void fv3jedi_state_create_f90(F90state &, const F90geom &, const eckit::Configuration *const *)
integer, parameter ny
void getValues(const ioda::Locations &, const oops::Variables &, ufo::GeoVaLs &) const
Get state values at observation locations.
void fv3jedi_state_rms_f90(const F90state &, double &)
void fv3jedi_state_sizes_f90(const F90state &, int &, int &, int &)
GeoVaLs: geophysical values at locations.
void analytic_init(const eckit::Configuration &, const GeometryFV3JEDI &)
StateFV3JEDI & operator+=(const IncrementFV3JEDI &)
Interactions with Increments.
void changeResolution(const StateFV3JEDI &xx)
Interpolate full state.
void fv3jedi_state_read_file_f90(const F90geom &, const F90state &, const eckit::Configuration *const *, util::DateTime *const *)
void fv3jedi_state_add_incr_f90(const F90geom &, const F90state &, const F90inc &)
const util::DateTime & validTime() const
Definition: StateFV3JEDI.h:91
StateFV3JEDI & operator=(const StateFV3JEDI &)
Basic operators.
oops::Variables vars_
Definition: StateFV3JEDI.h:102
void fv3jedi_state_getvalues_notraj_f90(const F90geom &, const F90state &, const F90locs &, const eckit::Configuration *const *, const F90goms &)
Locations class to handle locations for IODA.
void fv3jedi_state_change_resol_f90(const F90state &, const F90state &)
StateFV3JEDI(const GeometryFV3JEDI &, const oops::Variables &, const util::DateTime &)
Constructor, destructor.
Definition: StateFV3JEDI.cc:39
void write(const eckit::Configuration &) const
void fv3jedi_state_write_file_f90(const F90geom &, const F90state &, const eckit::Configuration *const *, const util::DateTime *const *)
double norm() const
GeometryFV3JEDI handles geometry for FV3JEDI model.
void fv3jedi_state_zero_f90(const F90state &)
void fv3jedi_state_delete_f90(F90state &)
void read(const eckit::Configuration &)
I/O and diagnostics.
void fv3jedi_state_axpy_f90(const F90state &, const double &, const F90state &)
util::DateTime time_
Definition: StateFV3JEDI.h:103
const eckit::Configuration & toFortran() const
Definition: Variables.h:36
boost::shared_ptr< const GeometryFV3JEDI > geom_
Definition: StateFV3JEDI.h:101
const util::DateTime & validTime() const