From 816c0e4230bd8b098c5e8ab628c4a0cfcb2ff5a9 Mon Sep 17 00:00:00 2001 From: kvrigor Date: Wed, 30 Oct 2024 12:58:55 +0100 Subject: [PATCH] More NetCDF fixes BuildParFlow.cmake - NETCDF_INCLUDE_DIR and NETCDF_LIBRARY aren't properly set even NETCDF_DIR is supplied. So we set them explicitly. - Reordered options for readability BuildOASIS3MCT.cmake - Forgot to change NetCDF_ROOT to NetCDF_F90_ROOT --- .github/workflows/CI.yml | 2 ++ cmake/BuildOASIS3MCT.cmake | 2 +- cmake/BuildParFlow.cmake | 54 ++++++++++++++++++++++---------------- 3 files changed, 34 insertions(+), 24 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index ff2ea1c..dcdce0a 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -17,7 +17,9 @@ jobs: env: CC: mpicc + CXX: mpicxx FC: mpifort + F77: mpif77 BUILD_DIR: bld INSTALL_DIR: install MODEL_DIR: ${{ github.workspace }}/component-models diff --git a/cmake/BuildOASIS3MCT.cmake b/cmake/BuildOASIS3MCT.cmake index a2f36d6..c66840f 100644 --- a/cmake/BuildOASIS3MCT.cmake +++ b/cmake/BuildOASIS3MCT.cmake @@ -21,7 +21,7 @@ file(WRITE ${OASIS_MAKE_INC} "CHAN = MPI1\n") file(APPEND ${OASIS_MAKE_INC} "COUPLE = ${OASIS_SRC}\n") file(APPEND ${OASIS_MAKE_INC} "BUILD_DIR = ${OASIS_BLD_DIR}\n") file(APPEND ${OASIS_MAKE_INC} "ARCHDIR = ${OASIS_INSTALL_PREFIX}\n") -file(APPEND ${OASIS_MAKE_INC} "NETCDF_INCLUDE = ${NetCDF_ROOT}/include\n") +file(APPEND ${OASIS_MAKE_INC} "NETCDF_INCLUDE = ${NetCDF_F90_ROOT}/include\n") file(APPEND ${OASIS_MAKE_INC} "NETCDF_LIBRARY = ${NetCDF_LIBRARIES}\n") file(APPEND ${OASIS_MAKE_INC} "MPI_INCLUDE = ${MPI_Fortran_INCLUDE_DIRS}\n") file(APPEND ${OASIS_MAKE_INC} "MAKE = make\n") diff --git a/cmake/BuildParFlow.cmake b/cmake/BuildParFlow.cmake index 9f5a1cb..fb4565f 100644 --- a/cmake/BuildParFlow.cmake +++ b/cmake/BuildParFlow.cmake @@ -3,24 +3,9 @@ find_package(Hypre REQUIRED) find_package(OpenMP REQUIRED) find_package(TCL REQUIRED) -if(CMAKE_C_COMPILER_ID STREQUAL "GNU") - # Flags were based from https://github.com/parflow/parflow/blob/77316043227b95215744e58fe9005d35145432ab/.github/workflows/linux.yml#L305 - set(PF_CFLAGS "${OpenMP_Fortran_FLAGS} -Wall -Werror -Wno-unused-result -Wno-unused-function") - set(PF_FFLAGS "-ffree-line-length-none -ffixed-line-length-none -ffree-form") - list(APPEND JSC_FLAGS -DPARFLOW_ENABLE_SLURM=OFF) -elseif(CMAKE_C_COMPILER_ID STREQUAL "Intel" OR CMAKE_C_COMPILER_ID STREQUAL "IntelLLVM") - set(PF_CFLAGS "${OpenMP_Fortran_FLAGS} -Wall -Werror") - set(PF_FFLAGS "-free") - - #TODO: These flags are specific to JSC system. These flags must be machine-agnostic! - list(APPEND JSC_FLAGS -DPARFLOW_ENABLE_SLURM=ON) - list(APPEND JSC_FLAGS -DMPIEXEC_EXECUTABLE=${MPIEXEC_EXECUTABLE}) - list(APPEND JSC_FLAGS -DMPIEXEC_NUMPROC_FLAG=${MPIEXEC_NUMPROC_FLAG}) - list(APPEND JSC_FLAGS -DCMAKE_EXE_LINKER_FLAGS="-lcudart -lcusparse -lcurand") -else() - message(FATAL_ERROR "C compiler '${CMAKE_C_COMPILER_ID}' is not supported.") -endif() - +# +# Choose which CLM to enable +# if(DEFINED eCLM_SRC) list(APPEND PF_CLM_FLAGS -DPARFLOW_AMPS_LAYER=oas3 -DOAS3_ROOT=${OASIS_ROOT} @@ -35,22 +20,45 @@ else() -DPARFLOW_HAVE_CLM=ON) endif() +# # TODO: Add compile switches for ParFlow GPU +# +if(CMAKE_C_COMPILER_ID STREQUAL "GNU") + # Flags were based from https://github.com/parflow/parflow/blob/77316043227b95215744e58fe9005d35145432ab/.github/workflows/linux.yml#L305 + set(PF_CFLAGS "${OpenMP_Fortran_FLAGS} -Wall -Werror -Wno-unused-result -Wno-unused-function") + #set(PF_FFLAGS "-ffree-line-length-none -ffixed-line-length-none -ffree-form") +elseif(CMAKE_C_COMPILER_ID STREQUAL "Intel" OR CMAKE_C_COMPILER_ID STREQUAL "IntelLLVM") + set(PF_CFLAGS "${OpenMP_Fortran_FLAGS} -Wall -Werror") + #set(PF_FFLAGS "-free") + + #TODO: These flags are specific to JSC system. This should be set in an env or build script! + list(APPEND JSC_FLAGS -DPARFLOW_ENABLE_SLURM=ON) + list(APPEND JSC_FLAGS -DCMAKE_EXE_LINKER_FLAGS="-lcudart -lcusparse -lcurand") +else() + message(FATAL_ERROR "C compiler '${CMAKE_C_COMPILER_ID}' is not supported.") +endif() + +# +# Pass options to ParFlow CMake +# ExternalProject_Add(ParFlow PREFIX ParFlow SOURCE_DIR ${PARFLOW_SRC} CMAKE_ARGS -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} + -DCMAKE_C_FLAGS=${PF_CFLAGS} -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} -DCMAKE_Fortran_COMPILER=${CMAKE_Fortran_COMPILER} + -DCMAKE_Fortran_FLAGS=${PF_FFLAGS} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} - -DNETCDF_DIR=${NetCDF_C_ROOT} - -DPARFLOW_AMPS_SEQUENTIAL_IO=on + -DTCL_TCLSH=${TCL_TCLSH} -DHYPRE_ROOT=${HYPRE_ROOT} + -DNETCDF_INCLUDE_DIR=${NetCDF_C_ROOT}/include + -DNETCDF_LIBRARY=${NetCDF_C_ROOT}/lib + -DPARFLOW_AMPS_SEQUENTIAL_IO=on -DPARFLOW_ENABLE_TIMING=TRUE - -DCMAKE_C_FLAGS=${PF_CFLAGS} - -DCMAKE_Fortran_FLAGS=${PF_FFLAGS} - -DTCL_TCLSH=${TCL_TCLSH} + -DMPIEXEC_EXECUTABLE=${MPIEXEC_EXECUTABLE} + -DMPIEXEC_NUMPROC_FLAG=${MPIEXEC_NUMPROC_FLAG} ${PF_CLM_FLAGS} ${JSC_FLAGS} DEPENDS ${MODEL_DEPENDENCIES}