-
Notifications
You must be signed in to change notification settings - Fork 11
/
CMakeLists.txt
358 lines (337 loc) · 8.73 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
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
cmake_minimum_required(VERSION 2.8)
project(FVCOM Fortran C)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/")
set(ROOT "${CMAKE_CURRENT_SOURCE_DIR}/FVCOM_source")
find_path(JULIAN_BASE fjulian.inc HINTS "${ROOT}/libs/julian" DOC "Source directory of julian")
find_path(METIS_BASE metis.h HINTS "${ROOT}/libs/metis" DOC "Source directory of METIS")
include_directories(${ROOT} ${JULIAN_BASE})
add_definitions(-DLIMITED_2 -DGCY1 -DMPDATA)
option(FVCOM_USE_FABM "Enable FABM" OFF)
if(FVCOM_USE_FABM)
add_definitions(-DFABM)
endif()
option(FVCOM_USE_DOUBLE_PRECISION "Use double precision" OFF)
if(FVCOM_USE_DOUBLE_PRECISION)
add_definitions(-DDOUBLE_PRECISION)
set(FABM_REAL_KIND "SELECTED_REAL_KIND(12)")
option(FVCOM_USE_SINGLE_OUTPUT "Use single precision for output" OFF)
if(FVCOM_USE_DOUBLE_PRECISION)
add_definitions(-DSINGLE_OUTPUT)
endif()
else()
set(FABM_REAL_KIND "SELECTED_REAL_KIND(6)")
endif()
option(FVCOM_USE_WET_DRY "Enable wetting-drying" ON)
if(FVCOM_USE_WET_DRY)
add_definitions(-DWET_DRY)
endif()
option(FVCOM_USE_MULTIPROCESSOR "Enable multi-processor use" OFF)
if(FVCOM_USE_MULTIPROCESSOR)
find_package(MPI REQUIRED)
if(MPI_Fortran_INCLUDE_PATH)
include_directories("${MPI_Fortran_INCLUDE_PATH}")
endif()
add_definitions(-DMULTIPROCESSOR)
endif()
# Customize compiler flags
if(${CMAKE_Fortran_COMPILER_ID} STREQUAL "GNU")
add_definitions(-DGFORTRAN)
elseif(${CMAKE_Fortran_COMPILER_ID} STREQUAL "Cray")
elseif(${CMAKE_Fortran_COMPILER_ID} STREQUAL "Intel")
if(WIN32)
set(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG} /Od")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /STACK:134217728")
endif()
endif()
find_package(NetCDF REQUIRED)
include_directories("${NetCDF_INCLUDE_DIRS}")
if (NetCDF_STATIC_MSVC_BUILD)
# On Windows with a statically-compiled NetCDF library - compile all code against static runtime.
# This MUST be done before any targets are added.
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} /libs:static")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /MT")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /MTd")
endif()
add_library(metis
${METIS_BASE}/coarsen.c
${METIS_BASE}/fm.c
${METIS_BASE}/initpart.c
${METIS_BASE}/match.c
${METIS_BASE}/ccgraph.c
${METIS_BASE}/memory.c
${METIS_BASE}/pmetis.c
${METIS_BASE}/pqueue.c
${METIS_BASE}/refine.c
${METIS_BASE}/util.c
${METIS_BASE}/timing.c
${METIS_BASE}/debug.c
${METIS_BASE}/bucketsort.c
${METIS_BASE}/graph.c
${METIS_BASE}/stat.c
${METIS_BASE}/kmetis.c
${METIS_BASE}/kwayrefine.c
${METIS_BASE}/kwayfm.c
${METIS_BASE}/balance.c
${METIS_BASE}/ometis.c
${METIS_BASE}/srefine.c
${METIS_BASE}/sfm.c
${METIS_BASE}/separator.c
${METIS_BASE}/mincover.c
${METIS_BASE}/mmd.c
${METIS_BASE}/mesh.c
${METIS_BASE}/meshpart.c
${METIS_BASE}/frename.c
${METIS_BASE}/fortran.c
${METIS_BASE}/myqsort.c
${METIS_BASE}/compress.c
${METIS_BASE}/parmetis.c
${METIS_BASE}/estmem.c
${METIS_BASE}/mpmetis.c
${METIS_BASE}/mcoarsen.c
${METIS_BASE}/mmatch.c
${METIS_BASE}/minitpart.c
${METIS_BASE}/mbalance.c
${METIS_BASE}/mrefine.c
${METIS_BASE}/mutil.c
${METIS_BASE}/mfm.c
${METIS_BASE}/mkmetis.c
${METIS_BASE}/mkwayrefine.c
${METIS_BASE}/mkwayfmh.c
${METIS_BASE}/mrefine2.c
${METIS_BASE}/minitpart2.c
${METIS_BASE}/mbalance2.c
${METIS_BASE}/mfm2.c
${METIS_BASE}/kvmetis.c
${METIS_BASE}/kwayvolrefine.c
${METIS_BASE}/kwayvolfm.c
${METIS_BASE}/subdomains.c
${METIS_BASE}/partition.c
)
target_include_directories(metis PRIVATE ${METIS_BASE})
if(MSVC)
target_compile_definitions(metis PRIVATE __VC__)
endif()
add_library(julian
${JULIAN_BASE}/dates.c
${JULIAN_BASE}/format.c
${JULIAN_BASE}/juldates.c
${JULIAN_BASE}/leapsecs.c
${JULIAN_BASE}/parse.c
${JULIAN_BASE}/seconds.c
${JULIAN_BASE}/tai_et.c
${JULIAN_BASE}/utc_tai.c
${JULIAN_BASE}/fortran.c
${JULIAN_BASE}/rlerrors.c
${JULIAN_BASE}/rlmemory.c
)
add_library(fjulian
${JULIAN_BASE}/fjulian.for
${JULIAN_BASE}/fstrings.for
)
if(FVCOM_USE_FABM)
find_path(FABM_BASE src/fabm.F90 DOC "Path to FABM source directory.")
set(FABM_FORCED_HOST fvcom)
add_subdirectory(${FABM_BASE}/src fabm)
set(EXTRA_SOURCES ${EXTRA_SOURCES} ${ROOT}/mod_fabm_3D.F ${ROOT}/mod_fabm_data.F)
endif()
add_library(FVCOM_C
${ROOT}/func_pointer.c
)
if(FVCOM_USE_HEATING_CALCULATED)
set(EXTRA_SOURCES ${EXTRA_SOURCES} ${ROOT}/mod_heatflux.F)
endif()
if(FVCOM_USE_HEATING_CALCULATED_GL)
set(EXTRA_SOURCES ${EXTRA_SOURCES} ${ROOT}/mod_heatflux_gl.F)
endif()
add_executable(FVCOM_exe
${ROOT}/adcor.F
${ROOT}/adjust2d3d.F
${ROOT}/adjust_ts.F
${ROOT}/advave_edge_gcn.F
${ROOT}/advave_edge_gcy.F
${ROOT}/advection_edge_gcn.F
${ROOT}/advection_edge_gcy.F
${ROOT}/adv_q.F
${ROOT}/adv_s.F
${ROOT}/adv_t.F
${ROOT}/adv_uv_edge_gcn.F
${ROOT}/adv_uv_edge_gcy.F
${ROOT}/allocate_all.F
${ROOT}/baropg.F
${ROOT}/bcond_gcn.F
${ROOT}/bcond_gcy.F
${ROOT}/bcond_ts.F
${ROOT}/brough.F
${ROOT}/calc_vort.F
${ROOT}/cell_area.F
${ROOT}/cntrl_prmtrs.F
${ROOT}/conv_over.F
${ROOT}/coords_n_const.F
${ROOT}/depth_check.F
${ROOT}/depth_grad.F
${ROOT}/edge_len.F
${ROOT}/enkf_ncdio.F
${ROOT}/eqs_of_state.F
${ROOT}/extelpf_edge.F
${ROOT}/extel_edge.F
${ROOT}/external_step.F
${ROOT}/extuv_edge.F
${ROOT}/fct_q2.F
${ROOT}/fct_q2l.F
${ROOT}/fct_s.F
${ROOT}/fct_t.F
${ROOT}/fvcom.F
${ROOT}/genmap.F
${ROOT}/genmap_lsf.F
${ROOT}/genmap_obc.F
${ROOT}/ghostuv.F
${ROOT}/grid_metrics.F
${ROOT}/ice_albedo.F
${ROOT}/ice_atmo.F
${ROOT}/ice_calendar.F
${ROOT}/ice_constants.F
#${ROOT}/ice_coupling.F
${ROOT}/ice_domain.F
${ROOT}/ice_fileunits.F
${ROOT}/ice_flux.F
${ROOT}/ice_flux_in.F
${ROOT}/ice_grid.F
${ROOT}/ice_init.F
${ROOT}/ice_itd.F
${ROOT}/ice_itd_linear.F
${ROOT}/ice_kinds_mod.F
${ROOT}/ice_mechred.F
${ROOT}/ice_model_size.F
${ROOT}/ice_ocean.F
${ROOT}/ice_scaling.F
${ROOT}/ice_state.F
${ROOT}/ice_therm_itd.F
${ROOT}/ice_therm_vertical.F
${ROOT}/ice_work.F
${ROOT}/icing.F
${ROOT}/init_sed.F
${ROOT}/internal_step.F
${ROOT}/linklist.F
${ROOT}/load_grid.F
${ROOT}/longshore_flow.F
${ROOT}/mod_action_ex.F
${ROOT}/mod_action_im.F
${ROOT}/mod_assim.F
${ROOT}/mod_balance_2d.F
${ROOT}/mod_bbl.F
${ROOT}/mod_bio_3D.F
${ROOT}/mod_boundschk.F
${ROOT}/mod_bulk.F
${ROOT}/mod_clock.F
${ROOT}/mod_dam.F
${ROOT}/mod_dye.F
${ROOT}/mod_enkf.F
${ROOT}/mod_enkfassim.F
${ROOT}/mod_enkf_ncd.F
${ROOT}/mod_enkf_obs.F
${ROOT}/mod_etkf.F
${ROOT}/mod_force.F
${ROOT}/mod_gotm.F
${ROOT}/mod_ice.F
${ROOT}/mod_ice2d.F
${ROOT}/mod_input.F
${ROOT}/mod_interp.F
${ROOT}/mod_lag.F
${ROOT}/mod_main.F
${ROOT}/mod_main_wave.F
${ROOT}/mod_meanflow.F
${ROOT}/mod_ncdio.F
${ROOT}/mod_ncll.F
${ROOT}/mod_nctools.F
${ROOT}/mod_nesting.F
${ROOT}/mod_newinp.F
${ROOT}/mod_non_hydro.F
${ROOT}/mod_northpole.F
${ROOT}/mod_obcs.F
${ROOT}/mod_obcs2.F
${ROOT}/mod_obcs3.F
${ROOT}/mod_onedtide.F
${ROOT}/mod_optimal_interpolation.F
${ROOT}/mod_par.F
${ROOT}/mod_petsc.F
${ROOT}/mod_plbc.F
${ROOT}/mod_prec.F
${ROOT}/mod_probe.F
${ROOT}/mod_pwp.F
${ROOT}/mod_report.F
${ROOT}/mod_rrk.F
${ROOT}/mod_rrkassim.F
${ROOT}/mod_rrkf_obs.F
${ROOT}/mod_scal.F
${ROOT}/mod_sed.F
${ROOT}/mod_semi_implicit.F
${ROOT}/mod_setup.F
${ROOT}/mod_set_time.F
${ROOT}/mod_sng.F
${ROOT}/mod_solar.F
${ROOT}/mod_spherical.F
${ROOT}/mod_startup.F
${ROOT}/mod_station_timeseries.F
${ROOT}/mod_time.F
${ROOT}/mod_tridiag.F
${ROOT}/mod_types.F
${ROOT}/mod_utils.F
${ROOT}/mod_visit.F
${ROOT}/mod_wavesetup.F
${ROOT}/mod_wave_current_interaction.F
${ROOT}/mod_wd.F
${ROOT}/mod_wqm.F
${ROOT}/namelist.F
${ROOT}/nh_set_nesting.F
${ROOT}/ocpcre.F
${ROOT}/ocpids.F
${ROOT}/ocpmix.F
${ROOT}/open_all.F
${ROOT}/particle.F
${ROOT}/phy_baropg.F
${ROOT}/print_vals.F
${ROOT}/rho_pmean.F
#${ROOT}/sectinf.F
${ROOT}/setup_domain.F
${ROOT}/shape_coef_gcn.F
${ROOT}/shape_coef_gcy.F
${ROOT}/sinter.F
${ROOT}/startup_type.F
${ROOT}/swancom1.F
${ROOT}/swancom2.F
${ROOT}/swancom3.F
${ROOT}/swancom4.F
${ROOT}/swancom5.F
${ROOT}/swanmain.F
${ROOT}/swanpre1.F
${ROOT}/swanpre2.F
${ROOT}/swanser.F
${ROOT}/swmod1.F
${ROOT}/swmod2.F
${ROOT}/swmod3.F
${ROOT}/tge.F
${ROOT}/vdif_q.F
${ROOT}/vdif_ts.F
${ROOT}/vdif_ts_gom.F
${ROOT}/vdif_uv.F
${ROOT}/vertvl_edge.F
${ROOT}/viscofh.F
${ROOT}/visitsim.F
${ROOT}/wreal.F
${EXTRA_SOURCES}
${MPI_Fortran_EXTRA_SOURCES}
)
set_property(TARGET FVCOM_exe PROPERTY Fortran_FORMAT FREE)
target_link_libraries(FVCOM_exe julian fjulian metis)
target_link_libraries(FVCOM_exe FVCOM_C)
target_link_libraries(FVCOM_exe "${NetCDF_LIBRARIES}")
if(FVCOM_USE_FABM)
target_include_directories(FVCOM_exe PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/fabm/modules)
target_link_libraries(FVCOM_exe fabm)
endif()
if (NetCDF_STATIC_MSVC_BUILD)
set_property(TARGET FVCOM_exe PROPERTY LINK_FLAGS_DEBUG "/NODEFAULTLIB:\"libcmt\"")
endif()
if(FVCOM_USE_MULTIPROCESSOR AND MPI_Fortran_LIBRARIES)
target_link_libraries(FVCOM_exe ${MPI_Fortran_LIBRARIES})
endif()