FV3 Bundle
PostTimer.cc
Go to the documentation of this file.
1 /*
2  * (C) Copyright 2009-2016 ECMWF.
3  *
4  * This software is licensed under the terms of the Apache Licence Version 2.0
5  * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
6  * In applying this licence, ECMWF does not waive the privileges and immunities
7  * granted to it by virtue of its status as an intergovernmental organisation nor
8  * does it submit to any jurisdiction.
9  */
10 
11 #include "oops/base/PostTimer.h"
12 
13 #include <algorithm>
14 #include <string>
15 #include <vector>
16 #include <boost/tokenizer.hpp>
17 
18 #include "eckit/config/LocalConfiguration.h"
19 #include "oops/util/abor1_cpp.h"
20 #include "oops/util/DateTime.h"
21 #include "oops/util/Duration.h"
22 #include "oops/util/Logger.h"
23 
24 namespace oops {
25 // -----------------------------------------------------------------------------
27  : conf_(), freq_(0), bgn_(), end_(), start_(0), finish_(0), pptimes_() {}
28 // -----------------------------------------------------------------------------
29 PostTimer::PostTimer(const util::Duration & freq)
30  : conf_(), freq_(freq), bgn_(), end_(), start_(0), finish_(0), pptimes_() {}
31 // -----------------------------------------------------------------------------
32 PostTimer::PostTimer(const eckit::Configuration & conf)
33  : conf_(conf), freq_(0), bgn_(), end_(), start_(0), finish_(0), pptimes_() {}
34 // -----------------------------------------------------------------------------
35 PostTimer::PostTimer(const util::DateTime & start, const eckit::Configuration & conf)
36  : conf_(conf), freq_(0), bgn_(), end_(), start_(new util::DateTime(start)),
37  finish_(0), pptimes_()
38 {}
39 // -----------------------------------------------------------------------------
40 PostTimer::PostTimer(const util::DateTime & start, const util::DateTime & finish,
41  const util::Duration & freq)
42  : conf_(), freq_(freq), bgn_(), end_(), start_(new util::DateTime(start)),
43  finish_(new util::DateTime(finish)), pptimes_() {}
44 // -----------------------------------------------------------------------------
45 void PostTimer::initialize(const util::DateTime & bgn, const util::DateTime & end,
46  const util::Duration &) {
47  util::DateTime start(bgn);
48  if (start_ != 0) {
49  start = *start_;
50  }
51  bgn_ = start;
52  util::DateTime finish(end);
53  if (finish_ != 0) {
54  finish = *finish_;
55  }
56  end_ = finish;
57 
58 // User specified configuration
59  Log::debug() << "PProc configuration is:" << conf_ << std::endl;
60 // User specified frequency and start
61  if (conf_.has("frequency"))
62  freq_ = util::Duration(conf_.getString("frequency"));
63  if (conf_.has("first")) {
64  const util::Duration first(conf_.getString("first"));
65  bgn_ += first;
66  }
67 // User specified steps
68  if (conf_.has("steps")) {
69  const std::string steps = conf_.getString("steps");
70  boost::tokenizer<> tok(steps);
71  for (boost::tokenizer<>::iterator it = tok.begin(); it != tok.end(); ++it) {
72  const util::Duration step(*it);
73  const util::DateTime tt = start+step;
74  if (bgn <= tt && tt <= end) pptimes_.push_back(tt);
75  }
76  }
77 }
78 // -----------------------------------------------------------------------------
79 bool PostTimer::itIsTime(const util::DateTime & now) {
80  bool doit = false;
81  if (now >= bgn_ && now <= end_) {
82  doit = (freq_.toSeconds() == 0 && pptimes_.empty());
83  if (!doit && freq_.toSeconds() > 0) {
84  const util::Duration dt = now - bgn_;
85  doit = (dt >= util::Duration(0) && dt % freq_ == 0);
86  }
87  if (!doit && !pptimes_.empty()) {
88  std::vector<util::DateTime>::iterator it;
89  it = find(pptimes_.begin(), pptimes_.end(), now);
90  doit = (it != pptimes_.end());
91  }
92  }
93  Log::trace() << "In PostTimer:itIsTime, time = " << now << ", doit = " << doit << std::endl;
94  return doit;
95 }
96 // -----------------------------------------------------------------------------
97 } // namespace oops
boost::scoped_ptr< util::DateTime > start_
Definition: PostTimer.h:50
************************************************************************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
Definition: conf.py:1
PostTimer()
Definition: PostTimer.cc:26
boost::scoped_ptr< util::DateTime > finish_
Definition: PostTimer.h:51
const eckit::LocalConfiguration conf_
Definition: PostTimer.h:46
The namespace for the main oops code.
logical debug
Definition: mpp.F90:1297
************************************************************************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:! ***********************************************************************subroutine READ_RECORD_CORE_(unit, field, nwords, data, start, axsiz) integer, intent(in) ::unit type(fieldtype), intent(in) ::field integer, intent(in) ::nwords MPP_TYPE_, intent(inout) ::data(nwords) integer, intent(in) ::start(:), axsiz(:) integer(SHORT_KIND) ::i2vals(nwords)!rab used in conjunction with transfer intrinsic to determine size of a variable integer(KIND=1) ::one_byte(8) integer ::word_sz!#ifdef __sgi integer(INT_KIND) ::ivals(nwords) real(FLOAT_KIND) ::rvals(nwords)!#else! integer ::ivals(nwords)! real ::rvals(nwords)!#endif real(DOUBLE_KIND) ::r8vals(nwords) pointer(ptr1, i2vals) pointer(ptr2, ivals) pointer(ptr3, rvals) pointer(ptr4, r8vals) if(mpp_io_stack_size< nwords) call mpp_io_set_stack_size(nwords) call mpp_error(FATAL, 'MPP_READ currently requires use_netCDF option') end subroutine READ_RECORD_CORE_ subroutine READ_RECORD_(unit, field, nwords, data, time_level, domain, position, tile_count, start_in, axsiz_in)!routine that is finally called by all mpp_read routines to perform the read!a non-netCDF record contains:! field ID! a set of 4 coordinates(is:ie, js:je) giving the data subdomain! a timelevel and a timestamp(=NULLTIME if field is static)! 3D real data(stored as 1D)!if you are using direct access I/O, the RECL argument to OPEN must be large enough for the above!in a global direct access file, record position on PE is given by %record.!Treatment of timestamp:! We assume that static fields have been passed without a timestamp.! Here that is converted into a timestamp of NULLTIME.! For non-netCDF fields, field is treated no differently, but is written! with a timestamp of NULLTIME. There is no check in the code to prevent! the user from repeatedly writing a static field. integer, intent(in) ::unit, nwords type(fieldtype), intent(in) ::field MPP_TYPE_, intent(inout) ::data(nwords) integer, intent(in), optional ::time_level type(domain2D), intent(in), optional ::domain integer, intent(in), optional ::position, tile_count integer, intent(in), optional ::start_in(:), axsiz_in(:) integer, dimension(size(field%axes(:))) ::start, axsiz integer ::tlevel !, subdomain(4) integer ::i, error, is, ie, js, je, isg, ieg, jsg, jeg type(domain2d), pointer ::io_domain=> tlevel if(PRESENT(start_in) .AND. PRESENT(axsiz_in)) then if(size(start(! the data domain and compute domain must refer to the subdomain being passed ! In this ! since that attempts to gather all data on PE start
util::DateTime end_
Definition: PostTimer.h:49
enddo ! cludge for now
subroutine, public step(x, g)
util::DateTime bgn_
Definition: PostTimer.h:48
bool itIsTime(const util::DateTime &)
Definition: PostTimer.cc:79
std::vector< util::DateTime > pptimes_
Definition: PostTimer.h:52
void initialize(const util::DateTime &, const util::DateTime &, const util::Duration &)
Definition: PostTimer.cc:45
util::Duration freq_
Definition: PostTimer.h:47