11 #ifndef OOPS_BASE_OBSERVER_H_ 12 #define OOPS_BASE_OBSERVER_H_ 17 #include <boost/shared_ptr.hpp> 28 #include "oops/util/DateTime.h" 29 #include "oops/util/Duration.h" 30 #include "oops/util/Logger.h" 31 #include "oops/util/Printable.h" 42 template <
typename MODEL,
typename STATE>
55 const util::Duration & tslot = util::Duration(0),
const bool subwin =
false);
60 void processTraj(
const STATE &, std::vector<boost::shared_ptr<InterpolatorTraj_> > &)
const;
65 void doInitialize(
const STATE &,
const util::DateTime &,
const util::Duration &)
override;
68 void print(std::ostream &)
const;
75 std::auto_ptr<Observations_>
yobs_;
85 std::vector<boost::shared_ptr<GeoVaLs_> >
gvals_;
88 typedef std::vector<boost::shared_ptr<InterpolatorTraj_> >
vspit;
93 template <
typename MODEL,
typename STATE>
98 const util::Duration & tslot,
const bool swin)
99 :
PostBase<STATE>(), obspace_(obsdb), hop_(hop),
101 winbgn_(obsdb.windowStart()), winend_(obsdb.windowEnd()),
102 bgn_(winbgn_), end_(winend_), hslot_(tslot/2), subwindows_(swin),
103 gvals_(0), filters_(filters)
105 Log::trace() <<
"Observer::Observer" << std::endl;
106 Log::debug() <<
"Observer filter is " << filters_ << std::endl;
109 template <
typename MODEL,
typename STATE>
111 const util::DateTime &
end,
112 const util::Duration & tstep) {
113 Log::trace() <<
"Observer::doInitialize start" << std::endl;
114 const util::DateTime bgn(xx.validTime());
115 if (hslot_ == util::Duration(0)) hslot_ = tstep/2;
125 if (bgn_ < winbgn_) bgn_ = winbgn_;
126 if (end_ > winend_) end_ = winend_;
128 for (
size_t jj = 0; jj < obspace_.size(); ++jj) {
129 boost::shared_ptr<GeoVaLs_>
tmp(
new GeoVaLs_(obspace_[jj].locations(bgn_, end_),
130 hop_.variables(jj)));
131 gvals_.push_back(
tmp);
133 Log::trace() <<
"Observer::doInitialize done" << std::endl;
136 template <
typename MODEL,
typename STATE>
138 Log::trace() <<
"Observer::doProcessing start" << std::endl;
139 util::DateTime
t1(xx.validTime()-hslot_);
140 util::DateTime
t2(xx.validTime()+hslot_);
141 if (
t1 < bgn_)
t1 = bgn_;
142 if (
t2 > end_)
t2 = end_;
145 for (
size_t jj = 0; jj < obspace_.size(); ++jj) {
146 xx.getValues(obspace_[jj].locations(
t1,
t2), hop_.variables(jj), *gvals_.at(jj));
148 Log::trace() <<
"Observer::doProcessing done" << std::endl;
151 template <
typename MODEL,
typename STATE>
153 Log::trace() <<
"Observer::processTraj start" << std::endl;
154 util::DateTime
t1(xx.validTime()-hslot_);
155 util::DateTime
t2(xx.validTime()+hslot_);
156 if (
t1 < bgn_)
t1 = bgn_;
157 if (
t2 > end_)
t2 = end_;
160 for (
size_t jj = 0; jj < obspace_.size(); ++jj) {
161 xx.getValues(obspace_[jj].locations(
t1,
t2), hop_.variables(jj), *gvals_.at(jj),
164 Log::trace() <<
"Observer::processTraj done" << std::endl;
167 template <
typename MODEL,
typename STATE>
169 Log::trace() <<
"Observer::finalizeTraj start" << std::endl;
170 for (
size_t jj = 0; jj < obspace_.size(); ++jj) {
171 htlad[jj].setTrajectory(*gvals_.at(jj), ybias_);
173 this->doFinalize(xx);
174 Log::trace() <<
"Observer::finalizeTraj done" << std::endl;
177 template <
typename MODEL,
typename STATE>
179 Log::trace() <<
"Observer::doFinalize start" << std::endl;
180 for (
size_t jj = 0; jj < obspace_.size(); ++jj) {
181 hop_[jj].simulateObs(*gvals_.at(jj), (*yobs_)[jj], ybias_);
182 filters_[jj].postFilter(*gvals_.at(jj), (*yobs_)[jj], obspace_[jj]);
185 Log::trace() <<
"Observer::doFinalize done" << std::endl;
188 template <
typename MODEL,
typename STATE>
194 #endif // OOPS_BASE_OBSERVER_H_ util::DateTime end_
End of currently active observations.
ObsSpaces< MODEL > ObsSpace_
InterpolatorTraj< MODEL > InterpolatorTraj_
const ObsAuxCtrl_ & ybias_
************************************************************************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
std::auto_ptr< Observations_ > yobs_
util::DateTime winend_
End of assimilation window.
Handles post-processing of model fields.
The namespace for the main oops code.
void doFinalize(const STATE &) override
Observations_ * release()
const ObsSpace_ & obspace_
std::vector< boost::shared_ptr< InterpolatorTraj_ > > vspit
ObsOperators< MODEL > ObsOperator_
ObsFilters< MODEL > ObsFilters_
util::DateTime winbgn_
Begining of assimilation window.
ObsAuxControl< MODEL > ObsAuxCtrl_
void finalizeTraj(const STATE &, LinearObsOperator_ &)
const ObsOperator_ & hop_
std::vector< boost::shared_ptr< GeoVaLs_ > > gvals_
Observations< MODEL > Observations_
util::Duration hslot_
Half time slot.
const ObsFilters_ filters_
Computes observation equivalent during model run.
LinearObsOperators< MODEL > LinearObsOperator_
GeoVaLs< MODEL > GeoVaLs_
void doProcessing(const STATE &) override
Actual processing.
void print(std::ostream &) const
util::DateTime bgn_
Begining of currently active observations.
void doInitialize(const STATE &, const util::DateTime &, const util::Duration &) override
Observer(const ObsSpace_ &, const ObsOperator_ &, const ObsAuxCtrl_ &, const ObsFilters_ &, const util::Duration &tslot=util::Duration(0), const bool subwin=false)
void processTraj(const STATE &, std::vector< boost::shared_ptr< InterpolatorTraj_ > > &) const