forked from JCSDA/fv3-jedi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
177 lines (131 loc) · 5.61 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
# (C) Copyright 2017-2019 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.0.0 LANGUAGES C CXX Fortran )
set( CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake;${CMAKE_MODULE_PATH})
set( CMAKE_DIRECTORY_LABELS "fv3-jedi" )
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 )
ecbuild_add_cxx11_flags()
set( FV3JEDI_LINKER_LANGUAGE CXX )
################################################################################
# Standard compiler flags
################################################################################
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
################################################################################
# NetCDF
find_package( NetCDF REQUIRED COMPONENTS Fortran )
include_directories( ${NETCDF_INCLUDE_DIRS} )
# atlas
ecbuild_use_package( PROJECT atlas VERSION 0.20.2 REQUIRED )
include_directories( ${ATLAS_INCLUDE_DIRS} )
# oops
ecbuild_use_package( PROJECT oops VERSION 1.0.0 REQUIRED )
include_directories( ${OOPS_INCLUDE_DIRS} )
# saber
ecbuild_use_package( PROJECT saber VERSION 1.0.0 REQUIRED )
include_directories( ${SABER_INCLUDE_DIRS} )
# crtm
ecbuild_use_package( PROJECT crtm VERSION 2.2.3 REQUIRED )
# ropp
ecbuild_use_package( PROJECT ropp-ufo QUIET )
# geos-aero
ecbuild_use_package( PROJECT geos-aero QUIET )
# ufo
ecbuild_use_package( PROJECT ufo VERSION 1.0.0 REQUIRED )
include_directories( ${UFO_INCLUDE_DIRS} )
# femps
ecbuild_use_package( PROJECT femps VERSION 1.0.0 REQUIRED )
include_directories( ${FEMPS_INCLUDE_DIRS} )
#OpenMP
find_package( OpenMP COMPONENTS Fortran )
# MPI
ecbuild_find_mpi( COMPONENTS CXX Fortran REQUIRED )
ecbuild_include_mpi()
link_libraries(${MPI_CXX_LIBRARIES} ${MPI_Fortran_LIBRARIES})
# fms
if (FV3_FORECAST_MODEL MATCHES "FV3CORE") # OR FV3_FORECAST_MODEL MATCHES "UFS")
ecbuild_use_package( PROJECT fms REQUIRED )
include_directories( ${FMS_INCLUDE_DIRS} )
endif()
# fv3
if (FV3_FORECAST_MODEL MATCHES "FV3CORE" OR NOT FV3_FORECAST_MODEL)
ecbuild_use_package( PROJECT fv3 REQUIRED )
include_directories( ${FV3_INCLUDE_DIRS} )
endif()
# 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()
# ufs
if (FV3_FORECAST_MODEL MATCHES "UFS")
#ToDo
endif()
# Linear model
ecbuild_use_package( PROJECT fv3jedilm VERSION 1.0.0 REQUIRED )
include_directories( ${FV3JEDILM_INCLUDE_DIRS} )
################################################################################
# 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
${CMAKE_Fortran_MODULE_DIRECTORY})
set( FV3JEDI_LIBRARIES fv3jedi )
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()
################################################################################
# Sources
################################################################################
include_directories( ${FV3JEDI_INCLUDE_DIRS}
${FV3JEDI_EXTRA_INCLUDE_DIRS} )
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()