From 1dcf47f0f612ddf05baa226da460304867296930 Mon Sep 17 00:00:00 2001 From: Soren Rasmussen Date: Fri, 13 Dec 2024 14:04:32 -0700 Subject: [PATCH] Modifications for building src directory with WRF CMake build system --- src/CMakeLists.txt | 34 ++++++++++++++++++++++++++++++++++ src/CPL/WRF_cpl/CMakeLists.txt | 25 +++++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 src/CPL/WRF_cpl/CMakeLists.txt diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ed12b2dd2..52007c4bf 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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") @@ -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") @@ -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() diff --git a/src/CPL/WRF_cpl/CMakeLists.txt b/src/CPL/WRF_cpl/CMakeLists.txt new file mode 100644 index 000000000..914191ba5 --- /dev/null +++ b/src/CPL/WRF_cpl/CMakeLists.txt @@ -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_include_directories(hydro_wrf_cpl PUBLIC + ${MPI_Fortran_MODULE_DIR} +)