-
Notifications
You must be signed in to change notification settings - Fork 158
/
CMakeLists.txt
184 lines (157 loc) · 4.94 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
# This is the main CMake file for fv3atm.
#
# Dusan Jovic, Alex Richert
cmake_minimum_required(VERSION 3.19)
# Handle user build options.
option(ENABLE_DOCS "Enable generation of doxygen-based documentation." OFF)
# Determine whether or not to generate documentation.
if(ENABLE_DOCS)
find_package(Doxygen REQUIRED)
add_subdirectory(docs)
endif()
# Enable CI build & unit testing:
if(BUILD_TESTING)
project(fv3atm VERSION 1.0 LANGUAGES C CXX Fortran)
include(ci/CMakeLists.txt)
endif()
###############################################################################
### CCPP
###############################################################################
set(MPI ON)
add_subdirectory(ccpp)
###############################################################################
### fv3 dynamical core
###############################################################################
# These ifdefs need to be turned ON in the dycore.
set(use_WRTCOMP ON)
set(GFS_PHYS ON)
set(GFS_TYPES ON)
set(USE_GFSL63 ON)
if(MOVING_NEST)
set(MOVING_NEST ON)
endif()
if(HYDRO)
set(HYDRO ON)
endif()
add_subdirectory(atmos_cubed_sphere)
target_compile_definitions(fv3 PRIVATE BYPASS_BREED_SLP_INLINE)
###############################################################################
### fv3atm
###############################################################################
if(INLINE_POST)
set(BUILD_POSTEXEC OFF)
add_subdirectory(upp)
set(POST_SRC io/post_nems_routines.F90 io/post_fv3.F90)
list(APPEND _fv3atm_defs_private INLINE_POST)
endif()
if(CCPP_32BIT)
add_definitions(-DCCPP_32BIT)
else()
remove_definitions(-DCCPP_32BIT)
endif()
if(NOT PARALLEL_NETCDF)
list(APPEND _fv3atm_defs_private NO_PARALLEL_NETCDF)
endif()
if(MOVING_NEST)
list(APPEND _fv3atm_defs_private MOVING_NEST)
if(NOT HYDRO)
list(APPEND _fv3atm_defs_private MOIST_CAPPA USE_COND)
endif()
if(DEBUG)
list(APPEND _fv3atm_defs_private DEBUG)
endif()
if(GFS_PHYS)
list(APPEND _fv3atm_defs_private GFS_PHYS)
endif()
if(GFS_TYPES)
list(APPEND _fv3atm_defs_private GFS_TYPES)
endif()
if(USE_GFSL63)
list(APPEND _fv3atm_defs_private USE_GFSL63)
endif()
if(INTERNAL_FILE_NML)
list(APPEND _fv3atm_defs_private INTERNAL_FILE_NML)
endif()
if(ENABLE_QUAD_PRECISION)
list(APPEND _fv3atm_defs_private ENABLE_QUAD_PRECISION)
endif()
if(32BIT)
list(APPEND _fv3atm_defs_private OVERLOAD_R4 OVERLOAD_R8)
endif()
list(APPEND moving_nest_srcs
moving_nest/bounding_box.F90
moving_nest/fv_tracker.F90
moving_nest/fv_moving_nest.F90
moving_nest/fv_moving_nest_main.F90
moving_nest/fv_moving_nest_physics.F90
moving_nest/fv_moving_nest_types.F90
moving_nest/fv_moving_nest_utils.F90
)
else()
list(APPEND moving_nest_srcs "")
endif()
add_library(fv3atm
atmos_model.F90
fv3_cap.F90
module_fv3_config.F90
module_fcst_grid_comp.F90
stochastic_physics/stochastic_physics_wrapper.F90
cpl/module_block_data.F90
cpl/module_cplfields.F90
cpl/module_cap_cpl.F90
cpl/module_cplscalars.F90
io/fv3atm_common_io.F90
io/fv3atm_clm_lake_io.F90
io/fv3atm_rrfs_sd_io.F90
io/fv3atm_sfc_io.F90
io/fv3atm_oro_io.F90
io/fv3atm_history_io.F90
io/fv3atm_restart_io.F90
io/module_write_netcdf.F90
io/module_write_restart_netcdf.F90
io/module_fv3_io_def.F90
io/module_write_internal_state.F90
io/module_wrt_grid_comp.F90
${moving_nest_srcs}
${POST_SRC}
)
add_dependencies(fv3atm fv3 fv3ccpp stochastic_physics)
list(APPEND _fv3atm_defs_private GFS_PHYS
INTERNAL_FILE_NML
use_WRTCOMP)
target_compile_definitions(fv3atm PRIVATE "${_fv3atm_defs_private}")
set_target_properties(fv3atm PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/mod)
target_include_directories(fv3atm INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/mod>
$<INSTALL_INTERFACE:mod>)
if(MULTI_GASES)
list(APPEND _fv3atm_defs_private MULTI_GASES)
endif()
target_link_libraries(fv3atm PUBLIC fv3
fv3ccpp
stochastic_physics
fms)
target_link_libraries(fv3atm PUBLIC w3emc::w3emc_d
sp::sp_d
bacio::bacio_4
esmf)
if(INLINE_POST)
target_link_libraries(fv3atm PUBLIC upp::upp)
endif()
if(OPENMP)
target_link_libraries(fv3atm PUBLIC OpenMP::OpenMP_Fortran)
endif()
if(BUILD_TESTING)
include(CTest)
add_subdirectory(tests)
endif()
###############################################################################
### Install
###############################################################################
install(
TARGETS fv3atm
EXPORT fv3atm-config
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/mod DESTINATION ${CMAKE_INSTALL_PREFIX})
install(EXPORT fv3atm-config
DESTINATION lib/cmake)