FV3 Bundle
ObsSpaceQG.cc
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 #include "model/ObsSpaceQG.h"
12 
13 #include <map>
14 #include <string>
15 
16 #include "eckit/config/Configuration.h"
17 
18 #include "oops/util/abor1_cpp.h"
19 #include "oops/util/Logger.h"
20 
21 #include "model/ObsVecQG.h"
22 
23 namespace qg {
24 // -----------------------------------------------------------------------------
25 std::map < std::string, int > ObsSpaceQG::theObsFileCount_;
26 // -----------------------------------------------------------------------------
27 
28 ObsSpaceQG::ObsSpaceQG(const eckit::Configuration & config,
29  const util::DateTime & bgn, const util::DateTime & end)
30  : oops::ObsSpaceBase(config, bgn, end), winbgn_(bgn), winend_(end)
31 {
32  static std::map < std::string, ObsHelpQG * > theObsFileRegister_;
33  typedef std::map< std::string, ObsHelpQG * >::iterator otiter;
34 
35  std::string ofin("-");
36  if (config.has("ObsData.ObsDataIn")) {
37  ofin = config.getString("ObsData.ObsDataIn.obsfile");
38  }
39  std::string ofout("-");
40  if (config.has("ObsData.ObsDataOut")) {
41  ofout = config.getString("ObsData.ObsDataOut.obsfile");
42  }
43  oops::Log::trace() << "ObsSpaceQG: Obs files are: " << ofin << " and " << ofout << std::endl;
44  ref_ = ofin + ofout;
45  if (ref_ == "--") {
46  ABORT("Underspecified observation files.");
47  }
48 
49  otiter it = theObsFileRegister_.find(ref_);
50  if (it == theObsFileRegister_.end()) {
51  // Open new file
52  oops::Log::trace() << "ObsSpaceQG::getHelper: " << "Opening " << ref_ << std::endl;
53  helper_ = new ObsHelpQG(config);
55  theObsFileRegister_[ref_] = helper_;
56  oops::Log::trace() << "ObsSpaceQG created, count=" << theObsFileCount_[ref_] << std::endl;
57  ASSERT(theObsFileCount_[ref_] == 1);
58  } else {
59  // File already open
60  oops::Log::trace() << "ObsSpaceQG::getHelper: " << ref_ << " already opened." << std::endl;
61  helper_ = it->second;
63  oops::Log::trace() << "ObsSpaceQG count=" << theObsFileCount_[ref_] << std::endl;
64  ASSERT(theObsFileCount_[ref_] > 1);
65  }
66 
67  obsname_ = config.getString("ObsType");
69 
70  // Very UGLY!!!
71  nout_ = 0;
72  if (obsname_ == "Stream") nout_ = 1;
73  if (obsname_ == "WSpeed") nout_ = 1;
74  if (obsname_ == "Wind") nout_ = 2;
75  ASSERT(nout_ > 0);
76  nvin_ = 0;
77  if (obsname_ == "Stream") nvin_ = 1;
78  if (obsname_ == "WSpeed") nvin_ = 2;
79  if (obsname_ == "Wind") nvin_ = 2;
80  ASSERT(nvin_ > 0);
81 }
82 
83 // -----------------------------------------------------------------------------
84 
85 void ObsSpaceQG::printJo(const ObsVecQG & dy, const ObsVecQG & grad) {
86  oops::Log::info() << "ObsSpaceQG::printJo not implemented" << std::endl;
87 }
88 
89 // -----------------------------------------------------------------------------
90 
92  ASSERT(theObsFileCount_[ref_] > 0);
93  theObsFileCount_[ref_] -= 1;
94  oops::Log::trace() << "ObsSpaceQG cleared, count=" << theObsFileCount_[ref_] << std::endl;
95  if (theObsFileCount_[ref_] == 0) {
96  delete helper_;
97  }
98 }
99 
100 // -----------------------------------------------------------------------------
101 
102 void ObsSpaceQG::print(std::ostream & os) const {
103  os << "ObsSpaceQG::print not implemented";
104 }
105 
106 // -----------------------------------------------------------------------------
107 
108 } // namespace qg
ObsHelpQG * helper_
Definition: ObsSpaceQG.h:69
unsigned int nobs_
Definition: ObsSpaceQG.h:71
std::string obsname_
Definition: ObsSpaceQG.h:70
************************************************************************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
std::string ref_
Definition: ObsSpaceQG.h:68
unsigned int nout_
Definition: ObsSpaceQG.h:73
unsigned int nvin_
Definition: ObsSpaceQG.h:72
The namespace for the main oops code.
void printJo(const ObsVecQG &, const ObsVecQG &)
Definition: ObsSpaceQG.cc:85
subroutine, public info(self)
void print(std::ostream &) const
Definition: ObsSpaceQG.cc:102
Observation Data Handler for QG Model.
Definition: ObsHelpQG.h:30
const eckit::Configuration & config() const
Access information.
Definition: ObsSpaceBase.h:34
ObsSpaceQG(const eckit::Configuration &, const util::DateTime &, const util::DateTime &)
Definition: ObsSpaceQG.cc:28
ObsVecQG class to handle vectors in observation space for QG model.
Definition: ObsVecQG.h:27
int nobs(const std::string &) const
Definition: ObsHelpQG.cc:89
The namespace for the qg model.
static std::map< std::string, int > theObsFileCount_
Definition: ObsSpaceQG.h:77