-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
141 lines (124 loc) · 5.38 KB
/
CMakeLists.txt
File metadata and controls
141 lines (124 loc) · 5.38 KB
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
cmake_minimum_required(VERSION 3.15.5)
foreach(env_var IN ITEMS CMAKE_C_COMPILER CMAKE_CXX_COMPILER CMAKE_Fortran_COMPILER)
if(NOT DEFINED ENV{${env_var}})
message(FATAL_ERROR "${env_var} is not defined")
endif()
endforeach()
set(CMAKE_C_COMPILER $ENV{CMAKE_C_COMPILER})
set(CMAKE_CXX_COMPILER $ENV{CMAKE_CXX_COMPILER})
set(CMAKE_Fortran_COMPILER $ENV{CMAKE_Fortran_COMPILER})
set(CMAKE_Platform $ENV{CMAKE_Platform})
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
project(NASA-Land-Coupler
VERSION 1.0
LANGUAGES Fortran)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules)
# NLC executable
list(APPEND nlc_app_files
src/driver/app.F90
src/driver/driver.F90
src/driver/fields.F90
src/driver/flags.F90
src/driver/mediator.F90
)
add_executable(NLC.exe ${nlc_app_files})
# link ESMF
find_package(ESMF MODULE REQUIRED)
if (NOT ESMF_FOUND)
message(FATAL_ERROR "ESMF library not found. Please set environment variable ESMFMKFILE.")
endif (NOT ESMF_FOUND)
target_link_libraries(NLC.exe PUBLIC ESMF)
list(APPEND nlc_defs_private ESMF_VERSION_MAJOR=${ESMF_VERSION_MAJOR})
list(APPEND nlc_defs_private ESMF_VERSION_MINOR=${ESMF_VERSION_MINOR})
if (COMPONENT_LIST)
string(REPLACE "," ";" COMPONENT_LIST "${COMPONENT_LIST}")
foreach (component IN ITEMS ${COMPONENT_LIST})
string(TOUPPER ${component} component)
set(ENABLE_${component} ON)
endforeach()
else()
set(ENABLE_LIS ON)
set(ENABLE_WRFHYDRO ON)
set(ENABLE_PARFLOW ON)
endif()
# link LIS
if (ENABLE_LIS)
set(NLC_LIS_INST ${CMAKE_INSTALL_PREFIX}/LIS)
if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/src/LISF/lis/make/configure.lis")
message(FATAL_ERROR "LIS configuration missing.")
endif()
message("Build LIS:")
message(" run: ${CMAKE_BUILD_TOOL} nuopcinstall INSTPATH=${NLC_LIS_INST} BUILD_TYPE=${CMAKE_BUILD_TYPE} COMPILER=${CMAKE_Fortran_COMPILER_ID}")
message(" in: ${CMAKE_CURRENT_SOURCE_DIR}/src/LISF/lis/runmodes/nuopc_cpl_mode")
message("")
add_custom_target(lis_nuopc
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/src/LISF/lis/runmodes/nuopc_cpl_mode"
COMMAND ${CMAKE_BUILD_TOOL} nuopcinstall INSTPATH=${NLC_LIS_INST} BUILD_TYPE=${CMAKE_BUILD_TYPE} COMPILER=${CMAKE_Fortran_COMPILER_ID})
add_dependencies(NLC.exe lis_nuopc)
target_link_libraries(NLC.exe PUBLIC ${NLC_LIS_INST}/liblis_nuopc.a)
target_include_directories(NLC.exe PUBLIC ${NLC_LIS_INST})
list(APPEND nlc_defs_private NUOPCCAP_LIS=LIS_NUOPC)
# link LIS dependencies
include(lis_dependencies)
target_link_lis_dependencies(NLC.exe)
endif (ENABLE_LIS)
# link WFHYDRO
if (ENABLE_WRFHYDRO)
message("Build WRFHYDRO:")
message(" add_subdirectory: ${CMAKE_CURRENT_SOURCE_DIR}/src/wrf_hydro_nwm/trunk/NDHMS")
message("")
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/src/wrf_hydro_nwm/trunk/NDHMS)
add_dependencies(NLC.exe wrfhydro_nuopc)
target_link_libraries(NLC.exe PUBLIC wrfhydro_nuopc)
target_include_directories(NLC.exe PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/src/wrf_hydro_nwm/trunk/NDHMS/mods>)
list(APPEND nlc_defs_private NUOPCCAP_WRFHYDRO=WRFHydro_NUOPC)
# link WRFHYDRO dependencies
include(wrfhydro_dependencies)
target_link_wrfhydro_dependencies(NLC.exe)
endif (ENABLE_WRFHYDRO)
# link PARFLOW
if (ENABLE_PARFLOW)
message("Build PARFLOW:")
message(" add_subdirectory: ${CMAKE_CURRENT_SOURCE_DIR}/src/parflow")
message("")
if (NOT DEFINED ENV{PARFLOW_AMPS_LAYER})
message(FATAL_ERROR "Environment missing PARFLOW_AMPS_LAYER.")
endif ()
set(PARFLOW_AMPS_LAYER $ENV{PARFLOW_AMPS_LAYER} CACHE FILEPATH "Setting for PARFLOW_AMPS_LAYER")
if (NOT DEFINED ENV{PARFLOW_HAVE_CLM})
message(FATAL_ERROR "Environment missing PARFLOW_HAVE_CLM.")
endif ()
set(PARFLOW_HAVE_CLM $ENV{PARFLOW_HAVE_CLM} CACHE FILEPATH "Setting for PARFLOW_HAVE_CLM")
string(TOUPPER "${PARFLOW_HAVE_CLM}" PARFLOW_HAVE_CLM)
if (NOT DEFINED ENV{PARFLOW_ENABLE_NETCDF})
message(FATAL_ERROR "Environment missing PARFLOW_ENABLE_NETCDF.")
endif ()
set(PARFLOW_ENABLE_NETCDF $ENV{PARFLOW_ENABLE_NETCDF} CACHE FILEPATH "Setting for PARFLOW_ENABLE_NETCDF")
string(TOUPPER "${PARFLOW_ENABLE_NETCDF}" PARFLOW_ENABLE_NETCDF)
if (NOT DEFINED ENV{PARFLOW_HYPRE_DIR})
message(FATAL_ERROR "Environment missing PARFLOW_HYPRE_DIR.")
endif ()
set(HYPRE_ROOT $ENV{PARFLOW_HYPRE_DIR} CACHE FILEPATH "Path to HYPRE_ROOT")
if (NOT DEFINED ENV{PARFLOW_HDF5_DIR})
message(FATAL_ERROR "Environment missing PARFLOW_HDF5_DIR.")
endif ()
set(HDF5_ROOT $ENV{PARFLOW_HDF5_DIR} CACHE FILEPATH "Path to HDF5_ROOT")
if (NOT DEFINED ENV{PARFLOW_SILO_DIR})
message(FATAL_ERROR "Environment missing PARFLOW_SILO_DIR.")
endif ()
set(SILO_ROOT $ENV{PARFLOW_SILO_DIR} CACHE FILEPATH "Path to SILO_ROOT")
set(PARFLOW_ENABLE_NUOPC "ON" CACHE FILEPATH "Set PARFLOW_ENABLE_NUOPC")
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/src/parflow)
add_dependencies(NLC.exe parflow_nuopc)
target_link_libraries(NLC.exe PUBLIC parflow_nuopc)
target_include_directories(NLC.exe PUBLIC $<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/include>)
list(APPEND nlc_defs_private NUOPCCAP_PARFLOW=parflow_nuopc)
# link PARFLOW dependencies
include(parflow_dependencies)
target_link_parflow_dependencies(NLC.exe)
endif (ENABLE_PARFLOW)
# add flags
target_compile_definitions(NLC.exe PRIVATE "${nlc_defs_private}")
# NLC install
install(TARGETS NLC.exe DESTINATION .)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/driver/fd_nlc.yaml DESTINATION .)