From 83a8083d3c82f2cc586bf5ccd1f17b6250436cd3 Mon Sep 17 00:00:00 2001 From: Micael Oliveira Date: Tue, 4 Apr 2023 14:57:27 +1000 Subject: [PATCH] Several further changes to use the CESM driver: - compile the corresponding MOM6 cap (this is simply a module wrapper around the real cap). - add options to turn on/off the different components (MOM6, WW3 and CICE6). - do not compile the data components when the corresponding model component is used. - set the *_PRESENT compile definitions for the CESM driver. --- CDEPS/CMakeLists.txt | 37 +++++++++++++++++++++++++------------ CMakeLists.txt | 37 +++++++++++++++++++++++++++++-------- MOM6/mom6_files.cmake | 1 + 3 files changed, 55 insertions(+), 20 deletions(-) diff --git a/CDEPS/CMakeLists.txt b/CDEPS/CMakeLists.txt index ef1873d..df4af19 100644 --- a/CDEPS/CMakeLists.txt +++ b/CDEPS/CMakeLists.txt @@ -30,23 +30,36 @@ list(APPEND cdeps_src_files CDEPS/datm/datm_datamode_gefs_mod.F90 CDEPS/datm/datm_datamode_jra_mod.F90 - CDEPS/dice/dice_datamode_ssmi_mod.F90 - CDEPS/dice/dice_flux_atmice_mod.F90 - CDEPS/dice/ice_comp_nuopc.F90 - CDEPS/dlnd/lnd_comp_nuopc.F90 - CDEPS/docn/docn_datamode_aquaplanet_mod.F90 - CDEPS/docn/docn_datamode_copyall_mod.F90 - CDEPS/docn/docn_datamode_iaf_mod.F90 - CDEPS/docn/docn_datamode_som_mod.F90 - CDEPS/docn/ocn_comp_nuopc.F90 - CDEPS/drof/rof_comp_nuopc.F90 - - CDEPS/dwav/wav_comp_nuopc.F90 ) + +if(NOT ENABLE_MOM6) + list(APPEND cdeps_src_files + CDEPS/docn/docn_datamode_aquaplanet_mod.F90 + CDEPS/docn/docn_datamode_copyall_mod.F90 + CDEPS/docn/docn_datamode_iaf_mod.F90 + CDEPS/docn/docn_datamode_som_mod.F90 + CDEPS/docn/ocn_comp_nuopc.F90 + ) +endif() + +if(NOT ENABLE_CICE) + list(APPEND cdeps_src_files + CDEPS/dice/dice_datamode_ssmi_mod.F90 + CDEPS/dice/dice_flux_atmice_mod.F90 + CDEPS/dice/ice_comp_nuopc.F90 + ) +endif() + +if(NOT ENABLE_WW3) + list(APPEND cdeps_src_files + CDEPS/dwav/wav_comp_nuopc.F90 + ) +endif() + add_library(cdeps STATIC ${cdeps_src_files}) set_target_properties(cdeps PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/mod) diff --git a/CMakeLists.txt b/CMakeLists.txt index d941c5f..e5da1c6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,6 +6,11 @@ project(ACCESS-OM3 list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake) +# Components to enable +set(ENABLE_MOM6 ON CACHE BOOL "Enable MOM6") +set(ENABLE_CICE ON CACHE BOOL "Enable CICE6") +set(ENABLE_WW3 OFF CACHE BOOL "Enable WW3") + # Build options set(OPENMP ON CACHE BOOL "Enable OpenMP threading") @@ -61,14 +66,23 @@ add_subdirectory(share) # Components # Ocean component (MOM6) -add_subdirectory(MOM6) +if(ENABLE_MOM6) + add_subdirectory(MOM6) + list(APPEND COMPONENTS_TARGETS mom6) +endif() # Sea-ice component (CICE6) -add_subdirectory(CICE) +if(ENABLE_CICE) + add_subdirectory(CICE) + list(APPEND COMPONENTS_TARGETS cice) +endif() # Wave component (WW3) -set(SWITCH "multi_esmf" CACHE STRING "NUOPC mesh cap") -add_subdirectory(WW3) +if(ENABLE_WW3) + set(SWITCH "multi_esmf" CACHE STRING "NUOPC mesh cap") + add_subdirectory(WW3) + list(APPEND COMPONENTS_TARGETS WW3::WW3) +endif() # Mediator component (CMEPS) add_subdirectory(CMEPS) @@ -85,13 +99,20 @@ add_library(cesm_driver CMEPS/CMEPS/cesm/driver/ensemble_driver.F90 CMEPS/CMEPS/cesm/driver/esm_time_mod.F90 ) -target_link_libraries(cesm_driver PUBLIC share mom6 cice WW3::WW3 cmeps cdeps esmf PIO::PIO_Fortran) - +target_link_libraries(cesm_driver PUBLIC share ${COMPONENTS_TARGETS} cmeps cdeps esmf PIO::PIO_Fortran) set_target_properties(cesm_driver PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/mod) target_include_directories(cesm_driver PUBLIC $ - $) - + $) + +target_compile_definitions(cesm_driver PRIVATE MED_PRESENT + ATM_PRESENT + ICE_PRESENT + LND_PRESENT + OCN_PRESENT + WAV_PRESENT + ROF_PRESENT +) add_executable(access-om3 CMEPS/CMEPS/cesm/driver/esmApp.F90) target_link_libraries(access-om3 PRIVATE cesm_driver esmf PIO::PIO_Fortran NetCDF::NetCDF_Fortran) diff --git a/MOM6/mom6_files.cmake b/MOM6/mom6_files.cmake index a09403e..f50824a 100644 --- a/MOM6/mom6_files.cmake +++ b/MOM6/mom6_files.cmake @@ -293,6 +293,7 @@ list(APPEND mom6_src_files MOM6/config_src/infra/FMS2/MOM_time_manager.F90 MOM6/config_src/drivers/nuopc_cap/mom_cap.F90 + MOM6/config_src/drivers/nuopc_cap/ocn_comp_NUOPC.F90 MOM6/config_src/drivers/nuopc_cap/time_utils.F90 MOM6/config_src/drivers/nuopc_cap/mom_cap_methods.F90 MOM6/config_src/drivers/nuopc_cap/mom_cap_time.F90