[emos] 02/02: Upstream 4.4.4

Alastair McKinstry mckinstry at moszumanska.debian.org
Fri Oct 28 09:36:33 UTC 2016


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

mckinstry pushed a commit to tag upstream/4.4.4
in repository emos.

commit f51ff0c6d80a6dc7da7da0b815374f4f9aea5332
Author: Alastair McKinstry <mckinstry at debian.org>
Date:   Sun Oct 23 12:45:22 2016 +0100

    Upstream 4.4.4
---
 ChangeLog                                          |   8 +
 VERSION.cmake                                      |   2 +-
 bufrtables/.gitignore                              |   4 +
 cmake/FindAEC.cmake                                |  31 ++--
 cmake/FindMKL.cmake                                |   7 +-
 cmake/FindOpenJPEG.cmake                           |  16 +-
 cmake/VERSION.cmake                                |   6 +-
 .../contrib/GreatCMakeCookOff/AddCPP11Flags.cmake  |   5 +-
 .../GreatCMakeCookOff/CheckCXX11Features.cmake     | 125 +++++++--------
 cmake/ecbuild_add_executable.cmake                 |   2 +-
 cmake/ecbuild_add_fortran_flags.cmake              |  11 +-
 cmake/ecbuild_add_library.cmake                    |   2 +-
 cmake/ecbuild_add_option.cmake                     |  29 ++--
 cmake/ecbuild_add_test.cmake                       |   2 +-
 cmake/ecbuild_check_cxx11.cmake                    |  11 +-
 cmake/ecbuild_check_fortran.cmake                  | 126 ++++++++++++++++
 cmake/ecbuild_check_fortran_source_return.cmake    |  13 +-
 cmake/ecbuild_check_functions.cmake                |   9 ++
 cmake/ecbuild_config.h.in                          |   6 +
 cmake/ecbuild_declare_project.cmake                |  94 ++++++++++--
 cmake/ecbuild_download_resource.cmake              |   1 +
 cmake/ecbuild_find_python.cmake                    | 149 ++++++++++--------
 cmake/ecbuild_get_cxx11_flags.cmake                |   9 +-
 cmake/ecbuild_get_test_data.cmake                  |   1 +
 cmake/ecbuild_install_project.cmake                |  58 ++++---
 cmake/ecbuild_log.cmake                            |  21 ++-
 cmake/ecbuild_print_summary.cmake                  |   5 +
 cmake/ecbuild_separate_sources.cmake               |  14 +-
 cmake/ecbuild_source_flags.cmake                   |   6 +-
 cmake/ecbuild_system.cmake                         |   1 +
 cmake/fortran_features/CheckFortranFeatures.cmake  | 167 +++++++++++++++++++++
 cmake/fortran_features/c_size_t.F90                |   8 +
 cmake/fortran_features/c_sizeof.F90                |   3 +
 cmake/fortran_features/derivedtype_interface.F90   |  54 +++++++
 cmake/fortran_features/derivedtype_io.F90          |  42 ++++++
 cmake/fortran_features/finalization.F90            | 141 +++++++++++++++++
 cmake/fortran_features/submodules.F90              |  35 +++++
 debian/libemos-dev.install                         |   6 -
 debian/libemos0d.install                           |   1 -
 interpolation/igdiwe.F                             |   3 +
 libemos-4.4.3-Source.tar.gz?api=v2                 | Bin 55695641 -> 0 bytes
 pbio/emosnum.F                                     |   2 +-
 share/ecbuild/toolchains/ichec-fionn-Intel.cmake   |  67 +++++++++
 43 files changed, 1054 insertions(+), 249 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index c674c29..f8b1e8d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+000444
+
+	Notes
+		* This release is part of ECMWF Development Section Synchronised Release 2016.10
+
+	Bug fixes
+		* [EMOS-304] - fix for Greenwich meridian values on particular combinations of increments and sub-areas
+
 000443
 
 	Notes
diff --git a/VERSION.cmake b/VERSION.cmake
index fe39904..18450cd 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.3" )
+set( ${PROJECT_NAME}_VERSION_STR "4.4.4" )
diff --git a/bufrtables/.gitignore b/bufrtables/.gitignore
new file mode 100644
index 0000000..5e7d273
--- /dev/null
+++ b/bufrtables/.gitignore
@@ -0,0 +1,4 @@
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/cmake/FindAEC.cmake b/cmake/FindAEC.cmake
index 767544f..717b2b5 100644
--- a/cmake/FindAEC.cmake
+++ b/cmake/FindAEC.cmake
@@ -3,24 +3,31 @@
 # 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.
+# granted to it by virtue of its status as an intergovernmental organisation
+# nor does it submit to any jurisdiction.
 
 # - Try to find AEC (Adaptive Entropy Coding library)
 # See https://www.dkrz.de/redmine/projects/aec/wiki
 
 # Once done this will define
-#  AEC_FOUND - System has AEC
+#  AEC_FOUND        - System has AEC
 #  AEC_INCLUDE_DIRS - The AEC include directories
-#  AEC_LIBRARIES - The libraries needed to use AEC
-
-if( DEFINED AEC_PATH )
-    find_path( AEC_INCLUDE_DIR szlib.h    PATHS ${AEC_PATH}/include PATH_SUFFIXES aec NO_DEFAULT_PATH )
-    find_library( AEC_LIBRARY  NAMES aec  PATHS ${AEC_PATH}/lib     PATH_SUFFIXES aec NO_DEFAULT_PATH )
-endif()
-
-find_path( AEC_INCLUDE_DIR szlib.h PATH_SUFFIXES aec )
-find_library( AEC_LIBRARY NAMES aec PATH_SUFFIXES aec )
+#  AEC_LIBRARIES    - The libraries needed to use AEC
+#
+# The following paths will be searched with priority if set in CMake or env
+#
+#  AEC_DIR          - prefix path of the AEC installation
+#  AEC_PATH         - prefix path of the AEC installation
+
+find_path( AEC_INCLUDE_DIR szlib.h
+           PATHS ${AEC_DIR} ${AEC_PATH} ENV AEC_DIR ENV AEC_PATH
+           PATH_SUFFIXES include include/aec NO_DEFAULT_PATH )
+find_path( AEC_INCLUDE_DIR szlib.h PATH_SUFFIXES include include/aec )
+
+find_library( AEC_LIBRARY  NAMES aec
+              PATHS ${AEC_DIR} ${AEC_PATH} ENV AEC_DIR ENV AEC_PATH
+              PATH_SUFFIXES lib lib64 lib/aec lib64/aec NO_DEFAULT_PATH )
+find_library( AEC_LIBRARY NAMES aec PATH_SUFFIXES lib lib64 lib/aec lib64/aec )
 
 set( AEC_LIBRARIES    ${AEC_LIBRARY} )
 set( AEC_INCLUDE_DIRS ${AEC_INCLUDE_DIR} )
diff --git a/cmake/FindMKL.cmake b/cmake/FindMKL.cmake
index 1123234..5941179 100644
--- a/cmake/FindMKL.cmake
+++ b/cmake/FindMKL.cmake
@@ -15,6 +15,7 @@
 #
 # The following paths will be searched with priority if set in CMake or env
 #
+#  MKLROOT           - root directory of the MKL installation
 #  MKL_PATH          - root directory of the MKL installation
 #  MKL_ROOT          - root directory of the MKL installation
 
@@ -34,9 +35,9 @@ else()
 
 endif()
 
-# Search with priority for MKL_ROOT and MKL_PATH if set in CMake or env
+# Search with priority for MKLROOT, MKL_PATH and MKL_ROOT if set in CMake or env
 find_path(MKL_INCLUDE_DIR mkl.h
-          PATHS ${MKL_PATH} ${MKL_ROOT} ENV MKL_PATH MKL_ROOT
+          PATHS ${MKLROOT} ${MKL_PATH} ${MKL_ROOT} ENV MKLROOT ENV MKL_PATH ENV MKL_ROOT
           PATH_SUFFIXES include NO_DEFAULT_PATH)
 find_path(MKL_INCLUDE_DIR mkl.h
           PATH_SUFFIXES include)
@@ -53,8 +54,6 @@ if( MKL_INCLUDE_DIR ) # use include dir to find libs
     set( __libsfx "" )
   endif()
 
-  message( STATUS "ICC_LIB_PATH ${ICC_LIB_PATH}" )
-
   find_library( MKL_LIB_INTEL         NAMES mkl_intel${__libsfx} PATHS ${MKL_LIB_PATH} )
   find_library( ${__mkl_lib_par}      NAMES ${__mkl_lib_name} PATHS ${MKL_LIB_PATH} )
   find_library( MKL_LIB_CORE          NAMES mkl_core PATHS ${MKL_LIB_PATH} )
diff --git a/cmake/FindOpenJPEG.cmake b/cmake/FindOpenJPEG.cmake
index 805f091..b54ecce 100644
--- a/cmake/FindOpenJPEG.cmake
+++ b/cmake/FindOpenJPEG.cmake
@@ -20,14 +20,20 @@ IF( NOT DEFINED OPENJPEG_PATH AND NOT "$ENV{OPENJPEG_PATH}" STREQUAL "" )
   SET( OPENJPEG_PATH "$ENV{OPENJPEG_PATH}" )
 ENDIF()
 
-# TODO: This only works for OpenJPEG v1.x.y and not for v2 which has a different API, library name etc
+# 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  NO_DEFAULT_PATH)
-        find_library(OPENJPEG_LIBRARY  openjpeg   PATHS ${OPENJPEG_PATH}/lib     PATH_SUFFIXES openjpeg  NO_DEFAULT_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 )
-find_library( OPENJPEG_LIBRARY  openjpeg   PATH_SUFFIXES openjpeg )
+find_path(OPENJPEG_INCLUDE_DIR  openjpeg.h PATH_SUFFIXES openjpeg openjpeg-2.1)
+
+find_library( OPENJPEG_LIBRARY NAMES openjpeg openjp2 PATH_SUFFIXES openjpeg )
 
 set( OPENJPEG_LIBRARIES    ${OPENJPEG_LIBRARY} )
 set( OPENJPEG_INCLUDE_DIRS ${OPENJPEG_INCLUDE_DIR} )
diff --git a/cmake/VERSION.cmake b/cmake/VERSION.cmake
index 22d11f1..b4c65ee 100644
--- a/cmake/VERSION.cmake
+++ b/cmake/VERSION.cmake
@@ -1,7 +1,7 @@
 set( ECBUILD_MAJOR_VERSION "2" )
-set( ECBUILD_MINOR_VERSION "3" )
-set( ECBUILD_PATCH_VERSION "1" )
+set( ECBUILD_MINOR_VERSION "4" )
+set( ECBUILD_PATCH_VERSION "0" )
 
-set( ECBUILD_VERSION_STR  "2.3.1" )
+set( ECBUILD_VERSION_STR  "2.4.0" )
 
 set( ECBUILD_MACRO_VERSION "${ECBUILD_MAJOR_VERSION}.${ECBUILD_MINOR_VERSION}" )
diff --git a/cmake/contrib/GreatCMakeCookOff/AddCPP11Flags.cmake b/cmake/contrib/GreatCMakeCookOff/AddCPP11Flags.cmake
index 2a11e04..ac7f456 100644
--- a/cmake/contrib/GreatCMakeCookOff/AddCPP11Flags.cmake
+++ b/cmake/contrib/GreatCMakeCookOff/AddCPP11Flags.cmake
@@ -29,6 +29,7 @@ endif(CMAKE_VERSION VERSION_LESS 2.8.9)
 
 check_cxx_compiler_flag(-std=c++11 has_std_cpp11)
 check_cxx_compiler_flag(-std=c++0x has_std_cpp0x)
+check_cxx_compiler_flag(-hstd=c++11 has_hstd_cpp11)
 if(MINGW) 
   check_cxx_compiler_flag(-std=gnu++11 has_std_gnupp11)
   check_cxx_compiler_flag(-std=gnu++0x has_std_gnupp0x)
@@ -37,10 +38,12 @@ if(has_std_gnupp11)
   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
 elseif(has_std_gnupp0x)
   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++0x")
-elseif(has_std_cpp11) 
+elseif(has_std_cpp11)
   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
 elseif(has_std_cpp0x)
   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
+elseif(has_hstd_cpp11)
+  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -hstd=c++11")
 endif(has_std_gnupp11)
 
 if(MSVC) 
diff --git a/cmake/contrib/GreatCMakeCookOff/CheckCXX11Features.cmake b/cmake/contrib/GreatCMakeCookOff/CheckCXX11Features.cmake
index 71fa610..593b62f 100644
--- a/cmake/contrib/GreatCMakeCookOff/CheckCXX11Features.cmake
+++ b/cmake/contrib/GreatCMakeCookOff/CheckCXX11Features.cmake
@@ -1,14 +1,14 @@
 # Checks for C++11 features
-# 
+#
 # USAGE: There are two functions
 #
-# cxx11_find_all_features(OUTPUT_VARIABLE) 
+# cxx11_find_all_features(OUTPUT_VARIABLE)
 # This function returns a variable with all possible features.
 #
 # cxx11_feature_check([feature feature] [REQUIRED [feature feature]])
 # If no arguments are provided, then checks all available features
 # Features appeacing before REQUIRED are optional.
-# If arguments are provided and those features are available, sets 
+# If arguments are provided and those features are available, sets
 # the variable HAS_CXX11_FEATURENAME, where FEATURENAME is the input in capital letters.
 # Fails if required feature are not available
 #
@@ -17,65 +17,66 @@
 # Original script by Rolf Eike Beer
 # Modifications by Andreas Weis
 # Further Modifications by RSDT at UCL
+# Adapted to ecBuild by Florian Rathgeber <florian.rathgeber at ecmwf.int>
 
 set(CPP11_FEATURE_CHECK_DIR ${CMAKE_CURRENT_LIST_DIR}/cpp11 CACHE INTERNAL "c++11 file directory")
 
 MACRO(cxx11_check_single_feature FEATURE_NAME FEATURE_NUMBER RESULT_VAR)
-	IF (NOT DEFINED ${RESULT_VAR})
+  IF (NOT DEFINED ${RESULT_VAR})
     SET(_bindir "${CMAKE_BINARY_DIR}/cxx11_feature_tests/cxx11_${FEATURE_NAME}")
 
-		IF (${FEATURE_NUMBER})
+    IF (${FEATURE_NUMBER})
       SET(_SRCFILE_BASE ${CPP11_FEATURE_CHECK_DIR}/${FEATURE_NAME}-N${FEATURE_NUMBER})
-			SET(_LOG_NAME "\"${FEATURE_NAME}\" (N${FEATURE_NUMBER})")
-		ELSE (${FEATURE_NUMBER})
+      SET(_LOG_NAME "\"${FEATURE_NAME}\" (N${FEATURE_NUMBER})")
+    ELSE (${FEATURE_NUMBER})
       SET(_SRCFILE_BASE ${CPP11_FEATURE_CHECK_DIR}/${FEATURE_NAME})
-			SET(_LOG_NAME "\"${FEATURE_NAME}\"")
-		ENDIF (${FEATURE_NUMBER})
-		MESSAGE(STATUS "Checking C++11 support for ${_LOG_NAME}")
-
-		SET(_SRCFILE "${_SRCFILE_BASE}.cpp")
-		SET(_SRCFILE_FAIL "${_SRCFILE_BASE}_fail.cpp")
-		SET(_SRCFILE_FAIL_COMPILE "${_SRCFILE_BASE}_fail_compile.cpp")
-
-		IF (CROSS_COMPILING)
-			try_compile(${RESULT_VAR} "${_bindir}" "${_SRCFILE}")
-			IF (${RESULT_VAR} AND EXISTS ${_SRCFILE_FAIL})
-				try_compile(${RESULT_VAR} "${_bindir}_fail" "${_SRCFILE_FAIL}")
-			ENDIF (${RESULT_VAR} AND EXISTS ${_SRCFILE_FAIL})
-		ELSE (CROSS_COMPILING)
-			try_run(_RUN_RESULT_VAR _COMPILE_RESULT_VAR
-					"${_bindir}" "${_SRCFILE}")
-			IF (_COMPILE_RESULT_VAR AND NOT _RUN_RESULT_VAR)
-				SET(${RESULT_VAR} TRUE)
-			ELSE (_COMPILE_RESULT_VAR AND NOT _RUN_RESULT_VAR)
-				SET(${RESULT_VAR} FALSE)
-			ENDIF (_COMPILE_RESULT_VAR AND NOT _RUN_RESULT_VAR)
-			IF (${RESULT_VAR} AND EXISTS ${_SRCFILE_FAIL})
-				try_run(_RUN_RESULT_VAR _COMPILE_RESULT_VAR
-						"${_bindir}_fail" "${_SRCFILE_FAIL}")
-				IF (_COMPILE_RESULT_VAR AND _RUN_RESULT_VAR)
-					SET(${RESULT_VAR} TRUE)
-				ELSE (_COMPILE_RESULT_VAR AND _RUN_RESULT_VAR)
-					SET(${RESULT_VAR} FALSE)
-				ENDIF (_COMPILE_RESULT_VAR AND _RUN_RESULT_VAR)
-			ENDIF (${RESULT_VAR} AND EXISTS ${_SRCFILE_FAIL})
-		ENDIF (CROSS_COMPILING)
-		IF (${RESULT_VAR} AND EXISTS ${_SRCFILE_FAIL_COMPILE})
-			try_compile(_TMP_RESULT "${_bindir}_fail_compile" "${_SRCFILE_FAIL_COMPILE}")
-			IF (_TMP_RESULT)
-				SET(${RESULT_VAR} FALSE)
-			ELSE (_TMP_RESULT)
-				SET(${RESULT_VAR} TRUE)
-			ENDIF (_TMP_RESULT)
-		ENDIF (${RESULT_VAR} AND EXISTS ${_SRCFILE_FAIL_COMPILE})
-
-		IF (${RESULT_VAR})
-			MESSAGE(STATUS "Checking C++11 support for ${_LOG_NAME} -- works")
-		ELSE (${RESULT_VAR})
-			MESSAGE(STATUS "Checking C++11 support for ${_LOG_NAME} -- not supported")
-		ENDIF (${RESULT_VAR})
-		SET(${RESULT_VAR} ${${RESULT_VAR}} CACHE INTERNAL "C++11 support for ${_LOG_NAME}")
-	ENDIF (NOT DEFINED ${RESULT_VAR})
+      SET(_LOG_NAME "\"${FEATURE_NAME}\"")
+    ENDIF (${FEATURE_NUMBER})
+    ecbuild_info("Checking C++11 support for ${_LOG_NAME}")
+
+    SET(_SRCFILE "${_SRCFILE_BASE}.cpp")
+    SET(_SRCFILE_FAIL "${_SRCFILE_BASE}_fail.cpp")
+    SET(_SRCFILE_FAIL_COMPILE "${_SRCFILE_BASE}_fail_compile.cpp")
+
+    IF (CROSS_COMPILING)
+      try_compile(${RESULT_VAR} "${_bindir}" "${_SRCFILE}")
+      IF (${RESULT_VAR} AND EXISTS ${_SRCFILE_FAIL})
+        try_compile(${RESULT_VAR} "${_bindir}_fail" "${_SRCFILE_FAIL}")
+      ENDIF (${RESULT_VAR} AND EXISTS ${_SRCFILE_FAIL})
+    ELSE (CROSS_COMPILING)
+      try_run(_RUN_RESULT_VAR _COMPILE_RESULT_VAR
+          "${_bindir}" "${_SRCFILE}")
+      IF (_COMPILE_RESULT_VAR AND NOT _RUN_RESULT_VAR)
+        SET(${RESULT_VAR} TRUE)
+      ELSE (_COMPILE_RESULT_VAR AND NOT _RUN_RESULT_VAR)
+        SET(${RESULT_VAR} FALSE)
+      ENDIF (_COMPILE_RESULT_VAR AND NOT _RUN_RESULT_VAR)
+      IF (${RESULT_VAR} AND EXISTS ${_SRCFILE_FAIL})
+        try_run(_RUN_RESULT_VAR _COMPILE_RESULT_VAR
+            "${_bindir}_fail" "${_SRCFILE_FAIL}")
+        IF (_COMPILE_RESULT_VAR AND _RUN_RESULT_VAR)
+          SET(${RESULT_VAR} TRUE)
+        ELSE (_COMPILE_RESULT_VAR AND _RUN_RESULT_VAR)
+          SET(${RESULT_VAR} FALSE)
+        ENDIF (_COMPILE_RESULT_VAR AND _RUN_RESULT_VAR)
+      ENDIF (${RESULT_VAR} AND EXISTS ${_SRCFILE_FAIL})
+    ENDIF (CROSS_COMPILING)
+    IF (${RESULT_VAR} AND EXISTS ${_SRCFILE_FAIL_COMPILE})
+      try_compile(_TMP_RESULT "${_bindir}_fail_compile" "${_SRCFILE_FAIL_COMPILE}")
+      IF (_TMP_RESULT)
+        SET(${RESULT_VAR} FALSE)
+      ELSE (_TMP_RESULT)
+        SET(${RESULT_VAR} TRUE)
+      ENDIF (_TMP_RESULT)
+    ENDIF (${RESULT_VAR} AND EXISTS ${_SRCFILE_FAIL_COMPILE})
+
+    IF (${RESULT_VAR})
+      ecbuild_info("Checking C++11 support for ${_LOG_NAME} -- works")
+    ELSE (${RESULT_VAR})
+      ecbuild_info("Checking C++11 support for ${_LOG_NAME} -- not supported")
+    ENDIF (${RESULT_VAR})
+    SET(${RESULT_VAR} ${${RESULT_VAR}} CACHE INTERNAL "C++11 support for ${_LOG_NAME}")
+  ENDIF (NOT DEFINED ${RESULT_VAR})
 ENDMACRO(cxx11_check_single_feature)
 
 # Find list of all features
@@ -138,12 +139,12 @@ macro(_figure_out_cxx11_feature current_feature)
       list(REMOVE_ITEM ALL_FEATURE_FILES ${filename})
     endif()
   endforeach()
-  
+
   list(LENGTH ALL_FEATURE_FILES NFILES)
   if(NOT ${NFILES} EQUAL 1)
-    message(FATAL_ERROR "[c++11] Expected to find only one feature. Found ${NFILES} -- ${ALL_FEATURE_FILES}.")
+    ecbuild_critical("[c++11] Expected to find only one feature. Found ${NFILES} -- ${ALL_FEATURE_FILES}.")
   endif(NOT ${NFILES} EQUAL 1)
-  
+
   # Now we know which file corresponds to option.
   get_filename_component(basename ${ALL_FEATURE_FILES} NAME_WE)
   # If has feature number, extract it
@@ -165,18 +166,18 @@ function(cxx11_feature_check)
   # Parses input to this function.
   parse_input_features("${ALL_CPP11_FEATURES}" OPTIONALS REQUIRED ERRORS ${ARGN})
   if(NOT ${ERRORS} STREQUAL "")
-    message(STATUS "[c++11] The following features are unknown: ${ERRORS}.")
+    ecbuild_info("[c++11] The following features are unknown: ${ERRORS}.")
   endif()
 
   # MinGW has not implemented std::random_device fully yet. Unfortunately, this can only be detected
   # by running a program which tries to call std::random_device. However that generates an error that
-  # is *not* caught by CMake's try_run. 
+  # is *not* caught by CMake's try_run.
   if(MSYS)
     list(REMOVE_ITEM OPTIONALS "random_device")
     list(FIND REQUIRED "random_device" feature_was_found)
     if(NOT feature_was_found EQUAL "-1")
-      message(FATAL_ERROR "[c++1] MSYS does not implement Random devices fully.\n"
-                          "       It cannot be required on this system.")
+      ecbuild_critical("[c++1] MSYS does not implement Random devices fully.\n"
+                       "       It cannot be required on this system.")
     endif()
   endif()
 
@@ -190,7 +191,7 @@ function(cxx11_feature_check)
     _figure_out_cxx11_feature(${current_feature})
     set(VARNAME HAS_CXX11_${UPPER_OPTIONAL})
     if(NOT ${VARNAME})
-      message(FATAL_ERROR "[c++11] Required feature ${current_feature} is not available.")
+      ecbuild_critical("[c++11] Required feature ${current_feature} is not available.")
     endif(NOT ${VARNAME})
   endforeach(current_feature ${REQUIRED})
 
diff --git a/cmake/ecbuild_add_executable.cmake b/cmake/ecbuild_add_executable.cmake
index 4572832..c25fe59 100644
--- a/cmake/ecbuild_add_executable.cmake
+++ b/cmake/ecbuild_add_executable.cmake
@@ -26,7 +26,7 @@
 #                           [ PERSISTENT <file1> [<file2> ...] ]
 #                           [ GENERATED <file1> [<file2> ...] ]
 #                           [ DEPENDS <target1> [<target2> ...] ]
-#                           [ CONDITION <condition1> [<condition2> ...] ]
+#                           [ CONDITION <condition> ]
 #                           [ NOINSTALL ]
 #                           [ VERSION <version> | AUTO_VERSION ]
 #                           [ CFLAGS <flag1> [<flag2> ...] ]
diff --git a/cmake/ecbuild_add_fortran_flags.cmake b/cmake/ecbuild_add_fortran_flags.cmake
index 17b9bf2..0d3b544 100644
--- a/cmake/ecbuild_add_fortran_flags.cmake
+++ b/cmake/ecbuild_add_fortran_flags.cmake
@@ -64,7 +64,14 @@ macro( ecbuild_add_fortran_flags m_fortran_flags )
 
       math( EXPR N_FortranFLAG '${N_FortranFLAG}+1' )
 
-      if( NOT ECBUILD_TRUST_FLAGS )
+      if( ECBUILD_TRUST_FLAGS )
+        set( _flag_ok 1 )
+      # Due to a bug in CMake < 3.0, check_fortran_compiler_flag ALWAYS fails with ifort
+      # see https://cmake.org/Bug/view.php?id=14507
+      elseif( CMAKE_MAJOR_VERSION LESS 3 AND CMAKE_Fortran_COMPILER_ID MATCHES "Intel" )
+        set( _flag_ok 1 )
+        ecbuild_warn( "Not testing Fortran flags due to a bug in CMake < 3.0 with ifort" )
+      else()
         if( DEFINED _PAR_NAME )
           check_fortran_compiler_flag( ${_flags} ${_PAR_NAME} )
           set( _flag_ok ${${_PAR_NAME}} )
@@ -72,8 +79,6 @@ macro( ecbuild_add_fortran_flags m_fortran_flags )
           check_fortran_compiler_flag( ${_flags} Fortran_FLAG_TEST_${N_FortranFLAG} )
           set( _flag_ok ${Fortran_FLAG_TEST_${N_FortranFLAG}} )
         endif()
-      else()
-        set( _flag_ok 1 )
       endif()
 
       if( _flag_ok )
diff --git a/cmake/ecbuild_add_library.cmake b/cmake/ecbuild_add_library.cmake
index 48602a4..55b8ce5 100644
--- a/cmake/ecbuild_add_library.cmake
+++ b/cmake/ecbuild_add_library.cmake
@@ -29,7 +29,7 @@
 #                        [ PERSISTENT <file1> [<file2> ...] ]
 #                        [ GENERATED <file1> [<file2> ...] ]
 #                        [ DEPENDS <target1> [<target2> ...] ]
-#                        [ CONDITION <condition1> [<condition2> ...] ]
+#                        [ CONDITION <condition> ]
 #                        [ NOINSTALL ]
 #                        [ HEADER_DESTINATION <path> ]
 #                        [ INSTALL_HEADERS LISTED|ALL ]
diff --git a/cmake/ecbuild_add_option.cmake b/cmake/ecbuild_add_option.cmake
index 8261bd4..e0468fb 100644
--- a/cmake/ecbuild_add_option.cmake
+++ b/cmake/ecbuild_add_option.cmake
@@ -19,7 +19,7 @@
 #                       [ DESCRIPTION <description> ]
 #                       [ PURPOSE <purpose> ]
 #                       [ REQUIRED_PACKAGES <package1> [<package2> ...] ]
-#                       [ CONDITION <condition1> [<condition2> ...] ]
+#                       [ CONDITION <condition> ]
 #                       [ ADVANCED ] )
 #
 # Options
@@ -196,6 +196,7 @@ macro( ecbuild_add_option )
         string( TOUPPER ${pkgname} pkgUPPER )
         string( TOLOWER ${pkgname} pkgLOWER )
 
+        set( __help_msg "Provide ${pkgname} location with -D${pkgUPPER}_PATH=/..." )
         if( ${pkgname}_FOUND OR ${pkgUPPER}_FOUND OR ${pkgLOWER}_FOUND )
 
           ecbuild_debug("ecbuild_add_option(${_p_FEATURE}): ${pkgname} has already been found")
@@ -205,7 +206,7 @@ macro( ecbuild_add_option )
 
           if( pkgproject )
 
-            ecbuild_debug("ecbuild_add_option(${_p_FEATURE}): searching for ecbuild project ${pkgname}")
+            ecbuild_debug("ecbuild_add_option(${_p_FEATURE}): searching for ecbuild project ${pkgname} - ecbuild_use_package( ${pkglist} )")
             ecbuild_use_package( ${pkglist} )
 
           else()
@@ -213,7 +214,7 @@ macro( ecbuild_add_option )
             if( pkgname STREQUAL "MPI" )
               set( _find_args ${pkglist} )
               list( REMOVE_ITEM _find_args "MPI" )
-              ecbuild_debug("ecbuild_add_option(${_p_FEATURE}): searching for MPI")
+              ecbuild_debug("ecbuild_add_option(${_p_FEATURE}): searching for MPI - ecbuild_find_mpi( ${_find_args} )")
               ecbuild_find_mpi( ${_find_args} )
             elseif( pkgname STREQUAL "OMP" )
               set( _find_args ${pkglist} )
@@ -221,20 +222,21 @@ macro( ecbuild_add_option )
               if( NOT ENABLE_${_p_FEATURE} )
                 list( APPEND _find_args STUBS )
               endif()
-              ecbuild_debug("ecbuild_add_option(${_p_FEATURE}): searching for OpenMP")
+              ecbuild_debug("ecbuild_add_option(${_p_FEATURE}): searching for OpenMP - ecbuild_find_omp( ${_find_args} )")
               ecbuild_find_omp( ${_find_args} )
             elseif( pkgname STREQUAL "Python" OR pkgname STREQUAL "PYTHON" )
               set( _find_args ${pkglist} )
               list( REMOVE_ITEM _find_args ${pkgname} )
-              ecbuild_debug("ecbuild_add_option(${_p_FEATURE}): searching for Python")
+              ecbuild_debug("ecbuild_add_option(${_p_FEATURE}): searching for Python - ecbuild_find_python( ${_find_args} )")
               ecbuild_find_python( ${_find_args} )
+              set( __help_msg "Specify the location of the Python interpreter with -DPYTHON_EXECUTABLE=/..." )
             elseif( pkgname STREQUAL "LEXYACC" )
               set( _find_args ${pkglist} )
               list( REMOVE_ITEM _find_args ${pkgname} )
-              ecbuild_debug("ecbuild_add_option(${_p_FEATURE}): searching for lex-yacc")
+              ecbuild_debug("ecbuild_add_option(${_p_FEATURE}): searching for lex-yacc - ecbuild_find_lexyacc( ${_find_args} )")
               ecbuild_find_lexyacc( ${_find_args} )
             else()
-              ecbuild_debug("ecbuild_add_option(${_p_FEATURE}): searching for package ${pkgname}")
+              ecbuild_debug("ecbuild_add_option(${_p_FEATURE}): searching for package ${pkgname} - find_package( ${pkglist} )")
               find_package( ${pkglist} )
             endif()
 
@@ -259,7 +261,7 @@ macro( ecbuild_add_option )
         if( ${pkgname}_FOUND OR ${pkgUPPER}_FOUND OR ${pkgLOWER}_FOUND )
           ecbuild_info( "Found package ${pkgname} required for feature ${_p_FEATURE}" )
         else()
-          ecbuild_info( "Could not find package ${pkgname} required for feature ${_p_FEATURE} -- Provide ${pkgname} location with -D${pkgUPPER}_PATH=/..." )
+          ecbuild_info( "Could NOT find package ${pkgname} required for feature ${_p_FEATURE} -- ${__help_msg}" )
           set( HAVE_${_p_FEATURE} 0 )
           list( APPEND _failed_to_find_packages ${pkgname} )
         endif()
@@ -279,15 +281,16 @@ macro( ecbuild_add_option )
     else() # if user provided input and we cannot satisfy FAIL otherwise WARN
 
       if( ${_p_FEATURE}_user_provided_input )
-        if( _${_p_FEATURE}_condition )
-          ecbuild_critical( "Feature ${_p_FEATURE} cannot be enabled -- following required packages weren't found: ${_failed_to_find_packages}" )
-        else()
+        if( NOT _${_p_FEATURE}_condition )
           string(REPLACE ";" " " _condition_msg "${_p_CONDITION}")
           ecbuild_critical( "Feature ${_p_FEATURE} cannot be enabled -- following condition was not met: ${_condition_msg}" )
+        else()
+          ecbuild_critical( "Feature ${_p_FEATURE} cannot be enabled -- following required packages weren't found: ${_failed_to_find_packages}" )
         endif()
       else()
-        if( _${_p_FEATURE}_condition )
-          ecbuild_info( "Feature ${_p_FEATURE} was not enabled (also not requested) -- following condition was not met: ${_p_CONDITION}" )
+        if( NOT _${_p_FEATURE}_condition )
+          string(REPLACE ";" " " _condition_msg "${_p_CONDITION}")
+          ecbuild_info( "Feature ${_p_FEATURE} was not enabled (also not requested) -- following condition was not met: ${_condition_msg}" )
         else()
           ecbuild_info( "Feature ${_p_FEATURE} was not enabled (also not requested) -- following required packages weren't found: ${_failed_to_find_packages}" )
         endif()
diff --git a/cmake/ecbuild_add_test.cmake b/cmake/ecbuild_add_test.cmake
index 2097683..0563cd6 100644
--- a/cmake/ecbuild_add_test.cmake
+++ b/cmake/ecbuild_add_test.cmake
@@ -33,7 +33,7 @@
 #                     [ GENERATED <file1> [<file2> ...] ]
 #                     [ DEPENDS <target1> [<target2> ...] ]
 #                     [ TEST_DEPENDS <target1> [<target2> ...] ]
-#                     [ CONDITION <condition1> [<condition2> ...] ]
+#                     [ CONDITION <condition> ]
 #                     [ ENVIRONMENT <variable1> [<variable2> ...] ]
 #                     [ WORKING_DIRECTORY <path> ]
 #                     [ CFLAGS <flag1> [<flag2> ...] ]
diff --git a/cmake/ecbuild_check_cxx11.cmake b/cmake/ecbuild_check_cxx11.cmake
index 390462b..1639a6a 100644
--- a/cmake/ecbuild_check_cxx11.cmake
+++ b/cmake/ecbuild_check_cxx11.cmake
@@ -23,14 +23,19 @@
 # Options
 # -------
 #
-# FEATURES : optional, checks for all features if omitted
-#   list of features to check for
+# FEATURES : optional
+#   list of optional features to check for
 #
 # REQUIRED : optional
 #   list of required features to check for
 #
 # PRINT : optional
-#   print a summary of features check for, found and not found
+#   print a summary of features checked for, found and not found
+#
+# Note
+# ----
+#
+# If neither ``FEATURES`` nor ``REQUIRED`` are given, check for all features.
 #
 ##############################################################################
 
diff --git a/cmake/ecbuild_check_fortran.cmake b/cmake/ecbuild_check_fortran.cmake
new file mode 100644
index 0000000..5612134
--- /dev/null
+++ b/cmake/ecbuild_check_fortran.cmake
@@ -0,0 +1,126 @@
+# (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_check_fortran
+# =====================
+#
+# Check for Fortran features. ::
+#
+#   ecbuild_check_fortran( [ FEATURES <feature1> [ <feature2> ... ] ]
+#                          [ REQUIRED <feature1> [ <feature2> ... ] ]
+#                          [ PRINT ] )
+#
+# Options
+# -------
+#
+# FEATURES : optional
+#   list of optional features to check for
+#
+# REQUIRED : optional
+#   list of required features to check for, fails if not detected
+#
+# PRINT : optional
+#   print a summary of features checked for, found and not found
+#
+# Note
+# ----
+#
+# If neither ``FEATURES`` nor ``REQUIRED`` are given, check for all features.
+#
+##############################################################################
+
+function( ecbuild_check_fortran )
+
+  # parse parameters
+
+  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} )
+
+  if(_PAR_UNPARSED_ARGUMENTS)
+    ecbuild_critical("Unknown keywords given to ecbuild_check_fortran(): \"${_PAR_UNPARSED_ARGUMENTS}\"")
+  endif()
+
+  include( ${ECBUILD_MACROS_DIR}/fortran_features/CheckFortranFeatures.cmake )
+
+  fortran_find_all_features( ALL_FEATURES ) # list all available features to check
+
+  if( NOT _p_FEATURES AND NOT _p_REQUIRED ) # no input, then search for all features
+
+    fortran_feature_check()
+
+  else()
+
+    foreach( _f ${_p_FEATURES} )
+      fortran_feature_check( ${_f} )
+    endforeach()
+
+    foreach( _f ${_p_REQUIRED} )
+      fortran_feature_check( REQUIRED ${_f} )
+    endforeach()
+
+  endif()
+
+  if( _p_FEATURES OR _p_REQUIRED )
+    set( Fortran_CHECKED_FEATURES ${_p_FEATURES} ${_p_REQUIRED} )
+  else()
+    set( Fortran_CHECKED_FEATURES ${ALL_FEATURES} )
+  endif()
+
+  foreach( f ${Fortran_CHECKED_FEATURES} )
+    string( TOUPPER ${f} FEAT )
+    if( HAS_Fortran_${FEAT} )
+       list( APPEND Fortran_SUPPORTED_FEATURES ${f} )
+       set( EC_HAVE_Fortran_${FEAT} 1 PARENT_SCOPE )
+    else()
+       list( APPEND Fortran_NOT_SUPPORTED_FEATURES ${f} )
+       set( EC_HAVE_Fortran_${FEAT} 0 PARENT_SCOPE )
+    endif()
+  endforeach()
+
+  if( Fortran_CHECKED_FEATURES )
+    list( SORT Fortran_CHECKED_FEATURES )
+  endif()
+  if( Fortran_SUPPORTED_FEATURES )
+    list( SORT Fortran_SUPPORTED_FEATURES )
+  endif()
+  if( Fortran_NOT_SUPPORTED_FEATURES )
+    list( SORT Fortran_NOT_SUPPORTED_FEATURES )
+  endif()
+
+  set( Fortran_CHECKED_FEATURES       ${Fortran_CHECKED_FEATURES}       PARENT_SCOPE )
+  set( Fortran_SUPPORTED_FEATURES     ${Fortran_SUPPORTED_FEATURES}     PARENT_SCOPE )
+  set( Fortran_NOT_SUPPORTED_FEATURES ${Fortran_NOT_SUPPORTED_FEATURES} PARENT_SCOPE )
+
+  if( _p_PRINT )
+    if( Fortran_CHECKED_FEATURES )
+      join( Fortran_CHECKED_FEATURES " " Fortran_CHECKED_FEATURES_STR )
+      ecbuild_info( "Checked Fortran features: ${Fortran_CHECKED_FEATURES_STR}" )
+    else()
+      ecbuild_info( "Checked no Fortran features" )
+    endif()
+    if( Fortran_SUPPORTED_FEATURES )
+      join( Fortran_SUPPORTED_FEATURES " " Fortran_SUPPORTED_FEATURES_STR )
+      ecbuild_info( "Found Fortran features: ${Fortran_SUPPORTED_FEATURES_STR}" )
+    else()
+      ecbuild_info( "Found no Fortran features" )
+    endif()
+    if( Fortran_NOT_SUPPORTED_FEATURES )
+      join( Fortran_NOT_SUPPORTED_FEATURES " " Fortran_NOT_SUPPORTED_FEATURES_STR )
+      ecbuild_info( "Not found Fortran features: ${Fortran_NOT_SUPPORTED_FEATURES_STR}" )
+    else()
+      ecbuild_info( "Found all checked Fortran features" )
+    endif()
+  endif()
+
+endfunction( ecbuild_check_fortran )
diff --git a/cmake/ecbuild_check_fortran_source_return.cmake b/cmake/ecbuild_check_fortran_source_return.cmake
index 6b007df..175f4ef 100644
--- a/cmake/ecbuild_check_fortran_source_return.cmake
+++ b/cmake/ecbuild_check_fortran_source_return.cmake
@@ -52,7 +52,6 @@
 
 macro( ecbuild_check_fortran_source_return SOURCE )
 
-    ecbuild_warn( "This macro ecbuild_check_fortran_source has never been tested" )
     set( options )
     set( single_value_args VAR  OUTPUT )
     set( multi_value_args  INCLUDES LIBS DEFINITIONS )
@@ -93,15 +92,15 @@ macro( ecbuild_check_fortran_source_return SOURCE )
         if( __add_libs )
             set(CHECK_Fortran_SOURCE_COMPILES_ADD_INCLUDES "-DINCLUDE_DIRECTORIES:STRING=${__add_incs}")
         endif()
-    
+
         # write the source file
-    
-        file( WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/test_${_PAR_VAR}.f" "${SOURCE}\n" )
+
+        file( WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/test_${_PAR_VAR}.F90" "${SOURCE}\n" )
 
         ecbuild_debug( "Performing Test ${_PAR_VAR}" )
         try_run( ${_PAR_VAR}_EXITCODE ${_PAR_VAR}_COMPILED
           ${CMAKE_BINARY_DIR}
-          ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/test_${_PAR_VAR}.f
+          ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/test_${_PAR_VAR}.F90
           COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
           CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS}
           -DCMAKE_SKIP_RPATH:BOOL=${CMAKE_SKIP_RPATH}
@@ -142,9 +141,9 @@ macro( ecbuild_check_fortran_source_return SOURCE )
     
           ecbuild_debug("Performing Test ${_PAR_VAR} - Failed")
           file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log 
-            "Performing C SOURCE FILE Test ${_PAR_VAR} failed with the following compile output:\n"
+            "Performing Fortran SOURCE FILE Test ${_PAR_VAR} failed with the following compile output:\n"
             "${compile_OUTPUT}\n" 
-            "Performing C SOURCE FILE Run ${_PAR_VAR} failed with the following run output:\n"
+            "Performing Fortran SOURCE FILE Run ${_PAR_VAR} failed with the following run output:\n"
             "${run_OUTPUT}\n" 
             "Return value: ${${_PAR_VAR}_EXITCODE}\n"
             "Source file was:\n${SOURCE}\n")
diff --git a/cmake/ecbuild_check_functions.cmake b/cmake/ecbuild_check_functions.cmake
index 88526b5..73f5cb5 100644
--- a/cmake/ecbuild_check_functions.cmake
+++ b/cmake/ecbuild_check_functions.cmake
@@ -169,6 +169,15 @@ if( ENABLE_OS_FUNCTIONS_TEST )
 #    ecbuild_debug_var(EC_HAVE_PROCFS)
 #    ecbuild_debug_var(EC_HAVE_PROCFS_OUTPUT)
 
+    #### check support for DL library #############
+
+    ecbuild_cache_check_include_files( dlfcn.h  EC_HAVE_DLFCN_H )
+
+    cmake_push_check_state(RESET)
+    set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_DL_LIBS} )
+    ecbuild_cache_check_c_source_compiles( "#define _GNU_SOURCE\n#include <dlfcn.h>\nint main(){ void* addr; Dl_info info; dladdr(addr, &info); }\n" EC_HAVE_DLADDR )
+    cmake_pop_check_state()
+
 endif()
 
 
diff --git a/cmake/ecbuild_config.h.in b/cmake/ecbuild_config.h.in
index dd8e9cd..df9eb91 100644
--- a/cmake/ecbuild_config.h.in
+++ b/cmake/ecbuild_config.h.in
@@ -129,6 +129,12 @@
 #cmakedefine EC_ATTRIBUTE_CONSTRUCTOR_INITS_ARGV
 #cmakedefine EC_HAVE_PROCFS
 
+
+/* --- dl library support --- */
+
+#cmakedefine EC_HAVE_DLFCN_H
+#cmakedefine EC_HAVE_DLADDR
+
 /* --- c compiler support --- */
 
 #cmakedefine EC_HAVE_C_INLINE
diff --git a/cmake/ecbuild_declare_project.cmake b/cmake/ecbuild_declare_project.cmake
index 1c2e93b..c5ef5a0 100644
--- a/cmake/ecbuild_declare_project.cmake
+++ b/cmake/ecbuild_declare_project.cmake
@@ -28,29 +28,63 @@
 # :<PNAME>_MINOR_VERSION:  minor version number
 # :<PNAME>_PATCH_VERSION:  patch version number
 # :INSTALL_BIN_DIR:        relative install directory for executables
-#                          (default: ``bin``)
 # :INSTALL_LIB_DIR:        relative install directory for libraries
-#                          (default: ``lib``)
 # :INSTALL_INCLUDE_DIR:    relative install directory for include files
-#                          (default: ``include``)
 # :INSTALL_DATA_DIR:       relative install directory for data
-#                          (default: ``share/<project_name>``)
 # :INSTALL_CMAKE_DIR:      relative install directory for CMake files
-#                          (default: ``share/<project_name>/cmake``)
 #
 # The relative installation directories of components can be customised by
 # setting the following CMake variables on the command line or in cache:
 #
-# :<PNAME>_INSTALL_BIN_DIR:     directory for installing executables
-# :<PNAME>_INSTALL_LIB_DIR:     directory for installing libraries
-# :<PNAME>_INSTALL_INCLUDE_DIR: directory for installing include files
-# :<PNAME>_INSTALL_DATA_DIR:    directory for installing data
-# :<PNAME>_INSTALL_CMAKE_DIR:   directory for installing CMake files
+# :INSTALL_BIN_DIR:        directory for installing executables
+#                          (default: ``bin``)
+# :INSTALL_LIB_DIR:        directory for installing libraries
+#                          (default: ``lib``)
+# :INSTALL_INCLUDE_DIR:    directory for installing include files
+#                          (default: ``include``)
+# :INSTALL_DATA_DIR:       directory for installing data
+#                          (default: ``share/<project_name>``)
+# :INSTALL_CMAKE_DIR:      directory for installing CMake files
+#                          (default: ``share/<project_name>/cmake``)
 #
 # Using *relative* paths is recommended, which are interpreted relative to the
 # ``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 )
@@ -107,13 +141,40 @@ 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
 
-  set( INSTALL_BIN_DIR bin )
-  set( INSTALL_LIB_DIR lib )
-  set( INSTALL_INCLUDE_DIR include )
-  set( INSTALL_DATA_DIR share/${PROJECT_NAME} )
-  set( INSTALL_CMAKE_DIR share/${PROJECT_NAME}/cmake )
+  # Use defaults unless values are already present in cache
+  if( NOT INSTALL_BIN_DIR )
+    set( INSTALL_BIN_DIR bin )
+  endif()
+  if( NOT INSTALL_LIB_DIR )
+    set( INSTALL_LIB_DIR lib )
+  endif()
+  if( NOT INSTALL_INCLUDE_DIR )
+    set( INSTALL_INCLUDE_DIR include )
+  endif()
+  if( NOT INSTALL_DATA_DIR )
+    set( INSTALL_DATA_DIR share/${PROJECT_NAME} )
+  endif()
+  if( NOT INSTALL_CMAKE_DIR )
+    set( INSTALL_CMAKE_DIR share/${PROJECT_NAME}/cmake )
+  endif()
 
   mark_as_advanced( INSTALL_BIN_DIR )
   mark_as_advanced( INSTALL_LIB_DIR )
@@ -121,10 +182,11 @@ macro( ecbuild_declare_project )
   mark_as_advanced( INSTALL_DATA_DIR )
   mark_as_advanced( INSTALL_CMAKE_DIR )
 
-  # overrides of install dirs
+  # overrides of install dirs (deprecated in ecBuild 2.4.0)
 
   foreach( p LIB BIN INCLUDE DATA CMAKE )
     if( ${PNAME}_INSTALL_${p}_DIR )
+      ecbuild_deprecate( "Use of ${PNAME}_INSTALL_${p}_DIR is deprecated and will be removed in a future release. Use INSTALL_${p}_DIR instead." )
       set( INSTALL_${p}_DIR ${${PNAME}_INSTALL_${p}_DIR} )
     endif()
   endforeach()
diff --git a/cmake/ecbuild_download_resource.cmake b/cmake/ecbuild_download_resource.cmake
index 3b2f90e..5d394f5 100644
--- a/cmake/ecbuild_download_resource.cmake
+++ b/cmake/ecbuild_download_resource.cmake
@@ -25,6 +25,7 @@ function( ecbuild_download_resource _p_OUT _p_URL )
   if( NOT EXISTS ${_p_OUT} )
 
     find_program( CURL_PROGRAM curl )
+    mark_as_advanced(CURL_PROGRAM)
     if( CURL_PROGRAM )
       execute_process( COMMAND ${CURL_PROGRAM} --silent --show-error --fail --output ${_p_OUT} ${_p_URL}
                        WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} RESULT_VARIABLE CMD_RESULT )
diff --git a/cmake/ecbuild_find_python.cmake b/cmake/ecbuild_find_python.cmake
index 0273951..d3cf377 100644
--- a/cmake/ecbuild_find_python.cmake
+++ b/cmake/ecbuild_find_python.cmake
@@ -28,6 +28,10 @@
 # NO_LIBS : optional
 #   only search for the Python interpreter, not the libraries
 #
+# Unless ``NO_LIBS`` is set, the ``python-config`` utility, if found, is used
+# to determine the Python include directories, libraries and link line. Set the
+# CMake variable ``PYTHON_NO_CONFIG`` to use CMake's FindPythonLibs instead.
+#
 # Output variables
 # ----------------
 #
@@ -62,38 +66,34 @@ function( ecbuild_find_python )
     if(_p_UNPARSED_ARGUMENTS)
       ecbuild_critical("Unknown keywords given to ecbuild_find_python(): \"${_p_UNPARSED_ARGUMENTS}\"")
     endif()
+    if( _p_REQUIRED )
+      set( _p_REQUIRED REQUIRED )
+    else()
+      unset( _p_REQUIRED )
+    endif()
 
     # find python executable
 
-    find_package( PythonInterp )
-
-    if( NOT PYTHONINTERP_FOUND AND _p_REQUIRED )
-        ecbuild_error( "Failed to find any Python interpreter (REQUIRED)" )
+    # Search first without specifying the version, since doing so gives preference to the specified
+    # version even though a never version of the interpreter may be available
+    find_package( PythonInterp ${_p_REQUIRED} )
+
+    # If no suitable version was found, search again with the version specified
+    if( PYTHONINTERP_FOUND AND _p_VERSION )
+      if( _p_VERSION VERSION_GREATER "${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}.${PYTHON_VERSION_PATCH}" )
+        ecbuild_debug( "ecbuild_find_python: Found Python interpreter version ${PYTHON_VERSION_STRING} at ${PYTHON_EXECUTABLE}, however version ${_p_VERSION} is required. Searching again..." )
+        unset( PYTHONINTERP_FOUND )
+        unset( PYTHON_EXECUTABLE )
+        unset( PYTHON_EXECUTABLE CACHE )
+        unset( PYTHON_VERSION_MAJOR )
+        unset( PYTHON_VERSION_MINOR )
+        unset( PYTHON_VERSION_PATCH )
+        unset( PYTHON_VERSION_STRING )
+        find_package( PythonInterp "${_p_VERSION}" ${_p_REQUIRED} )
+      endif()
     endif()
 
-    # find python version
-    # execute_process( COMMAND ${PYTHON_EXECUTABLE} -V ERROR_VARIABLE _version  RESULT_VARIABLE _return ERROR_STRIP_TRAILING_WHITESPACE)
-    # if( NOT _return )
-    #    string(REGEX REPLACE ".*([0-9]+)\\.([0-9]+)\\.([0-9]+)" "\\1.\\2.\\3" PYTHON_VERSION ${_version} )
-    # endif()
-    # endif()
-
-    # ecbuild_debug( "Python version ${PYTHON_VERSION_STRING}" )
-    # ecbuild_debug_var(PYTHON_VERSION_MAJOR)
-    # ecbuild_debug_var(PYTHON_VERSION_MINOR)
-    # ecbuild_debug_var(PYTHON_VERSION_PATCH)
-
-    if( PYTHONINTERP_FOUND AND DEFINED _p_VERSION )
-        if( _p_VERSION VERSION_GREATER "${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}.${PYTHON_VERSION_PATCH}" )
-            set( PYTHONINTERP_FOUND 0 )
-            set( PYTHON_EXECUTABLE "PYTHON_EXECUTABLE-NOTFOUND" )
-            if( _p_REQUIRED )
-                ecbuild_critical( "Required python version at least ${_p_VERSION} but found only ${PYTHON_VERSION_STRING}" )
-            else()
-                ecbuild_warn( "Looking for python version at least ${_p_VERSION} but found only ${PYTHON_VERSION_STRING}\nMarking Python as NOTFOUND" )
-            endif()
-        endif()
-    endif()
+    set( __required_vars PYTHONINTERP_FOUND )
 
     if( PYTHONINTERP_FOUND )
         ecbuild_debug( "ecbuild_find_python: Found Python interpreter version ${PYTHON_VERSION_STRING} at ${PYTHON_EXECUTABLE}" )
@@ -104,15 +104,24 @@ function( ecbuild_find_python )
             execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())" OUTPUT_VARIABLE PYTHON_SITE_PACKAGES OUTPUT_STRIP_TRAILING_WHITESPACE)
         endif()
         ecbuild_debug( "ecbuild_find_python: PYTHON_SITE_PACKAGES=${PYTHON_SITE_PACKAGES}" )
-
     endif()
+
     if( PYTHONINTERP_FOUND AND NOT _p_NO_LIBS )
+        list( APPEND __required_vars PYTHONLIBS_FOUND PYTHON_LIBS_WORKING )
+
         # find python config
 
         if( PYTHON_EXECUTABLE AND EXISTS ${PYTHON_EXECUTABLE}-config )
             set(PYTHON_CONFIG_EXECUTABLE ${PYTHON_EXECUTABLE}-config CACHE PATH "" FORCE)
         else()
-            find_program( PYTHON_CONFIG_EXECUTABLE NAMES python-config python-config${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR} )
+            get_filename_component( __python_bin_dir ${PYTHON_EXECUTABLE} PATH )
+            find_program( PYTHON_CONFIG_EXECUTABLE
+                          NO_CMAKE_PATH NO_CMAKE_SYSTEM_PATH
+                          NO_CMAKE_ENVIRONMENT_PATH NO_SYSTEM_ENVIRONMENT_PATH
+                          HINTS ${__python_bin_dir}
+                          NAMES python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}-config
+                                python${PYTHON_VERSION_MAJOR}-config
+                                python-config )
         endif()
 
         ecbuild_debug_var( PYTHON_CONFIG_EXECUTABLE )
@@ -122,31 +131,58 @@ function( ecbuild_find_python )
         # The OpenBSD python packages have python-config's
         # that don't reliably report linking flags that will work.
 
-        if( PYTHON_CONFIG_EXECUTABLE AND NOT ${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD" )
+        if( PYTHON_CONFIG_EXECUTABLE AND NOT ( PYTHON_NO_CONFIG OR ${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD" ) )
             ecbuild_debug( "ecbuild_find_python: Searching for Python include directories and libraries using ${PYTHON_CONFIG_EXECUTABLE}" )
 
-            execute_process(COMMAND "${PYTHON_CONFIG_EXECUTABLE}" --ldflags
-                            OUTPUT_VARIABLE PYTHON_LIBRARIES
-                            OUTPUT_STRIP_TRAILING_WHITESPACE
-                            ERROR_QUIET)
+            if( NOT PYTHON_LIBRARY )
+              execute_process(COMMAND "${PYTHON_CONFIG_EXECUTABLE}" --prefix
+                              OUTPUT_VARIABLE PYTHON_PREFIX
+                              OUTPUT_STRIP_TRAILING_WHITESPACE
+                              ERROR_QUIET)
+
+              execute_process(COMMAND "${PYTHON_CONFIG_EXECUTABLE}" --ldflags
+                              OUTPUT_VARIABLE PYTHON_LIBRARY
+                              OUTPUT_STRIP_TRAILING_WHITESPACE
+                              ERROR_QUIET)
+
+              # Prepend -L and and set the RPATH to the lib directory under the
+              # Python install prefix unless it is a standard system prefix path
+              if( PYTHON_LIBRARY AND PYTHON_PREFIX AND NOT CMAKE_SYSTEM_PREFIX_PATH MATCHES ${PYTHON_PREFIX} )
+                set( PYTHON_LIBRARY "-L${PYTHON_PREFIX}/lib -Wl,-rpath,${PYTHON_PREFIX}/lib ${PYTHON_LIBRARY}" )
+              endif()
+
+              set( PYTHON_INCLUDE_DIR "${PYTHON_INCLUDE_DIR}" CACHE PATH
+                   "Path to where Python.h is found" FORCE )
+            endif()
+
+            if(DEFINED PYTHON_INCLUDE_PATH AND NOT DEFINED PYTHON_INCLUDE_DIR)
+              set( PYTHON_INCLUDE_DIR "${PYTHON_INCLUDE_PATH}" CACHE PATH
+                   "Path to where Python.h is found" FORCE )
+            elseif( NOT PYTHON_INCLUDE_DIR )
+              execute_process(COMMAND "${PYTHON_CONFIG_EXECUTABLE}" --includes
+                              OUTPUT_VARIABLE PYTHON_INCLUDE_DIR
+                              OUTPUT_STRIP_TRAILING_WHITESPACE
+                              ERROR_QUIET)
 
-            execute_process(COMMAND "${PYTHON_CONFIG_EXECUTABLE}" --includes
-                            OUTPUT_VARIABLE PYTHON_INCLUDE_DIRS
-                            OUTPUT_STRIP_TRAILING_WHITESPACE
-                            ERROR_QUIET)
+              string(REGEX REPLACE "^[-I]" "" PYTHON_INCLUDE_DIR "${PYTHON_INCLUDE_DIR}")
+              string(REGEX REPLACE "[ ]-I" " " PYTHON_INCLUDE_DIR "${PYTHON_INCLUDE_DIR}")
 
-            string(REGEX REPLACE "^[-I]" "" PYTHON_INCLUDE_DIRS "${PYTHON_INCLUDE_DIRS}")
-            string(REGEX REPLACE "[ ]-I" " " PYTHON_INCLUDE_DIRS "${PYTHON_INCLUDE_DIRS}")
+              separate_arguments(PYTHON_INCLUDE_DIR)
+              set( PYTHON_INCLUDE_DIR "${PYTHON_INCLUDE_DIR}" CACHE PATH
+                   "Path to where Python.h is found" FORCE )
 
-            separate_arguments(PYTHON_INCLUDE_DIRS)
+            endif()
+
+            set(PYTHON_INCLUDE_DIRS "${PYTHON_INCLUDE_DIR}")
+            set(PYTHON_LIBRARIES "${PYTHON_LIBRARY}")
+
+            find_package_handle_standard_args( PythonLibs DEFAULT_MSG
+                                               PYTHON_INCLUDE_DIRS PYTHON_LIBRARIES )
 
         else() # revert to finding pythonlibs the standard way (cmake macro)
-            ecbuild_debug( "ecbuild_find_python: Searching for Python include directories and libraries using find_package(PythonLibs)" )
+            ecbuild_debug( "ecbuild_find_python: Searching for Python include directories and libraries using find_package( PythonLibs ${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}.${PYTHON_VERSION_PATCH} ${_p_REQUIRED} )" )
 
-            find_package(PythonLibs)
-            if( PYTHON_INCLUDE_PATH AND NOT PYTHON_INCLUDE_DIRS )
-              set(PYTHON_INCLUDE_DIRS "${PYTHON_INCLUDE_PATH}")
-            endif()
+            find_package( PythonLibs "${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}.${PYTHON_VERSION_PATCH}" ${_p_REQUIRED} )
 
         endif()
 
@@ -159,25 +195,18 @@ function( ecbuild_find_python )
             try_compile( PYTHON_LIBS_WORKING ${CMAKE_CURRENT_BINARY_DIR}
                          ${__test_python}
                          CMAKE_FLAGS "-DINCLUDE_DIRECTORIES=${PYTHON_INCLUDE_DIRS}"
-                         LINK_LIBRARIES ${PYTHON_LIBRARIES} )
-
-            # set output variables
-
-            find_package_handle_standard_args( PythonLibs DEFAULT_MSG
-                                               PYTHON_INCLUDE_DIRS PYTHON_LIBRARIES PYTHON_LIBS_WORKING )
-            ecbuild_debug( "ecbuild_find_python: PYTHON_INCLUDE_DIRS=${PYTHON_INCLUDE_DIRS}" )
-            ecbuild_debug( "ecbuild_find_python: PYTHON_LIBRARIES=${PYTHON_LIBRARIES}" )
-
-        endif()
+                         LINK_LIBRARIES ${PYTHON_LIBRARIES}
+                         OUTPUT_VARIABLE __try_compile_output )
+            if( NOT PYTHON_LIBS_WORKING )
+              ecbuild_debug( "ecbuild_find_python: trying to link executable with Python libraries failed\n${__try_compile_output}" )
+            endif()
 
-        # Also set PYTHON_FOUND and Python_FOUND for compatibility with ecbuild_add_option
-        if( PYTHONLIBS_FOUND )
-          set( PYTHON_FOUND 1 )
-          set( Python_FOUND 1 )
         endif()
 
     endif()
 
+    find_package_handle_standard_args( Python DEFAULT_MSG ${__required_vars} )
+
     ecbuild_debug_var( PYTHONINTERP_FOUND )
     ecbuild_debug_var( PYTHON_FOUND )
     ecbuild_debug_var( PYTHON_EXECUTABLE )
diff --git a/cmake/ecbuild_get_cxx11_flags.cmake b/cmake/ecbuild_get_cxx11_flags.cmake
index 47d0e1a..a97fe11 100644
--- a/cmake/ecbuild_get_cxx11_flags.cmake
+++ b/cmake/ecbuild_get_cxx11_flags.cmake
@@ -23,7 +23,7 @@ function( ecbuild_get_cxx11_flags CXX11_FLAGS )
 
   include(CheckCXXCompilerFlag)
 
-  # On older cmake versions + newer compilers, 
+  # On older cmake versions + newer compilers,
   # the given version of CheckCXXCompilerFlags does not quite work.
   if(CMAKE_VERSION VERSION_LESS 2.8.9)
     macro (CHECK_CXX_COMPILER_FLAG _FLAG _RESULT)
@@ -52,7 +52,8 @@ function( ecbuild_get_cxx11_flags CXX11_FLAGS )
 
   check_cxx_compiler_flag(-std=c++11 has_std_cpp11)
   check_cxx_compiler_flag(-std=c++0x has_std_cpp0x)
-  if(MINGW) 
+  check_cxx_compiler_flag(-hstd=c++11 has_hstd_cpp11)
+  if(MINGW)
     check_cxx_compiler_flag(-std=gnu++11 has_std_gnupp11)
     check_cxx_compiler_flag(-std=gnu++0x has_std_gnupp0x)
   endif(MINGW)
@@ -60,7 +61,9 @@ function( ecbuild_get_cxx11_flags CXX11_FLAGS )
     set(${CXX11_FLAGS} "-std=gnu++11" PARENT_SCOPE)
   elseif(has_std_gnupp0x)
     set(${CXX11_FLAGS} "-std=gnu++0x" PARENT_SCOPE)
-  elseif(has_std_cpp11) 
+  elseif(has_hstd_cpp11)
+    set(${CXX11_FLAGS} "-hstd=c++11" PARENT_SCOPE)
+  elseif(has_std_cpp11)
     set(${CXX11_FLAGS} "-std=c++11" PARENT_SCOPE)
   elseif(has_std_cpp0x)
     set(${CXX11_FLAGS} "-std=c++0x" PARENT_SCOPE)
diff --git a/cmake/ecbuild_get_test_data.cmake b/cmake/ecbuild_get_test_data.cmake
index c19a760..d908399 100644
--- a/cmake/ecbuild_get_test_data.cmake
+++ b/cmake/ecbuild_get_test_data.cmake
@@ -20,6 +20,7 @@ function( _download_test_data _p_NAME _p_DIRNAME )
   #endif()
 
   find_program( CURL_PROGRAM curl )
+  mark_as_advanced(CURL_PROGRAM)
 
   if( CURL_PROGRAM )
 
diff --git a/cmake/ecbuild_install_project.cmake b/cmake/ecbuild_install_project.cmake
index 2ba472e..5e26bea 100644
--- a/cmake/ecbuild_install_project.cmake
+++ b/cmake/ecbuild_install_project.cmake
@@ -233,6 +233,18 @@ macro( ecbuild_install_project )
         endif()
     endforeach()
 
+    # Deduplicate TPL includes, libs and definitions
+    # The same TPL may indirectly be pulled in multiple times!
+    if( ${PNAME}_TPL_INCLUDE_DIRS )
+      list( REMOVE_DUPLICATES ${PNAME}_TPL_INCLUDE_DIRS )
+    endif()
+    if( ${PNAME}_TPL_LIBRARIES )
+      list( REMOVE_DUPLICATES ${PNAME}_TPL_LIBRARIES )
+    endif()
+    if( ${PNAME}_TPL_DEFINITIONS )
+      list( REMOVE_DUPLICATES ${PNAME}_TPL_DEFINITIONS )
+    endif()
+
     # Generate the project .cmake config files
     # All variables here must be (sub)project specific in order to work within bundles
     if ( NOT ECBUILD_SKIP_${PNAME}_EXPORT )
@@ -278,8 +290,6 @@ macro( ecbuild_install_project )
            set( CONF_TPL_LIBRARIES ${${PNAME}_TPL_LIBRARIES} )
         endif()
 
-        # project-config.cmake @ build tree
-
         set( CONF_TPLS ${${PNAME}_TPLS} )
 
         set( CONF_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}" "${PROJECT_BINARY_DIR}" )
@@ -288,18 +298,11 @@ macro( ecbuild_install_project )
         endif()
 
         set( CONF_TPL_INCLUDE_DIRS "" )
-        foreach( _tpl ${${PNAME}_TPLS} )
-            string( TOUPPER ${_tpl} TPL )
-            if( ${_tpl}_INCLUDE_DIRS )
-                list( APPEND CONF_TPL_INCLUDE_DIRS ${${_tpl}_INCLUDE_DIRS} )
-            elseif( ${_tpl}_INCLUDE_DIR )
-                list( APPEND CONF_TPL_INCLUDE_DIRS ${${_tpl}_INCLUDE_DIR} )
-            elseif( ${TPL}_INCLUDE_DIRS )
-                list( APPEND CONF_TPL_INCLUDE_DIRS ${${TPL}_INCLUDE_DIRS} )
-            elseif( ${TPL}_INCLUDE_DIR )
-                list( APPEND CONF_TPL_INCLUDE_DIRS ${${TPL}_INCLUDE_DIR} )
-            endif()
-        endforeach()
+        if( ${PNAME}_TPL_INCLUDE_DIRS )
+            set( CONF_TPL_INCLUDE_DIRS ${${PNAME}_TPL_INCLUDE_DIRS} )
+        endif()
+
+        # Generate <project>-import.cmake (if it exists)
 
         set( CONF_IMPORT_FILE "${LNAME}-import.cmake" )
 
@@ -323,11 +326,17 @@ macro( ecbuild_install_project )
           ecbuild_debug( "No ${CONF_IMPORT_FILE} found in ${PROJECT_SOURCE_DIR}" )
         endif()
 
+        # Generate <project>-config.cmake for use from the build tree
+
         set( _lname_config "${PROJECT_BINARY_DIR}/${LNAME}-config.cmake")
 
+        # Include directories (may) reference source and build tree and the
+        # config file is marked as coming from a build tree
         set( _is_build_dir_export ON )
         configure_file( "${_template_config}" "${_lname_config}" @ONLY )
 
+        # Generate <project>-config.cmake.tpls (if there are any TPLs)
+
         file( REMOVE ${_lname_config}.tpls.in )
 
         foreach( _tpl ${${PNAME}_TPLS} )
@@ -360,28 +369,13 @@ macro( ecbuild_install_project )
             install( FILES "${_lname_config}.tpls" DESTINATION "${INSTALL_CMAKE_DIR}" )
         endif()
 
-        # project-config.cmake @ install tree
+        # Generate <project>-config.cmake for use in the install tree
 
+        # Compute path to the include dir relative to the project's CMake dir
+        # where <project>-config.cmake is installed to
         file( RELATIVE_PATH REL_INCLUDE_DIR "${${PNAME}_FULL_INSTALL_CMAKE_DIR}" "${${PNAME}_FULL_INSTALL_INCLUDE_DIR}" )
         set( CONF_INCLUDE_DIRS "\${${PNAME}_CMAKE_DIR}/${REL_INCLUDE_DIR}" )
 
-        set( CONF_TPL_INCLUDE_DIRS "" )
-        foreach( _tpl ${${PNAME}_TPLS} )
-            string( TOUPPER ${_tpl} TPL )
-            if( ${TPL}_FULL_INSTALL_INCLUDE_DIR )
-                 list( APPEND CONF_TPL_INCLUDE_DIRS "\${${PNAME}_CMAKE_DIR}/${REL_INCLUDE_DIR}" )
-            endif()
-            if( ${_tpl}_INCLUDE_DIRS )
-                list( APPEND CONF_TPL_INCLUDE_DIRS ${${_tpl}_INCLUDE_DIRS} )
-            elseif( ${_tpl}_INCLUDE_DIR )
-                list( APPEND CONF_TPL_INCLUDE_DIRS ${${_tpl}_INCLUDE_DIR} )
-            elseif( ${TPL}_INCLUDE_DIRS )
-                list( APPEND CONF_TPL_INCLUDE_DIRS ${${TPL}_INCLUDE_DIRS} )
-            elseif( ${TPL}_INCLUDE_DIR )
-                list( APPEND CONF_TPL_INCLUDE_DIRS ${${TPL}_INCLUDE_DIR} )
-            endif()
-        endforeach()
-
         set( _is_build_dir_export OFF )
         configure_file( "${_template_config}" "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${LNAME}-config.cmake" @ONLY )
         install( FILES "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${LNAME}-config.cmake" DESTINATION "${INSTALL_CMAKE_DIR}" )
diff --git a/cmake/ecbuild_log.cmake b/cmake/ecbuild_log.cmake
index ec99495..f982d07 100644
--- a/cmake/ecbuild_log.cmake
+++ b/cmake/ecbuild_log.cmake
@@ -20,7 +20,9 @@
 # :ecbuild_warn:      logs a ``WARNING`` message if log level <= ``WARN``
 # :ecbuild_error:     logs a ``SEND_ERROR`` message if log level <= ``ERROR``
 # :ecbuild_critical:  logs a ``FATAL_ERROR`` message if log level <= ``CRITICAL``
-# :ecbuild_deprecate: logs a ``DEPRECATION`` message
+# :ecbuild_deprecate: logs a ``DEPRECATION`` message as a warning
+#                     enable CMAKE_ERROR_DEPRECATED to raise an error instead
+#                     disable CMAKE_WARN_DEPRECATED to hide deprecations
 #
 # Furthermore there are auxilliary functions for outputting CMake variables,
 # CMake lists and environment variables if the log level is ``DEBUG``:
@@ -50,10 +52,6 @@
 # ECBUILD_NO_COLOUR : bool
 #   if set, does not colour log output (by default log output is coloured)
 #
-# ECBUILD_NO_DEPRECATIONS : bool
-#   if set, does not output deprecation messages (only set this if you *really*
-#   know what you are doing!)
-#
 # Usage
 # -----
 #
@@ -113,6 +111,9 @@ endif()
 if( NOT DEFINED ECBUILD_LOG_FILE )
   set( ECBUILD_LOG_FILE ${CMAKE_BINARY_DIR}/ecbuild.log )
 endif()
+if( NOT DEFINED CMAKE_ERROR_DEPRECATED AND NOT DEFINED CMAKE_WARN_DEPRECATED )
+  set( CMAKE_WARN_DEPRECATED ON )
+endif()
 
 ##############################################################################
 
@@ -167,7 +168,15 @@ endfunction( ecbuild_error )
 function( ecbuild_deprecate )
   string(REPLACE ";" " " MSG ${ARGV})
   ecbuild_log(DEPRECATION "${MSG}")
-  if( NOT ECBUILD_NO_DEPRECATIONS )
+  # DEPRECATION message type was only introduced in CMake 3.0, provide
+  # consistent behaviour for CMake < 3.0
+  if( CMAKE_VERSION VERSION_LESS 3.0 )
+    if( CMAKE_ERROR_DEPRECATED )
+      message(FATAL_ERROR "${BoldRed}DEPRECATION - ${MSG}${ColourReset}")
+    elseif( CMAKE_WARN_DEPRECATED )
+      message(WARNING "${Yellow}DEPRECATION - ${MSG}${ColourReset}")
+    endif()
+  else()
     message(DEPRECATION "${BoldRed}${MSG}${ColourReset}")
   endif()
 endfunction( ecbuild_deprecate )
diff --git a/cmake/ecbuild_print_summary.cmake b/cmake/ecbuild_print_summary.cmake
index 4cf05cc..f9bac6d 100644
--- a/cmake/ecbuild_print_summary.cmake
+++ b/cmake/ecbuild_print_summary.cmake
@@ -59,6 +59,11 @@ macro( ecbuild_print_summary )
     ecbuild_info( "build type       : [${CMAKE_BUILD_TYPE}]" )
     ecbuild_info( "timestamp        : [${EC_BUILD_TIMESTAMP}]" )
     ecbuild_info( "install prefix   : [${CMAKE_INSTALL_PREFIX}]" )
+    ecbuild_info( "  bin dir        : [${${PNAME}_FULL_INSTALL_BIN_DIR}]" )
+    ecbuild_info( "  lib dir        : [${${PNAME}_FULL_INSTALL_LIB_DIR}]" )
+    ecbuild_info( "  include dir    : [${${PNAME}_FULL_INSTALL_INCLUDE_DIR}]" )
+    ecbuild_info( "  data dir       : [${${PNAME}_FULL_INSTALL_DATA_DIR}]" )
+    ecbuild_info( "  cmake dir      : [${${PNAME}_FULL_INSTALL_CMAKE_DIR}]" )
     if( EC_LINK_DIR )
       ecbuild_info( "links prefix     : [${EC_LINK_DIR}]" )
     endif()
diff --git a/cmake/ecbuild_separate_sources.cmake b/cmake/ecbuild_separate_sources.cmake
index b56db63..dfc74f1 100644
--- a/cmake/ecbuild_separate_sources.cmake
+++ b/cmake/ecbuild_separate_sources.cmake
@@ -35,7 +35,8 @@
 # :<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
+# :<target>_f_srcs:   list of sources with extension .f, .F, .for, f77, .f90,
+#                                                    .f95, .F77, .F90, .F95
 #
 ##############################################################################
 
@@ -60,32 +61,33 @@ macro( ecbuild_separate_sources )
 	endif()
 
 	foreach( src ${_PAR_SOURCES} )
-		if(${src} MATCHES "(\\.h|\\.hxx|\\.hh|\\.hpp|\\.H)")
+		if(${src} MATCHES "(\\.h$|\\.hxx$|\\.hh$|\\.hpp$|\\.H$)")
 			list( APPEND ${_PAR_TARGET}_h_srcs ${src} )
 		endif()
 	endforeach()
 
 	foreach( src ${_PAR_SOURCES} )
-		if(${src} MATCHES "(\\.c)")
+		if(${src} MATCHES "(\\.c$)")
 			list( APPEND ${_PAR_TARGET}_c_srcs ${src} )
 		endif()
 	endforeach()
 
 	foreach( src ${_PAR_SOURCES} )
-		if(${src} MATCHES "(\\.cc|\\.cxx|\\.cpp|\\.C)")
+		if(${src} MATCHES "(\\.cc$|\\.cxx$|\\.cpp$|\\.C$)")
 			list( APPEND ${_PAR_TARGET}_cxx_srcs ${src} )
 		endif()
 	endforeach()
 
 	foreach( src ${_PAR_SOURCES} )
-		if(${src} MATCHES "(\\.f|\\.F|\\.for|\\.f77|\\.f90|\\.f95)")
+		if(${src} MATCHES "(\\.f$|\\.F$|\\.for$|\\.f77$|\\.f90$|\\.f95$|\\.f03$|\\.f08$|\\.F77$|\\.F90$|\\.F95$|\\.F03$|\\.F08$)")
 			list( APPEND ${_PAR_TARGET}_f_srcs ${src} )
 		endif()
 	endforeach()
+	set_source_files_properties( ${${_PAR_TARGET}_f_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 )
 
-endmacro( ecbuild_separate_sources  )
+endmacro( ecbuild_separate_sources )
diff --git a/cmake/ecbuild_source_flags.cmake b/cmake/ecbuild_source_flags.cmake
index 2414765..a281f1d 100644
--- a/cmake/ecbuild_source_flags.cmake
+++ b/cmake/ecbuild_source_flags.cmake
@@ -23,8 +23,12 @@ function( ecbuild_source_flags OUT TARGET DEFAULT_FLAGS SOURCES )
   endif()
   execute_process( COMMAND ${PYTHON_EXECUTABLE} ${__gen_source_flags}
                            ${ECBUILD_SOURCE_FLAGS} ${OUTFILE} "${DEFAULT_FLAGS}"
-                           ${SOURCES} "${__debug}" )
+                           ${SOURCES} "${__debug}"
+                   RESULT_VARIABLE __res )
 
+  if( __res GREATER 0 )
+    ecbuild_error( "ecbuild_source_flags: failed generating source flags for target ${TARGET} from ${ECBUILD_SOURCE_FLAGS}" )
+  endif()
   set( ${OUT} ${OUTFILE} PARENT_SCOPE )
 
 endfunction()
diff --git a/cmake/ecbuild_system.cmake b/cmake/ecbuild_system.cmake
index a4361f7..8e7eda8 100644
--- a/cmake/ecbuild_system.cmake
+++ b/cmake/ecbuild_system.cmake
@@ -187,6 +187,7 @@ if( PROJECT_NAME STREQUAL CMAKE_PROJECT_NAME )
     include( ecbuild_add_cxx_flags )
     include( ecbuild_add_cxx11_flags )
     include( ecbuild_get_cxx11_flags )
+    include( ecbuild_check_fortran )
     include( ecbuild_add_fortran_flags )
     include( ecbuild_add_test )
     include( ecbuild_add_resources )
diff --git a/cmake/fortran_features/CheckFortranFeatures.cmake b/cmake/fortran_features/CheckFortranFeatures.cmake
new file mode 100644
index 0000000..992964f
--- /dev/null
+++ b/cmake/fortran_features/CheckFortranFeatures.cmake
@@ -0,0 +1,167 @@
+###############################################################################
+# checks
+set(Fortran_FEATURE_CHECK_DIR ${CMAKE_CURRENT_LIST_DIR} CACHE INTERNAL "fortran file directory")
+
+MACRO(fortran_check_single_feature FEATURE_NAME FEATURE_NUMBER RESULT_VAR)
+  IF (NOT DEFINED ${RESULT_VAR})
+    SET(_bindir "${CMAKE_BINARY_DIR}/fortran_feature_tests/fortran_${FEATURE_NAME}")
+
+    IF (${FEATURE_NUMBER})
+      SET(_SRCFILE_BASE ${Fortran_FEATURE_CHECK_DIR}/${FEATURE_NAME}-N${FEATURE_NUMBER})
+      SET(_LOG_NAME "\"${FEATURE_NAME}\" (N${FEATURE_NUMBER})")
+    ELSE (${FEATURE_NUMBER})
+      SET(_SRCFILE_BASE ${Fortran_FEATURE_CHECK_DIR}/${FEATURE_NAME})
+      SET(_LOG_NAME "\"${FEATURE_NAME}\"")
+    ENDIF (${FEATURE_NUMBER})
+    ecbuild_info("Checking Fortran support for ${_LOG_NAME}")
+
+    SET(_SRCFILE "${_SRCFILE_BASE}.F90")
+    SET(_SRCFILE_FAIL "${_SRCFILE_BASE}_fail.F90")
+    SET(_SRCFILE_FAIL_COMPILE "${_SRCFILE_BASE}_fail_compile.F90")
+
+    IF (CROSS_COMPILING)
+      try_compile(${RESULT_VAR} "${_bindir}" "${_SRCFILE}")
+      IF (${RESULT_VAR} AND EXISTS ${_SRCFILE_FAIL})
+        try_compile(${RESULT_VAR} "${_bindir}_fail" "${_SRCFILE_FAIL}")
+      ENDIF (${RESULT_VAR} AND EXISTS ${_SRCFILE_FAIL})
+    ELSE (CROSS_COMPILING)
+      try_run(_RUN_RESULT_VAR _COMPILE_RESULT_VAR
+          "${_bindir}" "${_SRCFILE}")
+      IF (_COMPILE_RESULT_VAR AND NOT _RUN_RESULT_VAR)
+        SET(${RESULT_VAR} TRUE)
+      ELSE (_COMPILE_RESULT_VAR AND NOT _RUN_RESULT_VAR)
+        SET(${RESULT_VAR} FALSE)
+      ENDIF (_COMPILE_RESULT_VAR AND NOT _RUN_RESULT_VAR)
+      IF (${RESULT_VAR} AND EXISTS ${_SRCFILE_FAIL})
+        try_run(_RUN_RESULT_VAR _COMPILE_RESULT_VAR
+            "${_bindir}_fail" "${_SRCFILE_FAIL}")
+        IF (_COMPILE_RESULT_VAR AND _RUN_RESULT_VAR)
+          SET(${RESULT_VAR} TRUE)
+        ELSE (_COMPILE_RESULT_VAR AND _RUN_RESULT_VAR)
+          SET(${RESULT_VAR} FALSE)
+        ENDIF (_COMPILE_RESULT_VAR AND _RUN_RESULT_VAR)
+      ENDIF (${RESULT_VAR} AND EXISTS ${_SRCFILE_FAIL})
+    ENDIF (CROSS_COMPILING)
+    IF (${RESULT_VAR} AND EXISTS ${_SRCFILE_FAIL_COMPILE})
+      try_compile(_TMP_RESULT "${_bindir}_fail_compile" "${_SRCFILE_FAIL_COMPILE}")
+      IF (_TMP_RESULT)
+        SET(${RESULT_VAR} FALSE)
+      ELSE (_TMP_RESULT)
+        SET(${RESULT_VAR} TRUE)
+      ENDIF (_TMP_RESULT)
+    ENDIF (${RESULT_VAR} AND EXISTS ${_SRCFILE_FAIL_COMPILE})
+
+    IF (${RESULT_VAR})
+      ecbuild_info("Checking Fortran support for ${_LOG_NAME} -- works")
+    ELSE (${RESULT_VAR})
+      ecbuild_info("Checking Fortran support for ${_LOG_NAME} -- not supported")
+    ENDIF (${RESULT_VAR})
+    SET(${RESULT_VAR} ${${RESULT_VAR}} CACHE INTERNAL "Fortran support for ${_LOG_NAME}")
+  ENDIF (NOT DEFINED ${RESULT_VAR})
+ENDMACRO(fortran_check_single_feature)
+
+# Find list of all features
+function(fortran_find_all_features outvar)
+  FILE(GLOB ALL_Fortran_FEATURE_FILES "${Fortran_FEATURE_CHECK_DIR}/*.F90")
+  set(OUTPUT_VARIABLES)
+  foreach(filename ${ALL_Fortran_FEATURE_FILES})
+    get_filename_component(filename ${filename} NAME_WE)
+    string(REGEX REPLACE "_fail_compile" "" filename "${filename}")
+    string(REGEX REPLACE "_fail" "" filename "${filename}")
+    string(REGEX REPLACE "-N[0-9]*" "" filename "${filename}")
+    set(OUTPUT_VARIABLES ${OUTPUT_VARIABLES} ${filename})
+  endforeach()
+  list(REMOVE_DUPLICATES OUTPUT_VARIABLES)
+  set(${outvar} ${OUTPUT_VARIABLES} PARENT_SCOPE)
+endfunction()
+
+# Parses input and separates into arguments before REQUIRED and after REQUIRED.
+# Arguments before REQUIRED are OPTIONALS.
+# Arguments after REQUIRED are REQUIRED.
+# If no arguments, then sets output OPTIONALS to ALLFEATURES.
+function(parse_input_features ALLFEATURES OPTIONALS REQUIRED ERRORS)
+
+  if("${ARGN}" STREQUAL "")
+    set(${OPTIONALS} ${ALLFEATURES} PARENT_SCOPE)
+    set(${REQUIRED} "" PARENT_SCOPE)
+  else()
+    set(REQUIRED_FEATURES)
+    set(OPTIONAL_FEATURES)
+    set(UNKNOWN_FEATURES)
+    set(result_type OPTIONAL_FEATURES)
+    foreach(feature ${ARGN})
+      if(${feature} STREQUAL "REQUIRED")
+        set(result_type REQUIRED_FEATURES)
+      else()
+        list(FIND ALLFEATURES ${feature} feature_was_found)
+
+        if(feature_was_found EQUAL -1)
+          list(APPEND UNKNOWN_FEATURES ${feature})
+        else()
+          list(APPEND ${result_type} ${feature})
+        endif()
+
+      endif(${feature} STREQUAL "REQUIRED")
+    endforeach()
+
+    set(${OPTIONALS} ${OPTIONAL_FEATURES} PARENT_SCOPE)
+    set(${REQUIRED} ${REQUIRED_FEATURES} PARENT_SCOPE)
+    set(${ERRORS} ${UNKNOWN_FEATURES} PARENT_SCOPE)
+  endif("${ARGN}" STREQUAL "")
+endfunction(parse_input_features)
+
+# Figures out name and number of feature
+# then calls macro that does the work
+macro(_figure_out_fortran_feature current_feature)
+  # Find set of files that match current_feature, excepting _fail and _fail_compile.
+  file(GLOB ALL_FEATURE_FILES "${Fortran_FEATURE_CHECK_DIR}/${current_feature}*.F90")
+  foreach(filename ${ALL_FEATURE_FILES})
+    if(filename MATCHES "_fail")
+      list(REMOVE_ITEM ALL_FEATURE_FILES ${filename})
+    endif()
+  endforeach()
+
+  list(LENGTH ALL_FEATURE_FILES NFILES)
+  if(NOT ${NFILES} EQUAL 1)
+    ecbuild_critical("[Fortran] Expected to find only one feature. Found ${NFILES} -- ${ALL_FEATURE_FILES}.")
+  endif(NOT ${NFILES} EQUAL 1)
+
+  # Now we know which file corresponds to option.
+  get_filename_component(basename ${ALL_FEATURE_FILES} NAME_WE)
+  # If has feature number, extract it
+  set(number "")
+  if(basename MATCHES "-N[0-9]*$")
+    string(REGEX REPLACE "${current_feature}-N" "" number "${basename}")
+  endif()
+  # Then call macro
+  string(TOUPPER ${current_feature} UPPER_OPTIONAL)
+  set(VARNAME HAS_Fortran_${UPPER_OPTIONAL})
+  fortran_check_single_feature(${current_feature} "${number}" ${VARNAME})
+endmacro(_figure_out_fortran_feature)
+
+function(fortran_feature_check)
+
+  # find all features
+  fortran_find_all_features(ALL_Fortran_FEATURES)
+
+  # Parses input to this function.
+  parse_input_features("${ALL_Fortran_FEATURES}" OPTIONALS REQUIRED ERRORS ${ARGN})
+  if(NOT ${ERRORS} STREQUAL "")
+    ecbuild_info("[Fortran] The following features are unknown: ${ERRORS}.")
+  endif()
+
+  # Check optional features
+  foreach(current_feature ${OPTIONALS})
+    _figure_out_fortran_feature(${current_feature})
+  endforeach(current_feature ${ARGN})
+
+  # Check required features
+  foreach(current_feature ${REQUIRED})
+    _figure_out_fortran_feature(${current_feature})
+    set(VARNAME HAS_Fortran_${UPPER_OPTIONAL})
+    if(NOT ${VARNAME})
+      ecbuild_critical("[Fortran] Required feature ${current_feature} is not available.")
+    endif(NOT ${VARNAME})
+  endforeach(current_feature ${REQUIRED})
+
+endfunction(fortran_feature_check)
diff --git a/cmake/fortran_features/c_size_t.F90 b/cmake/fortran_features/c_size_t.F90
new file mode 100644
index 0000000..3c47136
--- /dev/null
+++ b/cmake/fortran_features/c_size_t.F90
@@ -0,0 +1,8 @@
+program test_c_sizeof
+use, intrinsic :: iso_c_binding, only : c_size_t, c_int, c_long
+
+write(0,*) "c_int    = ",c_int
+write(0,*) "c_long   = ",c_long
+write(0,*) "c_size_t = ",c_size_t
+
+end program
\ No newline at end of file
diff --git a/cmake/fortran_features/c_sizeof.F90 b/cmake/fortran_features/c_sizeof.F90
new file mode 100644
index 0000000..fc1be41
--- /dev/null
+++ b/cmake/fortran_features/c_sizeof.F90
@@ -0,0 +1,3 @@
+program test_c_sizeof
+use, intrinsic :: iso_c_binding, only : c_sizeof
+end program
\ No newline at end of file
diff --git a/cmake/fortran_features/derivedtype_interface.F90 b/cmake/fortran_features/derivedtype_interface.F90
new file mode 100644
index 0000000..d59a1c3
--- /dev/null
+++ b/cmake/fortran_features/derivedtype_interface.F90
@@ -0,0 +1,54 @@
+module constructor
+
+implicit none
+
+TYPE :: AnimalType
+  private
+  integer :: m_age
+contains
+  procedure :: age
+  procedure :: speak
+ENDTYPE
+
+! Declare constructor as interface with same name as type
+interface AnimalType
+  module procedure AnimalType__ctor
+end interface
+
+contains
+
+function AnimalType__ctor(age) result(self)
+  type(AnimalType) :: self
+  integer :: age
+  write(0,'(A)') "Constructor Animal"
+  self%m_age = age
+end function
+
+function age(self)
+  class(AnimalType), intent(inout) :: self
+  integer :: age
+  age = self%m_age
+end function
+
+subroutine speak(self)
+  class(AnimalType), intent(in) :: self
+  write(0,'(A)') "Animal::speak not overridden"
+end subroutine
+
+end module
+
+! ------------------------------------------------------------------------
+
+program test_constructor
+use constructor
+implicit none
+
+  type(AnimalType) :: animal
+
+  animal = AnimalType(8)
+
+  write(0,'(A,I0)') "age = ",animal%age()
+
+  call animal%speak()
+
+end program
diff --git a/cmake/fortran_features/derivedtype_io.F90 b/cmake/fortran_features/derivedtype_io.F90
new file mode 100644
index 0000000..47a98b0
--- /dev/null
+++ b/cmake/fortran_features/derivedtype_io.F90
@@ -0,0 +1,42 @@
+module write_module
+
+implicit none
+
+TYPE :: AnimalType
+  integer :: m_age
+  integer :: m_paws
+contains
+  procedure :: writetype
+  generic :: write(formatted) => writetype
+ENDTYPE
+
+contains
+
+subroutine writetype(animal, unit, iotype, v_list, iostat, iomsg)
+  ! Argument names here from the std, but you can name them differently.
+  class(AnimalType), intent(in) :: animal ! Object to write.
+  integer, intent(in) :: unit             ! Internal unit to write to.
+  character(*), intent(in) :: iotype      ! LISTDIRECTED or DTxxx
+  integer, intent(in) :: v_list(:)        ! parameters from fmt spec.
+  integer, intent(out) :: iostat          ! non zero on error, etc.
+  character(*), intent(inout) :: iomsg    ! define if iostat non zero.
+
+  write (unit, "(A)", IOSTAT=iostat, IOMSG=iomsg) &
+      "I am a dog"
+end subroutine writetype
+
+end module
+
+! ------------------------------------------------------------------------
+
+program test_write
+use write_module
+implicit none
+
+  type(AnimalType) :: animal
+
+  animal = AnimalType(8,4)
+
+  write(0,'(A,DT)') 'Custom writing: ',animal
+
+end program
diff --git a/cmake/fortran_features/finalization.F90 b/cmake/fortran_features/finalization.F90
new file mode 100644
index 0000000..5bacd5f
--- /dev/null
+++ b/cmake/fortran_features/finalization.F90
@@ -0,0 +1,141 @@
+module final_module
+
+implicit none
+
+integer :: final_counted = 0
+integer :: destroy_counted = 0
+
+TYPE :: AnimalType
+  character(len=20), private :: m_kind = "unidentified"
+  logical :: constructed = .false.
+contains
+  procedure :: speak
+  final :: AnimalType__dtor
+ENDTYPE
+
+interface AnimalType
+  module procedure AnimalType__ctor
+end interface
+
+interface assignment(=)
+  module procedure AnimalType__assignment
+end interface
+
+contains
+
+subroutine speak(self)
+  class(AnimalType), intent(in) :: self
+  write(0,'(2A)') "I am a ",self%m_kind
+end subroutine
+
+subroutine AnimalType__dtor(self)
+  type(AnimalType), intent(inout) :: self
+
+  write(0,'(2A)') "Final animal ",self%m_kind
+  final_counted = final_counted + 1
+
+  ! Destruction guard needed for portability
+  if( self%constructed ) then
+    write(0,'(2A)') "    Destroy animal ",self%m_kind
+    destroy_counted = destroy_counted + 1
+  endif
+end subroutine
+
+function AnimalType__ctor(animaltype_) result(self)
+  type(AnimalType) :: self
+  character(len=*) :: animaltype_
+  self%m_kind = animaltype_
+  write(0,'(3A,I0)') "Constructing animal ",self%m_kind, " -- address = ",loc(self)
+  self%constructed = .true.
+end function
+
+subroutine AnimalType__assignment(animal_out,animal_in)
+  type(AnimalType), intent(out) :: animal_out
+  class(AnimalType), intent(in) :: animal_in
+  write(0,'(3A,I0,A,I0)') '   Copying ',animal_in%m_kind, " -- from address ", loc(animal_in), " to address ", loc(animal_out)
+  animal_out%m_kind = animal_in%m_kind
+  animal_out%constructed = animal_in%constructed
+end subroutine
+
+end module
+
+! ------------------------------------------------------------------------
+
+subroutine scope_test
+use final_module
+implicit none
+
+  type(AnimalType) :: dog
+  type(AnimalType) :: cat
+
+  dog = AnimalType("dog")  ! Cray       : final called on temporary AnimalType("dog"); missing final call on dog before assignment
+                           ! Intel      : final called on dog before assignment; and on temporary AnimalType("dog")
+                           ! PGI 14.4   : final NOT called at all, possibly compiler bug
+                           ! GNU 4.9    : final called on dog before assignment; missing call on temporary AnimalType("dog")
+  call dog%speak()
+
+  ! final called on dog when out of scope
+end subroutine
+
+! -------------------------------------------------------
+
+subroutine assignment_test
+use final_module
+implicit none
+
+  type(AnimalType) :: dog
+  type(AnimalType) :: animal
+
+  dog = AnimalType("dog")    ! final called on dog before assignment
+  call dog%speak()
+  write(0,'(A)') "-- animal = dog"
+  animal = dog               ! final called on animal before assignment
+  call animal%speak()
+
+  ! final called on dog when out of scope
+  ! final called on animal when out of scope
+end subroutine
+
+! -------------------------------------------------------
+
+program test_final
+use final_module
+implicit none
+  logical :: test_failed = .false.
+
+  final_counted = 0
+  destroy_counted = 0
+
+  write(0,'(A)') " "
+  write(0,'(A)') ">>>>>> begin scope_test"
+  call scope_test
+  write(0,'(A)') "<<<<<< end scope_test"
+  write(0,'(A)') " "
+
+  write(0,'(A,I0)') "final_counted = ", final_counted
+  write(0,'(A,I0)') "destroy_counted = ", destroy_counted
+
+  if( destroy_counted < 1 ) then
+    test_failed = .true.
+    write(0,'(A)') "ASSERTION FAILED: destroy_counted < 1"
+  endif
+
+  final_counted = 0
+  destroy_counted = 0
+
+  write(0,'(A)') " "
+  write(0,'(A)') ">>>>>> begin assignment_test"
+  call assignment_test
+  write(0,'(A)') "<<<<<< end assignment_test"
+  write(0,'(A)') " "
+
+  write(0,'(A,I0)') "final_counted = ", final_counted
+  write(0,'(A,I0)') "destroy_counted = ", destroy_counted
+
+  if( destroy_counted < 2 ) then
+    test_failed = .true.
+    write(0,*) "ASSERTION FAILED: destroy_counted < 2"
+  endif
+  if( test_failed ) STOP 1
+
+end program
diff --git a/cmake/fortran_features/submodules.F90 b/cmake/fortran_features/submodules.F90
new file mode 100644
index 0000000..3a2261f
--- /dev/null
+++ b/cmake/fortran_features/submodules.F90
@@ -0,0 +1,35 @@
+module sb_module
+implicit none
+integer :: a = 1
+
+interface
+  module subroutine sb
+  end subroutine
+end interface
+
+contains
+end module sb_module
+
+! -------------------------------------------------------
+
+submodule (sb_module) sb_submod1
+implicit none
+integer :: b = 2
+
+contains
+
+module subroutine sb()
+  a = b
+end subroutine
+
+end submodule sb_submod1
+
+! -------------------------------------------------------
+
+program test_submodule
+use sb_module
+implicit none
+write(0,*) a
+call sb()
+write(0,*) a
+end program
\ No newline at end of file
diff --git a/debian/libemos-dev.install b/debian/libemos-dev.install
deleted file mode 100644
index 444e90b..0000000
--- a/debian/libemos-dev.install
+++ /dev/null
@@ -1,6 +0,0 @@
-pbio/*.h		usr/include/pbio
-gribex/*.h		usr/include/gribex
-interpolation/*.h	usr/include/interpolation
-obj-*/e*.pc		usr/lib/x86_64-linux-gnu/pkgconfig
-lib/*.a		usr/lib/x86_64-linux-gnu
-share/libemos/cmake/*	usr/lib/x86_64-linux-gnu/cmake/libemos
diff --git a/debian/libemos0d.install b/debian/libemos0d.install
deleted file mode 100644
index c202b25..0000000
--- a/debian/libemos0d.install
+++ /dev/null
@@ -1 +0,0 @@
-lib/*.0d	usr/lib/x86_64-linux-gnu
diff --git a/interpolation/igdiwe.F b/interpolation/igdiwe.F
index 54f2c07..7ce951c 100644
--- a/interpolation/igdiwe.F
+++ b/interpolation/igdiwe.F
@@ -297,6 +297,9 @@ C         set grid increments
             DO WHILE (LO.LT.0.)
               LO = LO + 360.
             ENDDO
+            DO WHILE (LO.GE.360.)
+              LO = LO - 360.
+            ENDDO
 
             I = MOD(FLOOR( LO/IDELTA ),KIWE) + 1
             KWEIND (JP_I_W,J) = I
diff --git a/libemos-4.4.3-Source.tar.gz?api=v2 b/libemos-4.4.3-Source.tar.gz?api=v2
deleted file mode 100644
index 9b77152..0000000
Binary files a/libemos-4.4.3-Source.tar.gz?api=v2 and /dev/null differ
diff --git a/pbio/emosnum.F b/pbio/emosnum.F
index 8774baa..c4888fe 100644
--- a/pbio/emosnum.F
+++ b/pbio/emosnum.F
@@ -88,7 +88,7 @@ C
       CHARACTER*35 CMESS
 C     CHARACTER*20 YNUMBER
 C
-      DATA INUMBER/000443/, ICOUNT/0/
+      DATA INUMBER/000444/, ICOUNT/0/
       DATA CMESS/'* EMOSLIB version number = ****** *'/
 C
 C ------------------------------------------------------------------
diff --git a/share/ecbuild/toolchains/ichec-fionn-Intel.cmake b/share/ecbuild/toolchains/ichec-fionn-Intel.cmake
new file mode 100644
index 0000000..184dfb5
--- /dev/null
+++ b/share/ecbuild/toolchains/ichec-fionn-Intel.cmake
@@ -0,0 +1,67 @@
+####################################################################
+# ARCHITECTURE
+####################################################################
+
+
+####################################################################
+# COMPILER
+####################################################################
+
+include(CMakeForceCompiler)
+
+CMAKE_FORCE_C_COMPILER       ( icc  Intel )
+CMAKE_FORCE_CXX_COMPILER     ( icpc  Intel )
+CMAKE_FORCE_Fortran_COMPILER ( ifort Intel )
+
+####################################################################
+# OpenMP FLAGS
+####################################################################
+
+set( OMP_C_FLAGS             "-openmp -openmp-threadprivate=compat" )
+set( OMP_CXX_FLAGS           "-openmp -openmp-threadprivate=compat" )
+set( OMP_Fortran_FLAGS       "-openmp -openmp-threadprivate=compat" )
+
+####################################################################
+# COMMON FLAGS
+####################################################################
+
+# for diagnostics:
+#  -diag-enable=vec -diag-file -Winline
+
+set( ECBUILD_C_FLAGS       "-fp-speculation=strict -fp-model precise -traceback")
+set( ECBUILD_CXX_FLAGS     "-fp-speculation=strict -fp-model precise -traceback" )
+set( ECBUILD_Fortran_FLAGS "-fp-speculation=strict -fp-model source  -convert big_endian -assume byterecl -traceback -fpe0" )
+
+####################################################################
+# BIT REPRODUCIBLE FLAGS
+####################################################################
+
+set( ECBUILD_C_FLAGS_BIT        "-O2 -xAVX -finline-function -finline-limit=500" )
+set( ECBUILD_CXX_FLAGS_BIT      "-O2 -xAVX -finline-function -finline-limit=500" )
+set( ECBUILD_Fortran_FLAGS_BIT  "-O2 -xAVX -finline-function -finline-limit=500 -align array64byte" )
+
+####################################################################
+# DEBUG FLAGS
+####################################################################
+
+set( ECBUILD_C_FLAGS_DEBUG        "-O0 -g -traceback -fp-trap=common" )
+set( ECBUILD_CXX_FLAGS_DEBUG      "-O0 -g -traceback -fp-trap=common" )
+# -check all implies -check bounds
+set( ECBUILD_Fortran_FLAGS_DEBUG  "-O0 -g -traceback -warn all -heap-arrays -fpe-all=0 -fpe:0 -check all" )
+
+####################################################################
+# 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" )
+
+###################################################################
+# 
+# Serial versions of these packages (need to specify intel_mpi versions? )
+###################################################################
+
+set( FFTW_PATH    "/ichec/packages/fftw/intel/3.3.4")
+set( NETCDF_PATH  "/ichec/packages/netcdf/intel/4.4.0")
+set( HDF5_PATH    "/ichec/packages/hdf5/intel/1.8.16")

-- 
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