FV3 Bundle
PostProcessorTLAD.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_POSTPROCESSORTLAD_H_
12 #define OOPS_BASE_POSTPROCESSORTLAD_H_
13 
14 #include <vector>
15 
16 #include <boost/foreach.hpp>
17 #include <boost/shared_ptr.hpp>
18 
20 #include "oops/base/PostBaseTLAD.h"
22 #include "oops/interface/State.h"
23 
24 namespace oops {
25 
26 /// Control model post processing
27 /*!
28  * This class controls model post processing in the most general sense,
29  * ie all diagnostics computations that do not affect the model integration.
30  * It just calls all the individual processors one by one.
31  */
32 
33 template<typename MODEL>
38 
39  public:
43 
45  if (pp != 0) {
46  boost::shared_ptr<PostBaseTLAD_> sp(pp);
47  processors_.push_back(sp);
48  }
49  }
50 
51  void enrollProcessor(boost::shared_ptr<PostBaseTLAD_> pp) {
52  if (pp != 0) processors_.push_back(pp);
53  }
54 
55 /// Set linearization state
56  void initializeTraj(const State_ & xx, const util::DateTime & end,
57  const util::Duration & step) {
58  BOOST_FOREACH(boost::shared_ptr<PostBaseTLAD_> jp, processors_) {
59  jp->initializeTraj(xx, end, step);
60  }
61  }
62 
63  void processTraj(const State_ & xx) {
64  BOOST_FOREACH(boost::shared_ptr<PostBaseTLAD_> jp, processors_) jp->processTraj(xx);
65  }
66 
67  void finalizeTraj(const State_ & xx) {
68  BOOST_FOREACH(boost::shared_ptr<PostBaseTLAD_> jp, processors_) jp->finalizeTraj(xx);
69  }
70 
71 /// Tangent linear methods
72  void initializeTL(const Increment_ & dx, const util::DateTime & end,
73  const util::Duration & step) {
74  BOOST_FOREACH(boost::shared_ptr<PostBaseTLAD_> jp, processors_) {
75  jp->initializeTL(dx, end, step);
76  }
77  }
78 
79  void processTL(const Increment_ & dx) {
80  BOOST_FOREACH(boost::shared_ptr<PostBaseTLAD_> jp, processors_) jp->processTL(dx);
81  }
82 
83  void finalizeTL(const Increment_ & dx) {
84  BOOST_FOREACH(boost::shared_ptr<PostBaseTLAD_> jp, processors_) jp->finalizeTL(dx);
85  }
86 
87 /// Get TL dual space output
89  GeneralizedDepartures * lambda = processors_[ii]->releaseOutputFromTL();
90  return lambda;
91  }
92 
93 /// Adjoint methods
94  void initializeAD(Increment_ & dx, const util::DateTime & bgn,
95  const util::Duration & step) {
96  BOOST_FOREACH(boost::shared_ptr<PostBaseTLAD_> jp, processors_) {
97  jp->initializeAD(dx, bgn, step);
98  }
99  }
100 
101  void processAD(Increment_ & dx) {
102  BOOST_FOREACH(boost::shared_ptr<PostBaseTLAD_> jp, processors_) jp->processAD(dx);
103  }
104 
105  void finalizeAD(Increment_ & dx) {
106  BOOST_FOREACH(boost::shared_ptr<PostBaseTLAD_> jp, processors_) jp->finalizeAD(dx);
107  }
108 
109  private:
110  std::vector< boost::shared_ptr<PostBaseTLAD_> > processors_;
112 };
113 
114 } // namespace oops
115 
116 #endif // OOPS_BASE_POSTPROCESSORTLAD_H_
GeneralizedDepartures * releaseOutputFromTL(unsigned int ii)
Get TL dual space output.
void initializeAD(Increment_ &dx, const util::DateTime &bgn, const util::Duration &step)
Adjoint methods.
real(r8), dimension(cast_m, cast_n) sp
PostProcessorTLAD operator=(const PostProcessorTLAD &)
Increment< MODEL > Increment_
************************************************************************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
void processTraj(const State_ &xx)
PostBaseTLAD< MODEL > PostBaseTLAD_
Handles post-processing of model fields related to cost function.
Definition: PostBaseTLAD.h:39
void enrollProcessor(boost::shared_ptr< PostBaseTLAD_ > pp)
Encapsulates the model state.
PostProcessorTLAD()
void finalizeTL(const Increment_ &dx)
void finalizeAD(Increment_ &dx)
PostProcessorTLAD(const PostProcessorTLAD &pp)
The namespace for the main oops code.
void processTL(const Increment_ &dx)
void initializeTraj(const State_ &xx, const util::DateTime &end, const util::Duration &step)
Set linearization state.
void processAD(Increment_ &dx)
Control model post processing.
~PostProcessorTLAD()
void enrollProcessor(PostBaseTLAD_ *pp)
subroutine, public step(x, g)
Increment Class: Difference between two states.
void initializeTL(const Increment_ &dx, const util::DateTime &end, const util::Duration &step)
Tangent linear methods.
Abstract base class for quantities.
State< MODEL > State_
void finalizeTraj(const State_ &xx)
std::vector< boost::shared_ptr< PostBaseTLAD_ > > processors_