-
Notifications
You must be signed in to change notification settings - Fork 7
/
CMakeLists.txt
327 lines (275 loc) · 10.8 KB
/
CMakeLists.txt
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
## Ravindra Shinde (2021) (c) TREX-CoE
cmake_minimum_required(VERSION 3.17 FATAL_ERROR)
# Project's name
project(CHAMP VERSION 2.3.0 LANGUAGES Fortran C)
# Needed for something which we don't know
cmake_policy(SET CMP0079 NEW)
cmake_policy(SET CMP0076 NEW)
set(CMAKE_VERBOSE_MAKEFILE OFF)
# ## Build type
# if(NOT CMAKE_BUILD_TYPE)
# set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type" FORCE)
# endif()
# Cmake modules/macros are in a subdirectory to keep this file cleaner
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules)
# Print the header text art
find_package(Banner)
# useful info
message(STATUS "Compiling :: " ${CMAKE_PROJECT_NAME})
message(STATUS "Fortran compiler :: " ${CMAKE_Fortran_COMPILER} )
message(STATUS "Fortran compiler version :: " ${CMAKE_Fortran_COMPILER_VERSION} )
# Set folder variables:
set(CMAKE_BINARY_DIR ${CMAKE_SOURCE_DIR}/bin)
set(CMAKE_VMC_DIR ${CMAKE_SOURCE_DIR}/src/vmc)
set(CMAKE_DMC_DIR ${CMAKE_SOURCE_DIR}/src/dmc)
set(CMAKE_PARSER_DIR ${CMAKE_SOURCE_DIR}/src/parser)
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR})
set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR})
## User options
# documentation
option(BUILD_DOC "build_doc" off)
# MPI
option(ENABLE_MPI "enable_mpi" on)
# QMMM option
option(ENABLE_QMMM "enable_qmmm" off)
## External packages
option(ENABLE_TREXIO "enable_trexio" off)
option(ENABLE_QMCKL "enable_qmckl" off)
option(ENABLE_GPU "enable_gpu" off)
# Include function to Load MKL
message("")
if(CMAKE_Fortran_COMPILER_ID MATCHES "Intel")
if (BLA_STATIC MATCHES "ON")
set(BLA_VENDOR Intel10_64lp)
else()
set(BLA_VENDOR Intel10_64_dyn)
endif()
# write elseif part here for non-intel compilers
endif()
find_package(BLAS COMPONENTS Fortran REQUIRED QUIET)
find_package(LAPACK COMPONENTS Fortran REQUIRED QUIET)
if (BLAS_FOUND AND LAPACK_FOUND)
message(STATUS "Using BLAS and LAPACK for the linear algebra calculations!")
# Printing individual libraries in the list
message(STATUS "BLAS and LAPACK LIBRARIES : ")
foreach(lib ${BLAS_LIBRARIES})
message(" :: " ${lib})
endforeach(lib)
endif()
set(LINEAR_ALGEBRA ${BLAS_LIBRARIES} ${LAPACK_LIBRARIES})
link_libraries(${LINEAR_ALGEBRA})
# LibFDF is built-in in the src/parser folder
# Find HDF5 library
if (ENABLE_TREXIO)
find_package(HDF5 QUIET)
if (HDF5_FOUND)
message(STATUS "Is HDF5 library found :: " ${HDF5_VERSION})
message(STATUS "Is HDF5 library parallel :: " ${HDF5_IS_PARALLEL})
message(STATUS "HDF5 Library C Compiler exec :: " ${HDF5_C_COMPILER_EXECUTABLE})
message(STATUS "HDF5 include dirs :: " ${HDF5_INCLUDE_DIRS})
message(STATUS "HDF5 library directories : " )
foreach(lib ${HDF5_LIBRARIES})
message(" :: " ${lib})
endforeach(lib)
message(STATUS " ")
# add_definitions(-DHDF5_VERSION=\"${HDF5_VERSION}\")
endif(HDF5_FOUND)
# Find TREXIO
message(" ")
message("Looking for TREXIO library:")
find_package(TREXIO QUIET)
if (TREXIO_FOUND)
message(STATUS "Is TREXIO library found :: " ${TREXIO_FOUND})
message(STATUS "TREXIO Library include dirs :: " ${TREXIO_INCLUDE_DIR})
message(STATUS "TREXIO Library lib dirs :: " ${TREXIO_LIBRARY})
message(STATUS " ")
add_definitions(-DTREXIO_FOUND=\"${TREXIO_FOUND}\")
link_libraries(${TREXIO_LIBRARIES})
include_directories( ${TREXIO_INCLUDE_DIRS} )
endif(TREXIO_FOUND)
endif(ENABLE_TREXIO)
# Find QMCkl
if (TREXIO_FOUND AND ENABLE_QMCKL)
message(" ")
message("Looking for QMCkl library:")
find_package(QMCKL QUIET)
endif()
if (QMCKL_FOUND)
message(STATUS "Is QMCkl library found :: " ${QMCKL_FOUND})
message(STATUS "QMCKL Library include dirs :: " ${QMCKL_INCLUDE_DIR})
message(STATUS "QMCKL Library lib dirs :: " ${QMCKL_LIBRARY})
message(" ")
add_definitions(-DQMCKL_FOUND=\"${QMCKL_FOUND}\")
link_libraries(${QMCKL_LIBRARIES})
include_directories( ${QMCKL_INCLUDE_DIRS} )
endif(QMCKL_FOUND)
#
set(NVFORTRAN_PATH "" CACHE PATH "Path to CUDA executable nvfortran and nvcc")
if (ENABLE_GPU)
find_package(CUDA)
find_package(CUDAToolkit)
endif(ENABLE_GPU)
if (CUDA_FOUND)
message(" ")
message(STATUS "Is CUDA found :: " ${CUDA_FOUND})
message(STATUS "CUDA version :: " ${CUDA_VERSION})
message(STATUS "CUDA toolkit directory :: " ${CUDA_TOOLKIT_ROOT_DIR})
endif()
# documentation requirements
if (BUILD_DOC)
find_package(DOXYGEN)
endif(BUILD_DOC)
if (ENABLE_GPU)
list(APPEND CMAKE_PREFIX_PATH ${NVFORTRAN_PATH})
endif(ENABLE_GPU)
# Find MPI
if (ENABLE_MPI)
find_package(MPI COMPONENTS Fortran REQUIRED)
endif(ENABLE_MPI)
# SIMD instructions
find_package(SIMD)
# system information
find_package(SystemInfo)
# Git information
find_package(GitInfo)
gitinfo(${CMAKE_SOURCE_DIR})
# List of Fortran flags for Nvidia's NVHPC compiler begins here
if(CMAKE_Fortran_COMPILER_ID MATCHES "NVHPC")
list(APPEND Fortran_FLAGS "-O2" "-cpp" "-mcmodel=medium")
list(APPEND Fortran_FLAGS "-D_MPI_")
list(APPEND Fortran_FLAGS "-DCLUSTER")
list(APPEND Fortran_FLAGS "-DPGI")
list(APPEND Fortran_FLAGS "-DOPENACC")
list(APPEND Fortran_FLAGS "-Mfree")
list(APPEND Fortran_FLAGS "-mp=multicore,gpu")
list(APPEND Fortran_FLAGS "-acc")
list(APPEND Fortran_FLAGS "-gpu=cc80")
list(APPEND Fortran_FLAGS "-Mcudalib=cublas")
list(APPEND Fortran_FLAGS "-Mcuda=lineinfo")
list(APPEND Fortran_FLAGS "-Minfo=mp,acc")
list(APPEND Fortran_FLAGS "-gopt")
list(APPEND Fortran_FLAGS "-traceback")
list(APPEND Fortran_FLAGS "-Mextend")
list(APPEND Fortran_FLAGS "-Mnoframe")
#CUDALIB= -L$(CUDA_LIB) -lcufft -lcublasLt -lcublas -lcudart
if (MKL_FOUND)
list(APPEND Fortran_FLAGS "-m64")
endif()
endif()
# List of Fortran flags for Nvidia's NVHPC compiler ends here
# List of Fortran flags for Fujitsu compiler begins here
if(CMAKE_Fortran_COMPILER_ID MATCHES "Fujitsu")
message(STATUS "Fujitsu compiler detected :: ")
list(APPEND Fortran_FLAGS "-O3" "-Cpp" "-Nalloc_assign" "-Fwide" "-fs" "-Kopenmp" "-Kparallel" "-Kfast" "-mcmodel=large" )
list(APPEND Fortran_FLAGS "-D_MPI_")
list(APPEND Fortran_FLAGS "-DCLUSTER")
if (TREXIO_FOUND)
list(APPEND Fortran_FLAGS "-L${TREXIO_LIBRARY} -ltrexio -I${TREXIO_INCLUDE_DIR}")
endif()
endif()
# List of Fortran flags for Fujitsu compiler ends here
# List of Fortran flags for GNU compiler begins here
if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU")
list(APPEND Fortran_FLAGS "-O2" "-cpp" "-mcmodel=large" "-ffree-line-length-none")
list(APPEND Fortran_FLAGS "-D_MPI_")
list(APPEND Fortran_FLAGS "-DCLUSTER")
if(CMAKE_BUILD_TYPE MATCHES "DEBUG")
list(APPEND Fortran_FLAGS "-fcheck=all" "-fbacktrace"
"-g" "-Wall" "-Wextra"
"-Wno-unused" "-Wno-conversion" "-Wno-unused-dummy-argument"
"-Wno-character-truncation" "-Wno-compare-reals"
"-Wno-function-elimination"
"-fno-check-array-temporaries"
"-std=f2018"
#"-Wintrinsics-std"
"-std=legacy"
#"-Werror"
# "-ffpe-trap=invalid,zero,overflow"
)
endif()
# if (TREXIO_FOUND)
# list(APPEND Fortran_FLAGS "-ltrexio")
# endif()
set(CMAKE_Fortran_FORMAT_FIXED_FLAG "-ffixed-form -ffixed-line-length-132 -fno-automatic")
if (MKL_FOUND)
#list(APPEND Fortran_FLAGS "-fdefault-integer-8")
list(APPEND Fortran_FLAGS "-m64")
endif()
# List of Fortran flags for GNU compiler ends here
# List of Fortran flags for Intel's ifort compiler begins here
elseif(CMAKE_Fortran_COMPILER_ID STREQUAL "Intel")
list(APPEND Fortran_FLAGS "-O2" "-diag-disable=all")
list(APPEND Fortran_FLAGS "-fPIC")
list(APPEND Fortran_FLAGS "-implicitnone")
list(APPEND Fortran_FLAGS "-ipo")
list(APPEND Fortran_FLAGS "-finline" "-ip" "-align" "array64byte" "-fma" "-ftz" "-fomit-frame-pointer")
list(APPEND Fortran_FLAGS "-fpp" "-mcmodel=small" "-shared-intel" "-dyncom=grid3d_data,orbital_num_spl,orbital_num_lag,orbital_num_spl2,grid3d_data" )
list(APPEND Fortran_FLAGS "-D_MPI_")
list(APPEND Fortran_FLAGS "-DCLUSTER")
if(CMAKE_BUILD_TYPE MATCHES "DEBUG")
list(APPEND Fortran_FLAGS "-O0" "-diag-enable=all" "-traceback" "-g" "-check" "all" )
else()
endif()
if (TREXIO_FOUND)
list(APPEND Fortran_FLAGS "-ltrexio")
endif()
set(CMAKE_Fortran_FORMAT_FIXED_FLAG "-free")
# List of Fortran flags for Intel's ifort compiler ends here
# List of Fortran flags for Intel's LLVM based compiler begins here
elseif(CMAKE_Fortran_COMPILER_ID STREQUAL "IntelLLVM")
list(APPEND Fortran_FLAGS "-O2")
list(APPEND Fortran_FLAGS "-fPIC")
list(APPEND Fortran_FLAGS "-implicitnone")
list(APPEND Fortran_FLAGS "-finline" "-align" "array64byte" "-fma" "-ftz" "-fomit-frame-pointer")
list(APPEND Fortran_FLAGS "-fpp" "-mcmodel=small" "-shared-intel" "-dyncom=grid3d_data,orbital_num_spl,orbital_num_lag,orbital_num_spl2,grid3d_data" )
list(APPEND Fortran_FLAGS "-D_MPI_")
list(APPEND Fortran_FLAGS "-DCLUSTER")
if(CMAKE_BUILD_TYPE MATCHES "DEBUG")
list(APPEND Fortran_FLAGS "-O0" "-diag-enable=all" "-traceback" "-g" "-check" "all" )
else()
endif()
if (TREXIO_FOUND)
list(APPEND Fortran_FLAGS "-ltrexio")
endif()
set(CMAKE_Fortran_FORMAT_FIXED_FLAG "-free")
# List of Fortran flags for Intel's LLVM based compiler ends here
#List of Fortran flags for LLVM "classic" Flang based compiler begins here
#This include flang and aocc-flang and shouldn't be confused with flang-new (LLVMFlang in cmake)
elseif(CMAKE_Fortran_COMPILER_ID STREQUAL "Flang")
list(APPEND Fortran_FLAGS "-O2" "-cpp" "-mcmodel=large")
list(APPEND Fortran_FLAGS "-D_MPI_")
list(APPEND Fortran_FLAGS "-DCLUSTER")
if (TREXIO_FOUND)
list(APPEND Fortran_FLAGS "-ltrexio")
endif()
set(CMAKE_Fortran_FORMAT_FIXED_FLAG "-ffixed-form -ffixed-line-length-132")
#List of Fortran flags for LLVM Flang based compiler ends here
elseif(Fortran_COMPILER_ID MATCHES "PGI")
list(APPEND CMAKE_Fortran_FLAGS "-Mfreeform -Mdclchk -Mstandard -Mallocatable=03")
endif()
message("")
message(STATUS "Fortran compiler flags : " )
foreach(flag ${Fortran_FLAGS})
message(" :: " ${flag})
endforeach(flag)
## Subdirectories
# Include the following subdirectories
add_subdirectory(src)
add_subdirectory(tools)
add_subdirectory(lib)
## Testing
MESSAGE(STATUS " Tests are enabled :: cd build; ctest")
enable_testing()
add_subdirectory(tests)
#Packaging
set(CPACK_ARCHIVE_COMPONENT_INSTALL 1)
set(CPACK_ARCHIVE_GENERATOR "TBZ2")
set(CPACK_SOURCE_GENERATOR "ZIP")
set(CPACK_PACKAGE_VERSION "2.3.0")
set(CPACK_PACKAGE_NAME "CHAMP")
set(CPACK_ARCHIVE_FILE_NAME "CHAMP-v2.3.0.zip")
set(CPACK_PACKAGE_VERSION "v2.3.0")
set(CPACK_PACKAGE_VERSION_MAJOR "2")
set(CPACK_PACKAGE_VERSION_MINOR "3")
set(CPACK_PACKAGE_VERSION_PATCH "0")
include(CPack)