11 #ifndef OOPS_RUNS_DIRAC_H_
12 #define OOPS_RUNS_DIRAC_H_
19 #include "eckit/config/Configuration.h"
30 #include "oops/util/DateTime.h"
31 #include "oops/util/Duration.h"
32 #include "oops/util/Logger.h"
47 instantiateCovarFactory<MODEL>();
52 int execute(
const eckit::Configuration & fullConfig)
const {
53 const eckit::LocalConfiguration backgroundConfig(fullConfig,
"initial condition");
54 std::vector<eckit::LocalConfiguration> confs;
55 backgroundConfig.get(
"states", confs);
56 size_t nslots = confs.size();
58 const eckit::mpi::Comm * commSpace = &this->
getComm();
61 size_t ntasks = this->
getComm().size();
62 ASSERT(ntasks % nslots == 0);
63 size_t myrank = this->
getComm().rank();
64 size_t ntaskpslot = ntasks / nslots;
65 size_t myslot = myrank / ntaskpslot;
68 std::string sgeom =
"comm_geom_" + std::to_string(myslot);
69 char const *geomName = sgeom.c_str();
70 commSpace = &this->
getComm().split(myslot, geomName);
71 ASSERT(commSpace->size() == ntaskpslot);
74 size_t myarea = commSpace->rank();
75 std::string stime =
"comm_time_" + std::to_string(myarea);
76 char const *timeName = stime.c_str();
77 commTime = &this->
getComm().split(myarea, timeName);
78 ASSERT(commTime->size() == nslots);
82 const eckit::LocalConfiguration resolConfig(fullConfig,
"geometry");
83 const Geometry_ resol(resolConfig, *commSpace, *commTime);
86 State_ xx(resol, backgroundConfig);
95 const eckit::LocalConfiguration covarConfig(fullConfig,
"background error");
99 covarConfig, resol, vars, xx, xx));
104 const eckit::LocalConfiguration diracConfig(fullConfig,
"dirac");
105 dxdirin.
dirac(diracConfig);
106 Log::test() <<
"Input Dirac increment: " << dxdirin << std::endl;
109 B->multiply(dxdirin, dxdirout);
112 const eckit::LocalConfiguration output_B(fullConfig,
"output B");
113 dxdirout.
write(output_B);
114 Log::test() <<
"B * Increment: " << dxdirout << std::endl;
117 std::vector<eckit::LocalConfiguration> locConfigs;
118 if (covarConfig.has(
"localization")) {
119 locConfigs.push_back(eckit::LocalConfiguration(covarConfig,
"localization"));
121 if (covarConfig.has(
"components")) {
122 std::vector<eckit::LocalConfiguration> confs;
123 covarConfig.get(
"components", confs);
124 for (
const auto & conf : confs) {
125 const eckit::LocalConfiguration componentConf(conf,
"covariance");
126 if (componentConf.has(
"localization")) {
127 locConfigs.push_back(eckit::LocalConfiguration(componentConf,
"localization"));
133 for (
size_t jcomp = 0; jcomp < locConfigs.size(); ++jcomp) {
138 const eckit::LocalConfiguration diracConfig(fullConfig,
"dirac");
139 dxdir.
dirac(diracConfig);
148 const eckit::LocalConfiguration output_localization(fullConfig,
"output localization");
149 dxdir.
write(output_localization);
150 Log::test() <<
"Localized Increment: " << dxdir << std::endl;
153 if (fullConfig.has(
"output variance")) {
155 const eckit::LocalConfiguration output_variance(fullConfig,
"output variance");
161 B->getVariance(variance);
164 variance.
write(output_variance);
165 Log::test() <<
"Randomized variance: " << variance << std::endl;
173 return "oops::Dirac<" + MODEL::name() +
">";
const eckit::mpi::Comm & getComm() const
IncrementEnsemble< MODEL > Ensemble_
std::shared_ptr< IncrementEnsemble< MODEL > > EnsemblePtr_
Increment< MODEL > Increment_
Geometry< MODEL > Geometry_
Dirac(const eckit::mpi::Comm &comm=oops::mpi::world())
std::string appname() const
int execute(const eckit::Configuration &fullConfig) const
Localization< MODEL > Localization_
Geometry class used in oops; subclass of interface class interface::Geometry.
Increment class used in oops.
Abstract model-space localization class used by high level algorithms and applications.
virtual void multiply(Increment_ &dx) const
State class used in oops; subclass of interface class interface::State.
void dirac(const eckit::Configuration &)
Set Increment according to the configuration (used in Dirac application)
void write(const eckit::Configuration &) const
Write this Increment out to file.
const util::DateTime validTime() const
Accessor to the time of this State.
const Variables & variables() const
Accessor to variables associated with this State.
const eckit::mpi::Comm & myself()
Default communicator with each MPI task by itself.
const eckit::mpi::Comm & world()
Default communicator with all MPI tasks (ie MPI_COMM_WORLD)
The namespace for the main oops code.