11 #ifndef OOPS_BASE_WEIGHTEDDIFF_H_ 12 #define OOPS_BASE_WEIGHTEDDIFF_H_ 16 #include <boost/scoped_ptr.hpp> 24 #include "oops/util/DateTime.h" 25 #include "oops/util/Duration.h" 26 #include "oops/util/Logger.h" 27 #include "oops/util/printStackTrace.h" 40 template <
typename MODEL,
typename INCR,
typename FLDS>
45 WeightedDiff(
const eckit::Configuration &,
const util::DateTime &,
const util::Duration &,
52 void doInitialize(
const FLDS &,
const util::DateTime &,
const util::Duration &)
override;
71 template <
typename MODEL,
typename INCR,
typename FLDS>
73 const util::DateTime &
vt,
74 const util::Duration & span,
75 const util::Duration & tstep,
79 wfct_(wfct), weights_(), avg_(0), sum_(0.0), linit_(
false),
80 vtime_(
vt), bgn_(
vt-span/2), end_(
vt+span/2), tstep_(tstep),
81 bgnleg_(), endleg_(), current_()
89 template <
typename MODEL,
typename INCR,
typename FLDS>
91 Log::debug() <<
"WeightedDiff: release sum = " << sum_
92 <<
", bgnleg_ = " << bgnleg_ <<
", endleg_ = " << endleg_
93 <<
", bgn_ = " << bgn_ <<
", end_ = " << end_ << std::endl;
95 ASSERT(std::abs(sum_) < 1.0
e-8);
101 template <
typename MODEL,
typename INCR,
typename FLDS>
103 const util::DateTime &
end,
104 const util::Duration & tstep) {
105 const util::DateTime bgn(xx.validTime());
106 if (!linit_ && bgn <= end_ && end >= bgn_) {
107 if (tstep_ == util::Duration(0)) tstep_ = tstep;
108 ASSERT(tstep_ > util::Duration(0));
109 weights_ = wfct_.setWeights(bgn_, end_, tstep_);
111 ASSERT(weights_.find(vtime_) != weights_.end());
112 weights_[vtime_] -= 1.0;
116 current_ = bgn-tstep;
118 <<
" bgnleg_ = " << bgnleg_ <<
", endleg_ = " << endleg_
119 <<
", bgn_ = " << bgn_ <<
", end_ = " << end_ << std::endl;
124 template <
typename MODEL,
typename INCR,
typename FLDS>
126 const util::DateTime
now(xx.validTime());
128 ASSERT(
now > current_);
129 if (((bgnleg_ < end_ && endleg_ > bgn_) || bgnleg_ == endleg_) &&
130 (
now != endleg_ ||
now == end_ ||
now == bgnleg_)) {
131 ASSERT(weights_.find(
now) != weights_.end());
132 const double zz = weights_[
now];
133 avg_->accumul(zz, xx);
136 <<
", weight = " << zz <<
", sum = " << sum_ << std::endl;
145 #endif // OOPS_BASE_WEIGHTEDDIFF_H_
void doProcessing(const FLDS &) override
Actual processing.
const util::DateTime bgn_
void doInitialize(const FLDS &, const util::DateTime &, const util::Duration &) override
Compute time average of states or increments during model run.
************************************************************************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
integer(long), parameter false
Handles post-processing of model fields.
The namespace for the main oops code.
real(fp), parameter, public e
real, dimension(:,:,:), allocatable vt
const util::DateTime end_
std::map< util::DateTime, double > weights_
Geometry< MODEL > Geometry_
Accumulator< MODEL, INCR, FLDS > * avg_
WeightedDiff(const eckit::Configuration &, const util::DateTime &, const util::Duration &, const util::Duration &, const Geometry_ &, WeightingFct &)
const util::DateTime vtime_