Skip to content

Commit

Permalink
Modifications for building src directory with WRF CMake build system
Browse files Browse the repository at this point in the history
  • Loading branch information
scrasmussen committed Dec 13, 2024
1 parent e1eb6d6 commit 35f2d3e
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
34 changes: 34 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
if(${PROJECT_NAME} STREQUAL "WRF")
# additions that WRF-Hydro's top CMakeLists.txt handles
add_compile_options( "${PROJECT_COMPILE_OPTIONS}" )
add_compile_definitions( "${PROJECT_COMPILE_DEFINITIONS}" )
set(CMAKE_Fortran_MODULE_DIRECTORY ${PROJECT_BINARY_DIR}/hydro/mods)
add_definitions(-DMPP_LAND)
if (WRF_HYDRO_NUDGING STREQUAL "1")
add_definitions(-DWRF_HYDRO_NUDGING=1)
endif()
endif()


# build the various sup-projects
add_subdirectory("MPP")
add_subdirectory("utils")
Expand All @@ -10,6 +22,9 @@ add_subdirectory("Routing/Reservoirs")
add_subdirectory("Data_Rec")
add_subdirectory("Routing")
add_subdirectory("HYDRO_drv")
if(${PROJECT_NAME} STREQUAL "WRF")
add_subdirectory("CPL/WRF_cpl")
endif()

if (WRF_HYDRO_NUDGING STREQUAL "1")
add_subdirectory("nudging")
Expand Down Expand Up @@ -195,6 +210,25 @@ elseif (HYDRO_LSM MATCHES "Noah")
COMMAND rm ${PROJECT_BINARY_DIR}/src/wrfhydro.exe
)

elseif(${PROJECT_NAME} STREQUAL "WRF")
add_library(wrfhydro INTERFACE)
target_link_libraries(wrfhydro INTERFACE
hydro_utils
hydro_mpp
hydro_debug_utils
hydro_routing_overland
hydro_routing_subsurface
hydro_data_rec
hydro_routing
hydro_routing_reservoirs_levelpool
hydro_routing_reservoirs_hybrid
hydro_routing_reservoirs_rfc
hydro_routing_reservoirs
hydro_wrf_cpl
hydro_orchestrator
hydro_netcdf_layer
hydro_driver
)
else()
message("Unknown land surface model:" ${HYDRO_LSM} )
endif()
25 changes: 25 additions & 0 deletions src/CPL/WRF_cpl/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
add_library(hydro_wrf_cpl STATIC
wrf_drv_HYDRO.F90
module_wrf_HYDRO.F90
)

add_dependencies(hydro_wrf_cpl
hydro_mpp
hydro_utils
hydro_debug_utils
hydro_data_rec
hydro_driver
hydro_orchestrator
${PROJECT_NAME}_Core
MPI::MPI_Fortran
)

target_include_directories(hydro_wrf_cpl
PRIVATE
$<TARGET_PROPERTY:${PROJECT_NAME}_Core,Fortran_MODULE_DIRECTORY>
$<TARGET_PROPERTY:esmf_time_f90,Fortran_MODULE_DIRECTORY>
)

target_include_directories(hydro_wrf_cpl PUBLIC
${MPI_Fortran_MODULE_DIR}
)

0 comments on commit 35f2d3e

Please sign in to comment.