Skip to content

Commit f4ccfa3

Browse files
committed
Merge branch 'release/0.14.0'
* release/0.14.0: Update travis Update changelog Require eckit 0.20.0 Version 0.14.0 ATLAS-134: TransCacheMemoryEntry eckit::geometry::Sphere update (Willem, please confirm)
2 parents 8d62366 + 40bf19e commit f4ccfa3

31 files changed

+179
-371
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ install:
196196
### Install eckit
197197
install-dep.sh --repo eckit --branch ${DEPS_BRANCH} --prefix ${DEPS_DIR}/eckit --cmake "-DENABLE_TESTS=OFF -DCMAKE_BUILD_TYPE=DEBUG ${ECKIT_CMAKE_OPTIONS}"
198198
- export ECKIT_PATH=${DEPS_DIR}/eckit
199-
- ${DEPS_DIR}/eckit/bin/eckit_version
199+
- ${DEPS_DIR}/eckit/bin/eckit-version
200200

201201
#################################################################
202202
# Install fckit

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html
77

88
## [Unreleased]
99

10+
## [0.14.0] - 2018-03-22
11+
### Added
12+
- Spherical Harmonics transforms can receive a cache memory handle
13+
14+
### Changed
15+
- Earth interface (C++)
16+
- Requires eckit 0.20.0, fckit 0.5.0
17+
1018
## [0.13.2] - 2018-03-20
1119
### Fixed
1220
- C++ compilation using PGI 17, 18 and GCC 7
@@ -22,5 +30,6 @@ This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html
2230
## 0.13.0 - 2018-02-16
2331

2432
[Unreleased]: https://github.com/ecmwf/atlas/compare/master...develop
33+
[0.14.0]: https://github.com/ecmwf/atlas/compare/0.13.2...0.14.0
2534
[0.13.2]: https://github.com/ecmwf/atlas/compare/0.13.1...0.13.2
2635
[0.13.1]: https://github.com/ecmwf/atlas/compare/0.13.0...0.13.1

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ ecbuild_declare_project()
3131

3232
### eckit
3333

34-
ecbuild_use_package( PROJECT eckit VERSION 0.18.1 REQUIRED )
34+
ecbuild_use_package( PROJECT eckit VERSION 0.20.0 REQUIRED )
3535
ecbuild_debug( " ECKIT_FEATURES : [${ECKIT_FEATURES}]" )
3636

3737
# options & dependencies

VERSION.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66
# granted to it by virtue of its status as an intergovernmental organisation nor
77
# does it submit to any jurisdiction.
88

9-
set ( ${PROJECT_NAME}_VERSION_STR "0.13.2" )
9+
set ( ${PROJECT_NAME}_VERSION_STR "0.14.0" )
1010

src/apps/atlas-benchmark.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ void AtlasBenchmark::execute( const Args& args ) {
279279
//----------------------------------------------------------------------------------------------------------------------
280280

281281
void AtlasBenchmark::initial_condition( const Field& field, const double& beta ) {
282-
const double radius = util::Earth::radiusInMeters();
282+
const double radius = util::Earth::radius();
283283
const double USCAL = 20.;
284284
const double pvel = USCAL / radius;
285285
const double deg2rad = M_PI / 180.;

src/atlas/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,6 @@ runtime/ErrorHandling.h
452452
util/Config.cc
453453
util/Config.h
454454
util/Constants.h
455-
util/Earth.cc
456455
util/Earth.h
457456
util/GaussianLatitudes.cc
458457
util/GaussianLatitudes.h
@@ -466,6 +465,7 @@ util/Rotation.cc
466465
util/Rotation.h
467466
util/SphericalPolygon.cc
468467
util/SphericalPolygon.h
468+
util/UnitSphere.h
469469
util/detail/BlackMagic.h
470470
util/detail/Cache.h
471471
util/detail/Debug.h

src/atlas/grid/detail/grid/Structured.cc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
#include "atlas/grid/detail/spacing/LinearSpacing.h"
2323
#include "atlas/runtime/ErrorHandling.h"
2424
#include "atlas/runtime/Log.h"
25-
#include "atlas/util/Earth.h"
2625
#include "atlas/util/Point.h"
26+
#include "atlas/util/UnitSphere.h"
2727

2828
namespace atlas {
2929
namespace grid {
@@ -438,8 +438,11 @@ void Structured::computeTruePeriodicity() {
438438
const PointLonLat Pllmin = projection().lonlat( PointXY( xmin_[j], y_[j] ) );
439439
const PointLonLat Pllmax = projection().lonlat( PointXY( xmax_[j], y_[j] ) );
440440

441-
Point3 Pxmin = util::Earth::convertGeodeticToGeocentric( Pllmin, 1. );
442-
Point3 Pxmax = util::Earth::convertGeodeticToGeocentric( Pllmax, 1. );
441+
Point3 Pxmin;
442+
util::UnitSphere::convertSphericalToCartesian(Pllmin, Pxmin );
443+
444+
Point3 Pxmax;
445+
util::UnitSphere::convertSphericalToCartesian(Pllmax, Pxmax );
443446

444447
periodic_x_ = points_equal( Pxmin, Pxmax );
445448
}

src/atlas/grid/detail/grid/Structured.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,8 @@ class Structured : public Grid {
140140
}
141141

142142
private:
143-
Grid::IteratorXY::Predicate p_;
144143
const Structured& grid_;
144+
Grid::IteratorXY::Predicate p_;
145145
size_t i_;
146146
size_t j_;
147147
size_t n_;

src/atlas/grid/detail/grid/Unstructured.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ class Unstructured : public Grid {
112112
private:
113113
const Unstructured& grid_;
114114
Grid::IteratorXY::Predicate p_;
115-
size_t n_;
116115
size_t size_;
116+
size_t n_;
117117
};
118118

119119
class IteratorLonLat : public Grid::IteratorLonLat {

src/atlas/interpolation/method/FiniteElement.cc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ void FiniteElement::setup( const FunctionSpace& source, const FunctionSpace& tar
6565
PointXYZ p2;
6666
for ( size_t n = 0; n < N; ++n ) {
6767
const PointLonLat p1( lonlat( n, 0 ), lonlat( n, 1 ) );
68-
p2 = util::Earth::convertGeodeticToGeocentric( p1 );
68+
util::Earth::convertSphericalToCartesian( p1, p2 );
6969
xyz( n, 0 ) = p2.x();
7070
xyz( n, 1 ) = p2.y();
7171
xyz( n, 2 ) = p2.z();
@@ -148,7 +148,8 @@ void FiniteElement::setup( const FunctionSpace& source ) {
148148
failures.push_back( ip );
149149
Log::debug() << "------------------------------------------------------"
150150
"---------------------\n";
151-
const PointLonLat pll = util::Earth::convertGeocentricToGeodetic( p );
151+
PointLonLat pll;
152+
util::Earth::convertCartesianToSpherical( p, pll );
152153
Log::debug() << "Failed to project point (lon,lat)=" << pll << '\n';
153154
Log::debug() << failures_log.str();
154155
}
@@ -163,7 +164,8 @@ void FiniteElement::setup( const FunctionSpace& source ) {
163164
msg << "Rank " << eckit::mpi::comm().rank() << " failed to project points:\n";
164165
for ( std::vector<size_t>::const_iterator i = failures.begin(); i != failures.end(); ++i ) {
165166
const PointXYZ p{( *ocoords_ )( *i, 0 ), ( *ocoords_ )( *i, 1 ), ( *ocoords_ )( *i, 2 )}; // lookup point
166-
const PointLonLat pll = util::Earth::convertGeocentricToGeodetic( p );
167+
PointLonLat pll;
168+
util::Earth::convertCartesianToSpherical(p, pll);
167169
msg << "\t(lon,lat) = " << pll << "\n";
168170
}
169171

src/atlas/mesh/actions/BuildStatistics.cc

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,11 @@
2929
#include "atlas/mesh/actions/BuildDualMesh.h"
3030
#include "atlas/parallel/Checksum.h"
3131
#include "atlas/runtime/ErrorHandling.h"
32+
#include "atlas/util/Constants.h"
3233
#include "atlas/util/CoordinateEnums.h"
3334
#include "atlas/util/Earth.h"
3435
#include "atlas/util/Point.h"
36+
#include "atlas/util/UnitSphere.h"
3537

3638
namespace atlas {
3739
namespace mesh {
@@ -62,9 +64,11 @@ void quad_quality( double& eta, double& rho, const PointLonLat& p1, const PointL
6264
const PointLonLat& p4 ) {
6365
// see http://geuz.org/gmsh/doc/preprints/gmsh_quad_preprint.pdf
6466

65-
const PointXYZ xyz[]{
66-
util::Earth::convertGeodeticToGeocentric( p1, 1. ), util::Earth::convertGeodeticToGeocentric( p2, 1. ),
67-
util::Earth::convertGeodeticToGeocentric( p3, 1. ), util::Earth::convertGeodeticToGeocentric( p4, 1. )};
67+
PointXYZ xyz[4];
68+
util::UnitSphere::convertSphericalToCartesian(p1, xyz[0]);
69+
util::UnitSphere::convertSphericalToCartesian(p2, xyz[1]);
70+
util::UnitSphere::convertSphericalToCartesian(p3, xyz[2]);
71+
util::UnitSphere::convertSphericalToCartesian(p4, xyz[3]);
6872

6973
PointXYZ l2m1( PointXYZ::sub( xyz[1], xyz[0] ) );
7074
PointXYZ l3m2( PointXYZ::sub( xyz[2], xyz[1] ) );
@@ -123,7 +127,7 @@ void build_statistics( Mesh& mesh ) {
123127
int ip2 = edge_nodes( jedge, 1 );
124128
PointLonLat p1( lonlat( ip1, LON ), lonlat( ip1, LAT ) );
125129
PointLonLat p2( lonlat( ip2, LON ), lonlat( ip2, LAT ) );
126-
dist( jedge ) = util::Earth::distanceInMeters( p1, p2 ) * 1e-3;
130+
dist( jedge ) = util::Earth::distance( p1, p2 ) * 1e-3;
127131
}
128132
}
129133

@@ -209,8 +213,8 @@ void build_statistics( Mesh& mesh ) {
209213

210214
for ( size_t jnode = 0; jnode < nodes.size(); ++jnode ) {
211215
const double lat = util::Constants::degreesToRadians() * lonlat( jnode, LAT );
212-
const double hx = util::Constants::degreesToRadians() * util::Earth::radiusInKm() * std::cos( lat );
213-
const double hy = util::Constants::degreesToRadians() * util::Earth::radiusInKm();
216+
const double hx = util::Constants::degreesToRadians() * util::Earth::radius() * std::cos( lat );
217+
const double hy = util::Constants::degreesToRadians() * util::Earth::radius();
214218
dual_delta_sph( jnode ) = std::sqrt( dual_volumes( jnode ) * hx * hy );
215219
}
216220

src/atlas/mesh/actions/BuildXYZField.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Field& BuildXYZField::operator()( mesh::Nodes& nodes ) const {
4444
PointXYZ p2;
4545
for ( size_t n = 0; n < nodes.size(); ++n ) {
4646
const PointLonLat p1( lonlat( n, 0 ), lonlat( n, 1 ) );
47-
p2 = util::Earth::convertGeodeticToGeocentric( p1 );
47+
util::Earth::convertSphericalToCartesian( p1, p2 );
4848
xyz( n, 0 ) = p2.x();
4949
xyz( n, 1 ) = p2.y();
5050
xyz( n, 2 ) = p2.z();

src/atlas/mesh/actions/ExtendNodesGlobal.cc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
* nor does it submit to any jurisdiction.
99
*/
1010

11-
#include "eckit/exception/Exceptions.h"
11+
#include "atlas/mesh/actions/ExtendNodesGlobal.h"
1212

13+
#include "eckit/exception/Exceptions.h"
1314
#include "atlas/field/Field.h"
1415
#include "atlas/grid/Grid.h"
1516
#include "atlas/mesh/Mesh.h"
1617
#include "atlas/mesh/Nodes.h"
17-
#include "atlas/mesh/actions/ExtendNodesGlobal.h"
1818
#include "atlas/util/CoordinateEnums.h"
1919
#include "atlas/util/Earth.h"
2020

@@ -64,7 +64,10 @@ void ExtendNodesGlobal::operator()( const Grid& grid, Mesh& mesh ) const {
6464
for ( size_t i = 0; i < nb_extension_pts; ++i ) {
6565
const size_t n = nb_real_pts + i;
6666
const PointLonLat pLL = grid.projection().lonlat( extended_pts[i] );
67-
const PointXYZ pXYZ = util::Earth::convertGeodeticToGeocentric( pLL );
67+
68+
PointXYZ pXYZ;
69+
util::Earth::convertSphericalToCartesian( pLL, pXYZ );
70+
6871
xyz( n, XX ) = pXYZ.x();
6972
xyz( n, YY ) = pXYZ.y();
7073
xyz( n, ZZ ) = pXYZ.z();

src/atlas/numerics/fvm/Method.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ size_t get_levels( const eckit::Parametrisation& params ) {
5151
}
5252

5353
double get_radius( const eckit::Parametrisation& params ) {
54-
double radius = util::Earth::radiusInMeters();
54+
double radius = util::Earth::radius();
5555
params.get( "radius", radius );
5656
return radius;
5757
}

src/atlas/option/Options.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ radius::radius( double _radius ) {
5858
}
5959

6060
radius::radius( const std::string& key ) {
61-
if ( key == "Earth" ) { set( "radius", util::Earth::radiusInMeters() ); }
61+
if ( key == "Earth" ) { set( "radius", util::Earth::radius() ); }
6262
else {
6363
NOTIMP;
6464
}

src/atlas/projection/detail/LambertProjection.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ namespace detail {
3838
// constructors
3939
LambertProjection::LambertProjection( const eckit::Parametrisation& params ) {
4040
// check presence of radius
41-
if ( !params.get( "radius", radius_ ) ) radius_ = util::Earth::radiusInMeters();
41+
if ( !params.get( "radius", radius_ ) ) radius_ = util::Earth::radius();
4242
// check presence of lat1 and lat2
4343
if ( !params.get( "latitude1", lat1_ ) ) throw eckit::BadParameter( "latitude1 missing in Params", Here() );
4444
if ( !params.get( "latitude2", lat2_ ) ) lat2_ = lat1_;
@@ -95,7 +95,7 @@ LambertProjection::Spec LambertProjection::spec() const {
9595
proj_spec.set( "latitude1", lat1_ );
9696
proj_spec.set( "latitude2", lat2_ );
9797
proj_spec.set( "longitude0", lon0_ );
98-
if ( radius_ != util::Earth::radiusInMeters() ) proj_spec.set( "radius", radius_ );
98+
if ( radius_ != util::Earth::radius() ) proj_spec.set( "radius", radius_ );
9999
return proj_spec;
100100
}
101101

src/atlas/projection/detail/MercatorProjection.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ MercatorProjectionT<Rotation>::MercatorProjectionT( const eckit::Parametrisation
4141
ProjectionImpl(),
4242
rotation_( params ) {
4343
// check presence of radius
44-
if ( !params.get( "radius", radius_ ) ) radius_ = util::Earth::radiusInMeters();
44+
if ( !params.get( "radius", radius_ ) ) radius_ = util::Earth::radius();
4545
// check presence of lon0
4646
if ( !params.get( "longitude0", lon0_ ) ) lon0_ = 0.0;
4747

@@ -74,7 +74,7 @@ typename MercatorProjectionT<Rotation>::Spec MercatorProjectionT<Rotation>::spec
7474
Spec proj_spec;
7575
proj_spec.set( "type", static_type() );
7676
proj_spec.set( "longitude0", lon0_ );
77-
if ( radius_ != util::Earth::radiusInMeters() ) proj_spec.set( "radius", radius_ );
77+
if ( radius_ != util::Earth::radius() ) proj_spec.set( "radius", radius_ );
7878
rotation_.spec( proj_spec );
7979
return proj_spec;
8080
}

src/atlas/trans/Trans.h

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@ class TransCacheEntry {
4444
virtual const void* data() const = 0;
4545
};
4646

47-
class EmptyCacheEntry : public TransCacheEntry {
47+
class EmptyCacheEntry final : public TransCacheEntry {
4848
public:
4949
virtual size_t size() const override { return 0; }
5050
virtual const void* data() const override { return nullptr; }
5151
};
5252

53-
class TransCacheFileEntry : public TransCacheEntry {
53+
class TransCacheFileEntry final : public TransCacheEntry {
5454
eckit::Buffer buffer_;
5555

5656
public:
@@ -64,6 +64,21 @@ class TransCacheFileEntry : public TransCacheEntry {
6464
virtual const void* data() const override { return buffer_.data(); }
6565
};
6666

67+
class TransCacheMemoryEntry final : public TransCacheEntry {
68+
public:
69+
TransCacheMemoryEntry(const void* data, size_t size) : data_(data), size_(size) {
70+
ASSERT(data_);
71+
ASSERT(size_);
72+
}
73+
virtual const void* data() const override { return data_; }
74+
virtual size_t size() const override { return size_; }
75+
private:
76+
const void* data_;
77+
const size_t size_;
78+
};
79+
80+
//-----------------------------------------------------------------------------
81+
6782
class Cache {
6883
public:
6984
Cache() : legendre_( new EmptyCacheEntry() ), fft_( new EmptyCacheEntry() ) {}
@@ -86,6 +101,9 @@ class Cache {
86101

87102
class LegendreCache : public Cache {
88103
public:
104+
LegendreCache(const void* address, size_t size) :
105+
Cache(std::make_shared<atlas::trans::TransCacheMemoryEntry>(address, size)) {
106+
}
89107
LegendreCache( const eckit::PathName& path ) :
90108
Cache( std::shared_ptr<TransCacheEntry>( new TransCacheFileEntry( path ) ) ) {}
91109
};

src/atlas/trans/local/TransLocal.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "atlas/trans/local/FourierTransforms.h"
1919
#include "atlas/trans/local/LegendrePolynomials.h"
2020
#include "atlas/trans/local/LegendreTransforms.h"
21+
#include "atlas/util/Constants.h"
2122

2223
namespace atlas {
2324
namespace trans {

src/atlas/trans/local/TransLocal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ class TransLocal : public trans::TransImpl {
108108
const eckit::Configuration& = util::NoConfig() ) const;
109109

110110
private:
111-
int truncation_;
112111
Grid grid_;
112+
int truncation_;
113113
bool precompute_;
114114
std::vector<double> legendre_;
115115
std::vector<size_t> legendre_begin_;

src/atlas/trans/local/VorDivToUVLocal.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
* nor does it submit to any jurisdiction.
99
*/
1010

11+
#include <cmath> // for std::sqrt
1112
#include "atlas/trans/local/VorDivToUVLocal.h"
1213
#include "atlas/functionspace/Spectral.h"
1314
#include "atlas/runtime/Log.h"
@@ -78,7 +79,7 @@ void vd2uv( const int truncation, // truncation
7879
repsnm[0] = 0.;
7980

8081
// rlapin: constant factor from eq.(2.2) and (2.3) in [Temperton 1991]
81-
double ra = util::Earth::radiusInMeters();
82+
double ra = util::Earth::radius();
8283
std::vector<double> rlapin( truncation + 3 );
8384
for ( int jn = 1; jn <= truncation + 2; ++jn ) {
8485
rlapin[jn] = -ra * ra / ( jn * ( jn + 1. ) );
@@ -145,7 +146,7 @@ void vd2uv( const int truncation, // truncation
145146
int ilcm = truncation - km;
146147
int ioff = ( 2 * truncation - km + 3 ) * km;
147148
// ioff: start index of zonal wavenumber km in spectral data
148-
double za_r = 1. / util::Earth::radiusInMeters();
149+
double za_r = 1. / util::Earth::radius();
149150
for ( int j = 0; j <= ilcm; ++j ) {
150151
// ilcm-j = total wavenumber
151152
int inm = ioff + ( ilcm - j ) * 2;

0 commit comments

Comments
 (0)