-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
IFS-2479 Extract ecwam build system, and find ecwam instead
- Loading branch information
1 parent
690f64c
commit 2e989d7
Showing
26 changed files
with
7,152 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
.tags* | ||
CMakeLists.txt.user* | ||
*.autosave | ||
doc/html | ||
doc/latex | ||
*.sublime-workspace | ||
*.swp | ||
.nfs* | ||
build/* | ||
install/* | ||
env.sh | ||
*.DS_Store | ||
.vscode | ||
*.mod |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
# (C) Copyright 2022- 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. | ||
|
||
cmake_minimum_required( VERSION 3.12 FATAL_ERROR ) | ||
find_package( ecbuild 3.4 REQUIRED HINTS ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/../ecbuild ) | ||
|
||
if( NOT ECWAM_PROJECT_NAME ) | ||
set( ECWAM_PROJECT_NAME ecwam ) | ||
endif() | ||
|
||
project( ${ECWAM_PROJECT_NAME} LANGUAGES Fortran C CXX ) | ||
|
||
include( ecwam_macros ) | ||
ecbuild_enable_fortran( REQUIRED NO_MODULE_DIRECTORY ) | ||
|
||
### Dependencies | ||
|
||
ecbuild_find_package( fiat REQUIRED ) | ||
ecbuild_find_package( eccodes REQUIRED ) | ||
|
||
|
||
### Options | ||
|
||
ecbuild_add_option( FEATURE OMP | ||
DESCRIPTION "support for OpenMP shared memory parallelism" | ||
REQUIRED_PACKAGES "OpenMP COMPONENTS Fortran" ) | ||
|
||
ecbuild_add_option( FEATURE MPI | ||
DESCRIPTION "Support for MPI distributed parallelism" | ||
REQUIRED_PACKAGES "MPI COMPONENTS Fortran" ) | ||
|
||
ecbuild_add_option( FEATURE MULTIO | ||
DESCRIPTION "Support for IO to the FDB" | ||
REQUIRED_PACKAGES "multio" ) | ||
|
||
ecbuild_add_option( FEATURE SINGLE_PRECISION | ||
DEFAULT OFF | ||
DESCRIPTION "Support for Single Precision" ) | ||
|
||
ecbuild_add_option( FEATURE UNWAM | ||
DEFAULT OFF | ||
DESCRIPTION "Support for UNWAM" ) | ||
|
||
ecbuild_add_option( FEATURE OCEAN_COUPLING | ||
DEFAULT ON | ||
DESCRIPTION "Support ocean coupling" | ||
CONDITION ${PNAME}_OCEAN_LIBRARIES ) | ||
|
||
### Set third party libraries | ||
|
||
if( HAVE_SINGLE_PRECISION ) | ||
set( prec sp ) | ||
else() | ||
set( prec dp ) | ||
endif() | ||
|
||
unset( OpenMP_Fortran_LIBRARIES ) | ||
if( HAVE_OMP ) | ||
set( OpenMP_Fortran_LIBRARIES OpenMP::OpenMP_Fortran ) | ||
endif() | ||
|
||
### Sources | ||
|
||
include(ecwam_compile_flags) | ||
add_subdirectory(src) | ||
|
||
### Tests | ||
|
||
add_subdirectory(tests) | ||
|
||
### Documentation | ||
|
||
add_subdirectory(doc) | ||
|
||
### Export | ||
|
||
ecbuild_install_project( NAME ${PROJECT_NAME} ) | ||
|
||
ecbuild_print_summary() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
ecWAM | ||
***** | ||
|
||
The ECMWF wave model WAM | ||
|
||
Introduction | ||
============ | ||
|
||
|
||
License | ||
======= | ||
|
||
ecWAM is distributed under the Apache License Version 2.0. | ||
See `LICENSE` file for details. | ||
|
||
Installing ecWAM | ||
================ | ||
|
||
Supported Platforms | ||
------------------- | ||
|
||
- Linux | ||
- Apple MacOS | ||
|
||
Other UNIX-like operating systems may work too out of the box. | ||
|
||
Requirements | ||
------------ | ||
- Fortran and C compiler, and optionally C++ compiler | ||
- CMake (see https://cmake.org) | ||
- ecbuild (see https://github.com/ecmwf/ecbuild) | ||
- fiat | ||
- eccodes | ||
|
||
Further optional dependencies: | ||
- MPI Fortran libraries | ||
- multio | ||
- NEMO | ||
|
||
Building ecWAM | ||
------------- | ||
|
||
Environment variables | ||
|
||
$ export ecbuild_ROOT=<path-to-ecbuild> | ||
$ export MPI_HOME=<path-to-MPI> | ||
$ export fiat_ROOT=<path-to-fiat> | ||
$ export CC=<path-to-C-compiler> | ||
$ export FC=<path-to-Fortran-compiler> | ||
$ export CXX=<path-to-C++-compiler> | ||
|
||
You must compile ecWAM out-of-source, so create a build-directory | ||
|
||
$ mkdir build && cd build | ||
|
||
Configuration of the build happens through standard CMake | ||
|
||
$ cmake .. | ||
|
||
Extra options can be added to the `cmake` command to control the build: | ||
|
||
- `-DCMAKE_BUILD_TYPE=<Debug|RelWithDebInfo|Release|Bit>` default=RelWithDebInfo (typically `-O2 -g`) | ||
- `-DENABLE_TESTS=<ON|OFF>` | ||
- `-DENABLE_MPI=<ON|OFF>` | ||
- `-DENABLE_OMP=<ON|OFF>` | ||
- `-DCMAKE_INSTALL_PREFIX=<install-prefix>` | ||
|
||
More options to control compilation flags, only when defaults are not sufficient | ||
|
||
- `-DOpenMP_Fortran_FLAGS=<flags>` | ||
- `-DCMAKE_Fortran_FLAGS=<fortran-flags>` | ||
- `-DCMAKE_C_FLAGS=<c-flags>` | ||
|
||
Once this has finished successfully, run ``make`` and ``make install``. | ||
|
||
Optionally, tests can be run to check succesful compilation, when the feature TESTS is enabled (`-DENABLE_TESTS=ON`, default ON) | ||
|
||
$ ctest | ||
|
||
Reporting Bugs | ||
============== | ||
|
||
TODO | ||
|
||
Contributing | ||
============ | ||
|
||
TODO | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
1.0.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# (C) Copyright 2013 ECMWF. | ||
# | ||
# This software is licensed under the terms of the Apache Licence Version 2.0 | ||
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. | ||
# In applying this licence, ECMWF does not waive the privileges and immunities | ||
# granted to it by virtue of its status as an intergovernmental organisation nor | ||
# does it submit to any jurisdiction. | ||
|
||
############################################################################### | ||
|
||
# find FORD Fortran documentation generator | ||
find_program( FORD_EXECUTABLE ford QUIET DOC "Fortran documentation generator" ) | ||
|
||
if( FORD_EXECUTABLE ) | ||
set( FORD_FOUND TRUE ) | ||
endif() | ||
|
||
mark_as_advanced(FORD_EXECUTABLE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# (C) Copyright 2022- 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. | ||
|
||
# Import for ecwam pproject | ||
# | ||
# This file is included during | ||
# | ||
# find_package( ecwam [COMPONENTS (double|single)] [QUIET] [REQUIRED] ) | ||
# | ||
# Supported COMPONENTS: double single | ||
# | ||
# If available following targets will be exported: | ||
# - ecwam_dp Double precision ecwam library | ||
# - ecwam_sp Single precision ecwam library | ||
# | ||
|
||
################################################################## | ||
## Export project variables | ||
|
||
set( ${CMAKE_FIND_PACKAGE_NAME}_VERSION_STR @PROJECT_VERSION@ ) | ||
set( ${CMAKE_FIND_PACKAGE_NAME}_HAVE_MPI @HAVE_MPI@ ) | ||
set( ${CMAKE_FIND_PACKAGE_NAME}_HAVE_OMP @HAVE_OMP@ ) | ||
set( ${CMAKE_FIND_PACKAGE_NAME}_HAVE_SINGLE_PRECISION @HAVE_SINGLE_PRECISION@ ) | ||
set( ${CMAKE_FIND_PACKAGE_NAME}_HAVE_DOUBLE_PRECISION @HAVE_DOUBLE_PRECISION@ ) | ||
set( ${CMAKE_FIND_PACKAGE_NAME}_HAVE_UNWAM @HAVE_UNWAM@ ) | ||
|
||
if( NOT ${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY ) | ||
message( STATUS "Found ecwam version ${${CMAKE_FIND_PACKAGE_NAME}_VERSION_STR}" ) | ||
endif() | ||
|
||
################################################################## | ||
## Export project dependencies | ||
|
||
include( CMakeFindDependencyMacro ) | ||
|
||
################################################################## | ||
## Handle components | ||
|
||
set( ${CMAKE_FIND_PACKAGE_NAME}_single_FOUND ${${CMAKE_FIND_PACKAGE_NAME}_HAVE_SINGLE_PRECISION} ) | ||
set( ${CMAKE_FIND_PACKAGE_NAME}_double_FOUND ${${CMAKE_FIND_PACKAGE_NAME}_HAVE_DOUBLE_PRECISION} ) | ||
|
||
foreach( _component ${${CMAKE_FIND_PACKAGE_NAME}_FIND_COMPONENTS} ) | ||
if( NOT ${CMAKE_FIND_PACKAGE_NAME}_${_component}_FOUND AND ${CMAKE_FIND_PACKAGE_NAME}_FIND_REQUIRED ) | ||
message( SEND_ERROR "${CMAKE_FIND_PACKAGE_NAME} was not build with support for COMPONENT ${_component}" ) | ||
endif() | ||
endforeach() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# (C) Copyright 2022- 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. | ||
|
||
if(CMAKE_Fortran_COMPILER_ID MATCHES "Cray") | ||
set(autopromote_flags "-sreal64") | ||
set(convertendian_flags "-hbyteswapio") | ||
set(checkbounds_flags "-Rb") | ||
set(fpe_flags "-Ktrap=fp") | ||
set(initsnan_flags "-ei") | ||
elseif(CMAKE_Fortran_COMPILER_ID MATCHES "GNU") | ||
set(autopromote_flags "-fdefault-real-8 -fdefault-double-8") | ||
set(convertendian_flags "-fconvert=big-endian" ) | ||
set(checkbounds_flags "-fcheck=bounds") | ||
set(fpe_flags "-ffpe-trap=invalid,zero,overflow") | ||
set(initsnan_flags "-finit-real=snan") | ||
if( NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 10 ) | ||
ecbuild_add_fortran_flags( "-fallow-argument-mismatch" NAME argument_mismatch ) | ||
endif() | ||
elseif(CMAKE_Fortran_COMPILER_ID MATCHES "Intel") | ||
set(autopromote_flags "-real-size 64") | ||
set(convertendian_flags "-convert big_endian") | ||
set(checkbounds_flags "-check bounds") | ||
set(initsnan_flags "-init=snan") | ||
set(fpe_flags "-fpe0") | ||
elseif(CMAKE_Fortran_COMPILER_ID MATCHES "PGI|NVHPC") | ||
set(autopromote_flags "-r8") | ||
set(convertendian_flags "-Mbyteswapio") | ||
set(checkbounds_flags "-Mbounds") | ||
set(fpe_flags "-Ktrap=fp") | ||
endif() | ||
|
||
if( NOT HAVE_SINGLE_PRECISION ) | ||
ecbuild_add_fortran_flags( "${autopromote_flags}" NAME autopromote ) | ||
endif() | ||
ecbuild_add_fortran_flags( "${convertendian_flags}" NAME convert_bigendian ) | ||
|
||
if( CMAKE_BUILD_TYPE MATCHES "Debug" ) | ||
if( fpe_flags ) | ||
ecbuild_add_fortran_flags( "${fpe_flags}" NAME fpe) | ||
endif() | ||
if( initsnan_flags ) | ||
ecbuild_add_fortran_flags( "${initsnan_flags}" NAME initsnan) | ||
endif() | ||
if( checkbounds_flags ) | ||
ecbuild_add_fortran_flags( "${checkbounds_flags}" NAME checkbounds) | ||
endif() | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ecwam-import.cmake.in |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# (C) Copyright 2020- 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. | ||
|
||
### Workaround to extract GIT_SHA1 from parent directory | ||
if( NOT ${PROJECT_NAME}_GIT_SHA1 ) | ||
get_filename_component( PARENT_DIR ${PROJECT_SOURCE_DIR} DIRECTORY ) | ||
if( EXISTS ${PARENT_DIR}/.git ) | ||
get_filename_component( PARENT_REPOSITORY_NAME ${PARENT_DIR} NAME_WE ) | ||
get_git_head_revision( GIT_REFSPEC ${PROJECT_NAME}_GIT_SHA1 ) | ||
string( SUBSTRING "${${PROJECT_NAME}_GIT_SHA1}" 0 7 ${PROJECT_NAME}_GIT_SHA1_SHORT ) | ||
set( ${PROJECT_NAME}_GIT_SHA1_SHORT "${PARENT_REPOSITORY_NAME}/${${PROJECT_NAME}_GIT_SHA1_SHORT}" ) | ||
set( ${PROJECT_NAME}_GIT_SHA1 "${PARENT_REPOSITORY_NAME}/${${PROJECT_NAME}_GIT_SHA1}" ) | ||
endif() | ||
endif() | ||
|
||
find_program( FCM_EXECUTABLE fcm DOC "Fortran interface generator" | ||
HINTS | ||
${CMAKE_SOURCE_DIR}/fcm | ||
${CMAKE_BINARY_DIR}/fcm | ||
${fcm_ROOT} | ||
ENV fcm_ROOT | ||
PATH_SUFFIXES bin ) | ||
if (NOT FCM_EXECUTABLE) | ||
include(FetchContent) | ||
FetchContent_Populate( | ||
fcm | ||
GIT_REPOSITORY https://github.com/metomi/fcm.git | ||
GIT_TAG 2019.09.0 | ||
SOURCE_DIR ${CMAKE_BINARY_DIR}/fcm | ||
) | ||
set( FCM_EXECUTABLE ${CMAKE_BINARY_DIR}/fcm/bin/fcm ) | ||
endif() | ||
|
||
|
||
include( ecwam_target_fortran_module_directory ) | ||
include( ecwam_target_compile_definitions_FILENAME ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ecwam-import.cmake.in |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
function( ecwam_target_compile_definitions_FILENAME target ) | ||
get_target_property( sources "${target}" SOURCES) | ||
foreach( src ${sources} ) | ||
get_filename_component( filename ${src} NAME ) | ||
set_property( | ||
SOURCE ${src} | ||
APPEND | ||
PROPERTY COMPILE_DEFINITIONS __FILENAME__="${filename}" ) | ||
endforeach() | ||
endfunction() | ||
|
Oops, something went wrong.