diff --git a/.github/ISSUE_TEMPLATE/parameter-testing.yml b/.github/ISSUE_TEMPLATE/parameter-testing.yml deleted file mode 100644 index afdd3bc..0000000 --- a/.github/ISSUE_TEMPLATE/parameter-testing.yml +++ /dev/null @@ -1,41 +0,0 @@ -name: Parameter Testing -description: Template for tracking parameter testing issues -title: "[Parameter Testing] " -labels: "Parameter-testing" -assignees: [optional-assignee] -body: - - type: markdown - attributes: - value: | - Please fill out the sections below to clearly and concisely describe: - 1. the parameter(s) tested, - 2. the exact version of the test tool (Expts_manager) used. - - - type: textarea - attributes: - label: Parameter Tests Description - placeholder: "including a short description and Parameter Name(s): Value(s) Tested" - validations: - required: true - - - type: input - attributes: - label: Expts_manager Version - placeholder: Git URL including commit hash - validations: - required: true - - - type: textarea - attributes: - label: YAML input file - placeholder: | - ```yaml - Copy the yaml input file used - ``` - validations: - required: true - - - type: textarea - attributes: - label: Additional Information - placeholder: Any other relevant information... diff --git a/.github/workflows/compilation.yml b/.github/workflows/compilation.yml deleted file mode 100644 index c17b188..0000000 --- a/.github/workflows/compilation.yml +++ /dev/null @@ -1,33 +0,0 @@ -name: compilation - -on: - push: - -jobs: - compilation: - runs-on: ubuntu-latest - - strategy: - fail-fast: false - matrix: - compiler: [gcc] - build_type: [Debug, Release] - - container: - image: ghcr.io/cosima/access-om3-ci-images/${{matrix.compiler}}:main - - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - submodules: recursive - - - name: Configure CMake - env: - FC: mpifort - CC: mpicc - run: . /etc/profile && cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DCMAKE_VERBOSE_MAKEFILE=ON - - - name: Build - # Build your program with the given configuration - run: . /etc/profile && cmake --build ${{github.workspace}}/build --config ${{matrix.build_type}} diff --git a/CDEPS/CMakeLists.txt b/CDEPS/CMakeLists.txt index 16d7f10..785c1eb 100644 --- a/CDEPS/CMakeLists.txt +++ b/CDEPS/CMakeLists.txt @@ -1,14 +1,17 @@ +# Copyright ACCESS-NRI and contributors. See the top-level COPYRIGHT file for details. +# SPDX-License-Identifier: Apache-2.0 + ### Targets ## 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 $) -target_link_libraries(OM3_cdeps_common - PUBLIC esmf - PRIVATE AccessOM3::share AccessOM3::cmeps AccessOM3::nuopc_cap_share FoX::FoX PIO::PIO_Fortran +add_fortran_library(ACCESS3_cdeps_common mod/common STATIC) +add_library(Access3::cdeps_common ALIAS ACCESS3_cdeps_common) +target_include_directories(ACCESS3_cdeps_common PRIVATE $) +target_link_libraries(ACCESS3_cdeps_common + PUBLIC ESMF::ESMF + PRIVATE Access3::share Access3::cmeps Access3::nuopc_cap_share FoX::FoX ) -target_sources(OM3_cdeps_common PRIVATE +target_sources(ACCESS3_cdeps_common PRIVATE CDEPS/streams/dshr_methods_mod.F90 CDEPS/streams/dshr_strdata_mod.F90 CDEPS/streams/dshr_stream_mod.F90 @@ -20,14 +23,14 @@ 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 $) -target_link_libraries(OM3_cdeps_datm - PUBLIC esmf - PRIVATE AccessOM3::cdeps_common AccessOM3::share +add_fortran_library(ACCESS3_cdeps_datm mod/datm STATIC) +add_library(Access3::cdeps_datm ALIAS ACCESS3_cdeps_datm) +target_include_directories(ACCESS3_cdeps_datm PRIVATE $) +target_link_libraries(ACCESS3_cdeps_datm + PUBLIC ESMF::ESMF + PRIVATE Access3::cdeps_common Access3::share ) -target_sources(OM3_cdeps_datm PRIVATE +target_sources(ACCESS3_cdeps_datm PRIVATE CDEPS/datm/datm_datamode_cfsr_mod.F90 CDEPS/datm/datm_datamode_clmncep_mod.F90 CDEPS/datm/datm_datamode_core2_mod.F90 @@ -38,17 +41,17 @@ target_sources(OM3_cdeps_datm PRIVATE CDEPS/datm/datm_datamode_simple_mod.F90 extra_sources/datm_datamode_jra55do_mod.F90 ) -add_patched_source(OM3_cdeps_datm CDEPS/datm/atm_comp_nuopc.F90) +add_patched_source(ACCESS3_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 $) -target_link_libraries(OM3_cdeps_docn - PUBLIC esmf - PRIVATE AccessOM3::cdeps_common AccessOM3::share +add_fortran_library(ACCESS3_cdeps_docn mod/docn STATIC) +add_library(Access3::cdeps_docn ALIAS ACCESS3_cdeps_docn) +target_include_directories(ACCESS3_cdeps_docn PRIVATE $) +target_link_libraries(ACCESS3_cdeps_docn + PUBLIC ESMF::ESMF + PRIVATE Access3::cdeps_common Access3::share ) -target_sources(OM3_cdeps_docn PRIVATE +target_sources(ACCESS3_cdeps_docn PRIVATE CDEPS/docn/docn_datamode_aquaplanet_mod.F90 CDEPS/docn/docn_datamode_copyall_mod.F90 CDEPS/docn/docn_datamode_cplhist_mod.F90 @@ -61,80 +64,93 @@ 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 $) -target_link_libraries(OM3_cdeps_dice - PUBLIC esmf - PRIVATE AccessOM3::cdeps_common AccessOM3::share +add_fortran_library(ACCESS3_cdeps_dice mod/dice STATIC) +add_library(Access3::cdeps_dice ALIAS ACCESS3_cdeps_dice) +target_include_directories(ACCESS3_cdeps_dice PRIVATE $) +target_link_libraries(ACCESS3_cdeps_dice + PUBLIC ESMF::ESMF + PRIVATE Access3::cdeps_common Access3::share ) -target_sources(OM3_cdeps_dice PRIVATE +target_sources(ACCESS3_cdeps_dice PRIVATE CDEPS/dice/dice_datamode_ssmi_mod.F90 CDEPS/dice/dice_flux_atmice_mod.F90 CDEPS/dice/ice_comp_nuopc.F90 ) ## 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 $) -target_link_libraries(OM3_cdeps_dwav - PUBLIC esmf - PRIVATE AccessOM3::cdeps_common AccessOM3::share +add_fortran_library(ACCESS3_cdeps_dwav mod/dwav STATIC) +add_library(Access3::cdeps_dwav ALIAS ACCESS3_cdeps_dwav) +target_include_directories(ACCESS3_cdeps_dwav PRIVATE $) +target_link_libraries(ACCESS3_cdeps_dwav + PUBLIC ESMF::ESMF + PRIVATE Access3::cdeps_common Access3::share ) -target_sources(OM3_cdeps_dwav PRIVATE +target_sources(ACCESS3_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 $) -target_link_libraries(OM3_cdeps_drof - PUBLIC esmf - PRIVATE AccessOM3::cdeps_common AccessOM3::share +add_fortran_library(ACCESS3_cdeps_drof mod/drof STATIC) +add_library(Access3::cdeps_drof ALIAS ACCESS3_cdeps_drof) +target_include_directories(ACCESS3_cdeps_drof PRIVATE $) +target_link_libraries(ACCESS3_cdeps_drof + PUBLIC ESMF::ESMF + PRIVATE Access3::cdeps_common Access3::share ) -target_sources(OM3_cdeps_drof PRIVATE +target_sources(ACCESS3_cdeps_drof PRIVATE CDEPS/drof/rof_comp_nuopc.F90 ) ### Install and Export -## Library -if(OM3_LIB_INSTALL) - # cdeps_common - set_target_properties(OM3_cdeps_common PROPERTIES - OUTPUT_NAME access-cdeps-common - EXPORT_NAME cdeps-common +# cdeps_common +set_target_properties(ACCESS3_cdeps_common PROPERTIES + OUTPUT_NAME access-cdeps-common + EXPORT_NAME cdeps-common +) +install(TARGETS ACCESS3_cdeps_common + EXPORT Access3Sharecdeps_Targets + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT Access3Share_RunTime NAMELINK_COMPONENT Access3Share_Development + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT Access3Share_Development +) +# Fortran module files are a special case, as currently there is no standard + # way of handling them in CMake + target_include_directories(ACCESS3_cdeps_common PUBLIC "$") + get_target_property(common_moddir ACCESS3_cdeps_common Fortran_MODULE_DIRECTORY) + install(FILES + ${common_moddir}/dshr_methods_mod.mod + ${common_moddir}/dshr_strdata_mod.mod + ${common_moddir}/dshr_stream_mod.mod + ${common_moddir}/dshr_tinterp_mod.mod + + ${common_moddir}/dshr_dfield_mod.mod + ${common_moddir}/dshr_fldlist_mod.mod + ${common_moddir}/dshr_mod.mod + DESTINATION ${CMAKE_INSTALL_MODULEDIR}/access-cdeps-common + COMPONENT Access3Share_Development + ) +# components +foreach(LIB atm ocn ice wav rof) + set_target_properties(ACCESS3_cdeps_d${LIB} PROPERTIES + OUTPUT_NAME access-cdeps-d${LIB} + EXPORT_NAME cdeps-d${LIB} ) - install(TARGETS OM3_cdeps_common - EXPORT AccessOM3cdeps_Targets - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT AccessOM3_RunTime NAMELINK_COMPONENT AccessOM3_Development - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT AccessOM3_Development + install(TARGETS ACCESS3_cdeps_d${LIB} + EXPORT Access3Sharecdeps_Targets + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT Access3Share_RunTime NAMELINK_COMPONENT Access3Share_Development + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT Access3Share_Development ) - # components - foreach(LIB atm ocn ice wav rof) - set_target_properties(OM3_cdeps_d${LIB} PROPERTIES - OUTPUT_NAME access-cdeps-d${LIB} - EXPORT_NAME cdeps-d${LIB} - ) - install(TARGETS OM3_cdeps_d${LIB} - EXPORT AccessOM3cdeps_Targets - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT AccessOM3_RunTime NAMELINK_COMPONENT AccessOM3_Development - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT AccessOM3_Development - ) - # Fortran module files are a special case, as currently there is no standard - # way of handling them in CMake - target_include_directories(OM3_cdeps_d${LIB} PUBLIC "$") - get_target_property(d${LIB}_moddir OM3_cdeps_d${LIB} Fortran_MODULE_DIRECTORY) - install(FILES ${d${LIB}_moddir}/${LIB}_comp_nuopc.mod - DESTINATION ${CMAKE_INSTALL_MODULEDIR}/access-cdeps-d${LIB} - COMPONENT AccessOM3_Development - ) - endforeach() - install(EXPORT AccessOM3cdeps_Targets - FILE AccessOM3cdepsTargets.cmake - NAMESPACE AccessOM3:: - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/AccessOM3 + # Fortran module files are a special case, as currently there is no standard + # way of handling them in CMake + target_include_directories(ACCESS3_cdeps_d${LIB} PUBLIC "$") + get_target_property(d${LIB}_moddir ACCESS3_cdeps_d${LIB} Fortran_MODULE_DIRECTORY) + install(FILES ${d${LIB}_moddir}/${LIB}_comp_nuopc.mod + DESTINATION ${CMAKE_INSTALL_MODULEDIR}/access-cdeps-d${LIB} + COMPONENT Access3Share_Development ) -endif() +endforeach() +install(EXPORT Access3Sharecdeps_Targets + FILE Access3SharecdepsTargets.cmake + NAMESPACE Access3:: + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/Access3Share +) \ No newline at end of file diff --git a/CDEPS/extra_sources/datm_datamode_jra55do_mod.F90 b/CDEPS/extra_sources/datm_datamode_jra55do_mod.F90 index d97837b..53d6e49 100644 --- a/CDEPS/extra_sources/datm_datamode_jra55do_mod.F90 +++ b/CDEPS/extra_sources/datm_datamode_jra55do_mod.F90 @@ -1,3 +1,6 @@ +! Copyright ACCESS-NRI and contributors. See the top-level COPYRIGHT file for details. +! SPDX-License-Identifier: Apache-2.0 + module datm_datamode_jra55do_mod use ESMF , only : ESMF_State, ESMF_StateGet, ESMF_SUCCESS, ESMF_LogWrite, ESMF_LOGMSG_INFO diff --git a/CDEPS/patches/atm_comp_nuopc.F90.patch b/CDEPS/patches/atm_comp_nuopc.F90.patch index 3e8dd23..43ffb73 100644 --- a/CDEPS/patches/atm_comp_nuopc.F90.patch +++ b/CDEPS/patches/atm_comp_nuopc.F90.patch @@ -1,3 +1,6 @@ +# Copyright ACCESS-NRI and contributors. See the top-level COPYRIGHT file for details. +# SPDX-License-Identifier: Apache-2.0 + diff --git a/datm/atm_comp_nuopc.F90 b/datm/atm_comp_nuopc.F90 index b74e0d3..bb31c22 100644 --- a/datm/atm_comp_nuopc.F90 diff --git a/CMEPS/CMakeLists.txt b/CMEPS/CMakeLists.txt index 6aa109b..9d628e4 100644 --- a/CMEPS/CMakeLists.txt +++ b/CMEPS/CMakeLists.txt @@ -1,16 +1,19 @@ +# Copyright ACCESS-NRI and contributors. See the top-level COPYRIGHT file for details. +# SPDX-License-Identifier: Apache-2.0 + ### Targets ## CMEPS library -add_fortran_library(OM3_cmeps mod/cmeps STATIC) -add_library(AccessOM3::cmeps ALIAS OM3_cmeps) -target_link_libraries(OM3_cmeps - PUBLIC esmf - PRIVATE AccessOM3::nuopc_cap_share AccessOM3::share AccessOM3::timing +add_fortran_library(ACCESS3_cmeps mod/cmeps STATIC) +add_library(Access3::cmeps ALIAS ACCESS3_cmeps) +target_link_libraries(ACCESS3_cmeps + PUBLIC ESMF::ESMF + PRIVATE Access3::nuopc_cap_share Access3::share Access3::timing ) if(OpenMP_Fortran_FOUND) - target_link_libraries(OM3_cmeps PRIVATE OpenMP::OpenMP_Fortran) + target_link_libraries(ACCESS3_cmeps PRIVATE OpenMP::OpenMP_Fortran) endif() -target_sources(OM3_cmeps PRIVATE +target_sources(ACCESS3_cmeps PRIVATE CMEPS/cesm/flux_atmocn/shr_flux_mod.F90 CMEPS/mediator/med_phases_history_mod.F90 CMEPS/mediator/med_phases_restart_mod.F90 @@ -49,13 +52,13 @@ target_sources(OM3_cmeps PRIVATE ) ## 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 +add_fortran_library(ACCESS3_nuopc_cap_share mod/nuopc_cap_share STATIC) +add_library(Access3::nuopc_cap_share ALIAS ACCESS3_nuopc_cap_share) +target_link_libraries(ACCESS3_nuopc_cap_share + PUBLIC ESMF::ESMF + PRIVATE Access3::share ) -target_sources(OM3_nuopc_cap_share PRIVATE +target_sources(ACCESS3_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 @@ -64,52 +67,50 @@ target_sources(OM3_nuopc_cap_share PRIVATE ### Install and Export -if(OM3_LIB_INSTALL) - ## CMEPS library - set_target_properties(OM3_cmeps PROPERTIES - OUTPUT_NAME access-cmeps - EXPORT_NAME cmeps - ) - install(TARGETS OM3_cmeps - EXPORT AccessOM3cmeps_Targets - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT AccessOM3_RunTime NAMELINK_COMPONENT AccessOM3_Development - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT AccessOM3_Development - ) - # Fortran module files are a special case, as currently there is no standard - # way of handling them in CMake - target_include_directories(OM3_cmeps PUBLIC "$") - get_target_property(cmeps_moddir OM3_cmeps Fortran_MODULE_DIRECTORY) - install(FILES ${cmeps_moddir}/med.mod ${cmeps_moddir}/med_time_mod.mod ${cmeps_moddir}/med_internalstate_mod.mod - DESTINATION ${CMAKE_INSTALL_MODULEDIR}/access-cmeps - COMPONENT AccessOM3_Development - ) - install(EXPORT AccessOM3cmeps_Targets - FILE AccessOM3cmepsTargets.cmake - NAMESPACE AccessOM3:: - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/AccessOM3 - ) +## CMEPS library +set_target_properties(ACCESS3_cmeps PROPERTIES + OUTPUT_NAME access-cmeps + EXPORT_NAME cmeps +) +install(TARGETS ACCESS3_cmeps + EXPORT Access3Sharecmeps_Targets + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT Access3Share_RunTime NAMELINK_COMPONENT Access3Share_Development + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT Access3Share_Development +) +# Fortran module files are a special case, as currently there is no standard +# way of handling them in CMake +target_include_directories(ACCESS3_cmeps PUBLIC "$") +get_target_property(cmeps_moddir ACCESS3_cmeps Fortran_MODULE_DIRECTORY) +install(FILES ${cmeps_moddir}/med.mod ${cmeps_moddir}/med_internalstate_mod.mod + DESTINATION ${CMAKE_INSTALL_MODULEDIR}/access-cmeps + COMPONENT Access3Share_Development +) +install(EXPORT Access3Sharecmeps_Targets + FILE Access3SharecmepsTargets.cmake + NAMESPACE Access3:: + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/Access3Share +) - ## NUOPC cap share - set_target_properties(OM3_nuopc_cap_share PROPERTIES - OUTPUT_NAME access-nuopc_cap_share - EXPORT_NAME nuopc_cap_share - ) - install(TARGETS OM3_nuopc_cap_share - EXPORT AccessOM3nuopc_cap_share_Targets - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT AccessOM3_RunTime NAMELINK_COMPONENT AccessOM3_Development - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT AccessOM3_Development - ) - # Fortran module files are a special case, as currently there is no standard - # way of handling them in CMake - target_include_directories(OM3_nuopc_cap_share PUBLIC "$") - get_target_property(nuopc_cap_share_moddir OM3_nuopc_cap_share Fortran_MODULE_DIRECTORY) - install(DIRECTORY ${nuopc_cap_share_moddir}/ - DESTINATION ${CMAKE_INSTALL_MODULEDIR}/access-nuopc_cap_share - COMPONENT AccessOM3_Development - ) - install(EXPORT AccessOM3nuopc_cap_share_Targets - FILE AccessOM3nuopc_cap_shareTargets.cmake - NAMESPACE AccessOM3:: - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/AccessOM3 - ) -endif() +## NUOPC cap share +set_target_properties(ACCESS3_nuopc_cap_share PROPERTIES + OUTPUT_NAME access-nuopc_cap_share + EXPORT_NAME nuopc_cap_share +) +install(TARGETS ACCESS3_nuopc_cap_share + EXPORT Access3Sharenuopc_cap_share_Targets + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT Access3Share_RunTime NAMELINK_COMPONENT Access3Share_Development + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT Access3Share_Development +) +# Fortran module files are a special case, as currently there is no standard +# way of handling them in CMake +target_include_directories(ACCESS3_nuopc_cap_share PUBLIC "$") +get_target_property(nuopc_cap_share_moddir ACCESS3_nuopc_cap_share Fortran_MODULE_DIRECTORY) +install(DIRECTORY ${nuopc_cap_share_moddir}/ + DESTINATION ${CMAKE_INSTALL_MODULEDIR}/access-nuopc_cap_share + COMPONENT Access3Share_Development +) +install(EXPORT Access3Sharenuopc_cap_share_Targets + FILE Access3Sharenuopc_cap_shareTargets.cmake + NAMESPACE Access3:: + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/Access3Share +) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2a1cf87..6406f18 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,3 +1,13 @@ +# Copyright ACCESS-NRI and contributors. See the top-level COPYRIGHT file for details. +# SPDX-License-Identifier: Apache-2.0 + +# This CMakeLists file has an option to control what to build: +# ACCESS3_LIB_INSTALL: +# If ON, then build libraries for the shared components (CMEPS/CDEPS/Share) +# If OFF, then build ACCESS-OM3 using CMEPS code and linked to model components (built elsewhere). +# Build components are set through the KnownConfigurations CMAKE variable +# This can be extended to included CM3 by linking against the UM libraries built with nuopc/cmeps driver. + cmake_minimum_required(VERSION 3.18) # CMake version compatibility @@ -5,49 +15,20 @@ cmake_minimum_required(VERSION 3.18) # Basic project definition # #]==============================================================================] -project(ACCESS-OM3 VERSION "0.2.0" - HOMEPAGE_URL https://github.com/COSIMA/access-om3 - DESCRIPTION "Global coupled ocean - sea ice - wave model" - LANGUAGES C Fortran) +project(Access3Share + HOMEPAGE_URL https://github.com/access-nri/access3-share + DESCRIPTION "Dependencies for global climate models" + LANGUAGES C Fortran) #[==============================================================================[ # Options # #]==============================================================================] -# Configurations to build -list(APPEND KnownConfigurations MOM6 CICE6 WW3 MOM6-CICE6 CICE6-WW3 MOM6-WW3 MOM6-CICE6-WW3) - -option(OM3_ENABLE_MOM6 "Build MOM6 configuration" OFF) -option(OM3_ENABLE_CICE6 "Build CICE6 configuration" OFF) -option(OM3_ENABLE_WW3 "Build WW3 configuration" OFF) -option(OM3_ENABLE_MOM6-WW3 "Build MOM6-WW3 configuration" OFF) -option(OM3_ENABLE_MOM6-CICE6 "Build MOM6-CICE6 configuration" ON) -option(OM3_ENABLE_CICE6-WW3 "Build CICE6-WW3 configuration" ON) -option(OM3_ENABLE_MOM6-CICE6-WW3 "Build MOM6-CICE6-WW3 configuration" ON) - -message(STATUS "Configurations") -message(STATUS " - MOM6 ${OM3_ENABLE_MOM6}") -message(STATUS " - CICE6 ${OM3_ENABLE_CICE6}") -message(STATUS " - WW3 ${OM3_ENABLE_WW3}") -message(STATUS " - MOM6-WW3 ${OM3_ENABLE_MOM6-WW3}") -message(STATUS " - MOM6-CICE6 ${OM3_ENABLE_MOM6-CICE6}") -message(STATUS " - CICE6-WW3 ${OM3_ENABLE_CICE6-WW3}") -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") +option(ACCESS3_LIB_INSTALL "Install ACCESS3 libraries" OFF) 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}") +message(STATUS " - ACCESS3_LIB_INSTALL ${ACCESS3_LIB_INSTALL}") #[==============================================================================[ @@ -56,37 +37,11 @@ message(STATUS " - OM3_CICE_IO ${OM3_CICE_IO}") list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake) include(GNUInstallDirs) -if(OM3_LIB_INSTALL) - include(CMakePackageConfigHelpers) -endif() # Include some custom cmake modules include(FortranLib) include(AddPatchedSource) -## Configure project variables - -# 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_BUILD_MOM6 ON) -else() - 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_BUILD_CICE6 ON) -else() - 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_BUILD_WW3 ON) -else() - 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") set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fbacktrace -fconvert=big-endian -ffree-line-length-none -ffixed-line-length-none") @@ -96,7 +51,7 @@ if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU") set(CMAKE_Fortran_FLAGS_RELEASE "-O") set(CMAKE_Fortran_FLAGS_DEBUG "-g -Wall -Og -ffpe-trap=zero,overflow -fcheck=bounds") elseif(CMAKE_Fortran_COMPILER_ID MATCHES "Intel") - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -qno-opt-dynamic-align -convert big_endian -assume byterecl -ftz -traceback -assume realloc_lhs -fp-model source") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -qno-opt-dynamic-align -convert big_endian -assume byterecl -ftz -traceback -assume realloc_lhs -fp-model precise") set(CMAKE_Fortran_FLAGS_RELEASE "-O2 -debug minimal") set(CMAKE_Fortran_FLAGS_DEBUG "-O0 -g -check uninit -check bounds -check pointers -fpe0 -check noarg_temp_created") else() @@ -131,126 +86,16 @@ set(CMAKE_INSTALL_MODULEDIR ${CMAKE_INSTALL_INCLUDEDIR} # Find dependencies find_package(MPI REQUIRED) -if(OM3_OPENMP) - find_package(OpenMP REQUIRED) -endif() -find_package(FoX 4.1.2 REQUIRED) -find_package(NetCDF 4.7.3 REQUIRED Fortran) find_package(ESMF 8.3.0 MODULE REQUIRED) -find_package(fms COMPONENTS R8 REQUIRED) -find_package(PIO 2.5.3 REQUIRED COMPONENTS C Fortran) #[==============================================================================[ -# Main definitions # +# Build and Install # #]==============================================================================] -# Some code shared by several components -add_subdirectory(share) - -## Components - -# Data component (CDEPS) -add_subdirectory(CDEPS) +## Use seperate files for building libraries vs final exectuable -# Ocean component (MOM6) -if(OM3_BUILD_MOM6) - add_subdirectory(MOM6) -endif() - -# Sea-ice component (CICE6) -if(OM3_BUILD_CICE6) - add_subdirectory(CICE) -endif() - -# Wave component (WW3) -if(OM3_BUILD_WW3) - add_subdirectory(WW3) -endif() - -# Mediator component (CMEPS) -add_subdirectory(CMEPS) - -# Add executable for each enabled configuration -foreach(CONF IN LISTS KnownConfigurations) - if(NOT OM3_ENABLE_${CONF}) - continue() - endif() - - set(ComponentsTargets "") - if(OM3_${CONF} MATCHES MOM6) - list(APPEND ComponentsTargets AccessOM3::mom6) - else() - list(APPEND ComponentsTargets AccessOM3::cdeps_docn) - endif() - if(OM3_${CONF} MATCHES CICE6) - list(APPEND ComponentsTargets AccessOM3::cice) - else() - list(APPEND ComponentsTargets AccessOM3::cdeps_dice) - endif() - if(OM3_${CONF} MATCHES WW3) - list(APPEND ComponentsTargets AccessOM3::ww3) - else() - list(APPEND ComponentsTargets AccessOM3::cdeps_dwav) - endif() - - # We use the CESM driver from CMEPS - 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 ${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 - ICE_PRESENT - OCN_PRESENT - WAV_PRESENT - ROF_PRESENT - $<$:DEBUG> - ) - - add_executable(OM3_${CONF} CMEPS/CMEPS/cesm/driver/esmApp.F90) - target_link_libraries(OM3_${CONF} PRIVATE OM3_cesm_driver_${CONF} AccessOM3::share esmf) - - set_target_properties(OM3_${CONF} PROPERTIES - LINKER_LANGUAGE Fortran - OUTPUT_NAME access-om3-${CONF} - ) -endforeach() - -#[==============================================================================[ -# Install or Export # -#]==============================================================================] - -## Installs - -# Note that the installation of some components is done in the corresponding subdirectory - -# OM3 executables -if(OM3_BIN_INSTALL) - foreach(CONF IN LISTS KnownConfigurations) - if(NOT OM3_ENABLE_${CONF}) - continue() - endif() - - install(TARGETS OM3_${CONF} - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - ) - endforeach() -endif() - -# Libraries -if(OM3_LIB_INSTALL) - configure_package_config_file( - cmake/AccessOM3Config.cmake.in - ${CMAKE_CURRENT_BINARY_DIR}/AccessOM3Config.cmake - INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/AccessOM3 - ) - install(FILES ${CMAKE_SOURCE_DIR}/cmake/FindFoX.cmake ${CMAKE_CURRENT_BINARY_DIR}/AccessOM3Config.cmake - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/AccessOM3 - COMPONENT AccessOM3_Development - ) -endif() +if(ACCESS3_LIB_INSTALL) + include(Access3LibInstall) +else() + include(Access3BinInstall) +endif() \ No newline at end of file diff --git a/CMakePresets.json b/CMakePresets.json deleted file mode 100644 index 70cb850..0000000 --- a/CMakePresets.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "version": 5, - "cmakeMinimumRequired": { - "major": 3, - "minor": 23, - "patch": 0 - }, - "include": [ - "cmake/CMakePresets-defaults.json", - "cmake/CMakePresets-compilers.json", - "cmake/CMakePresets-machines.json" - ] -} diff --git a/COPYRIGHT.txt b/COPYRIGHT.txt new file mode 100644 index 0000000..63b00ed --- /dev/null +++ b/COPYRIGHT.txt @@ -0,0 +1,13 @@ + Copyright 2025 ACCESS-NRI + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..f49a4e1 --- /dev/null +++ b/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. \ No newline at end of file diff --git a/README.md b/README.md index a931c09..9c8a201 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,10 @@ -                -

-[![Compilation Status](https://github.com/COSIMA/access-om3/actions/workflows/compilation.yml/badge.svg)](https://github.com/COSIMA/access-om3/actions/workflows/compilation.yml) +# ACCESS3-Share -# ACCESS-OM3 +ACCESS3-Share repository contains the common tools for coupling the components of 3rd generation ACCESS earth system models. These are the framework for ACCESS-OM3 (an ocean and sea-ice model), ACCESS-ESM3 (a global climate model) and other ACCESS models. This repository contains a CMake based build system for the [Community Mediator for Earth Prediction Systems](https://github.com/ESCOMP/CMEPS/), the [Community Data Models for Earth Prediction Systems](https://github.com/ESCOMP/CDEPS/) and the [Community Earth System Model shared code](https://github.com/ESCOMP/CESM_share). -ACCESS-OM3 is a global coupled ocean - sea ice - wave model being developed by [COSIMA](http://www.cosima.org.au) and [ACCESS-NRI](https://www.access-nri.org.au/). +The contents of this repository are licensed under the _Apache 2.0_ license unless otherwise noted. For any submodules, please refer to the seperate repositories for license information. -WARNING: this is a very early pre-release development version and doesn't yet work! - -# Downloading - -NCI-based users of ACCESS-OM3 typically won't need to download this repository, as there are pre-built executables available on NCI (see the [quick start](https://github.com/COSIMA/access-om3/wiki/Quick-start)). +NCI-based users of ACCESS-OM3 typically won't need to mess with this package. There are pre-built executables available on NCI and some [configurations](https://github.com/accESS-NRI/access-om3-configs). This respository contains submodules, so you will need to clone it with the `--recursive` flag: ``` @@ -29,4 +23,4 @@ to update all the submodules. # Further information (including building and running the model) -See the [ACCESS-OM3 wiki](https://github.com/COSIMA/access-om3/wiki), particularly the [quick start](https://github.com/COSIMA/access-om3/wiki/Quick-start). +See the [ACCESS-OM3 configurations](https://github.com/accESS-NRI/access-om3-configs) diff --git a/cmake/Access3BinInstall.cmake b/cmake/Access3BinInstall.cmake new file mode 100644 index 0000000..07d3fd7 --- /dev/null +++ b/cmake/Access3BinInstall.cmake @@ -0,0 +1,113 @@ +# Copyright ACCESS-NRI and contributors. See the top-level COPYRIGHT file for details. +# SPDX-License-Identifier: Apache-2.0 + +#[==============================================================================[ +# Options # +#]==============================================================================] + +# Configurations to build +# TO-DO add UM +list(APPEND KnownConfigurations MOM6 CICE6 WW3 MOM6-CICE6 CICE6-WW3 MOM6-WW3 MOM6-CICE6-WW3) +set(BuildConfigurations) + +option(ENABLE_MOM6 "Build MOM6 configuration" OFF) +option(ENABLE_CICE6 "Build CICE6 configuration" OFF) +option(ENABLE_WW3 "Build WW3 configuration" OFF) + +# Check validity of requested components +foreach(_conf IN LISTS BuildConfigurations) + if (NOT _conf IN_LIST KnownConfigurations) + message (FATAL_ERROR "Unsupported configuration: ${_conf}") + endif() + # Do not build try to include that are not going to be used + if (_conf MATCHES MOM6) + set(ENABLE_MOM6 ON) + endif() + if (_conf MATCHES CICE6) + set(ENABLE_CICE6 ON) + endif() + if (_conf MATCHES WW3) + set(ENABLE_WW3 ON) + endif() +endforeach() + +message(STATUS "BuildConfigurations") +message(STATUS "${BuildConfigurations}") +message(STATUS " - MOM6 ${ENABLE_MOM6}") +message(STATUS " - CICE6 ${ENABLE_CICE6}") +message(STATUS " - WW3 ${ENABLE_WW3}") + +if(NOT (ENABLE_MOM6 OR ENABLE_CICE6 OR ENABLE_WW3)) + message (FATAL_ERROR "No model components have been requested, atleast one ENABLE_ configuration must be set") +endif() + +# External packages +find_package(Access3Share REQUIRED cdeps cmeps nuopc_cap_share share timing) +if(ENABLE_CICE6) + find_package(Cicelib REQUIRED COMPONENTS AccessCICECmeps_Development) +endif() +if(ENABLE_MOM6) + find_package(Mom6lib REQUIRED AccessMOM6Cmeps_Development) +endif() +if(ENABLE_WW3) + find_package(Ww3lib REQUIRED AccessWW3Cmeps_Development) +endif() + +# Main Definitions + +# Add executable for each enabled configuration +foreach(CONF IN LISTS BuildConfigurations) + + set(ComponentsTargets "") + if(CONF MATCHES MOM6) + list(APPEND ComponentsTargets Access3::mom6lib) + else() + list(APPEND ComponentsTargets Access3::cdeps-docn) + endif() + if(CONF MATCHES CICE6) + list(APPEND ComponentsTargets Access3::cicelib) + else() + list(APPEND ComponentsTargets Access3::cdeps-dice) + endif() + if(CONF MATCHES WW3) + list(APPEND ComponentsTargets Access3::ww3lib) + else() + list(APPEND ComponentsTargets Access3::cdeps-dwav) + endif() + + # We use the CESM driver from CMEPS + 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::ESMF + PRIVATE ${ComponentsTargets} Access3::cdeps-drof Access3::cdeps-datm Access3::cmeps Access3::nuopc_cap_share Access3::share Access3::timing + ) + target_compile_definitions(OM3_cesm_driver_${CONF} PRIVATE MED_PRESENT + ATM_PRESENT + ICE_PRESENT + OCN_PRESENT + WAV_PRESENT + ROF_PRESENT + $<$:DEBUG> + ) + + add_executable(OM3_${CONF} CMEPS/CMEPS/cesm/driver/esmApp.F90) + target_link_libraries(OM3_${CONF} PRIVATE OM3_cesm_driver_${CONF} Access3::share ESMF::ESMF) + + set_target_properties(OM3_${CONF} PROPERTIES + LINKER_LANGUAGE Fortran + OUTPUT_NAME access-om3-${CONF} + ) +endforeach() + +# Install + +foreach(CONF IN LISTS BuildConfigurations) + + install(TARGETS OM3_${CONF} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + ) +endforeach() diff --git a/cmake/Access3LibInstall.cmake b/cmake/Access3LibInstall.cmake new file mode 100644 index 0000000..172a14a --- /dev/null +++ b/cmake/Access3LibInstall.cmake @@ -0,0 +1,38 @@ +# Copyright ACCESS-NRI and contributors. See the top-level COPYRIGHT file for details. +# SPDX-License-Identifier: Apache-2.0 + +include(CMakePackageConfigHelpers) + +# External packages + +find_package(FoX 4.1.2 REQUIRED) +find_package(PIO 2.5.3 REQUIRED COMPONENTS C Fortran) +find_package(NetCDF 4.7.3 REQUIRED C Fortran) +# Code has not been tested with older PIO/NetCDF versions , but probably still works fine + +# Main definitions + +# Some code shared by several components +add_subdirectory(share) + +# Data component (CDEPS) +add_subdirectory(CDEPS) + +# Mediator component (CMEPS) +add_subdirectory(CMEPS) + +# make some common deps available +target_link_libraries(share PUBLIC ESMF::ESMF PIO::PIO_Fortran PIO::PIO_C NetCDF::NetCDF_Fortran NetCDF::NetCDF_C) + +# Install/Export +# Note that the installation of some components is done in the corresponding subdirectory + +configure_package_config_file( + cmake/Access3ShareConfig.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/Access3ShareConfig.cmake + INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/Access3Share + ) +install(FILES ${CMAKE_SOURCE_DIR}/cmake/FindFoX.cmake ${CMAKE_SOURCE_DIR}/cmake/FindNetCDF.cmake ${CMAKE_SOURCE_DIR}/cmake/FindPIO.cmake ${CMAKE_SOURCE_DIR}/cmake/FindESMF.cmake ${CMAKE_CURRENT_BINARY_DIR}/Access3ShareConfig.cmake +DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/Access3Share +COMPONENT Access3Share +) \ No newline at end of file diff --git a/cmake/Access3ShareConfig.cmake.in b/cmake/Access3ShareConfig.cmake.in new file mode 100755 index 0000000..51e4d18 --- /dev/null +++ b/cmake/Access3ShareConfig.cmake.in @@ -0,0 +1,69 @@ +# Copyright ACCESS-NRI and contributors. See the top-level COPYRIGHT file for details. +# SPDX-License-Identifier: Apache-2.0 + +@PACKAGE_INIT@ + +if(NOT Access3Share_FIND_QUIETLY) + message(STATUS "Found Access3Share: ${PACKAGE_PREFIX_DIR}") +endif() + +# Available components + +# The following components are always available (order is important!) +set(_supported_components timing share nuopc_cap_share cmeps cdeps) + +# Check validity of requested components +foreach(_comp ${Access3Share_FIND_COMPONENTS}) + if (NOT _comp IN_LIST _supported_components) + set(Access3Share_FOUND False) + set(Access3Share_NOT_FOUND_MESSAGE "Unsupported component: ${_comp}") + endif() +endforeach() + +# Build a list of all the required components, taking into account their dependencies +set(_required_components ${Access3Share_FIND_COMPONENTS}) +if(cdeps IN_LIST _required_components) + list(APPEND _required_components cmeps share nuopc_cap_share) +endif() +if(cmeps IN_LIST _required_components) + list(APPEND _required_components nuopc_cap_share share timing) +endif() +if(nuopc_cap_share IN_LIST _required_components) + list(APPEND _required_components share timing) +endif() +if(share IN_LIST _required_components) + list(APPEND _required_components timing) +endif() + +list(REMOVE_DUPLICATES _required_components) + + +if(NOT Access3Share_FIND_QUIETLY) + message(STATUS " - Access3Share Components: ${_required_components}") +endif() + +# Include required targets. We do this by looping over the _supported_components +# list because the order in which targets are loaded matters. +foreach(_comp ${_supported_components}) + #if (_comp IN_LIST _required_components) + message(STATUS " - Including Access3Share Components: ${_comp}") + include("${CMAKE_CURRENT_LIST_DIR}/Access3Share${_comp}Targets.cmake") + #endif() +endforeach() + +# Find dependencies of required components +include(CMakeFindDependencyMacro) + +list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}) + +if (cdeps IN_LIST _required_components) + find_dependency(FoX) +endif() + +find_package(PIO 2.5.3 REQUIRED COMPONENTS C Fortran) +find_package(NetCDF 4.7.3 REQUIRED C Fortran) +find_package(ESMF 8.3.0 MODULE REQUIRED) + +list(REMOVE_ITEM CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}) + +check_required_components(_supported_components) diff --git a/cmake/AccessOM3Config.cmake.in b/cmake/AccessOM3Config.cmake.in deleted file mode 100644 index 2a4703f..0000000 --- a/cmake/AccessOM3Config.cmake.in +++ /dev/null @@ -1,82 +0,0 @@ -@PACKAGE_INIT@ - -if(NOT AccessOM3_FIND_QUIETLY) - message(STATUS "Found AccessOM3: ${PACKAGE_PREFIX_DIR}") -endif() - -# Available components - -# The following components are always available (order is important!) -set(_supported_components timing share nuopc_cap_share cmeps cdeps mom6 cice ww3) - -# Check validity of requested components -foreach(_comp ${AccessOM3_FIND_COMPONENTS}) - if (NOT _comp IN_LIST _supported_components) - set(AccessOM3_FOUND False) - set(AccessOM3_NOT_FOUND_MESSAGE "Unsupported component: ${_comp}") - endif() -endforeach() - -# Some components are only available if they were built -if ((mom6 IN_LIST ${AccessOM3_FIND_COMPONENTS}) AND (NOT @OM3_BUILD_MOM6@)) - set(AccessOM3_FOUND False) - set(AccessOM3_NOT_FOUND_MESSAGE "The following component is not available: mom6") -endif() -if ((cice IN_LIST ${AccessOM3_FIND_COMPONENTS}) AND (NOT @OM3_BUILD_CICE6@)) - set(AccessOM3_FOUND False) - set(AccessOM3_NOT_FOUND_MESSAGE "The following component is not available: cice") -endif() -if ((ww3 IN_LIST ${AccessOM3_FIND_COMPONENTS}) AND (NOT @OM3_BUILD_WW3@)) - set(AccessOM3_FOUND False) - set(AccessOM3_NOT_FOUND_MESSAGE "The following component is not available: ww3") -endif() - -# Build a list of all the required components, taking into account their dependencies -set(_required_components ${AccessOM3_FIND_COMPONENTS}) -if(cice IN_LIST _required_components) - list(APPEND _required_components cdeps nuopc_cap_share share timing) -endif() -if(mom6 IN_LIST _required_components) - list(APPEND _required_components nuopc_cap_share share) -endif() -if(cdeps IN_LIST _required_components) - list(APPEND _required_components cmeps share nuopc_cap_share) -endif() -if(cmeps IN_LIST _required_components) - list(APPEND _required_components nuopc_cap_share share timing) -endif() -if(nuopc_cap_share IN_LIST _required_components) - list(APPEND _required_components share timing) -endif() -if(share IN_LIST _required_components) - list(APPEND _required_components timing) -endif() -list(REMOVE_DUPLICATES _required_components) - -if(NOT AccessOM3_FIND_QUIETLY) - message(STATUS " - AccessOM3 Components: ${_required_components}") -endif() - -# Include required targets. We do this by looping over the _supported_components -# list because the order in which targets are loaded matters. -foreach(_comp ${_supported_components}) - if (_comp IN_LIST _required_components) - include("${CMAKE_CURRENT_LIST_DIR}/AccessOM3${_comp}Targets.cmake") - endif() -endforeach() - -# Find dependencies of required components -include(CMakeFindDependencyMacro) - -list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}) - -if (cdeps IN_LIST _required_components) - find_dependency(FoX) -endif() -if (mom6 IN_LIST _required_components) - find_dependency(fms COMPONENTS R8 REQUIRED) -endif() - -list(REMOVE_ITEM CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}) - -check_required_components(_supported_components) diff --git a/cmake/AddPatchedSource.cmake b/cmake/AddPatchedSource.cmake index 6a54755..5859442 100644 --- a/cmake/AddPatchedSource.cmake +++ b/cmake/AddPatchedSource.cmake @@ -1,3 +1,6 @@ +# Copyright ACCESS-NRI and contributors. See the top-level COPYRIGHT file for details. +# SPDX-License-Identifier: Apache-2.0 + # Apply a patch to a source file and add the resulting file to the sources of a # given target. function(add_patched_source TARGET FILE) diff --git a/cmake/CMakePresets-compilers.json b/cmake/CMakePresets-compilers.json deleted file mode 100644 index e847096..0000000 --- a/cmake/CMakePresets-compilers.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "version": 5, - "include": [ - "CMakePresets-defaults.json" - ], - "configurePresets": [ - { - "name": "openmpi", - "displayName": "Configure preset for OpenMPI based toolchains", - "inherits": [ - "default" - ], - "cacheVariables": { - "CMAKE_Fortran_COMPILER": { - "value": "mpif90" - }, - "CMAKE_C_COMPILER": { - "value": "mpicc" - } - } - }, - { - "name": "intel-mpi", - "displayName": "Configure preset for Intel-MPI based toolchain", - "inherits": [ - "default" - ], - "cacheVariables": { - "CMAKE_Fortran_COMPILER": { - "type": "FILEPATH", - "value": "mpiifort" - }, - "CMAKE_C_COMPILER": { - "type": "FILEPATH", - "value": "mpiicc" - } - } - } - ], - "buildPresets": [ - { - "name": "toolchain-base", - "hidden": true, - "inherits": [ - "default" - ], - "cleanFirst": true - }, - { - "name": "openmpi", - "displayName": "Build preset for OpenMPI based toolchains", - "inherits": [ - "toolchain-base" - ], - "configurePreset": "openmpi" - }, - { - "name": "intel", - "displayName": "Build preset for Intel-MPI based toolchains", - "inherits": [ - "toolchain-base" - ], - "configurePreset": "intel-mpi" - } - ] -} diff --git a/cmake/CMakePresets-defaults.json b/cmake/CMakePresets-defaults.json deleted file mode 100644 index 78570c1..0000000 --- a/cmake/CMakePresets-defaults.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "version": 5, - "configurePresets": [ - { - "name": "default", - "displayName": "Default configuration preset", - "binaryDir": "cmake-build-release", - "cacheVariables": { - "CMAKE_BUILD_TYPE": { - "type": "STRING", - "value": "Release" - } - } - } - ], - "buildPresets": [ - { - "name": "default", - "displayName": "Default build preset", - "configurePreset": "default" - } - ], - "testPresets": [ - { - "name": "default", - "displayName": "Default test preset", - "configurePreset": "default" - } - ] -} diff --git a/cmake/CMakePresets-machines.json b/cmake/CMakePresets-machines.json deleted file mode 100644 index 1e7a712..0000000 --- a/cmake/CMakePresets-machines.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "version": 5, - "include": [ - "CMakePresets-defaults.json", - "CMakePresets-compilers.json" - ], - "configurePresets": [ - { - "name": "gadi", - "displayName": "Configure preset for Gadi", - "inherits": [ - "openmpi" - ], - "cacheVariables": { - "NetCDF_C_LIBRARY": { - "type": "FILEPATH", - "value": "$env{SPACK_NETCDF_C_ROOT}/lib/libnetcdf.so" - }, - "NetCDF_Fortran_LIBRARY": { - "type": "FILEPATH", - "value": "$env{SPACK_NETCDF_FORTRAN_ROOT}/lib/libnetcdff.so" - }, - "NetCDF_Fortran_INCLUDE_DIRS": { - "type": "FILEPATH", - "value": "$env{SPACK_NETCDF_FORTRAN_ROOT}/include" - } - } - } - ], - "buildPresets": [ - { - "name": "gadi", - "displayName": "Build preset for Gadi", - "inherits": [ - "openmpi" - ], - "cleanFirst": true, - "configurePreset": "gadi" - } - ] -} diff --git a/cmake/FindESMF.cmake b/cmake/FindESMF.cmake index 5ba7003..8dfb926 100644 --- a/cmake/FindESMF.cmake +++ b/cmake/FindESMF.cmake @@ -1,34 +1,81 @@ +# Earth System Modeling Framework + +# Copyright (c) 2002-2025 University Corporation for Atmospheric Research, +# Massachusetts Institute of Technology, Geophysical Fluid Dynamics Laboratory, +# University of Michigan, National Centers for Environmental Prediction, +# Los Alamos National Laboratory, Argonne National Laboratory, +# NASA Goddard Space Flight Center. +# All rights reserved. + +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal with the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# 1. Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimers. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimers in the +# documentation and/or other materials provided with the distribution. +# 3. Neither the names of the organizations developing this software, nor +# the names of its contributors may be used to endorse or promote products +# derived from this Software without specific prior written permission. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# WITH THE SOFTWARE. + # - Try to find ESMF # -# Requires setting ESMFMKFILE to the filepath of esmf.mk. If this is NOT set, -# then ESMF_FOUND will always be FALSE. If ESMFMKFILE exists, then ESMF_FOUND=TRUE -# and all ESMF makefile variables will be set in the global scope. Optionally, -# set ESMF_MKGLOBALS to a string list to filter makefile variables. For example, -# to globally scope only ESMF_LIBSDIR and ESMF_APPSDIR variables, use this CMake -# command in CMakeLists.txt: +# Uses ESMFMKFILE to find the filepath of esmf.mk. If this is NOT set, then this +# module will attempt to find esmf.mk. If ESMFMKFILE exists, then +# ESMF_FOUND=TRUE and all ESMF makefile variables will be set in the global +# scope. Optionally, set ESMF_MKGLOBALS to a string list to filter makefile +# variables. For example, to globally scope only ESMF_LIBSDIR and ESMF_APPSDIR +# variables, use this CMake command in CMakeLists.txt: # # set(ESMF_MKGLOBALS "LIBSDIR" "APPSDIR") +# Set ESMFMKFILE as defined by system env variable. If it's not explicitly set +# try to find esmf.mk file in default locations (ESMF_ROOT, CMAKE_PREFIX_PATH, +# etc) -# Add the ESMFMKFILE path to the cache if defined as system env variable -if(DEFINED ENV{ESMFMKFILE} AND NOT DEFINED ESMFMKFILE) - set(ESMFMKFILE $ENV{ESMFMKFILE} CACHE FILEPATH "Path to ESMF mk file") -endif() +# - Common Usage +# +# Where to look for this FindESMF.cmake file +# list(APPEND CMAKE_MODULE_PATH "") +# is to be replaced with the directory for this file +# +# How to locate ESMF libraries and create target +# find_package(ESMF MODULE REQUIRED) +# is to be replaced with the minimum version required +# +# How to link targets +# target_link_libraries( PUBLIC ESMF::ESMF) +# is to be replaced with your CMake target -# If it's not explicitly set try to find esmf.mk file in default locations (ESMF_ROOT, CMAKE_PREFIX_PATH, etc) if(NOT DEFINED ESMFMKFILE) - find_path(ESMFMKFILE_PATH esmf.mk PATH_SUFFIXES lib lib64) - if(ESMFMKFILE_PATH) - set(ESMFMKFILE ${ESMFMKFILE_PATH}/esmf.mk) - message(STATUS "Found esmf.mk file ${ESMFMKFILE}") + if(NOT DEFINED ENV{ESMFMKFILE}) + find_path(ESMFMKFILE_PATH esmf.mk PATH_SUFFIXES lib lib64) + if(ESMFMKFILE_PATH) + set(ESMFMKFILE ${ESMFMKFILE_PATH}/esmf.mk) + message(STATUS "Found esmf.mk file ${ESMFMKFILE}") + endif() else() - message(STATUS "ESMFMKFILE not defined. This is the path to esmf.mk file. \ -Without this filepath, ESMF_FOUND will always be FALSE.") + set(ESMFMKFILE $ENV{ESMFMKFILE}) endif() endif() # Only parse the mk file if it is found if(EXISTS ${ESMFMKFILE}) + set(ESMFMKFILE ${ESMFMKFILE} CACHE FILEPATH "Path to esmf.mk file") + set(ESMF_FOUND TRUE CACHE BOOL "esmf.mk file found" FORCE) + # Read the mk file file(STRINGS "${ESMFMKFILE}" esmfmkfile_contents) # Parse each line in the mk file @@ -78,58 +125,70 @@ if(EXISTS ${ESMFMKFILE}) set(ESMF_BETA_RELEASE FALSE) if(ESMF_VERSION_BETASNAPSHOT MATCHES "^('T')$") set(ESMF_BETA_RELEASE TRUE) - string(REGEX REPLACE ".*beta_snapshot_*\([0-9]*\).*" "\\1" ESMF_BETA_SNAPSHOT "${ESMF_VERSION_STRING_GIT}") - message(STATUS "Detected ESMF Beta snapshot ${ESMF_BETA_SNAPSHOT}") + if(ESMF_VERSION_STRING_GIT MATCHES "^ESMF.*beta_snapshot") + set(ESMF_BETA_SNAPSHOT ${ESMF_VERSION_STRING_GIT}) + elseif(ESMF_VERSION_STRING_GIT MATCHES "^v.\..\..b") + set(ESMF_BETA_SNAPSHOT ${ESMF_VERSION_STRING_GIT}) + else() + set(ESMF_BETA_SNAPSHOT 0) + endif() + message(STATUS "Detected ESMF Beta snapshot: ${ESMF_BETA_SNAPSHOT}") endif() set(ESMF_VERSION "${ESMF_VERSION_MAJOR}.${ESMF_VERSION_MINOR}.${ESMF_VERSION_PATCH}") - separate_arguments(ESMF_F90COMPILEPATHS NATIVE_COMMAND ${ESMF_F90COMPILEPATHS}) - foreach(ITEM ${ESMF_F90COMPILEPATHS}) - string(REGEX REPLACE "^-I" "" ITEM "${ITEM}") - list(APPEND tmp ${ITEM}) - endforeach() - set(ESMF_F90COMPILEPATHS ${tmp}) - - # Look for static library, if not found try dynamic library - find_library(esmf_lib NAMES libesmf.a PATHS ${ESMF_LIBSDIR}) - if(esmf_lib MATCHES "esmf_lib-NOTFOUND") - unset(esmf_lib) - message(STATUS "Static ESMF library not found, searching for dynamic library instead") - find_library(esmf_lib NAMES esmf_fullylinked libesmf.so PATHS ${ESMF_LIBSDIR}) - if(esmf_lib MATCHES "esmf_lib-NOTFOUND") - unset(esmf_lib) - message(STATUS "Neither the dynamic nor the static ESMF library was found") - else() - set(_library_type SHARED) + # Find the ESMF library + if(USE_ESMF_STATIC_LIBS) + find_library(ESMF_LIBRARY_LOCATION NAMES libesmf.a PATHS ${ESMF_LIBSDIR} NO_DEFAULT_PATH) + if(ESMF_LIBRARY_LOCATION MATCHES "ESMF_LIBRARY_LOCATION-NOTFOUND") + message(WARNING "Static ESMF library (libesmf.a) not found in \ + ${ESMF_LIBSDIR}. Try setting USE_ESMF_STATIC_LIBS=OFF") + endif() + if(NOT TARGET ESMF::ESMF) + add_library(ESMF::ESMF STATIC IMPORTED) endif() else() - set(_library_type STATIC) + find_library(ESMF_LIBRARY_LOCATION NAMES esmf PATHS ${ESMF_LIBSDIR} NO_DEFAULT_PATH) + if(ESMF_LIBRARY_LOCATION MATCHES "ESMF_LIBRARY_LOCATION-NOTFOUND") + message(WARNING "ESMF library not found in ${ESMF_LIBSDIR}.") + endif() + if(NOT TARGET ESMF::ESMF) + add_library(ESMF::ESMF UNKNOWN IMPORTED) + endif() endif() - string(STRIP "${ESMF_F90ESMFLINKRPATHS} ${ESMF_F90ESMFLINKPATHS} ${ESMF_F90LINKPATHS} ${ESMF_F90LINKLIBS} ${ESMF_F90LINKOPTS}" ESMF_INTERFACE_LINK_LIBRARIES) - set(ESMF_LIBRARY_LOCATION ${esmf_lib}) + # Add ESMF as an alias to ESMF::ESMF for backward compatibility + if(NOT TARGET ESMF) + add_library(ESMF ALIAS ESMF::ESMF) + endif() -else() + # Add ESMF include directories + set(ESMF_INCLUDE_DIRECTORIES "") + separate_arguments(_ESMF_F90COMPILEPATHS UNIX_COMMAND ${ESMF_F90COMPILEPATHS}) + foreach(_ITEM ${_ESMF_F90COMPILEPATHS}) + string(REGEX REPLACE "^-I" "" _ITEM "${_ITEM}") + list(APPEND ESMF_INCLUDE_DIRECTORIES ${_ITEM}) + endforeach() - message(WARNING "ESMFMKFILE ${ESMFMKFILE} does not exist") + # Add ESMF link libraries + string(STRIP "${ESMF_F90LINKRPATHS} ${ESMF_F90ESMFLINKRPATHS} ${ESMF_F90ESMFLINKPATHS} ${ESMF_F90LINKPATHS} ${ESMF_F90LINKLIBS} ${ESMF_F90LINKOPTS}" ESMF_INTERFACE_LINK_LIBRARIES) -endif() + # Finalize find_package + include(FindPackageHandleStandardArgs) -## Finalize find_package -include(FindPackageHandleStandardArgs) - -find_package_handle_standard_args( - ${CMAKE_FIND_PACKAGE_NAME} - REQUIRED_VARS ESMF_LIBRARY_LOCATION - ESMF_INTERFACE_LINK_LIBRARIES - ESMF_F90COMPILEPATHS - VERSION_VAR ESMF_VERSION) - -## If ESMF is found create imported library target -if(ESMF_FOUND) - add_library(esmf ${_library_type} IMPORTED) - set_target_properties(esmf PROPERTIES - IMPORTED_LOCATION "${ESMF_LIBRARY_LOCATION}" - INTERFACE_INCLUDE_DIRECTORIES "${ESMF_F90COMPILEPATHS}" - INTERFACE_LINK_LIBRARIES "${ESMF_INTERFACE_LINK_LIBRARIES}") -endif() + find_package_handle_standard_args( + ${CMAKE_FIND_PACKAGE_NAME} + REQUIRED_VARS ESMF_LIBRARY_LOCATION + ESMF_INTERFACE_LINK_LIBRARIES + ESMF_F90COMPILEPATHS + VERSION_VAR ESMF_VERSION) + + set_target_properties(ESMF::ESMF PROPERTIES + IMPORTED_LOCATION "${ESMF_LIBRARY_LOCATION}" + INTERFACE_INCLUDE_DIRECTORIES "${ESMF_INCLUDE_DIRECTORIES}" + INTERFACE_LINK_LIBRARIES "${ESMF_INTERFACE_LINK_LIBRARIES}") + +else() + set(ESMF_FOUND FALSE CACHE BOOL "esmf.mk file NOT found" FORCE) + message(WARNING "ESMFMKFILE ${ESMFMKFILE} not found. Try setting ESMFMKFILE \ + to esmf.mk location.") +endif() \ No newline at end of file diff --git a/cmake/FortranLib.cmake b/cmake/FortranLib.cmake index 08bcccb..ddab739 100644 --- a/cmake/FortranLib.cmake +++ b/cmake/FortranLib.cmake @@ -1,3 +1,6 @@ +# Copyright ACCESS-NRI and contributors. See the top-level COPYRIGHT file for details. +# SPDX-License-Identifier: Apache-2.0 + function(add_fortran_library LIB MOD_DIR) add_library(${LIB} ${ARGN}) diff --git a/cmake/PatchFile.cmake b/cmake/PatchFile.cmake index 7f83ad1..c6d1738 100644 --- a/cmake/PatchFile.cmake +++ b/cmake/PatchFile.cmake @@ -1,3 +1,6 @@ +# Copyright ACCESS-NRI and contributors. See the top-level COPYRIGHT file for details. +# SPDX-License-Identifier: Apache-2.0 + # use GNU Patch from any platform if(WIN32) diff --git a/share/CMakeLists.txt b/share/CMakeLists.txt old mode 100644 new mode 100755 index 9367f14..91c12ab --- a/share/CMakeLists.txt +++ b/share/CMakeLists.txt @@ -1,18 +1,20 @@ +# Copyright ACCESS-NRI and contributors. See the top-level COPYRIGHT file for details. +# SPDX-License-Identifier: Apache-2.0 ## share library -add_fortran_library(OM3_share mod/share STATIC) -add_library(AccessOM3::share ALIAS OM3_share) -target_include_directories(OM3_share PUBLIC "$") +add_fortran_library(share mod/share STATIC) +add_library(Access3::share ALIAS share) +target_include_directories(share PUBLIC "$") if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU") - target_compile_definitions(OM3_share PRIVATE CPRGNU NAMING=_ADD_UNDERSCORE FORTRANUNDERSCORE) + target_compile_definitions(share PRIVATE CPRGNU NAMING=_ADD_UNDERSCORE FORTRANUNDERSCORE) elseif(CMAKE_Fortran_COMPILER_ID MATCHES "Intel") - target_compile_definitions(OM3_share PRIVATE CPRINTEL NAMING=_ADD_UNDERSCORE FORTRANUNDERSCORE) + target_compile_definitions(share PRIVATE CPRINTEL NAMING=_ADD_UNDERSCORE FORTRANUNDERSCORE) endif() -target_link_libraries(OM3_share - PUBLIC esmf PIO::PIO_Fortran - PRIVATE AccessOM3::timing +target_link_libraries(share + PUBLIC ESMF::ESMF + PRIVATE Access3::timing PIO::PIO_Fortran ) -target_sources(OM3_share PRIVATE +target_sources(share PRIVATE # The following files are generated with a script acting on templates # We include pre-generated files that are committed to the repository src/shr_assert_mod.F90 @@ -45,8 +47,8 @@ target_sources(OM3_share PRIVATE # The following file is a stub. stubs/mct_mod.F90 ) -add_patched_source(OM3_share CESM_share/src/nuopc_shr_methods.F90) -add_patched_source(OM3_share CESM_share/src/shr_const_mod.F90) +add_patched_source(share CESM_share/src/nuopc_shr_methods.F90) +add_patched_source(share CESM_share/src/shr_const_mod.F90) if(CMAKE_Fortran_COMPILER_ID MATCHES "Intel") # CESM reduces the precision and increases speed for the following file @@ -54,16 +56,16 @@ if(CMAKE_Fortran_COMPILER_ID MATCHES "Intel") 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) +add_fortran_library(ACCESS3_timing mod/timing STATIC) +add_library(Access3::timing ALIAS ACCESS3_timing) +target_compile_definitions(ACCESS3_timing PRIVATE NUOPC_INTERFACE HAVE_MPI) if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU") - target_compile_definitions(OM3_timing PRIVATE CPRGNU NAMING=_ADD_UNDERSCORE FORTRANUNDERSCORE) + target_compile_definitions(ACCESS3_timing PRIVATE CPRGNU NAMING=_ADD_UNDERSCORE FORTRANUNDERSCORE) elseif(CMAKE_Fortran_COMPILER_ID MATCHES "Intel") - target_compile_definitions(OM3_timing PRIVATE CPRINTEL NAMING=_ADD_UNDERSCORE FORTRANUNDERSCORE) + target_compile_definitions(ACCESS3_timing PRIVATE CPRINTEL NAMING=_ADD_UNDERSCORE FORTRANUNDERSCORE) endif() -target_link_libraries(OM3_timing PRIVATE esmf) -target_sources(OM3_timing PRIVATE +target_link_libraries(ACCESS3_timing PRIVATE ESMF::ESMF) +target_sources(ACCESS3_timing PRIVATE timing/f_wrappers.c timing/gptl.c timing/GPTLget_memusage.c @@ -78,52 +80,50 @@ target_sources(OM3_timing PRIVATE ### Install and Export -if(OM3_LIB_INSTALL) - ## share library - set_target_properties(OM3_share PROPERTIES - OUTPUT_NAME access-share - EXPORT_NAME share - ) - install(TARGETS OM3_share - EXPORT AccessOM3share_Targets - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT AccessOM3_RunTime NAMELINK_COMPONENT AccessOM3_Development - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT AccessOM3_Development - ) - # Fortran module files are a special case, as currently there is no standard - # way of handling them in CMake - target_include_directories(OM3_share PUBLIC "$") - get_target_property(share_moddir OM3_share Fortran_MODULE_DIRECTORY) - install(DIRECTORY ${share_moddir}/ - DESTINATION ${CMAKE_INSTALL_MODULEDIR}/access-share - COMPONENT AccessOM3_Development - ) - install(EXPORT AccessOM3share_Targets - FILE AccessOM3shareTargets.cmake - NAMESPACE AccessOM3:: - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/AccessOM3 - ) +## share library +set_target_properties(share PROPERTIES + OUTPUT_NAME access-share + EXPORT_NAME share +) +install(TARGETS share + EXPORT Access3Shareshare_Targets + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT Access3Share_RunTime NAMELINK_COMPONENT Access3Share_Development + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT Access3Share_Development +) +# Fortran module files are a special case, as currently there is no standard +# way of handling them in CMake +target_include_directories(share PUBLIC "$") +get_target_property(share_moddir share Fortran_MODULE_DIRECTORY) +install(DIRECTORY ${share_moddir}/ + DESTINATION ${CMAKE_INSTALL_MODULEDIR}/access-share + COMPONENT Access3Share_Development +) +install(EXPORT Access3Shareshare_Targets + FILE Access3ShareshareTargets.cmake + NAMESPACE Access3:: + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/Access3Share +) - ## timing library - set_target_properties(OM3_timing PROPERTIES - OUTPUT_NAME access-timing - EXPORT_NAME timing - ) - install(TARGETS OM3_timing - EXPORT AccessOM3timing_Targets - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT AccessOM3_RunTime NAMELINK_COMPONENT AccessOM3_Development - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT AccessOM3_Development - ) - # Fortran module files are a special case, as currently there is no standard - # way of handling them in CMake - target_include_directories(OM3_timing PUBLIC "$") - get_target_property(timing_moddir OM3_timing Fortran_MODULE_DIRECTORY) - install(DIRECTORY ${timing_moddir}/ - DESTINATION ${CMAKE_INSTALL_MODULEDIR}/access-timing - COMPONENT AccessOM3_Development - ) - install(EXPORT AccessOM3timing_Targets - FILE AccessOM3timingTargets.cmake - NAMESPACE AccessOM3:: - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/AccessOM3 - ) -endif() +## timing library +set_target_properties(ACCESS3_timing PROPERTIES + OUTPUT_NAME access-timing + EXPORT_NAME timing +) +install(TARGETS ACCESS3_timing + EXPORT Access3Sharetiming_Targets + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT Access3Share_RunTime NAMELINK_COMPONENT Access3Share_Development + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT Access3Share_Development +) +# Fortran module files are a special case, as currently there is no standard +# way of handling them in CMake +target_include_directories(ACCESS3_timing PUBLIC "$") +get_target_property(timing_moddir ACCESS3_timing Fortran_MODULE_DIRECTORY) +install(DIRECTORY ${timing_moddir}/ + DESTINATION ${CMAKE_INSTALL_MODULEDIR}/access-timing + COMPONENT Access3Share_Development +) +install(EXPORT Access3Sharetiming_Targets + FILE Access3SharetimingTargets.cmake + NAMESPACE Access3:: + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/Access3Share +) diff --git a/share/patches/nuopc_shr_methods.F90.patch b/share/patches/nuopc_shr_methods.F90.patch index afe9086..70a4f80 100644 --- a/share/patches/nuopc_shr_methods.F90.patch +++ b/share/patches/nuopc_shr_methods.F90.patch @@ -1,3 +1,6 @@ +# Copyright ACCESS-NRI and contributors. See the top-level COPYRIGHT file for details. +# SPDX-License-Identifier: Apache-2.0 + diff --git a/src/nuopc_shr_methods.F90 b/src/nuopc_shr_methods.F90 index 07cf7e5..8bdf11f 100644 --- a/src/nuopc_shr_methods.F90 diff --git a/share/patches/shr_const_mod.F90.patch b/share/patches/shr_const_mod.F90.patch index b1b0b64..c72cf29 100644 --- a/share/patches/shr_const_mod.F90.patch +++ b/share/patches/shr_const_mod.F90.patch @@ -1,3 +1,6 @@ +# Copyright ACCESS-NRI and contributors. See the top-level COPYRIGHT file for details. +# SPDX-License-Identifier: Apache-2.0 + diff --git a/src/shr_const_mod.F90 b/src/shr_const_mod.F90 index 8437190..9696c81 100644 --- shr_const_mod.F90.old