-
Notifications
You must be signed in to change notification settings - Fork 5
/
CMakeLists.txt
197 lines (176 loc) · 9.71 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
cmake_minimum_required(VERSION 3.0.2)
cmake_policy(SET CMP0048 NEW)
project(ASTR LANGUAGES Fortran)
set(AUTHOR "Jian Fang")
set(AUTHOR_DETAILS "jian.fang@stfc.ac.uk")
set(DESCRIPTION "Building ASTR using cmake")
message(STATUS "building ${PROJECT_NAME}")
include(GNUInstallDirs)
set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR})
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_BINDIR})
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "${PROJECT_BINARY_DIR}/opt" CACHE PATH "..." FORCE)
endif()
# Add support for CMAKE_DEPENDENT_OPTION
INCLUDE(CMakeDependentOption)
INCLUDE(CMakeParseArguments)
# Find the modules included with ASTR
#SET(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
# make sure that the default is a RELEASE
if (NOT CMAKE_BUILD_TYPE)
set (CMAKE_BUILD_TYPE RELEASE CACHE STRING
"Choose the type of build, options are: None Debug Release."
FORCE)
endif (NOT CMAKE_BUILD_TYPE)
set(Fortran_COMPILER_NAME ${CMAKE_Fortran_COMPILER_ID} )
message(STATUS "COMP ID ${Fortran_COMPILER_NAME}")
message(STATUS "Fortran compiler name ${Fortran_COMPILER_NAME}")
message(STATUS "Fortran compiler version ${CMAKE_Fortran_COMPILER_VERSION}")
if (Fortran_COMPILER_NAME MATCHES "GNU")
# gfortran
message(STATUS "Setting gfortran flags")
set(CMAKE_Fortran_FLAGS "-cpp -funroll-loops -floop-optimize -g -fcray-pointer -fbacktrace -ffree-line-length-none")
if (CMAKE_Fortran_COMPILER_VERSION GREATER_EQUAL "10")
message(STATUS "Set New Fortran basic flags")
set(CMAKE_Fortran_FLAGS "-cpp -funroll-loops -floop-optimize -g -fcray-pointer -fbacktrace -ffree-line-length-none -fallow-argument-mismatch")
endif (CMAKE_Fortran_COMPILER_VERSION GREATER_EQUAL "10")
set(CMAKE_Fortran_FLAGS_RELEASE "-funroll-all-loops -fno-f2c -O3")
set(CMAKE_Fortran_FLAGS_DEBUG "-DDEBG -O0 -g")
elseif (Fortran_COMPILER_NAME MATCHES "Intel")
message(STATUS "Setting ifort flags")
set(CMAKE_Fortran_FLAGS "-fpp -xHost -heaparrays -safe-cray-ptr -g -traceback")
set (CMAKE_Fortran_FLAGS_RELEASE "-O3 -ipo")
set (CMAKE_Fortran_FLAGS_DEBUG "-O0 -g -DDEBG")
#set(CMAKE_Fortran_FLAGS "-cpp xSSE4.2 -axAVX,CORE-AVX-I,CORE-AVX2 -ipo -fp-model fast=2 -mcmodel=large -safe-cray-ptr")
elseif (Fortran_COMPILER_NAME MATCHES "NAG")
message(STATUS "Setting nagfor flags")
set(CMAKE_Fortran_FLAGS "-fpp")
set (CMAKE_Fortran_FLAGS_RELEASE "-O3")
set (CMAKE_Fortran_FLAGS_DEBUG "-O0 -g")
elseif (Fortran_COMPILER_NAME MATCHES "Cray")
message(STATUS "Setting cray fortran flags")
set(CMAKE_Fortran_FLAGS "-eF -g -N 1023")
set (CMAKE_Fortran_FLAGS_RELEASE "-O3")
set (CMAKE_Fortran_FLAGS_DEBUG "-O0 -g")
elseif (Fortran_COMPILER_NAME MATCHES "PGI")
message(STATUS "Setting PGI fortran flags")
set(CMAKE_Fortran_FLAGS "-cpp -acc -Mfree -Kieee -Minfo=accel -g")
set (CMAKE_Fortran_FLAGS_RELEASE "-O3")
set (CMAKE_Fortran_FLAGS_DEBUG "-O0 -DDEBG")
elseif (Fortran_COMPILER_NAME MATCHES "Fujitsu")
message(STATUS "Setting Fujitsu fortran flags")
set (CMAKE_Fortran_FLAGS "-Cpp")
set (CMAKE_Fortran_FLAGS_RELEASE "-O3")
set (CMAKE_Fortran_FLAGS_DEBUG "-O0")
else (Fortran_COMPILER_NAME MATCHES "GNU")
message ("CMAKE_Fortran_COMPILER full path: " ${CMAKE_Fortran_COMPILER})
message ("Fortran compiler: " ${Fortran_COMPILER_NAME})
message ("No optimized Fortran compiler flags are known, we just try -O2...")
set (CMAKE_Fortran_FLAGS_RELEASE "-O2")
set (CMAKE_Fortran_FLAGS_DEBUG "-O0 -g")
endif (Fortran_COMPILER_NAME MATCHES "GNU")
if (CMAKE_BUILD_TYPE MATCHES "DEBUG")
add_definitions("-DDEBG")
endif (CMAKE_BUILD_TYPE MATCHES "DEBUG")
find_package(MPI REQUIRED)
# Stop if there is no MPI_Fortran_Compiler
if (MPI_Fortran_COMPILER)
message(STATUS "MPI_Fortran_COMPILER found: ${MPI_Fortran_COMPILER}")
else (MPI_Fortran_COMPILER)
message(SEND_ERROR "This application cannot compile without MPI")
endif(MPI_Fortran_COMPILER)
# Warning if Include are not found => can be fixed with more recent cmake version
if (MPI_FOUND)
message(STATUS "MPI FOUND: ${MPI_FOUND}")
include_directories(SYSTEM ${MPI_INCLUDE_PATH})
message(STATUS "MPI INCL : ${MPI_INCLUDE_PATH}")
else (MPI_FOUND)
message(STATUS "NO MPI include have been found. The executable won't be targeted with MPI include")
message(STATUS "Code will compile but performaces can be compromised")
message(STATUS "Using a CMake vers > 3.10 should solve the problem")
message(STATUS "Alternatively use ccmake to manually set the include if available")
endif (MPI_FOUND)
set(HDF5_PREFER_PARALLEL TRUE)
find_package(HDF5 REQUIRED COMPONENTS Fortran HL)
message(STATUS "HDF5_Fortran_COMPILER found: ${HDF5_Fortran_COMPILER_EXECUTABLE}")
message(STATUS "HDF5_DIR: ${HDF5_DIR}")
# Stop if there is no HDF5
# if (HDF5_Fortran_COMPILER)
# message(STATUS "HDF5_Fortran_COMPILER found: ${HDF5_Fortran_COMPILER}")
# else (HDF5_Fortran_COMPILER)
# message(SEND_ERROR "This application cannot compile without HDF5")
# endif(HDF5_Fortran_COMPILER)
# Warning if Include are not found => can be fixed with more recent cmake version
if (HDF5_FOUND)
message(STATUS "HDF5 FOUND: ${HDF5_FOUND}")
include_directories(${HDF5_INCLUDE_DIRS})
message(STATUS "HDF5 INCL: ${HDF5_INCLUDE_DIRS}")
link_libraries(${HDF5_LIBRARIES})
message(STATUS "HDF5_LIB: ${HDF5_LIBRARIES}")
link_libraries(${HDF5_HL_LIBRARIES})
message(STATUS "HDF5_HL_LIB: ${HDF5_HL_LIBRARIES}")
link_libraries(${HDF5_Fortran_LIBRARIES})
message(STATUS "HDF5_Fortran_LIBRARIES: ${HDF5_Fortran_LIBRARIES}")
link_libraries(${HDF5_Fortran_HL_LIBRARIES})
message(STATUS "HDF5_Fortran_HL_LIBRARIES: ${HDF5_Fortran_HL_LIBRARIES}")
add_definitions("-DHDF5")
else (HDF5_FOUND)
message(STATUS "NO HDF5 include have been found. The executable won't be targeted with HDF5 include")
message(STATUS "Code will compile but performaces can be compromised")
message(STATUS "Using a CMake vers > 3.10 should solve the problem")
message(STATUS "Alternatively use ccmake to manually set the include if available")
endif (HDF5_FOUND)
# set chemistry library
option(CHEMISTRY "Build ASTR with chemistry" OFF)
if (CHEMISTRY)
IF(EXISTS ${CANTERA_DIR})
MESSAGE(STATUS "CANTERA directory " ${CANTERA_DIR})
set(CTRDIR ${CANTERA_DIR})
include_directories(${CTRDIR}/include/cantera)
link_directories(${CTRDIR}/lib)
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
add_definitions(-DCOMB)
else()
message(FATAL_ERROR " !! CANTERA path not found: " ${CANTERA_DIR})
endif(EXISTS ${CANTERA_DIR})
else(CHEMISTRY)
message("chemistry is not activated")
endif (CHEMISTRY)
set(ASTR_ROOT ${CMAKE_CURRENT_SOURCE_DIR})
message(STATUS "ASTR directory: ${ASTR_ROOT}")
set(CMAKE_INSTALL_PREFIX ${ASTR_ROOT})
# Create the ASTR executable
add_subdirectory(src)
# Create an example dir with all input.i3d example files
option(BUILD_TESTING "Build with tests" ON)
set(test_dir "${PROJECT_BINARY_DIR}/Test")
add_subdirectory(examples)
message(STATUS "Before test main ${test_dir}")
set(osub "--oversubscribe")
if (${BUILD_TESTING})
include(CTest)
message(STATUS "MPI INCL ALSO FOUND: ${MPI_INCLUDE_PATH}")
message(STATUS "MPI EXEC: ${MPIEXEC_EXECUTABLE}")
#dd_test(NAME TGV2D COMMAND ${MPIEXEC_EXECUTABLE} -n 4 ${CMAKE_INSTALL_PREFIX}/bin/astr run ./datin/input.tgv2d WORKING_DIRECTORY ${test_dir}/TGV2D)
#et_tests_properties(TGV2D PROPERTIES LABELS "nondim")
add_test(NAME Shuosher COMMAND ${MPIEXEC_EXECUTABLE} -n 2 ${CMAKE_INSTALL_PREFIX}/bin/astr run ./datin/input.shuosher WORKING_DIRECTORY ${test_dir}/Shuosher)
set_tests_properties(Shuosher PROPERTIES LABELS "nondim")
add_test(NAME VT COMMAND ${MPIEXEC_EXECUTABLE} -n 8 ${osub} ${CMAKE_INSTALL_PREFIX}/bin/astr run ./datin/input.2dvort WORKING_DIRECTORY ${test_dir}/VT)
set_tests_properties(VT PROPERTIES LABELS "nondim")
add_test(NAME mixinglayer COMMAND ${MPIEXEC_EXECUTABLE} -n 8 ${osub} ${CMAKE_INSTALL_PREFIX}/bin/astr run ./datin/input.2d WORKING_DIRECTORY ${test_dir}/mixinglayer)
set_tests_properties(mixinglayer PROPERTIES LABELS "nondim")
add_test(NAME WT2D COMMAND ${MPIEXEC_EXECUTABLE} -n 8 ${osub} ${CMAKE_INSTALL_PREFIX}/bin/astr run ./datin/input2d.windtunn WORKING_DIRECTORY ${test_dir}/WT2D)
set_tests_properties(WT2D PROPERTIES LABELS "nondim")
add_test(NAME TGV COMMAND ${MPIEXEC_EXECUTABLE} -n 8 ${osub} ${CMAKE_INSTALL_PREFIX}/bin/astr run ./datin/input.tgv WORKING_DIRECTORY ${test_dir}/TGV)
set_tests_properties(TGV PROPERTIES LABELS "nondim")
add_test(NAME RTI COMMAND ${MPIEXEC_EXECUTABLE} -n 8 ${osub} ${CMAKE_INSTALL_PREFIX}/bin/astr run ./datin/input.rti WORKING_DIRECTORY ${test_dir}/RTI)
set_tests_properties(RTI PROPERTIES LABELS "nondim")
add_test(NAME Channel COMMAND ${MPIEXEC_EXECUTABLE} -n 8 ${osub} ${CMAKE_INSTALL_PREFIX}/bin/astr run ./datin/input.chl WORKING_DIRECTORY ${test_dir}/Channel)
set_tests_properties(Channel PROPERTIES LABELS "nondim")
add_test(NAME SWLBI COMMAND ${MPIEXEC_EXECUTABLE} -n 8 ${osub} ${CMAKE_INSTALL_PREFIX}/bin/astr run ./datin/input.2d WORKING_DIRECTORY ${test_dir}/SWLBI)
set_tests_properties(SWLBI PROPERTIES LABELS "nondim")
add_test(NAME onedflame COMMAND ${MPIEXEC_EXECUTABLE} ${osub} ${CMAKE_INSTALL_PREFIX}/bin/astr run ./datin/input.onedflame WORKING_DIRECTORY ${test_dir}/onedflame)
set_tests_properties(onedflame PROPERTIES LABELS "combustion")
add_test(NAME TGVflame COMMAND ${MPIEXEC_EXECUTABLE} -n 8 ${osub} ${CMAKE_INSTALL_PREFIX}/bin/astr run ./datin/input.tgvflame WORKING_DIRECTORY ${test_dir}/TGVflame)
set_tests_properties(TGVflame PROPERTIES LABELS "combustion")
endif()