From 30d0d840f59cc54d15e728d758556fb550090d57 Mon Sep 17 00:00:00 2001 From: kvrigor Date: Wed, 30 Oct 2024 10:55:53 +0100 Subject: [PATCH] Forced cache component model repos; specified full path to dependencies and component models --- .github/workflows/CI.yml | 84 ++++++++++++++++++++++++++------------ cmake/BuildPDAFMODEL.cmake | 2 +- cmake/BuildParFlow.cmake | 2 +- cmake/FindNetCDF.cmake | 26 ++++++++++-- 4 files changed, 82 insertions(+), 32 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index f8983d7..ff2ea1c 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -20,13 +20,13 @@ jobs: FC: mpifort BUILD_DIR: bld INSTALL_DIR: install - MODEL_DIR: component-models + MODEL_DIR: ${{ github.workspace }}/component-models OASIS_TAG: tsmp-patches-v0.1 eCLM_TAG: beta-0.1 PARFLOW_TAG: v3.13.0 HYPRE_TAG: 2.26.0 CMAKE_BUILD_PARALLEL_LEVEL: 4 - CMAKE_PREFIX_PATH: dependencies + CMAKE_PREFIX_PATH: ${{ github.workspace }}/dependencies SYSTEMNAME: ${{ matrix.os }} steps: @@ -44,16 +44,17 @@ jobs: run: | mkdir -p ${CMAKE_PREFIX_PATH} ${MODEL_DIR} + # + # OASIS3-MCT + # - name: Restore cached OASIS3-MCT ${{ env.OASIS_TAG }} - uses: actions/cache@v4 - id: cache-oasis - env: - cache-name: cache-oasis + uses: actions/cache/restore@v4 + id: cache-oasis-restore with: path: ${{ env.MODEL_DIR }}/oasis3-mct key: cache-${{ matrix.config.name }}-${{ env.OASIS_TAG }} - - if: steps.cache-oasis.outputs.cache-hit != 'true' + - if: steps.cache-oasis-restore.outputs.cache-hit != 'true' name: Download OASIS3-MCT ${{ env.OASIS_TAG }} working-directory: ${{ env.MODEL_DIR }} run: | @@ -61,16 +62,24 @@ jobs: echo "OASIS3-MCT version: $(cd oasis3-mct && git describe --tags --always)" realpath oasis3-mct + - if: steps.cache-oasis-restore.outputs.cache-hit != 'true' + name: Cache OASIS3-MCT ${{ env.OASIS_TAG }} + uses: actions/cache/save@v4 + with: + path: ${{ env.MODEL_DIR }}/oasis3-mct + key: cache-${{ matrix.config.name }}-${{ env.OASIS_TAG }} + + # + # eCLM + # - name: Restore cached eCLM ${{ env.eCLM_TAG }} - uses: actions/cache@v4 - id: cache-eclm - env: - cache-name: cache-eclm + uses: actions/cache/restore@v4 + id: cache-eclm-restore with: path: ${{ env.MODEL_DIR }}/eCLM - key: cache-${{ matrix.config.name }} + key: cache-${{ matrix.config.name }}-${{ env.eCLM_TAG }} - - if: steps.cache-eclm.outputs.cache-hit != 'true' + - if: steps.cache-eclm-restore.outputs.cache-hit != 'true' name: Download eCLM ${{ env.eCLM_TAG }} working-directory: ${{ env.MODEL_DIR }} run: | @@ -78,16 +87,24 @@ jobs: echo "eCLM version: $(cd eCLM && git describe --tags --always)" realpath eCLM + - if: steps.cache-eclm-restore.outputs.cache-hit != 'true' + name: Cache eCLM ${{ env.eCLM_TAG }} + uses: actions/cache/save@v4 + with: + path: ${{ env.MODEL_DIR }}/eCLM + key: cache-${{ matrix.config.name }}-${{ env.eCLM_TAG }} + + # + # ParFlow + # - name: Restore cached ParFlow ${{ env.PARFLOW_TAG }} - uses: actions/cache@v4 - id: cache-parflow - env: - cache-name: cache-parflow + uses: actions/cache/restore@v4 + id: cache-parflow-restore with: path: ${{ env.MODEL_DIR }}/parflow key: cache-${{ matrix.config.name }}-${{ env.PARFLOW_TAG }} - - if: steps.cache-parflow.outputs.cache-hit != 'true' + - if: steps.cache-parflow-restore.outputs.cache-hit != 'true' name: Download ParFlow ${{ env.PARFLOW_TAG }} working-directory: ${{ env.MODEL_DIR }} run: | @@ -95,16 +112,24 @@ jobs: echo "ParFlow version: $(cd parflow && git describe --tags --always)" realpath parflow + - if: steps.cache-parflow-restore.outputs.cache-hit != 'true' + name: Cache ParFlow ${{ env.PARFLOW_TAG }} + uses: actions/cache/save@v4 + with: + path: ${{ env.MODEL_DIR }}/parflow + key: cache-${{ matrix.config.name }}-${{ env.PARFLOW_TAG }} + + # + # Hypre + # - name: Restore cached Hypre ${{ env.HYPRE_TAG }} - uses: actions/cache@v4 - id: cache-hypre - env: - cache-name: cache-hypre + uses: actions/cache/restore@v4 + id: cache-hypre-restore with: path: ${{ env.CMAKE_PREFIX_PATH }} key: cache-${{ matrix.config.name }}-${{ env.HYPRE_TAG }} - - if: steps.cache-hypre.outputs.cache-hit != 'true' + - if: steps.cache-hypre-restore.outputs.cache-hit != 'true' name: Install Hypre ${{ env.HYPRE_TAG }} run: | wget https://github.com/hypre-space/hypre/archive/v${HYPRE_TAG}.tar.gz @@ -113,11 +138,16 @@ jobs: ./configure --prefix=$(realpath $CMAKE_PREFIX_PATH) make -j${CMAKE_BUILD_PARALLEL_LEVEL} install - - name: Check for component model and dependency directories - run: | - tree ${CMAKE_PREFIX_PATH} - tree ${MODEL_DIR} + - if: steps.cache-hypre-restore.outputs.cache-hit != 'true' + name: Cache Hypre ${{ env.HYPRE_TAG }} + uses: actions/cache/save@v4 + with: + path: ${{ env.CMAKE_PREFIX_PATH }} + key: cache-${{ matrix.config.name }}-${{ env.HYPRE_TAG }} + # + # TSMP2 + # - name: Configure TSMP2 run: >- cmake -S . -B ${BUILD_DIR} diff --git a/cmake/BuildPDAFMODEL.cmake b/cmake/BuildPDAFMODEL.cmake index f730933..81fe91b 100644 --- a/cmake/BuildPDAFMODEL.cmake +++ b/cmake/BuildPDAFMODEL.cmake @@ -17,7 +17,7 @@ set(TSMPPDAFLIBDIR "${CMAKE_INSTALL_PREFIX}/lib") # Include directories # ------------------- # General include dirs -list(APPEND PDAF_INCLUDES "-I${NetCDF_ROOT}/include") +list(APPEND PDAF_INCLUDES "-I${NetCDF_F90_ROOT}/include") # DA include dirs list(APPEND PDAF_INCLUDES "-I${PDAF_SRC}/interface/model") diff --git a/cmake/BuildParFlow.cmake b/cmake/BuildParFlow.cmake index c929c1a..9f5a1cb 100644 --- a/cmake/BuildParFlow.cmake +++ b/cmake/BuildParFlow.cmake @@ -44,7 +44,7 @@ ExternalProject_Add(ParFlow -DCMAKE_Fortran_COMPILER=${CMAKE_Fortran_COMPILER} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} - -DNETCDF_DIR=${NetCDF_ROOT} + -DNETCDF_DIR=${NetCDF_C_ROOT} -DPARFLOW_AMPS_SEQUENTIAL_IO=on -DHYPRE_ROOT=${HYPRE_ROOT} -DPARFLOW_ENABLE_TIMING=TRUE diff --git a/cmake/FindNetCDF.cmake b/cmake/FindNetCDF.cmake index 80b8ac4..db04742 100644 --- a/cmake/FindNetCDF.cmake +++ b/cmake/FindNetCDF.cmake @@ -3,20 +3,40 @@ include(FindPackageHandleStandardArgs) find_package(NetCDF_C QUIET NAMES netCDF) if(NetCDF_C_FOUND) + # Set default NetCDF C paths to the first found NetCDF C library. set(NetCDF_C_LIB_DIR "${netCDF_LIB_DIR}") + set(NetCDF_C_ROOT "${netCDF_INSTALL_PREFIX}") + + # However, if the default NetCDF C library doesn't have parallel support, try searching for another one. + if(NOT ${netCDF_HAS_PARALLEL}) + # Option 1 (Ubuntu-specific): `sudo apt-get install libnetcdf-mpi-dev` provides NetCDF with parallel support. + pkg_check_modules(NetCDF_C_MPI QUIET netcdf-mpi) + if (NetCDF_C_MPI_FOUND) + pkg_get_variable(NetCDF_C_ROOT netcdf-mpi prefix) + set(NetCDF_C_LIB_DIR "${NetCDF_C_ROOT}/lib") + set(netCDF_HAS_PARALLEL "ON") + endif() + endif() endif() pkg_check_modules(NetCDF_F90 REQUIRED netcdf-fortran) if (NetCDF_F90_FOUND) - pkg_get_variable(NetCDF_F90_LIB_DIR netcdf-fortran libdir) pkg_get_variable(NetCDF_F90_ROOT netcdf-fortran prefix) + pkg_get_variable(NetCDF_F90_LIB_DIR netcdf-fortran libdir) + pkg_get_variable(NetCDF_F90_INCLUDEDIR netcdf-fortran fmoddir) endif() find_package_handle_standard_args(NetCDF - REQUIRED_VARS NetCDF_C_LIB_DIR NetCDF_F90_LIB_DIR + REQUIRED_VARS NetCDF_C_ROOT NetCDF_F90_ROOT NetCDF_C_LIB_DIR NetCDF_F90_LIB_DIR NetCDF_F90_INCLUDEDIR VERSION_VAR NetCDF_F90_VERSION) if(NetCDF_FOUND) set(NetCDF_LIBRARIES "-L${NetCDF_C_LIB_DIR} -L${NetCDF_F90_LIB_DIR} -lnetcdff -lnetcdf" CACHE STRING "NetCDF linker options") - set(NetCDF_ROOT ${NetCDF_F90_ROOT} CACHE PATH "Full path to the root directory containing NetCDF include files and libraries.") + set(NetCDF_F90_ROOT ${NetCDF_F90_ROOT} CACHE PATH "Path to NetCDF-Fortran directory which contains its include header files and libraries.") + set(NetCDF_C_ROOT ${NetCDF_C_ROOT} CACHE PATH "Path to NetCDF-C directory which contains its include header files and libraries.") + if (netCDF_HAS_PARALLEL) + message(STATUS "TSMP2 found NetCDF C built with parallel I/O support.") + else() + message(WARNING "TSMP2 is using NetCDF C without parallel I/O support.") + endif() endif() \ No newline at end of file