FV3 Bundle
ObsHelpQG.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/ObsHelpQG.h"
12 
13 #include <string>
14 
15 #include "eckit/config/Configuration.h"
16 #include "model/QgFortran.h"
17 #include "oops/util/DateTime.h"
18 #include "oops/util/Duration.h"
19 #include "oops/util/Logger.h"
20 
21 namespace qg {
22 
23 // -----------------------------------------------------------------------------
24 
25 ObsHelpQG::ObsHelpQG(const eckit::Configuration & config) {
26  const eckit::Configuration * configc = &config;
27  qg_obsdb_setup_f90(keyHelp_, &configc);
28  oops::Log::trace() << "ObsHelpQG constructed" << std::endl;
29 }
30 
31 // -----------------------------------------------------------------------------
32 
35  oops::Log::trace() << "ObsHelpQG destructed" << std::endl;
36 }
37 
38 // -----------------------------------------------------------------------------
39 
40 void ObsHelpQG::putdb(const std::string & obsname, const std::string & col, const int & keyFvec) {
41  oops::Log::trace() << "ObsHelpQG:putdb obsname = " << obsname << ", col = " << col << std::endl;
42  qg_obsdb_put_f90(keyHelp_, obsname.size(), obsname.c_str(), col.size(), col.c_str(), keyFvec);
43 }
44 
45 // -----------------------------------------------------------------------------
46 
47 void ObsHelpQG::getdb(const std::string & obsname, const std::string & col, int & keyFvec) const {
48  oops::Log::trace() << "ObsHelpQG:getdb obsname = " << obsname << ", col = " << col << std::endl;
49  qg_obsdb_get_f90(keyHelp_, obsname.size(), obsname.c_str(), col.size(), col.c_str(), keyFvec);
50 }
51 
52 // -----------------------------------------------------------------------------
53 
54 F90locs ObsHelpQG::locations(const std::string & obsname,
55  const util::DateTime & t1, const util::DateTime & t2) const {
56  const util::DateTime * p1 = &t1;
57  const util::DateTime * p2 = &t2;
58  F90locs key_locs;
59  qg_obsdb_locations_f90(keyHelp_, obsname.size(), obsname.c_str(), &p1, &p2, key_locs);
60  return key_locs;
61 }
62 
63 // -----------------------------------------------------------------------------
64 
65 void ObsHelpQG::generateDistribution(const eckit::Configuration & config,
66  const std::string & obsname,
67  const util::DateTime & t1, const util::DateTime & t2,
68  unsigned int & nobs) {
69  const eckit::Configuration * configc = &config;
70  const util::Duration first(config.getString("begin"));
71  const util::DateTime start(t1 + first);
72  const util::Duration freq(config.getString("obs_period"));
73  int nobstimes = 0;
74  util::DateTime now(start);
75  while (now <= t2) {
76  ++nobstimes;
77  now += freq;
78  }
79  const util::DateTime * bgn = &start;
80  const util::Duration * stp = &freq;
81  int iobs;
82  qg_obsdb_generate_f90(keyHelp_, obsname.size(), obsname.c_str(), &configc,
83  &bgn, &stp, nobstimes, iobs);
84  nobs = iobs;
85 }
86 
87 // -----------------------------------------------------------------------------
88 
89 int ObsHelpQG::nobs(const std::string & obsname) const {
90  int iobs;
91  qg_obsdb_nobs_f90(keyHelp_, obsname.size(), obsname.c_str(), iobs);
92  return iobs;
93 }
94 
95 // -----------------------------------------------------------------------------
96 
97 
98 } // namespace qg
void generateDistribution(const eckit::Configuration &, const std::string &, const util::DateTime &, const util::DateTime &, unsigned int &)
Definition: ObsHelpQG.cc:65
void qg_obsdb_generate_f90(const F90odb &, const int &, const char *, const eckit::Configuration *const *, const util::DateTime *const *, const util::Duration *const *, const int &, int &)
void qg_obsdb_locations_f90(const F90odb &, const int &, const char *, const util::DateTime *const *, const util::DateTime *const *, F90locs &)
void qg_obsdb_nobs_f90(const F90odb &, const int &, const char *, int &)
real, parameter t2
void qg_obsdb_delete_f90(F90odb &)
F90locs locations(const std::string &, const util::DateTime &, const util::DateTime &) const
Definition: ObsHelpQG.cc:54
************************************************************************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:! ***********************************************************************subroutine READ_RECORD_CORE_(unit, field, nwords, data, start, axsiz) integer, intent(in) ::unit type(fieldtype), intent(in) ::field integer, intent(in) ::nwords MPP_TYPE_, intent(inout) ::data(nwords) integer, intent(in) ::start(:), axsiz(:) integer(SHORT_KIND) ::i2vals(nwords)!rab used in conjunction with transfer intrinsic to determine size of a variable integer(KIND=1) ::one_byte(8) integer ::word_sz!#ifdef __sgi integer(INT_KIND) ::ivals(nwords) real(FLOAT_KIND) ::rvals(nwords)!#else! integer ::ivals(nwords)! real ::rvals(nwords)!#endif real(DOUBLE_KIND) ::r8vals(nwords) pointer(ptr1, i2vals) pointer(ptr2, ivals) pointer(ptr3, rvals) pointer(ptr4, r8vals) if(mpp_io_stack_size< nwords) call mpp_io_set_stack_size(nwords) call mpp_error(FATAL, 'MPP_READ currently requires use_netCDF option') end subroutine READ_RECORD_CORE_ subroutine READ_RECORD_(unit, field, nwords, data, time_level, domain, position, tile_count, start_in, axsiz_in)!routine that is finally called by all mpp_read routines to perform the read!a non-netCDF record contains:! field ID! a set of 4 coordinates(is:ie, js:je) giving the data subdomain! a timelevel and a timestamp(=NULLTIME if field is static)! 3D real data(stored as 1D)!if you are using direct access I/O, the RECL argument to OPEN must be large enough for the above!in a global direct access file, record position on PE is given by %record.!Treatment of timestamp:! We assume that static fields have been passed without a timestamp.! Here that is converted into a timestamp of NULLTIME.! For non-netCDF fields, field is treated no differently, but is written! with a timestamp of NULLTIME. There is no check in the code to prevent! the user from repeatedly writing a static field. integer, intent(in) ::unit, nwords type(fieldtype), intent(in) ::field MPP_TYPE_, intent(inout) ::data(nwords) integer, intent(in), optional ::time_level type(domain2D), intent(in), optional ::domain integer, intent(in), optional ::position, tile_count integer, intent(in), optional ::start_in(:), axsiz_in(:) integer, dimension(size(field%axes(:))) ::start, axsiz integer ::tlevel !, subdomain(4) integer ::i, error, is, ie, js, je, isg, ieg, jsg, jeg type(domain2d), pointer ::io_domain=> tlevel if(PRESENT(start_in) .AND. PRESENT(axsiz_in)) then if(size(start(! the data domain and compute domain must refer to the subdomain being passed ! In this ! since that attempts to gather all data on PE start
void qg_obsdb_get_f90(const F90odb &, const int &, const char *, const int &, const char *, const F90ovec &)
real, parameter t1
void getdb(const std::string &, const std::string &, int &keyOvec) const
Definition: ObsHelpQG.cc:47
void qg_obsdb_put_f90(const F90odb &, const int &, const char *, const int &, const char *, const F90ovec &)
ObsHelpQG(const eckit::Configuration &)
Definition: ObsHelpQG.cc:25
enddo ! cludge for now
void qg_obsdb_setup_f90(F90odb &, const eckit::Configuration *const *)
void putdb(const std::string &, const std::string &, const int &keyOvec)
Definition: ObsHelpQG.cc:40
real, parameter p2
Definition: sw_core_nlm.F90:47
int F90locs
Definition: QgFortran.h:34
int nobs(const std::string &) const
Definition: ObsHelpQG.cc:89
real, parameter p1
Definition: sw_core_nlm.F90:46
F90odb keyHelp_
Definition: ObsHelpQG.h:50
The namespace for the qg model.