-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathBuildParFlow.cmake
More file actions
104 lines (97 loc) · 3.71 KB
/
Copy pathBuildParFlow.cmake
File metadata and controls
104 lines (97 loc) · 3.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# Choose which CLM to enable
if(DEFINED eCLM_SRC)
list(APPEND PF_CLM_FLAGS -DPARFLOW_AMPS_LAYER=oas3
-DOAS3_ROOT=${OASIS_ROOT}
-DPARFLOW_HAVE_ECLM=ON)
elseif(DEFINED CLM35_SRC)
list(APPEND PF_CLM_FLAGS -DPARFLOW_AMPS_LAYER=oas3
-DOAS3_ROOT=${OASIS_ROOT}
-DPARFLOW_HAVE_ECLM=OFF
-DPARFLOW_HAVE_CLM=OFF)
else()
# use ParFlow's internal CLM
list(APPEND PF_CLM_FLAGS -DPARFLOW_AMPS_LAYER=mpi1
-DPARFLOW_HAVE_CLM=ON)
endif()
# Set GPU-specific options
if (${ParFlowGPU})
# TODO: Add option to specify CUDA or Kokkos
include(FindCUDAToolkit)
if (CUDAToolkit_FOUND)
set(PF_ACC_BACKEND "cuda")
else()
# Search for Kokkos (untested)
find_package(Kokkos)
if (Kokkos_FOUND)
set(PF_ACC_BACKEND "kokkos")
else()
message(FATAL_ERROR "BuildParFlow: ParFlow GPU is enabled, but neither CUDA nor Kokkos was found.")
endif()
endif()
else()
find_package(OpenMP)
if (OpenMP_FOUND)
set(PF_ACC_BACKEND "omp")
else()
set(PF_ACC_BACKEND "none")
endif()
endif()
# Set compiler flags
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
# Flags were based from https://github.com/parflow/parflow/blob/c8aa8d7140db19153194728b8fa9136b95177b6d/.github/workflows/linux.yml#L486
set(PF_CFLAGS "-Wall -Werror -Wno-unused-result -Wno-unused-function -Wno-stringop-overread")
if(${PDAF})
# parflow-pdaf fork currently ignores unused variables
string(APPEND PF_CFLAGS " -Wno-unused-variable")
endif()
# Silence arch-specific compiler warnings
if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm64|aarch64")
string(APPEND PF_CFLAGS " -Wno-maybe-uninitialized")
endif()
set(PF_FFLAGS "-ffree-line-length-none -ffixed-line-length-none")
elseif(CMAKE_C_COMPILER_ID STREQUAL "Intel" OR CMAKE_C_COMPILER_ID STREQUAL "IntelLLVM")
set(PF_CFLAGS "-Wall -Werror -Wno-unused-function -Wno-unused-variable")
else()
message(FATAL_ERROR "C compiler '${CMAKE_C_COMPILER_ID}' is not supported.")
endif()
# Enable/disable SLURM
find_program(SLURM_SRUN srun DOC "Path to the SLURM srun executable")
if(SLURM_SRUN)
set(ENABLE_SLURM "ON")
else()
set(ENABLE_SLURM "OFF")
endif()
# Enable Umpire if exists
if (DEFINED ENV{UMPIRE_ROOT} AND NOT ${PDAF})
set(PF_UMPIRE_FLAG "-DUMPIRE_ROOT=$ENV{UMPIRE_ROOT}")
endif()
# Enable SUNDIALS if exists
if (DEFINED ENV{SUNDIALS_ROOT} AND NOT ${PDAF})
set(PF_SUNDIALS_FLAG "-DSUNDIALS_ROOT=$ENV{SUNDIALS_ROOT}")
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}
-DPARFLOW_ENABLE_HYPRE=ON
-DPARFLOW_ENABLE_NETCDF=ON
-DPARFLOW_AMPS_SEQUENTIAL_IO=ON
-DPARFLOW_ENABLE_TIMING=TRUE
-DPARFLOW_ACCELERATOR_BACKEND=${PF_ACC_BACKEND}
-DMPIEXEC_EXECUTABLE=${MPIEXEC_EXECUTABLE}
-DMPIEXEC_NUMPROC_FLAG=${MPIEXEC_NUMPROC_FLAG}
-DPARFLOW_ENABLE_SLURM=${ENABLE_SLURM}
${PF_UMPIRE_FLAG}
${PF_SUNDIALS_FLAG}
${PF_CLM_FLAGS}
DEPENDS ${MODEL_DEPENDENCIES}
)
get_model_version(${PARFLOW_SRC} PARFLOW_VERSION)
list(APPEND TSMP2_MODEL_VERSIONS "${PARFLOW_ID}: ${PARFLOW_VERSION}")