FV3 Bundle
VariablesQG.cc
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 #include "model/VariablesQG.h"
9 
10 #include<vector>
11 
12 #include "eckit/config/Configuration.h"
13 #include "oops/base/Variables.h"
14 #include "oops/util/Logger.h"
15 
16 namespace qg {
17 
18 // -----------------------------------------------------------------------------
19 
21  : oopsvars_(oopsvars) {
22  oops::Log::debug() << "VariablesQG oopsvar:" << oopsvars.variables() << std::endl;
23  this->setF90(oopsvars.variables());
24  oops::Log::debug() << *this << std::endl;
25 }
26 
27 // -----------------------------------------------------------------------------
28 
29 VariablesQG::VariablesQG(const eckit::Configuration & config)
30  : oopsvars_(config) {
31  oops::Log::debug() << "VariablesQG config:" << config << std::endl;
32  std::vector<std::string> vars;
33  config.get("variables", vars);
34  this->setF90(vars);
35  oops::Log::debug() << *this << std::endl;
36 }
37 
38 // -----------------------------------------------------------------------------
39 
40 void VariablesQG::setF90(const std::vector<std::string> vars) {
41  size_t nv = vars.size();
42  oops::Log::debug() << "setF90 " << nv << " vars = " << vars << std::endl;
43  fvars_.resize(nv + 2);
44  fvars_[0] = nv;
45  for (size_t jj = 0; jj < nv; ++jj) {
46  int ii = 0;
47  if (vars[jj] == "x") ii = 1;
48  if (vars[jj] == "q") ii = 2;
49  if (vars[jj] == "u") ii = 3;
50  if (vars[jj] == "v") ii = 4;
51  if (vars[jj] == "bc") ii = 5;
52  ASSERT(ii > 0);
53  fvars_[jj+1] = ii;
54  }
55  fvars_[nv+1] = 999; // just for checking
56  oops::Log::debug() << "setF90 " << nv << " fvars = " << fvars_ << std::endl;
57 }
58 
59 // -----------------------------------------------------------------------------
60 
62 
63 // -----------------------------------------------------------------------------
64 
66  : fvars_(other.fvars_),
67  oopsvars_(other.toOopsVariables()) {}
68 
69 // -----------------------------------------------------------------------------
70 
71 void VariablesQG::print(std::ostream & os) const {
72  os << "qg::VariablesQG: vars = " << fvars_;
73 }
74 
75 // -----------------------------------------------------------------------------
76 
77 } // namespace qg
VariablesQG(const oops::Variables &)
Definition: VariablesQG.cc:20
void print(std::ostream &) const
Definition: VariablesQG.cc:71
const std::vector< std::string > & variables() const
Definition: Variables.h:35
logical debug
Definition: mpp.F90:1297
std::vector< int > fvars_
Definition: VariablesQG.h:48
void setF90(const std::vector< std::string >)
Definition: VariablesQG.cc:40
The namespace for the qg model.