FV3 Bundle
ObsVecQG.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 <math.h>
12 
13 #include "oops/util/Logger.h"
14 
15 #include "model/ObsSpaceQG.h"
16 #include "model/ObsVecQG.h"
17 #include "model/QgFortran.h"
18 
19 namespace qg {
20 // -----------------------------------------------------------------------------
22  : obsdb_(obsdb), keyOvec_(0)
23 {
24  qg_obsvec_setup_f90(keyOvec_, obsdb.nout(), obsdb.nobs());
25 }
26 // -----------------------------------------------------------------------------
27 ObsVecQG::ObsVecQG(const ObsVecQG & other, const bool copy)
28  : obsdb_(other.obsdb_), keyOvec_(0) {
30  if (copy) {
32  } else {
34  }
35 }
36 // -----------------------------------------------------------------------------
39 }
40 // -----------------------------------------------------------------------------
42  const int keyOvecRhs = rhs.keyOvec_;
43  qg_obsvec_assign_f90(keyOvec_, keyOvecRhs);
44  return *this;
45 }
46 // -----------------------------------------------------------------------------
47 ObsVecQG & ObsVecQG::operator*= (const double & zz) {
49  return *this;
50 }
51 // -----------------------------------------------------------------------------
53  const int keyOvecRhs = rhs.keyOvec_;
54  qg_obsvec_add_f90(keyOvec_, keyOvecRhs);
55  return *this;
56 }
57 // -----------------------------------------------------------------------------
59  const int keyOvecRhs = rhs.keyOvec_;
60  qg_obsvec_sub_f90(keyOvec_, keyOvecRhs);
61  return *this;
62 }
63 // -----------------------------------------------------------------------------
65  const int keyOvecRhs = rhs.keyOvec_;
66  qg_obsvec_mul_f90(keyOvec_, keyOvecRhs);
67  return *this;
68 }
69 // -----------------------------------------------------------------------------
71  const int keyOvecRhs = rhs.keyOvec_;
72  qg_obsvec_div_f90(keyOvec_, keyOvecRhs);
73  return *this;
74 }
75 // -----------------------------------------------------------------------------
78 }
79 // -----------------------------------------------------------------------------
80 void ObsVecQG::axpy(const double & zz, const ObsVecQG & rhs) {
81  const int keyOvecRhs = rhs.keyOvec_;
82  qg_obsvec_axpy_f90(keyOvec_, zz, keyOvecRhs);
83 }
84 // -----------------------------------------------------------------------------
87 }
88 // -----------------------------------------------------------------------------
91 }
92 // -----------------------------------------------------------------------------
93 double ObsVecQG::dot_product_with(const ObsVecQG & other) const {
94  const int keyOvecOther = other.keyOvec_;
95  double zz;
96  qg_obsvec_dotprod_f90(keyOvec_, keyOvecOther, zz);
97  return zz;
98 }
99 // -----------------------------------------------------------------------------
100 double ObsVecQG::rms() const {
101  double zz;
103  int iobs;
105  zz = sqrt(zz/iobs);
106  return zz;
107 }
108 // -----------------------------------------------------------------------------
109 void ObsVecQG::read(const std::string & name) {
111 }
112 // -----------------------------------------------------------------------------
113 void ObsVecQG::save(const std::string & name) const {
115 }
116 // -----------------------------------------------------------------------------
117 void ObsVecQG::print(std::ostream & os) const {
118  double zmin, zmax, zavg;
119  qg_obsvec_minmaxavg_f90(keyOvec_, zmin, zmax, zavg);
120  os << obsdb_.obsname() << " nobs= " << size()
121  << " Min=" << zmin << ", Max=" << zmax << ", Average=" << zavg;
122 }
123 // -----------------------------------------------------------------------------
124 unsigned int ObsVecQG::size() const {
125  int iobs;
127  unsigned int nobs(iobs);
128  return nobs;
129 }
130 // -----------------------------------------------------------------------------
131 } // namespace qg
void putdb(const std::string &col, const int &keyData) const
Definition: ObsSpaceQG.h:43
const ObsSpaceQG & obsdb_
Definition: ObsVecQG.h:62
void qg_obsvec_mul_scal_f90(const F90ovec &, const double &)
ObsVecQG & operator=(const ObsVecQG &)
Definition: ObsVecQG.cc:41
void zero()
Definition: ObsVecQG.cc:76
subroutine, public copy(self, rhs)
int nout() const
Definition: ObsSpaceQG.h:60
void qg_obsvec_zero_f90(const F90ovec &)
int nobs() const
Definition: ObsSpaceQG.h:58
void read(const std::string &)
Definition: ObsVecQG.cc:109
unsigned int size() const
Definition: ObsVecQG.cc:124
ObsVecQG & operator+=(const ObsVecQG &)
Definition: ObsVecQG.cc:52
void invert()
Definition: ObsVecQG.cc:85
void qg_obsvec_axpy_f90(const F90ovec &, const double &, const F90ovec &)
void qg_obsvec_nobs_f90(const F90ovec &, int &)
ObsVecQG & operator*=(const double &)
Definition: ObsVecQG.cc:47
void random()
Definition: ObsVecQG.cc:89
ObsVecQG & operator/=(const ObsVecQG &)
Definition: ObsVecQG.cc:70
void print(std::ostream &) const
Definition: ObsVecQG.cc:117
void qg_obsvec_mul_f90(const F90ovec &, const F90ovec &)
void qg_obsvec_add_f90(const F90ovec &, const F90ovec &)
character(len=32) name
void save(const std::string &) const
Definition: ObsVecQG.cc:113
void qg_obsvec_sub_f90(const F90ovec &, const F90ovec &)
void qg_obsvec_dotprod_f90(const F90ovec &, const F90ovec &, double &)
F90ovec keyOvec_
Definition: ObsVecQG.h:63
void getdb(const std::string &col, int &keyData) const
Definition: ObsSpaceQG.h:40
void qg_obsvec_random_f90(const F90ovec &)
void axpy(const double &, const ObsVecQG &)
Definition: ObsVecQG.cc:80
void qg_obsvec_div_f90(const F90ovec &, const F90ovec &)
void qg_obsvec_delete_f90(F90ovec &)
ObsVecQG(const ObsSpaceQG &)
Definition: ObsVecQG.cc:21
void qg_obsvec_setup_f90(F90ovec &, const int &, const int &)
double rms() const
Definition: ObsVecQG.cc:100
ObsVecQG & operator-=(const ObsVecQG &)
Definition: ObsVecQG.cc:58
double dot_product_with(const ObsVecQG &) const
Definition: ObsVecQG.cc:93
void qg_obsvec_invert_f90(const F90ovec &)
ObsVecQG class to handle vectors in observation space for QG model.
Definition: ObsVecQG.h:27
Wrapper around ObsHelpQG, mostly to hide the factory.
Definition: ObsSpaceQG.h:35
void qg_obsvec_clone_f90(const F90ovec &, F90ovec &)
void qg_obsvec_assign_f90(const F90ovec &, const F90ovec &)
const std::string & obsname() const
Definition: ObsSpaceQG.h:61
The namespace for the qg model.
void qg_obsvec_minmaxavg_f90(const F90ovec &, double &, double &, double &)