FV3 Bundle
TrajectorySaver.h
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 #ifndef OOPS_BASE_TRAJECTORYSAVER_H_
12 #define OOPS_BASE_TRAJECTORYSAVER_H_
13 
14 #include <boost/ptr_container/ptr_vector.hpp>
15 
16 #include "eckit/config/LocalConfiguration.h"
17 #include "oops/base/PostBase.h"
21 #include "oops/interface/State.h"
22 #include "oops/util/DateTime.h"
23 #include "oops/util/Duration.h"
24 
25 namespace oops {
26 
27 /// Save trajectory during forecast run.
28 
29 // -----------------------------------------------------------------------------
30 
31 template <typename MODEL>
32 class TrajectorySaver : public PostBase<State<MODEL> > {
38 
39  public:
40  TrajectorySaver(const eckit::Configuration &, const Geometry_ &,
41  const ModelAux_ &, boost::ptr_vector<LinearModel_> &, PPTLAD_);
43 
44  private:
46  const eckit::LocalConfiguration tlConf_;
48  boost::ptr_vector<LinearModel_> & tlm_;
51 
52  void doInitialize(const State_ &, const util::DateTime &, const util::Duration &) override;
53  void doProcessing(const State_ &) override;
54  void doFinalize(const State_ &) override;
55 };
56 
57 // -----------------------------------------------------------------------------
58 
59 template <typename MODEL>
60 TrajectorySaver<MODEL>::TrajectorySaver(const eckit::Configuration & conf,
61  const Geometry_ & resol,
62  const ModelAux_ & bias,
63  boost::ptr_vector<LinearModel_> & tlm,
64  PPTLAD_ pptraj):
66  resol_(resol), tlConf_(conf), lrBias_(resol, bias),
67  tlm_(tlm), subtlm_(0), pptraj_(pptraj)
68 {
69  Log::trace() << "TrajectorySaver::TrajectorySaver" << std::endl;
70 }
71 // -----------------------------------------------------------------------------
72 template <typename MODEL>
74  const util::DateTime & end,
75  const util::Duration & step) {
76  Log::trace() << "TrajectorySaver::doInitialize start" << std::endl;
77  subtlm_ = new LinearModel_(resol_, tlConf_);
78  State_ xlr(resol_, x0);
79  pptraj_.initializeTraj(xlr, end, step);
80  Log::trace() << "TrajectorySaver::doInitialize done" << std::endl;
81 }
82 // -----------------------------------------------------------------------------
83 template <typename MODEL>
85  Log::trace() << "TrajectorySaver::doProcessing start" << std::endl;
86  ASSERT(subtlm_ != 0);
87  State_ xlr(resol_, xx);
88  subtlm_->setTrajectory(xx, xlr, lrBias_);
89  pptraj_.processTraj(xlr);
90  Log::trace() << "TrajectorySaver::doProcessing done" << std::endl;
91 }
92 // -----------------------------------------------------------------------------
93 template <typename MODEL>
95  Log::trace() << "TrajectorySaver::doFinalize start" << std::endl;
96  State_ xlr(resol_, xx);
97  tlm_.push_back(subtlm_);
98  pptraj_.finalizeTraj(xlr);
99  subtlm_ = 0;
100  Log::trace() << "TrajectorySaver::doFinalize done" << std::endl;
101 }
102 // -----------------------------------------------------------------------------
103 
104 } // namespace oops
105 
106 #endif // OOPS_BASE_TRAJECTORYSAVER_H_
const ModelAux_ lrBias_
************************************************************************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
LinearModel_ * subtlm_
PostProcessorTLAD< MODEL > PPTLAD_
State< MODEL > State_
boost::ptr_vector< LinearModel_ > & tlm_
Encapsulates the model state.
Save trajectory during forecast run.
Handles post-processing of model fields.
Definition: PostBase.h:33
The namespace for the main oops code.
Geometry< MODEL > Geometry_
const eckit::LocalConfiguration tlConf_
Control model post processing.
const Geometry_ resol_
TrajectorySaver(const eckit::Configuration &, const Geometry_ &, const ModelAux_ &, boost::ptr_vector< LinearModel_ > &, PPTLAD_)
string tlm
Definition: TLM_vs_NLM.py:25
void doProcessing(const State_ &) override
Actual processing.
subroutine, public step(x, g)
ModelAuxControl< MODEL > ModelAux_
void doInitialize(const State_ &, const util::DateTime &, const util::Duration &) override
void doFinalize(const State_ &) override
LinearModel< MODEL > LinearModel_
Encapsulates the linear forecast model.