OOPS
Resolution.h
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 #ifndef LORENZ95_RESOLUTION_H_
12 #define LORENZ95_RESOLUTION_H_
13 
14 #include <iostream>
15 #include <string>
16 #include <vector>
17 
18 #include "eckit/config/Configuration.h"
19 #include "lorenz95/Iterator.h"
20 #include "oops/base/Variables.h"
21 #include "oops/mpi/mpi.h"
22 #include "oops/util/parameters/Parameters.h"
23 #include "oops/util/parameters/RequiredParameter.h"
24 #include "oops/util/Printable.h"
25 
26 namespace lorenz95 {
27 
28 class Iterator;
29 
30 // -----------------------------------------------------------------------------
31 /// \brief Parameters controlling a Lorenz95 model's resolution.
32 class ResolutionParameters : public oops::Parameters {
33  OOPS_CONCRETE_PARAMETERS(ResolutionParameters, Parameters)
34 
35  public:
36  /// \brief Number of gridpoints.
37  oops::RequiredParameter<int> resol{"resol", this};
38 };
39 
40 // -----------------------------------------------------------------------------
41 /// Handles resolution.
42 
43 class Resolution : public util::Printable {
44  public:
46 
47  Resolution(const ResolutionParameters & parameters, const eckit::mpi::Comm & comm)
48  : resol_(parameters.resol), comm_(comm)
49  {ASSERT(comm_.size() == 1);}
50  explicit Resolution(const int resol): resol_(resol), comm_(oops::mpi::myself())
51  {ASSERT(comm_.size() == 1);}
52 
53  int npoints() const {return resol_;}
54 
55  Iterator begin() const;
56  Iterator end() const;
57  std::vector<double> verticalCoord(std::string &) const;
58  std::vector<size_t> variableSizes(const oops::Variables &) const;
59  const eckit::mpi::Comm & getComm() const {return comm_;}
60 
61  private:
62  void print(std::ostream & os) const {os << resol_;}
63  const int resol_;
64  const eckit::mpi::Comm & comm_;
65 };
66 
67 // -----------------------------------------------------------------------------
68 
69 } // namespace lorenz95
70 
71 #endif // LORENZ95_RESOLUTION_H_
Handles resolution.
Definition: Resolution.h:43
const eckit::mpi::Comm & comm_
Definition: Resolution.h:64
ResolutionParameters Parameters_
Definition: Resolution.h:45
const eckit::mpi::Comm & getComm() const
Definition: Resolution.h:59
int npoints() const
Definition: Resolution.h:53
Resolution(const int resol)
Definition: Resolution.h:50
Resolution(const ResolutionParameters &parameters, const eckit::mpi::Comm &comm)
Definition: Resolution.h:47
void print(std::ostream &os) const
Definition: Resolution.h:62
std::vector< size_t > variableSizes(const oops::Variables &) const
Definition: Resolution.cc:31
std::vector< double > verticalCoord(std::string &) const
Definition: Resolution.cc:26
Iterator begin() const
Definition: Resolution.cc:18
Iterator end() const
Definition: Resolution.cc:22
Parameters controlling a Lorenz95 model's resolution.
Definition: Resolution.h:32
oops::RequiredParameter< int > resol
Number of gridpoints.
Definition: Resolution.h:37
The namespace for the L95 model.
const eckit::mpi::Comm & myself()
Default communicator with each MPI task by itself.
Definition: oops/mpi/mpi.cc:90
The namespace for the main oops code.