| 1 |
/* |
| 2 |
* (C) Copyright 2013 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 |
| 8 |
* nor does it submit to any jurisdiction. |
| 9 |
*/ |
| 10 |
|
| 11 |
#include <ostream> |
| 12 |
|
| 13 |
#include "eckit/utils/Hash.h" |
| 14 |
|
| 15 |
#include "atlas/domain/detail/DomainFactory.h" |
| 16 |
#include "atlas/domain/detail/GlobalDomain.h" |
| 17 |
|
| 18 |
namespace atlas { |
| 19 |
namespace domain { |
| 20 |
|
| 21 |
namespace { |
| 22 |
constexpr std::array<double, 2> yrange() { |
| 23 |
return {-90., 90.}; |
| 24 |
} |
| 25 |
|
| 26 |
static double get_west(const eckit::Parametrisation& params) { |
| 27 |
double west = 0.; |
| 28 |
params.get("west", west); |
| 29 |
return west; |
| 30 |
} |
| 31 |
|
| 32 |
} // namespace |
| 33 |
|
| 34 |
GlobalDomain::GlobalDomain(const double west): ZonalBandDomain(yrange(), west) {} |
| 35 |
|
| 36 |
GlobalDomain::GlobalDomain(): ZonalBandDomain(yrange()) {} |
| 37 |
|
| 38 |
GlobalDomain::GlobalDomain(const eckit::Parametrisation& params): GlobalDomain(get_west(params)) {} |
| 39 |
|
| 40 |
GlobalDomain::Spec GlobalDomain::spec() const { |
| 41 |
Spec domain_spec; |
| 42 |
domain_spec.set("type", type()); |
| 43 |
if (xmin() != 0.) { |
| 44 |
domain_spec.set("west", xmin()); |
| 45 |
} |
| 46 |
return domain_spec; |
| 47 |
} |
| 48 |
|
| 49 |
void GlobalDomain::hash(eckit::Hash& h) const { |
| 50 |
h.add(type()); |
| 51 |
} |
| 52 |
|
| 53 |
void GlobalDomain::print(std::ostream& os) const { |
| 54 |
os << "GlobalDomain[west=" << xmin() << "]"; |
| 55 |
} |
| 56 |
|
| 57 |
namespace { |
| 58 |
static DomainBuilder<GlobalDomain> register_builder(GlobalDomain::static_type()); |
| 59 |
} |
| 60 |
} // namespace domain |
| 61 |
} // namespace atlas |