11 #ifndef OOPS_BASE_OBSERVERTLAD_H_ 12 #define OOPS_BASE_OBSERVERTLAD_H_ 17 #include <boost/scoped_ptr.hpp> 18 #include <boost/shared_ptr.hpp> 33 #include "oops/util/DateTime.h" 34 #include "oops/util/Duration.h" 40 template <
typename MODEL>
57 const util::Duration & tslot = util::Duration(0),
const bool subwin =
false);
68 const util::DateTime &,
const util::Duration &)
override;
73 const util::DateTime &,
const util::Duration &)
override;
89 boost::shared_ptr<const Departures_>
ydepad_;
99 std::vector<std::vector<boost::shared_ptr<InterpolatorTraj_> > >
traj_;
103 std::vector<boost::shared_ptr<GeoVaLs_> >
gvals_;
107 template <
typename MODEL>
112 const util::Duration & tslot,
const bool subwin)
113 :
PostBaseTLAD<MODEL>(obsdb.windowStart(), obsdb.windowEnd()),
114 obspace_(obsdb), hoptlad_(obspace_),
115 observer_(obspace_, hop, ybias, filters, tslot, subwin),
116 ydeptl_(), ybiastl_(), ydepad_(), ybiasad_(),
117 winbgn_(obsdb.windowStart()), winend_(obsdb.windowEnd()),
118 bgn_(winbgn_), end_(winend_), hslot_(tslot/2), subwindows_(subwin)
120 Log::trace() <<
"ObserverTLAD::ObserverTLAD" << std::endl;
123 template <
typename MODEL>
125 const util::DateTime &
end,
const util::Duration & tstep) {
126 Log::trace() <<
"ObserverTLAD::doInitializeTraj start" << std::endl;
130 nsteps = 1+(winend_-winbgn_).toSeconds() / tstep.toSeconds();
131 for (std::size_t ib = 0; ib < nsteps; ++ib) {
132 std::vector<boost::shared_ptr<InterpolatorTraj_> > obstraj;
133 for (std::size_t jj = 0; jj < obspace_.size(); ++jj) {
135 obstraj.push_back(traj);
137 traj_.push_back(obstraj);
140 observer_.initialize(xx,
end, tstep);
141 Log::trace() <<
"ObserverTLAD::doInitializeTraj done" << std::endl;
144 template <
typename MODEL>
146 Log::trace() <<
"ObserverTLAD::doProcessingTraj start" << std::endl;
149 int ib = (xx.
validTime()-winbgn_).toSeconds() / bintstep.toSeconds();
152 observer_.processTraj(xx, traj_[ib]);
154 Log::trace() <<
"ObserverTLAD::doProcessingTraj done" << std::endl;
157 template <
typename MODEL>
159 Log::trace() <<
"ObserverTLAD::doFinalizeTraj start" << std::endl;
160 observer_.finalizeTraj(xx, hoptlad_);
161 Log::trace() <<
"ObserverTLAD::doFinalizeTraj done" << std::endl;
164 template <
typename MODEL>
166 Log::trace() <<
"ObserverTLAD::setupTL start" << std::endl;
169 Log::trace() <<
"ObserverTLAD::setupTL done" << std::endl;
172 template <
typename MODEL>
174 const util::DateTime &
end,
const util::Duration & tstep) {
175 Log::trace() <<
"ObserverTLAD::doInitializeTL start" << std::endl;
176 const util::DateTime bgn(dx.
validTime());
177 if (hslot_ == util::Duration(0)) hslot_ = tstep/2;
187 if (bgn_ < winbgn_) bgn_ = winbgn_;
188 if (end_ > winend_) end_ = winend_;
190 for (std::size_t jj = 0; jj < obspace_.size(); ++jj) {
191 boost::shared_ptr<GeoVaLs_>
192 gom(
new GeoVaLs_(obspace_[jj].locations(bgn_, end_), hoptlad_.variables(jj)));
193 gvals_.push_back(gom);
195 Log::trace() <<
"ObserverTLAD::doInitializeTL done" << std::endl;
198 template <
typename MODEL>
200 Log::trace() <<
"ObserverTLAD::doProcessingTL start" << std::endl;
203 if (
t1 < bgn_)
t1 = bgn_;
204 if (
t2 > end_)
t2 = end_;
207 int ib = (dx.
validTime()-winbgn_).toSeconds() / bintstep.toSeconds();
210 for (std::size_t jj = 0; jj < obspace_.size(); ++jj) {
212 *gvals_.at(jj), *traj_.at(ib).at(jj));
214 Log::trace() <<
"ObserverTLAD::doProcessingTL done" << std::endl;
217 template <
typename MODEL>
219 Log::trace() <<
"ObserverTLAD::doFinalizeTL start" << std::endl;
220 for (std::size_t jj = 0; jj < obspace_.size(); ++jj) {
221 hoptlad_[jj].simulateObsTL(*gvals_.at(jj), (*ydeptl_)[jj], *ybiastl_);
224 Log::trace() <<
"ObserverTLAD::doFinalizeTL done" << std::endl;
227 template <
typename MODEL>
230 Log::trace() <<
"ObserverTLAD::setupAD start" << std::endl;
233 Log::trace() <<
"ObserverTLAD::setupAD done" << std::endl;
236 template <
typename MODEL>
238 const util::Duration & tstep) {
239 Log::trace() <<
"ObserverTLAD::doFirstAD start" << std::endl;
240 if (hslot_ == util::Duration(0)) hslot_ = tstep/2;
251 if (bgn_ < winbgn_) bgn_ = winbgn_;
252 if (end_ > winend_) end_ = winend_;
254 for (std::size_t jj = 0; jj < obspace_.size(); ++jj) {
255 boost::shared_ptr<GeoVaLs_>
256 gom(
new GeoVaLs_(obspace_[jj].locations(bgn_, end_), hoptlad_.variables(jj)));
257 hoptlad_[jj].simulateObsAD(*gom, (*ydepad_)[jj], *ybiasad_);
258 gvals_.push_back(gom);
260 Log::trace() <<
"ObserverTLAD::doFirstAD done" << std::endl;
263 template <
typename MODEL>
265 Log::trace() <<
"ObserverTLAD::doProcessingAD start" << std::endl;
268 if (
t1 < bgn_)
t1 = bgn_;
269 if (
t2 > end_)
t2 = end_;
272 int ib = (dx.
validTime()-winbgn_).toSeconds() / bintstep.toSeconds();
275 for (std::size_t jj = 0; jj < obspace_.size(); ++jj) {
277 *gvals_.at(jj), *traj_.at(ib).at(jj));
279 Log::trace() <<
"ObserverTLAD::doProcessingAD done" << std::endl;
282 template <
typename MODEL>
284 Log::trace() <<
"ObserverTLAD::doLastAD start" << std::endl;
286 Log::trace() <<
"ObserverTLAD::doLastAD done" << std::endl;
292 #endif // OOPS_BASE_OBSERVERTLAD_H_ ObsOperators< MODEL > ObsOperators_
ObserverTLAD(const ObsSpace_ &, const ObsOperators_ &, const ObsAuxCtrl_ &, const ObsFilters_ &, const util::Duration &tslot=util::Duration(0), const bool subwin=false)
void doProcessingAD(Increment_ &) override
util::DateTime winbgn_
Begining of assimilation window.
Departures_ * releaseOutputFromTL() override
Return TL dual space output.
util::Duration hslot_
Half time slot.
void getValuesAD(const Locations_ &, const Variables &, const GeoVaLs_ &, const InterpolatorTraj_ &)
void setupAD(boost::shared_ptr< const Departures_ >, ObsAuxIncr_ &)
Observations_ * release()
Difference between two observation vectors.
************************************************************************GNU Lesser General Public License **This file is part of the GFDL Flexible Modeling System(FMS). ! *! *FMS is free software without even the implied warranty of MERCHANTABILITY or *FITNESS FOR A PARTICULAR PURPOSE See the GNU General Public License *for more details **You should have received a copy of the GNU Lesser General Public *License along with FMS If see< http:! ***********************************************************************!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! MPP_TRANSMIT !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! subroutine MPP_TRANSMIT_(put_data, put_len, to_pe, get_data, get_len, from_pe, block, tag, recv_request, send_request)!a message-passing routine intended to be reminiscent equally of both MPI and SHMEM!put_data and get_data are contiguous MPP_TYPE_ arrays!at each call, your put_data array is put to to_pe 's get_data! your get_data array is got from from_pe 's put_data!i.e we assume that typically(e.g updating halo regions) each PE performs a put _and_ a get!special PE designations:! NULL_PE:to disable a put or a get(e.g at boundaries)! ANY_PE:if remote PE for the put or get is to be unspecific! ALL_PES:broadcast and collect operations(collect not yet implemented)!ideally we would not pass length, but this f77-style call performs better(arrays passed by address, not descriptor)!further, this permits< length > contiguous words from an array of any rank to be passed(avoiding f90 rank conformance check)!caller is responsible for completion checks(mpp_sync_self) before and after integer, intent(in) ::put_len, to_pe, get_len, from_pe MPP_TYPE_, intent(in) ::put_data(*) MPP_TYPE_, intent(out) ::get_data(*) logical, intent(in), optional ::block integer, intent(in), optional ::tag integer, intent(out), optional ::recv_request, send_request logical ::block_comm integer ::i MPP_TYPE_, allocatable, save ::local_data(:) !local copy used by non-parallel code(no SHMEM or MPI) integer ::comm_tag integer ::rsize if(.NOT.module_is_initialized) call mpp_error(FATAL, 'MPP_TRANSMIT:You must first call mpp_init.') if(to_pe.EQ.NULL_PE .AND. from_pe.EQ.NULL_PE) return block_comm=.true. if(PRESENT(block)) block_comm=block if(debug) then call SYSTEM_CLOCK(tick) write(stdout_unit,'(a, i18, a, i6, a, 2i6, 2i8)')&'T=', tick, ' PE=', pe, ' MPP_TRANSMIT begin:to_pe, from_pe, put_len, get_len=', to_pe, from_pe, put_len, get_len end if comm_tag=DEFAULT_TAG if(present(tag)) comm_tag=tag!do put first and then get if(to_pe.GE.0 .AND. to_pe.LT.npes) then!use non-blocking sends if(debug .and.(current_clock.NE.0)) call SYSTEM_CLOCK(start_tick)!z1l:truly non-blocking send.! if(request(to_pe).NE.MPI_REQUEST_NULL) then !only one message from pe-> to_pe in queue *PE waiting for to_pe ! call error else get_len so only do gets but you cannot have a pure get with MPI call a get means do a wait to ensure put on remote PE is complete error call increase mpp_nml request_multiply call MPP_TRANSMIT end
ObsAuxIncrement< MODEL > ObsAuxIncr_
const util::DateTime validTime() const
Time.
const ObsSpace_ & obspace_
Handles post-processing of model fields related to cost function.
Increment< MODEL > Increment_
Encapsulates the model state.
boost::shared_ptr< const Departures_ > ydepad_
Observer< MODEL, State_ > observer_
void doFinalizeTraj(const State_ &) override
void doLastAD(Increment_ &) override
InterpolatorTraj< MODEL > InterpolatorTraj_
The namespace for the main oops code.
ObsFilters< MODEL > ObsFilters_
const ObsAuxIncr_ * ybiastl_
std::auto_ptr< Departures_ > ydeptl_
util::DateTime end_
End of currently active observations.
std::vector< boost::shared_ptr< GeoVaLs_ > > gvals_
void doProcessingTraj(const State_ &) override
Departures< MODEL > Departures_
Computes observation equivalent during model run.
Observations< MODEL > Observations_
Increment Class: Difference between two states.
void doInitializeTL(const Increment_ &, const util::DateTime &, const util::Duration &) override
void doFirstAD(Increment_ &, const util::DateTime &, const util::Duration &) override
util::DateTime bgn_
Begining of currently active observations.
ObsSpaces< MODEL > ObsSpace_
void getValuesTL(const Locations_ &, const Variables &, GeoVaLs_ &, const InterpolatorTraj_ &) const
Get increment values at observation locations.
void doInitializeTraj(const State_ &, const util::DateTime &, const util::Duration &) override
util::DateTime winend_
End of assimilation window.
void setupTL(const ObsAuxIncr_ &)
std::vector< std::vector< boost::shared_ptr< InterpolatorTraj_ > > > traj_
void doProcessingTL(const Increment_ &) override
ObsAuxControl< MODEL > ObsAuxCtrl_
GeoVaLs< MODEL > GeoVaLs_
LinearObsOperators< MODEL > LinearObsOperators_
void doFinalizeTL(const Increment_ &) override
Computes observation equivalent TL and AD to/from increments.
LinearObsOperators_ hoptlad_
const util::DateTime validTime() const
Time.