diff --git a/CMake/FindFFTW.cmake b/CMake/FindFFTW.cmake index 08ece4c55fcdbc1b5305b1d5770a97d333496f84..cfef1dff0a491254d77d9f48736b46ab73e635bd 100644 --- a/CMake/FindFFTW.cmake +++ b/CMake/FindFFTW.cmake @@ -50,7 +50,7 @@ # Examples: fFtW3Q => FFTW3Q, fftw3f-mpi => FFTW3F_MPI # # == Using a specific FFTW == -# Set the variable ${fftw_DIR} to you desired search paths if it's not in a "classic" place or if you want a specific version. +# Set the variable ${FFTW_DIR} to your desired search paths if it's not in a standard place or if you want a specific version. # # == Checking against a specific version or the library == # Not supported yet. @@ -160,7 +160,7 @@ foreach(fftw_comp ${FFTW_FIND_COMPONENTS}) set(LIBRARY_DIR_FOUND FALSE) else() get_filename_component(${COMPONENT}_LIBRARY_DIR "${${COMPONENT}_LIBRARY}" DIRECTORY) - set(${COMPONENT}_LIBRARY "${library}") + #set(${COMPONENT}_LIBRARY "${library}") set(LIBRARY_DIR_FOUND TRUE) endif() @@ -169,12 +169,18 @@ foreach(fftw_comp ${FFTW_FIND_COMPONENTS}) if(FFTWQ_POS EQUAL 0) if(NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") set(DEPENDENCIES_FOUND FALSE) # -- only gcc supports quadmaths - else() - list(APPEND ${COMPONENT}_LIBRARIES "quadmath") - list(APPEND ${COMPONENT}_DEFINES "-DHAS_QUADMATHS") - list(APPEND FFTW_COMPILE_FLAGS "-fext-numeric-literals") - set(DEPENDENCIES_FOUND TRUE) - endif() + else() + find_library(QUADMATHLIB + NAMES quadmath + ) + if(QUADMATHLIB_FOUND) + list(APPEND ${COMPONENT}_LIBRARIES ${QUADMATHLIB}) + #list(APPEND ${COMPONENT}_LIBRARIES "quadmath") + list(APPEND ${COMPONENT}_DEFINES "-DHAS_QUADMATHS") + list(APPEND FFTW_COMPILE_FLAGS "-fext-numeric-literals") + set(DEPENDENCIES_FOUND TRUE) + endif() + endif() else() set(DEPENDENCIES_FOUND TRUE) endif() @@ -217,7 +223,6 @@ foreach(fftw_comp ${FFTW_FIND_COMPONENTS}) unset(component) unset(COMPONENT) endforeach() - list(REMOVE_DUPLICATES FFTW_INCLUDE_DIRS) list(REMOVE_DUPLICATES FFTW_LIBRARY_DIRS) list(REMOVE_DUPLICATES FFTW_LIBRARIES) diff --git a/CMake/HySoPInstallSetup.cmake b/CMake/HySoPInstallSetup.cmake old mode 100644 new mode 100755 index ee14dcb52e25c91fcd9fbeb045cec30e954194d1..e977a87a7b10f190f8d0950d755f08b45c8bfff0 --- a/CMake/HySoPInstallSetup.cmake +++ b/CMake/HySoPInstallSetup.cmake @@ -27,95 +27,31 @@ # # -# Function to compute the install path/options -# -# Usage : -# set_install_options() -# -# Resutl : -# - set CMAKE_INSTALL_PREFIX (directory where lib and packages -# will be installed) -# - set install-opt : list of options given to 'python setup.py install' command. -# -function(set_install_options) - # CMAKE_INSTALL_PREFIX given in cmake options : - if(NOT restart) - if(NOT CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) - set(restart 1 CACHE INTERNAL "True if this is not the first cmake run.") - # if 'CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT' is false, it means - # that -DCMAKE_INSTALL_PREFIX=something has been given to cmake. - # A prefix is given by user. installation in PREFIX - # (as python --prefix=<PREFIX>). - set(install-opt "--prefix=${CMAKE_INSTALL_PREFIX}" CACHE INTERNAL - "options for python installer") - # Need to set the CMAKE_INSTALL_PREFIX to the proper site - # (subdirectory of PREFIX) - # Get python install suffix (~> lib/pythonX.X/site-packages) from numpy package - set(PYTHON_COMMAND_GET_INSTALL_DIR - "import os, re, numpy; print os.path.join(os.path.join(\"${CMAKE_INSTALL_PREFIX}\",*re.compile('/numpy/__init__.py.*').sub('',numpy.__file__).split('/')[-3:]), \"${PROJECT_NAME}\")") - else() - # Default case, check virtualenv - set(restart 1 CACHE INTERNAL "True if this is not the first cmake run.") - # First, we need to check if '--user' option works in the current environment. - execute_process(COMMAND ${PYTHON_EXECUTABLE} -c - "import site; print site.ENABLE_USER_SITE" OUTPUT_VARIABLE ENABLE_USER) - string(STRIP ${ENABLE_USER} ENABLE_USER) - if(ENABLE_USER) - # Default prefix (as python --user) -> installation in site.USER_SITE - execute_process(COMMAND ${PYTHON_EXECUTABLE} -c - "import site; print site.USER_BASE" OUTPUT_VARIABLE USER_BASE) - set(install-opt "--prefix=${USER_BASE}" CACHE INTERNAL "") - # Need to set the CMAKE_INSTALL_PREFIX to site.USER_SITE - # Get python user site and install path = USER_SITE + project_name - set(PYTHON_COMMAND_GET_INSTALL_DIR - "import site, os, sys ; print os.path.join(site.USER_BASE, os.path.join(\"lib\", os.path.join(\"python\" + str(sys.version_info.major) + '.' + str(sys.version_info.minor), os.path.join(\"site-packages\", \"${PROJECT_NAME}\"))))") - else() - # user site not included in the path, - # which probably means that python is run using virtualenv - # Command to find 'global' site-packages - set(GET_SITE_PACKAGE - "from distutils.sysconfig import get_python_lib; print(get_python_lib())") - execute_process(COMMAND ${PYTHON_EXECUTABLE} -c - "${GET_SITE_PACKAGE}" OUTPUT_VARIABLE GLOBAL_SITE_PACKAGE) - string(STRIP ${GLOBAL_SITE_PACKAGE} GLOBAL_SITE_PACKAGE) - set(PYTHON_COMMAND_GET_INSTALL_DIR ${GET_SITE_PACKAGE}) - set(install-opt "" CACHE INTERNAL "") - endif() - endif() - # Set the CMAKE_INSTALL_DIR to the proper path - execute_process( - COMMAND ${PYTHON_EXECUTABLE} -c "${PYTHON_COMMAND_GET_INSTALL_DIR}" - OUTPUT_VARIABLE ${PROJECT_NAME}_INSTALL_DIR) - string(STRIP ${${PROJECT_NAME}_INSTALL_DIR} ${PROJECT_NAME}_INSTALL_DIR) - - set(CMAKE_INSTALL_PREFIX ${${PROJECT_NAME}_INSTALL_DIR} - CACHE PATH "default install path" FORCE) - - endif() - -endfunction() - +include(PythonInstallSetup) -### Start the configuration for installation ### - -set_install_options() +# =========== Find python install prefix, determined by HYSOP_INSTALL value =========== +set_python_install_path() +# ---> set HYSOP_PYTHON_INSTALL_DIR and python_install_options +# =========== install target =========== +add_custom_target(python-install + COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/setup.py install ${python_install_options} + VERBATIM + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMENT "build/install hysop package") +install(CODE "execute_process(COMMAND ${CMAKE_BUILD_TOOL} python-install WORKING_DIRECTORY \"${CMAKE_CURRENT_BINARY_DIR}\")") -# Target to remove hysop from install-path. -if(CMAKE_PATCH_VERSION LESS 12) - set(${PROJECT_NAME}_PYTHONPATH ${CMAKE_INSTALL_PREFIX}/..) - get_filename_component(${PROJECT_NAME}_PYTHONPATH ${${PROJECT_NAME}_PYTHONPATH} REALPATH) -else() - set(${PROJECT_NAME}_PYTHONPATH ${CMAKE_INSTALL_PREFIX}) - get_filename_component(${PROJECT_NAME}_PYTHONPATH ${${PROJECT_NAME}_PYTHONPATH} DIRECTORY) +if(USE_FORTRAN) + add_dependencies(python-install ${HYSOP_LIBRARY_NAME}) endif() -set(${PROJECT_NAME}_PYTHONPATH ${${PROJECT_NAME}_PYTHONPATH} CACHE PATH "PYTHONPATH for hysop") -add_custom_target(uninstall COMMAND rm -rf ${${PROJECT_NAME}_PYTHONPATH}/${PYPACKAGE_NAME}* - COMMENT "Remove ${${PROJECT_NAME}_PYTHONPATH}/${PYPACKAGE_NAME} directory (hysop package and its dependencies)") -# To install python package AND hysop library and modules -add_custom_target(python-install COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/setup.py install ${install-opt} config_fc --f90exec=${CMAKE_Fortran_COMPILER} - #COMMAND make install - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMENT "build/install hysop package") -install(CODE "execute_process(COMMAND ${CMAKE_BUILD_TOOL} python-install WORKING_DIRECTORY \"${CMAKE_CURRENT_BINARY_DIR}\")") +# =========== uninstall target =========== +configure_file( + "${CMAKE_CURRENT_SOURCE_DIR}/CMake/cmake_uninstall.cmake.in" + "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" + IMMEDIATE @ONLY) + +add_custom_target(uninstall + echo >> ${CMAKE_CURRENT_BINARY_DIR}/install_manifest.txt + COMMAND cat ${CMAKE_CURRENT_BINARY_DIR}/python_install_manifest.txt >> ${CMAKE_CURRENT_BINARY_DIR}/install_manifest.txt + COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake) diff --git a/CMake/HySoPTests.cmake b/CMake/HySoPTests.cmake old mode 100644 new mode 100755 index f4df2ffc010bc298eb8c3665d7e32f2a3706112b..e9daf953bef516ed2074b891f98e39b3d2bc1d30 --- a/CMake/HySoPTests.cmake +++ b/CMake/HySoPTests.cmake @@ -3,25 +3,53 @@ # --> collect test directories/files # --> create tests (ctest) # +# For each function 'test_something' in all files of directories +# 'tests' a new test is created. +# # Those tests will be run after a call to 'make test' # or a call to ctest. enable_testing() find_python_module(pytest REQUIRED) -# Choose python build dir as directory where tests will be run. -# --> get build dir for python -execute_process( - COMMAND ${PYTHON_EXECUTABLE} -c "import distutils.util as ut ; import distutils.sysconfig as sy; print 'lib.'+ut.get_platform()+'-'+sy.get_python_version()" - OUTPUT_VARIABLE ${PROJECT_NAME}_PYTHON_BUILD_DIR) -string(STRIP ${${PROJECT_NAME}_PYTHON_BUILD_DIR} ${PROJECT_NAME}_PYTHON_BUILD_DIR) +# Declaration of python test +# Usage: +# add_python_test(name file) +# with 'name' is the name of the test and file the source +# file for the test. +macro(add_python_test test_name test_file) + add_test(${test_name} py.test "${pytest_opt}" ${test_file}) + set_tests_properties(${test_name} PROPERTIES FAIL_REGULAR_EXPRESSION "FAILURE;Exception;[^x]failed;ERROR;Assertion") + set_tests_properties(${test_name} PROPERTIES WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/dataForTests) + set_tests_properties(${test_name} PROPERTIES ENVIRONMENT "PYTHONPATH=$ENV{PYTHONPATH}:${HYSOP_BUILD_PYTHONPATH}") + set_tests_properties(${test_name} PROPERTIES ENVIRONMENT "PYTHONPATH=$ENV{PYTHONPATH}:${HYSOP_BUILD_PYTHONPATH},LD_LIBRARY_PATH=$ENV{LD_LIBRARY_PATH}:${HYSOP_BUILD_PYTHONPATH}") + if(WITH_MPI_TESTS) + # Run the same test using mpi multi process run. + # The number of processes used is set with NBPROCS_FOR_TESTS variable (user option for cmake, default=8) + add_test(${test_name}_mpi ${MPIEXEC} -np ${NBPROCS_FOR_TESTS} ${PYTHON_EXECUTABLE} -m pytest "${pytest_opt}" ${test_file}) + + #mpirun -np 1 python -m pytest -v + + set_tests_properties(${test_name}_mpi PROPERTIES FAIL_REGULAR_EXPRESSION "FAILURE;Exception;[^x]failed;ERROR;Assertion") + set_tests_properties(${test_name}_mpi PROPERTIES WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/dataForTests) + set_tests_properties(${test_name}_mpi PROPERTIES ENVIRONMENT "PYTHONPATH=$ENV{PYTHONPATH}:${HYSOP_BUILD_PYTHONPATH},LD_LIBRARY_PATH=$ENV{LD_LIBRARY_PATH}:${HYSOP_BUILD_PYTHONPATH}") + endif() + +endmacro() +# Choose python build dir as directory where tests will be run. # --> set test dir -set(testDir ${CMAKE_BINARY_DIR}/build/${${PROJECT_NAME}_PYTHON_BUILD_DIR}) -# 1 - Collect files for Python unitary tests (user-defined) ----- +set(testDir ${HYSOP_BUILD_PYTHONPATH}) + +# === Tests options === +if(FULL_TEST) + set(pytest_opt "-s -v -pep8" CACHE INTERNAL "extra options for py.test") +else() + set(pytest_opt "-v" CACHE INTERNAL "extra options for py.test") +endif() -# We create a new test for each test_XXX.py found in each directory (i.e. module) of hysop listed below +# === Set the list of all directories which may contain tests === set(py_src_dirs fields domain @@ -29,18 +57,12 @@ set(py_src_dirs numerics problem tools + mpi ) -# If mpi is on, we add test_XXX.py files of hysop/mpi directory -if(USE_MPI) - set(py_src_dirs - ${py_src_dirs} mpi) -endif() - # If GPU is on, we add test_XXX.py files of hysop/gpu directory if(WITH_GPU) - set(py_src_dirs - ${py_src_dirs} gpu) + list(APPEND py_src_dirs gpu) endif() # Copy the OpenCL sources files to build dir (required since only python files are copied by setup.py) @@ -57,24 +79,19 @@ foreach(_F ${clfiles}) configure_file(${_F} ${testDir}/${_F} COPYONLY) endforeach() +# === Create the files list from all directories in py_src_dirs === + # Build a list of test_*.py files for each directory of hysop/${py_src_dirs} set(py_test_files) foreach(testdir ${py_src_dirs}) file(GLOB testfiles RELATIVE ${CMAKE_SOURCE_DIR} hysop/${testdir}/tests/test_*.py) set(py_test_files ${py_test_files} ${testfiles}) # copy data files - file(GLOB datfiles hysop/${testdir}/tests/*.dat) - file(GLOB mapfiles hysop/${testdir}/tests/*.map) file(GLOB reffiles hysop/${testdir}/tests/ref_files/*) - set(datafiles ${mapfiles} ${datfiles}) file(COPY ${reffiles} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/dataForTests) - foreach(_F ${datafiles}) - get_filename_component(fname ${_F} NAME) - configure_file(${_F} ${CMAKE_CURRENT_BINARY_DIR}/dataForTests/${fname} COPYONLY) - endforeach() endforeach() -# 2 - Collect files for Python doctest ----- +# Build doctests # Handling doctest in *.py files recursively for each directory of hysop/${py_src_dirs} # excluding __init__ or test_ files. # Doctest are run for every line which contains '>>>' @@ -89,38 +106,17 @@ foreach(testdir ${py_src_dirs}) endforeach() endforeach() -# 3 - Create tests for all collected files ----- -message(STATUS "=== TESTS === ") +# === Create tests from py_test_files === foreach(testfile ${py_test_files}) get_filename_component(testName ${testfile} NAME_WE) - set(testExe ${testDir}/${testfile}) - message(STATUS "Add test ${testfile} ...") - if(FULL_TEST) - add_test(NAME ${testName} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/dataForTests - COMMAND py.test -v --pep8 ${testExe}) - else() - add_test(NAME ${testName} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/dataForTests - COMMAND py.test -v ${testExe}) - endif() - - # Run the same test using mpi multi process run. - # The number of processes used is set with NBPROCS_FOR_TESTS variable (user option for cmake, default=8) - if(WITH_MPI_TESTS) - message(STATUS "Add test mpi_${testName}.") - add_test( - NAME mpi_${testName} - WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/dataForTests - COMMAND mpirun -np ${NBPROCS_FOR_TESTS} ${PYTHON_EXECUTABLE} ${testExe} - ) - set_tests_properties(mpi_${testName} - PROPERTIES ENVIRONMENT "PYTHONPATH=${testDir}") - endif() + set(exename ${testDir}/${testfile}) + message(STATUS "Add test ${exename} ...") + add_python_test(${testName} ${exename}) endforeach() # Add files containing doctests foreach(testfile ${py_doctest_files}) get_filename_component(testName ${testfile} NAME_WE) - message(STATUS "Add test from doc doctest_${testName} ...") add_test("doctest_${testName}" py.test -v --doctest-modules ${testfile}) endforeach() -message(STATUS "===") + diff --git a/CMake/HysopVersion.cmake b/CMake/HysopVersion.cmake new file mode 100644 index 0000000000000000000000000000000000000000..dc6db0275703022bc6bd5c213743d69b693ade6e --- /dev/null +++ b/CMake/HysopVersion.cmake @@ -0,0 +1,5 @@ +# --- set hysop current version --- +set(MAJOR_VERSION 2) +set(MINOR_VERSION 0) +set(PATCH_VERSION 0) +set(HYSOP_VERSION "${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}") diff --git a/CMake/MyTools.cmake b/CMake/MyTools.cmake index 018c8d5ba2315f44bd8a4d25bffeb746501acbfa..bfe3fde4ad943c8b287cb978061ba1df5ce28d50 100644 --- a/CMake/MyTools.cmake +++ b/CMake/MyTools.cmake @@ -1,4 +1,7 @@ -include(LibFindMacros) +# +# Some convenience macros +# +include(CMakeParseArguments) # -- Basic list manipulation -- # Get first element of list var @@ -12,23 +15,23 @@ macro(CDR var junk) endmacro(CDR) # LIST(APPEND ...) is not correct on <COMPILER>_FLAGS -macro(APPEND_FLAGS) +macro(append_flags) CAR(_V ${ARGV}) CDR(_F ${ARGV}) set(${_V} "${${_V}} ${_F}") -endmacro(APPEND_FLAGS) +endmacro(append_flags) # The use of ADD_DEFINITION results in a warning with Fortran compiler macro(APPEND_C_FLAGS) - APPEND_FLAGS(CMAKE_C_FLAGS ${ARGV}) + append_flags(CMAKE_C_FLAGS ${ARGV}) endmacro(APPEND_C_FLAGS) macro(APPEND_CXX_FLAGS) - APPEND_FLAGS(CMAKE_CXX_FLAGS ${ARGV}) + append_flags(CMAKE_CXX_FLAGS ${ARGV}) endmacro(APPEND_CXX_FLAGS) macro(APPEND_Fortran_FLAGS) - APPEND_FLAGS(CMAKE_Fortran_FLAGS ${ARGV}) + append_flags(CMAKE_Fortran_FLAGS ${ARGV}) endmacro(APPEND_Fortran_FLAGS) # Scans DIRS (list of directories) and returns a list of all files in those dirs @@ -109,6 +112,12 @@ macro(display V) message(STATUS "${V} = ${${V}}") endmacro(display V) +macro(ASSERT VAR) + if (NOT DEFINED ${VAR}) + message( FATAL_ERROR "ASSERTION ERROR : ${VAR} UNSET" ) + endif() +endmacro() + # ======================================= # For a given package name, try to find # corresponding headers and libraries and @@ -127,23 +136,54 @@ endmacro(display V) # with the same 'options' as find_package # (see http://www.cmake.org/cmake/help/v3.0/command/find_package.html?highlight=find_package) macro(COMPILE_WITH) + + set(options REQUIRED) + set(oneValueArgs ONLY) + set(multiValueArgs COMPONENTS) + + cmake_parse_arguments(COMPILE_WITH "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} ) + + set(_NAME) + set(_NAME_VERSION) + # Get package name and extra args ... - CAR(_NAME ${ARGV}) - CDR(_REST ${ARGV}) - CAR(_REQ ${_REST}) - if(_REST) - CDR(_RREST ${_REST}) - CAR(_COMP ${_RREST}) - endif(_REST) - string(TOUPPER ${_NAME} _UNAME) + CAR(_NAME ${COMPILE_WITH_UNPARSED_ARGUMENTS}) + CDR(_NAME_VERSION ${COMPILE_WITH_UNPARSED_ARGUMENTS}) + + set(_NAMES) + STRING(TOUPPER ${_NAME} _UNAME) list(APPEND _NAMES ${_NAME}) list(APPEND _NAMES ${_UNAME}) set(_FOUND) - find_package(${ARGV}) - - foreach(_N ${_NAMES}) + + if(COMPILE_WITH_COMPONENTS) + set(_COMPONENTS COMPONENTS ${COMPILE_WITH_COMPONENTS}) + set(_COMPONENTS_STR "components ${COMPILE_WITH_COMPONENTS} of the package") + else() + set(_COMPONENTS) + set(_COMPONENTS_STR "package") + endif() + + if(${COMPILE_WITH_REQUIRED}) + set(_REQUIRED REQUIRED) + set(_REQUIRED_STR "required") + else() + set(_REQUIRED) + set(_REQUIRED_STR "optional") + endif() + + if(_NAME_VERSION) + set(_NAME_VERSION_STR "version ${_NAME_VERSION}") + else() + set(_NAME_VERSION_STR "") + endif() + + FIND_PACKAGE(${_NAME} ${_NAME_VERSION} ${_COMPONENTS} ${_REQUIRED}) + set(_LINK_LIBRARIES) + FOREACH(_N ${_NAMES}) if(${_N}_FOUND) set(_FOUND TRUE) + set(_NAME_VERSION_STR "version ${${_N}_VERSION}") # add headers dirs into 'include' path # INCLUDE_DIR var name depends on FindNAME # We try to check the standard var names. @@ -158,8 +198,7 @@ macro(COMPILE_WITH) endif() # Now we set list of libs that must be linked with. if(DEFINED ${_N}_LIBRARIES) - set(HYSOP_LINK_LIBRARIES ${HYSOP_LINK_LIBRARIES} - ${${_N}_LIBRARIES}) + list(APPEND _LINK_LIBRARIES ${${_N}_LIBRARIES}) endif() # And the compiler flags if(DEFINED ${_N}_DEFINITIONS) @@ -170,13 +209,59 @@ macro(COMPILE_WITH) endif() endif() endforeach() - list(REMOVE_DUPLICATES HYSOP_LINK_LIBRARIES) - set(HYSOP_LINK_LIBRARIES ${HYSOP_LINK_LIBRARIES} - ${${_N}_LIBRARIES} CACHE INTERNAL "List of external libraries.") + if(_LINK_LIBRARIES) + list(REMOVE_DUPLICATES _LINK_LIBRARIES) + foreach(_lib ${_LINK_LIBRARIES}) + get_filename_component(libpath ${_lib} DIRECTORY) + list(FIND CMAKE_C_IMPLICIT_LINK_DIRECTORIES "${libpath}" isSystemDir) + if(${isSystemDir} GREATER -1) + list(GET CMAKE_C_IMPLICIT_LINK_DIRECTORIES ${isSystemDir} result) + if("${libpath}" STRGREATER "${result}") + message("oiaoazoazioazioza ${_lib}") + list(APPEND CMAKE_INSTALL_RPATH "${libpath}") + list(APPEND CMAKE_BUILD_RPATH "${libpath}") + endif() + else()#"${isSystemDir}" STREQUAL "-1") + #get_property(libpath SOURCE ${_lib} PROPERTY LOCATION) + list(APPEND CMAKE_INSTALL_RPATH "${libpath}") + list(APPEND CMAKE_BUILD_RPATH "${libpath}") + endif() + endforeach() + if(CMAKE_INSTALL_RPATH) + list(REMOVE_DUPLICATES CMAKE_INSTALL_RPATH) + endif() + if(CMAKE_BUILD_RPATH) + list(REMOVE_DUPLICATES CMAKE_BUILD_RPATH) + endif() + endif() + if(COMPILE_WITH_ONLY) + set(_sico_component ${COMPILE_WITH_ONLY}) + set(${_sico_component}_LINK_LIBRARIES ${${_sico_component}_LINK_LIBRARIES} + ${_LINK_LIBRARIES} CACHE INTERNAL "List of external libraries for ${_sico_component}.") + else() + set(HYSOP_LINK_LIBRARIES ${HYSOP_LINK_LIBRARIES} + ${_LINK_LIBRARIES} CACHE INTERNAL "List of external libraries.") + endif() + + IF (_FOUND) + message(STATUS "Compilation with ${_REQUIRED_STR} ${_COMPONENTS_STR} ${_NAME} ${_NAME_VERSION_STR}") + else() + message(STATUS "Compilation without ${_REQUIRED_STR} ${_COMPONENTS_STR} ${_NAME} ${_NAME_VERSION_STR}") + endif() + set(_N) set(_NAME) + set(_NAME_VERSION) + set(_NAME_VERSION_STR) set(_UNAME) set(_NAMES) + set(_FOUND) + set(_REQUIRED) + set(_REQUIRED_STR) + set(_COMPONENTS) + set(_COMPONENTS_STR) + set(_VERSION_STR) + endmacro(COMPILE_WITH) # ==== Save directories required for include_directory === diff --git a/CMake/PythonInstallSetup.cmake b/CMake/PythonInstallSetup.cmake new file mode 100755 index 0000000000000000000000000000000000000000..4a49efe24eb61b4a3afa697a3f583644801b623b --- /dev/null +++ b/CMake/PythonInstallSetup.cmake @@ -0,0 +1,112 @@ +# --- Function to compute the install path/options --- +# +# Usage : +# set_install_options() +# +# Read HYSOP_INSTALL option (from user input) +# and set python install dir according to its value. +# +# Summary : +# cmake path-to-your-sources -Dpython_install_dir=standard +# make install +# +# ---> install in 'system' python site-package +# +# cmake path-to-your-sources -Dpython_install_dir=user +# make install +# +# ---> install in USER_SITE (no virtualenv case) +# ---> install in site-packages of your virtualenv +# +# cmake path-to-your-sources -Dpython_install_dir=prefix -DCMAKE_INSTALL_PREFIX=/some/install/path +# make install +# +# ---> install in CMAKE_INSTALL_PREFIX +# +# If /some/install/path is not a standard path of your system, +# you'll probably need something like : +# export PYTHONPATH=${PYTHONPATH}:/some/install/path +# +# +function(set_python_install_path) + set(python_install_options "--record;${CMAKE_BINARY_DIR}/python_install_manifest.txt") + + if(HYSOP_INSTALL STREQUAL "user") + # --- Case 1 : HYSOP_INSTALL=user --- + # In that case, we need to find the user path. It depends on the operating system + # and on which python is used (virtualenv or not) + # First, we need to check if '--user' option works in the current environment. + execute_process(COMMAND ${PYTHON_EXECUTABLE} -c + "import site; print site.ENABLE_USER_SITE" OUTPUT_VARIABLE ENABLE_USER) + string(STRIP ${ENABLE_USER} ENABLE_USER) + + if(ENABLE_USER) # --user works ... + # Find install path for --user (site.USER_SITE) + execute_process(COMMAND ${PYTHON_EXECUTABLE} -c + "import site; print site.USER_BASE" OUTPUT_VARIABLE USER_BASE) + string(STRIP ${USER_BASE} USER_BASE) + list(APPEND python_install_options --prefix=${USER_BASE}) + # Get python user site and install path = USER_SITE + project_name + set(PYTHON_COMMAND_GET_INSTALL_DIR + "import site, os, sys ; print os.path.join(site.USER_BASE, os.path.join(\"lib\", os.path.join(\"python\" + str(sys.version_info.major) + '.' + str(sys.version_info.minor), + \"site-packages\")))") + execute_process( + COMMAND ${PYTHON_EXECUTABLE} -c "${PYTHON_COMMAND_GET_INSTALL_DIR}" + OUTPUT_VARIABLE PY_INSTALL_DIR) + + else() + # user site not included in the path, + # which probably means that python is run using virtualenv + # Command to find 'global' site-packages + # default path will probably be ok --> no options + set(GET_SITE_PACKAGE + "from distutils.sysconfig import get_python_lib; print(get_python_lib())") + execute_process(COMMAND ${PYTHON_EXECUTABLE} -c + "${GET_SITE_PACKAGE}" OUTPUT_VARIABLE GLOBAL_SITE_PACKAGE) + string(STRIP ${GLOBAL_SITE_PACKAGE} GLOBAL_SITE_PACKAGE) + set(PYTHON_COMMAND_GET_INSTALL_DIR ${GET_SITE_PACKAGE}) + execute_process( + COMMAND ${PYTHON_EXECUTABLE} -c "${PYTHON_COMMAND_GET_INSTALL_DIR}" + OUTPUT_VARIABLE PY_INSTALL_DIR) + endif() + + elseif(HYSOP_INSTALL STREQUAL standard) + # install in python standard installation location + # (may need to be root) + # Depends on OS/platform type, check for example https://docs.python.org/2/install/. + #set(PYTHON_COMMAND_GET_INSTALL_DIR + # "import site; print(site.getsitepackages()[0])") + # --> this does not work properly: the order in resulting + # list depends on the OS, the python version ... + configure_file(CMake/fake/setup.py tmp/setup.py) + configure_file(CMake/fake/__init__.py tmp/fake/__init__.py) + configure_file(CMake/find_python_install.py tmp/find_python_install.py) + execute_process( + COMMAND ${PYTHON_EXECUTABLE} find_python_install.py + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/tmp/ + OUTPUT_VARIABLE PY_INSTALL_DIR) + + else()#HYSOP_INSTALL STREQUAL prefix) + # Last case : HYSOP_INSTALL=prefix, user-defined prefix + # we use CMAKE_INSTALL_PREFIX as the path for python install + list(APPEND python_install_options --prefix=${HYSOP_INSTALL}) + set(PY_INSTALL_DIR ${HYSOP_INSTALL}) + endif() + + string(STRIP ${PY_INSTALL_DIR} PY_INSTALL_DIR) + if(NOT CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + if(NOT CMAKE_INSTALL_PREFIX STREQUAL PY_INSTALL_DIR) + message(STATUS "!!! Warning !!! Use HYSOP_INSTALL option rather than CMAKE_INSTALL_PREFIX that will be overwritten if not complient with HYSOP_INSTALL value.") + endif() + endif() + + # Set the HYSOP_PYTHON_INSTALL_DIR to the proper path + set(HYSOP_PYTHON_INSTALL_DIR ${PY_INSTALL_DIR} + CACHE PATH "Install directory for hysop python package" FORCE) + set(CMAKE_INSTALL_PREFIX ${PY_INSTALL_DIR} + CACHE PATH "Install directory for hysop python package" FORCE) + list(APPEND python_install_options config_fc) + list(APPEND python_install_options --f90exec=${CMAKE_Fortran_COMPILER}) + set(python_install_options ${python_install_options} CACHE INTERNAL "") +endfunction() + diff --git a/CMake/cmake_uninstall.cmake.in b/CMake/cmake_uninstall.cmake.in new file mode 100644 index 0000000000000000000000000000000000000000..d48e08426bf4ab0ad080f83187f2c971ab64fd3e --- /dev/null +++ b/CMake/cmake_uninstall.cmake.in @@ -0,0 +1,28 @@ +# ---------------------------------- +# Setup for make uninstall target +# See: +# http://www.cmake.org/Wiki/CMake_FAQ#Can_I_do_.22make_uninstall.22_with_CMake.3F +# ---------------------------------- + +if(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") + message(FATAL_ERROR "Cannot find install manifest: @CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") +endif(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") + +file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files) +string(REGEX REPLACE "\n" ";" files "${files}") +foreach(file ${files}) + message(STATUS "Uninstalling $ENV{DESTDIR}${file}") + if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") + exec_program( + "@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\"" + OUTPUT_VARIABLE rm_out + RETURN_VALUE rm_retval + ) + if(NOT "${rm_retval}" STREQUAL 0) + message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}") + endif(NOT "${rm_retval}" STREQUAL 0) + else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") + message(STATUS "File $ENV{DESTDIR}${file} does not exist.") + endif(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") +endforeach(file) + diff --git a/CMake/fake/__init__.py b/CMake/fake/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/CMake/fake/setup.py b/CMake/fake/setup.py new file mode 100644 index 0000000000000000000000000000000000000000..2bff192037c8273b5b32f39996c10a71dea0c76c --- /dev/null +++ b/CMake/fake/setup.py @@ -0,0 +1,20 @@ +"""False setup.py used to find where packages installed with +'python setup.py install' +will be installed. +This is the only portable and systematic way we found. + +site.getsitepackages() or distutils.sysconfig.get_python_lib() do not +behave equally on every platforms. +""" +from numpy.distutils.core import setup +from numpy.distutils.misc_util import Configuration +# List of python modules (directories) to be included +packages = ['fake', + ] +config = Configuration( + name='fake', + version='', + packages=packages, +) + +setup(**config.todict()) diff --git a/CMake/find_python_install.py b/CMake/find_python_install.py new file mode 100644 index 0000000000000000000000000000000000000000..4e0a2146a77dbb36cb00e3c5df745b871f73449c --- /dev/null +++ b/CMake/find_python_install.py @@ -0,0 +1,26 @@ +"""Find where python will install things when setup.py is called. +""" +import subprocess +import locale + +encoding = locale.getdefaultlocale()[1] + +output = subprocess.Popen(["python", "setup.py", "--dry-run", "install"], + stdout=subprocess.PIPE).communicate()[0] + +if encoding: + output = output.decode(encoding).split('\n') +else: # let's cross fingers here ... + output = output.split('\n') + +for line in output: + if line.count('egg') and line.count('fake'): + result = line + break +result = result.split(' ') +for line in result: + if line.count('egg'): + result = line + break +result = result.split('fake')[0] +print(result) diff --git a/CMake/fortran_utils.cmake b/CMake/fortran_utils.cmake new file mode 100644 index 0000000000000000000000000000000000000000..8f56794452975c5e23ad0aed1de74d937fb21be4 --- /dev/null +++ b/CMake/fortran_utils.cmake @@ -0,0 +1,52 @@ +# --- CMake utilities, to deal with f2py interface --- + + +# Create a pyf file that include +# all 'fortran' signature files (sub-pyf files) +# required by f2py. +# +# Usage: +# write_main_pyf_file(fname) +# where fname must be the name of the generated module +# +# For example to create hysop.f2hysop python module, +# call (in CMakeLists.txt) +# write_main_pyf_file(f2hysop) +# --> create f2hysop.pyf that will be used to generate hysop.f2hysop module. +# +function(write_main_pyf_file filename) + set(_file ${CMAKE_SOURCE_DIR}/${PACKAGE_NAME}/${filename}.pyf.in) + file(WRITE ${_file} +"! -*- f90 -*-\n +! Generated file - Do not edit.\n +! Note: the context of this file is case sensitive.\n +python module f2hysop ! in\n + interface\n") + file(APPEND ${_file} + " ! Example + include '@CMAKE_SOURCE_DIR@/hysop/fortran/template.pyf'\n") + file(APPEND ${_file} + " ! precision + include '@CMAKE_SOURCE_DIR@/hysop/f2py/parameters.pyf'\n") + if(WITH_FFTW) + file(APPEND ${_file} + " ! fftw + include '@CMAKE_SOURCE_DIR@/hysop/f2py/fftw2py.pyf'\n") + endif() + if(WITH_SCALES) + file(APPEND ${_file} + " ! scales + include '@CMAKE_SOURCE_DIR@/hysop/f2py/scales2py.pyf'\n") + endif() + if(WITH_EXTRAS) + file(APPEND ${_file} + " ! arnoldi + include '@CMAKE_SOURCE_DIR@/hysop/fortran/arnoldi2py.pyf'\n") + endif() + file(APPEND ${_file} " end interface\n +end python module f2hysop") + +message(STATUS "Generate pyf file ...") +configure_file(${_file} ${CMAKE_SOURCE_DIR}/${PACKAGE_NAME}/${filename}.pyf @ONLY) + +endfunction() diff --git a/HySoP/CMakeLists.txt b/HySoP/CMakeLists.txt old mode 100644 new mode 100755 index b98a6d94ffa9d6185502694eaca00b22b959e5c9..17397c31f865acadb4217fc77d71bd64083f93a5 --- a/HySoP/CMakeLists.txt +++ b/HySoP/CMakeLists.txt @@ -14,10 +14,12 @@ #=============================================================================== # ============= Global cmake Settings ============= # Set minimum version for cmake -cmake_minimum_required(VERSION 2.8.7) -if(POLICY CMP0042) - cmake_policy(SET CMP0042 OLD) +cmake_minimum_required(VERSION 3.0.2) + +if(POLICY CMP0053) + cmake_policy(SET CMP0053 NEW) endif() + # Set cmake modules directory (i.e. the one which contains all user-defined FindXXX.cmake files among other things) set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMake") # Force out-of-source build @@ -31,10 +33,10 @@ option(DOUBLEPREC "set precision for real numbers to double precision when this option(USE_MPI "compile and link HySoP with mpi when this mode is enable. Default = on." ON) option(WITH_TESTS "Enable testing. Default = off" ON) option(BUILD_SHARED_LIBS "Enable dynamic library build, default = ON." ON) -option(WITH_LIB_FORTRAN "Generate libhysop from fortran files in src, wrapped into hysop.f2py module. Default = ON." ON) option(WITH_LIB_CXX "Generate libhysop from fortran files in src, wrapped into hysop.cpp2hysop module. Default = ON." ON) option(WITH_SCALES "compile/create scales lib and link it with HySoP. Default = ON." ON) option(WITH_FFTW "Link with fftw library (required for some HySoP solvers), default = ON" ON) +option(WITH_EXTRAS "Link with some extra fortran libraries (like arnoldi solver), default = OFF" OFF) option(WITH_GPU "Use of GPU (required for some HySoP solvers), default = ON" ON) option(WITH_MAIN_FORTRAN "Create an executable (test purpose) from fortran sources in src/main, linked with libhysop, default = ON" ON) option(WITH_MAIN_CXX "Create an executable (test purpose) from cxx sources in src/hysop++/main, linked with libhysop, default = ON" ON) @@ -51,32 +53,44 @@ option(WITH_DOCUMENTATION "Build Documentation. Default = OFF" ON) # - user --> behave as 'python setup.py install --user' # - standard --> install in python site-package (ie behave as python setup.py install) # - prefix --> install in python CMAKE_INSTALL_PREFIX (ie behave as python setup.py install --prefix=CMAKE_INSTALL_PREFIX) -set(hysop_python_install "user" CACHE STRING "Install mode for hysop python package") +set(HYSOP_INSTALL "user" CACHE STRING "Install mode for hysop python package") + +# Install lib directory 32, 64 etc. on Fedora, Debian +# http://public.kitware.com/Bug/view.php?id=11964 +# See also http://www.cmake.org/cmake/help/v3.0/module/GNUInstallDirs.html?highlight=gnuinstalldirs +include(GNUInstallDirs) +# Set prefix path for libraries installation +# --> means that any library target will be installed +# in CMAKE_INSTALL_PREFIX/_install_lib +if(${PROJECT_NAME}_INSTALL_LIB_DIR) + set(_install_lib ${${PROJECT_NAME}_INSTALL_LIB_DIR}) +else() + ASSERT(CMAKE_INSTALL_LIBDIR) + set(_install_lib ${CMAKE_INSTALL_LIBDIR}) + set(${PROJECT_NAME}_INSTALL_LIB_DIR ${_install_lib}) +endif() -if(NOT WITH_LIB_FORTRAN) - message(WARNING "You deactivate libhysop (fortran) generation. This will disable the fortran interface, including fftw and scales fonctionnalities.") - set(WITH_SCALES "OFF") - set(WITH_MAIN_FORTRAN "OFF") +if(NOT USE_MPI) + message(FATAL_ERROR "No-mpi version of hysop is broken, please enable mpi.") +endif() + +if(WITH_FFTW OR WITH_SCALES OR WITH_EXTRAS) + set(USE_FORTRAN "ON") endif() if(NOT WITH_LIB_CXX) - message(WARNING "You deactivate libhysop (cxx) generation. This will disable the Aitken-Schwarz Poisson solver.") set(WITH_MAIN_CXX "OFF") set(WITH_GOOGLE_TESTS "OFF") endif() # true if hysop used Fortran and/or c++ sources -if(${WITH_LIB_FORTRAN} OR ${WITH_LIB_CXX}) +# We can not run scales or fftw without mpi ... +if(USE_FORTRAN OR WITH_LIB_CXX) set(WITH_COMPILED_LIB "ON") - set(WITH_FFTW "ON") + #set(WITH_FFTW "ON") else() set(WITH_COMPILED_LIB "OFF") - set(WITH_FFTW "OFF") -endif() - -# We can not run scales without mpi ... -if(WITH_FFTW OR WITH_SCALES) - set(USE_MPI "ON") + #set(WITH_FFTW "OFF") endif() # Force a default build type if not provided by user @@ -91,10 +105,7 @@ endif() set(PROJECT_NAME hysop) # --- Name for the package --- # This name will be used as the Python Package name -set(PYPACKAGE_NAME "hysop") -# --- Set a version number for the package --- -set(PACKAGE_VERSION 1.0.0) -set(${PYPACKAGE_NAME}_version ${PACKAGE_VERSION}) +set(PACKAGE_NAME "hysop") # --- The name (without extension) of the lib to be created --- set(PROJECT_LIBRARY_NAME ${PROJECT_NAME}) # ============= The project ============= @@ -108,20 +119,21 @@ set(LANGLIST) if(WITH_LIB_CXX) set(LANGLIST ${LANGLIST} C CXX) endif() -if(WITH_LIB_FORTRAN) +if(USE_FORTRAN) set(LANGLIST ${LANGLIST} Fortran) endif() - +include(HysopVersion) project(${PROJECT_NAME} ${LANGLIST}) set(HYSOP_LIBRARY_NAME hysop) -set(PACKAGE_NAME HySoP) +set(HYSOP_INCLUDE_DIRECTORIES + CACHE INTERNAL "Include directories for external dependencies.") +set(HYSOP_LINK_LIBRARIES CACHE INTERNAL "List of external libraries.") # ============= Python and its packages ============= # - Global setup (interp and lib) - find_package(PythonFull REQUIRED) include(FindPythonModule) - # - python packages - find_python_module(numpy REQUIRED) find_python_module(scipy) @@ -136,9 +148,20 @@ find_python_module(sympy) find_python_module(pyopencl REQUIRED) # --- MPI --- if(USE_MPI) + find_package(MPI REQUIRED) find_python_module(mpi4py REQUIRED) endif() +if(WITH_LIB_CXX) + find_package(SWIG 3.0.2 REQUIRED) + # WARNING FP : for cmake < 3.0 UseSWIG.cmake + # does not work properly (bug for swig outdir) + if(CMAKE_VERSION VERSION_LESS 3.0.0) + set(SWIG_USE_FILE ${CMAKE_SOURCE_DIR}/cmake/UseSWIG.cmake) + endif() + include(${SWIG_USE_FILE}) +endif() + # Find python build dir name --> needed for tests and doc if(WITH_COMPILED_LIB) execute_process( @@ -152,23 +175,30 @@ endif() # ============= Other dependencies ============= -# -- Swig -- -if(WITH_LIB_CXX) - find_package(SWIG 3.0.8 REQUIRED) - if(CMAKE_VERSION VERSION_LESS 3.0.0) - set(SWIG_USE_FILE ${CMAKE_SOURCE_DIR}/CMake/UseSWIG.cmake) - endif() - include(${SWIG_USE_FILE}) -endif() - +# --- FFTW --- if(WITH_FFTW) set(FIND_FFTW_VERBOSE OFF) set(FIND_FFTW_DEBUG OFF) - find_package(FFTW - REQUIRED COMPONENTS Fftw3d Fftw3f Fftw3d-mpi Fftw3f-mpi - OPTIONAL_COMPONENTS Fftw3l Fftw3q) + compile_with(FFTW + REQUIRED COMPONENTS Fftw3d Fftw3f Fftw3d-mpi Fftw3f-mpi + OPTIONAL_COMPONENTS Fftw3l)# Fftw3q) + set(dirlist) + + foreach(_file ${FFTW_LIBRARIES}) + get_filename_component(_name ${_file} DIRECTORY) + list(FIND dirlist ${_name} isin) + if(isin EQUAL -1) + list(APPEND dirlist ${_name}) + endif() + endforeach() + set(FFTWLIB ${dirlist} CACHE PATH "fftw libraries dir") + add_definitions(${FFTW_DEFINES}) endif() +if(WITH_EXTRAS) + # Arnoldi solver needs zgeev, which means lapack + compile_with(LAPACK) +endif() # ========= Check which opencl devices are available on the system ========= if(WITH_GPU) @@ -190,6 +220,33 @@ list(GET MY_LIST 0 OPENCL_DEFAULT_OPENCL_PLATFORM_ID) list(GET MY_LIST 1 OPENCL_DEFAULT_OPENCL_DEVICE_ID) display(OPENCL_DEFAULT_OPENCL_PLATFORM_ID) display(OPENCL_DEFAULT_OPENCL_DEVICE_ID) +# =========== RPATH stuff =========== +# Doc : +# - https://cmake.org/Wiki/CMake_RPATH_handling +# - https://cmake.org/cmake/help/git-master/manual/cmake-packages.7.html#creating-packages +# - http://matthew-brett.github.io/docosx/mac_runtime_link.html + +# Force MACOSX_RPATH, whatever the cmake version is. +# RPATH management on macosx with cmake is quite a mess, so please +# think hard before changing the following lines ... +set(CMAKE_MACOSX_RPATH 1) + +# don't skip the full RPATH for the build tree +# except if explicitely asked by user +if(FORCE_SKIP_RPATH) + set(CMAKE_SKIP_BUILD_RPATH TRUE) +else() + set(CMAKE_SKIP_BUILD_RPATH FALSE) +endif() + +# when building, don't use the install RPATH already +# (but later on when installing) +set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) +set(CMAKE_INSTALL_RPATH "${HYSOP_PYTHON_INSTALL_DIR}/${PACKAGE_NAME}") + +# add the automatically determined parts of the RPATH +# which point to directories outside the build tree to the install RPATH +set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) # ====== Create (and setup) install/uninstall targets ====== # @@ -200,19 +257,18 @@ include(HySoPInstallSetup) # Remark : this must be done before add_subdir below, since install process in src needs CMAKE_INSTALL_PREFIX # to be properly set. -if(EXISTS ${CMAKE_SOURCE_DIR}/${PYPACKAGE_NAME}/.f2py_f2cmap) - message(STATUS "Generate f2py map file ...") - configure_file(${CMAKE_SOURCE_DIR}/${PYPACKAGE_NAME}/.f2py_f2cmap - ${CMAKE_BINARY_DIR}/.f2py_f2cmap) -endif() -if(EXISTS ${CMAKE_SOURCE_DIR}/${PYPACKAGE_NAME}/f2hysop.pyf.in) - message(STATUS "Generate f2hysop.pyf (f2py main signature file) ...") - configure_file(${CMAKE_SOURCE_DIR}/${PYPACKAGE_NAME}/f2hysop.pyf.in - ${CMAKE_SOURCE_DIR}/${PYPACKAGE_NAME}/f2hysop.pyf) -endif() +if(USE_FORTRAN) + if(EXISTS ${CMAKE_SOURCE_DIR}/${PACKAGE_NAME}/.f2py_f2cmap) + message(STATUS "Generate f2py map file ...") + configure_file(${CMAKE_SOURCE_DIR}/${PACKAGE_NAME}/.f2py_f2cmap + ${CMAKE_BINARY_DIR}/.f2py_f2cmap) + endif() + include(fortran_utils) + # Create f2hysop.pyf file + write_main_pyf_file(f2hysop) + + # ====== Create non-python (fortran) libraries (fftw and scales interfaces), if required ===== -# ====== Create non-python (fortran) libraries (fftw and scales interfaces), if required ===== -if(WITH_LIB_FORTRAN) # Set module files directory (i.e. where .mod will be created) set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/Modules) # Add compilation flags: @@ -220,19 +276,17 @@ if(WITH_LIB_FORTRAN) append_Fortran_FLAGS("-Wall -fPIC -ffree-line-length-none -cpp") if(USE_MPI) - # Find MPI for fortran. - find_package(MPI REQUIRED) # -I include_directories(${MPI_Fortran_INCLUDE_PATH}) # Add compilation/link flags - set(${HYSOP_LIBRARY_NAME}_LINK_FLAGS ${${HYSOP_LIBRARY_NAME}_LINK_FLAGS} ${MPI_Fortran_LINK_FLAGS}) + list(APPEND ${HYSOP_LIBRARY_NAME}_LINK_FLAGS ${MPI_Fortran_LINK_FLAGS}) append_Fortran_flags(${MPI_Fortran_COMPILE_FLAGS}) # Append mpi libraries to the list of libraries linked with libhysop. - set(LIBS ${LIBS} ${MPI_Fortran_LIBRARIES} ) + list(APPEND HYSOP_LINK_LIBRARIES ${MPI_Fortran_LIBRARIES} ) endif(USE_MPI) - set(Fortran_FLAGS ${CMAKE_Fortran_FLAGS}) - append_flags(Fortran_FLAGS ${CMAKE_Fortran_FLAGS_${CMAKE_BUILD_TYPE}}) + #set(Fortran_FLAGS ${CMAKE_Fortran_FLAGS}) + #append_flags(Fortran_FLAGS ${CMAKE_Fortran_FLAGS_${CMAKE_BUILD_TYPE}}) endif() if(WITH_COMPILED_LIB) @@ -278,7 +332,7 @@ endif() set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES ${CMAKE_BINARY_DIR}/build) set(PYTHON_SETUP "${CMAKE_CURRENT_BINARY_DIR}/setup.py") -if(WITH_LIB_FORTRAN) +if(USE_FORTRAN) add_custom_target(python-build ALL COMMAND ${PYTHON_EXECUTABLE} ${PYTHON_SETUP} build config_fc --f90exec=${CMAKE_Fortran_COMPILER} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMENT "build hysop package" @@ -342,6 +396,39 @@ if(WITH_LIB_CXX) endif() endif() +# =========== RPATH stuff =========== +# Doc : +# - https://cmake.org/Wiki/CMake_RPATH_handling +# - https://cmake.org/cmake/help/git-master/manual/cmake-packages.7.html#creating-packages +# - http://matthew-brett.github.io/docosx/mac_runtime_link.html + +# Force MACOSX_RPATH, whatever the cmake version is. +# RPATH management on macosx with cmake is quite a mess, so please +# think hard before changing the following lines ... +set(CMAKE_MACOSX_RPATH 1) + +# don't skip the full RPATH for the build tree +# except if explicitely asked by user +if(FORCE_SKIP_RPATH) + set(CMAKE_SKIP_BUILD_RPATH TRUE) +else() + set(CMAKE_SKIP_BUILD_RPATH FALSE) +endif() + +# when building, don't use the install RPATH already +# (but later on when installing) +set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) +set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${PACKAGE_NAME}") + +# add the automatically determined parts of the RPATH +# which point to directories outside the build tree to the install RPATH +set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) + +# the RPATH to be used when installing, but only if it's not a system directory +list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/${PACKAGE_NAME}" isSystemDir) +if("${isSystemDir}" STREQUAL "-1") + set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${PACKAGE_NAME}") +endif() # ====== Create a Target to clean sources (remove .pyc files) and build dir ====== @@ -372,7 +459,8 @@ endif() if(WITH_TESTS) include(CTest) # Number of mpi processes used to run tests. - set(NBPROCS_FOR_TESTS 8) + set(NBPROCS_FOR_TESTS "8" CACHE STRING "Number of mpi processes used to run tests") + # set(NBPROCS_FOR_TESTS 8) if(NOT USE_MPI) set(WITH_MPI_TESTS "OFF") endif() @@ -382,19 +470,23 @@ endif(WITH_TESTS) # ============= Summary ============= if(VERBOSE_MODE) - message(STATUS "====================== Summary ======================") + message("\n====================== End of configuration process ======================") + message("\n Summary: ") message(STATUS " Python libraries : ${PYTHON_LIBRARIES}") message(STATUS " Python include : ${PYTHON_INCLUDE_DIRS}") message(STATUS " Python version : ${PYTHON_VERSION_STRING}") message(STATUS " Python executable : ${PYTHON_EXECUTABLE}") - message(STATUS " Python user lib : ${PYTHON_LIBRARY}") - message(STATUS " ${PACKAGE_NAME} will be installed in : ${HYSOP_PYTHON_INSTALL_DIR}") + message(STATUS " Install mode is `${HYSOP_INSTALL}` and ${PACKAGE_NAME} will be installed in : ${HYSOP_PYTHON_INSTALL_DIR}") message(STATUS " ${PACKAGE_NAME} will be built in ${HYSOP_BUILD_PYTHONPATH}") - if(WITH_LIB_FORTRAN) + if(USE_FORTRAN) message(STATUS " Fortran compiler : ${CMAKE_Fortran_COMPILER}") + else() + message(WARNING "You deactivate libhysop (fortran) generation. This will disable the fortran interface, including fftw and scales fonctionnalities.") endif() if(WITH_LIB_CXX) message(STATUS " CXX compiler : ${CMAKE_CXX_COMPILER}") + else() + message(WARNING "You deactivate libhysop (cxx) generation. This will disable the Aitken-Schwarz Poisson solver.") endif() message(STATUS " Sources are in : ${CMAKE_SOURCE_DIR}") message(STATUS " Project uses MPI : ${USE_MPI}") @@ -416,4 +508,3 @@ if(VERBOSE_MODE) message("Try to run python -c 'import hysop'. If it fails, add ${HYSOP_PYTHON_INSTALL_DIR} to PYTHONPATH environment variable.") message("Example : \n export PYTHONPATH=${HYSOP_PYTHON_INSTALL_DIR}:\${PYTHONPATH}\n") endif() - diff --git a/HySoP/hysop/__init__.py.in b/HySoP/hysop/__init__.py.in index 134f6a8d48e8d1f8ba7975f8c3ed119e7d06864c..e97188c9404012573229c41bbbc0f1a2c9d389a2 100755 --- a/HySoP/hysop/__init__.py.in +++ b/HySoP/hysop/__init__.py.in @@ -3,9 +3,6 @@ on hybrid architectures (MPI-GPU) """ -__version__ = 1.00 -__all__ = ['Box', 'Field'] - # Compilation flags __MPI_ENABLED__ = "@USE_MPI@" is "ON" __GPU_ENABLED__ = "@WITH_GPU@" is "ON" @@ -16,18 +13,49 @@ __DEBUG__ = "@DEBUG@" in ["2", "3"] __PROFILE__ = "@PROFILE@" in ["0", "1"] __OPTIMIZE__ = "@OPTIM@" is "ON" -## import hysop.tools.io_utils as io -default_path = 'toto' #io.IO.default_path() -msg_start = '\nStarting @PACKAGE_NAME@ (no mpi) version ' -msg_start += str(__version__) +from hysop.tools.sys_utils import SysUtils +# Box-type physical domain +from hysop.domain.box import Box +# Fields +from hysop.fields.continuous import Field +# Variable parameters +from hysop.fields.variable_parameter import VariableParameter +# Simulation parameters +from hysop.problem.simulation import Simulation +# Tools (io, mpi ...) +from hysop.tools.io_utils import IO +from hysop.tools.parameters import IOParams, MPIParams, Discretization +import hysop.mpi +# Problem +from hysop.problem.problem import Problem +# Solver +# import particular_solvers.basic +# ## #import particular_solvers.gpu +# ParticleSolver = particular_solvers.basic.ParticleSolver +# ## #GPUParticleSolver = particular_solvers.gpu.GPUParticleSolver +## from tools.explore_hardware import explore + + +__all__ = ['Box', 'Field', 'Discretization', + 'IOParams', 'Simulation', 'MPIParams', 'Problem', 'IO'] + +if SysUtils.is_interactive(): + # Set i/o default path to current directory + # for interactive sessions + # i.e. python interactive session or any call of ipython. + defpath = os.path.join(os.getcwd(), 'interactive') + IO.set_default_path(defpath) + +default_path = IO.default_path() +msg_start = '\nStarting @PACKAGE_NAME@ version ' +msg_start += str("@HYSOP_VERSION@") msg_io = '\nWarning : default path for all i/o is ' + default_path + '.\n' msg_io += 'If you want to change this, use io.set_default_path function.\n' # MPI if __MPI_ENABLED__: - import hysop.mpi as mpi if mpi.main_rank == 0: - msg_start += ' on ' + str(mpi.main_size) + ' mpi process(es).' + msg_start += ' with ' + str(mpi.main_size) + ' mpi process(es).' print msg_start print msg_io @@ -41,39 +69,3 @@ __DEFAULT_DEVICE_ID__ = @OPENCL_DEFAULT_OPENCL_DEVICE_ID@ version = "1.0.0" -# Box-type physical domain -import hysop.domain.box -Box = hysop.domain.box.Box - -# Fields -import hysop.fields.continuous -Field = hysop.fields.continuous.Field - -# Variable parameters -import hysop.fields.variable_parameter -VariableParameter = hysop.fields.variable_parameter.VariableParameter - -# Simulation parameters -import hysop.problem.simulation -Simulation = hysop.problem.simulation.Simulation - -# Tools (io, mpi ...) -import hysop.tools.parameters -IOParams = hysop.tools.parameters.IOParams -MPIParams = hysop.tools.parameters.MPIParams -Discretization = hysop.tools.parameters.Discretization - -# ## ## Problem -# import problem.problem -# Problem = problem.problem.Problem - - -# ## ## Solver -# import particular_solvers.basic -# ## #import particular_solvers.gpu -# ParticleSolver = particular_solvers.basic.ParticleSolver -# ## #GPUParticleSolver = particular_solvers.gpu.GPUParticleSolver - - -## from tools.explore_hardware import explore - diff --git a/HySoP/hysop/domain/tests/test_box.py b/HySoP/hysop/domain/tests/test_box.py old mode 100644 new mode 100755 index f23e357d3558f4ffb5e6abce6164fe5ef25b3dde..d9ab03cd0075118da370971ed1b1b04e54a78d9f --- a/HySoP/hysop/domain/tests/test_box.py +++ b/HySoP/hysop/domain/tests/test_box.py @@ -141,15 +141,3 @@ def test_topo_from_mesh(): assert (topo.shape == [1, 1, comm_s.Get_size()]).all() elif dom.is_on_task(GPU): assert topo.size == 1 - - -# This may be useful to run mpi tests -if __name__ == "__main__": - test_create_box1() - test_create_box2() - test_create_box3() - test_create_box4() - test_topo_standard() - test_topo_multi_tasks() - test_topo_plane() - test_topo_from_mesh() diff --git a/HySoP/hysop/domain/tests/test_control_box.py b/HySoP/hysop/domain/tests/test_control_box.py old mode 100644 new mode 100755 index 19eac3b1d8b2b46418eba1947c06a46bd3364b03..8feb3b925b4f7e00266eebc15ddd4e44403908f4 --- a/HySoP/hysop/domain/tests/test_control_box.py +++ b/HySoP/hysop/domain/tests/test_control_box.py @@ -203,13 +203,3 @@ def test_cb_3d_fulldomain(): except: res = True assert res - -# This may be useful to run mpi tests -if __name__ == "__main__": - test_cb_3d() - test_cb_3d_2() - test_cb_3d_3() - test_cb_2d() - test_cb_2d_2() - test_cb_2d_3() - test_cb_3d_fulldomain() diff --git a/HySoP/hysop/domain/tests/test_mesh.py b/HySoP/hysop/domain/tests/test_mesh.py old mode 100644 new mode 100755 index d93cf7362ea5bada82f9b01a39937a97045a9ce0..0ae2b4868b213a6358f65b93656c441287e3b0dd --- a/HySoP/hysop/domain/tests/test_mesh.py +++ b/HySoP/hysop/domain/tests/test_mesh.py @@ -172,13 +172,3 @@ def test_integ_3d(): vol = np.prod(dom.length) if main_rank == 0: assert np.abs(il - vol) < tol - -if __name__ == '__main__': - test_mesh3d() - test_mesh3d_ghost() - test_mesh2d() - test_mesh2d_ghost() - test_convert_local() - test_convert_global() - test_integ_2d() - test_integ_3d() diff --git a/HySoP/hysop/domain/tests/test_porous.py b/HySoP/hysop/domain/tests/test_porous.py old mode 100644 new mode 100755 index b813c1d7b5a8140b50692eac9faa6e018da5bc37..3ae7c79c9d72dc47bc3d661176c46ee86523b03f --- a/HySoP/hysop/domain/tests/test_porous.py +++ b/HySoP/hysop/domain/tests/test_porous.py @@ -212,28 +212,3 @@ def test_ringpole_sphere_2d(): def test_ringpole_hemisphere_2d(): assert_ringpole(d2d, HemiSphere, 'ringpole_hemisphere_2d') - -# This may be useful to run mpi tests -if __name__ == "__main__": - test_porous_sphere_3d() - test_porous_hemisphere_3d() - test_porous_cylinder_3d() - test_porous_hemicylinder_3d() - test_porous_sphere_2d() - test_porous_hemisphere_2d() - test_bipole_sphere_3d() - test_bipole_hemisphere_3d() - test_bipole_cylinder_3d() - test_bipole_hemicylinder_3d() - test_bipole_sphere_2d() - test_bipole_hemisphere_2d() - test_quadripole_sphere_3d() - test_quadripole_hemisphere_3d() - test_ring_sphere_3d() - test_ring_hemisphere_3d() - test_ring_sphere_2d() - test_ring_hemisphere_2d() - test_ringpole_sphere_3d() - test_ringpole_hemisphere_3d() - test_ringpole_sphere_2d() - test_ringpole_hemisphere_2d() diff --git a/HySoP/hysop/domain/tests/test_regular_subset.py b/HySoP/hysop/domain/tests/test_regular_subset.py old mode 100644 new mode 100755 index da1b44652d5184dca3bb496bc68251a094d431b5..f20de501d21ede246456ed100600a1b7ca40857a --- a/HySoP/hysop/domain/tests/test_regular_subset.py +++ b/HySoP/hysop/domain/tests/test_regular_subset.py @@ -216,16 +216,3 @@ def test_full2d_in3d(): assert (np.abs(i1 - vref) < 1e-6).all() print topo print cub.mesh[topo].iCompute - -# This may be useful to run mpi tests -if __name__ == "__main__": - test_subbox() - test_integ() - test_integ_2() - test_integ_3() - test_subbox_2d() - test_line() - test_2d_subbox() - test_2d_line() - test_integ_fulldom() - test_integ_fulldom_2d() diff --git a/HySoP/hysop/domain/tests/test_submesh.py b/HySoP/hysop/domain/tests/test_submesh.py old mode 100644 new mode 100755 index 86ac5284d54b4b67c3c8dee7288823bf7c90209c..5df5aeb85977417cb2f1e1c2645d6378521af08d --- a/HySoP/hysop/domain/tests/test_submesh.py +++ b/HySoP/hysop/domain/tests/test_submesh.py @@ -139,9 +139,3 @@ def test_integ_3d(): vol = np.prod(subm.global_length) if main_rank == 0: assert np.abs(il - vol) < tol - -if __name__ == '__main__': - test_submesh_3d() - test_submesh_2d() - test_integ_2d() - test_integ_3d() diff --git a/HySoP/hysop/domain/tests/test_subset.py b/HySoP/hysop/domain/tests/test_subset.py old mode 100644 new mode 100755 index 0b11f5288725e28b070e7f4049f5615a4462738e..5faf5e19ec3d871219e0088b643d1dbf380594a4 --- a/HySoP/hysop/domain/tests/test_subset.py +++ b/HySoP/hysop/domain/tests/test_subset.py @@ -189,18 +189,3 @@ def test_subtract_list_3d(): def test_subtract_list_2d(): assert init_subtract_lists(discr2D, 'multi_obst_subslist_2d') - -# This may be useful to run mpi tests -if __name__ == "__main__": - test_sphere_3d() - test_hemisphere_3d() - test_cylinder_3d() - test_hemicylinder_3d() - test_sphere_2d() - test_hemisphere_2d() - test_union_2d() - test_union_3d() - test_subtract_3d() - test_subtract_2d() - test_subtract_list_3d() - test_subtract_list_2d() diff --git a/HySoP/hysop/f2hysop.pyf.in b/HySoP/hysop/f2hysop.pyf.in old mode 100644 new mode 100755 index 02ea4c3f685efa9780dcf76cef09a6b55d9a3fb5..a11194e7df7e5f7f02bb55b202ff01bf3faa85e9 --- a/HySoP/hysop/f2hysop.pyf.in +++ b/HySoP/hysop/f2hysop.pyf.in @@ -1,18 +1,20 @@ - ! -*- f90 -*- - ! Note: the context of this file is case sensitive. - - python module f2hysop ! in - interface - ! Example - include '@CMAKE_SOURCE_DIR@/hysop/fortran/template.pyf' - ! precision - include '@CMAKE_SOURCE_DIR@/hysop/f2py/parameters.pyf' - ! fftw - include '@CMAKE_SOURCE_DIR@/hysop/f2py/fftw2py.pyf' - ! scales - include '@CMAKE_SOURCE_DIR@/hysop/f2py/scales2py.pyf' - ! Arnoldi - include '@CMAKE_SOURCE_DIR@/hysop/fortran/arnoldi2py.pyf' +! -*- f90 -*- + +! Generated file - Do not edit. + +! Note: the context of this file is case sensitive. +python module f2hysop ! in + + interface + ! Example + include '@CMAKE_SOURCE_DIR@/hysop/fortran/template.pyf' + ! precision + include '@CMAKE_SOURCE_DIR@/hysop/f2py/parameters.pyf' + ! fftw + include '@CMAKE_SOURCE_DIR@/hysop/f2py/fftw2py.pyf' + ! scales + include '@CMAKE_SOURCE_DIR@/hysop/f2py/scales2py.pyf' end interface -end python module f2hysop + +end python module f2hysop \ No newline at end of file diff --git a/HySoP/hysop/f2py/fftw2py.pyf b/HySoP/hysop/f2py/fftw2py.pyf index 3153e51b9c80f7ba98960bebb9378050867e2e50..a9a833e88b45bf33d735acac589a49ce3fa8f314 100644 --- a/HySoP/hysop/f2py/fftw2py.pyf +++ b/HySoP/hysop/f2py/fftw2py.pyf @@ -3,7 +3,7 @@ module fftw2py ! in fftw2py.f90 use fft3d - use mpi + !use mpi use client_data use hysopparam use fft2d diff --git a/HySoP/hysop/fields/tests/test_field.py b/HySoP/hysop/fields/tests/test_field.py old mode 100644 new mode 100755 index 1817cfedb2df94e2c2f66a3093c80000b9ac649a..b5181bbd26db39de1929e14bf3630b9da6ccef93 --- a/HySoP/hysop/fields/tests/test_field.py +++ b/HySoP/hysop/fields/tests/test_field.py @@ -341,19 +341,3 @@ def test_analytical_field_10(): assert allclose(cafd2[i], refd2.data[i]) assert allclose(cafd[i], refd.data[i]) assert id(cafd2.data[i]) == ids[i] - - -# This may be useful to run mpi tests -if __name__ == "__main__": - test_continuous() - test_analytical() - test_analytical_reset() - test_discretization() - test_analytical_field_1() - test_analytical_field_2() - test_analytical_field_3() - test_analytical_field_4() - test_analytical_field_5() - test_analytical_field_6() - test_analytical_field_7() - test_analytical_field_8() diff --git a/HySoP/hysop/fields/tests/test_variable.py b/HySoP/hysop/fields/tests/test_variable.py old mode 100644 new mode 100755 index 61294b96002f81af98a8212a9874b1b688257260..40e66eafd3a29a9c27e35f6899e662151e0f978e --- a/HySoP/hysop/fields/tests/test_variable.py +++ b/HySoP/hysop/fields/tests/test_variable.py @@ -47,10 +47,3 @@ def test_time_var2(): simu.advance() var.update(simu) assert np.allclose(var['alpha'], [sin(0.1), cos(0.1)]) - - -# This may be useful to run mpi tests -if __name__ == "__main__": - test_constant_var() - test_time_var() - test_time_var2() diff --git a/HySoP/hysop/fortran/arnoldi2py.f90 b/HySoP/hysop/fortran/arnoldi2py.f90 deleted file mode 100644 index 0b2ef50382a783576ada31b2c591c7e4f8c8c285..0000000000000000000000000000000000000000 --- a/HySoP/hysop/fortran/arnoldi2py.f90 +++ /dev/null @@ -1,29 +0,0 @@ -!> @file arnoldi2py.f90 -!! Fortran to python interface file. - -!> Interface to Arnoldi algorithm -module arnoldi2py - -! use client_data - use hysopparam - use arnoldi - use mpi - implicit none - -contains - - !> Arnoldi algorithm: solve eigen-problems for global linear stability analysis - !! @param[in] number of snapshots (i.e. dimension of the Krylov basis) - !! @param[in] solutions (snapshots as input and eigen-functions as output) - !! @param[inout] work array. Input: empty array - subroutine execute_arnoldi(solutions,ncli,ntot,nfp,nmodes,Tps) - - integer, intent(in) :: ncli, ntot, nfp, nmodes - real(pk), intent(in) :: Tps - real(pk), dimension(:,:), intent(inout) :: solutions - - call arnoldi3d(solutions,ncli,ntot,nfp,nmodes,Tps) - - end subroutine execute_arnoldi - -end module arnoldi2py diff --git a/HySoP/hysop/fortran/arnoldi2py.pyf b/HySoP/hysop/fortran/arnoldi2py.pyf index e82d95b29f89b134d6d5ddbf6ba0e3c37d89f3c8..6de3250e8665d2c260478dcd69baabd939ca45e4 100644 --- a/HySoP/hysop/fortran/arnoldi2py.pyf +++ b/HySoP/hysop/fortran/arnoldi2py.pyf @@ -5,15 +5,12 @@ module arnoldi2py ! in arnoldi2py.f90 use arnoldi use hysopparam use mpi - subroutine execute_arnoldi(solutions,ncli,ntot,nfp,nmodes,tps) ! in arnoldi2py.f90:arnoldi2py + subroutine arnoldi3d(solutions,ncli,ntot,nfp,nmodes,tps) ! in arnoldi2py.f90:arnoldi2py real(kind=pk) dimension(:,:),intent(inout) :: solutions integer intent(in) :: ncli integer intent(in) :: ntot integer intent(in) :: nfp integer intent(in) :: nmodes real(kind=pk) intent(in) :: tps - end subroutine execute_arnoldi + end subroutine arnoldi3d end module arnoldi2py - -! This file was auto-generated with f2py (version:2). -! See http://cens.ioc.ee/projects/f2py2e/ diff --git a/HySoP/hysop/gpu/tests/test_gpu_multiresolution_filter.py b/HySoP/hysop/gpu/tests/test_gpu_multiresolution_filter.py old mode 100644 new mode 100755 index 2405503763076604628a99ccd5dcc331d1cfb4f1..4c87351fb8440d1a13bf9cdc9b56bf46be9e26ab --- a/HySoP/hysop/gpu/tests/test_gpu_multiresolution_filter.py +++ b/HySoP/hysop/gpu/tests/test_gpu_multiresolution_filter.py @@ -126,7 +126,3 @@ def test_filter_L2_1(): f_out[0][topo_coarse.mesh.iCompute]), \ np.max(np.abs(valid[0][topo_coarse.mesh.iCompute] - f_out[0][topo_coarse.mesh.iCompute])) - -if __name__ == '__main__': - test_filter_linear() - test_filter_L2_1() diff --git a/HySoP/hysop/gpu/tests/test_multiphase_baroclinic.py b/HySoP/hysop/gpu/tests/test_multiphase_baroclinic.py old mode 100644 new mode 100755 index aa75f8614728f087e5c58a3eda42df7f648367bc..fbfd41963c69b5dc16748dbf2fbf4adaa2fa7569 --- a/HySoP/hysop/gpu/tests/test_multiphase_baroclinic.py +++ b/HySoP/hysop/gpu/tests/test_multiphase_baroclinic.py @@ -131,7 +131,3 @@ def call_operator(func, grad_func, vfunc): assert np.allclose(d_rhs[2] / max_val[2], d_true_rhs[2] / max_val[2], atol=1e-8 if HYSOP_REAL != np.float32 else 5e-4) - -if __name__ == '__main__': - test_baroclinic_rhs() - test_baroclinic_rhs_nonperiodic() diff --git a/HySoP/hysop/mpi/tests/test_bridge.py b/HySoP/hysop/mpi/tests/test_bridge.py old mode 100644 new mode 100755 index 0621466c23680c0181c82c2c6a445d8aebbb20b0..ac28390f78740971e8d358a21221fe7596e7fdbd --- a/HySoP/hysop/mpi/tests/test_bridge.py +++ b/HySoP/hysop/mpi/tests/test_bridge.py @@ -120,10 +120,3 @@ def test_bridgeInter3D(): bridge2 = BridgeInter(topo1, main_comm, source_id=GPU, target_id=CPU) assert bridge2 is not None - -if __name__ == '__main__': - test_bridge2D() - test_bridge3D() - test_bridge_overlap() - test_bridgeInter2D() - test_bridgeInter3D() diff --git a/HySoP/hysop/mpi/tests/test_topology.py b/HySoP/hysop/mpi/tests/test_topology.py old mode 100644 new mode 100755 index 23e6fcb0095075e99cbee9ae29a5123900e21afb..2b22daa48d909d40f3b286063d198637ffdd6677 --- a/HySoP/hysop/mpi/tests/test_topology.py +++ b/HySoP/hysop/mpi/tests/test_topology.py @@ -250,18 +250,3 @@ def test_operator_equal(): # test not equal ... assert topo2 != topo3 - -if __name__ == "__main__": - test_create_default_topology_2d() - test_create_default_topology2_2d() - test_create_topologyFromDim_2d() - test_create_topologyFromShape_2d() - test_create_topologyFromCutdir_2d() - test_create_planetopology_2d() - test_create_default_topology() - test_create_default_topology2() - test_create_topologyFromDim() - test_create_topologyFromShape() - test_create_topologyFromCutdir() - test_create_planetopology() - test_operator_equal() diff --git a/HySoP/hysop/numerics/tests/test_diffOp.py b/HySoP/hysop/numerics/tests/test_diffOp.py index 50c1e59b251a5aa4b196fc460c72ea8b4744e30a..529542e012b024bd7dd0f7144a96affa79c4f156 100755 --- a/HySoP/hysop/numerics/tests/test_diffOp.py +++ b/HySoP/hysop/numerics/tests/test_diffOp.py @@ -220,13 +220,3 @@ def test_div_advection(): errx = (topo3.domain.length[0] / (Nx - 1)) ** 4 assert np.allclose(rd[0][ic3], result[0][ic3], rtol=errx) - -if __name__ == "__main__": - test_curl() - test_curl_2d() - test_div_rho_v_2d() - test_div_rho_v() - test_laplacian() - test_divwv() - test_grad_vxw() - test_div_advection() diff --git a/HySoP/hysop/numerics/tests/test_update_ghosts.py b/HySoP/hysop/numerics/tests/test_update_ghosts.py old mode 100644 new mode 100755 index 694b27c0c931d7d67f67c65e779eeb359effebb3..e1970b2f39c3904a984f5e760d2b9e07dcab6654 --- a/HySoP/hysop/numerics/tests/test_update_ghosts.py +++ b/HySoP/hysop/numerics/tests/test_update_ghosts.py @@ -152,18 +152,3 @@ def test_update_ghosts_full_3D(): update(df.data) verify_full(df, gh) - -if __name__ == '__main__': - for f in (test_update_ghosts_simple_1D, - test_update_ghosts_simple_2D, - test_update_ghosts_simple_3D, - test_update_ghosts_1D, - test_update_ghosts_2D, - test_update_ghosts_3D, - test_update_ghosts_full_simple_1D, - test_update_ghosts_full_simple_2D, - test_update_ghosts_full_simple_3D, - test_update_ghosts_full_1D, - test_update_ghosts_full_2D, - test_update_ghosts_full_3D): - f() diff --git a/HySoP/hysop/operator/adapt_timestep.py b/HySoP/hysop/operator/adapt_timestep.py index 0079aa1eb6c29f4f82846e05cfcef484cf790c23..6a60e1ef2b52071ae28dbe2b6e410d56b7f3a5b6 100755 --- a/HySoP/hysop/operator/adapt_timestep.py +++ b/HySoP/hysop/operator/adapt_timestep.py @@ -64,7 +64,7 @@ class AdaptTimeStep(Computational): #assert 'dt' in self.dt_adapt.data self.input = self.variables - self.output = [self.vorticity] + self.output = [] self.time_range = time_range self.lcfl, self.cfl, self.maxdt = lcfl, cfl, maxdt self._intercomms = {} diff --git a/HySoP/hysop/operator/discrete/adapt_timestep.py b/HySoP/hysop/operator/discrete/adapt_timestep.py index 90bc6e15d347f36e897b09cdb387a2f67433cbe5..ccbc65d7ebdd5d83ded8df108d3d1a27181745ed 100755 --- a/HySoP/hysop/operator/discrete/adapt_timestep.py +++ b/HySoP/hysop/operator/discrete/adapt_timestep.py @@ -1,7 +1,5 @@ # -*- coding: utf-8 -*- """ -@file operator/discrete/adapt_timestep.py - Evaluation of the adaptative time step according to the flow fields. """ @@ -53,7 +51,7 @@ class AdaptTimeStep_D(DiscreteOperator): **kwds) self.input = self.variables - self.output = [self.vorticity] + self.output = [] ## Courant Fredrich Levy coefficient self.cfl = cfl ## Lagrangian CFL coefficient diff --git a/HySoP/hysop/operator/discrete/drag_and_lift.py b/HySoP/hysop/operator/discrete/drag_and_lift.py index a95d72bde2a003a7969e08a1c169e34e358f2e87..21f3fb77e23572376f05156704be4c3ddfa4c49f 100644 --- a/HySoP/hysop/operator/discrete/drag_and_lift.py +++ b/HySoP/hysop/operator/discrete/drag_and_lift.py @@ -307,10 +307,7 @@ class NocaForces(Forces): # So if you need computation in x and z directions, # surfdir = [0, 1, 4, 5] self._surfdir = surfdir - # buffer used to compute d/dt velocity - # see integrate_gamma_mom - self._previous_sum_u = npw.zeros(2 * self._dim) - + # buffers used to compute d/dt velocity self._previous_velo = [None] * self._dim * 2 * self._dim self._surf_buffer = None self._init_surf_buffers() @@ -355,32 +352,6 @@ class NocaForces(Forces): """ pass - def _allocate_rwork(self, rwork=None): - """Set or check rwork. - - rwork will be required only in formulations where - an integral over the volume of the control box is computed, - Noca I and Noca II. - """ - # !!! Velocity must be set before a call to this function - # and so before base class initialization !!! - - # The only required buffer if for integral on the volume - # of control. - toporef = self.velocity.topology - v_ind = self._voc.mesh[toporef].ind4integ - shape_v = self.velocity.data[0][v_ind].shape - # setup for rwork, iwork is useless. - if rwork is None: - # --- Local allocation --- - self._rwork = [npw.zeros(shape_v)] - else: - assert isinstance(rwork, list), 'rwork must be a list.' - # --- External rwork --- - self._rwork = rwork - assert len(self._rwork) == 1 - assert self._rwork[0].shape == shape_v - def _init_surf_buffers(self): """Allocate memory for local buffers (used to compute time derivative of the velocity on the surfaces of @@ -524,7 +495,30 @@ class NocaI(NocaForces): """Noca, "Impulse Equation" from Noca99 """ def _set_work_arrays(self, rwork=None, iwork=None): - self._allocate_rwork(rwork) + """Set or check rwork. + + rwork will be required only in formulations where + an integral over the volume of the control box is computed, + Noca I and Noca II. + """ + # !!! Velocity must be set before a call to this function + # and so before base class initialization !!! + + # The only required buffer if for integral on the volume + # of control. + toporef = self.velocity.topology + v_ind = self._voc.mesh[toporef].ind4integ + shape_v = self.velocity.data[0][v_ind].shape + # setup for rwork, iwork is useless. + if rwork is None: + # --- Local allocation --- + self._rwork = [npw.zeros(shape_v)] + else: + assert isinstance(rwork, list), 'rwork must be a list.' + # --- External rwork --- + self._rwork = rwork + assert len(self._rwork) == 1 + assert self._rwork[0].shape == shape_v def _noca(self, dt): """ @@ -574,9 +568,6 @@ class NocaI(NocaForces): class NocaII(NocaForces): - def _set_work_arrays(self, rwork=None, iwork=None): - self._allocate_rwork(rwork) - def _init_surf_buffers(self): """Allocate memory for local buffers (used to compute time derivative of the velocity on the surfaces of diff --git a/HySoP/hysop/operator/penalization.py b/HySoP/hysop/operator/penalization.py index 81b451ef8960972617c235ec49c7fa85c8f0b55d..2cabff25dfc17f6885c3aa148dd4b6bce23052f4 100644 --- a/HySoP/hysop/operator/penalization.py +++ b/HySoP/hysop/operator/penalization.py @@ -134,6 +134,8 @@ class PenalizeVorticity(Penalization): self.method = default.DIFFERENTIAL # operator to compute buffer = curl(penalised velocity) self._curl = None + self.input = self.variables + self.output = self.vorticity def discretize(self): diff --git a/HySoP/hysop/operator/tests/test_Stretching.py b/HySoP/hysop/operator/tests/test_Stretching.py index deef2a0222519d7e1ff5038c5f06eafd43725f1d..4b6baa5b095789b8abdf684075ffb7e6f816602e 100755 --- a/HySoP/hysop/operator/tests/test_Stretching.py +++ b/HySoP/hysop/operator/tests/test_Stretching.py @@ -215,8 +215,3 @@ def test_stretching_external_work(): stretch.setup(rwork=rwork) simulation = Simulation(tinit=0, tend=1., timeStep=timeStep) stretch.apply(simulation) - -if __name__ == "__main__": -# test_stretching() -# test_stretching_external_work() - test_stretchingLinearized() diff --git a/HySoP/hysop/operator/tests/test_adaptive_time_step.py b/HySoP/hysop/operator/tests/test_adaptive_time_step.py old mode 100644 new mode 100755 index 6792f4b3a49fa79a2010890c5b90b4f106306896..f1a7eef4000dbd2ac064721d44bdba0dce5ef244 --- a/HySoP/hysop/operator/tests/test_adaptive_time_step.py +++ b/HySoP/hysop/operator/tests/test_adaptive_time_step.py @@ -134,9 +134,3 @@ def test_adapt_4(): refval = simu.timeStep refval = main_comm.bcast(refval, root=0) assert refval == simu.timeStep - -if __name__ == "__main__": - #test_adapt() - #test_adapt_2() - #test_adapt_3() - test_adapt_4() diff --git a/HySoP/hysop/operator/tests/test_advec_scales.py b/HySoP/hysop/operator/tests/test_advec_scales.py index a4d881a538ddc5cb9a00a2fc6cb49c75ce1ace7e..c5e1c5213ada9107853ad1c80e8fb066f6ec10fa 100755 --- a/HySoP/hysop/operator/tests/test_advec_scales.py +++ b/HySoP/hysop/operator/tests/test_advec_scales.py @@ -470,15 +470,3 @@ def test_randomVelocity_vec_m8(): assert np.allclose(scal_ref_d.data[0], scal_d.data[0], atol=1e-07) assert np.allclose(scal_ref_d.data[1], scal_d.data[1], atol=1e-07) assert np.allclose(scal_ref_d.data[2], scal_d.data[2], atol=1e-07) - -if __name__ == "__main__": - test_nullVelocity_m4() - test_nullVelocity_vec_m4() - test_nullVelocity_m6() - test_nullVelocity_vec_m6() - test_nullVelocity_m8() - test_nullVelocity_vec_m8() - test_randomVelocity_m6() - test_randomVelocity_vec_m6() - test_randomVelocity_m8() - test_randomVelocity_vec_m8() diff --git a/HySoP/hysop/operator/tests/test_analytic.py b/HySoP/hysop/operator/tests/test_analytic.py old mode 100644 new mode 100755 index 38315854f7b52f40eac990eed121591eac19f090..3e2878ff9df036410c3aaa5133b153498feffa20 --- a/HySoP/hysop/operator/tests/test_analytic.py +++ b/HySoP/hysop/operator/tests/test_analytic.py @@ -160,10 +160,3 @@ def test_analytical_op_6(): assert allclose(cafd[i], refd.data[i]) assert id(cafd.data[i]) == ids[i] - -if __name__ == "__main__": - test_analytical_op_1() - test_analytical_op_3() - test_analytical_op_4() - test_analytical_op_5() - test_analytical_op_6() diff --git a/HySoP/hysop/operator/tests/test_density.py b/HySoP/hysop/operator/tests/test_density.py old mode 100644 new mode 100755 index be2e412371e9d5c8e4ce5006f6a2fe854a0df5cf..0016e6eedd6796b427483ac17ca796640f4fd5b5 --- a/HySoP/hysop/operator/tests/test_density.py +++ b/HySoP/hysop/operator/tests/test_density.py @@ -28,6 +28,3 @@ def test_density(): viscosity.initialize(topo=topo) # simu = Simulation(nbIter=2) # op.apply(simu) ## --> need to be reviewed - -if __name__ == "__main__": - test_density() diff --git a/HySoP/hysop/operator/tests/test_diff_poisson_3D.py b/HySoP/hysop/operator/tests/test_diff_poisson_3D.py index 1142d2ab764036946f1b2f0e34dd2b9483cbf1a3..d4c9186d1714eda051035d9b0341b24d2112b170 100755 --- a/HySoP/hysop/operator/tests/test_diff_poisson_3D.py +++ b/HySoP/hysop/operator/tests/test_diff_poisson_3D.py @@ -67,6 +67,3 @@ def test_Diff_Poisson(): iterMax=1000000) diffusion.apply(simu) poisson.apply(simu) - -if __name__ == "__main__": - test_Diff_Poisson() diff --git a/HySoP/hysop/operator/tests/test_differential.py b/HySoP/hysop/operator/tests/test_differential.py old mode 100644 new mode 100755 index 5e8c65b66e056a8e3f37f252f147bfe72e50bc4d..7a217638b23f2335873563e391bdc67dc301f9ff --- a/HySoP/hysop/operator/tests/test_differential.py +++ b/HySoP/hysop/operator/tests/test_differential.py @@ -248,21 +248,3 @@ def divadvection_func(res, x, y, z, t): def test_div_advection(): method = {SpaceDiscretisation: FD_C_4} call_op(DivAdvection, divadvection_func, topo3_3d, op_dim=1, method=method) - -# This may be useful to run mpi tests -if __name__ == "__main__": - test_curl_fd_1() - test_curl_fd_2() - test_curl_fd_1_2d() - test_curl_fd_3() - test_curl_fd_3_2d() - test_curl_fft_1() - #test_curl_fft_1_2d() - #test_curl_fft_2() - #test_curl_fft_2_2d() - test_grad_1() - test_grad_2() - test_grad_3() - test_grad_3_2d() - test_curl_fd_work() - test_div_advection() diff --git a/HySoP/hysop/operator/tests/test_diffusion.py b/HySoP/hysop/operator/tests/test_diffusion.py index 8aa9cd45522ad61cbc5da0b9ae3353cd9656bf97..9a493a7b497c4417d89c1aed59b152b0081fd099 100755 --- a/HySoP/hysop/operator/tests/test_diffusion.py +++ b/HySoP/hysop/operator/tests/test_diffusion.py @@ -84,9 +84,3 @@ def test_Diffusion2D(): diff.apply(simu) diff.finalize() - -# This may be useful to run mpi tests -if __name__ == "__main__": - test_Diffusion3D() - test_Diffusion3D_2() - test_Diffusion2D() diff --git a/HySoP/hysop/operator/tests/test_drag_and_lift.py b/HySoP/hysop/operator/tests/test_drag_and_lift.py old mode 100644 new mode 100755 index dfbdb7ba890d6df9972d279bfda2a4209d93c72d..ddda768fcaf51f82aab818df3db66755956c07a1 --- a/HySoP/hysop/operator/tests/test_drag_and_lift.py +++ b/HySoP/hysop/operator/tests/test_drag_and_lift.py @@ -189,12 +189,3 @@ def test_all_drags(): op.apply(simu) simu.advance() #assert False - -# This may be useful to run mpi tests -if __name__ == "__main__": - test_momentum_forces_3d() - test_noca1() - test_noca2() - test_noca3() - test_all_drags() -# test_noca_1_vol() diff --git a/HySoP/hysop/operator/tests/test_energy_enstrophy.py b/HySoP/hysop/operator/tests/test_energy_enstrophy.py old mode 100644 new mode 100755 index 124466d2694b8c8980e758352d7d991872552859..87505acb65773f87b55818fc9c8c5e0cb25f0f29 --- a/HySoP/hysop/operator/tests/test_energy_enstrophy.py +++ b/HySoP/hysop/operator/tests/test_energy_enstrophy.py @@ -82,6 +82,3 @@ def test_energy_enstrophy(): tol = (topo.mesh.space_step).max() ** 2 assert (op.energy() - eref * 0.5) < tol assert (op.enstrophy() - eref) < tol - -if __name__ == "__main__": - test_energy_enstrophy() diff --git a/HySoP/hysop/operator/tests/test_hdf5_io.py b/HySoP/hysop/operator/tests/test_hdf5_io.py old mode 100644 new mode 100755 index c1c0f5ab7bd4ecc68e4bdbd30da19e570288ccbd..0dee976d0007880c4532e38a1b9ac9f1921e1072 --- a/HySoP/hysop/operator/tests/test_hdf5_io.py +++ b/HySoP/hysop/operator/tests/test_hdf5_io.py @@ -387,15 +387,3 @@ def test_write_read_subset_2(): assert not np.allclose(b1.data[d][ind], v3d.data[d][ind]) assert np.allclose(b1.data[d][indsubset], v3d.data[d][indsubset]) - -# This may be useful to run mpi tests -if __name__ == "__main__": - test_write_read_scalar_3D() - test_write_read_scalar_3D_defaults() - test_write_read_vectors_3D_defaults() - test_write_read_vectors_3D() - test_write_read_subset_1() - test_write_read_subset_2() - if main_rank == 0: - shutil.rmtree(IO.default_path()) - purgeFiles() diff --git a/HySoP/hysop/operator/tests/test_multiphase_gradp.py b/HySoP/hysop/operator/tests/test_multiphase_gradp.py old mode 100644 new mode 100755 index 8b4bdf11d2c8c13020c5f38121184a2158feac2a..43aac523e8a34c2008b39e39cb45d688a1096a15 --- a/HySoP/hysop/operator/tests/test_multiphase_gradp.py +++ b/HySoP/hysop/operator/tests/test_multiphase_gradp.py @@ -70,8 +70,3 @@ def test_gradp(): assert np.allclose(d_res[0][iCompute], d_true_res[0][iCompute], atol=8e-3) assert np.allclose(d_res[1][iCompute], d_true_res[1][iCompute], atol=8e-3) assert np.allclose(d_res[2][iCompute], d_true_res[2][iCompute]) - - -if __name__ == '__main__': - #compute_true_res_formula() - test_gradp() diff --git a/HySoP/hysop/operator/tests/test_multiresolution_filter.py b/HySoP/hysop/operator/tests/test_multiresolution_filter.py old mode 100644 new mode 100755 index de4d72cc17cfa8fb13e3f39b2b04d8c175d1244b..6d66f25139a707a4eeb56f71c08dc217da4510c4 --- a/HySoP/hysop/operator/tests/test_multiresolution_filter.py +++ b/HySoP/hysop/operator/tests/test_multiresolution_filter.py @@ -216,19 +216,3 @@ def test_filter_l2_1(): np.max(np.abs(valid[0][topo_coarse.mesh.iCompute] - f_out[0][topo_coarse.mesh.iCompute])) - -if __name__ == '__main__': - if main_size == 1: - # These tests are too small to run un parrallel - test_linear_X() - test_linear_Y() - test_linear_Z() - test_linear_XY() - #order_linear() - test_L21_X() - test_L21_Y() - test_L21_Z() - test_L21_XY() - #order_L21() - test_filter_linear() - test_filter_l2_1() diff --git a/HySoP/hysop/operator/tests/test_particle_advection.py b/HySoP/hysop/operator/tests/test_particle_advection.py old mode 100644 new mode 100755 index e8c0de92618c3fcac96ccd357815311bafdba348..7ca871bea643158b25ffd0d323d2be0b1712ee20 --- a/HySoP/hysop/operator/tests/test_particle_advection.py +++ b/HySoP/hysop/operator/tests/test_particle_advection.py @@ -211,10 +211,3 @@ def test_nullVelocity_dict_3D(): advec = Advection(velocity=velo, variables=scal, discretization=d3d) assert assertion_list(scal.keys(), advec) - -#if __name__ == '__main__': - #test_nullVelocity_2D() - #test_nullVelocity_vector_2D() - #test_nullVelocity_list_2D() - #test_nullVelocity_3D() - #test_nullVelocity_vector_3D() diff --git a/HySoP/hysop/operator/tests/test_penalization.py b/HySoP/hysop/operator/tests/test_penalization.py old mode 100644 new mode 100755 index 4a55ca752d880f0dc14ba806abc1a97571bfa2bc..d26e3b36b168387bb4ebfab20cb0f702a1043ac5 --- a/HySoP/hysop/operator/tests/test_penalization.py +++ b/HySoP/hysop/operator/tests/test_penalization.py @@ -367,16 +367,3 @@ def test_penal_vort_multi_3d(): obstacles={hsphere: [1, 10, 1e8]}) check_penal_vort(penal, wref, vref, vorti, velo) - -if __name__ == "__main__": - test_penal_2d() - test_penal_3d() - test_penal_2d_multi() - test_penal_3d_multi() - test_penal_2d_porous() - test_penal_3d_porous() - test_penal_3d_porous_cyl() - test_penal_vort_3d() - test_penal_vort_2d() - test_penal_vort_multi_2d() - test_penal_vort_multi_3d() diff --git a/HySoP/hysop/operator/tests/test_poisson.py b/HySoP/hysop/operator/tests/test_poisson.py index 30bc1106e39a49b4014d08e90d5a07b7b041f4ee..57de254e06728c022fcb340b5b16e97d870e3b05 100755 --- a/HySoP/hysop/operator/tests/test_poisson.py +++ b/HySoP/hysop/operator/tests/test_poisson.py @@ -298,12 +298,3 @@ def test_Poisson3D_projection_2(): for i in range(dom.dimension): assert np.allclose(vd[i], refD[i]) poisson.finalize() - -# This may be useful to run mpi tests -if __name__ == "__main__": - test_Poisson_Pressure_3D() - test_Poisson3D() - test_Poisson2D() - test_Poisson3D_correction() - test_Poisson3D_projection_1() - test_Poisson3D_projection_2() diff --git a/HySoP/hysop/operator/tests/test_redistribute.py b/HySoP/hysop/operator/tests/test_redistribute.py old mode 100644 new mode 100755 index 9aa4f730bbf0e86f15857a6d18a35619a80a8254..a8bae9037aa321bed99017c317f03e9cfc706cdc --- a/HySoP/hysop/operator/tests/test_redistribute.py +++ b/HySoP/hysop/operator/tests/test_redistribute.py @@ -3,11 +3,10 @@ from hysop.operator.redistribute_inter import RedistributeInter from hysop.operator.redistribute_overlap import RedistributeOverlap #from hysop.mpi.main_var import main_size, main_rank, main_comm from hysop.tools.parameters import Discretization, MPIParams +from hysop import testsenv import hysop as pp import numpy as np -sin = np.sin import math -pi = math.pi from hysop import Simulation from hysop.operator.analytic import Analytic from hysop.mpi.main_var import main_comm, main_size @@ -15,6 +14,9 @@ from hysop.mpi.tests.utils import create_inter_topos, CPU, GPU, OTHER,\ create_multitask_context from hysop.fields.tests.func_for_tests import v3d, v2d, v3dbis from hysop.operator.poisson import Poisson +from hysop.mpi.tests.test_bridge import create_subtopos +sin = np.sin +pi = math.pi dim3 = 3 @@ -79,7 +81,8 @@ def test_distribute_intra_1(): assert np.allclose(vd_2.data[d][ind_ng], wd.data[d][ind_ng]) -def test_distribute_intra_failed_1(): +@testsenv.hysop_failed +def test_distribute_intra_fail_1(): """ redistribute data, intra comm, from one topology to another, no variables -> must fail @@ -91,12 +94,7 @@ def test_distribute_intra_failed_1(): # 3D topo, ghosts default_topo = dom.create_topology(discretization=r_wg) # Redistribute operator - res = False - try: - RedistributeIntra(source=plane_topo, target=default_topo) - except: - res = True - assert res + RedistributeIntra(source=plane_topo, target=default_topo) def test_distribute_intra_2(): @@ -293,7 +291,8 @@ def test_distribute_intra_5(): assert np.allclose(wd.data[d][ind_ng], rd.data[d][ind_ng]) -def test_distribute_intra_failed_4(): +@testsenv.hysop_failed +def test_distribute_intra_fail_4(): """ redistribute data, intra comm, between two operators. """ @@ -321,17 +320,11 @@ def test_distribute_intra_failed_4(): red = RedistributeIntra(source=source, target=target, variables=[velocity]) - res = False - try: - red.setup() - except: - res = True - assert res - -from hysop.mpi.tests.test_bridge import create_subtopos + red.setup() -def test_distribute_failed_5(): +@testsenv.hysop_failed +def test_distribute_fail_5(): """ Try the pathologic case where source and target do not apply on the same group of process but when groups overlap. @@ -349,13 +342,7 @@ def test_distribute_failed_5(): mpi_ref = MPIParams(comm=main_comm) red = RedistributeIntra(source=source_topo, target=target_topo, mpi_params=mpi_ref, variables=[velocity]) - res = False - try: - red.setup() - except: - res = True - - assert res + red.setup() def test_distribute_overlap(): @@ -686,21 +673,3 @@ def test_distribute_inter_2d(): for d in xrange(2): assert np.allclose(wd.data[d], vd.data[d]) - -# This may be useful to run mpi tests -if __name__ == "__main__": - test_distribute_intra_1() - test_distribute_intra_failed_1() - test_distribute_intra_2() - test_distribute_intra_3() - test_distribute_intra_4() - test_distribute_intra_failed_4() - test_distribute_intra_5() - test_distribute_failed_5() - test_distribute_overlap() - test_distribute_inter() - test_distribute_inter_2() - test_distribute_inter_3() - test_distribute_inter_4() - test_distribute_inter_5() - test_distribute_inter_2d() diff --git a/HySoP/hysop/operator/tests/test_velocity_correction.py b/HySoP/hysop/operator/tests/test_velocity_correction.py index e0f2a0905ec33cda080531dfd8d9320d9fe69aa7..34f9629296e17bf8ce4bf90707d993d46c7b95a6 100755 --- a/HySoP/hysop/operator/tests/test_velocity_correction.py +++ b/HySoP/hysop/operator/tests/test_velocity_correction.py @@ -112,8 +112,3 @@ def test_velocity_correction_2D(): sref = op.cb.surf[0] flowrate = sref.integrate_field_allc(velo, topo) assert (np.abs(flowrate - ref_rate) < tol).all() - -# This may be useful to run mpi tests -if __name__ == "__main__": - test_velocity_correction_2D() - test_velocity_correction_3D() diff --git a/HySoP/hysop/tools/sys_utils.py b/HySoP/hysop/tools/sys_utils.py old mode 100644 new mode 100755 index 82cd50c30690c742cd303863448ebc0e2aedd49f..0767cf2bb2e2c5972f03f46111599acfd428021f --- a/HySoP/hysop/tools/sys_utils.py +++ b/HySoP/hysop/tools/sys_utils.py @@ -1,5 +1,6 @@ """Tools related to global config. """ +import sys class SysUtils(object): @@ -8,9 +9,19 @@ class SysUtils(object): """ @staticmethod def in_ipython(): + """True if current session is run under ipython + """ try: __IPYTHON__ except NameError: return False else: return True + + @staticmethod + def is_interactive(): + """True if run under interactive session, else + False. Warning : return true in any case if ipython is + used. + """ + return hasattr(sys, 'ps1') or hasattr(sys, 'ipcompleter') diff --git a/HySoP/hysop/tools/tests/test_parameters.py b/HySoP/hysop/tools/tests/test_parameters.py old mode 100644 new mode 100755 index b67f3e03efa61fa25e7808231bc7d1492ef8908f..f13a18f3b199ebd9809610c5be7145e7a1cecc13 --- a/HySoP/hysop/tools/tests/test_parameters.py +++ b/HySoP/hysop/tools/tests/test_parameters.py @@ -60,7 +60,3 @@ def test_io_params_6(): assert iop.filename == filename assert iop.filepath == os.path.dirname(filename) - -if __name__ == "__main__": - # test 1 is enough ... - test_io_params_1() diff --git a/HySoP/hysop/tools/tests/test_profiler.py b/HySoP/hysop/tools/tests/test_profiler.py old mode 100644 new mode 100755 index 0c324b3eeb90768a8b760f58d924f739cca421cf..5823d1ec20d81e5a6bc4d4853906d023280ce8a8 --- a/HySoP/hysop/tools/tests/test_profiler.py +++ b/HySoP/hysop/tools/tests/test_profiler.py @@ -46,6 +46,3 @@ def test_profilers(): assert a.profiler['call'].n == 2 assert a.profiler['call_other'].n == 1 assert a.profiler['manual'].n == 1 - -if __name__ == '__main__': - test_profilers() diff --git a/HySoP/setup.py.in b/HySoP/setup.py.in index c5ce7c57465a4944d8ea6623189353108bba0d72..dddbc81f6a24f1946806101939510c24056e6de1 100644 --- a/HySoP/setup.py.in +++ b/HySoP/setup.py.in @@ -4,8 +4,10 @@ setup.py file for @PYPACKAGE_NAME@ """ +from setuptools import find_packages from numpy.distutils.core import setup, Extension from numpy.distutils.misc_util import Configuration +from distutils.spawn import find_executable import os import re @@ -17,6 +19,11 @@ import sys sys.path.append('@CMAKE_SOURCE_DIR@/') import sort_f90 +enable_cpp = "@WITH_LIB_CXX@" +if enable_cpp: + swig_executable = find_executable("@SWIG_EXECUTABLE@") + + def parseCMakeVar(var): if var != "": return var.split(';') @@ -41,6 +48,18 @@ def parseCMakeDefines(var): return res +hysop_link_libraries = parseCMakeVar("@HYSOP_LINK_LIBRARIES@") +hysop_link_libraries_names = set([]) +hysop_link_libraries_dirs = set([]) +# use set to avoid dupl. +link_list = "" +for lib in hysop_link_libraries: + hysop_link_libraries_names.add(os.path.basename(lib)) + hysop_link_libraries_dirs.add(os.path.dirname(lib)) + link_list += lib + " " +hysop_link_libraries_names = list(hysop_link_libraries_names) +hysop_link_libraries_dirs = list(hysop_link_libraries_dirs) + def create_fortran_extension(name, pyf_file=None, src_dirs=None, sources=None, libdir=None, libs=None, debug_mode=0): """Create a new f2py module from fortran files @@ -60,6 +79,7 @@ def create_fortran_extension(name, pyf_file=None, src_dirs=None, sources=None, if pyf_file is not None: sources.append(pyf_file) sources = sort_f90.sort(sources) + print "FORTRAN SOURCES : ", sources if debug_mode == 0: options.append(('F2PY_REPORT_ON_ARRAY_COPY', '1')) if os.uname()[0] == 'Linux': @@ -75,7 +95,13 @@ def create_fortran_extension(name, pyf_file=None, src_dirs=None, sources=None, #if(includes != None): #for exti in includes: #inc_dir.append(exti) - + #libs += hysop_link_libraries_names + #libdir += hysop_link_libraries_dirs + print libs + print libdir + # we trust cmake for external libraries and + # add them to linker, without using libraries option + extra_link_args = hysop_link_libraries ext_fort = Extension(name=name, sources=sources, f2py_options=f2py_options, @@ -83,7 +109,8 @@ def create_fortran_extension(name, pyf_file=None, src_dirs=None, sources=None, define_macros=options, library_dirs=libdir, libraries=libs, - extra_f90_compile_args=fortran_flags + extra_f90_compile_args=fortran_flags, + extra_link_args=extra_link_args ) return ext_fort @@ -155,39 +182,41 @@ def create_swig_extension(name, inc_dirs, src_dirs=None, sources=None): # ------------ Set list of packages required to build the module ------------- -# Full package name -name = '@PYPACKAGE_NAME@' # List of modules (directories) to be included -packages = ['hysop', - 'hysop.domain', - 'hysop.fields', - 'hysop.operator', - 'hysop.operator.discrete', - 'hysop.problem', - 'hysop.tools', - 'hysop.numerics', - 'hysop.numerics.integrators', - ] - -packages_for_tests = ['hysop.domain.tests', - 'hysop.fields.tests', - 'hysop.operator.tests', - 'hysop.numerics.tests', - 'hysop.tools.tests', - 'hysop.problem.tests', - 'hysop.numerics.tests', - ] - -if "@USE_MPI@" is "ON": - packages.append('hysop.mpi') - packages_for_tests.append('hysop.mpi.tests') +with_test = "@WITH_TESTS@" is "ON" +if with_test: + packages = find_packages(exclude=["*fakef2py*", "*gpu*"],where="@CMAKE_SOURCE_DIR@") +else: + packages = find_packages(exclude=["*tests*","*fakef2py*", "*gpu*"],where="@CMAKE_SOURCE_DIR@") + +# packages = ['hysop', +# 'hysop.domain', +# 'hysop.fields', +# 'hysop.operator', +# 'hysop.operator.discrete', +# 'hysop.problem', +# 'hysop.tools', +# 'hysop.numerics', +# 'hysop.numerics.integrators', +# ] + +# packages_for_tests = ['hysop.domain.tests', +# 'hysop.fields.tests', +# 'hysop.operator.tests', +# 'hysop.numerics.tests', +# 'hysop.tools.tests', +# 'hysop.problem.tests', +# 'hysop.numerics.tests', +# ] + +# if "@USE_MPI@" is "ON": +# packages.append('hysop.mpi') +# packages_for_tests.append('hysop.mpi.tests') if "@WITH_GPU@" is "ON": packages.append('hysop.gpu') - packages_for_tests.append('hysop.gpu.tests') - -if "@WITH_TESTS@" is "ON": - packages = packages + packages_for_tests + if with_test: + packages.append('hysop.gpu.tests') # Enable this to get debug info DISTUTILS_DEBUG = 1 @@ -197,7 +226,7 @@ DISTUTILS_DEBUG = 1 ext_modules = [] # Check if fortran interface is enabled -enable_fortran = "@WITH_LIB_FORTRAN@" +enable_fortran = "@USE_FORTRAN@" ext = {} if enable_fortran is "ON": @@ -207,14 +236,14 @@ if enable_fortran is "ON": hysoplib = ['@HYSOP_LIBRARY_NAME@'] f2py_options = ['--no-lower'] fortran_src = set([]) + fortran_src.add('f2py/parameters.f90') # -- fftw fortran sources -- withfftw = "@WITH_FFTW@" if withfftw is "ON": - fortran_src.add('f2py/parameters.f90') fortran_src.add('f2py/fftw2py.f90') fftwdir = '@FFTWLIB@' - hysoplib.append('fftw3') - hysoplib.append('fftw3_mpi') + #hysoplib.append('fftw3') + #hysoplib.append('fftw3_mpi') hysop_libdir.append(fftwdir) else: packages.append('hysop.fakef2py') @@ -222,7 +251,6 @@ if enable_fortran is "ON": # -- scales sources -- withscales = '@WITH_SCALES@' if withscales is "ON": - fortran_src.add('f2py/parameters.f90') fortran_src.add('f2py/scales2py.f90') else: packages.append('hysop.fakef2py') @@ -237,8 +265,7 @@ if enable_fortran is "ON": pyf_file = os.path.join(fortran_root, 'f2hysop.pyf') # -- list of directories which contains fortran sources -- # those dirs must be in hysop package directory - subdirs = ['fortran', - ] + subdirs = ['fortran',] num_dirs = [] for sd in subdirs: num_dirs.append(os.path.join(fortran_root, sd)) @@ -265,7 +292,7 @@ else: # --- C++ files and swig interface -- -enable_cpp = "@WITH_LIB_CXX@" + if enable_cpp is "ON": # path to .i files swig_include_dirs = [os.path.join('@CMAKE_SOURCE_DIR@','swig')] @@ -297,8 +324,8 @@ descr = 'Hybrid Computation with Particles.' authors = 'G.H Cottet, J.M Etancelin, J.B Keck, C.Mimeau, F.Pérignon, C. Picard' # authors = 'HySoP development team' config = Configuration( - name=name, - version='@PYPACKAGE_VERSION@', + name='@PACKAGE_NAME@', + version='@HYSOP_VERSION@', description=descr, author=authors, author_email='hysop-members@lists.forge.imag.fr', diff --git a/HySoP/src/CMakeLists.txt b/HySoP/src/CMakeLists.txt index 3fb7e14f8e3738c51f3380d49a9aba54be61158d..5eea76945fb822e3da511063aaf27f35d84576f3 100644 --- a/HySoP/src/CMakeLists.txt +++ b/HySoP/src/CMakeLists.txt @@ -8,89 +8,48 @@ # The list of all dirs containing sources to be compiled for the HySoP lib # Any file in those dirs will be used to create libhysop set(${HYSOP_LIBRARY_NAME}_SRCDIRS - ${CMAKE_CURRENT_SOURCE_DIR} - ) + .) # --- fftw interface --- if(WITH_FFTW) - set(${HYSOP_LIBRARY_NAME}_SRCDIRS - ${${HYSOP_LIBRARY_NAME}_SRCDIRS} ${CMAKE_CURRENT_SOURCE_DIR}/fftw - ) + list(APPEND ${HYSOP_LIBRARY_NAME}_SRCDIRS fftw) endif() + if(WITH_LIB_CXX) - set(${HYSOP_LIBRARY_NAME}_SRCDIRS - ${${HYSOP_LIBRARY_NAME}_SRCDIRS} ${CMAKE_CURRENT_SOURCE_DIR}/hysop++/src - ) + list(APPEND ${HYSOP_LIBRARY_NAME}_SRCDIRS hysop++/src) endif() -#set(SCALES_DIR scalesReduced) -set(SCALES_DIR ${CMAKE_CURRENT_SOURCE_DIR}/scalesInterface) +# --- Choose scales sources location --- +# --> cache var to allow user input +set(SCALES_DIR scalesInterface CACHE FILEPATH "Scales sources location, default=src/scalesInterface") # --- scales --- if(WITH_SCALES) set(${HYSOP_LIBRARY_NAME}_SRCDIRS ${${HYSOP_LIBRARY_NAME}_SRCDIRS} - ${SCALES_DIR}/ + ${SCALES_DIR}/. ${SCALES_DIR}/layout ${SCALES_DIR}/particles ${SCALES_DIR}/particles/advec_line ) endif() -list(APPEND FORTRAN_INCLUDE_DIRS ${${HYSOP_LIBRARY_NAME}_SRCDIRS}) - -# Matching expr for files to be compiled. -set(EXTS *.f90 *.f95 *F90) -# Matching expr for headers (install purpose) -set(EXTS_HDRS *.hpp *.h) -# Note FP : we can also use cmake vars ${CMAKE_Fortran_SOURCE_FILE_EXTENSIONS} ${CMAKE_C_SOURCE_FILE_EXTENSIONS} ${CMAKE_CXX_SOURCE_FILE_EXTENSIONS} - -# ============= The project ============= -# Set project name and project languages -# => this automatically defines: -# - ${HYSOP_LIBRARY_NAME}_BINARY_DIR : where you have run cmake, i.e. the place for compilation -# - ${HYSOP_LIBRARY_NAME}_SOURCE_DIR : where sources (.f and .h and this CMakeLists.txt) are located -# Note that because of OutOfSourceBuild, binary_dir and source_dir must be different. -project(${HYSOP_LIBRARY_NAME} Fortran CXX) - -# ============= Search for libraries ============= -# We search for libraries HySoP depends on and -# set the compile/link conf (-I and -L opt) - -# ============= Prepare compilation ============= - -# Force a default build type if not provided by user -# CMAKE_BUILD_TYPE = empty, Debug, Release, RelWithDebInfo or MinSizeRel. -if (NOT CMAKE_BUILD_TYPE) - set (CMAKE_BUILD_TYPE RELEASE CACHE STRING "Choose the type of build, options are: None, Debug, Release, RelWithDebInfo or MinSizeRel." FORCE) -endif (NOT CMAKE_BUILD_TYPE) - -# Set module files directory (i.e. where .mod will be created) -set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/Modules) -# Add compilation flags: -#append_Fortran_FLAGS("-Wall -fPIC -ffree-line-length-none -DBLOCKING_SEND_PLUS -DBLOCKING_SEND") -append_Fortran_FLAGS("-Wall -fPIC -ffree-line-length-none") - -# --- MPI --- -if(USE_MPI) - # Find MPI for fortran. - find_package(MPI REQUIRED) - # -I - include_directories(${MPI_Fortran_INCLUDE_PATH}) - # Add compilation/link flags - set(${HYSOP_LIBRARY_NAME}_LINK_FLAGS ${${HYSOP_LIBRARY_NAME}_LINK_FLAGS} ${MPI_Fortran_LINK_FLAGS}) - append_Fortran_flags(${MPI_Fortran_COMPILE_FLAGS}) - # Append mpi libraries to the list of libraries linked with libhysop. - set(LIBS ${LIBS} ${MPI_Fortran_LIBRARIES} ) -endif(USE_MPI) - -# --- FFTW --- -if(WITH_FFTW) - include_directories(SYSTEM ${FFTW_INCLUDE_DIRS}) - link_directories(${FFTW_LIBRARY_DIRS}) - add_definitions(${FFTW_DEFINES}) - set(LIBS ${LIBS} ${FFTW_LIBRARIES}) +if(WITH_EXTRAS) + list(APPEND ${HYSOP_LIBRARY_NAME}_SRCDIRS} extras) endif() +# extensions of source files that must be taken into account +get_standard_ext() +set(SRC_EXTS ${ALL_EXTS}) +set(HDR_EXTS *.hpp *.h) +#============= Collect source and header files and create the library ============= + +get_sources("${${HYSOP_LIBRARY_NAME}_SRCDIRS}") +set(${HYSOP_LIBRARY_NAME}_SRCS ${SOURCES_FILES}) +# --- Collect headers --- +# --> set HYSOP_HDRS (for installation) +set(HDRS_DIRS ${${HYSOP_LIBRARY_NAME}_SRCDIRS}) +get_headers("${HDRS_DIRS}") +set(${HYSOP_LIBRARY_NAME}_HDRS ${HDRS_FILES}) # ============= Generates HySoPConfig.hpp ============= # The file HYSOP_LIBRARY_NAME_defines.hpp will be generated from config.hpp.cmake; @@ -99,92 +58,48 @@ if(EXISTS ${CMAKE_SOURCE_DIR}/config.hpp.cmake) include_directories(${CMAKE_BINARY_DIR}) endif() -# ============= Collect source and header files and create the library ============= - -# 1 - We scan all files with matching extension in directories containing sources. -foreach(_DIR ${${HYSOP_LIBRARY_NAME}_SRCDIRS}) - set(_DIR_FILES) - foreach(_EXT ${EXTS}) # Source files - file(GLOB _DIR_FILES_EXT ${_DIR}/${_EXT}) - if(_DIR_FILES_EXT) - list(APPEND ${HYSOP_LIBRARY_NAME}_SRC ${_DIR_FILES_EXT}) - endif() - endforeach() - foreach(_EXT ${EXTS_HDRS}) # Headers - file(GLOB _DIR_FILES_EXT ${_DIR}/${_EXT}) - if(_DIR_FILES_EXT) - list(APPEND ${HYSOP_LIBRARY_NAME}_HDRS ${_DIR_FILES_EXT}) - endif() - endforeach() -endforeach() list(APPEND ${HYSOP_LIBRARY_NAME}_HDRS "hysop_defines.hpp") # We add headers to source files list -list(APPEND ${HYSOP_LIBRARY_NAME}_SRC ${${HYSOP_LIBRARY_NAME}_HDRS}) +list(APPEND ${HYSOP_LIBRARY_NAME}_SRCS ${${HYSOP_LIBRARY_NAME}_HDRS}) -include_directories(${${HYSOP_LIBRARY_NAME}_SRCDIRS}) +# --- include dirs for library --- +# for local headers ... +include_directories(${HDRS_DIRS}) include_directories(${CMAKE_Fortran_MODULE_DIRECTORY}) +# and for headers of external libraries +include_directories(${HYSOP_INCLUDE_DIRECTORIES}) + +add_library(${HYSOP_LIBRARY_NAME} STATIC ${${HYSOP_LIBRARY_NAME}_SRCS}) +target_link_libraries(${HYSOP_LIBRARY_NAME} PRIVATE ${HYSOP_LINK_LIBRARIES}) -# Cmake tools to handle fortran-c interface. It will generate F2CMangle.hpp, a file -# that will contain some useful macros to deal with fortran-C name mangling. -# See cmake doc for this module. -#include(FortranCInterface) -#FortranCInterface_HEADER(${CMAKE_Fortran_MODULE_DIRECTORY}/F2CMangle.hpp -# MACRO_NAMESPACE "F2C_" -# SYMBOL_NAMESPACE "F2C_") -message("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA") -# static library -display(${HYSOP_LIBRARY_NAME}_SRC) -add_library(${HYSOP_LIBRARY_NAME} STATIC ${${HYSOP_LIBRARY_NAME}_SRC}) -target_link_libraries(${HYSOP_LIBRARY_NAME} ${LIBS}) +#install(TARGETS ${HYSOP_LIBRARY_NAME} +# LIBRARY DESTINATION ${HYSOP_PYTHON_INSTALL_DIR}/${PACKAGE_NAME}) # ============= Create an executable linked with libhysop ============= # This part is optional and only useful to test libhysop in a # way that does not depends on python. # At the time it only includes fftw tests. - -if(WITH_FFTW) - # Set the name of a executable file that will be linked with libHYSOP_LIBRARY_NAME. - # Useful to test libhysop in a way that does not depend on python. - set(EXE_NAME ${HYSOP_LIBRARY_NAME}Run) - # A main file to create an executable (test purpose) - # Any files in these dirs will be used to create HySoP exec (linked with libhysop) - set(${EXE_NAME}_SRCDIRS main) - # Source and header files list, to generate a working executable based on libhysop. - foreach(_DIR ${${EXE_NAME}_SRCDIRS}) - set(_DIR_FILES) - foreach(_EXT ${EXTS}) - file(GLOB _DIR_FILES_EXT ${_DIR}/${_EXT}) - if(_DIR_FILES_EXT) - list(APPEND ${EXE_NAME}_SRC ${_DIR_FILES_EXT}) - endif() - endforeach() - foreach(_EXT ${EXTS_HDRS}) - file(GLOB _DIR_FILES_EXT ${_DIR}/${_EXT}) - if(_DIR_FILES_EXT) - list(APPEND ${EXE_NAME}_HDRS ${_DIR_FILES_EXT}) - endif() - endforeach() - endforeach() - list(APPEND ${EXE_NAME}_SRC ${${EXE_NAME}_HDRS}) - include_directories(${${EXE_NAME}_HDRS}) - add_executable(${EXE_NAME} ${${EXE_NAME}_SRC}) - add_dependencies(${EXE_NAME} ${HYSOP_LIBRARY_NAME}) - - # libs to link with EXE_NAME - target_link_libraries(${EXE_NAME} ${HYSOP_LIBRARY_NAME}) - target_link_libraries(${EXE_NAME} ${LIBS}) -endif() - -# ============== Add tests ============== -if(WITH_TESTS) -# message(STATUS "Enable testing ...") -# begin_test(src/tests/F2003) -# new_test(testAllocatedPtr userMod.f90 wrapper.f90 testAllocatedPtr.cxx) -# new_test(testNullPtr userMod.f90 wrapper.f90 testNullPtr.cxx) -# end_test() -# begin_test(src/tests/Particles) -# new_test(testCreate3D testCreate3D.f90) -# new_test(testCreate2D testCreate2D.f90) -# end_test() -endif(WITH_TESTS) +if(WITH_FORTRAN_TESTS) + if(WITH_FFTW) + # Set the name of a executable file that will be linked with libHYSOP_LIBRARY_NAME. + # Useful to test libhysop in a way that does not depend on python. + set(EXE_NAME ${HYSOP_LIBRARY_NAME}Run) + # A main file to create an executable (test purpose) + # Any files in these dirs will be used to create HySoP exec (linked with libhysop) + set(${EXE_NAME}_SRCDIRS main) + # Source and header files list, to generate a working executable based on libhysop. + get_sources("${${EXE_NAME}_SRCDIRS}") + get_headers("${${EXE_NAME}_SRCDIRS}") + set(${EXE_NAME}_SRCS ${SOURCES_FILES}) + set(${EXE_NAME}_HDRS ${HDRS_FILES}) + list(APPEND ${EXE_NAME}_SRC ${${EXE_NAME}_HDRS}) + include_directories(${${EXE_NAME}_HDRS}) + add_executable(${EXE_NAME} ${${EXE_NAME}_SRCS}) + add_dependencies(${EXE_NAME} ${HYSOP_LIBRARY_NAME}) + + # libs to link with EXE_NAME + target_link_libraries(${EXE_NAME} ${HYSOP_LIBRARY_NAME}) + target_link_libraries(${EXE_NAME} ${HYSOP_LINK_LIBRARIES}) + endif() +endif() \ No newline at end of file diff --git a/HySoP/src/arnoldi.f90 b/HySoP/src/extras/arnoldi.f90 similarity index 100% rename from HySoP/src/arnoldi.f90 rename to HySoP/src/extras/arnoldi.f90