-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
280 lines (227 loc) · 9.21 KB
/
CMakeLists.txt
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
# (C) Copyright 2017-2022 UCAR.
#
# 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.
################################################################################
# FV3JEDI
################################################################################
cmake_minimum_required( VERSION 3.3.2 FATAL_ERROR )
project( fv3jedi VERSION 1.9.0 LANGUAGES C CXX Fortran )
option(OPENMP "Build fv3-jedi with OpenMP support" ON)
set( CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake;${CMAKE_MODULE_PATH})
set( CMAKE_DIRECTORY_LABELS "fv3-jedi" )
find_package( ecbuild 3.6 REQUIRED )
set( ECBUILD_DEFAULT_BUILD_TYPE Release )
set( ENABLE_OS_TESTS OFF CACHE BOOL "Disable OS tests" FORCE )
set( ENABLE_LARGE_FILE_SUPPORT OFF CACHE BOOL "Disable testing of large file support" FORCE )
set( ENABLE_MPI ON CACHE BOOL "Compile with MPI" )
include( ecbuild_system NO_POLICY_SCOPE )
ecbuild_requires_macro_version( 2.5 )
################################################################################
# Project
################################################################################
ecbuild_declare_project()
ecbuild_enable_fortran( REQUIRED )
set( FV3JEDI_LINKER_LANGUAGE CXX )
################################################################################
# Standard compiler flags
################################################################################
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS OFF)
set(CMAKE_FORTRAN_STANDARD 08)
set(CMAKE_FORTRAN_STANDARD_REQUIRED ON)
set(CMAKE_FORTRAN_EXTENSIONS OFF)
include( fv3jedi_extra_macros )
option( ENABLE_FV3JEDI_DOC "Build FV3-JEDI documentation" OFF )
################################################################################
# Set default model to GFDL_atmos_cubed_sphere
################################################################################
if (NOT FV3_FORECAST_MODEL MATCHES GEOS AND NOT FV3_FORECAST_MODEL MATCHES UFS)
set(FV3_FORECAST_MODEL "FV3CORE")
endif()
################################################################################
# Dependencies
################################################################################
# jedi-cmake
find_package( jedicmake QUIET )
# NetCDF
find_package( NetCDF REQUIRED COMPONENTS C Fortran )
# atlas
find_package( atlas 0.35.0 REQUIRED )
# oops
find_package( oops 1.10.0 REQUIRED )
# saber
find_package( saber 1.10.0 REQUIRED )
# crtm
find_package( crtm 2.2.3 REQUIRED )
# ropp
find_package( ropp-ufo QUIET )
# gsibec
find_package( gsibec 1.2.1 QUIET )
if( gsibec_FOUND )
message( STATUS "FV3-SABER block GSI is enabled" )
add_definitions(-DENABLE_GSIBEC=1)
endif()
# ncep-sp
find_package( sp QUIET )
# ufo
find_package( ufo 1.10.0 REQUIRED )
# femps
find_package( femps 1.3.0 REQUIRED )
# vader
find_package( vader 1.7.0 REQUIRED )
#OpenMP
if(OPENMP)
find_package( OpenMP COMPONENTS Fortran )
endif()
# MPI
ecbuild_find_mpi( COMPONENTS CXX Fortran REQUIRED )
# Set default forecast model
# --------------------------
if (NOT FV3_FORECAST_MODEL MATCHES GEOS AND NOT FV3_FORECAST_MODEL MATCHES UFS)
set(FV3_FORECAST_MODEL "FV3CORE")
endif()
# fms
set(HAS_FMS2_IO TRUE) # Set to FALSE if FMS2 IO unavailable (should be removed eventually)
find_package(FMS 2023.04 REQUIRED COMPONENTS R4 R8)
if (FV3_PRECISION MATCHES DOUBLE OR NOT FV3_PRECISION)
add_library(fms ALIAS FMS::fms_r8)
else()
add_library(fms ALIAS FMS::fms_r4)
endif()
# fv3
# geos
if (FV3_FORECAST_MODEL MATCHES "GEOS")
if (NOT DEFINED GEOSgcm_FOUND)
find_package(MAPL REQUIRED PATHS ${FV3_FORECAST_MODEL_ROOT}/lib/cmake/MAPL )
find_package(GEOSgcm REQUIRED PATHS ${FV3_FORECAST_MODEL_ROOT}/lib/cmake/GEOSgcm )
endif()
find_package(FARGPARSE REQUIRED)
find_package(FLAP REQUIRED)
find_package(GFTL REQUIRED)
find_package(GFTL_SHARED REQUIRED)
find_package(PFLOGGER REQUIRED)
find_package(YAFYAML REQUIRED)
link_libraries(GEOSgcm_GridComp)
endif()
# Linear model
find_package( fv3jedilm 1.5.0 REQUIRED )
################################################################################
# Export package info
################################################################################
list( APPEND FV3JEDI_TPLS atlas atlas_f oops ufo saber )
set( FV3JEDI_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/src
${CMAKE_CURRENT_BINARY_DIR}/src
${DEPEND_LIB_ROOT}/include
${DEPEND_LIB_ROOT}/mod
${DEPEND_LIB_ROOT}/include/fv3
${CMAKE_Fortran_MODULE_DIRECTORY})
if( FV3_FORECAST_MODEL MATCHES UFS )
find_package(HDF5 REQUIRED COMPONENTS C HL )
# Use ESMF's own findESMF.cmake - if wanting
# the static ESMF library (we don't!), use
# set(USE_ESMF_STATIC_LIBS ON)
if( NOT DEFINED ENV{esmf_ROOT} )
message(FATAL_ERROR "Environmental variable esmf_ROOT not set, is ESMF module loaded?")
endif()
list(PREPEND CMAKE_MODULE_PATH "$ENV{esmf_ROOT}/cmake")
find_package(ESMF MODULE REQUIRED)
#
if( UFS_APP MATCHES "^(ATM)$" )
set( FV3JEDI_LIBRARIES fv3jedi
ccpp_framework
ccpp_physics )
elseif( UFS_APP MATCHES "^(ATMAERO)$" )
find_package (GFTL_SHARED REQUIRED)
find_package (FARGPARSE REQUIRED)
find_package (PFLOGGER REQUIRED)
find_package (MAPL REQUIRED)
set( FV3JEDI_LIBRARIES fv3jedi
ufs_aerosols
aerosols_gridcomp
gocart_gridcomp
ca2g_gridcomp
chem_shared
gocart_process
du2g_gridcomp
ni2g_gridcomp
ss2g_gridcomp
su2g_gridcomp
ga_environment
MAPL
ccpp_framework
ccpp_physics
GFTL_SHARED::gftl-shared )
elseif( UFS_APP MATCHES "^(S2S)$" )
find_package( PIO 2.5.3 REQUIRED COMPONENTS C Fortran)
set( FV3JEDI_LIBRARIES fv3jedi
gsw
mom6
cice
cmeps
cdeps
PIO::PIO_Fortran
PIO::PIO_C
ccpp_framework
ccpp_physics )
else()
message(FATAL_ERROR "fv3jedi FV3JEDI_LIBRARIES not configured for UFS_APP ${UFS_APP}")
endif()
else()
set( FV3JEDI_LIBRARIES fv3jedi )
endif()
get_directory_property( FV3JEDI_DEFINITIONS COMPILE_DEFINITIONS )
foreach( _tpl ${FV3JEDI_TPLS} )
string( TOUPPER ${_tpl} TPL )
list( APPEND FV3JEDI_EXTRA_DEFINITIONS ${${TPL}_DEFINITIONS} ${${TPL}_TPL_DEFINITIONS} )
list( APPEND FV3JEDI_EXTRA_INCLUDE_DIRS ${${TPL}_INCLUDE_DIRS} ${${TPL}_TPL_INCLUDE_DIRS} )
list( APPEND FV3JEDI_EXTRA_LIBRARIES ${${TPL}_LIBRARIES} ${${TPL}_TPL_LIBRARIES} )
endforeach()
################################################################################
# Test data
################################################################################
# DH 2023/10/06 - this is unfortunately still true ...
### The fv3-jedi-data package is problematic in bundles because it has some special CMake logic
### at the root bundle location. So, we cannot find the fv3-jedi-data while in fv3-jedi!
### Basically, with the current logic we hack fv3-jedi-data_FOUND to match ENABLE_FV3_JEDI_DATA
#find_package( fv3-jedi-data QUIET )
if (ENABLE_FV3_JEDI_DATA)
set (fv3-jedi-data_FOUND TRUE)
else()
# Set values for downloading fv3-jedi test data from tarball
set (fv3-jedi_data_download_url "https://bin.ssec.wisc.edu/pub/s4/CRTM/file")
set (fv3-jedi_data_tag "1.9.0")
set (fv3-jedi_data_tarball_name "fv3-jedi_testinput_tier_1_${fv3-jedi_data_tag}.tar.gz")
set (fv3-jedi_data_tarball_hash "8ea0904eda4e4b3840536b8c744b3d9e")
endif()
################################################################################
# Sources
################################################################################
# ufs
if (FV3_FORECAST_MODEL MATCHES UFS)
# Building with the UFS is now accomplished only via the ufs-bundle
# which will also build the UFS as an external library with a prescribed configuration
# There is now a unit test which will pull data from an s3 bucket and convert it
# into a run directory to be used with ctests involving UFS coupling (ATM-only)
find_package(bacio REQUIRED )
find_package(sigio REQUIRED )
find_package(sp REQUIRED )
find_package(w3emc REQUIRED )
find_package(nemsio REQUIRED )
endif()
add_subdirectory( src )
add_subdirectory( test )
if( ENABLE_FV3JEDI_DOC )
add_subdirectory( Documents )
endif()
################################################################################
# Finalise configuration
################################################################################
# prepares a tar.gz of the sources and/or binaries
ecbuild_install_project( NAME fv3jedi )
# print the summary of the configuration
ecbuild_print_summary()