forked from NCAR/lilac
-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
215 lines (153 loc) · 7.72 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
cmake_minimum_required(VERSION 2.8.12.1)
##include("/glade/work/negins/UFSCOMP/cime/tools/Macros.cmake")
set (CIME_ROOT "/glade/work/negins/UFSCOMP/cime")
message ("CIME_ROOT: ${CIME_ROOT}")
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/CMakeModules")
message ("CMAKE_MODULE_PATH: ${CMAKE_MODULE_PATH}")
set (CIME_CMAKE_MODULE_DIRECTORY "/glade/work/negins/UFSCOMP/cime/src/CMake/")
message ("CIME_CMAKE_MODULE_DIRECTORY: ${CIME_CMAKE_MODULE_DIRECTORY}")
list(APPEND CMAKE_MODULE_PATH ${CIME_CMAKE_MODULE_DIRECTORY})
message ("CMAKE_MODULE_PATH: ${CMAKE_MODULE_PATH}")
set (MACRO_ROOT "/glade/work/negins/UFSCOMP/cime/tools/")
include(${MACRO_ROOT}/Macros.cmake)
list(APPEND CMAKE_MODULE_PATH ${MACRO_ROOT})
message ("CMAKE_MODULE_PATH: ${CMAKE_MODULE_PATH}")
set (CLM_ROOT "/glade/work/negins/UFSCOMP/components/clm")
message("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
include_directories (${CMAKE_SOURCE_DIR}/cmake/CMakeModules/)
include (${CMAKE_SOURCE_DIR}/cmake/CMakeModules/genf90_utils.cmake)
include (${CMAKE_SOURCE_DIR}/cmake/CMakeModules/Sourcelist_utils.cmake)
include (${CMAKE_SOURCE_DIR}/cmake/CMakeModules/pFUnit_utils.cmake)
include (${CMAKE_SOURCE_DIR}/cmake/CMakeModules/FindpFUnit.cmake)
#include (Macros.cmake)
#include(CIME_initial_setup)
message("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
### -------------------------------------------------------------
# project name
project(LILAC Fortran C)
enable_language(Fortran)
# This definition is needed to avoid having ESMF depend on mpi
add_definitions(-DHIDE_MPI)
message("----------------------------------------------------")
message ("CMAKE_CURRENT_SOURCE_DIR: ${CMAKE_CURRENT_SOURCE_DIR}")
message ("CMAKE_MODULE_PATH: ${CMAKE_MODULE_PATH}")
message("----------------------------------------------------")
message("----------------------------------------------------")
# Add source directories from other share code (csm_share, etc.). This should be
# done first, so that in case of name collisions, the CLM versions take
# precedence (when there are two files with the same name, the one added later
# wins).
add_subdirectory(${CIME_ROOT}/src/share/util csm_share)
add_subdirectory(${CIME_ROOT}/src/share/unit_test_stubs/util csm_share_stubs)
add_subdirectory(${CIME_ROOT}/src/share/esmf_wrf_timemgr esmf_wrf_timemgr)
add_subdirectory(${CIME_ROOT}/src/drivers/mct/shr drv_share)
message("----------------------------------------------------")
# Extract just the files we need from drv_share
set (drv_sources_needed_base
glc_elevclass_mod.F90
)
extract_sources("${drv_sources_needed_base}" "${drv_sources}" drv_sources_needed)
message("~~~~~~~~~~~~~~~~~~~~~~CLM_ROOT~~~~~~~~~~~~~~~~~~~~~~")
# Add CLM source directories (these add their own test directories)
add_subdirectory(${CLM_ROOT}/src/utils clm_utils)
add_subdirectory(${CLM_ROOT}/src/biogeochem clm_biogeochem)
add_subdirectory(${CLM_ROOT}/src/soilbiogeochem clm_soilbiogeochem)
add_subdirectory(${CLM_ROOT}/src/biogeophys clm_biogeophys)
add_subdirectory(${CLM_ROOT}/src/dyn_subgrid clm_dyn_subgrid)
add_subdirectory(${CLM_ROOT}/src/main clm_main)
add_subdirectory(${CLM_ROOT}/src/init_interp clm_init_interp)
add_subdirectory(${CLM_ROOT}/src/fates/main fates_main)
# Add general unit test directories (stubbed out files, etc.)
add_subdirectory(unit_test_stubs)
add_subdirectory(unit_test_shr)
# Remove shr_mpi_mod from share_sources.
# This is needed because we want to use the mock shr_mpi_mod in place of the real one
#
# TODO: this should be moved into a general-purpose function in Sourcelist_utils.
# Then this block of code could be replaced with a single call, like:
# remove_source_file(${share_sources} "shr_mpi_mod.F90")}
foreach (sourcefile ${share_sources})
string(REGEX MATCH "shr_mpi_mod.F90" match_found ${sourcefile})
if(match_found)
list(REMOVE_ITEM share_sources ${sourcefile})
endif()
endforeach()
# We rely on pio for cmake utilities like findnetcdf.cmake, so that we don't
# need to duplicate this cmake code
message ("CMAKE_MODULE_PATH: ${CMAKE_MODULE_PATH}")
list (APPEND CMAKE_MODULE_PATH "${CIME_ROOT}/src/externals/pio2/cmake")
message ("CMAKE_MODULE_PATH: ${CMAKE_MODULE_PATH}")
add_subdirectory (${CIME_ROOT}/src/externals/pio2/test)
message("----------------------------------------------------")
option(ENABLE_PFUNIT "Enable pfUnit testing Framework" ON)
if (ENABLE_PFUNIT)
find_package(pfUnit)
include(pfUnit_utils)
include_directories("${PFUNIT_INCLUDE_DIRS}")
endif (ENABLE_PFUNIT)
message("----------------------------------------------------")
find_package(MPI REQUIRED)
# TODO: This should be found from the find_package call but its not working
#set(CMAKE_Fortran_COMPILER "/usr/lib64/mpich/bin/mpif90")
find_package(ESMF REQUIRED)
message("------------include (CIME_utils)--------------------")
include(CIME_utils)
message("----------------------------------------------------")
find_package(NetCDF COMPONENTS C Fortran)
include_directories(${NetCDF_C_INCLUDE_DIRS} ${NetCDF_Fortran_INCLUDE_DIRS})
message("NetCDF_C_INCLUDE_DIRS: ${NetCDF_C_INCLUDE_DIRS}")
message("----------------------------------------------------")
##=======##
#set(CESM_ROOT "/glade/work/negins/UFSCOMP/")
#set(CSM_SHR "/glade/work/negins/UFSCOMP/components/clm/src/unit_test_stubs/csm_share/")
#add_subdirectory(${CESM_ROOT}/models/csm_share/shr csm_share)
#add_subdirectory(${CSM_SHR} )
message("----------------------------------------------------")
# -lclm libclm.a
SET(NAMES libclm.a)
#find_library(LIB_TO_INCLUDE
# libclm.a
# PATHS /glade/scratch/negins/baghale6/bld/intel/mpt/nodebug/nothreads/nuopc/nuopc/esmf/lib/)
#find_library(LIB_TO_INCLUDE /glade/scratch/negins/baghale6/bld/intel/mpt/nodebug/nothreads/nuopc/nuopc/esmf/lib/)
#message(STATUS "include_directories for ${NAMES}: ${LIB_TO_INCLUDE}")
#include_directories(${LIB_TO_INCLUDE})
#link_directories(${LIB_TO_INCLUDE})
#message(STATUS "include_directories for ${NAMES}: ${LIB_TO_INCLUDE}")
#find_library(LIB_TO_INCLUDE /glade/scratch/negins/baghale6/bld/intel/mpt/nodebug/nothreads/nuopc/nuopc/esmf/lib/)
#message(STATUS "include_directories: ${LIB_TO_INCLUDE}")
#target_link_libraries (${LIB_TO_INCLUDE})
# Local CMake modules
if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU")
set(dialect "-ffree-form -std=f2008 -fimplicit-none")
set(bounds "-fbounds-check")
endif()
if(CMAKE_Fortran_COMPILER_ID MATCHES "Intel")
set(dialect "-stand f08 -free -implicitnone")
set(bounds "-check bounds")
endif()
if(CMAKE_Fortran_COMPILER_ID MATCHES "PGI")
set(dialect "-Mfreeform -Mdclchk -Mstandard -Mallocatable=03")
set(bounds "-C")
endif()
set(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG} ${bounds}")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${dialect}")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${ESMF_COMPILER_LINE}")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${ESMF_LINK_LINE} -g -cpp")
message(STATUS "==============================================================")
message(STATUS "Fortran Compiler : ${CMAKE_Fortran_COMPILER}")
message(STATUS "cmake Fortran Flags : ${CMAKE_Fortran_FLAGS}")
message(STATUS "==============================================================")
message(STATUS "==============================================================")
#add_executable("lilac.exe" ../lilac/*.F90)
#
# Compile.
#
file(GLOB_RECURSE SOURCES lilac/*.F90)
#add_subdirectory(lilac)
#add_executable(${PROJECT_NAME}.exe ../lilac/demo_driver.F90
# ../lilac/lilac_mod.F90 ../lilac/atmos_cap.F90 ../lilac/lilac_utils.F90
# ../lilac/lnd_cap.F90 ../lilac/cpl_mod.F90)
add_executable (${PROJECT_NAME}.exe ${SOURCES})
target_link_libraries(${PROJECT_NAME}.exe ${LIB_TO_INCLUDE})
#add_subdirectory(lilac)
#add_subdirectory(tests)