FV3 Bundle
FieldsQG.cc
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 #include "model/FieldsQG.h"
12 
13 #include <cmath>
14 #include <map>
15 #include <string>
16 #include <vector>
17 
18 #include "eckit/config/Configuration.h"
19 #include "model/GeometryQG.h"
20 #include "model/GomQG.h"
21 #include "model/LocationsQG.h"
22 #include "model/QgFortran.h"
23 #include "model/VariablesQG.h"
24 #include "oops/base/Variables.h"
26 #include "oops/util/DateTime.h"
27 #include "oops/util/Logger.h"
28 
29 // -----------------------------------------------------------------------------
30 namespace qg {
31 // -----------------------------------------------------------------------------
33  const util::DateTime & time):
34  geom_(new GeometryQG(geom)), vars_(vars), time_(time)
35 {
37 }
38 // -----------------------------------------------------------------------------
39 FieldsQG::FieldsQG(const FieldsQG & other, const bool copy)
40  : geom_(other.geom_), vars_(other.vars_), time_(other.time_)
41 {
43  if (copy) {
45  } else {
47  }
48 }
49 // -----------------------------------------------------------------------------
51  : geom_(other.geom_), vars_(other.vars_), time_(other.time_)
52 {
55 }
56 // -----------------------------------------------------------------------------
57 FieldsQG::FieldsQG(const FieldsQG & other, const GeometryQG & geom)
58  : geom_(new GeometryQG(geom)), vars_(other.vars_), time_(other.time_)
59 {
62 }
63 // -----------------------------------------------------------------------------
65  : geom_(other.geom_), vars_(vars), time_(other.time_)
66 {
69 }
70 // -----------------------------------------------------------------------------
73 }
74 // -----------------------------------------------------------------------------
77  time_ = rhs.time_;
78  return *this;
79 }
80 // -----------------------------------------------------------------------------
83  return *this;
84 }
85 // -----------------------------------------------------------------------------
88  return *this;
89 }
90 // -----------------------------------------------------------------------------
91 FieldsQG & FieldsQG::operator*=(const double & zz) {
93  return *this;
94 }
95 // -----------------------------------------------------------------------------
98 }
99 // -----------------------------------------------------------------------------
100 void FieldsQG::zero(const util::DateTime & time) {
102  time_ = time;
103 }
104 // -----------------------------------------------------------------------------
105 void FieldsQG::axpy(const double & zz, const FieldsQG & rhs) {
107 }
108 // -----------------------------------------------------------------------------
109 double FieldsQG::dot_product_with(const FieldsQG & fld2) const {
110  double zz;
112  return zz;
113 }
114 // -----------------------------------------------------------------------------
117 }
118 // -----------------------------------------------------------------------------
121 }
122 // -----------------------------------------------------------------------------
123 void FieldsQG::dirac(const eckit::Configuration & config) {
124  const eckit::Configuration * conf = &config;
126 }
127 // -----------------------------------------------------------------------------
129  GomQG & gom) const {
130  const VariablesQG varqg(vars);
132 }
133 // -----------------------------------------------------------------------------
135  GomQG & gom) const {
136  const VariablesQG varqg(vars);
138 }
139 // -----------------------------------------------------------------------------
141  const GomQG & gom) {
142  const VariablesQG varqg(vars);
144 }
145 // -----------------------------------------------------------------------------
148 }
149 // -----------------------------------------------------------------------------
150 void FieldsQG::add(const FieldsQG & rhs) {
152 }
153 // -----------------------------------------------------------------------------
154 void FieldsQG::diff(const FieldsQG & x1, const FieldsQG & x2) {
156 }
157 // -----------------------------------------------------------------------------
158 void FieldsQG::ug_coord(oops::UnstructuredGrid & ug, const int & colocated) const {
159  qg_field_ug_coord_f90(keyFlds_, ug.toFortran(), colocated);
160 }
161 // -----------------------------------------------------------------------------
162 void FieldsQG::field_to_ug(oops::UnstructuredGrid & ug, const int & colocated) const {
163  qg_field_field_to_ug_f90(keyFlds_, ug.toFortran(), colocated);
164 }
165 // -----------------------------------------------------------------------------
168 }
169 // -----------------------------------------------------------------------------
170 void FieldsQG::read(const eckit::Configuration & config) {
171  const eckit::Configuration * conf = &config;
172  util::DateTime * dtp = &time_;
174 }
175 // -----------------------------------------------------------------------------
176 void FieldsQG::analytic_init(const eckit::Configuration & config,
177  const GeometryQG & geom) {
178  const eckit::Configuration * conf = &config;
179  util::DateTime * dtp = &time_;
181 }
182 // -----------------------------------------------------------------------------
183 void FieldsQG::write(const eckit::Configuration & config) const {
184  const eckit::Configuration * conf = &config;
185  const util::DateTime * dtp = &time_;
187 }
188 // -----------------------------------------------------------------------------
189 double FieldsQG::norm() const {
190  double zz = 0.0;
192  return zz;
193 }
194 // -----------------------------------------------------------------------------
195 void FieldsQG::print(std::ostream & os) const {
196  int nx = -1;
197  int ny = -1;
198  int nf = -1;
199  int nb = -1;
200  int nl = -1;
201  qg_field_sizes_f90(keyFlds_, nx, ny, nf, nb, nl);
202  os << std::endl << " Resolution = " << nx << ", " << ny
203  << ", Fields = " << nf << ", " << nb;
204  nf += nb;
205  std::vector<double> zstat(3*nf);
206  qg_field_gpnorm_f90(keyFlds_, nf, zstat[0]);
207  for (int jj = 0; jj < nf; ++jj) {
208  os << std::endl << " Min=" << zstat[3*jj]
209  << ", Max=" << zstat[3*jj+1] << ", RMS=" << zstat[3*jj+2];
210  }
211 }
212 // -----------------------------------------------------------------------------
213 bool FieldsQG::isForModel(const bool & nonlinear) const {
214  int nx = -1;
215  int ny = -1;
216  int nf = -1;
217  int nb = -1;
218  int nl = -1;
219  qg_field_sizes_f90(keyFlds_, nx, ny, nf, nb, nl);
220  bool ok = (nf == 4);
221  if (nonlinear) ok = ok && (nb == 2);
222  return ok;
223 }
224 // -----------------------------------------------------------------------------
226  int nx = -1;
227  int ny = -1;
228  int nf = -1;
229  int nb = -1;
230  int nl = -1;
231  qg_field_sizes_f90(keyFlds_, nx, ny, nf, nb, nl);
232  std::vector<int> varlens(nf, nl);
233  std::vector<double> values(nf*nl);
234  qg_field_getpoint_f90(keyFlds_, iter.toFortran(), nf*nl, values[0]);
235  return oops::GridPoint(vars_.toOopsVariables(), values, varlens);
236 }
237 
238 } // namespace qg
GomQG class to handle local model values for QG model.
Definition: GomQG.h:31
F90flds keyFlds_
Definition: FieldsQG.h:105
void read(const eckit::Configuration &)
Definition: FieldsQG.cc:170
void qg_field_interp_ad_f90(const F90flds &, const F90locs &, const F90vars *, const F90goms &)
double dot_product_with(const FieldsQG &) const
Definition: FieldsQG.cc:109
void qg_field_change_resol_f90(const F90flds &, const F90flds &)
void print(std::ostream &) const
Definition: FieldsQG.cc:195
void qg_field_self_mul_f90(const F90flds &, const double &)
void getValuesAD(const LocationsQG &, const oops::Variables &, const GomQG &)
Definition: FieldsQG.cc:140
void qg_field_add_incr_f90(const F90flds &, const F90flds &)
integer, parameter nl
void qg_field_analytic_init_f90(const F90flds &, const F90geom &, const eckit::Configuration *const *, util::DateTime *const *)
void qg_field_axpy_f90(const F90flds &, const double &, const F90flds &)
Class to represent a FieldSet for the QG model.
Definition: FieldsQG.h:46
subroutine, public copy(self, rhs)
Definition: conf.py:1
integer, parameter nx
void dirac(const eckit::Configuration &)
Definition: FieldsQG.cc:123
void write(const eckit::Configuration &) const
Definition: FieldsQG.cc:183
void qg_field_field_to_ug_f90(const F90flds &, const int &, const int &)
void field_to_ug(oops::UnstructuredGrid &, const int &) const
Definition: FieldsQG.cc:162
void getValuesTL(const LocationsQG &, const oops::Variables &, GomQG &) const
Definition: FieldsQG.cc:134
integer, parameter ny
void qg_field_field_from_ug_f90(const F90flds &, const int &)
FieldsQG(const GeometryQG &, const oops::Variables &, const util::DateTime &)
Definition: FieldsQG.cc:32
void qg_field_random_f90(const F90flds &)
void qg_field_self_add_f90(const F90flds &, const F90flds &)
void add(const FieldsQG &)
Definition: FieldsQG.cc:150
bool isForModel(const bool &) const
Definition: FieldsQG.cc:213
util::DateTime time_
Definition: FieldsQG.h:108
void schur_product_with(const FieldsQG &)
Definition: FieldsQG.cc:115
FieldsQG & operator+=(const FieldsQG &)
Definition: FieldsQG.cc:81
const int * toFortran() const
Definition: VariablesQG.h:43
double norm() const
Definition: FieldsQG.cc:189
const oops::Variables & toOopsVariables() const
Definition: VariablesQG.h:44
const VariablesQG vars_
Definition: FieldsQG.h:107
int toFortran() const
Definition: LocationsQG.h:43
void changeResolution(const FieldsQG &)
Definition: FieldsQG.cc:146
void zero()
Definition: FieldsQG.cc:96
F90geom & toFortran()
Definition: GeometryQG.h:42
void qg_field_dirac_f90(const F90flds &, const eckit::Configuration *const *)
void axpy(const double &, const FieldsQG &)
Definition: FieldsQG.cc:105
void qg_field_ug_coord_f90(const F90flds &, const int &, const int &)
void qg_field_dot_prod_f90(const F90flds &, const F90flds &, double &)
void qg_field_gpnorm_f90(const F90flds &, const int &, double &)
void qg_field_delete_f90(F90flds &)
void ug_coord(oops::UnstructuredGrid &, const int &) const
Definition: FieldsQG.cc:158
void field_from_ug(const oops::UnstructuredGrid &)
Definition: FieldsQG.cc:166
oops::GridPoint getPoint(const GeometryQGIterator &) const
Definition: FieldsQG.cc:225
void qg_field_diff_incr_f90(const F90flds &, const F90flds &, const F90flds &)
void qg_field_read_file_f90(const F90flds &, const eckit::Configuration *const *, util::DateTime *const *)
void qg_field_sizes_f90(const F90flds &, int &, int &, int &, int &, int &)
GeometryQG handles geometry for QG model.
Definition: GeometryQG.h:33
void getValues(const LocationsQG &, const oops::Variables &, GomQG &) const
Definition: FieldsQG.cc:128
void qg_field_create_f90(F90flds &, const F90geom &, const F90vars *)
LocationsQG class to handle locations for QG model.
Definition: LocationsQG.h:26
void qg_field_write_file_f90(const F90flds &, const eckit::Configuration *const *, const util::DateTime *const *)
void qg_field_interp_tl_f90(const F90flds &, const F90locs &, const F90vars *, const F90goms &)
const util::DateTime & time() const
Definition: FieldsQG.h:93
void qg_field_getpoint_f90(const F90flds &, const F90iter &, const int &, double &)
FieldsQG & operator-=(const FieldsQG &)
Definition: FieldsQG.cc:86
void qg_field_zero_f90(const F90flds &)
void qg_field_rms_f90(const F90flds &, double &)
void diff(const FieldsQG &, const FieldsQG &)
Definition: FieldsQG.cc:154
boost::shared_ptr< const GeometryQG > geom_
Definition: FieldsQG.h:106
FieldsQG & operator=(const FieldsQG &)
Definition: FieldsQG.cc:75
void analytic_init(const eckit::Configuration &, const GeometryQG &)
Definition: FieldsQG.cc:176
void random()
Definition: FieldsQG.cc:119
void qg_field_self_sub_f90(const F90flds &, const F90flds &)
int & toFortran()
Definition: GomQG.h:59
The namespace for the qg model.
void qg_field_copy_f90(const F90flds &, const F90flds &)
void qg_field_self_schur_f90(const F90flds &, const F90flds &)
FieldsQG & operator*=(const double &)
Definition: FieldsQG.cc:91