FV3 Bundle
IncrementQG.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/IncrementQG.h"
12 
13 #include <algorithm>
14 #include <string>
15 #include <utility>
16 #include <vector>
17 
18 #include "eckit/config/LocalConfiguration.h"
20 #include "model/FieldsQG.h"
21 #include "model/GeometryQG.h"
22 #include "model/GomQG.h"
23 #include "model/LocationsQG.h"
25 #include "model/Nothing.h"
26 #include "model/StateQG.h"
27 #include "oops/base/Variables.h"
29 #include "oops/util/DateTime.h"
30 #include "oops/util/Duration.h"
31 #include "oops/util/Logger.h"
32 
33 namespace qg {
34 
35 // -----------------------------------------------------------------------------
36 /// Constructor, destructor
37 // -----------------------------------------------------------------------------
39  const util::DateTime & vt)
40  : fields_(new FieldsQG(resol, vars, vt)), stash_()
41 {
42  fields_->zero();
43  oops::Log::trace() << "IncrementQG constructed." << std::endl;
44 }
45 // -----------------------------------------------------------------------------
46 IncrementQG::IncrementQG(const GeometryQG & resol, const IncrementQG & other)
47  : fields_(new FieldsQG(*other.fields_, resol)), stash_()
48 {
49  oops::Log::trace() << "IncrementQG constructed from other." << std::endl;
50 }
51 // -----------------------------------------------------------------------------
52 IncrementQG::IncrementQG(const IncrementQG & other, const bool copy)
53  : fields_(new FieldsQG(*other.fields_, copy)), stash_()
54 {
55  oops::Log::trace() << "IncrementQG copy-created." << std::endl;
56 }
57 // -----------------------------------------------------------------------------
59  : fields_(new FieldsQG(*other.fields_)), stash_()
60 {
61  oops::Log::trace() << "IncrementQG copy-created." << std::endl;
62 }
63 // -----------------------------------------------------------------------------
65  oops::Log::trace() << "IncrementQG destructed" << std::endl;
66 }
67 // -----------------------------------------------------------------------------
68 /// Basic operators
69 // -----------------------------------------------------------------------------
70 void IncrementQG::diff(const StateQG & x1, const StateQG & x2) {
71  ASSERT(this->validTime() == x1.validTime());
72  ASSERT(this->validTime() == x2.validTime());
73  oops::Log::debug() << "IncrementQG:diff incr " << *fields_ << std::endl;
74  oops::Log::debug() << "IncrementQG:diff x1 " << x1.fields() << std::endl;
75  oops::Log::debug() << "IncrementQG:diff x2 " << x2.fields() << std::endl;
76  fields_->diff(x1.fields(), x2.fields());
77 }
78 // -----------------------------------------------------------------------------
80  *fields_ = *rhs.fields_;
81  return *this;
82 }
83 // -----------------------------------------------------------------------------
85  ASSERT(this->validTime() == dx.validTime());
86  *fields_ += *dx.fields_;
87  return *this;
88 }
89 // -----------------------------------------------------------------------------
91  ASSERT(this->validTime() == dx.validTime());
92  *fields_ -= *dx.fields_;
93  return *this;
94 }
95 // -----------------------------------------------------------------------------
96 IncrementQG & IncrementQG::operator*=(const double & zz) {
97  *fields_ *= zz;
98  return *this;
99 }
100 // -----------------------------------------------------------------------------
102  fields_->zero();
103 }
104 // -----------------------------------------------------------------------------
105 void IncrementQG::zero(const util::DateTime & vt) {
106  fields_->zero(vt);
107 }
108 // -----------------------------------------------------------------------------
109 void IncrementQG::axpy(const double & zz, const IncrementQG & dx,
110  const bool check) {
111  ASSERT(!check || this->validTime() == dx.validTime());
112  fields_->axpy(zz, *dx.fields_);
113 }
114 // -----------------------------------------------------------------------------
115 void IncrementQG::accumul(const double & zz, const StateQG & xx) {
116  fields_->axpy(zz, xx.fields());
117 }
118 // -----------------------------------------------------------------------------
120  fields_->schur_product_with(*dx.fields_);
121 }
122 // -----------------------------------------------------------------------------
123 double IncrementQG::dot_product_with(const IncrementQG & other) const {
124  return dot_product(*fields_, *other.fields_);
125 }
126 // -----------------------------------------------------------------------------
128  fields_->random();
129 }
130 // -----------------------------------------------------------------------------
131 void IncrementQG::dirac(const eckit::Configuration & config) {
132  fields_->dirac(config);
133 }
134 // -----------------------------------------------------------------------------
135 /// Get increment values at observation locations
136 // -----------------------------------------------------------------------------
138  GomQG & cols, const Nothing &) const {
139  fields_->getValuesTL(locs, vars, cols);
140 }
141 // -----------------------------------------------------------------------------
143  const GomQG & cols, const Nothing &) {
144  fields_->getValuesAD(locs, vars, cols);
145 }
146 // -----------------------------------------------------------------------------
147 /// Unstructured grid
148 // -----------------------------------------------------------------------------
149 void IncrementQG::ug_coord(oops::UnstructuredGrid & ug, const int & colocated) const {
150  fields_->ug_coord(ug, colocated);
151 }
152 // -----------------------------------------------------------------------------
153 void IncrementQG::field_to_ug(oops::UnstructuredGrid & ug, const int & colocated) const {
154  fields_->field_to_ug(ug, colocated);
155 }
156 // -----------------------------------------------------------------------------
158  fields_->field_from_ug(ug);
159 }
160 // -----------------------------------------------------------------------------
161 /// I/O and diagnostics
162 // -----------------------------------------------------------------------------
163 void IncrementQG::read(const eckit::Configuration & files) {
164  fields_->read(files);
165 }
166 // -----------------------------------------------------------------------------
167 void IncrementQG::write(const eckit::Configuration & files) const {
168  fields_->write(files);
169 }
170 // -----------------------------------------------------------------------------
171 void IncrementQG::print(std::ostream & os) const {
172  os << std::endl << " Valid time: " << validTime();
173  os << *fields_;
174 }
175 // -----------------------------------------------------------------------------
176 
177 } // namespace qg
IncrementQG & operator-=(const IncrementQG &)
Definition: IncrementQG.cc:90
void field_from_ug(const oops::UnstructuredGrid &)
Definition: IncrementQG.cc:157
GomQG class to handle local model values for QG model.
Definition: GomQG.h:31
void write(const eckit::Configuration &) const
Definition: IncrementQG.cc:167
IncrementQG(const GeometryQG &, const oops::Variables &, const util::DateTime &)
Constructor, destructor.
Definition: IncrementQG.cc:38
Class to represent a FieldSet for the QG model.
Definition: FieldsQG.h:46
subroutine, public copy(self, rhs)
boost::scoped_ptr< FieldsQG > fields_
Definition: IncrementQG.h:115
void read(const eckit::Configuration &)
I/O and diagnostics.
Definition: IncrementQG.cc:163
void dirac(const eckit::Configuration &)
Definition: IncrementQG.cc:131
void schur_product_with(const IncrementQG &)
Definition: IncrementQG.cc:119
void print(std::ostream &) const
Data.
Definition: IncrementQG.cc:171
virtual ~IncrementQG()
Definition: IncrementQG.cc:64
IncrementQG & operator=(const IncrementQG &)
Definition: IncrementQG.cc:79
const util::DateTime & validTime() const
Definition: StateQG.h:77
logical debug
Definition: mpp.F90:1297
IncrementQG & operator+=(const IncrementQG &)
Definition: IncrementQG.cc:84
type(file_type), dimension(:), allocatable, save files
Definition: diag_data.F90:780
real, dimension(:,:,:), allocatable vt
const util::DateTime & validTime() const
Definition: IncrementQG.h:92
IncrementQG & operator*=(const double &)
Definition: IncrementQG.cc:96
void getValuesTL(const LocationsQG &, const oops::Variables &, GomQG &, const Nothing &) const
Get increment values at observation locations.
Definition: IncrementQG.cc:137
void ug_coord(oops::UnstructuredGrid &, const int &) const
Unstructured grid.
Definition: IncrementQG.cc:149
QG model state.
Definition: StateQG.h:50
double dot_product_with(const IncrementQG &) const
Definition: IncrementQG.cc:123
FieldsQG & fields()
Access to fields.
Definition: StateQG.h:81
GeometryQG handles geometry for QG model.
Definition: GeometryQG.h:33
LocationsQG class to handle locations for QG model.
Definition: LocationsQG.h:26
void field_to_ug(oops::UnstructuredGrid &, const int &) const
Definition: IncrementQG.cc:153
void getValuesAD(const LocationsQG &, const oops::Variables &, const GomQG &, const Nothing &)
Definition: IncrementQG.cc:142
void axpy(const double &, const IncrementQG &, const bool check=true)
Definition: IncrementQG.cc:109
void accumul(const double &, const StateQG &)
Other.
Definition: IncrementQG.cc:115
The namespace for the qg model.
void diff(const StateQG &, const StateQG &)
Basic operators.
Definition: IncrementQG.cc:70
Increment Class: Difference between two states.
Definition: IncrementQG.h:55