FV3 Bundle
src/lorenz95/ModelBiasCorrection.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 
12 
13 #include <iostream>
14 #include <string>
15 
16 #include "eckit/config/Configuration.h"
17 #include "lorenz95/ModelBias.h"
19 #include "oops/util/Logger.h"
20 
21 // -----------------------------------------------------------------------------
22 namespace lorenz95 {
23 // -----------------------------------------------------------------------------
24 ModelBiasCorrection::ModelBiasCorrection(const Resolution &, const eckit::Configuration & conf)
25  : bias_(0.0), active_(conf.has("standard_deviation"))
26 {
27  if (active_) {
28  oops::Log::trace() << "ModelBiasCorrection::ModelBiasCorrection created." << std::endl;
29  }
30 }
31 // -----------------------------------------------------------------------------
33  const bool copy)
34  : bias_(0.0), active_(other.active_)
35 {
36  if (active_ && copy) bias_ = other.bias_;
37 }
38 // -----------------------------------------------------------------------------
40  const eckit::Configuration &)
41  : bias_(0.0), active_(other.active_)
42 {
43  if (active_) bias_ = other.bias_;
44 }
45 // -----------------------------------------------------------------------------
47  if (active_) bias_ = b1.bias() - b2.bias();
48 }
49 // -----------------------------------------------------------------------------
51  bias_ = 0.0;
52 }
53 // -----------------------------------------------------------------------------
55  if (active_) {
56  bias_ = rhs.bias_;
57  } else {
58  bias_ = 0.0;
59  }
60  return *this;
61 }
62 // -----------------------------------------------------------------------------
64  if (active_) bias_ += rhs.bias_;
65  return *this;
66 }
67 // -----------------------------------------------------------------------------
69  if (active_) bias_ -= rhs.bias_;
70  return *this;
71 }
72 // -----------------------------------------------------------------------------
74  if (active_) bias_ *= fact;
75  return *this;
76 }
77 // -----------------------------------------------------------------------------
78 void ModelBiasCorrection::axpy(const double fact, const ModelBiasCorrection & rhs) {
79  if (active_) bias_ += fact * rhs.bias_;
80 }
81 // -----------------------------------------------------------------------------
83  double zz = 0.0;
84  if (active_) zz = bias_ * rhs.bias_;
85  return zz;
86 }
87 // -----------------------------------------------------------------------------
88 void ModelBiasCorrection::print(std::ostream & os) const {
89  if (active_) {os << std::endl << "ModelBiasCorrection = " << bias_;}
90 }
91 // -----------------------------------------------------------------------------
92 } // namespace lorenz95
ModelBiasCorrection(const Resolution &, const eckit::Configuration &)
Constructor, destructor.
real, parameter b1
ModelBiasCorrection & operator=(const ModelBiasCorrection &)
subroutine, public copy(self, rhs)
Definition: conf.py:1
void diff(const ModelBias &, const ModelBias &)
Linear algebra operators.
Handles resolution.
Definition: Resolution.h:25
The namespace for the L95 model.
ModelBiasCorrection & operator*=(const double)
double dot_product_with(const ModelBiasCorrection &) const
Model error for Lorenz 95 model.
ModelBiasCorrection & operator+=(const ModelBiasCorrection &)
ModelBiasCorrection & operator-=(const ModelBiasCorrection &)
void axpy(const double, const ModelBiasCorrection &)
real, parameter b2