diff --git a/CMakeLists.txt b/CMakeLists.txt
index 446ef8b..ed9bb21 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,150 +1,117 @@
-#
-# @file CMakeLists.txt
-#
-# @brief
-#
-# @copyright
-# Copyright (©) 2021 EPFL (Ecole Polytechnique Fédérale de Lausanne)
-# SPC (Swiss Plasma Center)
-#
-# SPClibs is free software: you can redistribute it and/or modify it under
-# the terms of the GNU Lesser General Public License as published by the Free
-# Software Foundation, either version 3 of the License, or (at your option)
-# any later version.
-#
-# SPClibs is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public License
-# along with this program. If not, see .
-#
-# @author
-# (in alphabetical order)
-# @author Nicolas Richart
-# @author Trach-Minh Tran
-#
cmake_minimum_required (VERSION 2.8.8)
#cmake_policy(SET CMP0053 NEW)
project(bsplines_root Fortran C)
#enable_language(Fortran)
enable_testing()
option(BSPLINES_USE_MUMPS "Activate the mumps interface" ON)
+option(BSPLINES_USE_LAPACK "Activate the lapack interface" ON)
+option(BSPLINES_USE_PETSC "Activate the petsc interface" ON)
+option(BSPLINES_USE_SCALAPACK "Activate the scalapack interface" ON)
+
if(NOT DEFINED BSPLINES_EXAMPLES)
option(BSPLINES_EXAMPLES "Compiles the examples" ON)
endif()
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake")
-# Assume we are on CRAY if ftn is the Fortran compiler
-if (${CMAKE_Fortran_COMPILER} MATCHES "ftn$")
- set(CRAY TRUE)
- if(${CMAKE_Fortran_COMPILER_ID} MATCHES "Cray")
- set(cray_suffix cray)
- elseif(${CMAKE_Fortran_COMPILER_ID} MATCHES "PGI")
- set(cray_suffix pgi)
- elseif(${CMAKE_Fortran_COMPILER_ID} MATCHES "Intel")
- set(cray_suffix intel)
- elseif(${CMAKE_Fortran_COMPILER_ID} MATCHES "GNU")
- set(cray_suffix gnu)
- endif()
-else()
- set(CRAY FALSE)
-endif()
-
if(POLICY CMP0074)
cmake_policy(SET CMP0074 NEW)
endif()
include(CMakeFlagsHandling)
# Compiler flags for debug/optimization
-if(${CMAKE_Fortran_COMPILER_ID} MATCHES "Cray")
-elseif(${CMAKE_Fortran_COMPILER_ID} MATCHES "Intel")
+if(${CMAKE_Fortran_COMPILER_ID} MATCHES "Intel")
set(CMAKE_AR ${XIAR})
add_flags(LANG Fortran TYPE DEBUG -traceback "-check bounds" "-warn unused")
add_flags(LANG Fortran TYPE RELEASE -xHost)
elseif(${CMAKE_Fortran_COMPILER_ID} MATCHES "GNU")
add_flags(LANG Fortran TYPE DEBUG -fbounds-check -fbacktrace)
endif()
-if(NOT MUMPS)
- set(MUMPS $ENV{MUMPS_ROOT})
-endif()
-
# Installation root directory
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(PREFIX $ENV{PREFIX})
if(PREFIX)
set(${CMAKE_INSTALL_PREFIX} ${PREFIX})
else()
set(CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_SOURCE_DIR} CACHE PATH "..." FORCE)
endif()
message(STATUS "CMAKE_INSTALL_PREFIX is " ${CMAKE_INSTALL_PREFIX})
endif()
# Search and load the FUTILS configuration file
if(NOT TARGET futils)
find_package(futils PATHS ${FUTILS}/lib/cmake REQUIRED)
endif()
if(BSPLINES_USE_MUMPS)
find_package(Mumps REQUIRED)
set(HAS_MUMPS ${MUMPS_FOUND})
else()
set(HAS_MUMPS FALSE)
endif()
+if(BSPLINES_USE_PETSC)
+ find_package(PETSc REQUIRED)
+ set(HAS_PETSC ${PETSC_FOUND})
+else()
+ set(HAS_PETSC FALSE)
+endif()
+
# Find lapack/blas. Skip it if on CRAY!
if(CRAY)
set(BSPLINES_USE_PARDISO OFF)
endif()
include(blas)
if(NOT BSPLINES_EXPORT_TARGETS)
set(BSPLINES_EXPORT_TARGETS bsplines-targets)
endif()
find_package(MPI COMPONENTS Fortran REQUIRED)
include(GNUInstallDirs)
+set(FFT_EXAMPLES ${BSPLINES_EXAMPLES})
+
add_subdirectory(pppack)
add_subdirectory(pputils2)
add_subdirectory(fft)
add_subdirectory(src)
if(HAS_MUMPS AND BSPLINES_EXAMPLES)
add_subdirectory(multigrid)
endif()
if(BSPLINES_EXAMPLES)
add_subdirectory(examples)
add_subdirectory(wk)
endif()
export(TARGETS pppack pputils2 bsplines fft
FILE "${CMAKE_BINARY_DIR}/bsplinesLibraryDepends.cmake")
export(PACKAGE bsplines)
# install configuration files
if(BSPLINES_EXPORT_TARGETS MATCHES "bsplines-targets")
install(EXPORT bsplines-targets
DESTINATION lib/cmake
)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/cmake/bsplines-config.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/cmake/bsplines-config.cmake @ONLY
)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/cmake/bsplines-config.cmake
DESTINATION lib/cmake
)
endif()
# enable packaging with CPack
include(CPack)
+
diff --git a/cmake/CMakeFlagsHandling.cmake b/cmake/CMakeFlagsHandling.cmake
index 3736b1d..4ea3c65 100644
--- a/cmake/CMakeFlagsHandling.cmake
+++ b/cmake/CMakeFlagsHandling.cmake
@@ -1,100 +1,75 @@
-#
-# @file CMakeFlagsHandling.cmake
-#
-# @brief
-#
-# @copyright
-# Copyright (©) 2021 EPFL (Ecole Polytechnique Fédérale de Lausanne)
-# SPC (Swiss Plasma Center)
-#
-# SPClibs is free software: you can redistribute it and/or modify it under
-# the terms of the GNU Lesser General Public License as published by the Free
-# Software Foundation, either version 3 of the License, or (at your option)
-# any later version.
-#
-# SPClibs is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public License
-# along with this program. If not, see .
-#
-# @author
-# (in alphabetical order)
-# @author Nicolas Richart
-#
if(_CMAKE_FLAGS_HANDLING)
return()
endif()
set(_CMAKE_FLAGS_HANDLING TRUE)
#===============================================================================
# Compilation options handling
#===============================================================================
macro(_get_flags_message lang type desc)
if(${lang} MATCHES "C.." OR ${lang} MATCHES "Fortran")
set(${desc} "Flags used by the compiler")
elseif(${lang} MATCHES ".*_LINKER")
set(${desc} "Flags used by the linker")
endif()
if(${lang} MATCHES "SHARED_LINKER")
set(${desc} "${desc} during the creation of shared libraries")
elseif(${lang} MATCHES "MODULE_LINKER")
set(${desc} "${desc} during the creation of modules")
elseif(${lang} MATCHES "STATIC_LINKER")
set(${desc} "${desc} linker during the creation of static libraries")
endif()
if(${type} MATCHES "ALL")
set(${desc} "${desc} during all build types")
else()
set(${desc} "${desc} during ${type} builds")
endif()
endmacro()
#===============================================================================
function(handle_flags)
include(CMakeParseArguments)
cmake_parse_arguments(_flags
"ADD;REMOVE" "LANG;TYPE" ""
${ARGN}
)
if(NOT _flags_LANG)
set(_flags_LANG ${FLAGS_HANDLING_DEFAULT_LANGUAGE})
endif()
set(_variable CMAKE_${_flags_LANG}_FLAGS)
if (_flags_TYPE)
set(_variable ${_variable}_${_flags_TYPE})
else()
set(_flags_TYPE "ALL")
endif()
_get_flags_message(${_flags_LANG} ${_flags_TYPE} _desc)
foreach(flag ${_flags_UNPARSED_ARGUMENTS})
if (_flags_ADD)
string(REPLACE "${flag}" "match" _temp_var "${${_variable}}")
if(NOT _temp_var MATCHES "match")
set(${_variable} "${flag} ${${_variable}}" CACHE STRING ${_desc} FORCE)
endif()
elseif(_flags_REMOVE)
string(REPLACE "${flag} " "" ${_variable} "${${_variable}}")
set(${_variable} "${${_variable}}" CACHE STRING ${_desc} FORCE)
endif()
endforeach()
endfunction()
#===============================================================================
function(add_flags)
handle_flags(ADD ${ARGN})
endfunction()
#===============================================================================
function(remove_flags)
handle_flags(REMOVE ${ARGN})
endfunction()
#===============================================================================
diff --git a/cmake/FindFFTW.cmake b/cmake/FindFFTW.cmake
index 6cd6c44..6d68c1d 100644
--- a/cmake/FindFFTW.cmake
+++ b/cmake/FindFFTW.cmake
@@ -1,46 +1,21 @@
-#
-# @file FindFFTW.cmake
-#
-# @brief
-#
-# @copyright
-# Copyright (©) 2021 EPFL (Ecole Polytechnique Fédérale de Lausanne)
-# SPC (Swiss Plasma Center)
-#
-# SPClibs is free software: you can redistribute it and/or modify it under
-# the terms of the GNU Lesser General Public License as published by the Free
-# Software Foundation, either version 3 of the License, or (at your option)
-# any later version.
-#
-# SPClibs is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public License
-# along with this program. If not, see .
-#
-# @author
-# (in alphabetical order)
-# @author Nicolas Richart
-#
if(CMAKE_C_COMPILER_ID MATCHES "Cray")
set(_cray TRUE)
endif()
# Find FFTW2
if (${_cray})
# set(FFTW_LIBRARY "-ldfftw")
set(FFTW_LIBRARY "${FFTW_DIR}/libdfftw.a")
else()
find_library(FFTW_LIBRARY NAMES fftw PATHS ${FFTW}/lib)
find_library(FFTW_LIBRARY NAMES fftw3 PATHS ${FFTW}/lib)
find_path(FFTW_INCLUDES fftw_f77.h ${FFTW}/include)
find_path(FFTW_INCLUDES fftw_f77.i ${FFTW}/include)
find_path(FFTW_INCLUDES fftw.h ${FFTW}/include)
find_path(FFTW_INCLUDES fftw3.h ${FFTW}/include)
endif()
mark_as_advanced(FFTW_LIBRARY FFTW_INCLUDES)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(FFTW DEFAULT_MSG FFTW_LIBRARY)
diff --git a/cmake/FindFFTW3.cmake b/cmake/FindFFTW3.cmake
new file mode 100644
index 0000000..e8d2fa8
--- /dev/null
+++ b/cmake/FindFFTW3.cmake
@@ -0,0 +1,157 @@
+# - Find the FFTW3 library
+#
+# Usage:
+# find_package(FFTW [REQUIRED] [QUIET] )
+#
+# It sets the following variables:
+# FFTW3_FOUND ... true if fftw is found on the system
+# FFTW3_LIBRARIES ... full path to fftw library
+# FFTW3_INCLUDES ... fftw include directory
+#
+# The following variables will be checked by the function
+# FFTW3_USE_STATIC_LIBS ... if true, only static libraries are found
+# FFTW3_ROOT ... if set, the libraries are exclusively searched
+# under this path
+# FFTW3_LIBRARY ... fftw library to use
+# FFTW3_INCLUDE_DIR ... fftw include directory
+#
+
+#If environment variable FFTWDIR is specified, it has same effect as FFTW3_ROOT
+if(NOT FFTW3_ROOT AND ENV{FFTWDIR})
+ set(FFTW3_ROOT $ENV{FFTWDIR})
+endif()
+
+set(_FFTW3_PRECISIONS "double" "float" "quad")
+set(_FFTW3_IMPLEMENTATIONS "sequential" "mpi" "openmp" "threads")
+
+if(NOT FFTW3_FIND_COMPONENTS)
+ set(FFTW3_FIND_COMPONENTS "double" "float" "quad")
+endif()
+
+set(_precisions)
+set(_implementations)
+foreach(_comp ${FFTW3_FIND_COMPONENTS})
+ list(FIND _FFTW3_PRECISIONS ${_comp} _pos)
+ if(NOT _pos EQUAL -1)
+ list(APPEND _precisions ${_comp})
+ else()
+ list(APPEND _implementations ${_comp})
+ endif()
+endforeach()
+
+if("${_implementations}" STREQUAL "")
+ set(_implementations "sequential")
+endif()
+
+#Check whether to search static or dynamic libs
+set(CMAKE_FIND_LIBRARY_SUFFIXES_SAV ${CMAKE_FIND_LIBRARY_SUFFIXES})
+
+if(${FFTW3_USE_STATIC_LIBS})
+ set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_STATIC_LIBRARY_SUFFIX})
+ set(_import_type STATIC)
+else()
+ set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_SHARED_LIBRARY_SUFFIX})
+ set(_import_type SHARED)
+endif()
+
+set(_precision_double)
+set(_precision_simple "f")
+set(_precision_quad "l")
+
+set(_needed_vars)
+foreach(_impl ${_implementations})
+ if("${_impl}" STREQUAL "sequential")
+ set(_suffix)
+ set(_namespace)
+ elseif("${_impl}" STREQUAL "openmp")
+ set(_suffix "_omp")
+ set(_namespace "::${_impl}")
+ else()
+ set(_suffix "_${_impl}")
+ set(_namespace "::${_impl}")
+ endif()
+
+ set(_include_suffix)
+ if("${_impl}" STREQUAL "mpi")
+ set(_include_suffix "-mpi")
+ endif()
+ find_path(
+ FFTW3_${_impl}_INCLUDE_DIRS
+ NAMES "fftw3${_include_suffix}.h"
+ PATHS "${FFTW_ROOT}" ENV FFTW_ROOT
+ PATH_SUFFIXES "include"
+ )
+
+ mark_as_advanced(FFTW3_${_impl}_INCLUDE_DIRS)
+
+ list(APPEND _needed_vars
+ FFTW3_${_impl}_INCLUDE_DIRS
+ FFTW3_${_impl}_LIBRARIES
+ )
+ set(FFTW3_${_impl}_LIBRARIES)
+
+ foreach(_prec ${_precisions})
+ set(_lib FFTW3_${_prec}_${_impl}_LIBRARY)
+
+ find_library(
+ ${_lib}
+ NAMES "fftw3${_precision_${_prec}}${_suffix}"
+ PATHS "${FFTW_ROOT}" ENV FFTW_ROOT
+ PATH_SUFFIXES "lib" "lib64"
+ )
+
+
+ if(${_lib})
+ list(APPEND FFTW3_${_impl}_LIBRARIES ${${_lib}})
+
+ set(FFTW3_${_prec}_FOUND TRUE)
+ set(FFTW3_${_impl}_FOUND TRUE)
+ if(NOT DEFINED _fftw_version OR NOT _fftw_version)
+ file(WRITE "${PROJECT_BINARY_DIR}/_fftw_version.c"
+ "#include
+ #include
+
+ int main() {
+ printf(\"%s\", fftw_version);
+ return 0;
+ }")
+
+ try_run(_res _compile
+ ${PROJECT_BINARY_DIR}
+ "${PROJECT_BINARY_DIR}/_fftw_version.c"
+ CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:STRING=${FFTW3_${_impl}_INCLUDE_DIRS}"
+ LINK_LIBRARIES ${${_lib}}
+ RUN_OUTPUT_VARIABLE _fftw_version
+ COMPILE_OUTPUT_VARIABLE _compile_out
+ )
+
+ if(_fftw_version)
+ string(REGEX MATCH "[0-9.]+" _fftw_version ${_fftw_version})
+ endif()
+ endif()
+ endif()
+ mark_as_advanced(FFTW3_${_prec}_${_impl}_LIBRARY)
+ endforeach()
+endforeach()
+
+if(FFTW3_sequential_INCLUDE_DIRS)
+ set(FFTW3_INCLUDE_DIRS ${FFTW3_sequential_INCLUDE_DIRS}
+ CACHE PATH "Path to the include of fftw" FORCE)
+ list(APPEND _needed_vars FFTW3_INCLUDE_DIRS)
+ mark_as_advanced(FFTW3_INCLUDE_DIRS)
+endif()
+
+if(FFTW3_sequential_LIBRARIES)
+ set(FFTW3_LIBRARIES ${FFTW3_sequential_LIBRARIES}
+ CACHE PATH "FFTW libraries" FORCE)
+ list(APPEND _needed_vars FFTW3_LIBRARIES)
+ mark_as_advanced(FFTW3_LIBRARIES)
+endif()
+
+set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES_SAV})
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(FFTW3
+ REQUIRED_VARS ${_needed_vars}
+ VERSION_VAR _fftw_version
+ HANDLE_COMPONENTS)
diff --git a/cmake/FindMETIS.cmake b/cmake/FindMETIS.cmake
index 10cc4fd..333ceff 100644
--- a/cmake/FindMETIS.cmake
+++ b/cmake/FindMETIS.cmake
@@ -1,62 +1,41 @@
-#
-# @file FindMETIS.cmake
-#
-# @brief
-#
-# @copyright
-# Copyright (©) 2021 EPFL (Ecole Polytechnique Fédérale de Lausanne)
-# SPC (Swiss Plasma Center)
-#
-# SPClibs is free software: you can redistribute it and/or modify it under
-# the terms of the GNU Lesser General Public License as published by the Free
-# Software Foundation, either version 3 of the License, or (at your option)
-# any later version.
-#
-# SPClibs is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public License
-# along with this program. If not, see .
-#
-# @author
-# (in alphabetical order)
-# @author Nicolas Richart
-#
+set(_paths "${METIS_DIR}"
+ ENV METIS_DIR
+ ENV METIS_ROOT
+ ENV METIS_HOME
+ )
+
find_path(METIS_INCLUDE_DIR metis.h
- PATHS "${METIS_DIR}"
- ENV METIS_DIR
+ PATHS ${_paths}
PATH_SUFFIXES include
)
find_library(METIS_LIBRARY NAMES metis
- PATHS "${METIS_DIR}"
- ENV METIS_DIR
+ PATHS ${_paths}
PATH_SUFFIXES lib
)
mark_as_advanced(METIS_LIBRARY METIS_INCLUDE_DIR)
#===============================================================================
include(FindPackageHandleStandardArgs)
if(CMAKE_VERSION VERSION_GREATER 2.8.12)
if(METIS_INCLUDE_DIR)
file(STRINGS ${METIS_INCLUDE_DIR}/metis.h _versions
REGEX "^#define\ +METIS_VER_(MAJOR|MINOR|SUBMINOR) .*")
foreach(_ver ${_versions})
string(REGEX MATCH "METIS_VER_(MAJOR|MINOR|SUBMINOR) *([0-9.]+)" _tmp "${_ver}")
set(_metis_${CMAKE_MATCH_1} ${CMAKE_MATCH_2})
endforeach()
set(METIS_VERSION "${_metis_MAJOR}.${_metis_MINOR}" CACHE INTERNAL "")
endif()
find_package_handle_standard_args(METIS
REQUIRED_VARS
METIS_LIBRARY
METIS_INCLUDE_DIR
VERSION_VAR
METIS_VERSION)
else()
find_package_handle_standard_args(METIS DEFAULT_MSG
METIS_LIBRARY METIS_INCLUDE_DIR)
endif()
diff --git a/cmake/FindMumps.cmake b/cmake/FindMumps.cmake
index 01b22a4..7fa4282 100644
--- a/cmake/FindMumps.cmake
+++ b/cmake/FindMumps.cmake
@@ -1,289 +1,341 @@
#===============================================================================
# @file FindMumps.cmake
#
# @author Nicolas Richart
#
# @date creation: Fri Oct 24 2014
# @date last modification: Wed Jan 13 2016
#
# @brief The find_package file for the Mumps solver
#
# @section LICENSE
#
# Copyright (©) 2015 EPFL (Ecole Polytechnique Fédérale de Lausanne) Laboratory
# (LSMS - Laboratoire de Simulation en Mécanique des Solides)
#
# Akantu is free software: you can redistribute it and/or modify it under the
# terms of the GNU Lesser General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option) any
# later version.
#
# Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
# details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with Akantu. If not, see .
#
#===============================================================================
set(_MUMPS_COMPONENTS "sequential" "parallel" "double" "float" "complex_double" "complex_float")
if(NOT Mumps_FIND_COMPONENTS)
set(Mumps_FIND_COMPONENTS "parallel" "double" "float" "complex_double" "complex_float")
endif()
#===============================================================================
enable_language(Fortran)
+option(MUMPS_FIND_PACKAGE_DEBUG "To debug the find mumps package" OFF)
+mark_as_advanced(MUMPS_FIND_PACKAGE_DEBUG)
+
+
set(MUMPS_PRECISIONS)
set(MUMPS_PLAT)
foreach(_comp ${Mumps_FIND_COMPONENTS})
if("${_comp}" STREQUAL "sequential")
set(MUMPS_PLAT _seq) #default plat on debian based distribution
endif()
if("${_comp}" STREQUAL "float")
list(APPEND MUMPS_PRECISIONS s)
endif()
if("${_comp}" STREQUAL "double")
list(APPEND MUMPS_PRECISIONS d)
endif()
if("${_comp}" STREQUAL "complex_float")
list(APPEND MUMPS_PRECISIONS c)
endif()
if("${_comp}" STREQUAL "complex_double")
list(APPEND MUMPS_PRECISIONS z)
endif()
endforeach()
if(NOT MUMPS_PRECISIONS)
set(MUMPS_PRECISIONS s d c z)
endif()
list(GET MUMPS_PRECISIONS 0 _first_precision)
string(TOUPPER "${_first_precision}" _u_first_precision)
+set(_paths "${MUMPS_DIR}" ENV MUMPS_DIR
+ "${CRAY_TPSL_PREFIX_DIR}" ENV CRAY_TPSL_PREFIX_DIR
+ "${MUMPS}" ENV MUMPS
+ "${MUMPS_HOME}" ENV MUMPS_HOME)
+
find_path(MUMPS_INCLUDE_DIR ${_first_precision}mumps_c.h
- PATHS "${MUMPS_DIR}"
- ENV MUMPS_DIR
+ PATHS ${_paths}
PATH_SUFFIXES include
)
mark_as_advanced(MUMPS_INCLUDE_DIR)
set(_mumps_required_vars)
foreach(_precision ${MUMPS_PRECISIONS})
string(TOUPPER "${_precision}" _u_precision)
find_library(MUMPS_LIBRARY_${_u_precision}MUMPS NAMES ${_precision}mumps${MUMPS_PREFIX}
- PATHS "${MUMPS_DIR}"
- ENV MUMPS_DIR
+ PATHS ${_paths}
PATH_SUFFIXES lib
)
mark_as_advanced(MUMPS_LIBRARY_${_u_precision}MUMPS)
list(APPEND _mumps_required_vars MUMPS_LIBRARY_${_u_precision}MUMPS)
list(APPEND MUMPS_LIBRARIES_ALL ${MUMPS_LIBRARY_${_u_precision}MUMPS})
endforeach()
-
+set(_try_to_run TRUE)
if(MUMPS_LIBRARY_${_u_first_precision}MUMPS MATCHES ".*${_first_precision}mumps.*${CMAKE_STATIC_LIBRARY_SUFFIX}")
# Assuming mumps was compiled as a static library
set(MUMPS_LIBRARY_TYPE STATIC CACHE INTERNAL "" FORCE)
+
if (CMAKE_Fortran_COMPILER MATCHES ".*gfortran")
set(_compiler_specific gfortran)
elseif (CMAKE_Fortran_COMPILER MATCHES ".*ifort")
set(_compiler_specific ifcore)
+ elseif (CMAKE_Fortran_COMPILER MATCHES ".*ftn")
else()
message("Compiler ${CMAKE_Fortran_COMPILER} is not known, you will probably "
- "have to add semething instead of this message to be able to test mumps "
+ "have to add something instead of this message to be able to test mumps "
"install")
endif()
else()
set(MUMPS_LIBRARY_TYPE SHARED CACHE INTERNAL "" FORCE)
endif()
function(mumps_add_dependency _pdep _libs)
string(TOUPPER ${_pdep} _u_pdep)
if(_pdep STREQUAL "mumps_common")
find_library(MUMPS_LIBRARY_COMMON mumps_common${MUMPS_PREFIX}
- PATHS "${MUMPS_DIR}"
- ENV MUMPS_DIR
+ PATHS ${_paths}
PATH_SUFFIXES lib
)
set(${_libs} ${MUMPS_LIBRARY_COMMON} PARENT_SCOPE)
mark_as_advanced(MUMPS_LIBRARY_COMMON)
elseif(_pdep STREQUAL "pord")
find_library(MUMPS_LIBRARY_PORD pord${MUMPS_PREFIX}
- PATHS "${MUMPS_DIR}"
- ENV MUMPS_DIR
+ PATHS ${_paths}
PATH_SUFFIXES lib
)
set(${_libs} ${MUMPS_LIBRARY_PORD} PARENT_SCOPE)
mark_as_advanced(MUMPS_LIBRARY_PORD)
elseif(_pdep MATCHES "Scotch")
find_package(Scotch REQUIRED ${ARGN} QUIET)
if(ARGN)
list(GET ARGN 1 _comp)
string(TOUPPER ${_comp} _u_comp)
set(${_libs} ${SCOTCH_LIBRARY_${_u_comp}} PARENT_SCOPE)
else()
set(${_libs} ${${_u_pdep}_LIBRARIES} PARENT_SCOPE)
endif()
elseif(_pdep MATCHES "MPI")
if(MUMPS_PLAT STREQUAL "_seq")
find_library(MUMPS_LIBRARY_MPISEQ mpiseq${MUMPS_PREFIX}
PATHS "${MUMPS_DIR}"
- ENV MUMPS_DIR
+ ENV MUMPS_DIR CRAY_TPSL_DIR MUMPS
PATH_SUFFIXES lib
)
set(${_libs} ${MUMPS_LIBRARY_MPISEQ} PARENT_SCOPE)
mark_as_advanced(MUMPS_LIBRARY_MPISEQ)
else()
find_package(MPI REQUIRED C Fortran QUIET)
set(${_libs} ${MPI_C_LIBRARIES} ${MPI_Fortran_LIBRARIES} PARENT_SCOPE)
endif()
else()
find_package(${_pdep} REQUIRED QUIET)
set(${_libs} ${${_u_pdep}_LIBRARIES} ${${_u_pdep}_LIBRARY} PARENT_SCOPE)
endif()
endfunction()
function(mumps_find_dependencies)
set(_libraries_all ${MUMPS_LIBRARIES_ALL})
set(_include_dirs ${MUMPS_INCLUDE_DIR})
set(_mumps_test_dir "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}")
file(READ ${CMAKE_CURRENT_LIST_DIR}/CheckFindMumps.c _output)
file(WRITE "${_mumps_test_dir}/mumps_test_code.c"
"#include <${_first_precision}mumps_c.h>
${_u_first_precision}MUMPS_STRUC_C id;
#define mumps_c ${_first_precision}mumps_c
#define Real ${_u_first_precision}MUMPS_REAL
")
if(MUMPS_PLAT STREQUAL _seq)
file(APPEND "${_mumps_test_dir}/mumps_test_code.c"
"#define MUMPS_SEQ
")
else()
file(APPEND "${_mumps_test_dir}/mumps_test_code.c"
"// #undef MUMPS_SEQ
")
find_package(MPI REQUIRED)
list(APPEND _compiler_specific ${MPI_C_LIBRARIES})
list(APPEND _include_dirs ${MPI_C_INCLUDE_PATH} ${MPI_INCLUDE_DIR})
endif()
file(APPEND "${_mumps_test_dir}/mumps_test_code.c" "${_output}")
#===============================================================================
set(_mumps_dep_symbol_BLAS ${_first_precision}gemm)
set(_mumps_dep_symbol_ScaLAPACK numroc)
set(_mumps_dep_symbol_MPI mpi_send)
set(_mumps_dep_symbol_Scotch SCOTCH_graphInit)
set(_mumps_dep_symbol_Scotch_ptscotch scotchfdgraphexit)
set(_mumps_dep_symbol_Scotch_esmumps esmumps)
set(_mumps_dep_symbol_mumps_common mumps_abort)
set(_mumps_dep_symbol_pord SPACE_ordering)
set(_mumps_dep_symbol_METIS metis_nodend)
set(_mumps_dep_symbol_ParMETIS ParMETIS_V3_NodeND)
# added for fucking macosx that cannot fail at link
set(_mumps_run_dep_symbol_mumps_common mumps_fac_descband)
set(_mumps_run_dep_symbol_MPI mpi_bcast)
set(_mumps_run_dep_symbol_ScaLAPACK idamax)
set(_mumps_dep_comp_Scotch_ptscotch COMPONENTS ptscotch)
set(_mumps_dep_comp_Scotch_esmumps COMPONENTS esmumps)
set(_mumps_potential_dependencies mumps_common pord BLAS ScaLAPACK MPI
Scotch Scotch_ptscotch Scotch_esmumps METIS ParMETIS)
#===============================================================================
+ set(_try_to_run FALSE)
+ if (APPLE)
+ set(_try_to_run TRUE)
+ endif()
+
set(_retry_try_run TRUE)
set(_retry_count 0)
# trying only as long as we add dependencies to avoid inifinte loop in case of an unkown dependency
while (_retry_try_run AND _retry_count LESS 100)
- try_run(_mumps_run _mumps_compiles "${_mumps_test_dir}" "${_mumps_test_dir}/mumps_test_code.c"
- CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:STRING=${_include_dirs}"
- LINK_LIBRARIES ${_libraries_all} ${_libraries_all} ${_compiler_specific}
- RUN_OUTPUT_VARIABLE _run
- COMPILE_OUTPUT_VARIABLE _out)
+ if(_try_to_run)
+ try_run(_mumps_run _mumps_compiles "${_mumps_test_dir}" "${_mumps_test_dir}/mumps_test_code.c"
+ CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:STRING=${_include_dirs}"
+ LINK_LIBRARIES ${_libraries_all} ${_libraries_all} ${_compiler_specific}
+ RUN_OUTPUT_VARIABLE _run
+ COMPILE_OUTPUT_VARIABLE _out)
+
+ else()
+ try_compile(_mumps_compiles "${_mumps_test_dir}" "${_mumps_test_dir}/mumps_test_code.c"
+ CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:STRING=${_include_dirs}"
+ LINK_LIBRARIES ${_libraries_all} ${_libraries_all} ${_compiler_specific}
+ OUTPUT_VARIABLE _out)
+ set(_run)
+ endif()
+
+ # Some cleaning, does not hurt the code and helps the debug
+ string(REPLACE "\n" ";" _out_per_line "${_out}")
+ set(_missing_dependencies)
+ foreach(_line ${_out_per_line})
+ string(REGEX MATCH "undefined reference.*" _match "${_line}")
+ if(_match)
+ list(APPEND _missing_dependencies "${_match}")
+ endif()
+ endforeach()
+ if(_missing_dependencies)
+ list(SORT _missing_dependencies)
+ list(REMOVE_DUPLICATES _missing_dependencies)
+ endif()
+ string(REPLACE ";" "\n " _out_ns "${_missing_dependencies}")
+ string(STRIP "${_out_ns}" _out)
+
+ if(MUMPS_FIND_PACKAGE_DEBUG AND (_out OR run))
+ if(_try_to_run)
+ message("---- FindMUMPS ---- : try_run outputs: \n${_out} \n RUN OUTPUT \n${_run}")
+ else()
+ message("---- FindMUMPS ---- : try_compile outputs: \n${_out}")
+ endif()
+ endif()
set(_retry_compile FALSE)
- #message("COMPILATION outputs: \n${_out} \n RUN OUTPUT \n${_run}")
+
if(_mumps_compiles AND NOT (_mumps_run STREQUAL "FAILED_TO_RUN"))
break()
endif()
foreach(_pdep ${_mumps_potential_dependencies})
#message("CHECKING ${_pdep}")
set(_add_pdep FALSE)
if (NOT _mumps_compiles AND
_out MATCHES "undefined reference.*${_mumps_dep_symbol_${_pdep}}")
set(_add_pdep TRUE)
#message("NEED COMPILE ${_pdep}")
elseif(_mumps_run STREQUAL "FAILED_TO_RUN" AND
DEFINED _mumps_run_dep_symbol_${_pdep} AND
_run MATCHES "${_mumps_run_dep_symbol_${_pdep}}")
set(_add_pdep TRUE)
- #message("NEED RUN ${_pdep}")
+ #message("NEED RUN ${_pdep}")
endif()
if(_add_pdep)
+ if(MUMPS_FIND_PACKAGE_DEBUG)
+ message("---- FindMUMPS ---- : mumps depends on ${_pdep}")
+ endif()
+
mumps_add_dependency(${_pdep} _libs ${_mumps_dep_comp_${_pdep}})
- #message("ADDING ${_libs}")
+ if(MUMPS_FIND_PACKAGE_DEBUG)
+ message("---- FindMUMPS ---- : adding library ${_libs}")
+ endif()
+
if(NOT _libs)
message(FATAL_ERROR "MUMPS depends on ${_pdep} but no libraries where found")
endif()
list(APPEND _libraries_all ${_libs})
set(_retry_try_run TRUE)
endif()
endforeach()
math(EXPR _retry_count "${_retry_count} + 1")
endwhile()
if(_retry_count GREATER 10)
message(FATAL_ERROR "Do not know what to do to link with mumps on your system, I give up!")
endif()
if(APPLE)
# in doubt add some stuff because mumps was perhaps badly compiled
mumps_add_dependency(pord _libs)
list(APPEND _libraries_all ${_libs})
endif()
set(MUMPS_LIBRARIES_ALL ${_libraries_all} PARENT_SCOPE)
endfunction()
mumps_find_dependencies()
set(MUMPS_LIBRARIES ${MUMPS_LIBRARIES_ALL} CACHE INTERNAL "" FORCE)
#===============================================================================
include(FindPackageHandleStandardArgs)
if(CMAKE_VERSION VERSION_GREATER 2.8.12)
if(MUMPS_INCLUDE_DIR)
file(STRINGS ${MUMPS_INCLUDE_DIR}/dmumps_c.h _versions
REGEX "^#define MUMPS_VERSION .*")
foreach(_ver ${_versions})
string(REGEX MATCH "MUMPS_VERSION *\"([0-9.]+)\"" _tmp "${_ver}")
set(_mumps_VERSION ${CMAKE_MATCH_1})
endforeach()
set(MUMPS_VERSION "${_mumps_VERSION}" CACHE INTERNAL "")
endif()
find_package_handle_standard_args(Mumps
REQUIRED_VARS ${_mumps_required_vars}
MUMPS_INCLUDE_DIR
VERSION_VAR MUMPS_VERSION
)
else()
find_package_handle_standard_args(Mumps DEFAULT_MSG
${_mumps_required_vars} MUMPS_INCLUDE_DIR)
endif()
diff --git a/cmake/FindPETSc.cmake b/cmake/FindPETSc.cmake
index 6fba281..b92823a 100644
--- a/cmake/FindPETSc.cmake
+++ b/cmake/FindPETSc.cmake
@@ -1,92 +1,84 @@
-#
-# @file FindPETSc.cmake
-#
-# @brief
-#
-# @copyright
-# Copyright (©) 2021 EPFL (Ecole Polytechnique Fédérale de Lausanne)
-# SPC (Swiss Plasma Center)
-#
-# SPClibs is free software: you can redistribute it and/or modify it under
-# the terms of the GNU Lesser General Public License as published by the Free
-# Software Foundation, either version 3 of the License, or (at your option)
-# any later version.
-#
-# SPClibs is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public License
-# along with this program. If not, see .
-#
-# @author
-# (in alphabetical order)
-# @author Nicolas Richart
-#
# - Try to find PETSc
# PETSC_FOUND - system has PETSc
# PETSC_INCLUDE_DIRS - the PETSc include directories
# PETSC_LIBRARIES - Link these to use PETSc
# PETSC_VERSION - Version string (MAJOR.MINOR.SUBMINOR)
if(PETSc_FIND_REQUIRED)
find_package(PkgConfig REQUIRED)
else()
find_package(PkgConfig QUIET)
if(NOT PKG_CONFIG_FOUND)
return()
endif()
endif()
-pkg_search_module(_petsc PETSc)
-
-# Some debug code
-#get_property(_vars DIRECTORY PROPERTY VARIABLES)
-#foreach(_var ${_vars})
-# if ("${_var}" MATCHES "^_petsc")
-# message("${_var} -> ${${_var}}")
-# endif()
-#endforeach()
-
-if(_petsc_FOUND AND _petsc_VERSION)
- set(PETSC_VERSION ${_petsc_VERSION})
-endif()
-
-if(_petsc_FOUND)
- set(_petsc_libs)
- foreach(_lib ${_petsc_LIBRARIES})
- string(TOUPPER "${_lib}" _u_lib)
- find_library(PETSC_LIBRARY_${_u_lib} ${_lib} PATHS ${_petsc_LIBRARY_DIRS})
- list(APPEND _petsc_libs ${PETSC_LIBRARY_${_u_lib}})
- mark_as_advanced(PETSC_LIBRARY_${_u_lib})
- endforeach()
-
- if (NOT _petsc_INCLUDE_DIRS)
- pkg_get_variable(_petsc_INCLUDE_DIRS ${_petsc_MODULE_NAME} includedir)
- #message(${_petsc_INCLUDE_DIRS})
- endif()
-
- find_path(PETSC_Fortran_INCLUDE_DIRS "finclude/petsc.h"
- PATHS ${_petsc_INCLUDE_DIRS}/petsc
- NO_CMAKE_PATH
- NO_DEFAULT_PATH
- )
-
- set(PETSC_LIBRARIES ${_petsc_libs} CACHE FILEPATH "")
- set(PETSC_INCLUDE_DIRS ${_petsc_INCLUDE_DIRS} CACHE PATH "")
+set(_target $ENV{PE_PETSC_PKGCONFIG_LIBS})
+if (_target)
+ # on cray machine
+ string(TOLOWER "$ENV{PE_ENV}" _pe)
+ string(REGEX MATCH "(.*)_(.*)" _out "${_target}")
+ set(_lib "${CMAKE_MATCH_1}_${_pe}_${CMAKE_MATCH_2}")
+ find_library(PETSC_LIBRARIES ${_lib}
+ PATHS "${CRAY_PETSC_PREFIX_DIR}" ENV CRAY_PETSC_PREFIX_DIR
+ PATH_SUFFIXES lib
+ NO_CMAKE_PATH
+ NO_DEFAULT_PATH)
+ find_path(PETSC_INCLUDE_DIRS "petsc.h"
+ PATHS "${CRAY_PETSC_PREFIX_DIR}" ENV CRAY_PETSC_PREFIX_DIR
+ PATH_SUFFIXES include
+ NO_CMAKE_PATH
+ NO_DEFAULT_PATH)
add_library(petsc::petsc INTERFACE IMPORTED)
set_property(TARGET petsc::petsc PROPERTY INTERFACE_LINK_LIBRARIES ${PETSC_LIBRARIES})
set_property(TARGET petsc::petsc PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${PETSC_INCLUDE_DIRS})
+else()
+ pkg_search_module(_petsc PETSc)
+
+ # Some debug code
+ # get_property(_vars DIRECTORY PROPERTY VARIABLES)
+ # foreach(_var ${_vars})
+ # if (_var MATCHES "^_petsc")
+ # message("${_var} -> ${${_var}}")
+ # endif()
+ # endforeach()
+
+ if(_petsc_FOUND AND _petsc_VERSION)
+ set(PETSC_VERSION ${_petsc_VERSION})
+ endif()
+
+ if(_petsc_FOUND)
+ set(_petsc_libs)
+ foreach(_lib ${_petsc_LIBRARIES})
+ string(TOUPPER "${_lib}" _u_lib)
+ find_library(PETSC_LIBRARY_${_u_lib} ${_lib} PATHS ${_petsc_LIBRARY_DIRS})
+ list(APPEND _petsc_libs ${PETSC_LIBRARY_${_u_lib}})
+ mark_as_advanced(PETSC_LIBRARY_${_u_lib})
+ endforeach()
+
+ if (NOT _petsc_INCLUDE_DIRS)
+ pkg_get_variable(_petsc_INCLUDE_DIRS ${_petsc_MODULE_NAME} includedir)
+ endif()
- add_library(petsc::petscf INTERFACE IMPORTED)
- target_link_libraries(petsc::petscf INTERFACE petsc::petsc)
- set_property(TARGET petsc::petscf PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${PETSC_Fortran_INCLUDE_DIRS})
-
+ set(_include_dirs)
+ foreach (_path ${_petsc_INCLUDE_DIRS})
+ if(EXISTS ${_path})
+ list(APPEND _include_dirs ${_path})
+ endif()
+ endforeach()
+
+ set(PETSC_LIBRARIES ${_petsc_libs} CACHE FILEPATH "")
+ set(PETSC_INCLUDE_DIRS ${_include_dirs} CACHE PATH "")
+
+ add_library(petsc::petsc INTERFACE IMPORTED)
+ set_property(TARGET petsc::petsc PROPERTY INTERFACE_LINK_LIBRARIES ${PETSC_LIBRARIES})
+ set_property(TARGET petsc::petsc PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${PETSC_INCLUDE_DIRS})
+ endif()
endif()
include (FindPackageHandleStandardArgs)
find_package_handle_standard_args(PETSc
REQUIRED_VARS PETSC_LIBRARIES PETSC_INCLUDE_DIRS
VERSION_VAR PETSC_VERSION)
diff --git a/cmake/FindParMETIS.cmake b/cmake/FindParMETIS.cmake
index f5c8da8..69d2021 100644
--- a/cmake/FindParMETIS.cmake
+++ b/cmake/FindParMETIS.cmake
@@ -1,62 +1,41 @@
-#
-# @file FindParMETIS.cmake
-#
-# @brief
-#
-# @copyright
-# Copyright (©) 2021 EPFL (Ecole Polytechnique Fédérale de Lausanne)
-# SPC (Swiss Plasma Center)
-#
-# SPClibs is free software: you can redistribute it and/or modify it under
-# the terms of the GNU Lesser General Public License as published by the Free
-# Software Foundation, either version 3 of the License, or (at your option)
-# any later version.
-#
-# SPClibs is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public License
-# along with this program. If not, see .
-#
-# @author
-# (in alphabetical order)
-# @author Nicolas Richart
-#
+set(_paths "${PARMETIS_DIR}"
+ ENV PARMETIS_DIR
+ ENV PARTMETIS_ROOT
+ ENV PARMETIS_HOME
+ )
+
find_path(PARMETIS_INCLUDE_DIR parmetis.h
- PATHS "${PARMETIS_DIR}"
- ENV PARMETIS_DIR
+ PATHS ${_paths}
PATH_SUFFIXES include
)
find_library(PARMETIS_LIBRARY NAMES parmetis
- PATHS "${PARMETIS_DIR}"
- ENV PARMETIS_DIR
+ PATHS ${_paths}
PATH_SUFFIXES lib
)
mark_as_advanced(PARMETIS_LIBRARY PARMETIS_INCLUDE_DIR)
#===============================================================================
include(FindPackageHandleStandardArgs)
if(CMAKE_VERSION VERSION_GREATER 2.8.12)
if(PARMETIS_INCLUDE_DIR)
file(STRINGS ${PARMETIS_INCLUDE_DIR}/parmetis.h _versions
REGEX "^#define\ +PARMETIS_(MAJOR|MINOR|SUBMINOR)_VERSION .*")
foreach(_ver ${_versions})
string(REGEX MATCH "PARMETIS_(MAJOR|MINOR|SUBMINOR)_VERSION *([0-9.]+)" _tmp "${_ver}")
set(_parmetis_${CMAKE_MATCH_1} ${CMAKE_MATCH_2})
endforeach()
set(PARMETIS_VERSION "${_parmetis_MAJOR}.${_parmetis_MINOR}" CACHE INTERNAL "")
endif()
find_package_handle_standard_args(ParMETIS
REQUIRED_VARS
PARMETIS_LIBRARY
PARMETIS_INCLUDE_DIR
VERSION_VAR
PARMETIS_VERSION)
else()
find_package_handle_standard_args(ParMETIS DEFAULT_MSG
PARMETIS_LIBRARY PARMETIS_INCLUDE_DIR)
endif()
diff --git a/cmake/FindScaLAPACK.cmake b/cmake/FindScaLAPACK.cmake
index b695ed9..f34df56 100644
--- a/cmake/FindScaLAPACK.cmake
+++ b/cmake/FindScaLAPACK.cmake
@@ -1,156 +1,157 @@
#===============================================================================
# @file FindScaLAPACK.cmake
#
# @author Nicolas Richart
#
# @date creation: Tue Mar 31 2015
# @date last modification: Wed Jan 13 2016
#
# @brief The find_package file for the Mumps solver
#
# @section LICENSE
#
# Copyright (©) 2015 EPFL (Ecole Polytechnique Fédérale de Lausanne) Laboratory
# (LSMS - Laboratoire de Simulation en Mécanique des Solides)
#
# Akantu is free software: you can redistribute it and/or modify it under the
# terms of the GNU Lesser General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option) any
# later version.
#
# Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
# details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with Akantu. If not, see .
#
#===============================================================================
set(SCALAPACK_VENDOR "Auto" CACHE
STRING "Vendor for scalapack (Auto, Netlib, Intel_(i?)lp64_(openmpi|intelmpi|sgimpt)")
mark_as_advanced(SCALAPACK_VENDOR)
set_property(CACHE SCALAPACK_VENDOR PROPERTY STRINGS
Auto Netlib
Intel_lp64_openmpi Intel_lp64_intelmpi Intel_lp64_sgimpt
Intel_ilp64_openmpi Intel_ilp64_intelmpi Intel_ilp64_sgimpt)
macro(scalapack_find_library prefix target name list_libraries list_headers)
foreach(_lib ${list_libraries})
find_library(${prefix}_${_lib}_LIBRARY NAMES ${_lib}
- PATHS ${prefix}_DIR
+ PATHS "${prefix}_DIR" ENV ${prefix}_DIR
+ "${prefix}_HOME" ENV ${prefix}_HOME
+ "${prefix}_ROOT" ENV ${prefix}_ROOT
)
mark_as_advanced(${prefix}_${_lib}_LIBRARY)
if(${prefix}_${_lib}_LIBRARY)
list(APPEND ${prefix}_libraries ${${prefix}_${_lib}_LIBRARY})
get_filename_component(_ext ${${prefix}_${_lib}_LIBRARY} EXT)
if(NOT TARGET ${target})
if("${_ext}" STREQUAL "${CMAKE_SHARED_LIBRARY_SUFFIX}")
add_library(${target} SHARED IMPORTED)
get_filename_component(_soname ${${prefix}_${_lib}_LIBRARY} NAME)
set_property(TARGET ${target} PROPERTY IMPORTED_SONAME ${_soname})
else()
add_library(${target}_${name} STATIC IMPORTED)
endif()
set_property(TARGET ${target} PROPERTY
IMPORTED_LOCATION ${${prefix}_${_lib}_LIBRARY})
else()
if("${_ext}" STREQUAL "${CMAKE_SHARED_LIBRARY_SUFFIX}")
set_property(TARGET ${target} APPEND PROPERTY
IMPORTED_LINK_DEPENDENT_LIBRARIES ${${prefix}_${_lib}_LIBRARY}
)
else()
set_property(TARGET ${target} APPEND PROPERTY
IMPORTED_LINK_INTERFACE_LIBRARIES ${${prefix}_${_lib}_LIBRARY}
)
endif()
endif()
else()
unset(${prefix}_${_lib}_LIBRARY CACHE)
endif()
endforeach()
if(${prefix}_libraries)
foreach(_hdr ${list_headers})
get_filename_component(_hdr_name ${_hdr} NAME_WE)
find_path(${prefix}_${_hdr_name}_INCLUDE_DIR NAMES ${_hdr}
PATHS ${prefix}_DIR)
mark_as_advanced(${prefix}_${_hdr_name}_INCLUDE_DIR)
if(${prefix}_${_hdr_name}_INCLUDE_DIR)
list(APPEND ${prefix}_include_dir ${${prefix}_${_hdr_name}_INCLUDE_DIR})
set_property(TARGET ${target} APPEND PROPERTY
INTERFACE_INCLUDE_DIRECTORIES ${${prefix}_${_lib}_INCLUDE_DIR}
)
else()
unset(${prefix}_${_lib}_INCLUDE_DIR CACHE)
endif()
endforeach()
endif()
endmacro()
set(SCALAPACK_libraries)
set(SCALAPACK_INCLUDE_DIR)
if(SCALAPACK_VENDOR STREQUAL "Auto" OR SCALAPACK_VENDOR STREQUAL "Netlib")
if(NOT SCALAPACK_libraries)
scalapack_find_library(
SCALAPACK
ScaLAPACK
"netlib"
"scalapack;blacsC;blacsF77;blacs"
""
)
endif()
endif()
foreach(_precision lp64 ilp64)
foreach(_mpi intelmpi openmpi sgimpt)
if(NOT SCALAPACK_libraries)
if(SCALAPACK_VENDOR STREQUAL "Auto" OR SCALAPACK_VENDOR STREQUAL "Intel_${_precision}_${_mpi}")
- if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
- set(_mkl_common "mkl_intel_${_precision}")
+ if(CMAKE_C_COMPILER_ID STREQUAL "Intel")
+ set(_mkl_common "mkl_intel_${_precision}")
+ else()
+ set(_mkl_common "mkl_gf_${_precision}")
+ endif()
+ scalapack_find_library(
+ SCALAPACK
+ ScaLAPACK
+ "intel_${_precision}_${_mpi}"
+ "mkl_scalapack_${_precision};${_mkl_common};mkl_core;mkl_blacs_${_mpi}_${_precision}"
+ "mkl_scalapack.h"
+ )
- else()
- set(_mkl_common "mkl_gf_${_precision}")
- endif()
- scalapack_find_library(
- SCALAPACK
- ScaLAPACK
- "intel_${_precision}_${_mpi}"
- "mkl_scalapack_${_precision};${_mkl_common};mkl_sequential;mkl_core;mkl_blacs_${_mpi}_${_precision}"
- "mkl_scalapack.h"
- )
-
- if(SCALAPACK_libraries AND _precision STREQUAL "ilp64")
- set_property(TARGET ${target} APPEND PROPERTY
- INTERFACE_COMPILE_DEFINITIONS MKL_ILP64}
- )
- endif()
+ if(SCALAPACK_libraries AND _precision STREQUAL "ilp64")
+ set_property(TARGET ${target} APPEND PROPERTY
+ INTERFACE_COMPILE_DEFINITIONS MKL_ILP64}
+ )
+ endif()
- if(EXISTS ${SCALAPACK_include_dir}/mkl_version.h)
- file(STRINGS ${SCALAPACK_include_dir}/mkl_version.h _versions
- REGEX "^#define\ +__INTEL_MKL(_MINOR|_UPDATE)?__ .*")
- foreach(_ver ${_versions})
- string(REGEX MATCH "__INTEL_MKL(_MINOR|_UPDATE)?__ *([0-9.]+)" _tmp "${_ver}")
- set(_mkl${CMAKE_MATCH_1} ${CMAKE_MATCH_2})
- endforeach()
- set(SCALAPACK_VERSION "mkl:${_mkl}.${_mkl_MINOR}.${_mkl_UPDATE}" CACHE INTERNAL "")
- endif()
+ if(EXISTS ${SCALAPACK_include_dir}/mkl_version.h)
+ file(STRINGS ${SCALAPACK_include_dir}/mkl_version.h _versions
+ REGEX "^#define\ +__INTEL_MKL(_MINOR|_UPDATE)?__ .*")
+ foreach(_ver ${_versions})
+ string(REGEX MATCH "__INTEL_MKL(_MINOR|_UPDATE)?__ *([0-9.]+)" _tmp "${_ver}")
+ set(_mkl${CMAKE_MATCH_1} ${CMAKE_MATCH_2})
+ endforeach()
+ set(SCALAPACK_VERSION "mkl:${_mkl}.${_mkl_MINOR}.${_mkl_UPDATE}" CACHE INTERNAL "")
+ endif()
endif()
endif()
endforeach()
endforeach()
set(SCALAPACK_LIBRARIES ${SCALAPACK_libraries} CACHE INTERNAL "")
set(SCALAPACK_INCLUDE_DIR ${SCALAPACK_include_dir} CACHE INTERNAL "")
#===============================================================================
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(ScaLAPACK
REQUIRED_VARS SCALAPACK_LIBRARIES
VERSION_VAR SCALAPACK_VERSION)
diff --git a/cmake/FindScotch.cmake b/cmake/FindScotch.cmake
index c931764..15beb0d 100644
--- a/cmake/FindScotch.cmake
+++ b/cmake/FindScotch.cmake
@@ -1,245 +1,250 @@
#===============================================================================
# @file FindScotch.cmake
#
# @author Nicolas Richart
#
# @date creation: Fri Oct 24 2014
# @date last modification: Wed Jan 13 2016
#
# @brief The find_package file for Scotch
#
# @section LICENSE
#
# Copyright (©) 2015 EPFL (Ecole Polytechnique Fédérale de Lausanne) Laboratory
# (LSMS - Laboratoire de Simulation en Mécanique des Solides)
#
# Akantu is free software: you can redistribute it and/or modify it under the
# terms of the GNU Lesser General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option) any
# later version.
#
# Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
# details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with Akantu. If not, see .
#
#===============================================================================
set(_SCOTCH_COMPONENTS "metis" "parmetis" "esmumps" "ptscotch")
if(NOT Scotch_FIND_COMPONENTS)
set(Scotch_FIND_COMPONENTS)
endif()
-find_path(SCOTCH_INCLUDE_DIR scotch.h PATHS "${SCOTCH_DIR}" ENV SCOTCH_DIR
+find_path(SCOTCH_INCLUDE_DIR scotch.h
+ PATHS "${SCOTCH_DIR}"
+ ENV SCOTCH_DIR CRAY_TPSL_DIR
PATH_SUFFIXES include include/scotch
)
-find_library(SCOTCH_LIBRARY scotch PATHS "${SCOTCH_DIR}" ENV SCOTCH_DIR PATH_SUFFIXES lib)
+find_library(SCOTCH_LIBRARY scotch
+ PATHS "${SCOTCH_DIR}"
+ ENV SCOTCH_DIR CRAY_TPSL_DIR
+ PATH_SUFFIXES lib)
set(_scotch_test_dir "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}")
file(WRITE "${_scotch_test_dir}/scotch_test_code.c"
"#include
#include
#include
int main() {
SCOTCH_Graph graph;
SCOTCH_graphInit(&graph);
return 0;
}
")
#===============================================================================
include(FindPackageHandleStandardArgs)
if(CMAKE_VERSION VERSION_GREATER 2.8.12)
if(SCOTCH_INCLUDE_DIR)
file(STRINGS ${SCOTCH_INCLUDE_DIR}/scotch.h _versions
REGEX "^#define\ +SCOTCH_(VERSION|RELEASE|PATCHLEVEL) .*")
foreach(_ver ${_versions})
string(REGEX MATCH "SCOTCH_(VERSION|RELEASE|PATCHLEVEL) *([0-9.]+)" _tmp "${_ver}")
set(_scotch_${CMAKE_MATCH_1} ${CMAKE_MATCH_2})
endforeach()
set(SCOTCH_VERSION "${_scotch_VERSION}.${_scotch_RELEASE}.${_scotch_PATCHLEVEL}" CACHE INTERNAL "")
endif()
find_package_handle_standard_args(Scotch
REQUIRED_VARS SCOTCH_LIBRARY SCOTCH_INCLUDE_DIR
VERSION_VAR SCOTCH_VERSION)
else()
find_package_handle_standard_args(Scotch DEFAULT_MSG
SCOTCH_LIBRARY SCOTCH_INCLUDE_DIR)
endif()
set(SCOTCH_LIBRARIES_ALL ${SCOTCH_LIBRARY})
try_compile(_scotch_compiles "${_scotch_test_dir}" SOURCES "${_scotch_test_dir}/scotch_test_code.c"
CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:STRING=${SCOTCH_INCLUDE_DIR}"
LINK_LIBRARIES ${SCOTCH_LIBRARY}
OUTPUT_VARIABLE _out)
get_filename_component(_scotch_hint "${SCOTCH_LIBRARY}" DIRECTORY)
if(SCOTCH_LIBRARY MATCHES ".*scotch.*${CMAKE_STATIC_LIBRARY_SUFFIX}")
# Assuming scotch was compiled as a static library
set(SCOTCH_LIBRARY_TYPE STATIC CACHE INTERNAL "" FORCE)
else()
set(SCOTCH_LIBRARY_TYPE SHARED CACHE INTERNAL "" FORCE)
endif()
if(NOT _scotch_compiles)
if(_out MATCHES "SCOTCH_errorPrint")
find_library(SCOTCH_LIBRARY_ERR scotcherr
HINTS ${_scotch_hint})
find_library(SCOTCH_LIBRARY_ERREXIT scotcherrexit
HINTS ${_scotch_hint})
if(NOT TARGET Scotch::err)
add_library(Scotch::err ${SCOTCH_LIBRARY_TYPE} IMPORTED GLOBAL)
endif()
if(NOT TARGET Scotch::errexit)
add_library(Scotch::errexit ${SCOTCH_LIBRARY_TYPE} IMPORTED GLOBAL)
endif()
set_target_properties(Scotch::errexit PROPERTIES
IMPORTED_LOCATION "${SCOTCH_LIBRARY_ERREXIT}"
INTERFACE_INCLUDE_DIRECTORIES "${SCOTCH_INCLUDE_DIR}"
IMPORTED_LINK_INTERFACE_LANGUAGES "C")
set_target_properties(Scotch::err PROPERTIES
IMPORTED_LOCATION "${SCOTCH_LIBRARY_ERR}"
INTERFACE_INCLUDE_DIRECTORIES "${SCOTCH_INCLUDE_DIR}"
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
INTERFACE_LINK_LIBRARIES "Scotch::errexit")
mark_as_advanced(SCOTCH_LIBRARY_ERR
SCOTCH_LIBRARY_ERREXIT)
list(APPEND SCOTCH_LIBRARIES_ALL ${SCOTCH_LIBRARY_ERR} ${SCOTCH_LIBRARY_ERREXIT})
set(_scotch_link_lib INTERFACE_LINK_LIBRARIES "Scotch::err")
endif()
endif()
if(NOT TARGET Scotch::scotch)
add_library(Scotch::scotch ${SCOTCH_LIBRARY_TYPE} IMPORTED GLOBAL)
endif()
set_target_properties(Scotch::scotch PROPERTIES
IMPORTED_LOCATION "${SCOTCH_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${SCOTCH_INCLUDE_DIR}"
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
${_scotch_link_lib})
set(SCOTCH_LIBRARIES ${SCOTCH_LIBRARIES_ALL} CACHE INTERNAL "Libraries for Scotch" FORCE)
mark_as_advanced(SCOTCH_LIBRARY
SCOTCH_INCLUDE_DIR
SCOTCH_LIBRARIES)
if("${Scotch_FIND_COMPONENTS}" MATCHES "esmumps")
find_library(SCOTCH_LIBRARY_ESMUMPS esmumps HINTS ${_scotch_hint})
if(NOT TARGET Scotch::esmumps)
add_library(Scotch::esmumps ${SCOTCH_LIBRARY_TYPE} IMPORTED GLOBAL)
endif()
set_target_properties(Scotch::esmumps PROPERTIES
IMPORTED_LOCATION "${SCOTCH_LIBRARY_ESMUMPS}"
INTERFACE_INCLUDE_DIRECTORIES "${SCOTCH_INCLUDE_DIR}"
IMPORTED_LINK_INTERFACE_LANGUAGES "C")
mark_as_advanced(SCOTCH_LIBRARY_ESMUMPS)
endif()
if("${Scotch_FIND_COMPONENTS}" MATCHES "metis")
find_library(SCOTCH_LIBRARY_METIS scotchmetis HINTS ${_scotch_hint})
if(NOT TARGET Scotch::metis)
add_library(Scotch::metis ${SCOTCH_LIBRARY_TYPE} IMPORTED GLOBAL)
endif()
set_target_properties(Scotch::metis PROPERTIES
IMPORTED_LOCATION "${SCOTCH_LIBRARY_METIS}"
INTERFACE_INCLUDE_DIRECTORIES "${SCOTCH_INCLUDE_DIR}"
IMPORTED_LINK_INTERFACE_LANGUAGES "C")
mark_as_advanced(SCOTCH_LIBRARY_METIS)
endif()
if("${Scotch_FIND_COMPONENTS}" MATCHES "parmetis")
find_library(SCOTCH_LIBRARY_PARMETIS scotchparmetis HINTS ${_scotch_hint})
if(NOT TARGET Scotch::parmetis)
add_library(Scotch::parmetis ${SCOTCH_LIBRARY_TYPE} IMPORTED GLOBAL)
endif()
set_target_properties(Scotch::parmetis PROPERTIES
IMPORTED_LOCATION "${SCOTCH_LIBRARY_PARMETIS}"
INTERFACE_INCLUDE_DIRECTORIES "${SCOTCH_INCLUDE_DIR}"
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
INTERFACE_INCLUDE_DIRECTORIES "Scotch::metis")
mark_as_advanced(SCOTCH_LIBRARY_PARMETIS)
endif()
#
##===============================================================================
if("${Scotch_FIND_COMPONENTS}" MATCHES "ptscotch")
file(WRITE "${_scotch_test_dir}/ptscotch_test_code.c"
"#include
#include
#include
#include
int main() {
SCOTCH_Dgraph graph;
SCOTCH_dgraphInit(&graph, MPI_COMM_WORLD);
return 0;
}
")
find_package(MPI REQUIRED)
find_library(SCOTCH_LIBRARY_PTSCOTCH ptscotch HINTS ${_scotch_hint})
try_compile(_scotch_compiles "${_scotch_test_dir}" SOURCES "${_scotch_test_dir}/ptscotch_test_code.c"
CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:STRING=${SCOTCH_INCLUDE_DIR};${MPI_C_INCLUDE_PATH}"
LINK_LIBRARIES ${SCOTCH_LIBRARY_PTSCOTCH} ${MPI_C_LIBRARIES}
OUTPUT_VARIABLE _out)
if(NOT _scotch_compiles)
if(_out MATCHES "SCOTCH_archExit")
set(_scotch_link_lib INTERFACE_LINK_LIBRARIES "Scotch::scotch")
endif()
endif()
if(NOT TARGET Scotch::ptscotch)
add_library(Scotch::ptscotch ${SCOTCH_LIBRARY_TYPE} IMPORTED GLOBAL)
endif()
set_target_properties(Scotch::ptscotch PROPERTIES
IMPORTED_LOCATION "${SCOTCH_LIBRARY_PTSCOTCH}"
INTERFACE_INCLUDE_DIRECTORIES "${SCOTCH_INCLUDE_DIR}"
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
${_scotch_link_lib})
set(PTSCOTCH_LIBRARIES ${SCOTCH_LIBRARY_PTSCOTCH} ${SCOTCH_LIBRARIES} CACHE INTERNAL "Libraries for PT-Scotch" FORCE)
mark_as_advanced(SCOTCH_LIBRARY_PTSCOTCH
PTSCOTCH_LIBRARIES)
if("${Scotch_FIND_COMPONENTS}" MATCHES "esmumps")
find_library(SCOTCH_LIBRARY_PTESMUMPS ptesmumps
HINTS ${_scotch_hint} PATH_SUFFIXES lib .)
if(NOT TARGET Scotch::ptesmumps)
add_library(Scotch::ptesmumps ${SCOTCH_LIBRARY_TYPE} IMPORTED GLOBAL)
endif()
set_target_properties(Scotch::ptesmumps PROPERTIES
IMPORTED_LOCATION "${SCOTCH_LIBRARY_ESMUMPS}"
INTERFACE_INCLUDE_DIRECTORIES "${SCOTCH_INCLUDE_DIR}"
IMPORTED_LINK_INTERFACE_LANGUAGES "C")
mark_as_advanced(SCOTCH_LIBRARY_PTESMUMPS)
endif()
endif()
diff --git a/cmake/blas.cmake b/cmake/blas.cmake
index 5aeb667..28947d5 100644
--- a/cmake/blas.cmake
+++ b/cmake/blas.cmake
@@ -1,63 +1,54 @@
-#
-# @file blas.cmake
-#
-# @brief
-#
-# @copyright
-# Copyright (©) 2021 EPFL (Ecole Polytechnique Fédérale de Lausanne)
-# SPC (Swiss Plasma Center)
-#
-# SPClibs is free software: you can redistribute it and/or modify it under
-# the terms of the GNU Lesser General Public License as published by the Free
-# Software Foundation, either version 3 of the License, or (at your option)
-# any later version.
-#
-# SPClibs is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public License
-# along with this program. If not, see .
-#
-# @author
-# (in alphabetical order)
-# @author Nicolas Richart
-#
set(_default_blas $ENV{BLA_VENDOR})
if(NOT _default_blas)
set(_default_blas All)
endif()
set(BSPLINES_USE_BLAS_VENDOR "${_default_blas}" CACHE STRING "Version of blas to use")
mark_as_advanced(BSPLINES_USE_BLAS_VENDOR)
set_property(CACHE BSPLINES_USE_BLAS_VENDOR PROPERTY STRINGS
All
ACML
ACML_GPU
ACML_MP
ATLAS
Apple
CXML
DXML
Generic
Goto
IBMESSL
Intel
Intel10_32
Intel10_64lp
Intel10_64lp_seq
NAS
OpenBLAS
PhiPACK
SCSL
SGIMATH
SunPerf
)
if(BSPLINES_USE_PARDISO)
set(BSPLINES_USE_BLAS_VENDOR Intel10_64lp CACHE STRING "" INTERNAL)
endif()
set(ENV{BLA_VENDOR} ${BSPLINES_USE_BLAS_VENDOR})
+set(BLA_VENDOR ${BSPLINES_USE_BLAS_VENDOR})
+
+if (BSPLINES_USE_LAPACK)
+ if (BSPLINES_USE_BLAS_VENDOR MATCHES "Intel.*")
+ set(BLA_STATIC ON)
+ endif()
+endif()
find_package(BLAS REQUIRED)
-find_package(LAPACK REQUIRED)
+
+set(CRAY FALSE)
+# this is a bit hacky
+if(CMAKE_SYSTEM_NAME STREQUAL "CrayLinuxEnvironment" OR __craylinux_crayprgenv)
+ set(CRAY TRUE)
+endif()
+
+if(BSPLINES_USE_LAPACK AND NOT CRAY)
+ find_package(LAPACK REQUIRED)
+endif()
diff --git a/fft/CMakeLists.txt b/fft/CMakeLists.txt
index 7987c42..1165a36 100644
--- a/fft/CMakeLists.txt
+++ b/fft/CMakeLists.txt
@@ -1,69 +1,39 @@
-#
-# @file CMakeLists.txt
-#
-# @brief Principal CMake configuration file for the fft library
-#
-# @copyright
-# Copyright (©) 2021 EPFL (Ecole Polytechnique Fédérale de Lausanne)
-# SPC (Swiss Plasma Center)
-#
-# SPClibs is free software: you can redistribute it and/or modify it under
-# the terms of the GNU Lesser General Public License as published by the Free
-# Software Foundation, either version 3 of the License, or (at your option)
-# any later version.
-#
-# SPClibs is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public License
-# along with this program. If not, see .
-#
-# @author
-# (in alphabetical order)
-# @author Nicolas Richart
-# @author Trach-Minh Tran
-#
project(fft)
-find_package(FFTW REQUIRED)
-set(fft_w $ENV{fft_w})
+find_package(FFTW3 REQUIRED)
set(SRCS
fft_fftw.F90
)
-set(EXAMPLES tfft.f90)
+if(NOT DEFINED FFT_EXAMPLES)
+ option(FFT_EXAMPLES "Compiles the examples" ON)
+endif()
-add_library(fft STATIC ${SRCS})
+add_library(fft ${SRCS})
target_include_directories(fft
PRIVATE $
- ${FFTW_INCLUDES}
+ ${FFTW3_INCLUDE_DIRS}
INTERFACE $
$
- ${FFTW_INCLUDES}
+ ${FFTW3_INCLUDE_DIRS}
)
-if (${fft_w} MATCHES "fft_w2")
- target_compile_options(fft PRIVATE "-Dfft_w2")
-else()
- target_compile_options(fft PRIVATE "-Dfft_w3")
-endif()
+target_compile_options(fft PRIVATE "-Dfft_w3")
+target_link_libraries(fft PUBLIC ${FFTW3_LIBRARIES} ${MPI_Fortran_LIBRARIES})
-target_link_libraries(fft PUBLIC ${FFTW_LIBRARY} ${MPI_Fortran_LIBRARIES})
-#
set_property(TARGET fft
PROPERTY PUBLIC_HEADER ${CMAKE_CURRENT_BINARY_DIR}/modules/fft.mod)
-add_executable(tfft tfft.f90)
-target_link_libraries(tfft fft ${MPI_Fortran_LIBRARIES})
-
-#add_test(tfft ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} 1
-# ${CMAKE_CURRENT_BINARY_DIR}/tfft < ${fft_SOURCE_DIR}/in)
+if(FFT_EXAMPLES)
+ set(EXAMPLES tfft.f90)
+ add_executable(tfft tfft.f90)
+ target_link_libraries(tfft fft ${MPI_Fortran_LIBRARIES})
+endif()
install(TARGETS fft
EXPORT ${BSPLINES_EXPORT_TARGETS}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
diff --git a/pppack/CMakeLists.txt b/pppack/CMakeLists.txt
index 8dad83f..11308a1 100644
--- a/pppack/CMakeLists.txt
+++ b/pppack/CMakeLists.txt
@@ -1,37 +1,11 @@
-#
-# @file CMakeLists.txt
-#
-# @brief
-#
-# @copyright
-# Copyright (©) 2021 EPFL (Ecole Polytechnique Fédérale de Lausanne)
-# SPC (Swiss Plasma Center)
-#
-# SPClibs is free software: you can redistribute it and/or modify it under
-# the terms of the GNU Lesser General Public License as published by the Free
-# Software Foundation, either version 3 of the License, or (at your option)
-# any later version.
-#
-# SPClibs is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public License
-# along with this program. If not, see .
-#
-# @author
-# (in alphabetical order)
-# @author Nicolas Richart
-# @author Trach-Minh Tran
-#
set(SRCS
bvalue.f90
interv.f90
)
-add_library(pppack STATIC ${SRCS})
+add_library(pppack ${SRCS})
install(TARGETS pppack
EXPORT ${BSPLINES_EXPORT_TARGETS}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
diff --git a/pputils2/CMakeLists.txt b/pputils2/CMakeLists.txt
index ce71903..0315904 100644
--- a/pputils2/CMakeLists.txt
+++ b/pputils2/CMakeLists.txt
@@ -1,74 +1,48 @@
-#
-# @file CMakeLists.txt
-#
-# @brief
-#
-# @copyright
-# Copyright (©) 2021 EPFL (Ecole Polytechnique Fédérale de Lausanne)
-# SPC (Swiss Plasma Center)
-#
-# SPClibs is free software: you can redistribute it and/or modify it under
-# the terms of the GNU Lesser General Public License as published by the Free
-# Software Foundation, either version 3 of the License, or (at your option)
-# any later version.
-#
-# SPClibs is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public License
-# along with this program. If not, see .
-#
-# @author
-# (in alphabetical order)
-# @author Nicolas Richart
-# @author Trach-Minh Tran
-#
project(pputils2)
set(SRCS
pputils2.f90
)
set(CMAKE_Fortran_MODULE_DIRECTORY
${CMAKE_CURRENT_BINARY_DIR}/modules
)
-add_library(pputils2 STATIC ${SRCS})
+add_library(pputils2 ${SRCS})
target_include_directories(pputils2
PRIVATE $
${MPI_Fortran_INCLUDE_PATH}
INTERFACE $
$
${MPI_Fortran_INCLUDE_PATH}
)
target_compile_options(pputils2 PUBLIC ${MPI_Fortran_COMPILE_FLAGS})
target_link_libraries(pputils2 PUBLIC ${MPI_Fortran_LIBRARIES})
set_property(TARGET pputils2
PROPERTY PUBLIC_HEADER ${CMAKE_CURRENT_BINARY_DIR}/modules/pputils.mod)
include(GNUInstallDirs)
install(TARGETS pputils2
EXPORT ${BSPLINES_EXPORT_TARGETS}
- LIBRARY DESTINATION ${CNAKE_INSTALL_LIBDIR}
- ARCHIVE DESTINATION ${CNAKE_INSTALL_LIBDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
if(BSPLINES_EXAMPLES)
set(EXAMPLES ex1 ex2 ex3 ex4 ex5 ex6 ex7)
foreach(ex ${EXAMPLES})
add_executable(pputils2_${ex} ${ex}.f90)
target_link_libraries(pputils2_${ex} pputils2 futils)
endforeach()
add_test(ex1 ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} 4 ${CMAKE_CURRENT_BINARY_DIR}/pputils2_ex1)
add_test(ex2 ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} 9 ${CMAKE_CURRENT_BINARY_DIR}/pputils2_ex2)
add_test(ex3 ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} 5 ${CMAKE_CURRENT_BINARY_DIR}/pputils2_ex3)
add_test(ex4 ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} 12 ${CMAKE_CURRENT_BINARY_DIR}/pputils2_ex4)
add_test(ex5 ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} 8 ${CMAKE_CURRENT_BINARY_DIR}/pputils2_ex5)
add_test(ex6 ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} 12 ${CMAKE_CURRENT_BINARY_DIR}/pputils2_ex6)
add_test(ex7 ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} 6 ${CMAKE_CURRENT_BINARY_DIR}/pputils2_ex7)
endif()
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index ea61fbf..a1daabf 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,111 +1,81 @@
-#
-# @file CMakeLists.txt
-#
-# @brief
-#
-# @copyright
-# Copyright (©) 2021 EPFL (Ecole Polytechnique Fédérale de Lausanne)
-# SPC (Swiss Plasma Center)
-#
-# SPClibs is free software: you can redistribute it and/or modify it under
-# the terms of the GNU Lesser General Public License as published by the Free
-# Software Foundation, either version 3 of the License, or (at your option)
-# any later version.
-#
-# SPClibs is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public License
-# along with this program. If not, see .
-#
-# @author
-# (in alphabetical order)
-# @author Nicolas Richart
-# @author Trach-Minh Tran
-#
project(bsplines_src)
set(SRCS
bsplines.f90
matrix.f90
sparse_mod.f90
lapack_extra.f
math_util.f90
-)
-
-set(SRCS_PP
conmat.f90
)
set(PUBLIC_MODULES
bsplines.mod
matrix.mod
math_util.mod
conmat_mod.mod
sparse.mod
)
if(HAS_PARDISO)
list(APPEND ${SRCS_PP} pardiso_mod.f90)
endif()
set_property(SOURCE conmat.f90 APPEND PROPERTY COMPILE_OPTIONS -DWSMP ${MKL_DEFINITIONS})
if(HAS_MUMPS)
list(APPEND SRCS
multigrid_mod.f90
- )
-
- list(APPEND SRCS_PP
mumps_mod.f90
csr_mod.f90
cds_mod.f90
)
list(APPEND PUBLIC_MODULES
cds.mod
csr.mod
mumps_bsplines.mod)
set_property(SOURCE conmat.f90 APPEND PROPERTY COMPILE_OPTIONS -DMUMPS)
endif()
set(_public_headers)
foreach(_modules ${PUBLIC_MODULES})
list(APPEND _public_headers ${CMAKE_CURRENT_BINARY_DIR}/${_modules})
endforeach()
-set_property(SOURCE ${SRCS_PP} APPEND PROPERTY COMPILE_OPTIONS -cpp)
include(GNUInstallDirs)
-add_library(bsplines STATIC ${SRCS} ${SRCS_PP})
+add_library(bsplines ${SRCS})
target_include_directories(bsplines
PRIVATE $
- ${MUMPS_INCLUDE_DIR}
+ ${MUMPS_INCLUDE_DIR}
+ ${PETSC_INCLUDE_DIRS}
INTERFACE $
$
)
set_property(TARGET bsplines
PROPERTY PUBLIC_HEADER ${_public_headers})
target_link_libraries(bsplines
PUBLIC futils pppack pputils2 fft
${BLAS_LIBRARIES}
${MUMPS_LIBRARIES}
${LAPACK_LIBRARIES}
- )
+ ${PETSC_LIBRARIES}
+ )
+target_compile_options(bsplines PRIVATE -cpp)
if(MKL_Fortran_FLAGS)
separate_arguments(MKL_Fortran_FLAGS)
target_compile_options(bsplines PUBLIC ${MKL_Fortran_FLAGS})
target_link_options(bsplines PUBLIC ${MKL_Fortran_FLAGS})
endif()
install(TARGETS bsplines
EXPORT ${BSPLINES_EXPORT_TARGETS}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
diff --git a/src/Makefile b/src/Makefile
index 41988c2..e3ab5f1 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -1,176 +1,173 @@
-#
-# @file Makefile
-#
-# @brief
-#
-# @copyright
-# Copyright (©) 2021 EPFL (Ecole Polytechnique Fédérale de Lausanne)
-# SPC (Swiss Plasma Center)
-#
-# SPClibs is free software: you can redistribute it and/or modify it under
-# the terms of the GNU Lesser General Public License as published by the Free
-# Software Foundation, either version 3 of the License, or (at your option)
-# any later version.
-#
-# SPClibs is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public License
-# along with this program. If not, see .
-#
-# @author
-# (in alphabetical order)
-# @author Stephan Brunner
-# @author Sébastien Jolliet
-# @author Trach-Minh Tran
-#
-PREFIX=/usr/local/crpp
-FUTILS=$(PREFIX)/futils
+PREFIX=$(SPC_LOCAL)
PPPACK=../pppack
PPUTILS2=../pputils2
-MPIF90 = mpif90
-F90 = mpif90
+MPIF90 = $(SPC_MPIF90)
+F90 = $(MPIF90)
LD = $(MPIF90)
-debug = -g -traceback -check bounds -fpe0 -warn alignments -warn unused
-debug = -g -traceback -check bounds -fpe0 -warn alignments
-optim = -O3 -xHOST
+OPTLEVEL = O
+
+ifeq ($(OPTLEVEL), O) #optimized
+ ifeq ($(COMPTYPE), i) #intel
+ OPT = -O3 -xHOST -fpp
+ endif
+ ifeq ($(COMPTYPE), g) #gnu
+ OPT = -ffree-line-length-0 -O3 -cpp
+ endif
+ ifeq ($(COMPTYPE), c) #cray
+ OPT = -e Z
+ endif
+endif
-#OPT=$(debug)
-OPT=$(optim)
+ifeq ($(OPTLEVEL), g) #debug
+ ifeq ($(COMPTYPE), i) #intel
+ OPT = -g -traceback -CB -check bounds -fpe0 -warn alignments -fpp
+ endif
+ ifeq ($(COMPTYPE), g) #gnu
+ OPT = -ffree-line-length-0 -g -fbacktrace -fbounds-check -cpp
+ endif
+ ifeq ($(COMPTYPE), c) #cray
+ OPT = -g -O0 -e Z
+ endif
+endif
-F90FLAGS = $(OPT) -fPIC -I. -I$(FUTILS)/include
+F90FLAGS = $(OPT) -fPIC -I. -I$(PREFIX)/include/$(OPTLEVEL)
-CC = cc
+CC = $(SPC_MPICC)
CFLAGS = -O2
SPL_OBJS = bsplines.o matrix.o sparse_mod.o pardiso_mod.o \
lapack_extra.o conmat.o math_util.o
ifdef MKL
SPBLAS = -DMKL
endif
ifdef MUMPS
SPL_OBJS += mumps_mod.o csr_mod.o cds_mod.o multigrid_mod.o
F90FLAGS += -I$(MUMPS)/include
endif
ifdef WSMP
SPL_OBJS += wsmp_mod.o pwsmp_mod.o
endif
ifdef PETSC_DIR
SPL_OBJS += petsc_mod.o
FCCPFLAGS = -I$(PETSC_DIR)/include -I$(PETSC_DIR)/$(PETSC_ARCH)/include
endif
.SUFFIXES:
.SUFFIXES: .o .c .f90 .f .F90
.f90.o:
$(MPIF90) $(F90FLAGS) -c $<
.F90.o:
$(MPIF90) $(F90FLAGS) $(FCCPFLAGS) -c $<
.f.o:
$(F90) $(F90FLAGS) -c $<
SUBDIRS = pputils2 pppack fft
subdirs: $(SUBDIRS)
.PHONY: subdirs $(SUBSDIRS) $(PPUTILS2)
$(SUBDIRS):
- $(MAKE) "OPT=$(OPT)" -C ../$@ lib
+ $(MAKE) "OPTLEVEL=$(OPTLEVEL)" "OPT=$(OPT)" -C ../$@ lib
lib: subdirs libbsplines.a
cp -p $(PPPACK)/libpppack.a ./
+ cp -p $(PPUTILS2)/libpputils2.a ./
touch lib
cp -p lib ../examples
libbsplines.a: $(SPL_OBJS)
- xiar r $@ $?
+ ar r $@ $?
ranlib $@
debug:
make clean
- make "OPT=$(debug)" lib
+ make "OPTLEVEL=g" lib
mkdir -p .g
- cp -p libbsplines.a $(PPPACK)/libpppack.a *.mod .g/
+ cp -p libbsplines.a $(PPPACK)/libpppack.a $(PPUTILS2)/libpputils2.a $(PPUTILS2)/*.mod *.mod .g/
opt:
make clean
- make "OPT=$(optim)" lib
- mkdir -p $(PREFIX)/{lib,include}/O
+ make "OPTLEVEL=O" lib
+ mkdir -p $(PREFIX)/lib/O
+ mkdir -p $(PREFIX)/include/O
mkdir -p .O
- cp -p libbsplines.a $(PPPACK)/libpppack.a *.mod .O/
+ cp -p libbsplines.a $(PPPACK)/libpppack.a $(PPUTILS2)/libpputils2.a $(PPUTILS2)/*.mod *.mod .O/
install: debug opt
- mkdir -p $(PREFIX)/{lib,include}/g
+ mkdir -p $(PREFIX)/lib/g
+ mkdir -p $(PREFIX)/include/g
mv .g/*.a $(PREFIX)/lib/g/
mv .g/*.mod $(PREFIX)/include/g/
- mkdir -p $(PREFIX)/{lib,include}/O
+ mkdir -p $(PREFIX)/lib/O
+ mkdir -p $(PREFIX)/include/O
mv .O/*.a $(PREFIX)/lib/O/
mv .O/*.mod $(PREFIX)/include/O/
uninstall:
rm -f $(PREFIX)/include/{O,g}/bsplines.mod \
$(PREFIX)/include/{O,g}/cds.mod \
$(PREFIX)/include/{O,g}/conmat_mod.mod \
$(PREFIX)/include/{O,g}/csr.mod \
$(PREFIX)/include/{O,g}/math_util.mod \
$(PREFIX)/include/{O,g}/matrix.mod \
$(PREFIX)/include/{O,g}/multigrid.mod \
$(PREFIX)/include/{O,g}/mumps_bsplines.mod \
$(PREFIX)/include/{O,g}/pardiso_bsplines.mod \
$(PREFIX)/include/{O,g}/petsc_bsplines.mod \
$(PREFIX)/include/{O,g}/sparse.mod \
$(PREFIX)/include/{O,g}/wsmp_bsplines.mod \
$(PREFIX)/lib/{O,g}/libbsplines.a \
- $(PREFIX)/lib/{O,g}/libpppack.a
+ $(PREFIX)/lib/{O,g}/libpppack.a \
+ $(PREFIX)/lib/{O,g}/libpputils2.a
matrix.o: matrix.f90
sparse_mod.o: sparse_mod.f90
bsplines.o: bsplines.f90 matrix.o
multigrid_mod.o: bsplines.o matrix.o conmat.o csr_mod.o cds_mod.o
conmat.o: conmat.f90 conmat.tpl conmat_1d.tpl zconmat.tpl zconmat_1d.tpl conrhs.tpl
- $(F90) -fpp -DMKL -DWSMP -DMUMPS $(F90FLAGS) -c conmat.f90
+ $(F90) -DMKL -DWSMP -DMUMPS $(F90FLAGS) -c conmat.f90
cds_mod.o: cds_mod.f90
- $(F90) -fpp $(SPBLAS) $(F90FLAGS) -c cds_mod.f90
+ $(F90) $(SPBLAS) $(F90FLAGS) -c cds_mod.f90
pardiso_mod.o: pardiso_mod.f90 sparse_mod.o psum_mat.tpl p2p_mat.tpl
- $(F90) -fpp $(SPBLAS) $(F90FLAGS) -c pardiso_mod.f90
+ $(F90) $(SPBLAS) $(F90FLAGS) -c pardiso_mod.f90
mumps_mod.o:mumps_mod.f90 sparse_mod.o psum_mat.tpl p2p_mat.tpl
- $(F90) -fpp $(SPBLAS) $(F90FLAGS) -I$(PPUTILS2) -c mumps_mod.f90
+ $(F90) $(SPBLAS) $(F90FLAGS) -I$(PPUTILS2) -c mumps_mod.f90
wsmp_mod.o: wsmp_mod.f90 sparse_mod.o psum_mat.tpl p2p_mat.tpl
- $(F90) -fpp $(SPBLAS) $(F90FLAGS) -I$(PPUTILS2) -c wsmp_mod.f90
+ $(F90) $(SPBLAS) $(F90FLAGS) -I$(PPUTILS2) -c wsmp_mod.f90
pwsmp_mod.o: pwsmp_mod.f90 sparse_mod.o wsmp_mod.o psum_mat.tpl p2p_mat.tpl
- $(F90) -fpp $(SPBLAS) $(F90FLAGS) -I$(PPUTILS2) -c pwsmp_mod.f90
+ $(F90) $(SPBLAS) $(F90FLAGS) -I$(PPUTILS2) -c pwsmp_mod.f90
petsc_mod.o: petsc_mod.F90 sparse_mod.o
- $(F90) -fpp $(FCCPFLAGS) $(SPBLAS) $(F90FLAGS) -I$(PPUTILS2) -c petsc_mod.F90
+ $(F90) $(FCCPFLAGS) $(SPBLAS) $(F90FLAGS) -I$(PPUTILS2) -c petsc_mod.F90
csr_mod.o: csr_mod.f90 sparse_mod.o mumps_mod.o
- $(F90) -fpp $(SPBLAS) $(F90FLAGS) -I$(PPUTILS2) -c csr_mod.f90
+ $(F90) $(SPBLAS) $(F90FLAGS) -I$(PPUTILS2) -c csr_mod.f90
tags:
etags *.f *.f90 $(PPPACK)/*.f90
clean:
$(MAKE) -C $(PPPACK) clean
+ $(MAKE) -C $(PPUTILS2) clean
$(MAKE) -C ../fft clean
rm -f *.o *.mod *~ a.out
distclean: clean
$(MAKE) -C $(PPPACK) distclean
$(MAKE) -C ../fft distclean
$(MAKE) -C $(PPUTILS2) distclean
rm -f lib *.a *.mod ../bin/*
rm -rf .O .g