Skip to content

Commit

Permalink
Merge pull request #87 from COSIMA/several_fixes_and_lib_cleanup
Browse files Browse the repository at this point in the history
Several fixes and library dependencies cleanup
  • Loading branch information
micaeljtoliveira authored Nov 29, 2023
2 parents 808a6e5 + 6ce2fa6 commit 8160455
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 36 deletions.
18 changes: 12 additions & 6 deletions CDEPS/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

## Common library
add_fortran_library(OM3_cdeps_common mod/common STATIC)
add_library(AccessOM3::cdeps_common ALIAS OM3_cdeps_common)
target_include_directories(OM3_cdeps_common PRIVATE $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/fox/include>)
target_link_libraries(OM3_cdeps_common
PUBLIC esmf
PRIVATE OM3_share OM3_cmeps FoX::FoX PIO::PIO_Fortran
PRIVATE AccessOM3::share AccessOM3::cmeps AccessOM3::nuopc_cap_share FoX::FoX PIO::PIO_Fortran
)
target_sources(OM3_cdeps_common PRIVATE
CDEPS/streams/dshr_methods_mod.F90
Expand All @@ -20,10 +21,11 @@ target_sources(OM3_cdeps_common PRIVATE

## DATM
add_fortran_library(OM3_cdeps_datm mod/datm STATIC)
add_library(AccessOM3::cdeps_datm ALIAS OM3_cdeps_datm)
target_include_directories(OM3_cdeps_datm PRIVATE $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/fox/include>)
target_link_libraries(OM3_cdeps_datm
PUBLIC esmf
PRIVATE OM3_share OM3_cmeps FoX::FoX OM3_cdeps_common PIO::PIO_Fortran
PRIVATE AccessOM3::cdeps_common AccessOM3::share
)
target_sources(OM3_cdeps_datm PRIVATE
CDEPS/datm/datm_datamode_cfsr_mod.F90
Expand All @@ -39,10 +41,11 @@ add_patched_source(OM3_cdeps_datm CDEPS/datm/atm_comp_nuopc.F90)

## DOCN
add_fortran_library(OM3_cdeps_docn mod/docn STATIC)
add_library(AccessOM3::cdeps_docn ALIAS OM3_cdeps_docn)
target_include_directories(OM3_cdeps_docn PRIVATE $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/fox/include>)
target_link_libraries(OM3_cdeps_docn
PUBLIC esmf
PRIVATE OM3_share OM3_cmeps FoX::FoX OM3_cdeps_common PIO::PIO_Fortran
PRIVATE AccessOM3::cdeps_common AccessOM3::share
)
target_sources(OM3_cdeps_docn PRIVATE
CDEPS/docn/docn_datamode_aquaplanet_mod.F90
Expand All @@ -56,10 +59,11 @@ target_sources(OM3_cdeps_docn PRIVATE

## DICE
add_fortran_library(OM3_cdeps_dice mod/dice STATIC)
add_library(AccessOM3::cdeps_dice ALIAS OM3_cdeps_dice)
target_include_directories(OM3_cdeps_dice PRIVATE $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/fox/include>)
target_link_libraries(OM3_cdeps_dice
PUBLIC esmf
PRIVATE OM3_share OM3_cmeps FoX::FoX OM3_cdeps_common PIO::PIO_Fortran
PRIVATE AccessOM3::cdeps_common AccessOM3::share
)
target_sources(OM3_cdeps_dice PRIVATE
CDEPS/dice/dice_datamode_ssmi_mod.F90
Expand All @@ -69,21 +73,23 @@ target_sources(OM3_cdeps_dice PRIVATE

## DWAV
add_fortran_library(OM3_cdeps_dwav mod/dwav STATIC)
add_library(AccessOM3::cdeps_dwav ALIAS OM3_cdeps_dwav)
target_include_directories(OM3_cdeps_dwav PRIVATE $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/fox/include>)
target_link_libraries(OM3_cdeps_dwav
PUBLIC esmf
PRIVATE OM3_share OM3_cmeps FoX::FoX OM3_cdeps_common PIO::PIO_Fortran
PRIVATE AccessOM3::cdeps_common AccessOM3::share
)
target_sources(OM3_cdeps_dwav PRIVATE
CDEPS/dwav/wav_comp_nuopc.F90
)

## DROF
add_fortran_library(OM3_cdeps_drof mod/drof STATIC)
add_library(AccessOM3::cdeps_drof ALIAS OM3_cdeps_drof)
target_include_directories(OM3_cdeps_drof PRIVATE $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/fox/include>)
target_link_libraries(OM3_cdeps_drof
PUBLIC esmf
PRIVATE OM3_share OM3_cmeps FoX::FoX OM3_cdeps_common PIO::PIO_Fortran
PRIVATE AccessOM3::cdeps_common AccessOM3::share
)
target_sources(OM3_cdeps_drof PRIVATE
CDEPS/drof/rof_comp_nuopc.F90
Expand Down
3 changes: 2 additions & 1 deletion CICE/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@

## CICE library
add_fortran_library(OM3_cice mod STATIC)
add_library(AccessOM3::cice ALIAS OM3_cice)
target_compile_definitions(OM3_cice PRIVATE FORTRANUNDERSCORE ncdf)
if(OM3_CICE_IO MATCHES "^(NetCDF|PIO)$")
target_compile_definitions(OM3_cice PRIVATE USE_NETCDF)
endif()
target_link_libraries(OM3_cice
PUBLIC esmf
PRIVATE OM3_share OM3_timing OM3_cdeps_common OM3_cmeps
PRIVATE AccessOM3::cdeps_common AccessOM3::nuopc_cap_share AccessOM3::share AccessOM3::timing
)
if(OM3_CICE_IO MATCHES "^(NetCDF|PIO)$")
target_link_libraries(OM3_cice PRIVATE NetCDF::NetCDF_Fortran)
Expand Down
14 changes: 12 additions & 2 deletions CMEPS/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
### Targets

## CMEPS library
add_fortran_library(OM3_cmeps mod STATIC)
add_fortran_library(OM3_cmeps mod/cmeps STATIC)
add_library(AccessOM3::cmeps ALIAS OM3_cmeps)
target_link_libraries(OM3_cmeps
PUBLIC esmf
PRIVATE OM3_share OM3_timing PIO::PIO_Fortran
PRIVATE AccessOM3::nuopc_cap_share AccessOM3::share AccessOM3::timing
)
if(OpenMP_Fortran_FOUND)
target_link_libraries(OM3_cmeps PRIVATE OpenMP::OpenMP_Fortran)
Expand Down Expand Up @@ -46,7 +47,16 @@ target_sources(OM3_cmeps PRIVATE
CMEPS/mediator/med_phases_post_glc_mod.F90
CMEPS/mediator/med_phases_post_rof_mod.F90
CMEPS/mediator/med_phases_post_wav_mod.F90
)

## NUOPC cap share
add_fortran_library(OM3_nuopc_cap_share mod/nuopc_cap_share STATIC)
add_library(AccessOM3::nuopc_cap_share ALIAS OM3_nuopc_cap_share)
target_link_libraries(OM3_nuopc_cap_share
PUBLIC esmf
PRIVATE AccessOM3::share
)
target_sources(OM3_nuopc_cap_share PRIVATE
CMEPS/cesm/nuopc_cap_share/driver_pio_mod.F90
CMEPS/cesm/nuopc_cap_share/esm_utils_mod.F90
CMEPS/cesm/nuopc_cap_share/glc_elevclass_mod.F90
Expand Down
42 changes: 24 additions & 18 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,15 @@ message(STATUS " - MOM6-CICE6-WW3 ${OM3_ENABLE_MOM6-CICE6-WW3}")

# Build options
option(OM3_BIN_INSTALL "Instal ACCESS-OM3 executables" ${PROJECT_IS_TOP_LEVEL})
option(OM3_LIB_INSTALL "Instal ACCESS-OM3 libraries" OFF)
option(OM3_OPENMP "Enable OpenMP threading" OFF)
option(OM3_MOM_SYMMETRIC "Use symmetric memory" OFF)
set(OM3_CICE_IO "PIO" CACHE STRING "CICE OPTIONS: Choose IO options.")
set_property(CACHE OM3_CICE_IO PROPERTY STRINGS "NetCDF" "PIO" "Binary")

message(STATUS "Build options")
message(STATUS " - OM3_BIN_INSTALL ${OM3_BIN_INSTALL}")
message(STATUS " - OM3_LIB_INSTALL ${OM3_LIB_INSTALL}")
message(STATUS " - OM3_OPENMP ${OM3_OPENMP}")
message(STATUS " - OM3_MOM_SYMMETRIC ${OM3_MOM_SYMMETRIC}")
message(STATUS " - OM3_CICE_IO ${OM3_CICE_IO}")
Expand All @@ -63,20 +65,24 @@ include(AddPatchedSource)

# Do not build components that are not going to be used
if(OM3_ENABLE_MOM6 OR OM3_ENABLE_MOM6-CICE6 OR OM3_ENABLE_MOM6-WW3 OR OM3_ENABLE_MOM6-CICE6-WW3)
set(OM3_MOM6 ON FORCE)
set(OM3_BUILD_MOM6 ON)
else()
set(OM3_MOM6 OFF FORCE)
set(OM3_BUILD_MOM6 OFF)
endif()
if(OM3_ENABLE_CICE6 OR OM3_ENABLE_MOM6-CICE6 OR OM3_ENABLE_CICE6-WW3 OR OM3_ENABLE_MOM6-CICE6-WW3)
set(OM3_CICE6 ON FORCE)
set(OM3_BUILD_CICE6 ON)
else()
set(OM3_CICE6 OFF FORCE)
set(OM3_BUILD_CICE6 OFF)
endif()
if(OM3_ENABLE_WW3 OR OM3_ENABLE_MOM6-WW3 OR OM3_ENABLE_CICE6-WW3 OR OM3_ENABLE_MOM6-CICE6-WW3)
set(OM3_WW3 ON FORCE)
set(OM3_BUILD_WW3 ON)
else()
set(OM3_WW3 OFF FORCE)
set(OM3_BUILD_WW3 OFF)
endif()
message(STATUS "Components to build")
message(STATUS " - OM3_BUILD_MOM6 ${OM3_BUILD_MOM6}")
message(STATUS " - OM3_BUILD_CICE6 ${OM3_BUILD_CICE6}")
message(STATUS " - OM3_BUILD_WW3 ${OM3_BUILD_WW3}")

# Common compiler flags and definitions
if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU")
Expand Down Expand Up @@ -138,17 +144,17 @@ add_subdirectory(share)
add_subdirectory(CDEPS)

# Ocean component (MOM6)
if(OM3_MOM6)
if(OM3_BUILD_MOM6)
add_subdirectory(MOM6)
endif()

# Sea-ice component (CICE6)
if(OM3_CICE6)
if(OM3_BUILD_CICE6)
add_subdirectory(CICE)
endif()

# Wave component (WW3)
if(OM3_WW3)
if(OM3_BUILD_WW3)
add_subdirectory(WW3)
endif()

Expand All @@ -163,30 +169,30 @@ foreach(CONF IN LISTS KnownConfigurations)

set(ComponentsTargets "")
if(OM3_${CONF} MATCHES MOM6)
list(APPEND ComponentsTargets OM3_mom6)
list(APPEND ComponentsTargets AccessOM3::mom6)
else()
list(APPEND ComponentsTargets OM3_cdeps_docn)
list(APPEND ComponentsTargets AccessOM3::cdeps_docn)
endif()
if(OM3_${CONF} MATCHES CICE6)
list(APPEND ComponentsTargets OM3_cice)
list(APPEND ComponentsTargets AccessOM3::cice)
else()
list(APPEND ComponentsTargets OM3_cdeps_dice)
list(APPEND ComponentsTargets AccessOM3::cdeps_dice)
endif()
if(OM3_${CONF} MATCHES WW3)
list(APPEND ComponentsTargets OM3_ww3)
list(APPEND ComponentsTargets AccessOM3::ww3)
else()
list(APPEND ComponentsTargets OM3_cdeps_dwav)
list(APPEND ComponentsTargets AccessOM3::cdeps_dwav)
endif()

# We use the CESM driver from CMEPS
add_fortran_library(OM3_cesm_driver_${CONF} OM3_cesm_driver_${CONF}/mod STATIC
add_fortran_library(OM3_cesm_driver_${CONF} mod/OM3_cesm_driver_${CONF} STATIC
CMEPS/CMEPS/cesm/driver/esm.F90
CMEPS/CMEPS/cesm/driver/ensemble_driver.F90
CMEPS/CMEPS/cesm/driver/esm_time_mod.F90
)
target_link_libraries(OM3_cesm_driver_${CONF}
PUBLIC esmf
PRIVATE OM3_share OM3_timing ${ComponentsTargets} OM3_cmeps OM3_cdeps_common OM3_cdeps_drof OM3_cdeps_datm PIO::PIO_Fortran
PRIVATE ${ComponentsTargets} AccessOM3::cdeps_drof AccessOM3::cdeps_datm AccessOM3::cmeps AccessOM3::nuopc_cap_share AccessOM3::share AccessOM3::timing
)
target_compile_definitions(OM3_cesm_driver_${CONF} PRIVATE MED_PRESENT
ATM_PRESENT
Expand All @@ -198,7 +204,7 @@ foreach(CONF IN LISTS KnownConfigurations)
)

add_executable(OM3_${CONF} CMEPS/CMEPS/cesm/driver/esmApp.F90)
target_link_libraries(OM3_${CONF} PRIVATE OM3_cesm_driver_${CONF} OM3_share esmf)
target_link_libraries(OM3_${CONF} PRIVATE OM3_cesm_driver_${CONF} AccessOM3::share esmf)

set_target_properties(OM3_${CONF} PROPERTIES
LINKER_LANGUAGE Fortran
Expand Down
3 changes: 2 additions & 1 deletion MOM6/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ endif()

## MOM6 library
add_fortran_library(OM3_mom6 mod STATIC)
add_library(AccessOM3::mom6 ALIAS OM3_mom6)
target_include_directories(OM3_mom6 PRIVATE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/MOM6/src/framework>)
if(OM3_MOM_SYMMETRIC)
target_include_directories(OM3_mom6 PRIVATE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/MOM6/config_src/memory/dynamic_symmetric>)
Expand All @@ -20,7 +21,7 @@ endif()
target_compile_options(OM3_mom6 PRIVATE "$<$<COMPILE_LANGUAGE:Fortran>:${fortran_compile_flags}>")
target_link_libraries(OM3_mom6
PUBLIC esmf
PRIVATE OM3_share OM3_cmeps FMS::fms_r8 NetCDF::NetCDF_Fortran
PRIVATE AccessOM3::nuopc_cap_share AccessOM3::share FMS::fms_r8
)
target_sources(OM3_mom6 PRIVATE
MOM6/src/ALE/coord_adapt.F90
Expand Down
14 changes: 7 additions & 7 deletions WW3/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ endforeach()

## WW3 library
add_fortran_library(OM3_ww3 mod STATIC)
add_library(AccessOM3::ww3 ALIAS OM3_ww3)
target_compile_definitions(OM3_ww3 PRIVATE ENDIANNESS="big_endian")
set_property(SOURCE WW3/model/src/w3initmd.F90
APPEND
Expand All @@ -20,7 +21,6 @@ set_property(SOURCE WW3/model/src/w3initmd.F90
)
target_link_libraries(OM3_ww3
PUBLIC esmf
PRIVATE NetCDF::NetCDF_Fortran
)
# Process switches and get list of extra source files
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/check_switches.cmake)
Expand Down Expand Up @@ -101,23 +101,23 @@ set_target_properties(OM3_ww3_grid PROPERTIES
LINKER_LANGUAGE Fortran
OUTPUT_NAME ww3_grid
)
target_link_libraries(OM3_ww3_grid PRIVATE OM3_ww3)
target_link_libraries(OM3_ww3_grid PRIVATE AccessOM3::ww3)

# ww3_strt
add_executable(OM3_ww3_strt WW3/model/src/ww3_strt.F90)
set_target_properties(OM3_ww3_strt PROPERTIES
LINKER_LANGUAGE Fortran
OUTPUT_NAME ww3_strt
)
target_link_libraries(OM3_ww3_strt PRIVATE OM3_ww3)
target_link_libraries(OM3_ww3_strt PRIVATE AccessOM3::ww3)

# ww3_outf
add_executable(OM3_ww3_outf WW3/model/src/ww3_outf.F90)
set_target_properties(OM3_ww3_outf PROPERTIES
LINKER_LANGUAGE Fortran
OUTPUT_NAME ww3_outf
)
target_link_libraries(OM3_ww3_outf PRIVATE OM3_ww3)
target_link_libraries(OM3_ww3_outf PRIVATE AccessOM3::ww3)

# ww3_ounf
add_executable(OM3_ww3_ounf)
Expand All @@ -129,19 +129,19 @@ set_target_properties(OM3_ww3_ounf PROPERTIES
LINKER_LANGUAGE Fortran
OUTPUT_NAME ww3_ounf
)
target_link_libraries(OM3_ww3_ounf PRIVATE OM3_ww3)
target_link_libraries(OM3_ww3_ounf PRIVATE AccessOM3::ww3)

# ww3_ounp
add_executable(OM3_ww3_ounp WW3/model/src/ww3_ounp.F90)
set_target_properties(OM3_ww3_ounp PROPERTIES
LINKER_LANGUAGE Fortran
OUTPUT_NAME ww3_ounp
)
target_link_libraries(OM3_ww3_ounp PRIVATE OM3_ww3)
target_link_libraries(OM3_ww3_ounp PRIVATE AccessOM3::ww3)


## Installs
if(OM3_BIN_INSTALL)
install(TARGETS OM3_ww3_grid OM3_ww3_strt OM3_ww3_ounf OM3_ww3_ounp
install(TARGETS OM3_ww3_grid OM3_ww3_strt OM3_ww3_outf OM3_ww3_ounf OM3_ww3_ounp
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()
4 changes: 3 additions & 1 deletion share/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## share library
add_fortran_library(OM3_share mod/share STATIC)
add_library(AccessOM3::share ALIAS OM3_share)
target_include_directories(OM3_share PUBLIC CESM_share/include)
if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU")
target_compile_definitions(OM3_share PRIVATE CPRGNU NAMING=_ADD_UNDERSCORE FORTRANUNDERSCORE)
Expand All @@ -10,7 +11,7 @@ elseif(CMAKE_Fortran_COMPILER_ID MATCHES "Intel")
endif()
target_link_libraries(OM3_share
PUBLIC esmf PIO::PIO_Fortran
PRIVATE OM3_timing
PRIVATE AccessOM3::timing
)
target_sources(OM3_share PRIVATE
# The following files are generated with a script acting on templates
Expand Down Expand Up @@ -53,6 +54,7 @@ endif()

## GPTL timing library
add_fortran_library(OM3_timing mod/timing STATIC)
add_library(AccessOM3::timing ALIAS OM3_timing)
target_compile_definitions(OM3_timing PRIVATE NUOPC_INTERFACE HAVE_MPI)
if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU")
target_compile_definitions(OM3_timing PRIVATE CPRGNU NAMING=_ADD_UNDERSCORE FORTRANUNDERSCORE)
Expand Down

0 comments on commit 8160455

Please sign in to comment.