From c85b1318cc81b47e3403e8196fc07795f0170c75 Mon Sep 17 00:00:00 2001 From: Micael Oliveira Date: Mon, 27 Nov 2023 13:48:29 +1100 Subject: [PATCH 1/3] Treat FoX as an external dependency: do not compile it anymore, instead try to find it using pkgconfig. --- .gitmodules | 3 --- CDEPS/CMakeLists.txt | 17 +++++--------- CDEPS/fox | 1 - CMakeLists.txt | 1 + cmake/FindFoX.cmake | 56 ++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 63 insertions(+), 15 deletions(-) delete mode 160000 CDEPS/fox create mode 100644 cmake/FindFoX.cmake diff --git a/.gitmodules b/.gitmodules index ecd28e5..618e7a7 100644 --- a/.gitmodules +++ b/.gitmodules @@ -13,9 +13,6 @@ [submodule "share/CESM_share"] path = share/CESM_share url = https://github.com/ESCOMP/CESM_share.git -[submodule "CDEPS/fox"] - path = CDEPS/fox - url = https://github.com/ESMCI/fox/ [submodule "WW3/WW3"] path = WW3/WW3 url = https://github.com/ESCOMP/WW3 diff --git a/CDEPS/CMakeLists.txt b/CDEPS/CMakeLists.txt index 3db3b24..3d39fb0 100644 --- a/CDEPS/CMakeLists.txt +++ b/CDEPS/CMakeLists.txt @@ -5,7 +5,7 @@ add_fortran_library(OM3_cdeps_common mod/common STATIC) target_include_directories(OM3_cdeps_common PRIVATE $) target_link_libraries(OM3_cdeps_common PUBLIC esmf - PRIVATE OM3_share OM3_cmeps FoX_dom PIO::PIO_Fortran + PRIVATE OM3_share OM3_cmeps FoX::FoX PIO::PIO_Fortran ) target_sources(OM3_cdeps_common PRIVATE CDEPS/streams/dshr_methods_mod.F90 @@ -23,7 +23,7 @@ add_fortran_library(OM3_cdeps_datm mod/datm STATIC) target_include_directories(OM3_cdeps_datm PRIVATE $) target_link_libraries(OM3_cdeps_datm PUBLIC esmf - PRIVATE OM3_share OM3_cmeps FoX_dom OM3_cdeps_common PIO::PIO_Fortran + PRIVATE OM3_share OM3_cmeps FoX::FoX OM3_cdeps_common PIO::PIO_Fortran ) target_sources(OM3_cdeps_datm PRIVATE CDEPS/datm/datm_datamode_cfsr_mod.F90 @@ -42,7 +42,7 @@ add_fortran_library(OM3_cdeps_docn mod/docn STATIC) target_include_directories(OM3_cdeps_docn PRIVATE $) target_link_libraries(OM3_cdeps_docn PUBLIC esmf - PRIVATE OM3_share OM3_cmeps FoX_dom OM3_cdeps_common PIO::PIO_Fortran + PRIVATE OM3_share OM3_cmeps FoX::FoX OM3_cdeps_common PIO::PIO_Fortran ) target_sources(OM3_cdeps_docn PRIVATE CDEPS/docn/docn_datamode_aquaplanet_mod.F90 @@ -59,7 +59,7 @@ add_fortran_library(OM3_cdeps_dice mod/dice STATIC) target_include_directories(OM3_cdeps_dice PRIVATE $) target_link_libraries(OM3_cdeps_dice PUBLIC esmf - PRIVATE OM3_share OM3_cmeps FoX_dom OM3_cdeps_common PIO::PIO_Fortran + PRIVATE OM3_share OM3_cmeps FoX::FoX OM3_cdeps_common PIO::PIO_Fortran ) target_sources(OM3_cdeps_dice PRIVATE CDEPS/dice/dice_datamode_ssmi_mod.F90 @@ -72,7 +72,7 @@ add_fortran_library(OM3_cdeps_dwav mod/dwav STATIC) target_include_directories(OM3_cdeps_dwav PRIVATE $) target_link_libraries(OM3_cdeps_dwav PUBLIC esmf - PRIVATE OM3_share OM3_cmeps FoX_dom OM3_cdeps_common PIO::PIO_Fortran + PRIVATE OM3_share OM3_cmeps FoX::FoX OM3_cdeps_common PIO::PIO_Fortran ) target_sources(OM3_cdeps_dwav PRIVATE CDEPS/dwav/wav_comp_nuopc.F90 @@ -83,13 +83,8 @@ add_fortran_library(OM3_cdeps_drof mod/drof STATIC) target_include_directories(OM3_cdeps_drof PRIVATE $) target_link_libraries(OM3_cdeps_drof PUBLIC esmf - PRIVATE OM3_share OM3_cmeps FoX_dom OM3_cdeps_common PIO::PIO_Fortran + PRIVATE OM3_share OM3_cmeps FoX::FoX OM3_cdeps_common PIO::PIO_Fortran ) target_sources(OM3_cdeps_drof PRIVATE CDEPS/drof/rof_comp_nuopc.F90 ) - -### Subdirectories - -## Build FoX -add_subdirectory(fox) diff --git a/CDEPS/fox b/CDEPS/fox deleted file mode 160000 index 4ff17b4..0000000 --- a/CDEPS/fox +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 4ff17b4a1a66b4ae0fbe9a2067503cb4b4c292c0 diff --git a/CMakeLists.txt b/CMakeLists.txt index a9333bd..4c7533e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -119,6 +119,7 @@ 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) diff --git a/cmake/FindFoX.cmake b/cmake/FindFoX.cmake new file mode 100644 index 0000000..b09bb35 --- /dev/null +++ b/cmake/FindFoX.cmake @@ -0,0 +1,56 @@ +# We will use pkgconfig to find the library +find_package(PkgConfig REQUIRED) + +## Prepare arguments to pass to pkg_search_module + +# QUIET +set(_quiet_arg) +if (FoX_FIND_QUIETLY) + list(APPEND _quiet_arg QUIET) +endif () + +# REQUIRED +set(_required_arg) +if (FoX_FIND_REQUIRED) + list(APPEND _required_arg REQUIRED) +endif () + +# Construct the moduleSpec to search for +if (DEFINED FoX_FIND_VERSION_RANGE) + # Can only parse the minimum requirement + list(APPEND PKG_MODULE_SPECS "fox>=${FoX_FIND_VERSION_MIN}") +elseif ({FoX_FIND_VERSION_EXACT) + # Requesting exact version + list(APPEND PKG_MODULE_SPECS "fox=${FoX_FIND_VERSION}") +elseif (DEFINED FoX_FIND_VERSION) + # Otherwise treat the request as minimum requirement + list(APPEND PKG_MODULE_SPECS "fox>=${FoX_FIND_VERSION}") +else () + # Fallthrough if no version is required + list(APPEND PKG_MODULE_SPECS "fox") +endif () + +## Call pkg-config +if (CMAKE_VERSION VERSION_LESS 3.28) + # https://gitlab.kitware.com/cmake/cmake/-/issues/25228 + set(ENV{PKG_CONFIG_ALLOW_SYSTEM_CFLAGS} 1) +endif () +if (CMAKE_VERSION VERSION_LESS 3.22) + # Back-porting + # https://gitlab.kitware.com/cmake/cmake/-/merge_requests/6345 + set(ENV{PKG_CONFIG_ALLOW_SYSTEM_LIBS} 1) +endif () +pkg_search_module(FoX + ${_required_arg} ${_quiet_arg} + IMPORTED_TARGET + ${PKG_MODULE_SPECS}) + +## Create alias if package was found by pkg-config +if (FoX_FOUND) + add_library(FoX::FoX ALIAS PkgConfig::FoX) +endif () + +# Sanitize local variables +set(PKG_MODULE_SPECS) +set(_quiet_arg) +set(_required_arg) From 161473563a339b92cd4ccc32330bcd7ef8873c50 Mon Sep 17 00:00:00 2001 From: Micael Oliveira Date: Mon, 27 Nov 2023 13:59:36 +1100 Subject: [PATCH 2/3] Update build script: use development version of spack environment and add fortranxml to list of modules to load. --- build.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.sh b/build.sh index 3fea3cf..8f5fbb4 100755 --- a/build.sh +++ b/build.sh @@ -20,8 +20,8 @@ OPENMPI_VERSION=4.1.4 module purge module load cmake/3.24.2 -module use /g/data/ik11/spack/0.20.1/modules/access-om3/0.2.0/linux-rocky8-x86_64 # requires membership of "ik11" group -module load esmf/8.4.2 fms/git.2021.03.01=2021.03.01 parallelio/2.5.10 +module use /g/data/ik11/spack/0.20.1/modules/access-om3/0.x.0/linux-rocky8-cascadelake # requires membership of "ik11" group +module load esmf/8.4.2 fms/git.2021.03.01=2021.03.01 parallelio/2.5.10 fortranxml/4.1.2 module load intel-compiler/${COMPILER_VERSION} openmpi/${OPENMPI_VERSION} cd ${SCRIPT_DIR} From d76d8ac3cbb1f3f92fa78ec40ea4effabc9f38d2 Mon Sep 17 00:00:00 2001 From: Micael Oliveira Date: Tue, 28 Nov 2023 17:35:59 +1100 Subject: [PATCH 3/3] Use main branch of CI images for testing. --- .github/workflows/compilation.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/compilation.yml b/.github/workflows/compilation.yml index 9c2b431..c17b188 100644 --- a/.github/workflows/compilation.yml +++ b/.github/workflows/compilation.yml @@ -14,7 +14,7 @@ jobs: build_type: [Debug, Release] container: - image: ghcr.io/cosima/access-om3-ci-images/${{matrix.compiler}}:0.4.1 + image: ghcr.io/cosima/access-om3-ci-images/${{matrix.compiler}}:main steps: - name: Checkout