Skip to content

Commit

Permalink
More NetCDF fixes
Browse files Browse the repository at this point in the history
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
  • Loading branch information
kvrigor committed Oct 30, 2024
1 parent f9dc2e2 commit 816c0e4
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 24 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion cmake/BuildOASIS3MCT.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
54 changes: 31 additions & 23 deletions cmake/BuildParFlow.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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}
Expand Down

0 comments on commit 816c0e4

Please sign in to comment.