FV3 Bundle
oops/interface/ObservationSpace.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_INTERFACE_OBSERVATIONSPACE_H_
12 #define OOPS_INTERFACE_OBSERVATIONSPACE_H_
13 
14 #include <ostream>
15 #include <string>
16 
17 #include <boost/shared_ptr.hpp>
18 
20 #include "oops/util/Logger.h"
21 #include "oops/util/ObjectCounter.h"
22 #include "oops/util/Printable.h"
23 #include "oops/util/Timer.h"
24 
25 namespace eckit {
26  class Configuration;
27 }
28 
29 namespace util {
30  class DateTime;
31 }
32 
33 namespace oops {
34  template <typename T> class ObsVector;
35 
36 // -----------------------------------------------------------------------------
37 
38 template <typename MODEL>
39 class ObservationSpace : public util::Printable,
40  private boost::noncopyable,
41  private util::ObjectCounter<ObservationSpace<MODEL> > {
43  typedef typename MODEL::ObsSpace ObsSpace_;
45 
46  public:
47  static const std::string classname() {return "oops::ObservationSpace";}
48 
49  ObservationSpace(const eckit::Configuration &,
50  const util::DateTime &, const util::DateTime &);
52 
53 /// Interfacing
54  ObsSpace_ & observationspace() const {return *obsdb_;}
55 
56 /// Assimilation window
57  const util::DateTime & windowStart() const {return obsdb_->windowStart();}
58  const util::DateTime & windowEnd() const {return obsdb_->windowEnd();}
59  const eckit::Configuration & config() const {return obsdb_->config();}
60 
61 // Other
62  Locations_ locations(const util::DateTime &, const util::DateTime &) const;
63  void generateDistribution(const eckit::Configuration &);
64  void printJo(const ObsVector_ &, const ObsVector_ &) const;
65 
66  private:
67  void print(std::ostream &) const;
68  boost::shared_ptr<ObsSpace_> obsdb_;
69 };
70 
71 // -----------------------------------------------------------------------------
72 
73 template <typename MODEL>
74 ObservationSpace<MODEL>::ObservationSpace(const eckit::Configuration & conf,
75  const util::DateTime & bgn,
76  const util::DateTime & end) : obsdb_() {
77  Log::trace() << "ObservationSpace<MODEL>::ObservationSpace starting" << std::endl;
78  util::Timer timer(classname(), "ObservationSpace");
79  obsdb_.reset(new ObsSpace_(conf, bgn, end));
80  Log::trace() << "ObservationSpace<MODEL>::ObservationSpace done" << std::endl;
81 }
82 
83 // -----------------------------------------------------------------------------
84 
85 template <typename MODEL>
87  Log::trace() << "ObservationSpace<MODEL>::~ObservationSpace" << std::endl;
88 }
89 
90 // -----------------------------------------------------------------------------
91 
92 template <typename MODEL>
93 void ObservationSpace<MODEL>::print(std::ostream & os) const {
94  Log::trace() << "ObservationSpace<MODEL>::print starting" << std::endl;
95  util::Timer timer(classname(), "print");
96  os << *obsdb_;
97  Log::trace() << "ObservationSpace<MODEL>::print done" << std::endl;
98 }
99 
100 // -----------------------------------------------------------------------------
101 
102 template <typename MODEL>
103 void ObservationSpace<MODEL>::generateDistribution(const eckit::Configuration & conf) {
104  Log::trace() << "ObservationSpace<MODEL>::generateDistribution starting" << std::endl;
105  util::Timer timer(classname(), "generateDistribution");
106  obsdb_->generateDistribution(conf);
107  Log::trace() << "ObservationSpace<MODEL>::generateDistribution done" << std::endl;
108 }
109 
110 // -----------------------------------------------------------------------------
111 
112 template <typename MODEL>
114  const util::DateTime & t2) const {
115  Log::trace() << "ObservationSpace<MODEL>::locations starting" << std::endl;
116  util::Timer timer(classname(), "locations");
117  return Locations_(obsdb_->locations(t1, t2));
118 }
119 
120 // -----------------------------------------------------------------------------
121 
122 template <typename MODEL>
123 void ObservationSpace<MODEL>::printJo(const ObsVector_ & dy, const ObsVector_ & grad) const {
124  Log::trace() << "ObservationSpace<MODEL>::printJo starting" << std::endl;
125  util::Timer timer(classname(), "printJo");
126  obsdb_->printJo(dy.obsvector(), grad.obsvector());
127  Log::trace() << "ObservationSpace<MODEL>::printJo done" << std::endl;
128 }
129 
130 // -----------------------------------------------------------------------------
131 
132 } // namespace oops
133 
134 #endif // OOPS_INTERFACE_OBSERVATIONSPACE_H_
static const std::string classname()
************************************************************************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
ObservationSpace(const eckit::Configuration &, const util::DateTime &, const util::DateTime &)
const eckit::Configuration & config() const
real, parameter t2
The namespace for the main oops code.
boost::shared_ptr< ObsSpace_ > obsdb_
const util::DateTime & windowEnd() const
real, parameter t1
ObsVector_ & obsvector()
Interfacing.
void print(std::ostream &) const
void printJo(const ObsVector_ &, const ObsVector_ &) const
Locations_ locations(const util::DateTime &, const util::DateTime &) const
ObsSpace_ & observationspace() const
Interfacing.
const util::DateTime & windowStart() const
Assimilation window.
void generateDistribution(const eckit::Configuration &)