SOCA
Geometry.cc
Go to the documentation of this file.
1 /*
2  * (C) Copyright 2017-2021 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 "atlas/field.h"
9 #include "atlas/functionspace.h"
10 #include "atlas/grid.h"
11 #include "atlas/util/Config.h"
12 
13 #include "eckit/config/YAMLConfiguration.h"
14 
15 #include "soca/Geometry/Geometry.h"
16 
17 // -----------------------------------------------------------------------------
18 namespace soca {
19  // -----------------------------------------------------------------------------
20  Geometry::Geometry(const eckit::Configuration & conf,
21  const eckit::mpi::Comm & comm)
22  : comm_(comm),
23  atmconf_(conf),
24  initatm_(initAtm(conf)),
25  fmsinput_(comm, conf) {
26 
28 
29  soca_geo_setup_f90(keyGeom_, &conf, &comm);
30 
31  // Set ATLAS lon/lat field
32  atlasFieldSet_.reset(new atlas::FieldSet());
34  atlas::Field atlasField = atlasFieldSet_->field("lonlat");
35 
36  // Create ATLAS function space
37  atlasFunctionSpace_.reset(new atlas::functionspace::PointCloud(atlasField));
38 
39  // Set ATLAS function space pointer in Fortran
41  atlasFunctionSpace_->get());
42 
43  // Fill ATLAS fieldset
44  atlasFieldSet_.reset(new atlas::FieldSet());
46  }
47  // -----------------------------------------------------------------------------
49  : comm_(other.comm_),
50  atmconf_(other.atmconf_),
51  initatm_(initAtm(other.atmconf_)),
52  fmsinput_(other.fmsinput_) {
53  const int key_geo = other.keyGeom_;
54  soca_geo_clone_f90(keyGeom_, key_geo);
55  atlasFunctionSpace_.reset(new atlas::functionspace::PointCloud(
56  other.atlasFunctionSpace_->lonlat()));
58  atlasFunctionSpace_->get());
59  atlasFieldSet_.reset(new atlas::FieldSet());
60  for (int jfield = 0; jfield < other.atlasFieldSet_->size(); ++jfield) {
61  atlas::Field atlasField = other.atlasFieldSet_->field(jfield);
62  atlasFieldSet_->add(atlasField);
63  }
64  }
65  // -----------------------------------------------------------------------------
68  }
69  // -----------------------------------------------------------------------------
70  void Geometry::gridgen() const {
72  }
73  // -----------------------------------------------------------------------------
75  // return start of the geometry on this mpi tile
76  int ist, iend, jst, jend;
77  soca_geo_start_end_f90(keyGeom_, ist, iend, jst, jend);
78  return GeometryIterator(*this, ist, jst);
79  }
80  // -----------------------------------------------------------------------------
82  // return end of the geometry on this mpi tile
83  // decided to return index out of bounds for the iterator loops to work
84  return GeometryIterator(*this, -1, -1);
85  }
86  // -----------------------------------------------------------------------------
87  std::vector<size_t> Geometry::variableSizes(
88  const oops::Variables & vars) const {
89  std::vector<size_t> lvls(vars.size());
90  soca_geo_get_num_levels_f90(toFortran(), vars, lvls.size(), lvls.data());
91  return lvls;
92  }
93  // -----------------------------------------------------------------------------
94  void Geometry::print(std::ostream & os) const {
95  // TODO(Travis): Implement this correctly.
96  }
97  // -----------------------------------------------------------------------------
98  atlas::FunctionSpace * Geometry::atlasFunctionSpace() const {
99  return atlasFunctionSpace_.get();
100  }
101  // -----------------------------------------------------------------------------
102  atlas::FieldSet * Geometry::atlasFieldSet() const {
103  return atlasFieldSet_.get();
104  }
105  // -----------------------------------------------------------------------------
106 } // namespace soca
Geometry handles geometry for SOCA model.
Definition: Geometry.h:48
FmsInput fmsinput_
Definition: Geometry.h:82
std::vector< size_t > variableSizes(const oops::Variables &vars) const
Definition: Geometry.cc:87
GeometryIterator begin() const
Definition: Geometry.cc:74
void gridgen() const
Definition: Geometry.cc:70
atlas::FunctionSpace * atlasFunctionSpace() const
Definition: Geometry.cc:98
std::unique_ptr< atlas::FieldSet > atlasFieldSet_
Definition: Geometry.h:84
atlas::FieldSet * atlasFieldSet() const
Definition: Geometry.cc:102
std::unique_ptr< atlas::functionspace::PointCloud > atlasFunctionSpace_
Definition: Geometry.h:83
Geometry(const eckit::Configuration &, const eckit::mpi::Comm &)
Definition: Geometry.cc:20
GeometryIterator end() const
Definition: Geometry.cc:81
int & toFortran()
Definition: Geometry.h:61
void print(std::ostream &) const
Definition: Geometry.cc:94
void soca_geo_gridgen_f90(const F90geom &)
void soca_geo_set_atlas_functionspace_pointer_f90(const F90geom &, atlas::functionspace::FunctionSpaceImpl *)
void soca_geo_clone_f90(F90geom &, const F90geom &)
void soca_geo_delete_f90(F90geom &)
void soca_geo_start_end_f90(const F90geom &, int &, int &, int &, int &)
void soca_geo_fill_atlas_fieldset_f90(const F90geom &, atlas::field::FieldSetImpl *)
void soca_geo_setup_f90(F90geom &, const eckit::Configuration *const &, const eckit::mpi::Comm *)
void soca_geo_set_atlas_lonlat_f90(const F90geom &, atlas::field::FieldSetImpl *)
void soca_geo_get_num_levels_f90(const F90geom &, const oops::Variables &, const size_t &, size_t[])
void updateNameList()
Definition: FmsInput.cc:41