FV3 Bundle
GeoVaLs.cc
Go to the documentation of this file.
1 /*
2  * (C) Copyright 2017-2018 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 "ufo/GeoVaLs.h"
9 
10 #include "eckit/config/Configuration.h"
11 
12 #include "ioda/Locations.h"
13 
14 #include "oops/base/Variables.h"
15 #include "oops/util/Logger.h"
16 
17 #include "ufo/Fortran.h"
18 #include "ufo/FortranGeoVals.h"
19 
20 namespace ufo {
21 
22 // -----------------------------------------------------------------------------
24  : keyGVL_(-1), vars_(vars)
25 {
26  oops::Log::trace() << "GeoVaLs contructor starting" << std::endl;
27  const eckit::Configuration * cvar = &vars_.toFortran();
28  ufo_geovals_setup_f90(keyGVL_, locs.toFortran(), &cvar);
29  oops::Log::trace() << "GeoVaLs contructor key = " << keyGVL_ << std::endl;
30 }
31 // -----------------------------------------------------------------------------
32 GeoVaLs::GeoVaLs(const eckit::Configuration & config, const oops::Variables & vars)
33 : keyGVL_(-1), vars_(vars)
34 {
35  oops::Log::trace() << "GeoVaLs constructor config starting" << std::endl;
37  int irandom = 0;
38  config.get("random", irandom);
39  const eckit::Configuration * conf = &config;
40  const eckit::Configuration * cvar = &vars_.toFortran();
41  if (irandom == 0) {
43  } else {
45  }
46  oops::Log::trace() << "GeoVaLs contructor config key = " << keyGVL_ << std::endl;
47 }
48 // -----------------------------------------------------------------------------
49 /*! \brief Copy constructor */
50 
51  GeoVaLs::GeoVaLs(const GeoVaLs & other)
52  : keyGVL_(-1), vars_(other.vars_)
53 {
54  oops::Log::trace() << "GeoVaLs copy constructor starting" << std::endl;
55 
58 
59  oops::Log::trace() << "GeoVaLs copy constructor key = " << keyGVL_ << std::endl;
60 }
61 // -----------------------------------------------------------------------------
64 }
65 // -----------------------------------------------------------------------------
66 /*! \brief Analytic initialization for GeoVaLs
67  *
68  * \details This ufo::GeoVaLs constructor was introduced in May, 2018 for use with
69  * the interpolation test. If "analytic_init" is not specified in the
70  * configuration then this does nothing. If "analytic_init" **is** specified, then
71  * the values are replaced by values computed directly from one of several idealized
72  * analytic states.
73  *
74  * \date May, 2018: Created (M. Miesch, JCSDA)
75  * \date June, 2018: Split off from constructor into independent method
76  * (M. Miesch, JCSDA)
77  */
79  const eckit::Configuration & config)
80  {
81  const eckit::Configuration * conf = &config;
82  if (config.has("analytic_init")) {
84  }
85  }
86 // -----------------------------------------------------------------------------
87 void GeoVaLs::zero() {
89 }
90 // -----------------------------------------------------------------------------
91 /*! Absolute value */
92 void GeoVaLs::abs() {
94 }
95 // -----------------------------------------------------------------------------
96 double GeoVaLs::norm() const {
97  double zz;
99  return zz;
100 }
101 // -----------------------------------------------------------------------------
104 }
105 // -----------------------------------------------------------------------------
106 GeoVaLs & GeoVaLs::operator*=(const double zz) {
108  return *this;
109 }
110 // -----------------------------------------------------------------------------
113  return *this;
114 }
115 // -----------------------------------------------------------------------------
118  return *this;
119 }
120 // -----------------------------------------------------------------------------
123  return *this;
124 }
125 // -----------------------------------------------------------------------------
126 /*! GeoVaLs normalization
127  *
128  * \details This operator is used to normalize each element of the input GeoVaLs
129  * object (LHS) with the rms values of each variable on the RHS, across all
130  * locations
131  */
134  return *this;
135 }
136 // -----------------------------------------------------------------------------
137 double GeoVaLs::dot_product_with(const GeoVaLs & other) const {
138  double zz;
140  return zz;
141 }
142 // -----------------------------------------------------------------------------
143 void GeoVaLs::print(std::ostream & os) const {
144  int nn;
145  double zmin, zmax, zrms;
146  ufo_geovals_minmaxavg_f90(keyGVL_, nn, zmin, zmax, zrms);
147  os << "GeoVaLs: nobs= " << nn << " Min=" << zmin << ", Max=" << zmax
148  << ", RMS=" << zrms << std::endl;
149 
150  /*! Verbose print statement (debug mode)
151  *
152  * \detail If the min value across all variables is positive, then this may be
153  * an error measurement. If so, compute the rms over the vertical profile and
154  * tell the user where the maximum rms value occurs, in terms of the
155  * observation number and the variable number. This is intended to help
156  * with debugging.
157  */
158 
159  if (zmin >= 0.0) {
160  double mxval;
161  int ivar, iobs;
162 
163  ufo_geovals_maxloc_f90(keyGVL_, mxval, iobs, ivar);
164 
165  oops::Log::debug() << "GeoVaLs: Maximum Value (vertical rms) = "
166  << std::setprecision(4)
167  << mxval << " for observation = " << iobs
168  << " and variable = " << ivar << std::endl;
169  }
170 }
171 // -----------------------------------------------------------------------------
172 void GeoVaLs::read(const eckit::Configuration & config) {
173  const eckit::Configuration * conf = &config;
174  const eckit::Configuration * cvar = &vars_.toFortran();
176 }
177 // -----------------------------------------------------------------------------
178 void GeoVaLs::write(const eckit::Configuration & config) const {
179  const eckit::Configuration * conf = &config;
181 }
182 // -----------------------------------------------------------------------------
183 } // namespace ufo
void random()
Definition: GeoVaLs.cc:102
void ufo_geovals_setup_f90(F90goms &, const F90locs &, const eckit::Configuration *const *)
Interface to Fortran UFO GeoVals routines.
Definition: conf.py:1
void ufo_geovals_abs_f90(const F90goms &)
void abs()
Absolute value.
Definition: GeoVaLs.cc:92
void ufo_geovals_setup_random_f90(const F90goms &, const eckit::Configuration *const *, const eckit::Configuration *const *)
void ufo_geovals_normalize_f90(const F90goms &, const F90goms &)
void ufo_geovals_minmaxavg_f90(const F90goms &, int &, double &, double &, double &)
void zero()
Definition: GeoVaLs.cc:87
void ufo_geovals_analytic_init_f90(F90goms &, const F90locs &, const eckit::Configuration *const *)
GeoVaLs & operator=(const GeoVaLs &)
Definition: GeoVaLs.cc:111
GeoVaLs: geophysical values at locations.
logical debug
Definition: mpp.F90:1297
GeoVaLs & operator-=(const GeoVaLs &)
Definition: GeoVaLs.cc:121
void read(const eckit::Configuration &)
Definition: GeoVaLs.cc:172
void ufo_geovals_create_f90(F90goms &)
void ufo_geovals_add_f90(const F90goms &, const F90goms &)
double dot_product_with(const GeoVaLs &other) const
Definition: GeoVaLs.cc:137
GeoVaLs & operator+=(const GeoVaLs &)
Definition: GeoVaLs.cc:116
void analytic_init(const ioda::Locations &, const eckit::Configuration &)
Analytic initialization for GeoVaLs.
Definition: GeoVaLs.cc:78
void ufo_geovals_random_f90(const F90goms &)
Locations class to handle locations for IODA.
oops::Variables vars_
void write(const eckit::Configuration &) const
Definition: GeoVaLs.cc:178
void print(std::ostream &) const
Definition: GeoVaLs.cc:143
void ufo_geovals_delete_f90(F90goms &)
void ufo_geovals_zero_f90(const F90goms &)
void ufo_geovals_dotprod_f90(const F90goms &, const F90goms &, double &)
GeoVaLs(const ioda::Locations &, const oops::Variables &)
Definition: GeoVaLs.cc:23
void ufo_geovals_scalmult_f90(const F90goms &, const double &)
void ufo_geovals_assign_f90(const F90goms &, const F90goms &)
void ufo_geovals_diff_f90(const F90goms &, const F90goms &)
void ufo_geovals_rms_f90(const F90goms &, double &)
GeoVaLs & operator*=(const double)
Definition: GeoVaLs.cc:106
void ufo_geovals_read_file_f90(const F90goms &, const eckit::Configuration *const *, const eckit::Configuration *const *)
void ufo_geovals_copy_f90(const F90goms &, F90goms &)
void ufo_geovals_write_file_f90(const F90goms &, const eckit::Configuration *const *)
const eckit::Configuration & toFortran() const
Definition: Variables.h:36
void ufo_geovals_maxloc_f90(const F90goms &, double &, int &, int &)
GeoVaLs & operator/=(const GeoVaLs &)
GeoVaLs normalization.
Definition: GeoVaLs.cc:132
double norm() const
Definition: GeoVaLs.cc:96