FV3 Bundle
LocationsQG.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 <ostream>
12 #include <string>
13 #include <vector>
14 
15 #include "eckit/config/Configuration.h"
16 #include "model/LocationsQG.h"
17 #include "model/QgFortran.h"
18 
19 namespace qg {
20 
21 // -------------------------------------------------------------------------
22 /*! QG Locations Constructor with Configuration
23  *
24  * \details This constructor can be used to generate user-specified
25  * and/or random locations for use with testStateInterpolation()
26  *
27  * To generate random locations, the relevant parameters specified in
28  * **State.Locations** section of the config file are:
29  *
30  * * **lats** user-specified latitudes (degrees)
31  * * **lons** user-specified longitudes (degrees)
32  * * **heights** user-specified heights (normalized, from 0-1)
33  * * **Nrandom** number of random locations desired
34  * * **random_seed** (optional) random seed for reproducibility of results
35  *
36  * \date April, 2018 Created (M. Miesch, JCSDA)
37  *
38  * \warning latitudes and longitudes are converted to normalized locations
39  * (between 0-1) based on on an assumed latitudinal extent of 180 degrees
40  * and an assumed longitudinal extent of 360 degrees
41  *
42  * \sa qg::c_qg_loc_test() test::testStateInterpolation()
43  *
44  */
45 
46 LocationsQG::LocationsQG(const eckit::Configuration & config) {
47  const eckit::Configuration * conf = &config;
48 
50 
51  if (config.has("lats") || config.has("Nrandom")) {
52  std::vector<double> lats = config.getDoubleVector("lats");
53  std::vector<double> lons = config.getDoubleVector("lons");
54  std::vector<double> zin = config.getDoubleVector("heights");
55 
56  ASSERT(lats.size() == lons.size());
57  const unsigned int nloc = lats.size();
58 
59  // Default to level 1 unless otherwise specified
60  std::vector<double> height(nloc, 0.25);
61 
62  if (zin.size() > 0) {
63  for (unsigned int i=0; i < zin.size(); ++i) {
64  if (i >= nloc) break;
65  height[i] = zin[i];
66  }
67  }
68  qg_loc_test_f90(keyLoc_, &conf, nloc, &lats[0], &lons[0], &height[0]);
69  }
70 }
71 
72 // -------------------------------------------------------------------------
73 } // namespace qg
l_size ! loop over number of fields ke do je do i
void qg_loc_test_f90(const F90locs &, const eckit::Configuration *const *, const int &, const double *, const double *, const double *)
Definition: conf.py:1
void qg_loc_create_f90(F90locs &)
LocationsQG(const F90locs key)
Definition: LocationsQG.h:31
real, dimension(maxmts) height
F90locs keyLoc_
Definition: LocationsQG.h:57
The namespace for the qg model.