OOPS
IncrementalAssimilation.h
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 #ifndef OOPS_ASSIMILATION_INCREMENTALASSIMILATION_H_
12 #define OOPS_ASSIMILATION_INCREMENTALASSIMILATION_H_
13 
14 #include <memory>
15 #include <vector>
16 
17 #include "eckit/config/Configuration.h"
23 #include "oops/base/State.h"
24 #include "oops/base/StateInfo.h"
25 #include "oops/util/Logger.h"
26 #include "oops/util/printRunStats.h"
27 
28 namespace oops {
29 
30 template<typename MODEL, typename OBS>
32  const eckit::Configuration & config) {
33  typedef ControlIncrement<MODEL, OBS> CtrlInc_;
34  typedef Minimizer<MODEL, OBS> Minimizer_;
35  typedef State<MODEL> State_;
36 
37  util::printRunStats("IncrementalAssimilation start");
38 
39 // Setup outer loop
40  std::vector<eckit::LocalConfiguration> iterconfs;
41  config.get("iterations", iterconfs);
42  const unsigned int nouter = iterconfs.size();
43  Log::info() << "Running incremental assimilation with " << nouter
44  << " outer iterations." << std::endl;
45 
46 // Setup minimizer
47  eckit::LocalConfiguration minConf(config, "minimizer");
48  minConf.set("nouter", static_cast<const int>(nouter));
49  std::unique_ptr<Minimizer_> minim(MinFactory<MODEL, OBS>::create(minConf, J));
50 
51  for (unsigned jouter = 0; jouter < nouter; ++jouter) {
52  iterconfs[jouter].set("iteration", static_cast<int>(jouter));
53 // Get configuration for current outer iteration
54  Log::info() << "IncrementalAssimilation: Configuration for outer iteration "
55  << jouter << ":" << std::endl << iterconfs[jouter] << std::endl;
56  util::printRunStats("IncrementalAssimilation iteration " + std::to_string(jouter));
57 
58 // Setup for the trajectory run
60  if (iterconfs[jouter].has("prints")) {
61  const eckit::LocalConfiguration prtConfig(iterconfs[jouter], "prints");
62  post.enrollProcessor(new StateInfo<State_>("traj", prtConfig));
63  }
64 
65 // Setup quadratic problem
66  J.linearize(xx, iterconfs[jouter], post);
67  util::printRunStats("IncrementalAssimilation linearize " + std::to_string(jouter));
68 
69 // Minimization
70  std::unique_ptr<CtrlInc_> dx(minim->minimize(iterconfs[jouter]));
71 
72 // Compute analysis in physical space
73  J.addIncrement(xx, *dx);
74 
75 // Clean-up trajectory, etc...
77  }
78  util::printRunStats("IncrementalAssimilation end");
79  return nouter;
80 }
81 
82 } // namespace oops
83 #endif // OOPS_ASSIMILATION_INCREMENTALASSIMILATION_H_
Control variable.
Cost Function.
Definition: CostFunction.h:53
void addIncrement(CtrlVar_ &, const CtrlInc_ &, PostProcessor< Increment_ > post=PostProcessor< Increment_ >()) const
Definition: CostFunction.h:312
double linearize(const CtrlVar_ &, const eckit::Configuration &, PostProcessor< State_ > post=PostProcessor< State_ >())
Definition: CostFunction.h:254
Minimizer Factory.
Definition: Minimizer.h:370
A Minimizer knows how to minimize a cost function.
Definition: Minimizer.h:37
Control model post processing.
Definition: PostProcessor.h:30
void enrollProcessor(PostBase_ *pp)
Definition: PostProcessor.h:38
State class used in oops; subclass of interface class interface::State.
Handles writing-out of forecast fields.
Definition: StateInfo.h:28
logical function has(this, var)
The namespace for the main oops code.
int IncrementalAssimilation(ControlVariable< MODEL, OBS > &xx, CostFunction< MODEL, OBS > &J, const eckit::Configuration &config)