11 #ifndef OOPS_ASSIMILATION_COSTFCT4DENSVAR_H_ 12 #define OOPS_ASSIMILATION_COSTFCT4DENSVAR_H_ 16 #include "eckit/config/LocalConfiguration.h" 31 #include "oops/util/DateTime.h" 32 #include "oops/util/Duration.h" 33 #include "oops/util/Logger.h" 64 const bool idModel =
false)
const override;
67 const bool idModel =
false)
const override;
94 template<
typename MODEL>
99 windowLength_ = util::Duration(config.getString(
"window_length"));
100 windowBegin_ = util::DateTime(config.getString(
"window_begin"));
102 windowSub_ = util::Duration(config.getString(
"window_sub"));
108 Log::trace() <<
"CostFct4DEnsVar constructed" << std::endl;
113 template <
typename MODEL>
122 template <
typename MODEL>
124 return new CostJo<MODEL>(joConf, windowBegin_, windowEnd_, windowSub_,
true);
129 template <
typename MODEL>
132 const eckit::LocalConfiguration jcdfi(jcConf,
"jcdfi");
133 const util::DateTime
vt(windowBegin_ + windowLength_/2);
139 template <
typename MODEL>
142 State_ xm(xx.
state()[0].geometry(), CostFct_::getModel().variables(), windowBegin_);
143 for (
unsigned int jsub = 0; jsub <= ncontrol_; ++jsub) {
144 util::DateTime
now(windowBegin_ + jsub*windowSub_);
146 ASSERT(xx.
state()[jsub].validTime() ==
now);
147 xm = xx.
state()[jsub];
148 CostFct_::getModel().forecast(xm, xx.
modVar(), util::Duration(0), post);
149 xx.
state()[jsub] = xm;
150 ASSERT(xx.
state()[jsub].validTime() ==
now);
156 template<
typename MODEL>
158 const eckit::Configuration & innerConf,
160 Log::trace() <<
"CostFct4DEnsVar::doLinearize start" << std::endl;
161 eckit::LocalConfiguration
conf(innerConf,
"linearmodel");
164 an2model_->setInputVariables(ctlvars_);
165 an2model_->setOutputVariables(CostFct_::getTLM().variables());
166 Log::trace() <<
"CostFct4DEnsVar::doLinearize done" << std::endl;
171 template <
typename MODEL>
178 for (
unsigned int jsub = 0; jsub <= ncontrol_; ++jsub) {
179 util::DateTime
now(windowBegin_ + jsub*windowSub_);
181 ASSERT(dx.
state()[jsub].validTime() ==
now);
182 an2model_->multiply(dx.
state()[jsub], dxmodel);
183 CostFct_::getTLM(jsub).forecastTL(dxmodel, dx.
modVar(), util::Duration(0), post, cost);
184 an2model_->multiplyInverse(dxmodel, dx.
state()[jsub]);
185 ASSERT(dx.
state()[jsub].validTime() ==
now);
191 template <
typename MODEL>
193 util::DateTime
now(windowBegin_);
194 for (
unsigned int jsub = 0; jsub <= ncontrol_; ++jsub) {
204 template <
typename MODEL>
211 for (
int jsub = ncontrol_; jsub >= 0; --jsub) {
212 util::DateTime
now(windowBegin_ + jsub*windowSub_);
214 ASSERT(dx.
state()[jsub].validTime() ==
now);
215 an2model_->multiplyInverseAD(dx.
state()[jsub], dxmodel);
216 CostFct_::getTLM(jsub).forecastAD(dxmodel, dx.
modVar(), util::Duration(0), post, cost);
217 an2model_->multiplyAD(dxmodel, dx.
state()[jsub]);
218 ASSERT(dx.
state()[jsub].validTime() ==
now);
224 template<
typename MODEL>
227 for (
unsigned jsub = 0; jsub <= ncontrol_; ++jsub) {
236 #endif // OOPS_ASSIMILATION_COSTFCT4DENSVAR_H_ void addIncr(CtrlVar_ &, const CtrlInc_ &, PostProcessor< Increment_ > &) const override
State4D_ & state()
Get state control variable.
ControlIncrement< MODEL > CtrlInc_
void zeroAD(CtrlInc_ &) const override
Increment< MODEL > Increment_
ObsAuxIncr_ & obsVar()
Get augmented observation control variable.
ModelAuxIncr_ & modVar()
Get augmented model control variable.
void doLinearize(const Geometry_ &, const eckit::Configuration &, const CtrlVar_ &, const CtrlVar_ &) override
void runNL(CtrlVar_ &, PostProcessor< State_ > &) const override
Geometry< MODEL > Geometry_
util::Duration windowSub_
void runTLM(CtrlInc_ &, PostProcessorTLAD< MODEL > &, PostProcessor< Increment_ >, const bool idModel=false) const override
Encapsulates the model state.
boost::scoped_ptr< ChangeVar_ > an2model_
LinearVariableChangeBase< MODEL > ChangeVar_
CostFunction< MODEL > CostFct_
The namespace for the main oops code.
ControlVariable< MODEL > CtrlVar_
ModelAux_ & modVar()
Get augmented model control variable.
real, dimension(:,:,:), allocatable vt
Increment4D_ & state()
Get state control variable.
util::DateTime windowEnd_
CostTermBase< MODEL > * newJc(const eckit::Configuration &, const Geometry_ &) const override
CostJb4D< MODEL > * newJb(const eckit::Configuration &, const Geometry_ &, const CtrlVar_ &) const override
LinearVariableChangeFactory Factory.
Control model post processing.
Base class for generic variable transform.
Encapsulates the nonlinear forecast model.
CostFct4DEnsVar(const eckit::Configuration &, const Geometry_ &, const Model_ &)
Increment Class: Difference between two states.
Base Class for Cost Function Terms.
Geometry_ geometry() const
Get geometry.
Control model post processing.
CostJo< MODEL > * newJo(const eckit::Configuration &) const override
void setupTerms(const eckit::Configuration &)
void runADJ(CtrlInc_ &, PostProcessorTLAD< MODEL > &, PostProcessor< Increment_ >, const bool idModel=false) const override
util::DateTime windowBegin_
util::Duration windowLength_