FV3 Bundle
LinearObsOperatorBase.h
Go to the documentation of this file.
1 /*
2  * (C) Copyright 2017-2018 UCAR
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  */
7 
8 #ifndef UFO_LINEAROBSOPERATORBASE_H_
9 #define UFO_LINEAROBSOPERATORBASE_H_
10 
11 #include <map>
12 #include <string>
13 
14 #include <boost/noncopyable.hpp>
15 
16 #include "eckit/config/Configuration.h"
17 #include "ioda/ObsSpace.h"
18 #include "oops/base/Variables.h"
19 #include "oops/util/abor1_cpp.h"
20 #include "oops/util/Printable.h"
21 
22 namespace ioda {
23 class ObsVector;
24 }
25 
26 namespace ufo {
27 class GeoVaLs;
28 class ObsBias;
29 class ObsBiasIncrement;
30 
31 // -----------------------------------------------------------------------------
32 /// Base class for observation operators
33 
34 class LinearObsOperatorBase : public util::Printable,
35  private boost::noncopyable {
36  public:
39 
40 /// Obs Operator
41  virtual void setTrajectory(const GeoVaLs &, const ObsBias &) = 0;
42  virtual void simulateObsTL(const GeoVaLs &, ioda::ObsVector &,
43  const ObsBiasIncrement &) const = 0;
44  virtual void simulateObsAD(GeoVaLs &, const ioda::ObsVector &, ObsBiasIncrement &) const = 0;
45 
46 /// Operator input required from Model
47  virtual const oops::Variables & variables() const = 0;
48 
49  private:
50  virtual void print(std::ostream &) const = 0;
51 };
52 
53 // -----------------------------------------------------------------------------
54 
55 /// Obs Operator Factory
57  public:
58  static LinearObsOperatorBase * create(const ioda::ObsSpace &, const eckit::Configuration &);
59  virtual ~LinearObsOperatorFactory() { getMakers().clear(); }
60  protected:
61  explicit LinearObsOperatorFactory(const std::string &);
62  private:
63  virtual LinearObsOperatorBase * make(const ioda::ObsSpace &, const eckit::Configuration &) = 0;
64  static std::map < std::string, LinearObsOperatorFactory * > & getMakers() {
65  static std::map < std::string, LinearObsOperatorFactory * > makers_;
66  return makers_;
67  }
68 };
69 
70 // -----------------------------------------------------------------------------
71 
72 template<class T>
74  virtual LinearObsOperatorBase * make(const ioda::ObsSpace & odb,
75  const eckit::Configuration & conf) {
76  return new T(odb, conf);
77  }
78  public:
79  explicit LinearObsOperatorMaker(const std::string & name) : LinearObsOperatorFactory(name) {}
80 };
81 
82 // -----------------------------------------------------------------------------
83 
84 } // namespace ufo
85 
86 #endif // UFO_LINEAROBSOPERATORBASE_H_
Base class for observation operators.
ObsVector class to handle vectors in observation space for IODA.
LinearObsOperatorMaker(const std::string &name)
LinearObsOperatorFactory(const std::string &)
virtual LinearObsOperatorBase * make(const ioda::ObsSpace &odb, const eckit::Configuration &conf)
virtual void simulateObsTL(const GeoVaLs &, ioda::ObsVector &, const ObsBiasIncrement &) const =0
Definition: conf.py:1
Wrapper around ObsHelpQG, mostly to hide the factory.
character(len=32) name
GeoVaLs: geophysical values at locations.
virtual void simulateObsAD(GeoVaLs &, const ioda::ObsVector &, ObsBiasIncrement &) const =0
************************************************************************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 get_len end if return end subroutine MPP_TRANSMIT_ ! MPP_BROADCAST ! subroutine but that doesn t allow !broadcast to a subset of PEs This version and mpp_transmit will remain !backward compatible intent(inout) & T
static LinearObsOperatorBase * create(const ioda::ObsSpace &, const eckit::Configuration &)
virtual LinearObsOperatorBase * make(const ioda::ObsSpace &, const eckit::Configuration &)=0
virtual const oops::Variables & variables() const =0
Operator input required from Model.
virtual void setTrajectory(const GeoVaLs &, const ObsBias &)=0
Obs Operator.
Class to handle observation bias parameters.
static std::map< std::string, LinearObsOperatorFactory *> & getMakers()
virtual void print(std::ostream &) const =0