SABER
LocalizationBUMP.h
Go to the documentation of this file.
1 /*
2  * (C) Copyright 2017-2020 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 #ifndef SABER_OOPS_LOCALIZATIONBUMP_H_
9 #define SABER_OOPS_LOCALIZATIONBUMP_H_
10 
11 #include <memory>
12 #include <sstream>
13 #include <string>
14 #include <vector>
15 
16 #include "eckit/config/Configuration.h"
17 
18 #include "oops/base/LocalizationBase.h"
19 #include "oops/base/Variables.h"
20 #include "oops/util/DateTime.h"
21 #include "oops/util/Duration.h"
22 #include "oops/util/Logger.h"
23 
24 #include "saber/oops/OoBump.h"
26 
27 namespace eckit {
28  class Configuration;
29 }
30 
31 namespace oops {
32  class Variables;
33 }
34 
35 namespace saber {
36 
37 // -----------------------------------------------------------------------------
38 /// BUMP localization matrix.
39 
40 template<typename MODEL>
41 class LocalizationBUMP : public oops::LocalizationBase<MODEL> {
42  typedef oops::Geometry<MODEL> Geometry_;
43  typedef oops::Increment<MODEL> Increment_;
46 
47  public:
48  LocalizationBUMP(const Geometry_ &, const util::DateTime & time, const eckit::Configuration &);
50 
51  void multiply(Increment_ &) const override;
52 
53  private:
54  void print(std::ostream &) const override;
55 
56  std::unique_ptr<OoBump_> ooBump_;
57 };
58 
59 // =============================================================================
60 
61 template<typename MODEL>
63  const util::DateTime & time,
64  const eckit::Configuration & conf)
65  : ooBump_()
66 {
67 // Setup variables
68  const oops::Variables vars(conf, "localization variables");
69 
70  size_t myslot = resol.timeComm().rank();
71  if (myslot == 0) {
72  // Setup parameters
73  ParametersBUMP_ param(resol, vars, time, conf);
74 
75  // Transfer OoBump pointer
76  ooBump_.reset(new OoBump_(param.getOoBump()));
77  }
78 
79  oops::Log::trace() << "LocalizationBUMP:LocalizationBUMP constructed" << std::endl;
80 }
81 
82 // -----------------------------------------------------------------------------
83 
84 template<typename MODEL>
86  oops::Log::trace() << "LocalizationBUMP:~LocalizationBUMP destructed" << std::endl;
87 }
88 
89 // -----------------------------------------------------------------------------
90 
91 template<typename MODEL>
93  oops::Log::trace() << "LocalizationBUMP:multiply starting" << std::endl;
94  ooBump_->multiplyNicas(dx);
95  oops::Log::trace() << "LocalizationBUMP:multiply done" << std::endl;
96 }
97 
98 // -----------------------------------------------------------------------------
99 
100 template<typename MODEL>
101 void LocalizationBUMP<MODEL>::print(std::ostream & os) const {
102  os << "LocalizationBUMP:print not implemeted yet";
103 }
104 
105 // -----------------------------------------------------------------------------
106 
107 } // namespace saber
108 
109 #endif // SABER_OOPS_LOCALIZATIONBUMP_H_
saber::LocalizationBUMP::Geometry_
oops::Geometry< MODEL > Geometry_
Definition: LocalizationBUMP.h:42
oops
Definition: ErrorCovarianceBUMP.h:33
saber::ParametersBUMP
BUMP parameters.
Definition: ParametersBUMP.h:43
saber::LocalizationBUMP::print
void print(std::ostream &) const override
Definition: LocalizationBUMP.h:101
ParametersBUMP.h
saber
Definition: type_bump.h:22
saber::LocalizationBUMP::ParametersBUMP_
ParametersBUMP< MODEL > ParametersBUMP_
Definition: LocalizationBUMP.h:45
saber::OoBump
OoBump C++ interface.
Definition: OoBump.h:47
eckit
Definition: type_bump.h:18
OoBump.h
saber::ParametersBUMP::getOoBump
OoBump_ & getOoBump()
Definition: ParametersBUMP.h:60
saber::LocalizationBUMP
BUMP localization matrix.
Definition: LocalizationBUMP.h:41
saber::LocalizationBUMP::LocalizationBUMP
LocalizationBUMP(const Geometry_ &, const util::DateTime &time, const eckit::Configuration &)
Definition: LocalizationBUMP.h:62
saber::LocalizationBUMP::Increment_
oops::Increment< MODEL > Increment_
Definition: LocalizationBUMP.h:43
saber::LocalizationBUMP::ooBump_
std::unique_ptr< OoBump_ > ooBump_
Definition: LocalizationBUMP.h:56
saber::LocalizationBUMP::OoBump_
OoBump< MODEL > OoBump_
Definition: LocalizationBUMP.h:44
saber::LocalizationBUMP::~LocalizationBUMP
~LocalizationBUMP()
Definition: LocalizationBUMP.h:85
saber::LocalizationBUMP::multiply
void multiply(Increment_ &) const override
Definition: LocalizationBUMP.h:92