-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
164 lines (125 loc) · 5.39 KB
/
Copy pathCMakeLists.txt
File metadata and controls
164 lines (125 loc) · 5.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# (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.24 FATAL_ERROR )
find_package( ecbuild 3.8 REQUIRED HINTS ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/../ecbuild )
set( ECWAM_PROJECT_NAME ecwam )
project( ${ECWAM_PROJECT_NAME} LANGUAGES Fortran C CXX )
string( TOUPPER ${PROJECT_NAME} PNAME )
include( ecwam_macros )
ecbuild_enable_fortran( REQUIRED NO_MODULE_DIRECTORY )
### Dependencies
ecbuild_find_package( fiat REQUIRED )
ecbuild_find_package( eccodes REQUIRED )
ecbuild_find_package( field_api 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 VERSION 2.1" )
ecbuild_add_option( FEATURE SINGLE_PRECISION
DEFAULT OFF
DESCRIPTION "Support for Single Precision" )
ecbuild_add_option( FEATURE DOUBLE_PRECISION
DEFAULT ON
DESCRIPTION "Support for Double Precision" )
ecbuild_add_option( FEATURE UNWAM
DEFAULT OFF
DESCRIPTION "Support for UNWAM" )
set( HAVE_dp ${HAVE_DOUBLE_PRECISION} )
set( HAVE_sp ${HAVE_SINGLE_PRECISION} )
### Determine ocean model precision
ecwam_find_nemo()
ecbuild_add_option( FEATURE OCEAN_COUPLING
DEFAULT ON
DESCRIPTION "Support ocean coupling"
CONDITION nemo_found )
ecbuild_add_option( FEATURE ECWAM_LAUNCH
DEFAULT ON
DESCRIPTION "Use share/ecwam/scripts/ecwam-launch script to run ecwam tests" )
ecbuild_add_option( FEATURE ECFLOW
DESCRIPTION "ecflow meter updates"
REQUIRED_PACKAGES "ecflow_light")
if( HAVE_ECWAM_LAUNCH )
# Overwrite meaning of mpiexec
set( ECWAM_LAUNCH ${CMAKE_CURRENT_SOURCE_DIR}/share/ecwam/scripts/ecwam-launch )
set( MPIEXEC_EXECUTABLE ${ECWAM_LAUNCH} )
set( MPIEXEC_NUMPROC_FLAG -n )
set( MPIEXEC_NUMTHREAD_FLAG -c )
set( CMAKE_CROSSCOMPILING_EMULATOR ${ECWAM_LAUNCH} ) # For serial runs
endif()
### Find python dependencies
ecwam_find_python_mods()
### Set third party libraries
unset( OpenMP_Fortran_LIBRARIES )
if( HAVE_OMP )
set( OpenMP_Fortran_LIBRARIES OpenMP::OpenMP_Fortran )
endif()
### Apply Loki source-to-source transformations to the ecWam physics
ecbuild_add_option( FEATURE LOKI
DEFAULT OFF
DESCRIPTION "Apply Loki transformations to ecWam physics"
REQUIRED_PACKAGES "loki" )
# Set default Loki transformation mode
set( LOKI_MODE "scc-stack" CACHE STRING "Transformation mode for Loki source transformations" )
### OpenACC
if( ${CMAKE_VERSION} VERSION_LESS "3.25" AND HAVE_LOKI AND NOT LOKI_MODE MATCHES "idem|idem-stack" )
if ( ${PNAME}_ENABLE_ACC OR (NOT DEFINED ${PNAME}_ENABLE_ACC AND ENABLE_ACC) )
# Incredibly inconvenient: FindOpenACC does _not_ set OpenACC_FOUND, only
# the language-specific components OpenACC_Fortran_FOUND and OpenACC_C_FOUND.
# This means, even internally CMake considers OpenACC as not found.
# (See eg get_property(... GLOBAL PROPERTY PACKAGES_NOT_FOUND))
# Therefore, we search for OpenACC, set OpenACC_FOUND ourselves according to
# the result, and then, trigger a second find_package via ecbuild_add_option.
# This then conveniently takes the previously set OpenACC_FOUND into account
# and rectifies CMake's internal bookkeeping in the process.
# This has been fixed in CMake 3.25
find_package( OpenACC )
if( OpenACC_Fortran_FOUND )
set( OpenACC_FOUND ON )
endif()
endif()
endif()
ecbuild_add_option( FEATURE ACC
DESCRIPTION "OpenACC" DEFAULT OFF
REQUIRED_PACKAGES "OpenACC COMPONENTS Fortran"
CONDITION HAVE_LOKI AND NOT LOKI_MODE MATCHES "idem|idem-stack" )
### CUDA
include(CheckLanguage)
check_language(CUDA)
ecbuild_add_option( FEATURE CUDA
DESCRIPTION "CUDA" DEFAULT OFF
CONDITION CMAKE_CUDA_COMPILER AND HAVE_ACC )
if( HAVE_CUDA )
enable_language( CUDA )
endif()
### GPU-aware MPI
ecbuild_add_option( FEATURE GPU_AWARE_MPI
DEFAULT OFF
DESCRIPTION "Enable GPU-aware MPI"
CONDITION HAVE_ACC AND MPI_Fortran_HAVE_F08_MODULE )
### Sources
ecbuild_override_compiler_flags(
COMPILE_FLAGS ${CMAKE_CURRENT_SOURCE_DIR}/cmake/ecwam_compile_flags.cmake
INHERIT_ECBUILD_FLAGS
)
add_subdirectory(src)
add_subdirectory(share)
### Tests
add_subdirectory(tests)
get_property(ecwam_test_configs GLOBAL PROPERTY ecwam_test_configs)
ecwam_cache_bathymetry( ${ecwam_test_configs} )
### Documentation
add_subdirectory(doc)
### Export
ecbuild_install_project( NAME ${PROJECT_NAME} )
ecbuild_print_summary()