Skip to content

Commit

Permalink
Merge branch 'release/0.18.1'
Browse files Browse the repository at this point in the history
* release/0.18.1:
  Version 0.18.1
  Feature CLANG_TIDY only ON by default for supported compilers (GNU, Clang)
  ATLAS-243 Remove assertion in StructuredInterpolation3D
  ATLAS-244 Fix StructuredColumnsHaloExchangeCache
  Remove dead code
  ATLAS-243 Fixup
  ATLAS-243 Fix Structured Interpolation to match old semi-Lagrangian Dwarf
  ATLAS-243 Fortran: atlas_Field%strides function
  ATLAS-243 Fortran: create StructuredColumns with Vertical levels with extra interval
  ATLAS-243 Fix index access in NativeArrayView
  • Loading branch information
wdeconinck committed Aug 10, 2019
2 parents 327e213 + 75942f6 commit 0ef1dad
Show file tree
Hide file tree
Showing 28 changed files with 539 additions and 477 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ install:
### Install CMake
if [[ "${TRAVIS_OS_NAME}" == "linux" ]]; then
if [[ -z "$(ls -A ${DEPS_DIR}/cmake)" ]]; then
CMAKE_URL="https://cmake.org/files/v3.10/cmake-3.10.2-Linux-x86_64.tar.gz"
CMAKE_URL="https://cmake.org/files/v3.15.2/cmake-3.15.2-Linux-x86_64.tar.gz"
mkdir -p ${DEPS_DIR}/cmake && travis_retry wget --no-check-certificate --quiet -O - ${CMAKE_URL} | tar --strip-components=1 -xz -C ${DEPS_DIR}/cmake
fi
export PATH=${DEPS_DIR}/cmake/bin:${PATH}
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html

## [Unreleased]

## [0.18.1] - 2019-08-10
### Fixed
- Match vertical structured interpolation to IFS
- Fix in creating vertical dimension in StructuredColumns using interval
- Fix in caching StructuredColumnsHaloExchange

## [0.18.0] - 2019-07-15
### Changed
- Make grid hashes crossplatform
Expand Down Expand Up @@ -128,6 +134,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.18.1]: https://github.com/ecmwf/atlas/compare/0.18.0...0.18.1
[0.18.0]: https://github.com/ecmwf/atlas/compare/0.17.2...0.18.0
[0.17.2]: https://github.com/ecmwf/atlas/compare/0.17.1...0.17.2
[0.17.1]: https://github.com/ecmwf/atlas/compare/0.17.0...0.17.1
Expand Down
26 changes: 3 additions & 23 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ ecbuild_add_option( FEATURE EIGEN
DESCRIPTION "Use Eigen linear algebra library"
REQUIRED_PACKAGES Eigen3 )

### Type for Global indices and unique point id's
### Type for Global indices and unique point ids

set( ATLAS_BITS_GLOBAL 64 )
set( ATLAS_BITS_LOCAL 32 )
Expand Down Expand Up @@ -258,29 +258,9 @@ set( MIR_NEEDS_TRANSI TRUE CACHE BOOL "Deprecated" INTERNAL )

include(CompileFlags)

find_program (CLANG_TIDY_EXE NAMES "clang-tidy" )
if( CLANG_TIDY_EXE )
message(STATUS "Found clang-tidy: ${CLANG_TIDY_EXE}")
endif()
ecbuild_add_option( FEATURE CLANG_TIDY
DESCRIPTION "Use clang-tidy"
CONDITION CLANG_TIDY_EXE )
if (HAVE_CLANG_TIDY)
set(CLANG_TIDY_CHECKS "-*,readability-braces-around-statements,redundant-string-init")
set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_EXE};-checks=${CLANG_TIDY_CHECKS};-header-filter='${CMAKE_SOURCE_DIR}/*'")
endif()
include(FeatureClangTidy)

find_program (INCLUDE_WHAT_YOU_USE_EXE NAMES "include-what-you-use" )
if( INCLUDE_WHAT_YOU_USE_EXE )
message(STATUS "Found include-what-you-use: ${INCLUDE_WHAT_YOU_USE_EXE}" )
endif()
ecbuild_add_option( FEATURE INCLUDE_WHAT_YOU_USE
DEFAULT OFF # Need clang compiler?
DESCRIPTION "Use include-what-you-use clang-tool"
CONDITION INCLUDE_WHAT_YOU_USE_EXE )
if( HAVE_INCLUDE_WHAT_YOU_USE )
set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE ${INCLUDE_WHAT_YOU_USE_EXE})
endif()
include(FeatureIncludeWhatYouUse)

add_subdirectory( src )

Expand Down
2 changes: 1 addition & 1 deletion VERSION.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
# granted to it by virtue of its status as an intergovernmental organisation nor
# does it submit to any jurisdiction.

set ( ${PROJECT_NAME}_VERSION_STR "0.18.0" )
set ( ${PROJECT_NAME}_VERSION_STR "0.18.1" )

26 changes: 26 additions & 0 deletions cmake/FeatureClangTidy.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
set( CLANG_TIDY_SUPPORTED_COMPILERS GNU Clang )

set( CLANG_TIDY_DEFAULT OFF )
foreach( _clang_tidy_supported_compiler ${CLANG_TIDY_SUPPORTED_COMPILERS} )
if( CMake_CXX_COMPILER_ID MATCHES _clang_tidy_supported_compiler )
set( CLANG_TIDY_DEFAULT ON )
endif()
endforeach()

find_program( CLANG_TIDY_EXE NAMES "clang-tidy" )
if( CLANG_TIDY_EXE )
ecbuild_info( "Found clang-tidy: ${CLANG_TIDY_EXE}" )
if( NOT CLANG_TIDY_DEFAULT AND NOT DEFINED ENABLE_CLANG_TIDY )
ecbuild_info( "Feature CLANG_TIDY default OFF for compiler ${CMAKE_CXX_COMPILER_ID}" )
endif()
endif()

ecbuild_add_option( FEATURE CLANG_TIDY
DEFAULT ${CLANG_TIDY_DEFAULT}
DESCRIPTION "Use clang-tidy"
CONDITION CLANG_TIDY_EXE )

if (HAVE_CLANG_TIDY)
set(CLANG_TIDY_CHECKS "-*,readability-braces-around-statements,redundant-string-init")
set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_EXE};-checks=${CLANG_TIDY_CHECKS};-header-filter='${CMAKE_SOURCE_DIR}/*'")
endif()
13 changes: 13 additions & 0 deletions cmake/FeatureIncludeWhatYouUse.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
find_program( INCLUDE_WHAT_YOU_USE_EXE NAMES "include-what-you-use" )
if( INCLUDE_WHAT_YOU_USE_EXE )
ecbuild_info( "Found include-what-you-use: ${INCLUDE_WHAT_YOU_USE_EXE}" )
endif()

ecbuild_add_option( FEATURE INCLUDE_WHAT_YOU_USE
DEFAULT OFF # Need clang compiler?
DESCRIPTION "Use include-what-you-use clang-tool"
CONDITION INCLUDE_WHAT_YOU_USE_EXE )

if( HAVE_INCLUDE_WHAT_YOU_USE )
set( CMAKE_CXX_INCLUDE_WHAT_YOU_USE ${INCLUDE_WHAT_YOU_USE_EXE} )
endif()
4 changes: 2 additions & 2 deletions src/atlas/array/native/NativeArrayView.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,13 @@ class ArrayView {
template <typename Int, bool EnableBool = true>
typename std::enable_if<( Rank == 1 && EnableBool ), const value_type&>::type operator[]( Int idx ) const {
check_bounds( idx );
return data_[idx];
return data_[idx * strides_[0]];
}

template <typename Int, bool EnableBool = true>
typename std::enable_if<( Rank == 1 && EnableBool ), value_type&>::type operator[]( Int idx ) {
check_bounds( idx );
return data_[idx];
return data_[idx * strides_[0]];
}

template <unsigned int Dim>
Expand Down
6 changes: 6 additions & 0 deletions src/atlas/field/detail/FieldInterface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,12 @@ void atlas__Field__shapef( FieldImpl* This, int*& shape, int& rank ) {
rank = This->shapef().size();
}

void atlas__Field__stridesf( FieldImpl* This, int*& shape, int& rank ) {
ATLAS_ASSERT( This != nullptr, "Cannot access bytes occupied by uninitialised atlas_Field" );
shape = const_cast<int*>( &This->stridesf().front() );
rank = This->stridesf().size();
}

void atlas__Field__data_int_specf( FieldImpl* This, int*& data, int& rank, int*& shapef, int*& stridesf ) {
atlas__Field__data_specf( This, data, rank, shapef, stridesf );
}
Expand Down
1 change: 1 addition & 0 deletions src/atlas/field/detail/FieldInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ int atlas__Field__size( FieldImpl* This );
int atlas__Field__levels( FieldImpl* This );
double atlas__Field__bytes( FieldImpl* This );
void atlas__Field__shapef( FieldImpl* This, int*& shape, int& rank );
void atlas__Field__stridesf( FieldImpl* This, int*& strides, int& rank );
void atlas__Field__data_int_specf( FieldImpl* This, int*& field_data, int& rank, int*& field_shapef,
int*& field_stridesf );
void atlas__Field__data_long_specf( FieldImpl* This, long*& field_data, int& rank, int*& field_shapef,
Expand Down
15 changes: 11 additions & 4 deletions src/atlas/functionspace/StructuredColumns.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "atlas/functionspace/StructuredColumns.h"

#include <iomanip>
#include <mutex>
#include <sstream>
#include <string>

Expand Down Expand Up @@ -81,7 +82,6 @@ std::string checksum_3d_field( const parallel::Checksum& checksum, const Field&
return checksum.execute( surface.data(), surface_field.stride( 0 ) );
}


} // namespace

class StructuredColumnsHaloExchangeCache : public util::Cache<std::string, parallel::HaloExchange>,
Expand All @@ -97,12 +97,19 @@ class StructuredColumnsHaloExchangeCache : public util::Cache<std::string, paral
}
util::ObjectHandle<value_type> get_or_create( const detail::StructuredColumns& funcspace ) {
creator_type creator = std::bind( &StructuredColumnsHaloExchangeCache::create, &funcspace );
return Base::get_or_create( key( *funcspace.grid().get() ), creator );
return Base::get_or_create( key( *funcspace.grid().get(), funcspace.halo() ),
remove_key( *funcspace.grid().get() ), creator );
}
virtual void onGridDestruction( grid::detail::grid::Grid& grid ) { remove( key( grid ) ); }
virtual void onGridDestruction( grid::detail::grid::Grid& grid ) { remove( remove_key( grid ) ); }

private:
static Base::key_type key( const grid::detail::grid::Grid& grid ) {
static Base::key_type key( const grid::detail::grid::Grid& grid, idx_t halo ) {
std::ostringstream key;
key << "grid[address=" << &grid << ",halo=" << halo << "]";
return key.str();
}

static Base::key_type remove_key( const grid::detail::grid::Grid& grid ) {
std::ostringstream key;
key << "grid[address=" << &grid << "]";
return key.str();
Expand Down
5 changes: 5 additions & 0 deletions src/atlas/grid/detail/vertical/VerticalInterface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ Vertical* atlas__Vertical__new( idx_t levels, const double z[] ) {
return new Vertical( levels, zvec );
}

Vertical* atlas__Vertical__new_interval( idx_t levels, const double z[], const double interval[] ) {
std::vector<double> zvec( z, z + levels );
return new Vertical( levels, zvec, interval );
}

void atlas__Vertical__delete( Vertical* This ) {
delete This;
}
Expand Down
1 change: 1 addition & 0 deletions src/atlas/grid/detail/vertical/VerticalInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ namespace atlas {

extern "C" {
Vertical* atlas__Vertical__new( idx_t levels, const double z[] );
Vertical* atlas__Vertical__new_interval( idx_t levels, const double z[], const double interval[] );
void atlas__Vertical__delete( Vertical* This );
field::FieldImpl* atlas__Vertical__z( const Vertical* This );
int atlas__Vertical__size( const Vertical* This );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ void StructuredInterpolation3D<Kernel>::setup( const FunctionSpace& source, cons
source_ = source;

if ( target.functionspace() ) { target_ = target.functionspace(); }
ATLAS_ASSERT( target.levels() );

target_3d_ = target;

Expand All @@ -106,7 +105,6 @@ void StructuredInterpolation3D<Kernel>::setup( const FunctionSpace& source, cons

ATLAS_ASSERT( target.size() >= 3 );
if ( target[0].functionspace() ) { target_ = target[0].functionspace(); }
ATLAS_ASSERT( target[0].levels() );

target_xyz_ = target;

Expand Down
109 changes: 6 additions & 103 deletions src/atlas/interpolation/method/structured/kernels/Cubic3DKernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "atlas/util/CoordinateEnums.h"
#include "atlas/util/Point.h"

#include "Cubic3DLimiter.h"
#include "CubicHorizontalKernel.h"
#include "CubicVerticalKernel.h"

Expand All @@ -29,6 +30,8 @@ namespace interpolation {
namespace method {

class Cubic3DKernel {
using Limiter = Cubic3DLimiter;

public:
Cubic3DKernel( const functionspace::StructuredColumns& fs, const util::Config& config = util::NoConfig() ) {
src_ = fs;
Expand Down Expand Up @@ -60,6 +63,7 @@ class Cubic3DKernel {
std::array<std::array<double, 4>, 4> weights_i;
std::array<double, 4> weights_j;
std::array<double, 4> weights_k;
friend std::ostream& operator<<( std::ostream& out, const Weights& v ) { ATLAS_NOTIMPLEMENTED; }
};

public:
Expand Down Expand Up @@ -113,58 +117,11 @@ class Cubic3DKernel {
}

if ( limiter_ ) {
limit_scalar( output, index, stencil, input );
Limiter::limit_scalar( output, index, stencil, input );
}
return output;
}

template <typename array_t, typename stencil_t>
typename std::enable_if<( array_t::RANK == 2 ), void>::type limit_scalar(
typename array_t::value_type& output, const std::array<std::array<idx_t, 4>, 4>& index,
const stencil_t& stencil, const array_t& input ) const {
using Scalar = typename array_t::value_type;
// Limit output to max/min of values in stencil marked by '*'
// x x x x
// x *-----* x
// / P |
// x *------ * x
// x x x x
idx_t k = stencil.k_interval();
idx_t k1, k2;
if ( k < 0 ) {
k1 = k2 = 0;
}
else if ( k > 2 ) {
k1 = k2 = 3;
}
else {
k1 = k;
k2 = k + 1;
}

Scalar maxval = std::numeric_limits<Scalar>::lowest();
Scalar minval = std::numeric_limits<Scalar>::max();
for ( idx_t j = 1; j < 3; ++j ) {
for ( idx_t i = 1; i < 3; ++i ) {
idx_t n = index[j][i];

Scalar f1 = input( n, stencil.k( k1 ) );
Scalar f2 = input( n, stencil.k( k2 ) );

maxval = std::max( maxval, f1 );
maxval = std::max( maxval, f2 );
minval = std::min( minval, f1 );
minval = std::min( minval, f2 );
}
}
if ( output < minval ) {
output = minval;
}
else if ( output > maxval ) {
output = maxval;
}
}

template <typename Value>
struct OutputView1D {
template <typename Int>
Expand Down Expand Up @@ -223,64 +180,10 @@ class Cubic3DKernel {
}

if ( limiter_ ) {
limit_vars( index, stencil, input, output, nvar );
Limiter::limit_vars( index, stencil, input, output, nvar );
}
}

template <typename InputArray, typename OutputArray, typename stencil_t>
typename std::enable_if<( InputArray::RANK == 3 ), void>::type limit_vars(
const std::array<std::array<idx_t, 4>, 4>& index, const stencil_t& stencil, const InputArray& input,
OutputArray& output, const idx_t nvar ) const {
// Limit output to max/min of values in stencil marked by '*'
// x x x x
// x *-----* x
// / P |
// x *------ * x
// x x x x

using Value = typename InputArray::value_type;

const idx_t k = stencil.k_interval();
idx_t k1, k2;
if ( k < 0 ) {
k1 = k2 = stencil.k( 0 );
}
else if ( k > 2 ) {
k1 = k2 = stencil.k( 3 );
}
else {
k1 = stencil.k( k );
k2 = k1 + 1;
}

for ( idx_t v = 0; v < nvar; ++v ) {
Value limited = output[v];
Value maxval = std::numeric_limits<Value>::lowest();
Value minval = std::numeric_limits<Value>::max();
for ( idx_t j = 1; j < 3; ++j ) {
for ( idx_t i = 1; i < 3; ++i ) {
idx_t n = index[j][i];

Value f1 = input( n, k1, v );
Value f2 = input( n, k2, v );

maxval = std::max( maxval, f1 );
maxval = std::max( maxval, f2 );
minval = std::min( minval, f1 );
minval = std::min( minval, f2 );
}
}
if ( limited < minval ) {
limited = minval;
}
else if ( limited > maxval ) {
limited = maxval;
}
output[v] = limited;
}
}


template <typename stencil_t, typename weights_t, typename InputArray, typename OutputArray>
typename std::enable_if<( InputArray::RANK == 2 && OutputArray::RANK == 1 ), void>::type interpolate(
const stencil_t& stencil, const weights_t& weights, const InputArray& input, OutputArray& output,
Expand Down
Loading

0 comments on commit 0ef1dad

Please sign in to comment.