Skip to content

Commit

Permalink
Merge branch 'hotfix/0.20.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
wdeconinck committed Apr 8, 2020
2 parents ee442b2 + faf3466 commit b9360f5
Show file tree
Hide file tree
Showing 22 changed files with 234 additions and 49 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html

## [Unreleased]

## [0.20.1] - 2019-04-08
### Fixed
- Make feature BOUNDSCHECKING work again. It was not turned on for DEBUG builds
- Workaround clang OpenMP bug
- Fix Segfault due to unexpected order of destruction of singleton objects

### Added
- atlas-grids tool can now be used to compute approximate North-South grid resolution

## [0.20.0] - 2019-03-06
### Fixed
- Pole edges hould not be created for global regular grids with points at poles
Expand Down Expand Up @@ -176,6 +185,7 @@ This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html
## 0.13.0 - 2018-02-16

[Unreleased]: https://github.com/ecmwf/atlas/compare/master...develop
[0.20.1]: https://github.com/ecmwf/atlas/compare/0.20.0...0.20.1
[0.20.0]: https://github.com/ecmwf/atlas/compare/0.20.0...0.19.2
[0.19.2]: https://github.com/ecmwf/atlas/compare/0.19.1...0.19.2
[0.19.1]: https://github.com/ecmwf/atlas/compare/0.19.0...0.19.1
Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ ecbuild_debug( " eckit_FEATURES : [${eckit_FEATURES}]" )
################################################################################
# Features that can be enabled / disabled with -DENABLE_<FEATURE>

include( features/BOUNDSCHECKING )
include( features/FORTRAN )
include( features/MPI )
include( features/OMP )
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.20.0
0.20.1
71 changes: 70 additions & 1 deletion src/apps/atlas-grids.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,51 @@
#include "atlas/grid/detail/grid/GridFactory.h"
#include "atlas/runtime/AtlasTool.h"

namespace atlas {

template <typename Value>
class FixedFormat {
public:
using value_type = Value;
FixedFormat( value_type x, long precision ) : x_( x ), precision_( precision > 0 ? precision : 20 ) {}
void print( std::ostream& out ) const {
for ( long precision = 0; precision <= precision_; ++precision ) {
if ( is_precision( precision ) || precision == precision_ ) {
out << std::setprecision( precision );
out << std::fixed << x_;
break;
}
}
}

bool is_precision( long precision ) const {
std::stringstream ss;
ss << std::setprecision( precision );
ss << std::fixed << x_;
value_type _x;
ss >> _x;
return std::abs( x_ - _x ) < 1.e-20;
}

friend std::ostream& operator<<( std::ostream& out, const FixedFormat& This ) {
This.print( out );
return out;
}

private:
float x_;
long precision_;
};

FixedFormat<double> fixed_format( double x, long precision ) {
return FixedFormat<double>( x, precision );
}
FixedFormat<float> fixed_format( float x, long precision ) {
return FixedFormat<float>( x, precision );
}

} // namespace atlas

//----------------------------------------------------------------------------------------------------------------------

struct AtlasGrids : public atlas::AtlasTool {
Expand All @@ -54,6 +99,9 @@ struct AtlasGrids : public atlas::AtlasTool {
add_option( new SimpleOption<bool>( "check", "Check grid" ) );
add_option( new SimpleOption<bool>( "check-uid", "Check grid uid required" ) );
add_option( new SimpleOption<bool>( "check-boundingbox", "Check grid bounding_box(n,w,s,e) required" ) );
add_option( new SimpleOption<long>( "precision", "Precision used for float output" ) );
add_option(
new SimpleOption<bool>( "approximate-resolution", "Approximate resolution in degrees (North-South)" ) );
}
};

Expand Down Expand Up @@ -85,7 +133,10 @@ int AtlasGrids::execute( const Args& args ) {
bool list = false;
args.get( "list", list );

bool do_run = list || ( !key.empty() && ( info || json || rtable || check ) );
bool approximate_resolution = false;
args.get( "approximate-resolution", approximate_resolution );

bool do_run = list || ( !key.empty() && ( info || json || rtable || check || approximate_resolution ) );

if ( !key.empty() && !do_run ) {
Log::error() << "Option wrong or missing after '" << key << "'" << std::endl;
Expand Down Expand Up @@ -240,6 +291,24 @@ int AtlasGrids::execute( const Args& args ) {
}
}

if ( approximate_resolution ) {
if ( auto structuredgrid = StructuredGrid( grid ) ) {
if ( structuredgrid.domain().global() ) {
auto deg = ( structuredgrid.y().front() - structuredgrid.y().back() ) / ( structuredgrid.ny() - 1 );

long precision = -1;
args.get( "precision", precision );
Log::info() << fixed_format( deg, precision ) << std::endl;
}
else {
ATLAS_NOTIMPLEMENTED;
}
}
else {
ATLAS_NOTIMPLEMENTED;
}
}

if ( json ) {
std::stringstream stream;
eckit::JSON js( stream );
Expand Down
14 changes: 5 additions & 9 deletions src/atlas/functionspace/CellColumns.cc
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ class CellColumnsHaloExchangeCache : public util::Cache<std::string, parallel::H
return inst;
}
util::ObjectHandle<value_type> get_or_create( const Mesh& mesh ) {
registerMesh( *mesh.get() );
creator_type creator = std::bind( &CellColumnsHaloExchangeCache::create, mesh );
return Base::get_or_create( key( *mesh.get() ), creator );
}
Expand All @@ -92,7 +93,6 @@ class CellColumnsHaloExchangeCache : public util::Cache<std::string, parallel::H
}

static value_type* create( const Mesh& mesh ) {
mesh.get()->attachObserver( instance() );
value_type* value = new value_type();
value->setup( array::make_view<int, 1>( mesh.cells().partition() ).data(),
array::make_view<idx_t, 1>( mesh.cells().remote_index() ).data(), REMOTE_IDX_BASE,
Expand All @@ -113,6 +113,7 @@ class CellColumnsGatherScatterCache : public util::Cache<std::string, parallel::
return inst;
}
util::ObjectHandle<value_type> get_or_create( const Mesh& mesh ) {
registerMesh( *mesh.get() );
creator_type creator = std::bind( &CellColumnsGatherScatterCache::create, mesh );
return Base::get_or_create( key( *mesh.get() ), creator );
}
Expand All @@ -126,7 +127,6 @@ class CellColumnsGatherScatterCache : public util::Cache<std::string, parallel::
}

static value_type* create( const Mesh& mesh ) {
mesh.get()->attachObserver( instance() );
value_type* value = new value_type();
value->setup( array::make_view<int, 1>( mesh.cells().partition() ).data(),
array::make_view<idx_t, 1>( mesh.cells().remote_index() ).data(), REMOTE_IDX_BASE,
Expand All @@ -147,6 +147,7 @@ class CellColumnsChecksumCache : public util::Cache<std::string, parallel::Check
return inst;
}
util::ObjectHandle<value_type> get_or_create( const Mesh& mesh ) {
registerMesh( *mesh.get() );
creator_type creator = std::bind( &CellColumnsChecksumCache::create, mesh );
return Base::get_or_create( key( *mesh.get() ), creator );
}
Expand All @@ -160,7 +161,6 @@ class CellColumnsChecksumCache : public util::Cache<std::string, parallel::Check
}

static value_type* create( const Mesh& mesh ) {
mesh.get()->attachObserver( instance() );
value_type* value = new value_type();
util::ObjectHandle<parallel::GatherScatter> gather(
CellColumnsGatherScatterCache::instance().get_or_create( mesh ) );
Expand Down Expand Up @@ -247,10 +247,7 @@ array::ArrayShape CellColumns::config_shape( const eckit::Configuration& config
}

CellColumns::CellColumns( const Mesh& mesh, const eckit::Configuration& config ) :
mesh_( mesh ),
cells_( mesh_.cells() ),
nb_levels_( config.getInt( "levels", 0 ) ),
nb_cells_( 0 ) {
mesh_( mesh ), cells_( mesh_.cells() ), nb_levels_( config.getInt( "levels", 0 ) ), nb_cells_( 0 ) {
ATLAS_TRACE();
if ( config.has( "halo" ) ) {
halo_ = mesh::Halo( config.getInt( "halo" ) );
Expand Down Expand Up @@ -769,8 +766,7 @@ void atlas__fs__CellColumns__checksum_field( const CellColumns* This, const fiel
CellColumns::CellColumns() : FunctionSpace(), functionspace_( nullptr ) {}

CellColumns::CellColumns( const FunctionSpace& functionspace ) :
FunctionSpace( functionspace ),
functionspace_( dynamic_cast<const detail::CellColumns*>( get() ) ) {}
FunctionSpace( functionspace ), functionspace_( dynamic_cast<const detail::CellColumns*>( get() ) ) {}

CellColumns::CellColumns( const Mesh& mesh, const eckit::Configuration& config ) :
FunctionSpace( new detail::CellColumns( mesh, config ) ),
Expand Down
14 changes: 5 additions & 9 deletions src/atlas/functionspace/EdgeColumns.cc
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ class EdgeColumnsHaloExchangeCache : public util::Cache<std::string, parallel::H
return inst;
}
util::ObjectHandle<value_type> get_or_create( const Mesh& mesh ) {
registerMesh( *mesh.get() );
creator_type creator = std::bind( &EdgeColumnsHaloExchangeCache::create, mesh );
return Base::get_or_create( key( *mesh.get() ), creator );
}
Expand All @@ -93,7 +94,6 @@ class EdgeColumnsHaloExchangeCache : public util::Cache<std::string, parallel::H
}

static value_type* create( const Mesh& mesh ) {
mesh.get()->attachObserver( instance() );
value_type* value = new value_type();
value->setup( array::make_view<int, 1>( mesh.edges().partition() ).data(),
array::make_view<idx_t, 1>( mesh.edges().remote_index() ).data(), REMOTE_IDX_BASE,
Expand All @@ -114,6 +114,7 @@ class EdgeColumnsGatherScatterCache : public util::Cache<std::string, parallel::
return inst;
}
util::ObjectHandle<value_type> get_or_create( const Mesh& mesh ) {
registerMesh( *mesh.get() );
creator_type creator = std::bind( &EdgeColumnsGatherScatterCache::create, mesh );
return Base::get_or_create( key( *mesh.get() ), creator );
}
Expand All @@ -127,7 +128,6 @@ class EdgeColumnsGatherScatterCache : public util::Cache<std::string, parallel::
}

static value_type* create( const Mesh& mesh ) {
mesh.get()->attachObserver( instance() );
value_type* value = new value_type();
value->setup( array::make_view<int, 1>( mesh.edges().partition() ).data(),
array::make_view<idx_t, 1>( mesh.edges().remote_index() ).data(), REMOTE_IDX_BASE,
Expand All @@ -148,6 +148,7 @@ class EdgeColumnsChecksumCache : public util::Cache<std::string, parallel::Check
return inst;
}
util::ObjectHandle<value_type> get_or_create( const Mesh& mesh ) {
registerMesh( *mesh.get() );
creator_type creator = std::bind( &EdgeColumnsChecksumCache::create, mesh );
return Base::get_or_create( key( *mesh.get() ), creator );
}
Expand All @@ -161,7 +162,6 @@ class EdgeColumnsChecksumCache : public util::Cache<std::string, parallel::Check
}

static value_type* create( const Mesh& mesh ) {
mesh.get()->attachObserver( instance() );
value_type* value = new value_type();
util::ObjectHandle<parallel::GatherScatter> gather(
EdgeColumnsGatherScatterCache::instance().get_or_create( mesh ) );
Expand Down Expand Up @@ -248,10 +248,7 @@ array::ArrayShape EdgeColumns::config_shape( const eckit::Configuration& config
}

EdgeColumns::EdgeColumns( const Mesh& mesh, const eckit::Configuration& config ) :
mesh_( mesh ),
edges_( mesh_.edges() ),
nb_levels_( config.getInt( "levels", 0 ) ),
nb_edges_( 0 ) {
mesh_( mesh ), edges_( mesh_.edges() ), nb_levels_( config.getInt( "levels", 0 ) ), nb_edges_( 0 ) {
ATLAS_TRACE();
if ( config.has( "halo" ) ) {
halo_ = mesh::Halo( config.getInt( "halo" ) );
Expand Down Expand Up @@ -767,8 +764,7 @@ void atlas__fs__EdgeColumns__checksum_field( const EdgeColumns* This, const fiel
EdgeColumns::EdgeColumns() : FunctionSpace(), functionspace_( nullptr ) {}

EdgeColumns::EdgeColumns( const FunctionSpace& functionspace ) :
FunctionSpace( functionspace ),
functionspace_( dynamic_cast<const detail::EdgeColumns*>( get() ) ) {}
FunctionSpace( functionspace ), functionspace_( dynamic_cast<const detail::EdgeColumns*>( get() ) ) {}

EdgeColumns::EdgeColumns( const Mesh& mesh, const eckit::Configuration& config ) :
FunctionSpace( new detail::EdgeColumns( mesh, config ) ),
Expand Down
16 changes: 5 additions & 11 deletions src/atlas/functionspace/NodeColumns.cc
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ class NodeColumnsHaloExchangeCache : public util::Cache<std::string, parallel::H
return inst;
}
util::ObjectHandle<value_type> get_or_create( const Mesh& mesh, long halo ) {
registerMesh( *mesh.get() );
creator_type creator = std::bind( &NodeColumnsHaloExchangeCache::create, mesh, halo );
return Base::get_or_create( key( *mesh.get(), halo ), creator );
}
Expand All @@ -97,8 +98,6 @@ class NodeColumnsHaloExchangeCache : public util::Cache<std::string, parallel::H
}

static value_type* create( const Mesh& mesh, long halo ) {
mesh.get()->attachObserver( instance() );

value_type* value = new value_type();

std::ostringstream ss;
Expand All @@ -125,6 +124,7 @@ class NodeColumnsGatherScatterCache : public util::Cache<std::string, parallel::
return inst;
}
util::ObjectHandle<value_type> get_or_create( const Mesh& mesh ) {
registerMesh( *mesh.get() );
creator_type creator = std::bind( &NodeColumnsGatherScatterCache::create, mesh );
return Base::get_or_create( key( *mesh.get() ), creator );
}
Expand All @@ -138,8 +138,6 @@ class NodeColumnsGatherScatterCache : public util::Cache<std::string, parallel::
}

static value_type* create( const Mesh& mesh ) {
mesh.get()->attachObserver( instance() );

value_type* value = new value_type();

mesh::IsGhostNode is_ghost( mesh.nodes() );
Expand Down Expand Up @@ -176,6 +174,7 @@ class NodeColumnsChecksumCache : public util::Cache<std::string, parallel::Check
return inst;
}
util::ObjectHandle<value_type> get_or_create( const Mesh& mesh ) {
registerMesh( *mesh.get() );
creator_type creator = std::bind( &NodeColumnsChecksumCache::create, mesh );
return Base::get_or_create( key( *mesh.get() ), creator );
}
Expand All @@ -189,7 +188,6 @@ class NodeColumnsChecksumCache : public util::Cache<std::string, parallel::Check
}

static value_type* create( const Mesh& mesh ) {
mesh.get()->attachObserver( instance() );
value_type* value = new value_type();
util::ObjectHandle<parallel::GatherScatter> gather(
NodeColumnsGatherScatterCache::instance().get_or_create( mesh ) );
Expand All @@ -201,10 +199,7 @@ class NodeColumnsChecksumCache : public util::Cache<std::string, parallel::Check
NodeColumns::NodeColumns( Mesh mesh ) : NodeColumns( mesh, util::NoConfig() ) {}

NodeColumns::NodeColumns( Mesh mesh, const eckit::Configuration& config ) :
mesh_( mesh ),
nodes_( mesh_.nodes() ),
nb_levels_( config.getInt( "levels", 0 ) ),
nb_nodes_( 0 ) {
mesh_( mesh ), nodes_( mesh_.nodes() ), nb_levels_( config.getInt( "levels", 0 ) ), nb_nodes_( 0 ) {
ATLAS_TRACE();
if ( config.has( "halo" ) ) {
halo_ = mesh::Halo( config.getInt( "halo" ) );
Expand Down Expand Up @@ -591,8 +586,7 @@ const parallel::Checksum& NodeColumns::checksum() const {
NodeColumns::NodeColumns() : FunctionSpace(), functionspace_( nullptr ) {}

NodeColumns::NodeColumns( const FunctionSpace& functionspace ) :
FunctionSpace( functionspace ),
functionspace_( dynamic_cast<const detail::NodeColumns*>( get() ) ) {}
FunctionSpace( functionspace ), functionspace_( dynamic_cast<const detail::NodeColumns*>( get() ) ) {}

namespace {
detail::NodeColumns* make_functionspace( Mesh mesh, const eckit::Configuration& config ) {
Expand Down
Loading

0 comments on commit b9360f5

Please sign in to comment.