| 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 |
/// @author Willem Deconinck |
| 12 |
/// @date Mar 2016 |
| 13 |
|
| 14 |
#include "PointsPerLatitude.h" |
| 15 |
|
| 16 |
#include <memory> |
| 17 |
#include <sstream> |
| 18 |
|
| 19 |
#include "atlas/grid/detail/pl/classic_gaussian/N.h" |
| 20 |
#include "atlas/runtime/Exception.h" |
| 21 |
|
| 22 |
|
| 23 |
namespace atlas { |
| 24 |
namespace grid { |
| 25 |
namespace detail { |
| 26 |
namespace pl { |
| 27 |
namespace classic_gaussian { |
| 28 |
|
| 29 |
//----------------------------------------------------------------------------- |
| 30 |
|
| 31 |
template <typename Int> |
| 32 |
void points_per_latitude_npole_equator_impl(const size_t N, Int nlon[]) { |
| 33 |
std::stringstream Nstream; |
| 34 |
Nstream << N; |
| 35 |
std::string Nstr = Nstream.str(); |
| 36 |
if (PointsPerLatitudeFactory::has(Nstr)) { |
| 37 |
std::unique_ptr<const PointsPerLatitude> pl(PointsPerLatitudeFactory::build(Nstr)); |
| 38 |
pl->assign(nlon, N); |
| 39 |
} |
| 40 |
else { |
| 41 |
throw_Exception("gaussian::classic::PointsPerLatitude not available for N" + Nstr, Here()); |
| 42 |
} |
| 43 |
} |
| 44 |
|
| 45 |
//----------------------------------------------------------------------------- |
| 46 |
|
| 47 |
template <typename Int> |
| 48 |
void points_per_latitude_npole_spole_impl(const size_t N, Int nlon[]) { |
| 49 |
points_per_latitude_npole_equator(N, nlon); |
| 50 |
size_t end = 2 * N - 1; |
| 51 |
for (size_t jlat = 0; jlat < N; ++jlat) { |
| 52 |
nlon[end--] = nlon[jlat]; |
| 53 |
} |
| 54 |
} |
| 55 |
|
| 56 |
//----------------------------------------------------------------------------- |
| 57 |
|
| 58 |
void points_per_latitude_npole_equator(const size_t N, long nlon[]) { |
| 59 |
points_per_latitude_npole_equator_impl(N, nlon); |
| 60 |
} |
| 61 |
void points_per_latitude_npole_equator(const size_t N, int nlon[]) { |
| 62 |
points_per_latitude_npole_equator_impl(N, nlon); |
| 63 |
} |
| 64 |
|
| 65 |
//----------------------------------------------------------------------------- |
| 66 |
|
| 67 |
void points_per_latitude_npole_spole(const size_t N, long nlon[]) { |
| 68 |
points_per_latitude_npole_spole_impl(N, nlon); |
| 69 |
} |
| 70 |
void points_per_latitude_npole_spole(const size_t N, int nlon[]) { |
| 71 |
points_per_latitude_npole_spole_impl(N, nlon); |
| 72 |
} |
| 73 |
|
| 74 |
//----------------------------------------------------------------------------- |
| 75 |
|
| 76 |
} // namespace classic_gaussian |
| 77 |
} // namespace pl |
| 78 |
} // namespace detail |
| 79 |
} // namespace grid |
| 80 |
} // namespace atlas |