diff --git a/CMakeLists.txt b/CMakeLists.txt index 4ea064b..6b6acbc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -111,36 +111,37 @@ if (BUILD_GEOS_GTFV3_INTERFACE) SRCS ${srcs} SUBCOMPONENTS fvdycore DEPENDENCIES ${dependencies} - DEPENDENCIES ${GFDL} DEPENDENCIES geos_gtfv3_interface_py) # Make the main library depend on the Python library else () esma_add_library (${this} SRCS ${srcs} SUBCOMPONENTS fvdycore - DEPENDENCIES ${dependencies} - DEPENDENCIES ${GFDL}) + DEPENDENCIES ${dependencies}) endif () if (FV_PRECISION STREQUAL R4) - set (GFDL FMS::fms_r4) + target_link_libraries (${this} PUBLIC FMS::fms_r4) + target_compile_definitions (${this} PRIVATE SINGLE_FV OVERLOAD_R4) elseif (FV_PRECISION STREQUAL R4R8) # FV is R4 but FMS is R8 - get_target_property (extra_incs FMS::fms_r4 INTERFACE_INCLUDE_DIRECTORIES) - target_include_directories(${this} PRIVATE $) - set (GFDL FMS::fms_r8) + # fvdycore needs r4 .mod interfaces + get_target_property(inc_r4 FMS::fms_r4 INTERFACE_INCLUDE_DIRECTORIES) + target_include_directories(${this} PRIVATE $) + + # But fvdycore should not *compile* with fms_r8 includes + target_link_libraries(${this} PUBLIC $) + + target_compile_definitions (${this} PRIVATE SINGLE_FV OVERLOAD_R4) + + # This tells CMake that we need these targets built before we can build + add_dependencies(${this} FMS::fms_r4 FMS::fms_r8) elseif (FV_PRECISION STREQUAL R8) - set (GFDL FMS::fms_r8) + target_link_libraries (${this} PUBLIC FMS::fms_r8) string(REPLACE " " ";" tmp ${FREAL8}) foreach(flag ${tmp}) target_compile_options (${this} PRIVATE $<$:${flag}>) endforeach() endif () -if (FV_PRECISION MATCHES R4) - target_compile_definitions (${this} PRIVATE -DSINGLE_FV -DOVERLOAD_R4) -elseif (FV_PRECISION MATCHES R4R8) # FV is R4 but FMS is R8 - target_compile_definitions (${this} PRIVATE -DSINGLE_FV -DOVERLOAD_R4) -endif () - message(STATUS "Building FV as ${FV_PRECISION}") #set (CMAKE_Fortran_FLAGS_RELEASE "${GEOS_Fortran_FLAGS_VECT}") @@ -149,11 +150,7 @@ if (CRAY_POINTER) set_target_properties (${this} PROPERTIES COMPILE_FLAGS ${CRAY_POINTER}) endif() -add_definitions (-DSPMD -DMAPL_MODE -DFVREGRID_MAPL_MODE) - -foreach(flag ${tmp}) - target_compile_options (${this} PRIVATE $<$:${flag}>) -endforeach() +target_compile_definitions (${this} PRIVATE MAPL_MODE FVREGRID_MAPL_MODE) ecbuild_add_executable ( TARGET StandAlone_FV3_Dycore.x @@ -196,6 +193,32 @@ ecbuild_add_executable ( SOURCES interp_restarts_bin.F90 LIBS ${this} OpenMP::OpenMP_Fortran) +# If we are doing R4R8 we also need add_dependencies for both fms_r4 and fms_r8 +# for all our executables that link to ${this} because of the way we set up the +# main library above. +if (FV_PRECISION STREQUAL R4R8) + foreach(executable + StandAlone_FV3_Dycore.x + rs_scale.x + StandAlone_AdvCore.x + StandAlone_DynAdvCore.x + c2c.x + interp_restarts.x + interp_restarts_bin.x) + + # fvdycore needs r4 .mod interfaces + get_target_property(inc_r4 FMS::fms_r4 INTERFACE_INCLUDE_DIRECTORIES) + target_include_directories(${executable} PRIVATE $) + + # But fvdycore should not *compile* with FMS::fms_r8 includes + target_link_libraries(${executable} $) + + # This tells CMake that we need these targets built before we can build + add_dependencies(${executable} FMS::fms_r4 FMS::fms_r8) + endforeach() +endif () + + if (BUILD_GEOS_GTFV3_INTERFACE) ecbuild_add_executable ( TARGET fv3_driver.x @@ -207,6 +230,16 @@ if (BUILD_GEOS_GTFV3_INTERFACE) geos-gtfv3/driver/input/input_arrays.f90 geos-gtfv3/driver/fv3_driver.F90 LIBS ${this}) + if (FV_PRECISION STREQUAL R4R8) + # fvdycore needs r4 .mod interfaces + get_target_property(inc_r4 FMS::fms_r4 INTERFACE_INCLUDE_DIRECTORIES) + target_include_directories(fv3_driver.x PRIVATE $) + + # But fvdycore should not *compile* with FMS::fms_r8 includes + target_link_libraries(fv3_driver.x PUBLIC $) + + add_dependencies(fv3_driver.x FMS::fms_r4 FMS::fms_r8) + endif () endif () add_subdirectory(scripts)