Skip to content

Commit 402e670

Browse files
author
Moni(cluster)
committed
Merge branch 'moniWEM' of repo.ctcc.no:pcmsolver into moniWEM
2 parents 6783fec + 2548fb5 commit 402e670

File tree

215 files changed

+1814
-442093
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

215 files changed

+1814
-442093
lines changed

CMakeLists.txt

Lines changed: 62 additions & 147 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
2-
# Always prefer system modules to local ones
3-
cmake_policy(SET CMP0017 NEW)
2+
# Set CMake policies here
3+
if(CMAKE_VERSION VERSION_GREATER 2.8.3)
4+
# CMP0017 was introduced in CMake 2.8.4
5+
# Always prefer system modules to local ones
6+
cmake_policy(SET CMP0017 NEW)
7+
endif()
48
#
59
# Declare project name and programming languages
610
#
7-
project(PCMSolver)
8-
enable_language(CXX C Fortran)
11+
project(PCMSolver CXX C Fortran)
912
#
1013
# Options
1114
# There still is nothing going on inside the code regarding MPI and OpenMP!!
@@ -45,160 +48,82 @@ include(GenericMacros)
4548
include(ConfigGitRevision) # Has to come after ConfigVersion.cmake
4649
include(MergeStaticLibs)
4750
include(FortranCInterface)
48-
include(CheckPython)
4951

5052
FortranCInterface_VERIFY(CXX)
5153
init_FCMangle()
5254

5355
set(EMBEDDED_PYTHON FALSE)
54-
# Check Python:
56+
# Try to configure Python, if not possible disable Python embedding
5557
if(ENABLE_PYTHON_EMBEDDING)
56-
# 1. a Python interpreter of the suitable version exists
57-
if("${PYTHON_INTERPRETER}" STREQUAL "")
58-
find_package(PythonInterp 2.4 REQUIRED)
59-
else()
60-
set(PYTHONINTERP_FOUND TRUE)
61-
set(PYTHON_EXECUTABLE "${PYTHON_INTERPRETER}")
62-
get_Python_version_string(pyVersion)
63-
set(PYTHON_VERSION_STRING "${pyVersion}")
64-
message(STATUS "Passed PythonInterp: ${PYTHON_INTERPRETER} (found suitable version \"${PYTHON_VERSION_STRING}\", minimum required is \"2.4\")")
65-
endif()
66-
# 2. Python libraries and headers of the same version exist
67-
# Set variables to help find Python library that is compatible with interpreter
68-
# Copied from https://bitbucket.org/fenics-project/dolfin
69-
if(PYTHONINTERP_FOUND)
70-
# Get Python include path from Python interpretter
71-
execute_process(COMMAND "${PYTHON_EXECUTABLE}" -c
72-
"import distutils.sysconfig, sys; sys.stdout.write(distutils.sysconfig.get_python_inc())"
73-
OUTPUT_VARIABLE _PYTHON_INCLUDE_PATH
74-
RESULT_VARIABLE _PYTHON_INCLUDE_RESULT)
75-
# Get Python library path from interpreter
76-
execute_process(COMMAND "${PYTHON_EXECUTABLE}" -c
77-
"import os, sys, inspect; sys.stdout.write(os.path.split(os.path.split(inspect.getfile(inspect))[0])[0])"
78-
OUTPUT_VARIABLE _PYTHON_LIB_PATH
79-
RESULT_VARIABLE _PYTHON_LIB_RESULT)
80-
# Set include path, if returned by interpreter
81-
if("${_PYTHON_INCLUDE_RESULT}" STREQUAL "0")
82-
set(PYTHON_INCLUDE_DIR ${_PYTHON_INCLUDE_PATH})
83-
endif()
84-
# Add a search path for Python library based on output from
85-
# interpreter
86-
set(CMAKE_LIBRARY_PATH_SAVE ${CMAKE_LIBRARY_PATH})
87-
if("${_PYTHON_LIB_RESULT}" STREQUAL "0")
88-
set(CMAKE_LIBRARY_PATH ${_PYTHON_LIB_PATH})
89-
endif()
90-
# Find Pythons libs
91-
find_package(PythonLibs ${PYTHON_VERSION_STRING} EXACT REQUIRED)
92-
# Check headers
93-
include(CheckIncludeFiles)
94-
set(CMAKE_REQUIRED_INCLUDES "${PYTHON_INCLUDE_DIRS}")
95-
check_include_files(Python.h HAS_PYTHON_H)
96-
check_include_files(pyconfig.h HAS_PYCONFIG_H)
97-
if(NOT HAS_PYTHON_H)
98-
message(STATUS "No Python.h header found!!")
99-
endif()
100-
if(NOT HAS_PYCONFIG_H)
101-
message(STATUS "No pyconfig.h header found!!")
58+
# libutil and libdl are needed in case only the static version of libpython is available
59+
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
60+
find_package(Util REQUIRED)
61+
if(NOT LIBUTIL_FOUND)
62+
message(STATUS "Python embedding DISABLED (libutil NOT FOUND)")
10263
endif()
103-
unset(CMAKE_REQUIRED_INCLUDES)
104-
# 3. that we can link against those libraries
105-
check_Python_compiles(pyCompiles)
106-
if(NOT pyCompiles)
107-
message(STATUS "Cannot link against Python!!")
108-
endif()
10964
endif()
110-
# Iff the answer is "YES" to all of the above, we set
111-
# EMBEDDED_PYTHON to TRUE enabling the embedded Python code
112-
if(PYTHONINTERP_FOUND AND PYTHONLIBS_FOUND
113-
AND HAS_PYTHON_H AND HAS_PYCONFIG_H AND pyCompiles)
65+
66+
find_package(DL REQUIRED)
67+
if(NOT LIBDL_FOUND)
68+
message(STATUS "Python embedding DISABLED (libdl NOT FOUND)")
69+
endif()
70+
include(ConfigPython)
71+
# We set EMBEDDED_PYTHON to TRUE enabling the embedded Python code
72+
# only if the interpreter and the headers/libraries were found
73+
if(PYTHONINTERP_FOUND AND PYTHONLIBS_FOUND)
11474
set(EMBEDDED_PYTHON TRUE)
11575
add_definitions(-DEMBEDDED_PYTHON)
76+
include_directories(SYSTEM ${PYTHON_INCLUDE_DIRS})
11677
message(STATUS "Python embedding ENABLED")
11778
else()
11879
message(STATUS "Python embedding DISABLED")
11980
message(STATUS " Dependencies not satisfied")
12081
endif()
121-
else()
82+
else(ENABLE_PYTHON_EMBEDDING)
12283
# The Python interpreter is anyway needed to run the MergeStaticLibs.py script
12384
find_package(PythonInterp 2.4 REQUIRED)
12485
message(STATUS "Python embedding DISABLED")
125-
endif()
86+
endif(ENABLE_PYTHON_EMBEDDING)
87+
12688
find_package(ZLIB REQUIRED)
89+
include_directories(SYSTEM ${ZLIB_INCLUDE_DIRS})
12790

12891
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
129-
set(CMAKE_INSTALL_PREFIX ${PROJECT_BINARY_DIR}/external)
130-
set(EXTERNAL_PROJECT_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX})
131-
set(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT ${CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT} CACHE INTERNAL "")
92+
set(CMAKE_INSTALL_PREFIX ${PROJECT_BINARY_DIR}/external)
93+
set(EXTERNAL_PROJECT_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX})
94+
set(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT ${CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT} CACHE INTERNAL "")
13295
else()
133-
set(EXTERNAL_PROJECT_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX})
134-
set(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT ${CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT} CACHE INTERNAL "")
96+
set(EXTERNAL_PROJECT_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX})
97+
set(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT ${CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT} CACHE INTERNAL "")
13598
endif()
13699

137-
# Just change the Boost version number here
138-
set(BOOSTVER 1.54.0)
139-
set(BUILD_CUSTOM_BOOST FALSE)
140-
# List all components needed (except mpi and unit_test_framework) here.
141-
# Components additionally required in PSI4: python, serialization, thread (Might be useful in the future?)
142-
# mpi and unit_test_framework will be added afterwards, if needed.
143-
list(APPEND needed_components filesystem system)
144-
set(Boost_USE_STATIC_LIBS ON)
145-
set(Boost_USE_MULTITHREADED ON)
146-
set(Boost_USE_STATIC_RUNTIME OFF)
147-
if(ENABLE_TESTS)
148-
list(APPEND needed_components unit_test_framework)
149-
find_package(Boost ${BOOSTVER} COMPONENTS "${needed_components}")
150-
else()
151-
find_package(Boost ${BOOSTVER} COMPONENTS "${needed_components}")
152-
endif()
153-
if(NOT Boost_FOUND)
154-
# Set also variables usually set by find_package
155-
message(STATUS " Build custom Boost ${BOOSTVER}")
156-
set(BUILD_CUSTOM_BOOST TRUE)
157-
set(CUSTOM_BOOST_LOCATION ${EXTERNAL_PROJECT_INSTALL_PREFIX}/boost)
158-
string(REGEX REPLACE "\\." "0" Boost_VERSION ${BOOSTVER})
159-
math(EXPR Boost_MAJOR_VERSION "${Boost_VERSION} / 100000")
160-
math(EXPR Boost_MINOR_VERSION "${Boost_VERSION} / 100 % 1000")
161-
math(EXPR Boost_SUBMINOR_VERSION "${Boost_VERSION} % 100")
162-
set(Boost_LIB_VERSION ${Boost_MAJOR_VERSION}_${Boost_MINOR_VERSION})
163-
add_subdirectory(external)
164-
set(Boost_FOUND TRUE)
165-
set(Boost_LIBRARIES "")
166-
# Read documentation in FindBoost.cmake for the difference between the singular and plural forms
167-
set(Boost_INCLUDE_DIR ${CUSTOM_BOOST_LOCATION}/include)
168-
set(Boost_INCLUDE_DIRS ${CUSTOM_BOOST_LOCATION}/include)
169-
set(Boost_LIBRARY_DIR ${CUSTOM_BOOST_LOCATION}/lib)
170-
set(Boost_LIBRARY_DIRS ${CUSTOM_BOOST_LOCATION}/lib)
171-
# We will link statically, so just set the Boost_<C>_LIBRARY for the static library
172-
foreach(_component ${needed_components})
173-
string(TOUPPER ${_component} _COMP)
174-
set(Boost_${_COMP}_FOUND TRUE)
175-
set(Boost_${_COMP}_LIBRARY libboost_${_component}-${Boost_LIB_VERSION}.a)
176-
list(APPEND Boost_LIBRARIES Boost_${_COMP}_LIBRARY)
177-
endforeach()
178-
endif()
100+
# Boost detection
101+
include(ConfigBoost)
102+
link_directories(${Boost_LIBRARY_DIRS})
103+
include_directories(SYSTEM ${Boost_INCLUDE_DIRS})
179104

180-
#
181105
# Eigen 3 stuff
182-
#
183106
if("${EIGEN3_ROOT}" STREQUAL "")
184-
if(DISABLE_EIGEN_OWN)
185-
find_package(Eigen3 3.0.0)
186-
message(STATUS "Eigen " ${EIGEN3_VERSION} " is located here: " ${EIGEN3_INCLUDE_DIR})
187-
else()
188-
set(EIGEN3_ROOT ${PROJECT_SOURCE_DIR}/external/eigen3)
189-
set(EIGEN3_INCLUDE_DIR ${EIGEN3_ROOT}/include/eigen3)
190-
install(DIRECTORY ${PROJECT_SOURCE_DIR}/external/eigen3 DESTINATION ${EXTERNAL_PROJECT_INSTALL_PREFIX}/include)
191-
message(STATUS "Eigen 3.2.0 is located here: " ${EXTERNAL_PROJECT_INSTALL_PREFIX}/include/eigen3)
192-
endif()
107+
if(DISABLE_EIGEN_OWN)
108+
find_package(Eigen3 3.0.0)
109+
message(STATUS "Eigen " ${EIGEN3_VERSION} " is located here: " ${EIGEN3_INCLUDE_DIR})
110+
else()
111+
set(EIGEN3_ROOT ${PROJECT_SOURCE_DIR}/external/eigen3)
112+
set(EIGEN3_INCLUDE_DIR ${EIGEN3_ROOT}/include/eigen3)
113+
install(DIRECTORY ${PROJECT_SOURCE_DIR}/external/eigen3 DESTINATION ${EXTERNAL_PROJECT_INSTALL_PREFIX}/include)
114+
message(STATUS "Eigen 3.2.0 is located here: " ${EXTERNAL_PROJECT_INSTALL_PREFIX}/include/eigen3)
115+
endif()
193116
else()
194-
find_package(Eigen3 3.0.0)
195-
message(STATUS "Eigen " ${EIGEN3_VERSION} " is located here: " ${EIGEN3_INCLUDE_DIR})
117+
find_package(Eigen3 3.0.0)
118+
message(STATUS "Eigen " ${EIGEN3_VERSION} " is located here: " ${EIGEN3_INCLUDE_DIR})
196119
endif()
120+
include_directories(SYSTEM ${EIGEN3_INCLUDE_DIR})
121+
197122
if(ENABLE_EIGEN_MKL)
198-
message(STATUS "ENABLE_EIGEN_MKL option requires at least Eigen 3.1.0 and Intel MKL 10.3")
199-
message(STATUS " Be sure you have read http://eigen.tuxfamily.org/dox/TopicUsingIntelMKL.html")
200-
include(ConfigMath)
201-
set(EIGEN_USE_MKL_ALL ON)
123+
message(STATUS "ENABLE_EIGEN_MKL option requires at least Eigen 3.1.0 and Intel MKL 10.3")
124+
message(STATUS " Be sure you have read http://eigen.tuxfamily.org/dox/TopicUsingIntelMKL.html")
125+
include(ConfigMath)
126+
set(EIGEN_USE_MKL_ALL ON)
202127
endif()
203128

204129
set(CMAKE_Fortran_MODULE_DIRECTORY
@@ -239,12 +164,8 @@ ExternalProject_Add(libtaylor
239164

240165
configure_files()
241166

242-
# To be includes as system headers
167+
# To be included as system headers
243168
include_directories(SYSTEM
244-
${EIGEN3_INCLUDE_DIR}
245-
${Boost_INCLUDE_DIRS}
246-
${PYTHON_INCLUDE_DIRS}
247-
${ZLIB_INCLUDE_DIRS}
248169
${PROJECT_SOURCE_DIR}/external
249170
${EXTERNAL_PROJECT_INSTALL_PREFIX}/include)
250171
# To be included as project headers
@@ -255,9 +176,7 @@ include_directories(${PROJECT_SOURCE_DIR}
255176
add_subdirectory(src)
256177
include_directories(${header_dir_list})
257178

258-
link_directories(${Boost_LIBRARY_DIRS}
259-
${PYTHON_LIBRARIES}
260-
${EXTERNAL_PROJECT_INSTALL_PREFIX}/external/lib
179+
link_directories(${EXTERNAL_PROJECT_INSTALL_PREFIX}/external/lib
261180
${EXTERNAL_PROJECT_INSTALL_PREFIX}/lib)
262181

263182
install(FILES
@@ -277,19 +196,15 @@ install(FILES
277196
DESTINATION include)
278197

279198
if(ENABLE_TESTS)
280-
include(ConfigFramework)
281-
include(TestingMacros)
282-
283-
setup_boosttest()
284-
285-
enable_testing()
286-
add_subdirectory(tests) # This must come last!!
199+
include(ConfigFramework)
200+
include(TestingMacros)
201+
202+
setup_boosttest()
203+
204+
enable_testing()
205+
add_subdirectory(tests) # This must come last!!
287206
endif()
288207

289-
# How to add a debug executable. Shouldn't be necessary, we have unit tests...
290-
#add_executable(debug_wavcav.x ${PROJECT_SOURCE_DIR}/src/debug_wavcav.cpp)
291-
#target_link_libraries(debug_wavcav.x solver green cavity wavcav pwl wem utils ${LIBS})
292-
293208
# Merge static libs from subfolders into one static lib: libpcm.a
294209
# This is the very last thing we do, i.e. DO NOT add anything depending on this target!!!
295210
merge_static_libs(pcm "${libs_to_merge}")

cmake/ConfigBoost.cmake

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Just change the Boost version number here
2+
# The version of the Boost archive we ship
3+
set(BOOSTVER 1.54.0)
4+
# The minimum required version of Boost
5+
set(BOOSTVERMIN 1.54.0)
6+
set(BUILD_CUSTOM_BOOST FALSE)
7+
# List all components needed (except mpi and unit_test_framework) here.
8+
# Components additionally required in PSI4: serialization, thread (Might be useful in the future?)
9+
# mpi and unit_test_framework will be added afterwards, if needed.
10+
if(EMBEDDED_PYTHON)
11+
list(APPEND needed_components python filesystem system)
12+
else()
13+
list(APPEND needed_components filesystem system)
14+
endif()
15+
set(Boost_USE_STATIC_LIBS ON)
16+
set(Boost_USE_MULTITHREADED ON)
17+
set(Boost_USE_STATIC_RUNTIME OFF)
18+
if(ENABLE_TESTS)
19+
list(APPEND needed_components unit_test_framework)
20+
find_package(Boost ${BOOSTVERMIN} COMPONENTS "${needed_components}")
21+
else()
22+
find_package(Boost ${BOOSTVERMIN} COMPONENTS "${needed_components}")
23+
endif()
24+
if(NOT Boost_FOUND)
25+
# Set also variables usually set by find_package
26+
message(STATUS "Boost ${BOOSTVERMIN} not found. The pre-packaged version will be built.")
27+
set(BUILD_CUSTOM_BOOST TRUE)
28+
set(CUSTOM_BOOST_LOCATION ${EXTERNAL_PROJECT_INSTALL_PREFIX}/boost)
29+
string(REGEX REPLACE "\\." "0" Boost_VERSION ${BOOSTVER})
30+
math(EXPR Boost_MAJOR_VERSION "${Boost_VERSION} / 100000")
31+
math(EXPR Boost_MINOR_VERSION "${Boost_VERSION} / 100 % 1000")
32+
math(EXPR Boost_SUBMINOR_VERSION "${Boost_VERSION} % 100")
33+
set(Boost_LIB_VERSION ${Boost_MAJOR_VERSION}_${Boost_MINOR_VERSION})
34+
add_subdirectory(external)
35+
set(Boost_FOUND TRUE)
36+
set(Boost_LIBRARIES "")
37+
# Read documentation in FindBoost.cmake for the difference between the singular and plural forms
38+
set(Boost_INCLUDE_DIR ${CUSTOM_BOOST_LOCATION}/include)
39+
set(Boost_INCLUDE_DIRS ${CUSTOM_BOOST_LOCATION}/include)
40+
set(Boost_LIBRARY_DIR ${CUSTOM_BOOST_LOCATION}/lib)
41+
set(Boost_LIBRARY_DIRS ${CUSTOM_BOOST_LOCATION}/lib)
42+
# We will link statically, so just set the Boost_<C>_LIBRARY for the static library
43+
foreach(_component ${needed_components})
44+
string(TOUPPER ${_component} _COMP)
45+
set(Boost_${_COMP}_FOUND TRUE)
46+
set(Boost_${_COMP}_LIBRARY libboost_${_component}-${Boost_LIB_VERSION}.a)
47+
list(APPEND Boost_LIBRARIES ${Boost_${_COMP}_LIBRARY})
48+
endforeach()
49+
endif()
50+
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
51+
find_package(RT)
52+
list(APPEND Boost_LIBRARIES ${LIBRT_LIBRARIES})
53+
endif()

cmake/ConfigPython.cmake

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# If the PYTHON_INTERPRETER variable is not empty, then the user passed a custom version
2+
# of the interpreter to be used. If that's the case, set PYTHON_EXECUTABLE accordingly and
3+
# proceed with detection of Python interpreter accordingly.
4+
if("${PYTHON_INTERPRETER}" STREQUAL "")
5+
find_package(PythonInterp 2.4 REQUIRED)
6+
else()
7+
set(PYTHONINTERP_FOUND TRUE)
8+
set(PYTHON_EXECUTABLE "${PYTHON_INTERPRETER}")
9+
find_package(PythonInterp 2.4 REQUIRED)
10+
endif()
11+
12+
# Now find Python libraries and headers of the EXACT SAME VERSION
13+
# Set variables to help find Python library with the EXACT SAME VERSION as the interpreter
14+
# Copied from https://bitbucket.org/fenics-project/dolfin
15+
if(PYTHONINTERP_FOUND)
16+
# Get Python include path from Python interpreter
17+
execute_process(COMMAND "${PYTHON_EXECUTABLE}" -c
18+
"import distutils.sysconfig, sys; sys.stdout.write(distutils.sysconfig.get_python_inc())"
19+
OUTPUT_VARIABLE _PYTHON_INCLUDE_PATH
20+
RESULT_VARIABLE _PYTHON_INCLUDE_RESULT)
21+
# Get Python library path from interpreter
22+
execute_process(COMMAND "${PYTHON_EXECUTABLE}" -c
23+
"import os, sys, inspect; sys.stdout.write(os.path.split(os.path.split(inspect.getfile(inspect))[0])[0])"
24+
OUTPUT_VARIABLE _PYTHON_LIB_PATH
25+
RESULT_VARIABLE _PYTHON_LIB_RESULT)
26+
# Set include path, if returned by interpreter
27+
if("${_PYTHON_INCLUDE_RESULT}" STREQUAL "0")
28+
set(PYTHON_INCLUDE_DIR ${_PYTHON_INCLUDE_PATH} CACHE PATH "Path to a file")
29+
endif()
30+
# Add a search path for Python library based on output from
31+
# interpreter
32+
set(CMAKE_LIBRARY_PATH_SAVE ${CMAKE_LIBRARY_PATH})
33+
if("${_PYTHON_LIB_RESULT}" STREQUAL "0")
34+
set(CMAKE_LIBRARY_PATH ${_PYTHON_LIB_PATH})
35+
endif()
36+
# Finally, find Python libs using the standard module
37+
find_package(PythonLibs ${PYTHON_VERSION_STRING} EXACT REQUIRED)
38+
endif()

cmake/ConfigVersion.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ if(EXISTS ${PROJECT_SOURCE_DIR}/RELEASE)
1111
set(DEVELOPMENT_CODE FALSE)
1212
else()
1313
set(DEVELOPMENT_CODE TRUE)
14+
add_definitions(-DDEVELOPMENT_CODE)
1415
add_definitions(-DWAVELET_DEVELOPMENT)
1516
add_definitions(-DTSLESS_DEVELOPMENT)
1617
endif()

0 commit comments

Comments
 (0)