Skip to content

Commit

Permalink
Merge branch 'release/0.29.0'
Browse files Browse the repository at this point in the history
* release/0.29.0: (49 commits)
  Version 0.29.0
  GitHub Actions CI: enable OpenMP for C/C++
  ATLAS-355 Workaround macOS OpenMP problems with 'omp task'
  ATLAS-354 bamboo using proj/8.2.1
  ATLAS-354 Introduce FindPROJ.cmake for proj installations based on autotools
  ATLAS-354 Compatibility with proj >= 8
  Add missing include <string>
  Restore compatibility with eckit < 1.18.5
  Support cubed-sphere wind interpolation (#99)
  Fix Jacobian::transpose() introduced in PR #93
  GitHub actions CI: reduce available MPI_SLOTS for macOS builds to 4
  Quad2D: Added fused multiply-add to discriminant calculation (#102)
  FieldSet::has() to replace FieldSet::has_field()
  Config::json() function
  Create Array using ArraySpec only (containing datatype)
  Add Datatype to ArraySpec
  Cosmetic changes to UnstructuredBilinearLonLat
  Change Quad2D's PointXY arguments to Point2
  Make GridToolsArray backend work with mixed indexing types
  Apply clang-format
  ...
  • Loading branch information
wdeconinck committed Apr 21, 2022
2 parents 2575ca3 + 6305ca5 commit b255889
Show file tree
Hide file tree
Showing 108 changed files with 3,223 additions and 1,131 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ jobs:
compiler_cxx: ~
compiler_fc: gfortran-11
caching: true
cmake_options: -DMPI_SLOTS=4

runs-on: ${{ matrix.os }}
steps:
Expand All @@ -106,6 +107,7 @@ jobs:
if [[ "${{ matrix.os }}" =~ macos ]]; then
brew install ninja
brew install libomp
else
sudo apt-get update
sudo apt-get install ninja-build
Expand Down
26 changes: 24 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,32 @@ This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html

## [Unreleased]

## [0.28.1] - 2021-03-14
## [0.29.0] - 2022-04-21
### Added
- MatchingMeshPartitioner "cubedsphere"
- Interpolator "cubedsphere-bilinear"
- Improvements to Interpolation::Cache
- Add support for rank 2 fields when a nonlinear action is added to the interpolator
- Create Array using ArraySpec only

### Changed
- FieldSet::has(...) replaces FieldSet::has_field(...)
- Metadata return value to Interpolation::execute()
- Rename BilinearRemapping to UnstructuredBilinearLonLat

### Fixed
- Compatibility with proj version >= 8
- Compatibility with eckit version <= 1.18.5
- Compatibility with GridTools backend and using 64bit idx_t
- Wrongly computed Jacobian::transpose() introduced in 0.28.0
- Fix bug where using ectrans was not enabling adjoint of invtrans
- Avoid segfault when OpenMP tasking is broken, as it is with AppleClang and LLVM libomp

## [0.28.1] - 2022-03-14
### Fixed
- Fix compilation for GNU 7.3

## [0.28.0] - 2021-03-02
## [0.28.0] - 2022-03-02
### Added
- Assignment of ArrayView from ArrayView
- Grid "regional_variable_resolution" via a new VariableResolutionProjection
Expand Down Expand Up @@ -345,6 +366,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.29.0]: https://github.com/ecmwf/atlas/compare/0.28.1...0.29.0
[0.28.1]: https://github.com/ecmwf/atlas/compare/0.28.0...0.28.1
[0.28.0]: https://github.com/ecmwf/atlas/compare/0.27.0...0.28.0
[0.27.0]: https://github.com/ecmwf/atlas/compare/0.26.0...0.27.0
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.28.1
0.29.0
2 changes: 1 addition & 1 deletion bamboo/GCC-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ module unload metview
module unload netcdf4

module load cmake/3.16.5
module load proj/6.1.1
module load proj/8.2.1
73 changes: 73 additions & 0 deletions cmake/FindPROJ.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# (C) Copyright 2011- ECMWF.
#
# This software is licensed under the terms of the Apache Licence Version 2.0
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
# In applying this licence, ECMWF does not waive the privileges and immunities
# granted to it by virtue of its status as an intergovernmental organisation
# nor does it submit to any jurisdiction.

# - Try to find the proj library
# Once done this will define
#
# PROJ_FOUND - system has proj
# PROJ_INCLUDE_DIRS - the proj include directory
# PROJ_LIBRARIES - Link these to use proj
# PROJ_VERSION - semantic version of proj
#

### Set search paths from environment
if ( NOT PROJ_PATH AND PROJ_ROOT )
set( PROJ_PATH ${PROJ_ROOT} )
endif()
if ( NOT PROJ_PATH AND NOT "$ENV{PROJ_ROOT}" STREQUAL "" )
set( PROJ_PATH "$ENV{PROJ_ROOT}" )
endif()
if ( NOT PROJ_PATH AND NOT "$ENV{PROJ_PATH}" STREQUAL "" )
set( PROJ_PATH "$ENV{PROJ_PATH}" )
endif()
if ( NOT PROJ_PATH AND NOT "$ENV{PROJ_DIR}" STREQUAL "" )
set( PROJ_PATH "$ENV{PROJ_DIR}" )
endif()


### If search paths given, use it, otherwise, use pkg-config
if( PROJ_PATH )
find_path(PROJ_INCLUDE_DIR NAMES proj.h PATHS ${PROJ_PATH} ${PROJ_PATH}/include PATH_SUFFIXES PROJ NO_DEFAULT_PATH )
find_library(PROJ_LIBRARY NAMES proj PATHS ${PROJ_PATH} ${PROJ_PATH}/lib PATH_SUFFIXES PROJ NO_DEFAULT_PATH )
else()
find_package(PkgConfig)
if(PKG_CONFIG_FOUND)
if(PROJ_FIND_VERSION)
pkg_check_modules(PKPROJ ${_pkgconfig_REQUIRED} QUIET PROJ>=${PROJ_FIND_VERSION})
else()
pkg_check_modules(PKPROJ ${_pkgconfig_REQUIRED} QUIET PROJ)
endif()

if( PKPROJ_FOUND )
find_path(PROJ_INCLUDE_DIR proj.h HINTS ${PKPROJ_INCLUDEDIR} ${PKPROJ_INCLUDE_DIRS} PATH_SUFFIXES PROJ NO_DEFAULT_PATH )
find_library(PROJ_LIBRARY proj HINTS ${PKPROJ_LIBDIR} ${PKPROJ_LIBRARY_DIRS} PATH_SUFFIXES PROJ NO_DEFAULT_PATH )
endif()
endif()
endif()

find_path(PROJ_INCLUDE_DIR NAMES proj.h PATHS PATH_SUFFIXES PROJ )
find_library( PROJ_LIBRARY NAMES proj PATHS PATH_SUFFIXES PROJ )

### Detect version
set( PROJ_VERSION 0 )
file(READ ${PROJ_INCLUDE_DIR}/proj.h proj_version)
string(REGEX REPLACE "^.*PROJ_VERSION_MAJOR +([0-9]+).*$" "\\1" PROJ_VERSION_MAJOR "${proj_version}")
string(REGEX REPLACE "^.*PROJ_VERSION_MINOR +([0-9]+).*$" "\\1" PROJ_VERSION_MINOR "${proj_version}")
string(REGEX REPLACE "^.*PROJ_VERSION_PATCH +([0-9]+).*$" "\\1" PROJ_VERSION_PATCH "${proj_version}")
string(CONCAT PROJ_VERSION ${PROJ_VERSION_MAJOR} "." ${PROJ_VERSION_MINOR} "." ${PROJ_VERSION_PATCH})

### Handle the QUIETLY and REQUIRED arguments and set PROJ_FOUND
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(PROJ
REQUIRED_VARS PROJ_LIBRARY PROJ_INCLUDE_DIR
VERSION_VAR PROJ_VERSION)

set( PROJ_LIBRARIES ${PROJ_LIBRARY} )
set( PROJ_INCLUDE_DIRS ${PROJ_INCLUDE_DIR} )

mark_as_advanced( PROJ_INCLUDE_DIR PROJ_LIBRARY )
60 changes: 49 additions & 11 deletions cmake/features/OMP.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -24,34 +24,72 @@ endif()
if( HAVE_OMP_CXX )

if( NOT CMAKE_CXX_COMPILER_ID MATCHES Clang )
set( ATLAS_OMP_TASK_UNTIED_SUPPORTED 1 )
set( ATLAS_OMP_TASK_SUPPORTED 1 )
endif()

if( NOT DEFINED ATLAS_OMP_TASK_UNTIED_SUPPORTED )
try_run( execute_result compile_result
if( NOT DEFINED ATLAS_OMP_TASK_SUPPORTED )
try_run( execute_result compile_result
${CMAKE_CURRENT_BINARY_DIR}
${PROJECT_SOURCE_DIR}/cmake/features/OMP/test_omp_untied.cc
${PROJECT_SOURCE_DIR}/cmake/features/OMP/test_omp_task.cc
LINK_LIBRARIES ${OMP_CXX}
COMPILE_OUTPUT_VARIABLE compile_output
RUN_OUTPUT_VARIABLE execute_output )

ecbuild_debug("Compiling and running ${PROJECT_SOURCE_DIR}/cmake/features/OMP/test_omp_untied.cc")
ecbuild_debug("Compiling and running ${PROJECT_SOURCE_DIR}/cmake/features/OMP/test_omp_task.cc")
ecbuild_debug_var( compile_result )
ecbuild_debug_var( compile_output )
ecbuild_debug_var( execute_result )
ecbuild_debug_var( execute_output )

if( compile_result )
if( execute_result MATCHES 0 )
set( ATLAS_OMP_TASK_UNTIED_SUPPORTED 1 )
set( ATLAS_OMP_TASK_SUPPORTED 1 )
else()
ecbuild_info(" Compiler failed to run program with omp pragma with 'untied if' construct."
"Workaround will be enabled.")
set( ATLAS_OMP_TASK_UNTIED_SUPPORTED 0 )
ecbuild_info(" Compiler failed to correctly run program with 'omp task' pragma."
"Sorting with OMP is disabled.")
set( ATLAS_OMP_TASK_SUPPORTED 0 )
endif()
else()
set( ATLAS_OMP_TASK_UNTIED_SUPPORTED 0 )
else()
set( ATLAS_OMP_TASK_SUPPORTED 0 )
endif()
endif()


if( ATLAS_OMP_TASK_SUPPORTED )
if( NOT CMAKE_CXX_COMPILER_ID MATCHES Clang )
set( ATLAS_OMP_TASK_UNTIED_SUPPORTED 1 )
endif()

if( NOT DEFINED ATLAS_OMP_TASK_UNTIED_SUPPORTED )
try_run( execute_result compile_result
${CMAKE_CURRENT_BINARY_DIR}
${PROJECT_SOURCE_DIR}/cmake/features/OMP/test_omp_untied.cc
LINK_LIBRARIES ${OMP_CXX}
COMPILE_OUTPUT_VARIABLE compile_output
RUN_OUTPUT_VARIABLE execute_output )

ecbuild_debug("Compiling and running ${PROJECT_SOURCE_DIR}/cmake/features/OMP/test_omp_untied.cc")
ecbuild_debug_var( compile_result )
ecbuild_debug_var( compile_output )
ecbuild_debug_var( execute_result )
ecbuild_debug_var( execute_output )

if( compile_result )
if( execute_result MATCHES 0 )
set( ATLAS_OMP_TASK_UNTIED_SUPPORTED 1 )
else()
ecbuild_info(" Compiler failed to run program with omp pragma with 'untied if' construct."
"Workaround will be enabled.")
set( ATLAS_OMP_TASK_UNTIED_SUPPORTED 0 )
endif()
else()
set( ATLAS_OMP_TASK_UNTIED_SUPPORTED 0 )
endif()
endif()
else()
set( ATLAS_OMP_TASK_UNTIED_SUPPORTED 0 )
endif()
else()
set( ATLAS_OMP_TASK_SUPPORTED 0 )
set( ATLAS_OMP_TASK_UNTIED_SUPPORTED 0 )
endif()
55 changes: 55 additions & 0 deletions cmake/features/OMP/test_omp_task.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* (C) Copyright 2013 ECMWF.
*
* This software is licensed under the terms of the Apache Licence Version 2.0
* which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
* In applying this licence, ECMWF does not waive the privileges and immunities
* granted to it by virtue of its status as an intergovernmental organisation
* nor does it submit to any jurisdiction.
*/


// This test mirrors functionality from src/atlas/parallel/omp/sort.h
// It appears that on some installations / compilers (such as apple-clang with llvm omp)
// the tasking does not seem to work properly.
// It all compiles but leads to runtime errors. This executable is
// added to allow compiler introspection for this feature.

#include <algorithm>
#include <vector>
#include <iostream>

#include <omp.h>


void recursive_task( int begin, int end ) {
int size = end - begin;

if ( size >= 2 ) { // should be much larger in real case (e.g. 256)
int mid = begin + size / 2;
std::cout << begin << " - " << end << " [" <<size << "]" << std::endl;
{
#pragma omp task
recursive_task( begin, mid );
#pragma omp task
recursive_task( mid, end );
#pragma omp taskwait
}
// do work after coming back from nested recursion
}
else {
// deepest level work
}
}


void start_task( int size ) {
#pragma omp parallel
#pragma omp single
recursive_task( 0, size );
}

int main() {
start_task( 8 );
return 0;
}
49 changes: 46 additions & 3 deletions cmake/features/PROJ.cmake
Original file line number Diff line number Diff line change
@@ -1,8 +1,51 @@

### Proj

ecbuild_find_package( NAME PROJ4 QUIET )
# From proj 9 onwards, it is guaranteed that it was built/installed using CMake and the CMake export is available.
# Then we can safely remove the file FindPROJ.cmake from atlas
# and the following atrocity could be simply replaced with
#
# ecbuild_add_option( FEATURE PROJ
# DESCRIPTION "PROJ-based projections"
# DEFAULT OFF
# REQUIRED_PACKAGES PROJ )
#

if( ENABLE_PROJ )
ecbuild_find_package_search_hints( NAME PROJ )

# 1) Try to find PROJ the CMake way (proj >= 7)
find_package( PROJ CONFIG )
if( PROJ_FOUND )
ecbuild_debug("Found PROJ via CONFIG")
else()
# 2) Try to find PROJ4 the CMake way (proj 6)
find_package( PROJ4 CONFIG )
if( PROJ4_FOUND )
ecbuild_debug("Found PROJ4 via CONFIG")
set( PROJ_FOUND ${PROJ4_FOUND} )
set( PROJ_LIBRARIES ${PROJ4_LIBRARIES} )
set( PROJ_INCLUDE_DIRS ${PROJ4_INCLUDE_DIRS} )
set( PROJ_VERSION ${PROJ4_VERSION} )
endif()
endif()
if( NOT PROJ_FOUND )
# 3) Try to find PROJ via FindPROJ.cmake provided within atlas (proj < 9)
find_package( PROJ MODULE )
if( PROJ_FOUND )
ecbuild_debug("Found PROJ via FindPROJ.cmake")
endif()
endif()
else()
ecbuild_debug("Skipping search for PROJ as ENABLE_PROJ=OFF (default)")
endif()

if( PROJ_FOUND )
ecbuild_info( "Found PROJ (${PROJ_VERSION}):")
ecbuild_info( " PROJ_LIBRARIES : ${PROJ_LIBRARIES}")
ecbuild_info( " PROJ_INCLUDE_DIRS : ${PROJ_INCLUDE_DIRS}")
endif()

ecbuild_add_option( FEATURE PROJ
DESCRIPTION "PROJ-based projections"
DEFAULT OFF
CONDITION PROJ4_FOUND )
CONDITION PROJ_FOUND )
20 changes: 14 additions & 6 deletions src/atlas/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ option/TransOptions.cc
projection.h
projection/Projection.cc
projection/Projection.h
projection/Jacobian.h
projection/detail/CubedSphereEquiAnglProjection.cc
projection/detail/CubedSphereEquiAnglProjection.h
projection/detail/CubedSphereEquiDistProjection.cc
Expand Down Expand Up @@ -203,6 +204,8 @@ grid/detail/partitioner/MatchingMeshPartitioner.h
grid/detail/partitioner/MatchingMeshPartitioner.cc
grid/detail/partitioner/MatchingMeshPartitionerBruteForce.cc
grid/detail/partitioner/MatchingMeshPartitionerBruteForce.h
grid/detail/partitioner/MatchingMeshPartitionerCubedSphere.cc
grid/detail/partitioner/MatchingMeshPartitionerCubedSphere.h
grid/detail/partitioner/MatchingMeshPartitionerLonLatPolygon.cc
grid/detail/partitioner/MatchingMeshPartitionerLonLatPolygon.h
grid/detail/partitioner/MatchingMeshPartitionerSphericalPolygon.cc
Expand Down Expand Up @@ -555,10 +558,10 @@ interpolation/method/PointSet.cc
interpolation/method/PointSet.h
interpolation/method/Ray.cc
interpolation/method/Ray.h
interpolation/method/fe/FiniteElement.cc
interpolation/method/fe/FiniteElement.h
interpolation/method/bil/BilinearRemapping.cc
interpolation/method/bil/BilinearRemapping.h
interpolation/method/cubedsphere/CellFinder.cc
interpolation/method/cubedsphere/CellFinder.h
interpolation/method/cubedsphere/CubedSphereBilinear.cc
interpolation/method/cubedsphere/CubedSphereBilinear.h
interpolation/method/knn/GridBox.cc
interpolation/method/knn/GridBox.h
interpolation/method/knn/GridBoxAverage.cc
Expand Down Expand Up @@ -598,6 +601,10 @@ interpolation/method/structured/kernels/LinearVerticalKernel.h
interpolation/method/structured/kernels/QuasiCubic3DKernel.cc
interpolation/method/structured/kernels/QuasiCubic3DKernel.h
interpolation/method/structured/kernels/QuasiCubicHorizontalKernel.h
interpolation/method/unstructured/FiniteElement.cc
interpolation/method/unstructured/FiniteElement.h
interpolation/method/unstructured/UnstructuredBilinearLonLat.cc
interpolation/method/unstructured/UnstructuredBilinearLonLat.h
interpolation/nonlinear/Missing.cc
interpolation/nonlinear/Missing.h
interpolation/nonlinear/NonLinear.cc
Expand Down Expand Up @@ -916,14 +923,15 @@ if( atlas_HAVE_TRANS )
endif()

if( atlas_HAVE_PROJ )
target_link_libraries( atlas PRIVATE ${PROJ4_LIBRARIES} )
target_include_directories( atlas PRIVATE ${PROJ4_INCLUDE_DIRS} )
target_link_libraries( atlas PRIVATE ${PROJ_LIBRARIES} )
target_include_directories( atlas PRIVATE ${PROJ_INCLUDE_DIRS} )
endif()

target_link_libraries( atlas PUBLIC
eckit
eckit_geometry
eckit_linalg
eckit_maths
eckit_mpi
eckit_option
)
Expand Down
Loading

0 comments on commit b255889

Please sign in to comment.