8 #ifndef SABER_OOPS_OOBUMP_H_
9 #define SABER_OOPS_OOBUMP_H_
18 #include "atlas/field.h"
19 #include "atlas/functionspace.h"
21 #include "eckit/config/Configuration.h"
22 #include "eckit/mpi/Comm.h"
24 #include "oops/assimilation/GMRESR.h"
25 #include "oops/base/IdentityMatrix.h"
26 #include "oops/base/Variables.h"
27 #include "oops/interface/Increment.h"
28 #include "oops/util/DateTime.h"
29 #include "oops/util/Logger.h"
39 class UnstructuredGrid;
47 template<
typename MODEL>
class OoBump {
52 OoBump(
const Geometry_ &,
const oops::Variables &,
const util::DateTime &,
53 const eckit::LocalConfiguration);
63 void addMember(
const atlas::FieldSet & atlasFieldSet,
const int &,
const int &)
const;
86 template<
typename MODEL>
88 const oops::Variables & vars,
89 const util::DateTime & time,
90 const eckit::LocalConfiguration conf) : keyOoBump_() {
92 std::vector<eckit::LocalConfiguration> grids;
96 conf.get(
"prefix", prefix);
99 if (conf.has(
"grids")) {
101 conf.get(
"grids", grids);
102 ASSERT(grids.size() > 0);
105 eckit::LocalConfiguration emptyConf;
106 grids.push_back(emptyConf);
110 for (
unsigned int jgrid = 0; jgrid < grids.size(); ++jgrid) {
112 if (!grids[jgrid].has(
"prefix")) {
113 std::ostringstream ss;
114 ss << std::setw(2) << std::setfill(
'0') << jgrid;
115 grids[jgrid].set(
"prefix", prefix +
"_" + ss.str());
119 std::vector<std::string> vars_str;
120 if (grids[jgrid].has(
"variables")) {
121 grids[jgrid].get(
"variables", vars_str);
123 for (
unsigned int jvar = 0; jvar < vars.size(); ++jvar) {
124 vars_str.push_back(vars[jvar]);
126 grids[jgrid].set(
"variables", vars_str);
128 grids[jgrid].set(
"nv", vars_str.size());
132 std::unique_ptr<atlas::FieldSet> atlasFieldSet(
new atlas::FieldSet());
133 dx.setAtlas(atlasFieldSet.get());
135 for (
unsigned int jvar = 0; jvar < vars_str.size(); ++jvar) {
136 atlas::Field atlasField = atlasFieldSet->field(vars_str[jvar]);
137 nl = std::max(nl, atlasField.levels());
139 grids[jgrid].set(
"nl", nl);
142 if (!grids[jgrid].has(
"lev2d")) {
143 grids[jgrid].set(
"lev2d",
"first");
148 ASSERT(grids.size() > 0);
151 oops::Log::info() <<
"Configuration: " << conf << std::endl;
153 for (
unsigned int jgrid = 0; jgrid < grids.size(); ++jgrid) {
155 oops::Log::info() <<
"Grid " << jgrid <<
": " << grids[jgrid] << std::endl;
160 resol.atlasFunctionSpace()->get(),
161 resol.atlasFieldSet()->get(),
167 template<
typename MODEL>
169 for (
unsigned int jgrid = 0; jgrid < other.
getSize(); ++jgrid) {
175 template<
typename MODEL>
177 for (
unsigned int jgrid = 0; jgrid < keyOoBump_.size(); ++jgrid) {
182 template<
typename MODEL>
184 const int & iens)
const {
185 for (
unsigned int jgrid = 0; jgrid < keyOoBump_.size(); ++jgrid) {
190 template<
typename MODEL>
192 for (
unsigned int jgrid = 0; jgrid < keyOoBump_.size(); ++jgrid) {
197 template<
typename MODEL>
199 std::unique_ptr<atlas::FieldSet> atlasFieldSet(
new atlas::FieldSet());
200 dxi.toAtlas(atlasFieldSet.get());
201 for (
unsigned int jgrid = 0; jgrid < keyOoBump_.size(); ++jgrid) {
204 dxo.fromAtlas(atlasFieldSet.get());
207 template<
typename MODEL>
209 std::unique_ptr<atlas::FieldSet> atlasFieldSet(
new atlas::FieldSet());
210 dxi.toAtlas(atlasFieldSet.get());
211 for (
unsigned int jgrid = 0; jgrid < keyOoBump_.size(); ++jgrid) {
214 dxo.fromAtlas(atlasFieldSet.get());
217 template<
typename MODEL>
219 std::unique_ptr<atlas::FieldSet> atlasFieldSet(
new atlas::FieldSet());
220 dxi.toAtlas(atlasFieldSet.get());
221 for (
unsigned int jgrid = 0; jgrid < keyOoBump_.size(); ++jgrid) {
224 dxo.fromAtlas(atlasFieldSet.get());
227 template<
typename MODEL>
229 std::unique_ptr<atlas::FieldSet> atlasFieldSet(
new atlas::FieldSet());
230 dxi.toAtlas(atlasFieldSet.get());
231 for (
unsigned int jgrid = 0; jgrid < keyOoBump_.size(); ++jgrid) {
234 dxo.fromAtlas(atlasFieldSet.get());
237 template<
typename MODEL>
239 std::unique_ptr<atlas::FieldSet> atlasFieldSet(
new atlas::FieldSet());
240 dxi.toAtlas(atlasFieldSet.get());
241 for (
unsigned int jgrid = 0; jgrid < keyOoBump_.size(); ++jgrid) {
244 dxo.fromAtlas(atlasFieldSet.get());
247 template<
typename MODEL>
249 std::unique_ptr<atlas::FieldSet> atlasFieldSet(
new atlas::FieldSet());
250 dxi.toAtlas(atlasFieldSet.get());
251 for (
unsigned int jgrid = 0; jgrid < keyOoBump_.size(); ++jgrid) {
254 dxo.fromAtlas(atlasFieldSet.get());
257 template<
typename MODEL>
259 std::unique_ptr<atlas::FieldSet> atlasFieldSet(
new atlas::FieldSet());
260 dx.toAtlas(atlasFieldSet.get());
261 for (
unsigned int jgrid = 0; jgrid < keyOoBump_.size(); ++jgrid) {
264 dx.fromAtlas(atlasFieldSet.get());
267 template<
typename MODEL>
269 std::unique_ptr<atlas::FieldSet> atlasFieldSet(
new atlas::FieldSet());
270 dxi.toAtlas(atlasFieldSet.get());
271 for (
unsigned int jgrid = 0; jgrid < keyOoBump_.size(); ++jgrid) {
274 dxo.fromAtlas(atlasFieldSet.get());
277 template<
typename MODEL>
279 oops::IdentityMatrix<Increment_> Id;
281 GMRESR(dxo, dxi, *
this, Id, 10, 1.0e-3);
284 template<
typename MODEL>
286 std::unique_ptr<atlas::FieldSet> atlasFieldSet(
new atlas::FieldSet());
287 dx.setAtlas(atlasFieldSet.get());
288 for (
unsigned int jgrid = 0; jgrid < keyOoBump_.size(); ++jgrid) {
291 dx.fromAtlas(atlasFieldSet.get());
294 template<
typename MODEL>
296 const int nstr = param.size();
297 const char *cstr = param.c_str();
298 std::unique_ptr<atlas::FieldSet> atlasFieldSet(
new atlas::FieldSet());
299 dx.setAtlas(atlasFieldSet.get());
300 for (
unsigned int jgrid = 0; jgrid < keyOoBump_.size(); ++jgrid) {
303 dx.fromAtlas(atlasFieldSet.get());
306 template<
typename MODEL>
308 const int nstr = param.size();
309 const char *cstr = param.c_str();
310 std::unique_ptr<atlas::FieldSet> atlasFieldSet(
new atlas::FieldSet());
311 dx.toAtlas(atlasFieldSet.get());
312 for (
unsigned int jgrid = 0; jgrid < keyOoBump_.size(); ++jgrid) {
320 #endif // SABER_OOPS_OOBUMP_H_