[emos] 01/13: upstream release 4.4.5

Alastair McKinstry mckinstry at moszumanska.debian.org
Fri Mar 3 13:54:38 UTC 2017


This is an automated email from the git hooks/post-receive script.

mckinstry pushed a commit to branch debian/master
in repository emos.

commit d0270214ade3fb68881718fb098f0fad9df85910
Author: Alastair McKinstry <mckinstry at debian.org>
Date:   Mon Nov 28 14:56:08 2016 +0000

    upstream release 4.4.5
---
 CMakeLists.txt                                     |   2 +-
 ChangeLog                                          |   9 ++
 VERSION.cmake                                      |   2 +-
 bamboo/CLANG-env.sh                                |   2 +
 bamboo/INTEL-env.sh                                |   2 +
 bamboo/flags.cmake                                 |   4 +-
 bamboo/opensuse131-flags.cmake                     |   4 +-
 bin/ecbuild                                        |   4 +-
 cmake/CheckFortranCompilerFlag.cmake               |  37 -----
 cmake/CheckFortranSourceCompiles.cmake             |  94 -------------
 cmake/{contrib => }/FindFFTW.cmake                 |   6 -
 cmake/FindGeoTIFF.cmake                            |  64 +++++----
 cmake/FindOpenJPEG.cmake                           |  60 ++++----
 cmake/VERSION.cmake                                |   4 +-
 cmake/compiler_flags/Cray_C.cmake                  |  11 +-
 cmake/compiler_flags/Cray_CXX.cmake                |  11 +-
 cmake/compiler_flags/Cray_Fortran.cmake            |  12 +-
 .../CMakeCheckCompilerFlagCommonPatterns.cmake     |  33 +++++
 cmake/contrib/CheckFortranCompilerFlag.cmake       |  72 +++++++---
 cmake/contrib/CheckFortranSourceCompiles.cmake     | 133 ++++++++++++------
 cmake/contrib/FindNetCDF4.cmake                    |   4 +-
 cmake/ecbuild_add_executable.cmake                 |  62 +--------
 cmake/ecbuild_add_library.cmake                    | 100 +++++--------
 cmake/ecbuild_add_option.cmake                     |  45 +++---
 cmake/ecbuild_add_test.cmake                       |  80 +++++++----
 cmake/ecbuild_bundle.cmake                         |   8 +-
 cmake/ecbuild_check_cxx11.cmake                    | 147 ++++++++++----------
 cmake/ecbuild_compiler_flags.cmake                 | 154 ++++++++++++++++++---
 cmake/ecbuild_declare_project.cmake                |  53 +------
 cmake/ecbuild_define_paths.cmake                   |  23 +--
 cmake/ecbuild_find_omp.cmake                       |   4 +-
 cmake/ecbuild_generate_fortran_interfaces.cmake    |   2 +-
 cmake/ecbuild_get_test_data.cmake                  |  14 +-
 cmake/ecbuild_log.cmake                            |   2 +-
 cmake/ecbuild_pkgconfig.cmake                      |   2 +-
 cmake/ecbuild_print_summary.cmake                  |   3 +-
 cmake/ecbuild_remove_fortran_flags.cmake           |   5 +-
 cmake/ecbuild_separate_sources.cmake               |  16 +--
 cmake/ecbuild_system.cmake                         |   1 +
 cmake/ecbuild_target_flags.cmake                   |  91 ++++++++++++
 cmake/ecbuild_use_package.cmake                    |   1 +
 interpolation/jopnggsm.c                           |   2 +-
 interpolation/jopnllsm.c                           |   2 +-
 interpolation/wavexx2.F                            |   7 +-
 pbio/emosnum.F                                     |   2 +-
 share/ecbuild/toolchains/ecmwf-XC30-Cray.cmake     |  21 +--
 share/ecbuild/toolchains/ecmwf-XC30-GNU.cmake      |  14 +-
 share/ecbuild/toolchains/ecmwf-XC30-Intel.cmake    |  14 +-
 .../bufr/regress/download_tests_bufr_src_files.txt |   9 --
 49 files changed, 761 insertions(+), 693 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index e3e393c..5a848bd 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -113,7 +113,7 @@ endif()
 
 ecbuild_add_option( FEATURE ECCODES DESCRIPTION "Use eccodes instead of grib_api"
                     REQUIRED_PACKAGES "PROJECT eccodes VERSION 0.14 REQUIRED"
-                    DEFAULT OFF )
+                    DEFAULT ON )
 
 if( HAVE_ECCODES)
   set( GRIB_API_INCLUDE_DIRS ${ECCODES_INCLUDE_DIRS} )
diff --git a/ChangeLog b/ChangeLog
index f8b1e8d..b6c227e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+000445
+
+	Notes
+		* This release is part of ECMWF Development Section Synchronised Release 2016.11
+		* This release configures with ecCodes by default
+
+	Bug fixes
+		* [EMOS-307] - wave parameter on specific sub-areas straddling Greenwich meridian
+
 000444
 
 	Notes
diff --git a/VERSION.cmake b/VERSION.cmake
index 18450cd..1340633 100644
--- a/VERSION.cmake
+++ b/VERSION.cmake
@@ -2,4 +2,4 @@
 #  Do NOT forget to update  pbio/emosnum.F
 #
 #
-set( ${PROJECT_NAME}_VERSION_STR "4.4.4" )
+set( ${PROJECT_NAME}_VERSION_STR "4.4.5" )
diff --git a/bamboo/CLANG-env.sh b/bamboo/CLANG-env.sh
index 8ea897b..ae7b1b9 100644
--- a/bamboo/CLANG-env.sh
+++ b/bamboo/CLANG-env.sh
@@ -1,5 +1,7 @@
 #!/bin/bash
 
+ctest_parallel="no"
+
 # No module environment on the Mac
 [[ $(uname) == "Darwin" ]] && return
 
diff --git a/bamboo/INTEL-env.sh b/bamboo/INTEL-env.sh
index 378388d..911ad2e 100644
--- a/bamboo/INTEL-env.sh
+++ b/bamboo/INTEL-env.sh
@@ -1,5 +1,7 @@
 #!/bin/bash
 
+ctest_parallel="no"
+
 # Initialise module environment if it is not
 if [[ ! $(command -v module > /dev/null 2>&1) ]]; then
   . /usr/local/apps/module/init/bash
diff --git a/bamboo/flags.cmake b/bamboo/flags.cmake
index 1237788..59e60c0 100644
--- a/bamboo/flags.cmake
+++ b/bamboo/flags.cmake
@@ -1,9 +1,9 @@
 set( BUFR_TABLES_PATH             "bufr/text" CACHE STRING "" )
 
 set( CMAKE_C_FLAGS
-     "-Dlinux -DREAL_8 -DREAL_BIGGER_THAN_INTEGER -DINTEGER_IS_INT -DLITTLE_ENDIAN"
+     "-Dlinux"
      CACHE STRING "C flags" )
 
 set( CMAKE_Fortran_FLAGS
-     "-fcray-pointer -fdefault-real-8 -fdefault-double-8 -Dlinux -DREAL_8 -DREAL_BIGGER_THAN_INTEGER -DINTEGER_IS_INT -DLITTLE_ENDIAN"
+     "-Dlinux -fcray-pointer -fdefault-real-8 -fdefault-double-8"
      CACHE STRING "Fortran flags" )
diff --git a/bamboo/opensuse131-flags.cmake b/bamboo/opensuse131-flags.cmake
index 4fc8160..031b859 100644
--- a/bamboo/opensuse131-flags.cmake
+++ b/bamboo/opensuse131-flags.cmake
@@ -2,9 +2,9 @@ set( ENABLE_LIBEMOS_TESTS_REGRESS ON          CACHE STRING "additional tests: re
 set( BUFR_TABLES_PATH             "bufr/text" CACHE STRING "" )
 
 set( CMAKE_C_FLAGS
-     "-Dlinux -DREAL_8 -DREAL_BIGGER_THAN_INTEGER -DINTEGER_IS_INT -DLITTLE_ENDIAN"
+     "-Dlinux"
      CACHE STRING "C flags" )
 
 set( CMAKE_Fortran_FLAGS
-     "-fcray-pointer -fdefault-real-8 -fdefault-double-8 -Dlinux -DREAL_8 -DREAL_BIGGER_THAN_INTEGER -DINTEGER_IS_INT -DLITTLE_ENDIAN"
+     "-Dlinux -fcray-pointer -fdefault-real-8 -fdefault-double-8"
      CACHE STRING "Fortran flags" )
diff --git a/bin/ecbuild b/bin/ecbuild
index 0ee4b13..da2d7b9 100755
--- a/bin/ecbuild
+++ b/bin/ecbuild
@@ -368,9 +368,9 @@ cmake_version_sufficient=""
 
 # Check that version $1 satisfies $2
 # CMake versions have no more than 4 fields
-# (adapted from http://stackoverflow.com/a/25731924/396967)
+# Version sort (sort -V) is not available on all platforms
 version_gte() {
-    [  "$2" = "$(echo -e "$1\n$2" | sort -t '.' -k 1,1 -k 2,2 -k 3,3 -k 4,4 -g | head -n1)" ]
+  [ "$2" = "$(echo -e "$1\n$2" | sort -t '.' -k 1,1 -k 2,2 -k 3,3 -k 4,4 -g | head -n1)" ]
 }
 
 # Use already built CMake if any
diff --git a/cmake/CheckFortranCompilerFlag.cmake b/cmake/CheckFortranCompilerFlag.cmake
deleted file mode 100644
index 5408691..0000000
--- a/cmake/CheckFortranCompilerFlag.cmake
+++ /dev/null
@@ -1,37 +0,0 @@
-# - Check whether the CXX compiler supports a given flag.
-# CHECK_CXX_COMPILER_FLAG(FLAG VARIABLE)
-#
-#  FLAG - the compiler flag
-#  VARIABLE - variable to store the result
-
-# Copyright (c) 2006, Alexander Neundorf, <neundorf at kde.org>
-#
-# Redistribution and use is allowed according to the terms of the BSD license.
-# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
-
-
-INCLUDE(CheckFortranSourceCompiles)
-
-MACRO (CHECK_FORTRAN_COMPILER_FLAG _FLAG _RESULT)
-   SET(SAFE_CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS}")
-   SET(CMAKE_REQUIRED_DEFINITIONS "${_FLAG}")
-   CHECK_FORTRAN_SOURCE_COMPILES("program main\nend program\n" ${_RESULT}
-     # Some compilers do not fail with a bad flag
-     FAIL_REGEX "command line option .* is valid for .* but not for C\\\\+\\\\+" # GNU
-     FAIL_REGEX "unrecognized .*option"                     # GNU
-     FAIL_REGEX "unknown .*option"                          # Clang
-     FAIL_REGEX "invalid value"                             # Clang
-     FAIL_REGEX "ignoring unknown option"                   # MSVC
-     FAIL_REGEX "warning D9002"                             # MSVC, any lang
-     FAIL_REGEX "option.*not supported"                     # Intel
-     FAIL_REGEX "invalid argument .*option"                 # Intel
-     FAIL_REGEX "ignoring option .*argument required"       # Intel
-     FAIL_REGEX "[Uu]nknown option"                         # HP
-     FAIL_REGEX "[Ww]arning: [Oo]ption"                     # SunPro
-     FAIL_REGEX "command option .* is not recognized"       # XL
-     FAIL_REGEX "not supported in this configuration; ignored"       # AIX
-     FAIL_REGEX "File with unknown suffix passed to linker" # PGI
-     FAIL_REGEX "WARNING: unknown flag:"                    # Open64
-     )
-   SET (CMAKE_REQUIRED_DEFINITIONS "${SAFE_CMAKE_REQUIRED_DEFINITIONS}")
-ENDMACRO (CHECK_FORTRAN_COMPILER_FLAG)
diff --git a/cmake/CheckFortranSourceCompiles.cmake b/cmake/CheckFortranSourceCompiles.cmake
deleted file mode 100644
index d3dc968..0000000
--- a/cmake/CheckFortranSourceCompiles.cmake
+++ /dev/null
@@ -1,94 +0,0 @@
-# - Check if given Fortran source compiles and links into an executable
-# CHECK_FORTRAN_SOURCE_COMPILES(<code> <var> [FAIL_REGEX <fail-regex>])
-#  <code>       - source code to try to compile, must define 'main'
-#  <var>        - variable to store whether the source code compiled
-#  <fail-regex> - fail if test output matches this regex
-# The following variables may be set before calling this macro to
-# modify the way the check is run:
-#
-#  CMAKE_REQUIRED_FLAGS = string of compile command line flags
-#  CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
-#  CMAKE_REQUIRED_INCLUDES = list of include directories
-#  CMAKE_REQUIRED_LIBRARIES = list of libraries to link
-
-#=============================================================================
-# Copyright 2005-2009 Kitware, Inc.
-# Fortran version, 2013, James Tappin
-#
-# Distributed under the OSI-approved BSD License (the "License");
-# see accompanying file Copyright.txt for details.
-#
-# This software is distributed WITHOUT ANY WARRANTY; without even the
-# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-# See the License for more information.
-#=============================================================================
-# (To distribute this file outside of CMake, substitute the full
-#  License text for the above reference.)
-
-
-
-macro(CHECK_FORTRAN_SOURCE_COMPILES SOURCE VAR)
-
-if( ${VAR} MATCHES "^${VAR}$" )
-    set(_FAIL_REGEX)
-    set(_key)
-    foreach(arg ${ARGN})
-      if("${arg}" MATCHES "^(FAIL_REGEX)$")
-        set(_key "${arg}")
-      elseif(_key)
-        list(APPEND _${_key} "${arg}")
-      else()
-        ecbuild_critical("Unknown argument:\n  ${arg}\n")
-      endif()
-    endforeach()
-    set(MACRO_CHECK_FUNCTION_DEFINITIONS
-      "-D${VAR} ${CMAKE_REQUIRED_FLAGS}")
-    if(CMAKE_REQUIRED_LIBRARIES)
-      set(CHECK_FORTRAN_SOURCE_COMPILES_ADD_LIBRARIES
-        LINK_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
-    else()
-      set(CHECK_FORTRAN_SOURCE_COMPILES_ADD_LIBRARIES)
-    endif()
-    if(CMAKE_REQUIRED_INCLUDES)
-      set(CHECK_FORTRAN_SOURCE_COMPILES_ADD_INCLUDES
-        "-DINCLUDE_DIRECTORIES:STRING=${CMAKE_REQUIRED_INCLUDES}")
-    else()
-      set(CHECK_FORTRAN_SOURCE_COMPILES_ADD_INCLUDES)
-    endif()
-    file(WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.f90"
-      "${SOURCE}\n")
-
-    ecbuild_debug("Performing Test ${VAR}")
-    try_compile(${VAR}
-      ${CMAKE_BINARY_DIR}
-      ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.f90
-      COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
-      ${CHECK_FORTRAN_SOURCE_COMPILES_ADD_LIBRARIES}
-      CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS}
-      "${CHECK_FORTRAN_SOURCE_COMPILES_ADD_INCLUDES}"
-      OUTPUT_VARIABLE OUTPUT)
-
-    foreach(_regex ${_FAIL_REGEX})
-      if("${OUTPUT}" MATCHES "${_regex}")
-        set(${VAR} 0)
-      endif()
-    endforeach()
-
-    if(${VAR})
-      set(${VAR} 1 CACHE INTERNAL "Test ${VAR}")
-      ecbuild_debug("Performing Test ${VAR} - Success")
-      file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
-        "Performing Fortran SOURCE FILE Test ${VAR} succeded with the following output:\n"
-        "${OUTPUT}\n"
-        "Source file was:\n${SOURCE}\n")
-    else()
-      ecbuild_debug("Performing Test ${VAR} - Failed")
-      set(${VAR} "" CACHE INTERNAL "Test ${VAR}")
-      file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
-        "Performing Fortran SOURCE FILE Test ${VAR} failed with the following output:\n"
-        "${OUTPUT}\n"
-        "Source file was:\n${SOURCE}\n")
-    endif()
-  endif()
-endmacro()
-
diff --git a/cmake/contrib/FindFFTW.cmake b/cmake/FindFFTW.cmake
similarity index 96%
rename from cmake/contrib/FindFFTW.cmake
rename to cmake/FindFFTW.cmake
index 5ef46df..b76afa5 100644
--- a/cmake/contrib/FindFFTW.cmake
+++ b/cmake/FindFFTW.cmake
@@ -56,12 +56,6 @@
 #
 ##############################################################################
 
-#============================================#
-#                                            #
-#    From Eigen3, modified by W Deconinck    #
-#                                            #
-#============================================#
-
 if( (NOT FFTW_ROOT) AND EXISTS $ENV{FFTW_ROOT} )
   set( FFTW_ROOT ${FFTW_ROOT} )
 endif()
diff --git a/cmake/FindGeoTIFF.cmake b/cmake/FindGeoTIFF.cmake
index 83c868c..126bc46 100644
--- a/cmake/FindGeoTIFF.cmake
+++ b/cmake/FindGeoTIFF.cmake
@@ -1,38 +1,46 @@
-###############################################################################
+# (C) Copyright 1996-2016 ECMWF.
 #
-# CMake module to search for GeoTIFF library
-#
-# On success, the macro sets the following variables:
-# GEOTIFF_FOUND       = if the library found
-# GEOTIFF_LIBRARIES   = full path to the library
-# GEOTIFF_INCLUDE_DIR = where to find the library headers 
-# also defined, but not for general use are
-# GEOTIFF_LIBRARY, where to find the PROJ.4 library.
-#
-# Copyright (c) 2009 Mateusz Loskot <mateusz at loskot.net>
+# 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 GeoTIFF includes and library
+# This module defines
 #
-# Module source: http://github.com/mloskot/workshop/tree/master/cmake/
+#  GEOTIFF_FOUND         - System has GeoTIFF
+#  GEOTIFF_INCLUDE_DIRS  - the GeoTIFF include directories
+#  GEOTIFF_LIBRARIES     - the libraries needed to use GeoTIFF
 #
-# Redistribution and use is allowed according to the terms of the BSD license.
-# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
+# The following paths will be searched with priority if set in CMake or env
 #
-###############################################################################
+#  GEOTIFF_DIR   - root folder of the GeoTIFF installation
+#  GEOTIFF_PATH  - root folder of the GeoTIFF installation
 
-SET(GEOTIFF_NAMES geotiff)
+find_path( GEOTIFF_INCLUDE_DIR geotiff.h
+           PATHS ${GEOTIFF_PATH} ENV GEOTIFF_PATH
+                 ${GEOTIFF_DIR}  ENV GEOTIFF_DIR
+           PATH_SUFFIXES include include/libgeotiff
+           NO_DEFAULT_PATH )
+find_path( GEOTIFF_INCLUDE_DIR  openjpeg.h
+           PATH_SUFFIXES include include/libgeotiff )
 
+find_library( GEOTIFF_LIBRARY NAMES geotiff
+              PATHS ${GEOTIFF_PATH} ENV GEOTIFF_PATH
+                    ${GEOTIFF_DIR}  ENV GEOTIFF_DIR
+              PATH_SUFFIXES lib lib64
+              NO_DEFAULT_PATH )
+find_library( GEOTIFF_LIBRARY NAMES geotiff )
 
-    FIND_PATH(GEOTIFF_INCLUDE_DIR geotiff.h PATH_PREFIXES geotiff 
-         PATHS /usr/local/include/libgeotiff /usr/include/libgeotiff)
+set( GEOTIFF_LIBRARIES    ${GEOTIFF_LIBRARY} )
+set( GEOTIFF_INCLUDE_DIRS ${GEOTIFF_INCLUDE_DIR} )
 
-    FIND_LIBRARY(GEOTIFF_LIBRARY NAMES ${GEOTIFF_NAMES})
+include(FindPackageHandleStandardArgs)
 
-
-IF(GEOTIFF_FOUND)
-  SET(GEOTIFF_LIBRARIES ${GEOTIFF_LIBRARY})
-ENDIF()
-
-# Handle the QUIET and REQUIRED arguments and set GEOTIFF_FOUND to TRUE
+# handle the QUIETLY and REQUIRED arguments and set GEOTIFF_FOUND to TRUE
 # if all listed variables are TRUE
-# Note: capitalisation of the package name must be the same as in the file name
-INCLUDE(FindPackageHandleStandardArgs)
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(GEOTiff DEFAULT_MSG GEOTIFF_LIBRARY GEOTIFF_INCLUDE_DIR)
+find_package_handle_standard_args( GeoTIFF DEFAULT_MSG
+                                   GEOTIFF_LIBRARY GEOTIFF_INCLUDE_DIR )
+
+mark_as_advanced( GEOTIFF_INCLUDE_DIR GEOTIFF_LIBRARY )
diff --git a/cmake/FindOpenJPEG.cmake b/cmake/FindOpenJPEG.cmake
index b54ecce..c660238 100644
--- a/cmake/FindOpenJPEG.cmake
+++ b/cmake/FindOpenJPEG.cmake
@@ -1,39 +1,45 @@
 # (C) Copyright 1996-2016 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 
+# 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 OpenJPEG includes and library
+# - Try to find the OpenJPEG includes and library (version 1.5.x or 2.1.x)
 # This module defines
+#
 #  OPENJPEG_FOUND         - System has OpenJPEG
 #  OPENJPEG_INCLUDE_DIRS  - the OpenJPEG include directories
 #  OPENJPEG_LIBRARIES     - the libraries needed to use OpenJPEG
 #
-# also defined internally:
-#  OPENJPEG_LIBRARY, where to find the OpenJPEG library.
-#  OPENJPEG_INCLUDE_DIR, where to find the openjpeg.h header
-
-IF( NOT DEFINED OPENJPEG_PATH AND NOT "$ENV{OPENJPEG_PATH}" STREQUAL "" )
-  SET( OPENJPEG_PATH "$ENV{OPENJPEG_PATH}" )
-ENDIF()
-
-# Note: OpenJPEG version 2.x.y onwards has a variable-name sub-dir in the include
-# e.g. include/openjpeg-2.0 or include/openjpeg-2.1
-# We only support version 2.1.x
-# Also the name of the library is different. In v1.x it was libopenjpeg and now it's libopenjp2
-if( DEFINED OPENJPEG_PATH )
-  find_path(OPENJPEG_INCLUDE_DIR openjpeg.h PATHS ${OPENJPEG_PATH}/include PATH_SUFFIXES openjpeg openjpeg-2.1 NO_DEFAULT_PATH)
-
-  find_library( OPENJPEG_LIBRARY NAMES openjpeg openjp2 PATHS ${OPENJPEG_PATH}/lib
-                PATH_SUFFIXES openjpeg  NO_DEFAULT_PATH )
-endif()
-
-find_path(OPENJPEG_INCLUDE_DIR  openjpeg.h PATH_SUFFIXES openjpeg openjpeg-2.1)
-
-find_library( OPENJPEG_LIBRARY NAMES openjpeg openjp2 PATH_SUFFIXES openjpeg )
+# The following paths will be searched with priority if set in CMake or env
+#
+#  OPENJPEG_DIR   - root folder of the OpenJPEG installation
+#  OPENJPEG_PATH  - root folder of the OpenJPEG installation
+
+# Note: OpenJPEG has a version-specific subdirectory in the include
+# e.g. include/openjpeg-2.0 or include/openjpeg-2.1.
+# Only version 1.5.x and 2.1.x are supported.
+# The library name is different for 1.x (libopenjpeg) and 2.x (libopenjp2).
+
+set( _suff include include/openjpeg include/openjpeg-1.5 include/openjpeg-2.1 )
+find_path( OPENJPEG_INCLUDE_DIR openjpeg.h
+           PATHS ${OPENJPEG_PATH} ENV OPENJPEG_PATH
+                 ${OPENJPEG_DIR}  ENV OPENJPEG_DIR
+           PATH_SUFFIXES ${_suff}
+           NO_DEFAULT_PATH )
+find_path( OPENJPEG_INCLUDE_DIR  openjpeg.h
+           PATH_SUFFIXES ${_suff} )
+unset( _suff )
+
+find_library( OPENJPEG_LIBRARY NAMES openjpeg openjp2
+              PATHS ${OPENJPEG_PATH} ENV OPENJPEG_PATH
+                    ${OPENJPEG_DIR}  ENV OPENJPEG_DIR
+              PATH_SUFFIXES lib lib/openjpeg
+              NO_DEFAULT_PATH )
+find_library( OPENJPEG_LIBRARY NAMES openjpeg openjp2
+              PATH_SUFFIXES lib lib/openjpeg )
 
 set( OPENJPEG_LIBRARIES    ${OPENJPEG_LIBRARY} )
 set( OPENJPEG_INCLUDE_DIRS ${OPENJPEG_INCLUDE_DIR} )
@@ -45,4 +51,4 @@ include(FindPackageHandleStandardArgs)
 find_package_handle_standard_args(OpenJPEG  DEFAULT_MSG
                                   OPENJPEG_LIBRARY OPENJPEG_INCLUDE_DIR)
 
-mark_as_advanced(OPENJPEG_INCLUDE_DIR OPENJPEG_LIBRARY )
+mark_as_advanced( OPENJPEG_INCLUDE_DIR OPENJPEG_LIBRARY )
diff --git a/cmake/VERSION.cmake b/cmake/VERSION.cmake
index b4c65ee..d9d8705 100644
--- a/cmake/VERSION.cmake
+++ b/cmake/VERSION.cmake
@@ -1,7 +1,7 @@
 set( ECBUILD_MAJOR_VERSION "2" )
-set( ECBUILD_MINOR_VERSION "4" )
+set( ECBUILD_MINOR_VERSION "5" )
 set( ECBUILD_PATCH_VERSION "0" )
 
-set( ECBUILD_VERSION_STR  "2.4.0" )
+set( ECBUILD_VERSION_STR  "2.5.0" )
 
 set( ECBUILD_MACRO_VERSION "${ECBUILD_MAJOR_VERSION}.${ECBUILD_MINOR_VERSION}" )
diff --git a/cmake/compiler_flags/Cray_C.cmake b/cmake/compiler_flags/Cray_C.cmake
index 5e7ec61..f487cf4 100644
--- a/cmake/compiler_flags/Cray_C.cmake
+++ b/cmake/compiler_flags/Cray_C.cmake
@@ -6,9 +6,8 @@
 # granted to it by virtue of its status as an intergovernmental organisation
 # nor does it submit to any jurisdiction.
 
-set( CMAKE_C_FLAGS_ALL            ""                                                                               CACHE STRING "Common flags for all build-types" FORCE )
-set( CMAKE_C_FLAGS_RELEASE        "${CMAKE_C_FLAGS_ALL} -O3 -hfp3 -hscalar3 -hvector3 -DNDEBUG"                    CACHE STRING "Release C flags"                  FORCE )
-set( CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_ALL} -O2 -hfp1 -Gfast -DNDEBUG"                                 CACHE STRING "Release-with-debug-info C flags"  FORCE )
-set( CMAKE_C_FLAGS_PRODUCTION     "${CMAKE_C_FLAGS_ALL} -O2 -hfp1 -G2"                                             CACHE STRING "Production C flags"               FORCE )
-set( CMAKE_C_FLAGS_BIT            "${CMAKE_C_FLAGS_ALL} -O2 -hfp1 -G2 -hflex_mp=conservative -DNDEBUG"             CACHE STRING "Bit-reproducible C flags"         FORCE )
-set( CMAKE_C_FLAGS_DEBUG          "${CMAKE_C_FLAGS_ALL} -O0 -G0"                                                   CACHE STRING "Debug Cflags"                     FORCE )
+set( CMAKE_C_FLAGS_RELEASE        "-O3 -hfp3 -hscalar3 -hvector3 -DNDEBUG"        CACHE STRING "Release C flags"                  FORCE )
+set( CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -hfp1 -Gfast -DNDEBUG"                     CACHE STRING "Release-with-debug-info C flags"  FORCE )
+set( CMAKE_C_FLAGS_PRODUCTION     "-O2 -hfp1 -G2"                                 CACHE STRING "Production C flags"               FORCE )
+set( CMAKE_C_FLAGS_BIT            "-O2 -hfp1 -G2 -hflex_mp=conservative -DNDEBUG" CACHE STRING "Bit-reproducible C flags"         FORCE )
+set( CMAKE_C_FLAGS_DEBUG          "-O0 -G0"                                       CACHE STRING "Debug Cflags"                     FORCE )
diff --git a/cmake/compiler_flags/Cray_CXX.cmake b/cmake/compiler_flags/Cray_CXX.cmake
index ccc440b..a2a6632 100644
--- a/cmake/compiler_flags/Cray_CXX.cmake
+++ b/cmake/compiler_flags/Cray_CXX.cmake
@@ -6,9 +6,8 @@
 # granted to it by virtue of its status as an intergovernmental organisation
 # nor does it submit to any jurisdiction.
 
-set( CMAKE_CXX_FLAGS_ALL            ""                                                                                 CACHE STRING "Common flags for all build-types"  FORCE )
-set( CMAKE_CXX_FLAGS_RELEASE        "${CMAKE_CXX_FLAGS_ALL} -O3 -hfp3 -hscalar3 -hvector3 -DNDEBUG"                    CACHE STRING "Release C++ flags"                 FORCE )
-set( CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_ALL} -O2 -hfp1 -Gfast -DNDEBUG"                                 CACHE STRING "Release-with-debug-info C++ flags" FORCE )
-set( CMAKE_CXX_FLAGS_PRODUCTION     "${CMAKE_CXX_FLAGS_ALL} -O2 -hfp1 -G2"                                             CACHE STRING "Production C++ flags"              FORCE )
-set( CMAKE_CXX_FLAGS_BIT            "${CMAKE_CXX_FLAGS_ALL} -O2 -hfp1 -G2 -hflex_mp=conservative -DNDEBUG"             CACHE STRING "Bit-reproducible C++ flags"        FORCE )
-set( CMAKE_CXX_FLAGS_DEBUG          "${CMAKE_CXX_FLAGS_ALL} -O0 -G0"                                                   CACHE STRING "Debug CXX flags"                   FORCE )
+set( CMAKE_CXX_FLAGS_RELEASE        "-O3 -hfp3 -hscalar3 -hvector3 -DNDEBUG"        CACHE STRING "Release C++ flags"                 FORCE )
+set( CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -hfp1 -Gfast -DNDEBUG"                     CACHE STRING "Release-with-debug-info C++ flags" FORCE )
+set( CMAKE_CXX_FLAGS_PRODUCTION     "-O2 -hfp1 -G2"                                 CACHE STRING "Production C++ flags"              FORCE )
+set( CMAKE_CXX_FLAGS_BIT            "-O2 -hfp1 -G2 -hflex_mp=conservative -DNDEBUG" CACHE STRING "Bit-reproducible C++ flags"        FORCE )
+set( CMAKE_CXX_FLAGS_DEBUG          "-O0 -G0"                                       CACHE STRING "Debug CXX flags"                   FORCE )
diff --git a/cmake/compiler_flags/Cray_Fortran.cmake b/cmake/compiler_flags/Cray_Fortran.cmake
index b2c23de..34b96e4 100644
--- a/cmake/compiler_flags/Cray_Fortran.cmake
+++ b/cmake/compiler_flags/Cray_Fortran.cmake
@@ -7,9 +7,9 @@
 # nor does it submit to any jurisdiction.
 
 # -emf activates .mods and uses lower case
-set( CMAKE_Fortran_FLAGS_ALL            "-emf"                                                                                 CACHE STRING "Common flags for all build-types"      FORCE )
-set( CMAKE_Fortran_FLAGS_RELEASE        "${CMAKE_Fortran_FLAGS_ALL} -O3 -hfp3 -hscalar3 -hvector3 -DNDEBUG"                    CACHE STRING "Release Fortran flags"                 FORCE )
-set( CMAKE_Fortran_FLAGS_RELWITHDEBINFO "${CMAKE_Fortran_FLAGS_ALL} -O2 -hfp1 -Gfast -DNDEBUG"                                 CACHE STRING "Release-with-debug-info Fortran flags" FORCE )
-set( CMAKE_Fortran_FLAGS_PRODUCTION     "${CMAKE_Fortran_FLAGS_ALL} -O2 -hfp1 -G2"                                             CACHE STRING "Production Fortran flags"              FORCE )
-set( CMAKE_Fortran_FLAGS_BIT            "${CMAKE_Fortran_FLAGS_ALL} -O2 -hfp1 -G2 -hflex_mp=conservative -hadd_paren -DNDEBUG" CACHE STRING "Bit-reproducible Fortran flags"        FORCE )
-set( CMAKE_Fortran_FLAGS_DEBUG          "${CMAKE_Fortran_FLAGS_ALL} -O0 -G0"                                                   CACHE STRING "Debug Fortran flags"                   FORCE )
+# -rmoid produces a listing file
+set( CMAKE_Fortran_FLAGS_RELEASE        "-emf -rmoid -O3 -hfp3 -hscalar3 -hvector3 -DNDEBUG"                    CACHE STRING "Release Fortran flags"                 FORCE )
+set( CMAKE_Fortran_FLAGS_RELWITHDEBINFO "-emf -rmoid -O2 -hfp1 -Gfast -DNDEBUG"                                 CACHE STRING "Release-with-debug-info Fortran flags" FORCE )
+set( CMAKE_Fortran_FLAGS_PRODUCTION     "-emf -rmoid -O2 -hfp1 -G2"                                             CACHE STRING "Production Fortran flags"              FORCE )
+set( CMAKE_Fortran_FLAGS_BIT            "-emf -rmoid -O2 -hfp1 -G2 -hflex_mp=conservative -hadd_paren -DNDEBUG" CACHE STRING "Bit-reproducible Fortran flags"        FORCE )
+set( CMAKE_Fortran_FLAGS_DEBUG          "-emf -rmoid -O0 -G0"                                                   CACHE STRING "Debug Fortran flags"                   FORCE )
diff --git a/cmake/contrib/CMakeCheckCompilerFlagCommonPatterns.cmake b/cmake/contrib/CMakeCheckCompilerFlagCommonPatterns.cmake
new file mode 100644
index 0000000..1b5178d
--- /dev/null
+++ b/cmake/contrib/CMakeCheckCompilerFlagCommonPatterns.cmake
@@ -0,0 +1,33 @@
+# Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+
+# Do NOT include this module directly into any of your code. It is meant as
+# a library for Check*CompilerFlag.cmake modules. It's content may change in
+# any way between releases.
+
+macro (CHECK_COMPILER_FLAG_COMMON_PATTERNS _VAR)
+   set(${_VAR}
+     FAIL_REGEX "[Uu]nrecogni[sz]ed .*option"               # GNU, NAG
+     FAIL_REGEX "unknown .*option"                          # Clang
+     FAIL_REGEX "optimization flag .* not supported"        # Clang
+     FAIL_REGEX "unknown argument ignored"                  # Clang (cl)
+     FAIL_REGEX "ignoring unknown option"                   # MSVC, Intel
+     FAIL_REGEX "warning D9002"                             # MSVC, any lang
+     FAIL_REGEX "option.*not supported"                     # Intel
+     FAIL_REGEX "invalid argument .*option"                 # Intel
+     FAIL_REGEX "ignoring option .*argument required"       # Intel
+     FAIL_REGEX "ignoring option .*argument is of wrong type" # Intel
+     FAIL_REGEX "[Uu]nknown option"                         # HP
+     FAIL_REGEX "[Ww]arning: [Oo]ption"                     # SunPro
+     FAIL_REGEX "command option .* is not recognized"       # XL
+     FAIL_REGEX "command option .* contains an incorrect subargument" # XL
+     FAIL_REGEX "not supported in this configuration. ignored"       # AIX
+     FAIL_REGEX "File with unknown suffix passed to linker" # PGI
+     FAIL_REGEX "[Uu]nknown switch"                         # PGI
+     FAIL_REGEX "WARNING: unknown flag:"                    # Open64
+     FAIL_REGEX "Incorrect command line option:"            # Borland
+     FAIL_REGEX "Warning: illegal option"                   # SunStudio 12
+     FAIL_REGEX "[Ww]arning: Invalid suboption"             # Fujitsu
+   )
+endmacro ()
diff --git a/cmake/contrib/CheckFortranCompilerFlag.cmake b/cmake/contrib/CheckFortranCompilerFlag.cmake
index 6a35c8e..8519fcc 100644
--- a/cmake/contrib/CheckFortranCompilerFlag.cmake
+++ b/cmake/contrib/CheckFortranCompilerFlag.cmake
@@ -1,25 +1,53 @@
-# File taken from CMake Bug Report: http://public.kitware.com/Bug/print_bug_page.php?bug_id=12459
+# Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
 
-# - Check whether the Fortan compiler supports a given flag.
-# CHECK_FORTRAN_COMPILER_FLAG(<flag> <var>)
-#  <flag> - the compiler flag
-#  <var>  - variable to store the result
-# This internally calls the check_fortran_source_compiles macro.  See help
-# for CheckFortranSourceCompiles for a listing of variables that can
-# modify the build.
+#.rst:
+# CheckFortranCompilerFlag
+# ------------------------
+#
+# Check whether the Fortran compiler supports a given flag.
+#
+# CHECK_Fortran_COMPILER_FLAG(<flag> <var>)
+#
+# ::
+#
+#   <flag> - the compiler flag
+#   <var>  - variable to store the result
+#            Will be created as an internal cache variable.
+#
+# This internally calls the check_fortran_source_compiles macro and
+# sets CMAKE_REQUIRED_DEFINITIONS to <flag>.  See help for
+# CheckFortranSourceCompiles for a listing of variables that can
+# otherwise modify the build.  The result only tells that the compiler
+# does not give an error message when it encounters the flag.  If the
+# flag has any effect or even a specific one is beyond the scope of
+# this module.
 
-INCLUDE(CheckFortranSourceCompiles)
+include(CheckFortranSourceCompiles)
+include(CMakeCheckCompilerFlagCommonPatterns)
 
-MACRO (CHECK_FORTRAN_COMPILER_FLAG _FLAG _RESULT)
-   SET(SAFE_CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS}")
-   SET(CMAKE_REQUIRED_DEFINITIONS "${_FLAG}")
-   CHECK_FORTRAN_SOURCE_COMPILES("end" ${_RESULT}
-     # Some compilers do not fail with a bad flag
-     FAIL_REGEX "unrecognized .*option"                     # GNU
-     FAIL_REGEX "ignoring unknown option"                   # MSVC
-     FAIL_REGEX "[Uu]nknown option"                         # HP
-     FAIL_REGEX "[Ww]arning: [Oo]ption"                     # SunPro
-     FAIL_REGEX "command option .* is not recognized"       # XL
-     )
-   SET (CMAKE_REQUIRED_DEFINITIONS "${SAFE_CMAKE_REQUIRED_DEFINITIONS}")
-ENDMACRO (CHECK_FORTRAN_COMPILER_FLAG)
+macro (CHECK_Fortran_COMPILER_FLAG _FLAG _RESULT)
+  set(SAFE_CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS}")
+  set(CMAKE_REQUIRED_DEFINITIONS "${_FLAG}")
+
+  # Normalize locale during test compilation.
+  set(_CheckFortranCompilerFlag_LOCALE_VARS LC_ALL LC_MESSAGES LANG)
+  foreach(v ${_CheckFortranCompilerFlag_LOCALE_VARS})
+    set(_CheckFortranCompilerFlag_SAVED_${v} "$ENV{${v}}")
+    set(ENV{${v}} C)
+  endforeach()
+  CHECK_COMPILER_FLAG_COMMON_PATTERNS(_CheckFortranCompilerFlag_COMMON_PATTERNS)
+  CHECK_Fortran_SOURCE_COMPILES("       program test\n       stop\n       end program" ${_RESULT}
+    # Some compilers do not fail with a bad flag
+    FAIL_REGEX "command line option .* is valid for .* but not for Fortran" # GNU
+    ${_CheckFortranCompilerFlag_COMMON_PATTERNS}
+    )
+  foreach(v ${_CheckFortranCompilerFlag_LOCALE_VARS})
+    set(ENV{${v}} ${_CheckFortranCompilerFlag_SAVED_${v}})
+    unset(_CheckFortranCompilerFlag_SAVED_${v})
+  endforeach()
+  unset(_CheckFortranCompilerFlag_LOCALE_VARS)
+  unset(_CheckFortranCompilerFlag_COMMON_PATTERNS)
+
+  set (CMAKE_REQUIRED_DEFINITIONS "${SAFE_CMAKE_REQUIRED_DEFINITIONS}")
+endmacro ()
diff --git a/cmake/contrib/CheckFortranSourceCompiles.cmake b/cmake/contrib/CheckFortranSourceCompiles.cmake
index 500aee6..c42254c 100644
--- a/cmake/contrib/CheckFortranSourceCompiles.cmake
+++ b/cmake/contrib/CheckFortranSourceCompiles.cmake
@@ -1,61 +1,106 @@
-# File taken from CMake Bug Report: http://public.kitware.com/Bug/print_bug_page.php?bug_id=12459
+# Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
 
-# - Check if the source code provided in the SOURCE argument compiles.
-# CHECK_FORTRAN_SOURCE_COMPILES(SOURCE VAR)
-# - macro which checks if the source code compiles
-#  SOURCE   - source code to try to compile
-#  VAR      - variable to store whether the source code compiled
+#.rst:
+# CheckFortranSourceCompiles
+# --------------------------
 #
-# The following variables may be set before calling this macro to
-# modify the way the check is run:
+# Check if given Fortran source compiles and links into an executable::
 #
-#  CMAKE_REQUIRED_FLAGS = string of compile command line flags
-#  CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
-#  CMAKE_REQUIRED_INCLUDES = list of include directories
-#  CMAKE_REQUIRED_LIBRARIES = list of libraries to link
+#   CHECK_Fortran_SOURCE_COMPILES(<code> <var> [FAIL_REGEX <fail-regex>]
+#                                 [SRC_EXT <ext>])
+#
+# The arguments are:
+#
+# ``<code>``
+#   Source code to try to compile.  It must define a PROGRAM entry point.
+# ``<var>``
+#   Variable to store whether the source code compiled.
+#   Will be created as an internal cache variable.
+# ``FAIL_REGEX <fail-regex>``
+#   Fail if test output matches this regex.
+# ``SRC_EXT <ext>``
+#   Use source extension ``.<ext>`` instead of the default ``.F``.
+#
+# The following variables may be set before calling this macro to modify
+# the way the check is run::
+#
+#   CMAKE_REQUIRED_FLAGS = string of compile command line flags
+#   CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
+#   CMAKE_REQUIRED_INCLUDES = list of include directories
+#   CMAKE_REQUIRED_LIBRARIES = list of libraries to link
+#   CMAKE_REQUIRED_QUIET = execute quietly without messages
 
-MACRO(CHECK_FORTRAN_SOURCE_COMPILES SOURCE VAR)
-  IF("${VAR}" MATCHES "^${VAR}$")
-    SET(MACRO_CHECK_FUNCTION_DEFINITIONS
+macro(CHECK_Fortran_SOURCE_COMPILES SOURCE VAR)
+  if(NOT DEFINED "${VAR}")
+    set(_FAIL_REGEX)
+    set(_SRC_EXT)
+    set(_key)
+    foreach(arg ${ARGN})
+      if("${arg}" MATCHES "^(FAIL_REGEX|SRC_EXT)$")
+        set(_key "${arg}")
+      elseif(_key)
+        list(APPEND _${_key} "${arg}")
+      else()
+        message(FATAL_ERROR "Unknown argument:\n  ${arg}\n")
+      endif()
+    endforeach()
+    if(NOT _SRC_EXT)
+      set(_SRC_EXT F)
+    endif()
+    set(MACRO_CHECK_FUNCTION_DEFINITIONS
       "-D${VAR} ${CMAKE_REQUIRED_FLAGS}")
-    IF(CMAKE_REQUIRED_LIBRARIES)
-      SET(CHECK_FORTRAN_SOURCE_COMPILES_ADD_LIBRARIES
-        "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}")
-    ELSE(CMAKE_REQUIRED_LIBRARIES)
-      SET(CHECK_FORTRAN_SOURCE_COMPILES_ADD_LIBRARIES)
-    ENDIF(CMAKE_REQUIRED_LIBRARIES)
-    IF(CMAKE_REQUIRED_INCLUDES)
-      SET(CHECK_FORTRAN_SOURCE_COMPILES_ADD_INCLUDES
+    if(CMAKE_REQUIRED_LIBRARIES)
+      set(CHECK_Fortran_SOURCE_COMPILES_ADD_LIBRARIES
+        LINK_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
+    else()
+      set(CHECK_Fortran_SOURCE_COMPILES_ADD_LIBRARIES)
+    endif()
+    if(CMAKE_REQUIRED_INCLUDES)
+      set(CHECK_Fortran_SOURCE_COMPILES_ADD_INCLUDES
         "-DINCLUDE_DIRECTORIES:STRING=${CMAKE_REQUIRED_INCLUDES}")
-    ELSE(CMAKE_REQUIRED_INCLUDES)
-      SET(CHECK_FORTRAN_SOURCE_COMPILES_ADD_INCLUDES)
-    ENDIF(CMAKE_REQUIRED_INCLUDES)
-    FILE(WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.f90"
+    else()
+      set(CHECK_Fortran_SOURCE_COMPILES_ADD_INCLUDES)
+    endif()
+    file(WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.${_SRC_EXT}"
       "${SOURCE}\n")
 
-    MESSAGE(STATUS "Performing Test ${VAR}")
-    TRY_COMPILE(${VAR}
+    if(NOT CMAKE_REQUIRED_QUIET)
+      message(STATUS "Performing Test ${VAR}")
+    endif()
+    try_compile(${VAR}
       ${CMAKE_BINARY_DIR}
-      ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.f90
+      ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.${_SRC_EXT}
       COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
+      ${CHECK_Fortran_SOURCE_COMPILES_ADD_LIBRARIES}
       CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS}
-      "${CHECK_FORTRAN_SOURCE_COMPILES_ADD_LIBRARIES}"
-      "${CHECK_FORTRAN_SOURCE_COMPILES_ADD_INCLUDES}"
+      "${CHECK_Fortran_SOURCE_COMPILES_ADD_INCLUDES}"
       OUTPUT_VARIABLE OUTPUT)
-    IF(${VAR})
-      SET(${VAR} 1 CACHE INTERNAL "Test ${VAR}")
-      MESSAGE(STATUS "Performing Test ${VAR} - Success")
-      FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
-        "Performing Fortran SOURCE FILE Test ${VAR} succeded with the following output:\n"
+
+    foreach(_regex ${_FAIL_REGEX})
+      if("${OUTPUT}" MATCHES "${_regex}")
+        set(${VAR} 0)
+      endif()
+    endforeach()
+
+    if(${VAR})
+      set(${VAR} 1 CACHE INTERNAL "Test ${VAR}")
+      if(NOT CMAKE_REQUIRED_QUIET)
+        message(STATUS "Performing Test ${VAR} - Success")
+      endif()
+      file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
+        "Performing Fortran SOURCE FILE Test ${VAR} succeeded with the following output:\n"
         "${OUTPUT}\n"
         "Source file was:\n${SOURCE}\n")
-    ELSE(${VAR})
-      MESSAGE(STATUS "Performing Test ${VAR} - Failed")
-      SET(${VAR} 0 CACHE INTERNAL "Test ${VAR}")
-      FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
+    else()
+      if(NOT CMAKE_REQUIRED_QUIET)
+        message(STATUS "Performing Test ${VAR} - Failed")
+      endif()
+      set(${VAR} "" CACHE INTERNAL "Test ${VAR}")
+      file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
         "Performing Fortran SOURCE FILE Test ${VAR} failed with the following output:\n"
         "${OUTPUT}\n"
         "Source file was:\n${SOURCE}\n")
-    ENDIF(${VAR})
-  ENDIF("${VAR}" MATCHES "^${VAR}$")
-ENDMACRO(CHECK_FORTRAN_SOURCE_COMPILES)
+    endif()
+  endif()
+endmacro()
diff --git a/cmake/contrib/FindNetCDF4.cmake b/cmake/contrib/FindNetCDF4.cmake
index 6bba4e0..70e54af 100644
--- a/cmake/contrib/FindNetCDF4.cmake
+++ b/cmake/contrib/FindNetCDF4.cmake
@@ -149,11 +149,11 @@ else()
     set( NETCDF_F90_INCLUDE_NAMES netcdf.mod typesizes.mod ${NETCDF_C_INCLUDE_NAMES} )
 
     set( NETCDF_C_LIBRARY_NAMES netcdf)
-    set( NETCDF_CXX_LIBRARY_NAMES netcdf_c++ ${NETCDF_C_LIBRARY_NAMES} )
+    set( NETCDF_CXX_LIBRARY_NAMES netcdf_c++ netcdf_c++4 ${NETCDF_C_LIBRARY_NAMES} )
     set( NETCDF_FORTRAN_LIBRARY_NAMES netcdff ${NETCDF_C_LIBRARY_NAMES})
     set( NETCDF_F90_LIBRARY_NAMES ${NETCDF_FORTRAN_LIBRARY_NAMES} )
 
-    set( NETCDF_REQUIRED netcdf.h netcdfcpp.h netcdf.mod typesizes.mod netcdf netcdff netcdf_c++)
+    set( NETCDF_REQUIRED netcdf.h netcdfcpp.h netcdf.mod typesizes.mod netcdf netcdff netcdf_c++ netcdf_c++4)
 
     foreach( LANGUAGE ${NETCDF_LANGUAGE_BINDINGS} )
         ecbuild_debug("FindNetCDF4: looking for ${LANGUAGE} language bindings")
diff --git a/cmake/ecbuild_add_executable.cmake b/cmake/ecbuild_add_executable.cmake
index c25fe59..424059e 100644
--- a/cmake/ecbuild_add_executable.cmake
+++ b/cmake/ecbuild_add_executable.cmake
@@ -232,66 +232,10 @@ macro( ecbuild_add_executable )
     #   ecbuild_debug_var( ${_PAR_TARGET}_h_srcs )
     #   ecbuild_debug_var( ${_PAR_TARGET}_c_srcs )
     #   ecbuild_debug_var( ${_PAR_TARGET}_cxx_srcs )
-    #   ecbuild_debug_var( ${_PAR_TARGET}_f_srcs )
+    #   ecbuild_debug_var( ${_PAR_TARGET}_fortran_srcs )
 
-    # add local flags
-
-    if( ${_PAR_TARGET}_c_srcs )
-
-      if( ECBUILD_SOURCE_FLAGS )
-        ecbuild_source_flags( ${_PAR_TARGET}_C_SOURCE_FLAGS
-                              ${_PAR_TARGET}_c
-                              "${_PAR_CFLAGS}"
-                              "${${_PAR_TARGET}_c_srcs}" )
-
-        ecbuild_debug("ecbuild_add_executable(${_PAR_TARGET}): setting source file C flags from ${${_PAR_TARGET}_C_SOURCE_FLAGS}")
-        include( ${${_PAR_TARGET}_C_SOURCE_FLAGS} )
-
-      elseif( DEFINED _PAR_CFLAGS )
-
-        ecbuild_debug("ecbuild_add_executable(${_PAR_TARGET}): use C flags ${_PAR_CFLAGS}")
-        set_source_files_properties( ${${_PAR_TARGET}_c_srcs}   PROPERTIES COMPILE_FLAGS "${_PAR_CFLAGS}" )
-
-      endif()
-    endif()
-
-    if( ${_PAR_TARGET}_cxx_srcs )
-
-      if( ECBUILD_SOURCE_FLAGS )
-        ecbuild_source_flags( ${_PAR_TARGET}_CXX_SOURCE_FLAGS
-                              ${_PAR_TARGET}_cxx
-                              "${_PAR_CXXFLAGS}"
-                              "${${_PAR_TARGET}_cxx_srcs}" )
-
-        ecbuild_debug("ecbuild_add_executable(${_PAR_TARGET}): setting source file CXX flags from ${${_PAR_TARGET}_CXX_SOURCE_FLAGS}")
-        include( ${${_PAR_TARGET}_CXX_SOURCE_FLAGS} )
-
-      elseif( DEFINED _PAR_CXXFLAGS )
-
-        ecbuild_debug("ecbuild_add_executable(${_PAR_TARGET}): use C++ flags ${_PAR_CFLAGS}")
-        set_source_files_properties( ${${_PAR_TARGET}_cxx_srcs} PROPERTIES COMPILE_FLAGS "${_PAR_CXXFLAGS}" )
-
-      endif()
-    endif()
-
-    if( ${_PAR_TARGET}_f_srcs )
-
-      if( ECBUILD_SOURCE_FLAGS )
-        ecbuild_source_flags( ${_PAR_TARGET}_Fortran_SOURCE_FLAGS
-                              ${_PAR_TARGET}_f
-                              "${_PAR_FFLAGS}"
-                              "${${_PAR_TARGET}_f_srcs}" )
-
-        ecbuild_debug("ecbuild_add_executable(${_PAR_TARGET}): setting source file Fortran flags from ${${_PAR_TARGET}_Fortran_SOURCE_FLAGS}")
-        include( ${${_PAR_TARGET}_Fortran_SOURCE_FLAGS} )
-
-      elseif( DEFINED _PAR_FFLAGS )
-
-        ecbuild_debug("ecbuild_add_executable(${_PAR_TARGET}): use Fortran flags ${_PAR_CFLAGS}")
-        set_source_files_properties( ${${_PAR_TARGET}_f_srcs}  PROPERTIES COMPILE_FLAGS "${_PAR_FFLAGS}" )
-
-      endif()
-    endif()
+    # Override compilation flags on a per source file basis
+    ecbuild_target_flags( ${_PAR_TARGET} "${_PAR_CFLAGS}" "${_PAR_CXXFLAGS}" "${_PAR_FFLAGS}" )
 
     # define VERSION if requested
     if( DEFINED _PAR_VERSION )
diff --git a/cmake/ecbuild_add_library.cmake b/cmake/ecbuild_add_library.cmake
index 55b8ce5..a7f8001 100644
--- a/cmake/ecbuild_add_library.cmake
+++ b/cmake/ecbuild_add_library.cmake
@@ -36,6 +36,7 @@
 #                        [ INSTALL_HEADERS_LIST <header1> [<header2> ...] ]
 #                        [ INSTALL_HEADERS_REGEX <pattern> ]
 #                        [ VERSION <version> | AUTO_VERSION ]
+#                        [ SOVERSION <soversion> | AUTO_SOVERSION ]
 #                        [ CFLAGS <flag1> [<flag2> ...] ]
 #                        [ CXXFLAGS <flag1> [<flag2> ...] ]
 #                        [ FFLAGS <flag1> [<flag2> ...] ]
@@ -123,10 +124,16 @@
 #   regular expression to match extra headers to install
 #
 # VERSION : optional, AUTO_VERSION or LIBS_VERSION is used if not specified
-#   version to use as library version
+#   build version of the library
 #
 # AUTO_VERSION : optional, ignored if VERSION is specified
-#   automatically version the library with the package version
+#   use MAJOR.MINOR package version as build version of the library
+#
+# SOVERSION : optional, AUTO_SOVERSION or LIBS_SOVERSION is used if not specified
+#   ABI version of the library
+#
+# AUTO_SOVERSION : optional, ignored if SOVERSION is specified
+#   use MAJOR package version as ABI version of the library
 #
 # CFLAGS : optional
 #   list of C compiler flags to use for all C source files
@@ -147,8 +154,8 @@
 
 function( ecbuild_add_library_impl )
 
-  set( options NOINSTALL AUTO_VERSION )
-  set( single_value_args TARGET TYPE COMPONENT INSTALL_HEADERS INSTALL_HEADERS_REGEX LINKER_LANGUAGE HEADER_DESTINATION VERSION OUTPUT_NAME )
+  set( options NOINSTALL AUTO_VERSION AUTO_SOVERSION )
+  set( single_value_args TARGET TYPE COMPONENT INSTALL_HEADERS INSTALL_HEADERS_REGEX LINKER_LANGUAGE HEADER_DESTINATION VERSION SOVERSION OUTPUT_NAME )
   set( multi_value_args  SOURCES SOURCES_GLOB SOURCES_EXCLUDE_REGEX OBJECTS TEMPLATES LIBS INCLUDES PRIVATE_INCLUDES PUBLIC_INCLUDES DEPENDS PERSISTENT DEFINITIONS INSTALL_HEADERS_LIST CFLAGS CXXFLAGS FFLAGS GENERATED CONDITION )
 
   cmake_parse_arguments( _PAR "${options}" "${single_value_args}" "${multi_value_args}"  ${_FIRST_ARG} ${ARGN} )
@@ -330,19 +337,32 @@ function( ecbuild_add_library_impl )
 
     # define VERSION if requested
     if( DEFINED _PAR_VERSION )
-      ecbuild_debug("ecbuild_add_library(${_PAR_TARGET}): set version to ${_PAR_VERSION}")
+      ecbuild_debug("ecbuild_add_library(${_PAR_TARGET}): set build version to ${_PAR_VERSION}")
       set_target_properties( ${_PAR_TARGET} PROPERTIES VERSION "${_PAR_VERSION}" )
     else()
       if( _PAR_AUTO_VERSION OR LIBS_VERSION MATCHES "[Aa][Uu][Tt][Oo]")
-        ecbuild_debug("ecbuild_add_library(${_PAR_TARGET}): set version to ${${PNAME}_MAJOR_VERSION}.${${PNAME}_MINOR_VERSION} (auto)")
+        ecbuild_debug("ecbuild_add_library(${_PAR_TARGET}): set build version to ${${PNAME}_MAJOR_VERSION}.${${PNAME}_MINOR_VERSION} (auto)")
         set_target_properties( ${_PAR_TARGET} PROPERTIES VERSION "${${PNAME}_MAJOR_VERSION}.${${PNAME}_MINOR_VERSION}" )
-      endif()
-      if( LIBS_VERSION AND NOT LIBS_VERSION MATCHES "[Aa][Uu][Tt][Oo]" )
-        ecbuild_debug("ecbuild_add_library(${_PAR_TARGET}): set version to ${LIBS_VERSION}")
+      elseif( DEFINED LIBS_VERSION )
+        ecbuild_debug("ecbuild_add_library(${_PAR_TARGET}): set build version to ${LIBS_VERSION}")
         set_target_properties( ${_PAR_TARGET} PROPERTIES VERSION "${LIBS_VERSION}" )
       endif()
     endif()
 
+    # define SOVERSION if requested
+    if( DEFINED _PAR_SOVERSION )
+      ecbuild_debug("ecbuild_add_library(${_PAR_TARGET}): set ABI version to ${_PAR_SOVERSION}")
+      set_target_properties( ${_PAR_TARGET} PROPERTIES SOVERSION "${_PAR_SOVERSION}" )
+    else()
+      if( _PAR_AUTO_SOVERSION OR LIBS_SOVERSION MATCHES "[Aa][Uu][Tt][Oo]")
+        ecbuild_debug("ecbuild_add_library(${_PAR_TARGET}): set ABI version to ${${PNAME}_MAJOR_VERSION} (auto)")
+        set_target_properties( ${_PAR_TARGET} PROPERTIES SOVERSION "${${PNAME}_MAJOR_VERSION}" )
+      elseif( DEFINED LIBS_SOVERSION )
+        ecbuild_debug("ecbuild_add_library(${_PAR_TARGET}): set ABI version to ${LIBS_SOVERSION}")
+        set_target_properties( ${_PAR_TARGET} PROPERTIES SOVERSION "${LIBS_SOVERSION}" )
+      endif()
+    endif()
+
     # filter sources
 
     if( _PAR_SOURCES )
@@ -352,66 +372,10 @@ function( ecbuild_add_library_impl )
     #   ecbuild_debug_var( ${_PAR_TARGET}_h_srcs )
     #   ecbuild_debug_var( ${_PAR_TARGET}_c_srcs )
     #   ecbuild_debug_var( ${_PAR_TARGET}_cxx_srcs )
-    #   ecbuild_debug_var( ${_PAR_TARGET}_f_srcs )
-
-    # add local flags
-
-    if( ${_PAR_TARGET}_c_srcs )
-
-      if( ECBUILD_SOURCE_FLAGS )
-        ecbuild_source_flags( ${_PAR_TARGET}_C_SOURCE_FLAGS
-                              ${_PAR_TARGET}_c
-                              "${_PAR_CFLAGS}"
-                              "${${_PAR_TARGET}_c_srcs}" )
-
-        ecbuild_debug("ecbuild_add_library(${_PAR_TARGET}): setting source file C flags from ${${_PAR_TARGET}_C_SOURCE_FLAGS}")
-        include( ${${_PAR_TARGET}_C_SOURCE_FLAGS} )
-
-      elseif( DEFINED _PAR_CFLAGS )
-
-        ecbuild_debug("ecbuild_add_library(${_PAR_TARGET}): use C flags ${_PAR_CFLAGS}")
-        set_source_files_properties( ${${_PAR_TARGET}_c_srcs}   PROPERTIES COMPILE_FLAGS "${_PAR_CFLAGS}" )
-
-      endif()
-    endif()
+    #   ecbuild_debug_var( ${_PAR_TARGET}_fortran_srcs )
 
-    if( ${_PAR_TARGET}_cxx_srcs )
-
-      if( ECBUILD_SOURCE_FLAGS )
-        ecbuild_source_flags( ${_PAR_TARGET}_CXX_SOURCE_FLAGS
-                              ${_PAR_TARGET}_cxx
-                              "${_PAR_CXXFLAGS}"
-                              "${${_PAR_TARGET}_cxx_srcs}" )
-
-        ecbuild_debug("ecbuild_add_library(${_PAR_TARGET}): setting source file CXX flags from ${${_PAR_TARGET}_CXX_SOURCE_FLAGS}")
-        include( ${${_PAR_TARGET}_CXX_SOURCE_FLAGS} )
-
-      elseif( DEFINED _PAR_CXXFLAGS )
-
-        ecbuild_debug("ecbuild_add_library(${_PAR_TARGET}): use C++ flags ${_PAR_CFLAGS}")
-        set_source_files_properties( ${${_PAR_TARGET}_cxx_srcs} PROPERTIES COMPILE_FLAGS "${_PAR_CXXFLAGS}" )
-
-      endif()
-    endif()
-
-    if( ${_PAR_TARGET}_f_srcs )
-
-      if( ECBUILD_SOURCE_FLAGS )
-        ecbuild_source_flags( ${_PAR_TARGET}_Fortran_SOURCE_FLAGS
-                              ${_PAR_TARGET}_f
-                              "${_PAR_FFLAGS}"
-                              "${${_PAR_TARGET}_f_srcs}" )
-
-        ecbuild_debug("ecbuild_add_library(${_PAR_TARGET}): setting source file Fortran flags from ${${_PAR_TARGET}_Fortran_SOURCE_FLAGS}")
-        include( ${${_PAR_TARGET}_Fortran_SOURCE_FLAGS} )
-
-      elseif( DEFINED _PAR_FFLAGS )
-
-        ecbuild_debug("ecbuild_add_library(${_PAR_TARGET}): use Fortran flags ${_PAR_CFLAGS}")
-        set_source_files_properties( ${${_PAR_TARGET}_f_srcs}  PROPERTIES COMPILE_FLAGS "${_PAR_FFLAGS}" )
-
-      endif()
-    endif()
+    # Override compilation flags on a per source file basis
+    ecbuild_target_flags( ${_PAR_TARGET} "${_PAR_CFLAGS}" "${_PAR_CXXFLAGS}" "${_PAR_FFLAGS}" )
 
     if( DEFINED _PAR_GENERATED )
       ecbuild_debug("ecbuild_add_library(${_PAR_TARGET}): mark as generated ${_PAR_GENERATED}")
diff --git a/cmake/ecbuild_add_option.cmake b/cmake/ecbuild_add_option.cmake
index e0468fb..fd8076e 100644
--- a/cmake/ecbuild_add_option.cmake
+++ b/cmake/ecbuild_add_option.cmake
@@ -20,7 +20,7 @@
 #                       [ PURPOSE <purpose> ]
 #                       [ REQUIRED_PACKAGES <package1> [<package2> ...] ]
 #                       [ CONDITION <condition> ]
-#                       [ ADVANCED ] )
+#                       [ ADVANCED ] [ NO_TPL ] )
 #
 # Options
 # -------
@@ -66,6 +66,9 @@
 # ADVANCED : optional
 #   mark the feature as advanced
 #
+# NO_TPL : optional
+#   do not add any ``REQUIRED_PACKAGES`` to the list of third party libraries
+#
 # Usage
 # -----
 #
@@ -84,7 +87,7 @@
 
 macro( ecbuild_add_option )
 
-  set( options ADVANCED )
+  set( options ADVANCED NO_TPL )
   set( single_value_args FEATURE DEFAULT DESCRIPTION TYPE PURPOSE )
   set( multi_value_args  REQUIRED_PACKAGES CONDITION )
 
@@ -129,17 +132,16 @@ macro( ecbuild_add_option )
     set( _${_p_FEATURE}_condition TRUE )
   endif()
 
-  # check if user provided value
-
-  get_property( _in_cache CACHE ENABLE_${_p_FEATURE} PROPERTY VALUE )
+  # Check if user explicitly enabled/disabled the feature in cache
+  get_property( _in_cache CACHE ENABLE_${_p_FEATURE} PROPERTY VALUE SET )
 
   # A feature set to REQUIRE is always treated as explicitly enabled
   if( ENABLE_${_p_FEATURE} MATCHES "REQUIRE" )
     set( ENABLE_${_p_FEATURE} ON CACHE BOOL "" FORCE )
     ecbuild_debug("ecbuild_add_option(${_p_FEATURE}): ENABLE_${_p_FEATURE} was required")
     set( ${_p_FEATURE}_user_provided_input 1 CACHE BOOL "" FORCE )
-  elseif( NOT "${ENABLE_${_p_FEATURE}}" STREQUAL "" AND _in_cache )
-    ecbuild_debug("ecbuild_add_option(${_p_FEATURE}): ENABLE_${_p_FEATURE} was found in cache")
+  elseif( NOT ENABLE_${_p_FEATURE} STREQUAL "" AND _in_cache )
+    ecbuild_debug("ecbuild_add_option(${_p_FEATURE}): ENABLE_${_p_FEATURE}=${ENABLE_${_p_FEATURE}} was found in cache")
     set( ${_p_FEATURE}_user_provided_input 1 CACHE BOOL "" )
   else()
     ecbuild_debug("ecbuild_add_option(${_p_FEATURE}): ENABLE_${_p_FEATURE} not found in cache")
@@ -159,13 +161,9 @@ macro( ecbuild_add_option )
                           TYPE ${_p_TYPE}
                           PURPOSE "${_p_PURPOSE}" )
 
-  ecbuild_debug("ecbuild_add_option(${_p_FEATURE}): ENABLE_${_p_FEATURE} = ${ENABLE_${_p_FEATURE}}")
-  set( _do_search ${ENABLE_${_p_FEATURE}} )
-  if( _p_FEATURE STREQUAL "OMP" )
-    set( _do_search TRUE )
-  endif()
+  ecbuild_debug("ecbuild_add_option(${_p_FEATURE}): ENABLE_${_p_FEATURE}=${ENABLE_${_p_FEATURE}}")
 
-  if( _do_search  )
+  if( ENABLE_${_p_FEATURE} )
     ecbuild_debug("ecbuild_add_option(${_p_FEATURE}): feature enabled")
 
     set( HAVE_${_p_FEATURE} 1 )
@@ -244,14 +242,6 @@ macro( ecbuild_add_option )
 
         endif()
 
-        # if found append to list of third-party libraries (to be forward to other packages )
-        if( ${pkgname}_FOUND OR ${pkgUPPER}_FOUND OR ${pkgLOWER}_FOUND )
-
-          list( APPEND ${PROJECT_NAME_CAPS}_TPLS ${pkgname} )
-          list( REMOVE_DUPLICATES ${PROJECT_NAME_CAPS}_TPLS )
-
-        endif()
-
         # ecbuild_debug_var( ${pkgname}_FOUND  )
         # ecbuild_debug_var( ${pkgLOWER}_FOUND )
         # ecbuild_debug_var( ${pkgUPPER}_FOUND )
@@ -260,6 +250,15 @@ macro( ecbuild_add_option )
 
         if( ${pkgname}_FOUND OR ${pkgUPPER}_FOUND OR ${pkgLOWER}_FOUND )
           ecbuild_info( "Found package ${pkgname} required for feature ${_p_FEATURE}" )
+
+          # append to list of third-party libraries (to be forward to other packages )
+          # unless the NO_TPL option was given
+          if( NOT _p_NO_TPL )
+            ecbuild_debug("ecbuild_add_option(${_p_FEATURE}): appending ${pkgname} to ${PROJECT_NAME_CAPS}_TPLS")
+            list( APPEND ${PROJECT_NAME_CAPS}_TPLS ${pkgname} )
+            list( REMOVE_DUPLICATES ${PROJECT_NAME_CAPS}_TPLS )
+          endif()
+
         else()
           ecbuild_info( "Could NOT find package ${pkgname} required for feature ${_p_FEATURE} -- ${__help_msg}" )
           set( HAVE_${_p_FEATURE} 0 )
@@ -300,13 +299,13 @@ macro( ecbuild_add_option )
 
     endif()
 
-  else( _do_search )
+  else()
 
     ecbuild_debug("ecbuild_add_option(${_p_FEATURE}): feature disabled")
     set( HAVE_${_p_FEATURE} 0 )
     ecbuild_set_feature( ${_p_FEATURE} ENABLED OFF )
 
-  endif( _do_search )
+  endif()
 
 
   if( ${_p_ADVANCED} )
diff --git a/cmake/ecbuild_add_test.cmake b/cmake/ecbuild_add_test.cmake
index 0563cd6..1dcf2c6 100644
--- a/cmake/ecbuild_add_test.cmake
+++ b/cmake/ecbuild_add_test.cmake
@@ -19,6 +19,7 @@
 #                     [ OBJECTS <obj1> [<obj2> ...] ]
 #                     [ COMMAND <executable> ]
 #                     [ TYPE EXE|SCRIPT|PYTHON ]
+#                     [ LABELS <label1> [<label2> ...] ]
 #                     [ ARGS <argument1> [<argument2> ...] ]
 #                     [ RESOURCES <file1> [<file2> ...] ]
 #                     [ TEST_DATA <file1> [<file2> ...] ]
@@ -63,6 +64,22 @@
 #   :SCRIPT: run command or script, default if COMMAND is provided
 #   :PYTHON: run a Python script (requires the Python interpreter to be found)
 #
+# LABELS : optional
+#   list of labels to assign to the test
+#
+#   The project name in lower case is always added as a label. Additional
+#   labels are assigned depending on the type of test:
+#
+#   :executable: for type ``EXE``
+#   :script:     for type ``SCRIPT``
+#   :python:     for type ``PYTHON``
+#   :boost:      uses Boost unit test
+#   :mpi:        if ``MPI`` is set
+#   :openmp:     if ``OMP`` is set
+#
+#   This allows selecting tests to run via ``ctest -L <regex>`` or tests
+#   to exclude via ``ctest -LE <regex>``.
+#
 # ARGS : optional
 #   list of arguments to pass to TARGET or COMMAND when running the test
 #
@@ -76,9 +93,9 @@
 #   use the Boost Unit Test Framework
 #
 # MPI : optional
-#   number of MPI tasks to use.
+#   Run with MPI using the given number of MPI tasks.
 #
-#   If greater than 1, and MPI is not available, the test is disabled.
+#   If greater than 1, and ``MPIEXEC`` is not available, the test is disabled.
 #
 # OMP : optional
 #   number of OpenMP threads per MPI task to use.
@@ -138,7 +155,7 @@ macro( ecbuild_add_test )
 
   set( options           BOOST )
   set( single_value_args TARGET ENABLED COMMAND TYPE LINKER_LANGUAGE MPI OMP WORKING_DIRECTORY )
-  set( multi_value_args  SOURCES OBJECTS LIBS INCLUDES TEST_DEPENDS DEPENDS ARGS
+  set( multi_value_args  SOURCES OBJECTS LIBS INCLUDES TEST_DEPENDS DEPENDS LABELS ARGS
                          PERSISTENT DEFINITIONS RESOURCES TEST_DATA CFLAGS
                          CXXFLAGS FFLAGS GENERATED CONDITION ENVIRONMENT )
 
@@ -150,21 +167,31 @@ macro( ecbuild_add_test )
 
   set( _TEST_DIR ${CMAKE_CURRENT_BINARY_DIR} )
 
-  # Check for MPI
-  if(_PAR_MPI)
-    if( (_PAR_MPI GREATER 1) AND ( (NOT MPI_FOUND) OR (NOT MPIEXEC) ) )
-      ecbuild_debug("ecbuild_add_test(${_PAR_TARGET}): ${_PAR_MPI} MPI ranks requested but MPI not available - disabling test")
+  # Undocumented flag for disabling all MPI tests for test environment without suitable MPI(EXEC)
+  if( _PAR_MPI AND ECBUILD_DISABLE_MPI_TESTS )
+    ecbuild_debug("ecbuild_add_test(${_PAR_TARGET}): ECBUILD_DISABLE_MPI_TESTS set - disabling test")
+    set( _PAR_ENABLED 0 )
+  elseif( _PAR_MPI )
+    # Check for MPIEXEC if it not set
+    find_program( MPIEXEC NAMES mpiexec mpirun lamexec srun
+                  DOC "Executable for running MPI programs." )
+    if( MPIEXEC )
+      set(MPIEXEC_NUMPROC_FLAG "-np" CACHE STRING "Flag used by MPI to specify the number of processes for MPIEXEC")
+      ecbuild_debug("ecbuild_add_test(${_PAR_TARGET}): Running using ${MPIEXEC} on ${_PAR_MPI} MPI rank(s)")
+      set( _PAR_LABELS mpi ${_PAR_LABELS} )
+    elseif( _PAR_MPI GREATER 1 )
+      ecbuild_debug("ecbuild_add_test(${_PAR_TARGET}): ${_PAR_MPI} MPI ranks requested but MPIEXEC not available - disabling test")
       set( _PAR_ENABLED 0 )
-    elseif( (_PAR_MPI EQUAL 1) AND (NOT MPI_FOUND) )
-      ecbuild_debug("ecbuild_add_test(${_PAR_TARGET}): 1 MPI rank requested but MPI not available - disabling MPI")
-      set( _PAR_MPI 0 )
     else()
-      ecbuild_debug("ecbuild_add_test(${_PAR_TARGET}): Running using ${_PAR_MPI} MPI rank(s)")
+      ecbuild_debug("ecbuild_add_test(${_PAR_TARGET}): 1 MPI rank requested but MPIEXEC not available - running sequentially")
+      set( _PAR_MPI 0 )
     endif()
   endif()
 
   # Check for OMP
-  if( NOT DEFINED _PAR_OMP )
+  if( DEFINED _PAR_OMP )
+    set( _PAR_LABELS openmp ${_PAR_LABELS} )
+  else()
     set( _PAR_OMP 1 )
   endif()
   list( APPEND _PAR_ENVIRONMENT "OMP_NUM_THREADS=${_PAR_OMP}" )
@@ -181,11 +208,13 @@ macro( ecbuild_add_test )
   # command implies script
   if( DEFINED _PAR_COMMAND )
     set( _PAR_TYPE "SCRIPT" )
+    set( _PAR_LABELS script ${_PAR_LABELS} )
   endif()
 
   # default of TYPE
   if( NOT _PAR_TYPE AND DEFINED _PAR_TARGET )
     set( _PAR_TYPE "EXE" )
+    set( _PAR_LABELS executable ${_PAR_LABELS} )
     if( NOT _PAR_SOURCES )
       ecbuild_critical("The call to ecbuild_add_test() defines a TARGET without SOURCES.")
     endif()
@@ -194,6 +223,7 @@ macro( ecbuild_add_test )
   if( _PAR_TYPE MATCHES "PYTHON" )
     if( PYTHONINTERP_FOUND )
       set( _PAR_COMMAND ${PYTHON_EXECUTABLE} )
+      set( _PAR_LABELS python ${_PAR_LABELS} )
     else()
       ecbuild_warn( "Requested a python test but python interpreter not found - disabling test\nPYTHON_EXECUTABLE: [${PYTHON_EXECUTABLE}]" )
       set( _PAR_ENABLED 0 )
@@ -233,6 +263,7 @@ macro( ecbuild_add_test )
   if( _PAR_BOOST AND ENABLE_TESTS AND _${_PAR_TARGET}_condition )
 
     if( HAVE_BOOST_UNIT_TEST )
+      set( _PAR_LABELS boost ${_PAR_LABELS} )
       if( BOOST_UNIT_TEST_FRAMEWORK_HEADER_ONLY )
         include_directories( ${ECBUILD_BOOST_HEADER_DIRS} )
         include_directories( ${Boost_INCLUDE_DIRS}  ) # temporary until we ship Boost Unit Test with ecBuild
@@ -322,25 +353,14 @@ macro( ecbuild_add_test )
       # filter sources
       ecbuild_separate_sources( TARGET ${_PAR_TARGET} SOURCES ${_PAR_SOURCES} )
 
-      # add local flags
-      if( DEFINED _PAR_CFLAGS )
-        ecbuild_debug("ecbuild_add_test(${_PAR_TARGET}): use C flags ${_PAR_CFLAGS}")
-        set_source_files_properties( ${${_PAR_TARGET}_c_srcs}   PROPERTIES COMPILE_FLAGS "${_PAR_CFLAGS}" )
-      endif()
-      if( DEFINED _PAR_CXXFLAGS )
-        ecbuild_debug("ecbuild_add_test(${_PAR_TARGET}): use C++ flags ${_PAR_CFLAGS}")
-        set_source_files_properties( ${${_PAR_TARGET}_cxx_srcs} PROPERTIES COMPILE_FLAGS "${_PAR_CXXFLAGS}" )
-      endif()
-      if( DEFINED _PAR_FFLAGS )
-        ecbuild_debug("ecbuild_add_test(${_PAR_TARGET}): use Fortran flags ${_PAR_CFLAGS}")
-        set_source_files_properties( ${${_PAR_TARGET}_f_srcs}   PROPERTIES COMPILE_FLAGS "${_PAR_FFLAGS}" )
-      endif()
+      # Override compilation flags on a per source file basis
+      ecbuild_target_flags( ${_PAR_TARGET} "${_PAR_CFLAGS}" "${_PAR_CXXFLAGS}" "${_PAR_FFLAGS}" )
+
       if( DEFINED _PAR_GENERATED )
         ecbuild_debug("ecbuild_add_test(${_PAR_TARGET}): mark as generated ${_PAR_GENERATED}")
         set_source_files_properties( ${_PAR_GENERATED} PROPERTIES GENERATED 1 )
       endif()
 
-
       # modify definitions to compilation ( -D... )
       get_property( _target_defs TARGET ${_PAR_TARGET} PROPERTY COMPILE_DEFINITIONS )
 
@@ -405,7 +425,7 @@ macro( ecbuild_add_test )
 
     # Wrap with MPIEXEC
     if( _PAR_MPI )
-      
+
       set( MPIEXEC_TASKS ${MPIEXEC_NUMPROC_FLAG} ${_PAR_MPI} )
       if( DEFINED MPIEXEC_NUMTHREAD_FLAG )
         set( MPIEXEC_THREADS ${MPIEXEC_NUMTHREAD_FLAG} ${_PAR_OMP} )
@@ -442,6 +462,12 @@ macro( ecbuild_add_test )
 
       endif()
 
+      # Add lower case project name to custom test labels
+      set( _PAR_LABELS ${PROJECT_NAME_LOWCASE} ${_PAR_LABELS} )
+      list( REMOVE_DUPLICATES _PAR_LABELS )
+      ecbuild_debug("ecbuild_add_test(${_PAR_TARGET}): assign labels ${_PAR_LABELS}")
+      set_property( TEST ${_PAR_TARGET} APPEND PROPERTY LABELS "${_PAR_LABELS}" )
+
       if( DEFINED _PAR_ENVIRONMENT )
         set_property( TEST ${_PAR_TARGET} APPEND PROPERTY ENVIRONMENT "${_PAR_ENVIRONMENT}" )
       endif()
diff --git a/cmake/ecbuild_bundle.cmake b/cmake/ecbuild_bundle.cmake
index 83b0bba..aee900c 100644
--- a/cmake/ecbuild_bundle.cmake
+++ b/cmake/ecbuild_bundle.cmake
@@ -20,7 +20,9 @@ include(ecbuild_git)
 # =========================
 #
 # Initialise the ecBuild environment for a bundle. *Must* be called *before*
-# any call to ecbuild_bundle.
+# any call to ``ecbuild_bundle``. ::
+#
+#   ecbuild_bundle_initialize()
 #
 ##############################################################################
 
@@ -159,7 +161,9 @@ endmacro()
 # =======================
 #
 # Finalise the ecBuild environment for a bundle. *Must* be called *after* the
-# last call to ecbuild_bundle.
+# last call to ``ecbuild_bundle``. ::
+#
+#   ecbuild_bundle_finalize()
 #
 ##############################################################################
 
diff --git a/cmake/ecbuild_check_cxx11.cmake b/cmake/ecbuild_check_cxx11.cmake
index 1639a6a..9552389 100644
--- a/cmake/ecbuild_check_cxx11.cmake
+++ b/cmake/ecbuild_check_cxx11.cmake
@@ -41,97 +41,98 @@
 
 function( ecbuild_check_cxx11 )
 
-	# parse parameters
+  # parse parameters
 
-	set( options PRINT )
-	set( single_value_args )
-	set( multi_value_args   FEATURES REQUIRED )
+  set( options PRINT )
+  set( single_value_args )
+  set( multi_value_args   FEATURES REQUIRED )
 
-	cmake_parse_arguments( _p "${options}" "${single_value_args}" "${multi_value_args}"  ${_FIRST_ARG} ${ARGN} )
+  cmake_parse_arguments( _p "${options}" "${single_value_args}" "${multi_value_args}"  ${_FIRST_ARG} ${ARGN} )
 
-	if(_PAR_UNPARSED_ARGUMENTS)
-		ecbuild_critical("Unknown keywords given to ecbuild_check_cxx11(): \"${_PAR_UNPARSED_ARGUMENTS}\"")
-	endif()
+  if(_PAR_UNPARSED_ARGUMENTS)
+    ecbuild_critical("Unknown keywords given to ecbuild_check_cxx11(): \"${_PAR_UNPARSED_ARGUMENTS}\"")
+  endif()
 
-	include( ${ECBUILD_MACROS_DIR}/contrib/GreatCMakeCookOff/CheckCXX11Features.cmake )
+  include( ${ECBUILD_MACROS_DIR}/contrib/GreatCMakeCookOff/CheckCXX11Features.cmake )
 
-	cxx11_find_all_features( ALL_FEATURES ) # list all available features to check
+  cxx11_find_all_features( ALL_FEATURES ) # list all available features to check
 
-	# Save CXX flags
-	set( CXX_FLAGS_SNASHOT ${CMAKE_CXX_FLAGS} )
+  # Save CXX flags
+  set( CXX_FLAGS_SNASHOT ${CMAKE_CXX_FLAGS} )
 
-	# Add C++11 flags
-	include( ${ECBUILD_MACROS_DIR}/ecbuild_get_cxx11_flags.cmake )
-	ecbuild_get_cxx11_flags( CXX11_FLAGS )
-	set( CMAKE_CXX_FLAGS "${CXX11_FLAGS} ${CMAKE_CXX_FLAGS}" )
+  # Add C++11 flags
+  include( ${ECBUILD_MACROS_DIR}/ecbuild_get_cxx11_flags.cmake )
+  ecbuild_get_cxx11_flags( CXX11_FLAGS )
+  ecbuild_debug( "ecbuild_check_cxx11: detected C++11 flag as ${CXX11_FLAGS}" )
+  set( CMAKE_CXX_FLAGS "${CXX11_FLAGS} ${CMAKE_CXX_FLAGS}" )
 
-	if( NOT _p_FEATURES AND NOT _p_REQUIRED ) # no input, then search for all features
+  if( NOT _p_FEATURES AND NOT _p_REQUIRED ) # no input, then search for all features
 
-		cxx11_feature_check()
+    cxx11_feature_check()
 
-	else()
+  else()
 
-		foreach( _f ${_p_FEATURES} )
-			cxx11_feature_check( ${_f} )
-		endforeach()
+    foreach( _f ${_p_FEATURES} )
+      cxx11_feature_check( ${_f} )
+    endforeach()
 
-		foreach( _f ${_p_REQUIRED} )
-			cxx11_feature_check( REQUIRED ${_f} )
-		endforeach()
+    foreach( _f ${_p_REQUIRED} )
+      cxx11_feature_check( REQUIRED ${_f} )
+    endforeach()
 
-	endif()
+  endif()
 
-	# Restore CXX flags
-	set( CMAKE_CXX_FLAGS ${CXX_FLAGS_SNAPSHOT} )
+  # Restore CXX flags
+  set( CMAKE_CXX_FLAGS ${CXX_FLAGS_SNAPSHOT} )
 
-	if( _p_FEATURES OR _p_REQUIRED )
-		set( CXX11_CHECKED_FEATURES ${_p_FEATURES} ${_p_REQUIRED} )
-	else()
-		set( CXX11_CHECKED_FEATURES ${ALL_FEATURES} )
-	endif()
+  if( _p_FEATURES OR _p_REQUIRED )
+    set( CXX11_CHECKED_FEATURES ${_p_FEATURES} ${_p_REQUIRED} )
+  else()
+    set( CXX11_CHECKED_FEATURES ${ALL_FEATURES} )
+  endif()
 
-	foreach( f ${CXX11_CHECKED_FEATURES} )
-		string( TOUPPER ${f} FEAT )
-		if( HAS_CXX11_${FEAT} )
-		   list( APPEND CXX11_SUPPORTED_FEATURES ${f} )
-		else()
-		   list( APPEND CXX11_NOT_SUPPORTED_FEATURES ${f} )
-		endif()
-	endforeach()
+  foreach( f ${CXX11_CHECKED_FEATURES} )
+    string( TOUPPER ${f} FEAT )
+    if( HAS_CXX11_${FEAT} )
+       list( APPEND CXX11_SUPPORTED_FEATURES ${f} )
+    else()
+       list( APPEND CXX11_NOT_SUPPORTED_FEATURES ${f} )
+    endif()
+  endforeach()
 
   if( CXX11_CHECKED_FEATURES )
     list( SORT CXX11_CHECKED_FEATURES )
-	endif()
-	if( CXX11_SUPPORTED_FEATURES )
-		list( SORT CXX11_SUPPORTED_FEATURES )
-	endif()
-	if( CXX11_NOT_SUPPORTED_FEATURES )
-		list( SORT CXX11_NOT_SUPPORTED_FEATURES )
-	endif()
-
-	set( CXX11_CHECKED_FEATURES       ${CXX11_CHECKED_FEATURES}       PARENT_SCOPE )
-	set( CXX11_SUPPORTED_FEATURES     ${CXX11_SUPPORTED_FEATURES}     PARENT_SCOPE )
-	set( CXX11_NOT_SUPPORTED_FEATURES ${CXX11_NOT_SUPPORTED_FEATURES} PARENT_SCOPE )
-
-	if( _p_PRINT )
-		if( CXX11_CHECKED_FEATURES )
-			join( CXX11_CHECKED_FEATURES " " CXX11_CHECKED_FEATURES_STR )
-			ecbuild_info( "Checked C++11 features: ${CXX11_CHECKED_FEATURES_STR}" )
-		else()
-			ecbuild_info( "Checked no C++11 features" )
-		endif()
-		if( CXX11_SUPPORTED_FEATURES )
-			join( CXX11_SUPPORTED_FEATURES " " CXX11_SUPPORTED_FEATURES_STR )
-			ecbuild_info( "Found C++11 features: ${CXX11_SUPPORTED_FEATURES_STR}" )
-		else()
-			ecbuild_info( "Found no C++11 features" )
-		endif()
-		if( CXX11_NOT_SUPPORTED_FEATURES )
-			join( CXX11_NOT_SUPPORTED_FEATURES " " CXX11_NOT_SUPPORTED_FEATURES_STR )
-			ecbuild_info( "Not found C++11 features: ${CXX11_NOT_SUPPORTED_FEATURES_STR}" )
-		else()
-			ecbuild_info( "Found all checked C++11 features" )
-		endif()
-	endif()
+  endif()
+  if( CXX11_SUPPORTED_FEATURES )
+    list( SORT CXX11_SUPPORTED_FEATURES )
+  endif()
+  if( CXX11_NOT_SUPPORTED_FEATURES )
+    list( SORT CXX11_NOT_SUPPORTED_FEATURES )
+  endif()
+
+  set( CXX11_CHECKED_FEATURES       ${CXX11_CHECKED_FEATURES}       PARENT_SCOPE )
+  set( CXX11_SUPPORTED_FEATURES     ${CXX11_SUPPORTED_FEATURES}     PARENT_SCOPE )
+  set( CXX11_NOT_SUPPORTED_FEATURES ${CXX11_NOT_SUPPORTED_FEATURES} PARENT_SCOPE )
+
+  if( _p_PRINT )
+    if( CXX11_CHECKED_FEATURES )
+      join( CXX11_CHECKED_FEATURES " " CXX11_CHECKED_FEATURES_STR )
+      ecbuild_info( "Checked C++11 features: ${CXX11_CHECKED_FEATURES_STR}" )
+    else()
+      ecbuild_info( "Checked no C++11 features" )
+    endif()
+    if( CXX11_SUPPORTED_FEATURES )
+      join( CXX11_SUPPORTED_FEATURES " " CXX11_SUPPORTED_FEATURES_STR )
+      ecbuild_info( "Found C++11 features: ${CXX11_SUPPORTED_FEATURES_STR}" )
+    else()
+      ecbuild_info( "Found no C++11 features" )
+    endif()
+    if( CXX11_NOT_SUPPORTED_FEATURES )
+      join( CXX11_NOT_SUPPORTED_FEATURES " " CXX11_NOT_SUPPORTED_FEATURES_STR )
+      ecbuild_info( "Not found C++11 features: ${CXX11_NOT_SUPPORTED_FEATURES_STR}" )
+    else()
+      ecbuild_info( "Found all checked C++11 features" )
+    endif()
+  endif()
 
 endfunction( ecbuild_check_cxx11 )
diff --git a/cmake/ecbuild_compiler_flags.cmake b/cmake/ecbuild_compiler_flags.cmake
index b97eb2c..0e3fe1e 100644
--- a/cmake/ecbuild_compiler_flags.cmake
+++ b/cmake/ecbuild_compiler_flags.cmake
@@ -12,7 +12,7 @@
 # ecbuild_compiler_flags
 # ======================
 #
-# Set default compiler flags for a given language. ::
+# Set compiler specific default compilation flags for a given language. ::
 #
 #   ecbuild_compiler_flags( <lang> )
 #
@@ -35,53 +35,171 @@
 
 macro( ecbuild_compiler_flags _lang )
 
+  # Set compiler and language specific default flags - OVERWRITES variables in CMake cache
   if( CMAKE_${_lang}_COMPILER_LOADED )
-
-    ecbuild_debug( "try include ${ECBUILD_MACROS_DIR}/compiler_flags/${CMAKE_${_lang}_COMPILER_ID}_${_lang}.cmake ")
-
+    ecbuild_debug( "ecbuild_compiler_flags(${_lang}): try include ${ECBUILD_MACROS_DIR}/compiler_flags/${CMAKE_${_lang}_COMPILER_ID}_${_lang}.cmake ")
     include( ${ECBUILD_MACROS_DIR}/compiler_flags/${CMAKE_${_lang}_COMPILER_ID}_${_lang}.cmake OPTIONAL )
-
-    ecbuild_debug_var( CMAKE_${_lang}_FLAGS )
-
-    foreach( _btype NONE DEBUG BIT PRODUCTION RELEASE RELWITHDEBINFO )
-      ecbuild_debug_var( CMAKE_${_lang}_FLAGS_${_btype} )
-    endforeach()
-
   endif()
 
+  # Apply user or toolchain specified compilation flag overrides (NOT written to cache)
+
   foreach( _btype NONE DEBUG BIT PRODUCTION RELEASE RELWITHDEBINFO )
     if( DEFINED ECBUILD_${_lang}_FLAGS_${_btype} )
+      ecbuild_debug( "ecbuild_compiler_flags(${_lang}): overriding CMAKE_${_lang}_FLAGS_${_btype} with ${ECBUILD_${_lang}_FLAGS_${_btype}}")
       set( CMAKE_${_lang}_FLAGS_${_btype} ${ECBUILD_${_lang}_FLAGS_${_btype}} )
     endif()
     mark_as_advanced( CMAKE_${_lang}_FLAGS_${_btype} )
   endforeach()
 
   if( DEFINED ECBUILD_${_lang}_FLAGS )
+    ecbuild_debug( "ecbuild_compiler_flags(${_lang}): overriding CMAKE_${_lang}_FLAGS with ${ECBUILD_${_lang}_FLAGS}")
     set( CMAKE_${_lang}_FLAGS "${ECBUILD_${_lang}_FLAGS}" )
   endif()
 
   mark_as_advanced( CMAKE_${_lang}_FLAGS )
 
   if( DEFINED ECBUILD_${_lang}_LINK_FLAGS )
+    ecbuild_debug( "ecbuild_compiler_flags(${_lang}): overriding CMAKE_${_lang}_LINK_FLAGS with ${ECBUILD_${_lang}_LINK_FLAGS}")
     set( CMAKE_${_lang}_LINK_FLAGS "${ECBUILD_${_lang}_LINK_FLAGS}" )
   endif()
 
   mark_as_advanced( CMAKE_${_lang}_LINK_FLAGS )
 
+  ecbuild_debug_var( CMAKE_${_lang}_FLAGS )
+  foreach( _btype NONE DEBUG BIT PRODUCTION RELEASE RELWITHDEBINFO )
+    ecbuild_debug_var( CMAKE_${_lang}_FLAGS_${_btype} )
+  endforeach()
+
 endmacro()
 
-#-----------------------------------------------------------------------------------------------------------------------
+##############################################################################
+#.rst:
+#
+# Using custom compilation flags
+# ==============================
+#
+# If compilation flags need to be controlled on a per source file basis,
+# ecBuild supports defining custom rules in a CMake or JSON file.
+#
+# When using this approach, *default compilation flags are NOT loaded*!
+#
+# Overriding compilation flags on a per source file basis using CMake rules
+# -------------------------------------------------------------------------
+#
+# Compiler flags can be overridden on a per source file basis by setting the
+# CMake variable ``ECBUILD_COMPILE_FLAGS`` to the *full path* of a CMake file
+# defining the override rules. If set, ``<PNAME>_ECBUILD_COMPILE_FLAGS``
+# takes precendence and ``ECBUILD_COMPILE_FLAGS`` is ignored, allowing for
+# rules that only apply to a subproject (e.g. in a bundle).
+#
+# Flags can be overridden in 3 different ways:
+#
+# 1.  By defining project specific flags for a language and (optionally)
+#     build type e.g. ::
+#
+#       set(<PNAME>_Fortran_FLAGS "...") # common flags for all build types
+#       set(<PNAME>_Fortran_FLAGS_DEBUG "...") # only for DEBUG build type
+#
+# 2.  By defining source file specific flags which are *combined* with the
+#     project and target specific flags ::
+#
+#       set_source_files_properties(<source>
+#         PROPERTIES COMPILE_FLAGS "..."  # common flags for all build types
+#                    COMPILE_FLAGS_DEBUG "...") # only for DEBUG build type
+#
+# 3.  By defining source file specific flags which *override* the project and
+#     target specific flags ::
+#
+#       set_source_files_properties(<source>
+#         PROPERTIES OVERRIDE_COMPILE_FLAGS "..."
+#                    OVERRIDE_COMPILE_FLAGS_DEBUG "...")
+#
+# See ``examples/override-compile-flags`` in the ecBuild source tree for a
+# complete example using this technique.
+#
+# Overriding compilation flags on a per source file basis using JSON rules
+# ------------------------------------------------------------------------
+#
+# Compiler flags can be overridden on a per source file basis by setting the
+# CMake variable ``ECBUILD_SOURCE_FLAGS`` to the *full path* of a JSON file
+# defining the override rules. If set, ``<PNAME>_ECBUILD_SOURCE_FLAGS``
+# takes precendence and ``ECBUILD_SOURCE_FLAGS`` is ignored, allowing for
+# rules that only apply to a subproject (e.g. in a bundle).
+#
+# The JSON file lists shell glob patterns and the rule to apply to each source
+# file matching the pattern, defined as an array ``[op, flag1, ...]``
+# containing an operator followed by one or more flags. Valid operators are:
+#
+# :+: Add the flags to the default compilation flags for matching files
+# :=: Set the flags for matching files, disregarding default compilation flags
+# :/: Remove the flags from the default compilation flags for matching files
+#
+# Rules can be nested to e.g. only apply to a subdirectory by setting the rule
+# to a dictionary, which will only apply to source files matching its pattern.
+#
+# An example JSON file demonstrating different rule types is given below: ::
+#
+#   {
+#     "*"       : [ "+", "-g0" ],
+#     "*.cxx"   : [ "+", "-cxx11" ],
+#     "*.f90"   : [ "+", "-pipe" ],
+#     "foo.c"   : [ "+", "-O0" ],
+#     "foo.cc"  : [ "+", "-O2", "-pipe" ],
+#     "bar/*": {
+#       "*.f90" : [ "=", "-O1" ]
+#     },
+#     "baz/*": {
+#       "*.f90" : [ "/", "-pipe" ],
+#       "*.f90" : [ "/", "-O2" ],
+#       "*.f90" : [ "+", "-O3" ]
+#     }
+#   }
+#
+# See ``examples/override-compile-flags`` in the ecBuild source tree for a
+# complete example using this technique.
+#
+##############################################################################
 
-### OVERRIDE Compiler FLAGS (we override because CMake forcely defines them) -- see ecbuild_compiler_flags() macro
+# Custom (project specific) compilation flags enabled?
+foreach( _flags COMPILE SOURCE )
+  if( ${PROJECT_NAME_CAPS}_ECBUILD_${_flags}_FLAGS )
+    if ( ECBUILD_${_flags}_FLAGS )
+      ecbuild_debug( "Override ECBUILD_${_flags}_FLAGS (${ECBUILD_${_flags}_FLAGS}) with ${PROJECT_NAME} specific flags (${${PROJECT_NAME_CAPS}_ECBUILD_${_flags}_FLAGS})" )
+    else()
+      ecbuild_debug( "Use ${PROJECT_NAME} specific ECBUILD_${_flags}_FLAGS (${${PROJECT_NAME_CAPS}_ECBUILD_${_flags}_FLAGS})" )
+    endif()
+    set( ECBUILD_${_flags}_FLAGS ${${PROJECT_NAME_CAPS}_ECBUILD_${_flags}_FLAGS} )
+  endif()
+  # Ensure ECBUILD_${_flags}_FLAGS is a valid file path
+  if( DEFINED ECBUILD_${_flags}_FLAGS AND NOT EXISTS ${ECBUILD_${_flags}_FLAGS} )
+    ecbuild_warn( "ECBUILD_${_flags}_FLAGS points to non-existent file ${ECBUILD_${_flags}_FLAGS} and will be ignored" )
+    unset( ECBUILD_${_flags}_FLAGS )
+    unset( ECBUILD_${_flags}_FLAGS CACHE )
+  endif()
+endforeach()
+if( ECBUILD_COMPILE_FLAGS )
+  include( "${ECBUILD_COMPILE_FLAGS}" )
+endif()
 
 foreach( _lang C CXX Fortran )
   if( CMAKE_${_lang}_COMPILER_LOADED )
-    ecbuild_compiler_flags( ${_lang} )
+
+    # Clear default compilation flags potentially inherited from parent scope
+    # when using custom compilation flags
+    if( ECBUILD_SOURCE_FLAGS OR ECBUILD_COMPILE_FLAGS )
+      set(CMAKE_${_lang}_FLAGS "")
+      foreach(_btype ALL RELEASE RELWITHDEBINFO PRODUCTION BIT DEBUG)
+        set(CMAKE_${_lang}_FLAGS_${_btype} "")
+      endforeach()
+    # Load default compilation flags only if custom compilation flags not enabled
+    else()
+      ecbuild_compiler_flags( ${_lang} )
+    endif()
+
   endif()
 endforeach()
 
-### OVERRIDE Linker FLAGS per object type (we override because CMake forcely defines them)
-
+# Apply user or toolchain specified linker flag overrides per object type (NOT written to cache)
 foreach( _btype NONE DEBUG BIT PRODUCTION RELEASE RELWITHDEBINFO )
 
   foreach( _obj EXE SHARED MODULE )
@@ -91,7 +209,3 @@ foreach( _btype NONE DEBUG BIT PRODUCTION RELEASE RELWITHDEBINFO )
   endforeach()
 
 endforeach()
-
-#-----------------------------------------------------------------------------------------------------------------------
-
-mark_as_advanced( CMAKE_C_FLAGS_BIT )
diff --git a/cmake/ecbuild_declare_project.cmake b/cmake/ecbuild_declare_project.cmake
index c5ef5a0..c95e8e3 100644
--- a/cmake/ecbuild_declare_project.cmake
+++ b/cmake/ecbuild_declare_project.cmake
@@ -33,6 +33,9 @@
 # :INSTALL_DATA_DIR:       relative install directory for data
 # :INSTALL_CMAKE_DIR:      relative install directory for CMake files
 #
+# Customising install locations
+# -----------------------------
+#
 # The relative installation directories of components can be customised by
 # setting the following CMake variables on the command line or in cache:
 #
@@ -51,40 +54,6 @@
 # ``CMAKE_INSTALL_PREFIX``. Using absolute paths makes the build
 # non-relocatable and may break the generation of relocatable binary packages.
 #
-# Compiler flags can be overridden on a per source file basis by providing a
-# JSON file defining the override rules and setting ``ECBUILD_SOURCE_FLAGS``
-# to the *full path* of this file. If set, ``<PNAME>_ECBUILD_SOURCE_FLAGS``
-# takes precendence and ``ECBUILD_SOURCE_FLAGS`` is ignored.
-#
-# The JSON file lists shell glob patterns and the rule to apply to each source
-# file matching the pattern, defined as an array ``[op, flag1, ...]``
-# containing an operator followed by one or more flags. Valid operators are:
-#
-# :+: Add the flags to the default compilation flags for matching files
-# :=: Set the flags for matching files, disregarding default compilation flags
-# :/: Remove the flags from the default compilation flags for matching files
-#
-# Rules can be nested to e.g. only apply to a subdirectory by setting the rule
-# to a dictionary, which will only apply to source files matching it pattern.
-#
-# An example JSON file demonstrating different rule types is given below: ::
-#
-#   {
-#     "*"       : [ "+", "-g0" ],
-#     "*.cxx"   : [ "+", "-cxx11" ],
-#     "*.f90"   : [ "+", "-pipe" ],
-#     "foo.c"   : [ "+", "-O0" ],
-#     "foo.cc"  : [ "+", "-O2", "-pipe" ],
-#     "bar/*": {
-#       "*.f90" : [ "=", "-O1" ]
-#     },
-#     "baz/*": {
-#       "*.f90" : [ "/", "-pipe" ],
-#       "*.f90" : [ "/", "-O2" ],
-#       "*.f90" : [ "+", "-O3" ]
-#     }
-#   }
-#
 ##############################################################################
 
 macro( ecbuild_declare_project )
@@ -141,22 +110,6 @@ macro( ecbuild_declare_project )
   #    ecbuild_debug_var( ${PNAME}_MINOR_VERSION )
   #    ecbuild_debug_var( ${PNAME}_PATCH_VERSION )
 
-  # Override source flags with project specific flags
-  if( ${PNAME}_ECBUILD_SOURCE_FLAGS )
-    if ( ECBUILD_SOURCE_FLAGS )
-      ecbuild_debug( "Override ECBUILD_SOURCE_FLAGS (${ECBUILD_SOURCE_FLAGS}) with ${PROJECT_NAME} specific flags (${${PNAME}_ECBUILD_SOURCE_FLAGS})" )
-    else()
-      ecbuild_debug( "Use ${PROJECT_NAME} specific ECBUILD_SOURCE_FLAGS (${${PNAME}_ECBUILD_SOURCE_FLAGS})" )
-    endif()
-    set( ECBUILD_SOURCE_FLAGS ${${PNAME}_ECBUILD_SOURCE_FLAGS} )
-  endif()
-  # Ensure ECBUILD_SOURCE_FLAGS is a valid file path
-  if( DEFINED ECBUILD_SOURCE_FLAGS AND NOT EXISTS ${ECBUILD_SOURCE_FLAGS} )
-    ecbuild_warn( "ECBUILD_SOURCE_FLAGS points to non-existent file ${ECBUILD_SOURCE_FLAGS} and will be ignored" )
-    unset( ECBUILD_SOURCE_FLAGS )
-    unset( ECBUILD_SOURCE_FLAGS CACHE )
-  endif()
-
   # install dirs for this project
 
   # Use defaults unless values are already present in cache
diff --git a/cmake/ecbuild_define_paths.cmake b/cmake/ecbuild_define_paths.cmake
index 856903d..6584b26 100644
--- a/cmake/ecbuild_define_paths.cmake
+++ b/cmake/ecbuild_define_paths.cmake
@@ -1,8 +1,8 @@
 # (C) Copyright 1996-2016 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 
+# 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.
 
@@ -15,17 +15,22 @@ file( MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/lib )
 
 # setup library building rpaths (both in build dir and then when installed)
 
-set( CMAKE_INSTALL_RPATH_USE_LINK_PATH   TRUE  ) # add the automatic parts to RPATH which point to dirs outside build tree
+# add the automatic parts to RPATH which point to dirs outside build tree
+set( CMAKE_INSTALL_RPATH_USE_LINK_PATH   TRUE  )
 
 # use RPATHs for the build tree
 set( CMAKE_SKIP_BUILD_RPATH              FALSE  )
 
-if( ENABLE_RELATIVE_RPATHS )
-    # when building, use the install RPATH immedietly
-	set( CMAKE_BUILD_WITH_INSTALL_RPATH      TRUE  )
+# If INSTALL_LIB_DIR is set to anything other than lib, the relative install
+# RPATH is wrong in the build tree
+if( ENABLE_RELATIVE_RPATHS AND (NOT INSTALL_LIB_DIR OR INSTALL_LIB_DIR STREQUAL "lib") )
+  # when building, use the install RPATH immediately (we don't want to relink)
+  set( CMAKE_BUILD_WITH_INSTALL_RPATH      TRUE  )
+  ecbuild_debug( "Building with install RPATH" )
 else()
-    # when building, don't use the install RPATH yet, but later on when installing
-    set( CMAKE_BUILD_WITH_INSTALL_RPATH      FALSE  ) 
+  # when building, don't use the install RPATH yet, but later on when installing
+  set( CMAKE_BUILD_WITH_INSTALL_RPATH      FALSE  )
+  ecbuild_debug( "Not building with install RPATH, need to relink when installing" )
 endif()
 
 # Always include srcdir and builddir in include path
diff --git a/cmake/ecbuild_find_omp.cmake b/cmake/ecbuild_find_omp.cmake
index 47c05c2..914da24 100644
--- a/cmake/ecbuild_find_omp.cmake
+++ b/cmake/ecbuild_find_omp.cmake
@@ -30,7 +30,7 @@ macro( lookup_omp_flags )
   #ifdef _OPENMP
     #pragma omp parallel
     {
-      int id = omp_get_thread_num();
+      (void)omp_get_thread_num();
     }
     return 0;
   #else
@@ -53,7 +53,7 @@ macro( lookup_omp_flags )
     #pragma omp parallel
     {
       // This pragma should have passed compilation
-      int id = 0;
+      (void)0;
     }
     return 0;
   #endif
diff --git a/cmake/ecbuild_generate_fortran_interfaces.cmake b/cmake/ecbuild_generate_fortran_interfaces.cmake
index d586248..93c7414 100644
--- a/cmake/ecbuild_generate_fortran_interfaces.cmake
+++ b/cmake/ecbuild_generate_fortran_interfaces.cmake
@@ -12,7 +12,7 @@
 # ecbuild_generate_fortran_interfaces
 # ===================================
 #
-# Generates interfaces form the Fortran source files. ::
+# Generates interfaces from the Fortran source files. ::
 #
 #   ecbuild_generate_fortran_interfaces()
 #
diff --git a/cmake/ecbuild_get_test_data.cmake b/cmake/ecbuild_get_test_data.cmake
index d908399..42185f1 100644
--- a/cmake/ecbuild_get_test_data.cmake
+++ b/cmake/ecbuild_get_test_data.cmake
@@ -241,6 +241,7 @@ endfunction(ecbuild_get_test_data)
 #   ecbuild_get_test_multidata( NAMES <name1> [ <name2> ... ]
 #                               TARGET <target>
 #                               [ DIRNAME <dir> ]
+#                               [ LABELS <label1> [<label2> ...] ]
 #                               [ EXTRACT ]
 #                               [ NOCHECK ] )
 #
@@ -258,6 +259,14 @@ endfunction(ecbuild_get_test_data)
 # DIRNAME : optional, defaults to <project>/<relative path to current dir>
 #   directory in which the test data resides
 #
+# LABELS : optional
+#   list of labels to assign to the test
+#
+#   Lower case project name and ``download_data`` are always added as labels.
+#
+#   This allows selecting tests to run via ``ctest -L <regex>`` or tests
+#   to exclude via ``ctest -LE <regex>``.
+#
 # EXTRACT : optional
 #   extract downloaded files (supported archives: tar, zip, tar.gz, tar.bz2)
 #
@@ -303,7 +312,7 @@ function( ecbuild_get_test_multidata )
 
     set( options EXTRACT NOCHECK )
     set( single_value_args TARGET DIRNAME )
-    set( multi_value_args  NAMES )
+    set( multi_value_args  NAMES LABELS )
 
     cmake_parse_arguments( _p "${options}" "${single_value_args}" "${multi_value_args}"  ${_FIRST_ARG} ${ARGN} )
 
@@ -386,6 +395,9 @@ endfunction()\n\n" )
 
     if( ENABLE_TESTS )
       add_test(  NAME ${_p_TARGET} COMMAND ${CMAKE_COMMAND} -P ${_script} )
+      set( _p_LABELS ${PROJECT_NAME_LOWCASE} download_data ${_p_LABELS} )
+      list( REMOVE_DUPLICATES _p_LABELS )
+      set_property( TEST ${_p_TARGET} APPEND PROPERTY LABELS "${_p_LABELS}" )
     endif()
 
 endfunction(ecbuild_get_test_multidata)
diff --git a/cmake/ecbuild_log.cmake b/cmake/ecbuild_log.cmake
index f982d07..32a1398 100644
--- a/cmake/ecbuild_log.cmake
+++ b/cmake/ecbuild_log.cmake
@@ -62,7 +62,7 @@
 #
 ##############################################################################
 
-# Define colour escape sequences (https://stackoverflow.com/a/19578320/396967)
+# Define colour escape sequences (not available on Windows)
 if(NOT (WIN32 OR ECBUILD_NO_COLOUR))
   string(ASCII 27 Esc)
   set(ColourReset "${Esc}[m")
diff --git a/cmake/ecbuild_pkgconfig.cmake b/cmake/ecbuild_pkgconfig.cmake
index 6f62977..d839a86 100644
--- a/cmake/ecbuild_pkgconfig.cmake
+++ b/cmake/ecbuild_pkgconfig.cmake
@@ -275,7 +275,7 @@ endfunction(ecbuild_pkgconfig_include)
 # ---------------
 #
 # The following CMake variables are used as default values for some of the
-# options listed above, where ``PNAME`` is the project name in upper case: ::
+# options listed above, where ``PNAME`` is the project name in upper case:
 #
 # :<PNAME>_LIBRARIES:    list of libraries to export
 # :<PNAME>_DESCRIPTION:  package description
diff --git a/cmake/ecbuild_print_summary.cmake b/cmake/ecbuild_print_summary.cmake
index f9bac6d..6fc70d0 100644
--- a/cmake/ecbuild_print_summary.cmake
+++ b/cmake/ecbuild_print_summary.cmake
@@ -71,7 +71,8 @@ macro( ecbuild_print_summary )
 
     foreach( lang ${langs} )
       ecbuild_info( "${lang} -- ${CMAKE_${lang}_COMPILER_ID} ${CMAKE_${lang}_COMPILER_VERSION}"  )
-      ecbuild_info( "    compiler   : ${CMAKE_${lang}_COMPILER} ${CMAKE_${lang}_FLAGS} ${CMAKE_${lang}_FLAGS_${CMAKE_BUILD_TYPE_CAPS}}" )
+      ecbuild_info( "    compiler   : ${CMAKE_${lang}_COMPILER}" )
+      ecbuild_info( "    flags      : ${CMAKE_${lang}_FLAGS} ${CMAKE_${lang}_FLAGS_${CMAKE_BUILD_TYPE_CAPS}} ${${PNAME}_${lang}_FLAGS} ${${PNAME}_${lang}_FLAGS_${CMAKE_BUILD_TYPE_CAPS}}" )
       ecbuild_info( "    link flags : ${CMAKE_${lang}_LINK_FLAGS}" )
     endforeach()
 
diff --git a/cmake/ecbuild_remove_fortran_flags.cmake b/cmake/ecbuild_remove_fortran_flags.cmake
index 74c8832..3a80316 100644
--- a/cmake/ecbuild_remove_fortran_flags.cmake
+++ b/cmake/ecbuild_remove_fortran_flags.cmake
@@ -10,9 +10,9 @@
 #.rst:
 #
 # ecbuild_remove_fortran_flags
-# =========================
+# ============================
 #
-# Remove Fortran compiler flags from CMAKE_Fortran_FLAGS. ::
+# Remove Fortran compiler flags from ``CMAKE_Fortran_FLAGS``. ::
 #
 #   ecbuild_remove_fortran_flags( <flag1> [ <flag2> ... ] [ BUILD <build> ] )
 #
@@ -58,4 +58,3 @@ macro( ecbuild_remove_fortran_flags m_flags )
   unset( _flags )
 
 endmacro()
-
diff --git a/cmake/ecbuild_separate_sources.cmake b/cmake/ecbuild_separate_sources.cmake
index dfc74f1..00722ae 100644
--- a/cmake/ecbuild_separate_sources.cmake
+++ b/cmake/ecbuild_separate_sources.cmake
@@ -32,11 +32,11 @@
 # If any file of the following group of extensions is present in the list of
 # sources, the corresponding CMake variable is set:
 #
-# :<target>_h_srcs:   list of sources with extension .h, .hxx, .hh, .hpp, .H
-# :<target>_c_srcs:   list of sources with extension .c
-# :<target>_cxx_srcs: list of sources with extension .cc, .cxx, .cpp, .C
-# :<target>_f_srcs:   list of sources with extension .f, .F, .for, f77, .f90,
-#                                                    .f95, .F77, .F90, .F95
+# :<target>_h_srcs:       source files with extension .h, .hxx, .hh, .hpp, .H
+# :<target>_c_srcs:       source files with extension .c
+# :<target>_cxx_srcs:     source files with extension .cc, .cxx, .cpp, .C
+# :<target>_fortran_srcs: source files with extension .f, .F, .for, f77, .f90,
+#                                                     .f95, .F77, .F90, .F95
 #
 ##############################################################################
 
@@ -80,14 +80,14 @@ macro( ecbuild_separate_sources )
 
 	foreach( src ${_PAR_SOURCES} )
 		if(${src} MATCHES "(\\.f$|\\.F$|\\.for$|\\.f77$|\\.f90$|\\.f95$|\\.f03$|\\.f08$|\\.F77$|\\.F90$|\\.F95$|\\.F03$|\\.F08$)")
-			list( APPEND ${_PAR_TARGET}_f_srcs ${src} )
+			list( APPEND ${_PAR_TARGET}_fortran_srcs ${src} )
 		endif()
 	endforeach()
-	set_source_files_properties( ${${_PAR_TARGET}_f_srcs} PROPERTIES LANGUAGE Fortran )
+	set_source_files_properties( ${${_PAR_TARGET}_fortran_srcs} PROPERTIES LANGUAGE Fortran )
 
 #    ecbuild_debug_var( ${_PAR_TARGET}_h_srcs )
 #    ecbuild_debug_var( ${_PAR_TARGET}_c_srcs )
 #    ecbuild_debug_var( ${_PAR_TARGET}_cxx_srcs )
-#    ecbuild_debug_var( ${_PAR_TARGET}_f_srcs )
+#    ecbuild_debug_var( ${_PAR_TARGET}_fortran_srcs )
 
 endmacro( ecbuild_separate_sources )
diff --git a/cmake/ecbuild_system.cmake b/cmake/ecbuild_system.cmake
index 8e7eda8..f02113e 100644
--- a/cmake/ecbuild_system.cmake
+++ b/cmake/ecbuild_system.cmake
@@ -212,6 +212,7 @@ if( PROJECT_NAME STREQUAL CMAKE_PROJECT_NAME )
     include( ecbuild_git )
     include( ecbuild_enable_fortran )
     include( ecbuild_source_flags )
+    include( ecbuild_target_flags )
     include( ecbuild_bundle )
     include( ecbuild_pkgconfig )
     include( ecbuild_cache )
diff --git a/cmake/ecbuild_target_flags.cmake b/cmake/ecbuild_target_flags.cmake
new file mode 100644
index 0000000..4c589af
--- /dev/null
+++ b/cmake/ecbuild_target_flags.cmake
@@ -0,0 +1,91 @@
+# (C) Copyright 1996-2016 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.
+
+##############################################################################
+#.rst:
+#
+# ecbuild_target_flags
+# ====================
+#
+# Override compiler flags for a given target. ::
+#
+#   ecbuild_target_flags( <target> <c_flags> <cxx_flags> <fortran_flags> )
+#
+# Required arguments:
+#
+# :target:        Target name
+# :c_flags:       Target specific C flags (can be empty)
+# :cxx_flags:     Target specific CXX flags (can be empty)
+# :fortran_flags: Target specific Fortran flags (can be empty)
+#
+# There are 3 cases, only the first applicable case takes effect:
+#
+# 1.  Use custom rules from user specified ``ECBUILD_COMPILE_FLAGS`` file and
+#     append target specific flags.
+#
+# 2.  Use JSON rules from user specified ``ECBUILD_SOURCE_FLAGS`` file and
+#     append target specific flags.
+#
+# 3.  Only the target specific flags are applied to all matching source files.
+#
+##############################################################################
+
+function( ecbuild_target_flags target c_flags cxx_flags fortran_flags )
+
+  get_property( languages GLOBAL PROPERTY ENABLED_LANGUAGES )
+
+  foreach( lang ${languages} )
+
+    string( TOLOWER ${lang} l )
+
+    if( ${target}_${l}_srcs )
+
+      # 1) Override compile flags from user specified CMake file
+      if( ECBUILD_COMPILE_FLAGS )
+
+        # Project specific flags for current language and optionally build type
+        set( pflags "${${PNAME}_${lang}_FLAGS} ${${PNAME}_${lang}_FLAGS_${CMAKE_BUILD_TYPE_CAPS}}" )
+
+        foreach( src ${${target}_${l}_srcs} )
+          get_property( oflags SOURCE ${src} PROPERTY OVERRIDE_COMPILE_FLAGS )
+          get_property( oflags_btype SOURCE ${src} PROPERTY OVERRIDE_COMPILE_FLAGS_${CMAKE_BUILD_TYPE_CAPS} )
+          # Override compile flags for source file?
+          if( oflags OR oflags_btype )
+            set_source_files_properties( ${src} PROPERTIES COMPILE_FLAGS "${oflags} ${oflags_btype}" )
+            ecbuild_debug( "ecbuild_target_flags(${target}): overriding flags for ${src} with '${oflags} ${oflags_btype}'" )
+          # Otherwise append source file specific flags to project specific and target specific flags
+          else()
+            get_property( flags SOURCE ${src} PROPERTY COMPILE_FLAGS )
+            get_property( flags_btype SOURCE ${src} PROPERTY COMPILE_FLAGS_${CMAKE_BUILD_TYPE_CAPS} )
+            set_source_files_properties( ${src} PROPERTIES COMPILE_FLAGS "${pflags} ${${l}_flags} ${flags} ${flags_btype}" )
+            ecbuild_debug( "ecbuild_target_flags(${target}): setting flags for ${src} to '${pflags} ${${l}_flags} ${flags} ${flags_btype}'" )
+          endif()
+        endforeach()
+
+      # 2) Override compile flags from user specified JSON file
+      elseif( ECBUILD_SOURCE_FLAGS )
+        ecbuild_source_flags( ${target}_${lang}_SOURCE_FLAGS
+                              ${target}_${l}
+                              "${${l}_flags}"
+                              "${${target}_${l}_srcs}" )
+
+        ecbuild_debug("ecbuild_target_flags(${target}): setting source file ${lang} flags from ${${target}_${lang}_SOURCE_FLAGS}")
+        include( ${${target}_${lang}_SOURCE_FLAGS} )
+
+      # 3) Use target specific compile flags
+      elseif( ${l}_flags )
+
+        set_source_files_properties( ${${target}_${l}_srcs} PROPERTIES COMPILE_FLAGS "${${l}_flags}" )
+        ecbuild_debug("ecbuild_target_flags(${target}): setting flags for '${${target}_${l}_srcs}' to '${${l}_flags}'")
+
+      endif()
+    endif()
+
+  endforeach()
+
+endfunction()
diff --git a/cmake/ecbuild_use_package.cmake b/cmake/ecbuild_use_package.cmake
index 6bd2bed..c88bca8 100644
--- a/cmake/ecbuild_use_package.cmake
+++ b/cmake/ecbuild_use_package.cmake
@@ -177,6 +177,7 @@ macro( ecbuild_use_package )
       # add as a subproject
 
       set( ${pkgUPPER}_subproj_dir_ ${${pkgUPPER}_subproj_dir_} CACHE PATH "Path to ${_p_PROJECT} source directory" )
+      mark_as_advanced( ${pkgUPPER}_subproj_dir_ )
 
       set( ECBUILD_PROJECTS ${ECBUILD_PROJECTS} ${_p_PROJECT} CACHE INTERNAL "" )
 
diff --git a/interpolation/jopnggsm.c b/interpolation/jopnggsm.c
index 5b20372..84dcf91 100644
--- a/interpolation/jopnggsm.c
+++ b/interpolation/jopnggsm.c
@@ -216,7 +216,7 @@ char *dbg;
     dbg = 0;
   }
   if (dbg) {
-    fprintf(stdout,"INTLOG DEBUG: JOPNGGSM: Coefficients file to open is:\n",ypfn);
+    fprintf(stdout,"INTLOG DEBUG: JOPNGGSM: Coefficients file to open is:\n");
     fprintf(stdout,"INTLOG DEBUG: %s\n",ypfn);
   }
 
diff --git a/interpolation/jopnllsm.c b/interpolation/jopnllsm.c
index 9415ac3..5bb10a1 100644
--- a/interpolation/jopnllsm.c
+++ b/interpolation/jopnllsm.c
@@ -238,7 +238,7 @@ char *dbg;
     dbg = 0;
   }
   if (dbg) {
-    fprintf(stdout,"INTLOG DEBUG: JOPNLLSM: Coefficients file to open is:\n",ypfn);
+    fprintf(stdout,"INTLOG DEBUG: JOPNLLSM: Coefficients file to open is:\n");
     fprintf(stdout,"INTLOG DEBUG: %s\n",ypfn);
   }
 
diff --git a/interpolation/wavexx2.F b/interpolation/wavexx2.F
index 1bd207d..0fdac57 100644
--- a/interpolation/wavexx2.F
+++ b/interpolation/wavexx2.F
@@ -382,10 +382,9 @@ C
           ROWINC = 360.0/NUMNEW(NROW)
 C
           IWEST = INT(WEST/ROWINC)
-          IF( (WEST.GT.0.0).AND.(WEST.NE.(IWEST*ROWINC)) ) THEN
-            IWEST = IWEST + 1
-          ELSEIF( (WEST.LT.0.0).AND.(WEST.NE.(IWEST*ROWINC)) ) THEN
-            IWEST = IWEST - 1
+          IF (ABS(WEST - IWEST*ROWINC).GT.0.000001) THEN
+            IF (WEST.GT.0.0) IWEST = IWEST + 1
+            IF (WEST.LT.0.0) IWEST = IWEST - 1
           ENDIF
           AWEST = IWEST * ROWINC
           IWOFSET = NUMPTWE(AWEST,0.0,ROWINC)
diff --git a/pbio/emosnum.F b/pbio/emosnum.F
index c4888fe..60014e4 100644
--- a/pbio/emosnum.F
+++ b/pbio/emosnum.F
@@ -88,7 +88,7 @@ C
       CHARACTER*35 CMESS
 C     CHARACTER*20 YNUMBER
 C
-      DATA INUMBER/000444/, ICOUNT/0/
+      DATA INUMBER/000445/, ICOUNT/0/
       DATA CMESS/'* EMOSLIB version number = ****** *'/
 C
 C ------------------------------------------------------------------
diff --git a/share/ecbuild/toolchains/ecmwf-XC30-Cray.cmake b/share/ecbuild/toolchains/ecmwf-XC30-Cray.cmake
index 52924b9..c6947e8 100644
--- a/share/ecbuild/toolchains/ecmwf-XC30-Cray.cmake
+++ b/share/ecbuild/toolchains/ecmwf-XC30-Cray.cmake
@@ -20,14 +20,6 @@ set( ECBUILD_FIND_MPI OFF )
 set( ECBUILD_TRUST_FLAGS ON )
 
 ####################################################################
-# MPI
-####################################################################
-
-set( MPIEXEC                 "aprun" )
-set( MPIEXEC_NUMPROC_FLAG    "-n"    )
-set( MPIEXEC_NUMTHREAD_FLAG  "-d"    )
-
-####################################################################
 # OpenMP FLAGS
 ####################################################################
 
@@ -40,17 +32,10 @@ set( OMPSTUBS_CXX_FLAGS      "-hnoomp" )
 set( OMPSTUBS_Fortran_FLAGS  "-hnoomp" )
 
 ####################################################################
-# Fortran FLAGS
-####################################################################
-
-# -emf activates .mods and uses lower case -rmoid produces a listing file
-set( ECBUILD_Fortran_FLAGS   "-emf -rmoid" )
-
-####################################################################
 # LINK FLAGS
 ####################################################################
 
-set( ECBUILD_C_LINK_FLAGS        "-Wl,-Map,loadmap -Wl,--as-needed -Ktrap=fp" )
-set( ECBUILD_CXX_LINK_FLAGS      "-Wl,-Map,loadmap -Wl,--as-needed -Ktrap=fp" )
-set( ECBUILD_Fortran_LINK_FLAGS  "-Wl,-Map,loadmap -Wl,--as-needed -Ktrap=fp" )
+set( ECBUILD_C_LINK_FLAGS        "-Wl,-Map,loadmap -Wl,--as-needed -Wl,--eh-frame-hdr -Ktrap=fp" )
+set( ECBUILD_CXX_LINK_FLAGS      "-Wl,-Map,loadmap -Wl,--as-needed -Wl,--eh-frame-hdr -Ktrap=fp" )
+set( ECBUILD_Fortran_LINK_FLAGS  "-Wl,-Map,loadmap -Wl,--as-needed -Wl,--eh-frame-hdr -Ktrap=fp" )
 set( ECBUILD_CXX_IMPLICIT_LINK_LIBRARIES "$ENV{CC_X86_64}/lib/x86-64/libcray-c++-rts.so" CACHE STRING "" )
diff --git a/share/ecbuild/toolchains/ecmwf-XC30-GNU.cmake b/share/ecbuild/toolchains/ecmwf-XC30-GNU.cmake
index 3f69f06..3ea294f 100644
--- a/share/ecbuild/toolchains/ecmwf-XC30-GNU.cmake
+++ b/share/ecbuild/toolchains/ecmwf-XC30-GNU.cmake
@@ -20,14 +20,6 @@ set( ECBUILD_FIND_MPI OFF )
 set( ECBUILD_TRUST_FLAGS ON )
 
 ####################################################################
-# MPI
-####################################################################
-
-set( MPIEXEC                 "aprun" )
-set( MPIEXEC_NUMPROC_FLAG    "-n"    )
-set( MPIEXEC_NUMTHREAD_FLAG  "-d"    )
-
-####################################################################
 # OpenMP FLAGS
 ####################################################################
 
@@ -47,6 +39,6 @@ set( ECBUILD_Fortran_FLAGS_DEBUG  "-ffree-line-length-none -O0 -g -fcheck=bounds
 # LINK FLAGS
 ####################################################################
 
-set( ECBUILD_C_LINK_FLAGS        "-Wl,-Map,load.map -Wl,--as-needed" )
-set( ECBUILD_CXX_LINK_FLAGS      "-Wl,-Map,load.map -Wl,--as-needed" )
-set( ECBUILD_Fortran_LINK_FLAGS  "-Wl,-Map,load.map -Wl,--as-needed" )
+set( ECBUILD_C_LINK_FLAGS        "-Wl,-Map,load.map -Wl,--as-needed -Wl,--eh-frame-hdr" )
+set( ECBUILD_CXX_LINK_FLAGS      "-Wl,-Map,load.map -Wl,--as-needed -Wl,--eh-frame-hdr" )
+set( ECBUILD_Fortran_LINK_FLAGS  "-Wl,-Map,load.map -Wl,--as-needed -Wl,--eh-frame-hdr" )
diff --git a/share/ecbuild/toolchains/ecmwf-XC30-Intel.cmake b/share/ecbuild/toolchains/ecmwf-XC30-Intel.cmake
index 01c6267..d5fdb32 100644
--- a/share/ecbuild/toolchains/ecmwf-XC30-Intel.cmake
+++ b/share/ecbuild/toolchains/ecmwf-XC30-Intel.cmake
@@ -21,14 +21,6 @@ set( ECBUILD_FIND_MPI OFF )
 set( ECBUILD_TRUST_FLAGS ON )
 
 ####################################################################
-# MPI
-####################################################################
-
-set( MPIEXEC                 "aprun" )
-set( MPIEXEC_NUMPROC_FLAG    "-n"    )
-set( MPIEXEC_NUMTHREAD_FLAG  "-d"    )
-
-####################################################################
 # OpenMP FLAGS
 ####################################################################
 
@@ -68,6 +60,6 @@ set( ECBUILD_Fortran_FLAGS_DEBUG  "-O0 -g -traceback -warn all -heap-arrays -fpe
 # LINK FLAGS
 ####################################################################
 
-set( ECBUILD_C_LINK_FLAGS        "-Wl,-Map,load.map -Wl,--as-needed" )
-set( ECBUILD_CXX_LINK_FLAGS      "-Wl,-Map,load.map -Wl,--as-needed" )
-set( ECBUILD_Fortran_LINK_FLAGS  "-Wl,-Map,load.map -Wl,--as-needed" )
+set( ECBUILD_C_LINK_FLAGS        "-Wl,-Map,load.map -Wl,--as-needed -Wl,--eh-frame-hdr" )
+set( ECBUILD_CXX_LINK_FLAGS      "-Wl,-Map,load.map -Wl,--as-needed -Wl,--eh-frame-hdr" )
+set( ECBUILD_Fortran_LINK_FLAGS  "-Wl,-Map,load.map -Wl,--as-needed -Wl,--eh-frame-hdr" )
diff --git a/tests/bufr/regress/download_tests_bufr_src_files.txt b/tests/bufr/regress/download_tests_bufr_src_files.txt
index eb22e35..e9e61ce 100644
--- a/tests/bufr/regress/download_tests_bufr_src_files.txt
+++ b/tests/bufr/regress/download_tests_bufr_src_files.txt
@@ -14,14 +14,8 @@ amse_55.bufr
 amsu_55.bufr
 amv2_87.bufr
 amv3_87.bufr
-asbh_139.bufr
-asbl_139.bufr
-asca_139.bufr
-asch_139.bufr
-ascs_139.bufr
 aseh_139.bufr
 asel_139.bufr
-ashs_139.bufr
 atap_55.bufr
 ateu_155.bufr
 atms_201.bufr
@@ -61,7 +55,6 @@ go15_87.bufr
 goee_87.bufr
 goes_87.bufr
 goga_89.bufr
-good_j2eo.bufr
 gosat.bufr
 grst_26.bufr
 gsd1_208.bufr
@@ -70,7 +63,6 @@ gsd3_208.bufr
 gst4_26.bufr
 hirb_55.bufr
 hirs_55.bufr
-ias1_240.bufr
 iasi_241.bufr
 ifco_208.bufr
 ikco_217.bufr
@@ -82,7 +74,6 @@ jaso_214.bufr
 kond_209.bufr
 maer_207.bufr
 meta_140.bufr
-mhen_55.bufr
 mhsa_55.bufr
 mhsb_55.bufr
 mhse_55.bufr

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/emos.git



More information about the debian-science-commits mailing list