FV3 Bundle
ObsSpaces.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_OBSSPACES_H_
12 #define OOPS_BASE_OBSSPACES_H_
13 
14 #include <cstddef>
15 #include <map>
16 #include <ostream>
17 #include <string>
18 #include <vector>
19 
20 #include <boost/noncopyable.hpp>
21 #include <boost/shared_ptr.hpp>
22 
23 #include "eckit/config/LocalConfiguration.h"
25 #include "oops/util/DateTime.h"
26 #include "oops/util/Logger.h"
27 #include "oops/util/ObjectCounter.h"
28 #include "oops/util/Printable.h"
29 #include "oops/util/Timer.h"
30 
31 namespace oops {
32  template <typename T>
33  class Departures;
34 
35 // -----------------------------------------------------------------------------
36 
37 template <typename MODEL>
38 class ObsSpaces : public util::Printable,
39  private boost::noncopyable,
40  private util::ObjectCounter<ObsSpaces<MODEL> > {
43 
44  public:
45  static const std::string classname() {return "oops::ObsSpaces";}
46 
47  ObsSpaces(const eckit::Configuration &, const util::DateTime &, const util::DateTime &);
48  ~ObsSpaces();
49 
50 /// Access
51  std::size_t size() const {return spaces_.size();}
52  const ObsSpace_ & operator[](const std::size_t ii) const {return *spaces_.at(ii);}
53  std::size_t itype(const std::string & type) const {return types_.at(type);}
54 
55 /// Assimilation window
56  const util::DateTime & windowStart() const {return wbgn_;}
57  const util::DateTime & windowEnd() const {return wend_;}
58 
59 /// Other
60  void printJo(const Departures_ &, const Departures_ &) const; // To be changed
61 
62  private:
63  void print(std::ostream &) const;
64  std::vector<boost::shared_ptr<ObsSpace_> > spaces_;
65  std::map<std::string, std::size_t> types_;
66  const util::DateTime wbgn_;
67  const util::DateTime wend_;
68 };
69 
70 // -----------------------------------------------------------------------------
71 
72 template <typename MODEL>
73 ObsSpaces<MODEL>::ObsSpaces(const eckit::Configuration & conf,
74  const util::DateTime & bgn, const util::DateTime & end)
75  : spaces_(0), types_(), wbgn_(bgn), wend_(end)
76 {
77  std::vector<eckit::LocalConfiguration> obsconf;
78  conf.get("ObsTypes", obsconf);
79  for (std::size_t jj = 0; jj < obsconf.size(); ++jj) {
80  Log::debug() << "ObsSpaces::ObsSpaces : conf " << obsconf[jj] << std::endl;
81  const std::string otype = obsconf[jj].getString("ObsType");
82  ASSERT(types_.count(otype) == 0);
83  types_[otype] = jj;
84  boost::shared_ptr<ObsSpace_> tmp(new ObsSpace_(obsconf[jj], bgn, end));
85  spaces_.push_back(tmp);
86 // Generate locations etc... if required
87  if (obsconf[jj].has("Generate")) {
88  const eckit::LocalConfiguration gconf(obsconf[jj], "Generate");
89  spaces_[jj]->generateDistribution(gconf);
90  }
91  }
92  ASSERT(spaces_.size() >0);
93 }
94 
95 // -----------------------------------------------------------------------------
96 
97 template <typename MODEL>
99 
100 // -----------------------------------------------------------------------------
101 
102 template <typename MODEL>
103 void ObsSpaces<MODEL>::print(std::ostream & os) const {
104  for (std::size_t jj = 0; jj < spaces_.size(); ++jj) {
105  os << *spaces_[jj];
106  }
107 }
108 
109 // -----------------------------------------------------------------------------
110 
111 template <typename MODEL>
112 void ObsSpaces<MODEL>::printJo(const Departures_ & dy, const Departures_ & grad) const {
113  for (std::size_t jj = 0; jj < spaces_.size(); ++jj) {
114  spaces_[jj]->printJo(dy[jj], grad[jj]);
115  }
116 }
117 
118 // -----------------------------------------------------------------------------
119 
120 } // namespace oops
121 
122 #endif // OOPS_BASE_OBSSPACES_H_
ObsSpaces(const eckit::Configuration &, const util::DateTime &, const util::DateTime &)
Definition: ObsSpaces.h:73
Difference between two observation vectors.
Definition: Departures.h:36
************************************************************************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
const ObsSpace_ & operator[](const std::size_t ii) const
Definition: ObsSpaces.h:52
const util::DateTime wbgn_
Definition: ObsSpaces.h:66
The namespace for the main oops code.
logical debug
Definition: mpp.F90:1297
void print(std::ostream &) const
Definition: ObsSpaces.h:103
type
Definition: c2f.py:15
Departures< MODEL > Departures_
Definition: ObsSpaces.h:41
ObservationSpace< MODEL > ObsSpace_
Definition: ObsSpaces.h:42
std::map< std::string, std::size_t > types_
Definition: ObsSpaces.h:65
std::size_t itype(const std::string &type) const
Definition: ObsSpaces.h:53
const util::DateTime & windowStart() const
Assimilation window.
Definition: ObsSpaces.h:56
void printJo(const Departures_ &, const Departures_ &) const
Other.
Definition: ObsSpaces.h:112
static const std::string classname()
Definition: ObsSpaces.h:45
const util::DateTime & windowEnd() const
Definition: ObsSpaces.h:57
const util::DateTime wend_
Definition: ObsSpaces.h:67
std::size_t size() const
Access.
Definition: ObsSpaces.h:51
std::vector< boost::shared_ptr< ObsSpace_ > > spaces_
Definition: ObsSpaces.h:64