FV3 Bundle
ObsSpace.cc
Go to the documentation of this file.
1 /*
2  * (C) Copyright 2017 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 #include "ioda/ObsSpace.h"
9 
10 #include <map>
11 #include <string>
12 #include <vector>
13 
14 #include "eckit/config/Configuration.h"
15 
16 #include "oops/parallel/mpi/mpi.h"
17 #include "oops/util/abor1_cpp.h"
18 #include "oops/util/Logger.h"
19 
20 #include "Locations.h"
21 
22 namespace ioda {
23 // -----------------------------------------------------------------------------
24 
25 ObsSpace::ObsSpace(const eckit::Configuration & config,
26  const util::DateTime & bgn, const util::DateTime & end)
27  : oops::ObsSpaceBase(config, bgn, end), winbgn_(bgn), winend_(end), commMPI_(oops::mpi::comm())
28 {
29  oops::Log::trace() << "ioda::ObsSpace config = " << config << std::endl;
30 
31  const eckit::Configuration * configc = &config;
32  obsname_ = config.getString("ObsType");
34 
35  oops::Log::trace() << "ioda::ObsSpace contructed name = " << obsname_ << std::endl;
36 }
37 
38 // -----------------------------------------------------------------------------
39 
42 }
43 
44 // -----------------------------------------------------------------------------
45 
46 void ObsSpace::getObsVector(const std::string & name, std::vector<double> & vec) const {
47  ioda_obsdb_getd_f90(keyOspace_, name.size(), name.c_str(), vec.size(), vec.data());
48 }
49 
50 // -----------------------------------------------------------------------------
51 
52 void ObsSpace::putObsVector(const std::string & name, const std::vector<double> & vec) const {
53  ioda_obsdb_putd_f90(keyOspace_, name.size(), name.c_str(), vec.size(), vec.data());
54 }
55 
56 // -----------------------------------------------------------------------------
57 void ObsSpace::get_db(const std::string & group, const std::string & name,
58  const std::size_t & vsize, int vdata[]) const {
59  ioda_obsdb_geti_f90(keyOspace_, name.size(), name.c_str(), static_cast<int>(vsize), vdata);
60 }
61 // -----------------------------------------------------------------------------
62 void ObsSpace::get_db(const std::string & group, const std::string & name,
63  const std::size_t & vsize, double vdata[]) const {
64  ioda_obsdb_getd_f90(keyOspace_, name.size(), name.c_str(), static_cast<int>(vsize), vdata);
65 }
66 // -----------------------------------------------------------------------------
67 void ObsSpace::put_db(const std::string & group, const std::string & name,
68  const std::size_t & vsize, const int vdata[]) const {
69  ioda_obsdb_puti_f90(keyOspace_, name.size(), name.c_str(), static_cast<int>(vsize), vdata);
70 }
71 // -----------------------------------------------------------------------------
72 void ObsSpace::put_db(const std::string & group, const std::string & name,
73  const std::size_t & vsize, const double vdata[]) const {
74  ioda_obsdb_putd_f90(keyOspace_, name.size(), name.c_str(), static_cast<int>(vsize), vdata);
75 }
76 // -----------------------------------------------------------------------------
77 
78 Locations * ObsSpace::locations(const util::DateTime & t1, const util::DateTime & t2) const {
79  const util::DateTime * p1 = &t1;
80  const util::DateTime * p2 = &t2;
81  int keylocs;
83 
84  return new Locations(keylocs);
85 }
86 
87 // -----------------------------------------------------------------------------
88 
89 int ObsSpace::nobs() const {
90  int n;
92 
93  return n;
94 }
95 
96 // -----------------------------------------------------------------------------
97 
98 int ObsSpace::nlocs() const {
99  int n;
101  return n;
102 }
103 
104 // -----------------------------------------------------------------------------
105 
106 void ObsSpace::generateDistribution(const eckit::Configuration & conf) {
107  const eckit::Configuration * configc = &conf;
108 
109  const util::DateTime * p1 = &winbgn_;
110  const util::DateTime * p2 = &winend_;
111  ioda_obsdb_generate_f90(keyOspace_, &configc, &p1, &p2);
112 }
113 
114 // -----------------------------------------------------------------------------
115 
116 void ObsSpace::print(std::ostream & os) const {
117  os << "ObsSpace::print not implemented";
118 }
119 
120 // -----------------------------------------------------------------------------
121 
122 void ObsSpace::printJo(const ObsVector & dy, const ObsVector & grad) {
123  oops::Log::info() << "ObsSpace::printJo not implemented" << std::endl;
124 }
125 
126 // -----------------------------------------------------------------------------
127 
128 } // namespace ioda
void get_db(const std::string &, const std::string &, const std::size_t &, int[]) const
Definition: ObsSpace.cc:57
void ioda_obsdb_getd_f90(const F90odb &, const int &, const char *, const int &, double[])
ObsVector class to handle vectors in observation space for IODA.
int nlocs() const
Definition: ObsSpace.cc:98
ObsSpace(const eckit::Configuration &, const util::DateTime &, const util::DateTime &)
Definition: ObsSpace.cc:25
************************************************************************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
void print(std::ostream &) const
Definition: ObsSpace.cc:116
real, parameter t2
void printJo(const ObsVector &, const ObsVector &)
Definition: ObsSpace.cc:122
character(len=32) name
void getObsVector(const std::string &, std::vector< double > &) const
Definition: ObsSpace.cc:46
The namespace for the main oops code.
int nobs() const
Definition: ObsSpace.cc:89
void ioda_obsdb_delete_f90(F90odb &)
subroutine, public info(self)
void ioda_obsdb_putd_f90(const F90odb &, const int &, const char *, const int &, const double[])
real, parameter t1
void ioda_obsdb_geti_f90(const F90odb &, const int &, const char *, const int &, int32_t[])
void ioda_obsdb_nobs_f90(const F90odb &, int &)
const util::DateTime winend_
void putObsVector(const std::string &, const std::vector< double > &) const
Definition: ObsSpace.cc:52
Locations class to handle locations for IODA.
const eckit::mpi::Comm & comm()
Definition: mpi.cc:16
void ioda_obsdb_puti_f90(const F90odb &, const int &, const char *, const int &, const int32_t[])
void put_db(const std::string &, const std::string &, const std::size_t &, const int[]) const
Definition: ObsSpace.cc:67
std::string obsname_
Locations * locations(const util::DateTime &, const util::DateTime &) const
Definition: ObsSpace.cc:78
void generateDistribution(const eckit::Configuration &)
Pure virtual methods.
Definition: ObsSpace.cc:106
const eckit::Configuration & config() const
Access information.
Definition: ObsSpaceBase.h:34
void ioda_obsdb_setup_f90(F90odb &, const eckit::Configuration *const *)
real, parameter p2
Definition: sw_core_nlm.F90:47
const util::DateTime winbgn_
real, parameter p1
Definition: sw_core_nlm.F90:46
void ioda_obsdb_generate_f90(const F90odb &, const eckit::Configuration *const *, const util::DateTime *const *, const util::DateTime *const *)
void ioda_obsdb_nlocs_f90(const F90odb &, int &)
void ioda_obsdb_getlocations_f90(const F90odb &, const util::DateTime *const *, const util::DateTime *const *, F90locs &)