diff --git a/HySoP/CMake/FindPythonLibs.cmake b/HySoP/CMake/FindPythonLibs.cmake new file mode 100755 index 0000000000000000000000000000000000000000..af80e2c7daefe7a8563f3f4b31a78d67f47a8f07 --- /dev/null +++ b/HySoP/CMake/FindPythonLibs.cmake @@ -0,0 +1,276 @@ +# - Find python libraries +# This module finds if Python is installed and determines where the +# include files and libraries are. It also determines what the name of +# the library is. This code sets the following variables: +# +# PYTHONLIBS_FOUND - have the Python libs been found +# PYTHON_LIBRARIES - path to the python library +# PYTHON_INCLUDE_PATH - path to where Python.h is found (deprecated) +# PYTHON_INCLUDE_DIRS - path to where Python.h is found +# PYTHON_DEBUG_LIBRARIES - path to the debug library (deprecated) +# PYTHONLIBS_VERSION_STRING - version of the Python libs found (since CMake 2.8.8) +# +# The Python_ADDITIONAL_VERSIONS variable can be used to specify a list of +# version numbers that should be taken into account when searching for Python. +# You need to set this variable before calling find_package(PythonLibs). +# +# If you'd like to specify the installation of Python to use, you should modify +# the following cache variables: +# PYTHON_LIBRARY - path to the python library +# PYTHON_INCLUDE_DIR - path to where Python.h is found + +#============================================================================= +# Copyright 2001-2009 Kitware, Inc. +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +INCLUDE(CMakeFindFrameworks) +# Search for the python framework on Apple. +CMAKE_FIND_FRAMEWORKS(Python) + +SET(_PYTHON1_VERSIONS 1.6 1.5) +SET(_PYTHON2_VERSIONS 2.7 2.6 2.5 2.4 2.3 2.2 2.1 2.0) +SET(_PYTHON3_VERSIONS 3.3 3.2 3.1 3.0) + +IF(PythonLibs_FIND_VERSION) + IF(PythonLibs_FIND_VERSION MATCHES "^[0-9]+\\.[0-9]+(\\.[0-9]+.*)?$") + STRING(REGEX REPLACE "^([0-9]+\\.[0-9]+).*" "\\1" _PYTHON_FIND_MAJ_MIN "${PythonLibs_FIND_VERSION}") + STRING(REGEX REPLACE "^([0-9]+).*" "\\1" _PYTHON_FIND_MAJ "${_PYTHON_FIND_MAJ_MIN}") + UNSET(_PYTHON_FIND_OTHER_VERSIONS) + IF(PythonLibs_FIND_VERSION_EXACT) + IF(_PYTHON_FIND_MAJ_MIN STREQUAL PythonLibs_FIND_VERSION) + SET(_PYTHON_FIND_OTHER_VERSIONS "${PythonLibs_FIND_VERSION}") + ELSE(_PYTHON_FIND_MAJ_MIN STREQUAL PythonLibs_FIND_VERSION) + SET(_PYTHON_FIND_OTHER_VERSIONS "${PythonLibs_FIND_VERSION}" "${_PYTHON_FIND_MAJ_MIN}") + ENDIF(_PYTHON_FIND_MAJ_MIN STREQUAL PythonLibs_FIND_VERSION) + ELSE(PythonLibs_FIND_VERSION_EXACT) + FOREACH(_PYTHON_V ${_PYTHON${_PYTHON_FIND_MAJ}_VERSIONS}) + IF(NOT _PYTHON_V VERSION_LESS _PYTHON_FIND_MAJ_MIN) + LIST(APPEND _PYTHON_FIND_OTHER_VERSIONS ${_PYTHON_V}) + ENDIF() + ENDFOREACH() + ENDIF(PythonLibs_FIND_VERSION_EXACT) + UNSET(_PYTHON_FIND_MAJ_MIN) + UNSET(_PYTHON_FIND_MAJ) + ELSE(PythonLibs_FIND_VERSION MATCHES "^[0-9]+\\.[0-9]+(\\.[0-9]+.*)?$") + SET(_PYTHON_FIND_OTHER_VERSIONS ${_PYTHON${PythonLibs_FIND_VERSION}_VERSIONS}) + ENDIF(PythonLibs_FIND_VERSION MATCHES "^[0-9]+\\.[0-9]+(\\.[0-9]+.*)?$") +ELSE(PythonLibs_FIND_VERSION) + SET(_PYTHON_FIND_OTHER_VERSIONS ${_PYTHON3_VERSIONS} ${_PYTHON2_VERSIONS} ${_PYTHON1_VERSIONS}) +ENDIF(PythonLibs_FIND_VERSION) + +# Set up the versions we know about, in the order we will search. Always add +# the user supplied additional versions to the front. +SET(_Python_VERSIONS + ${Python_ADDITIONAL_VERSIONS} + ${_PYTHON_FIND_OTHER_VERSIONS} + ) + +UNSET(_PYTHON_FIND_OTHER_VERSIONS) +UNSET(_PYTHON1_VERSIONS) +UNSET(_PYTHON2_VERSIONS) +UNSET(_PYTHON3_VERSIONS) + +FOREACH(_CURRENT_VERSION ${_Python_VERSIONS}) + STRING(REPLACE "." "" _CURRENT_VERSION_NO_DOTS ${_CURRENT_VERSION}) + IF(WIN32) + FIND_LIBRARY(PYTHON_DEBUG_LIBRARY + NAMES python${_CURRENT_VERSION_NO_DOTS}_d python + PATHS + [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/libs/Debug + [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/libs/Debug + [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/libs + [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/libs + ) + ENDIF(WIN32) + FIND_LIBRARY(PYTHON_LIBRARY + NAMES + python${_CURRENT_VERSION_NO_DOTS} + python${_CURRENT_VERSION}mu + python${_CURRENT_VERSION}m + python${_CURRENT_VERSION}u + python${_CURRENT_VERSION} + PATHS ENV LD_LIBRARY_PATH ENV DYLD_LIBRARY_PATH +# PATHS +# [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/libs +# [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/libs + # Avoid finding the .dll in the PATH. We want the .lib. + # NO_SYSTEM_ENVIRONMENT_PATH + ) + + # Look for the static library in the Python config directory + FIND_LIBRARY(PYTHON_LIBRARY + NAMES python${_CURRENT_VERSION_NO_DOTS} python${_CURRENT_VERSION} + # Avoid finding the .dll in the PATH. We want the .lib. + NO_SYSTEM_ENVIRONMENT_PATH + # This is where the static library is usually located + PATH_SUFFIXES python${_CURRENT_VERSION}/config + ) + + # For backward compatibility, honour value of PYTHON_INCLUDE_PATH, if + # PYTHON_INCLUDE_DIR is not set. + IF(DEFINED PYTHON_INCLUDE_PATH AND NOT DEFINED PYTHON_INCLUDE_DIR) + SET(PYTHON_INCLUDE_DIR "${PYTHON_INCLUDE_PATH}" CACHE PATH + "Path to where Python.h is found" FORCE) + ENDIF(DEFINED PYTHON_INCLUDE_PATH AND NOT DEFINED PYTHON_INCLUDE_DIR) + + SET(PYTHON_FRAMEWORK_INCLUDES) + IF(Python_FRAMEWORKS AND NOT PYTHON_INCLUDE_DIR) + FOREACH(dir ${Python_FRAMEWORKS}) + SET(PYTHON_FRAMEWORK_INCLUDES ${PYTHON_FRAMEWORK_INCLUDES} + ${dir}/Versions/${_CURRENT_VERSION}/include/python${_CURRENT_VERSION}) + ENDFOREACH(dir) + ENDIF(Python_FRAMEWORKS AND NOT PYTHON_INCLUDE_DIR) + + FIND_PATH(PYTHON_INCLUDE_DIR + NAMES Python.h + PATHS + ${PYTHON_FRAMEWORK_INCLUDES} + [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/include + [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/include + PATH_SUFFIXES + python${_CURRENT_VERSION}mu + python${_CURRENT_VERSION}m + python${_CURRENT_VERSION}u + python${_CURRENT_VERSION} + ) + + # For backward compatibility, set PYTHON_INCLUDE_PATH. + SET(PYTHON_INCLUDE_PATH "${PYTHON_INCLUDE_DIR}") + + IF(PYTHON_INCLUDE_DIR AND EXISTS "${PYTHON_INCLUDE_DIR}/patchlevel.h") + FILE(STRINGS "${PYTHON_INCLUDE_DIR}/patchlevel.h" python_version_str + REGEX "^#define[ \t]+PY_VERSION[ \t]+\"[^\"]+\"") + STRING(REGEX REPLACE "^#define[ \t]+PY_VERSION[ \t]+\"([^\"]+)\".*" "\\1" + PYTHONLIBS_VERSION_STRING "${python_version_str}") + UNSET(python_version_str) + ENDIF(PYTHON_INCLUDE_DIR AND EXISTS "${PYTHON_INCLUDE_DIR}/patchlevel.h") + + IF(PYTHON_LIBRARY AND PYTHON_INCLUDE_DIR) + BREAK() + ENDIF(PYTHON_LIBRARY AND PYTHON_INCLUDE_DIR) +ENDFOREACH(_CURRENT_VERSION) + +MARK_AS_ADVANCED( + PYTHON_DEBUG_LIBRARY + PYTHON_LIBRARY + PYTHON_INCLUDE_DIR +) + +# We use PYTHON_INCLUDE_DIR, PYTHON_LIBRARY and PYTHON_DEBUG_LIBRARY for the +# cache entries because they are meant to specify the location of a single +# library. We now set the variables listed by the documentation for this +# module. +SET(PYTHON_INCLUDE_DIRS "${PYTHON_INCLUDE_DIR}") +SET(PYTHON_DEBUG_LIBRARIES "${PYTHON_DEBUG_LIBRARY}") + +# These variables have been historically named in this module different from +# what SELECT_LIBRARY_CONFIGURATIONS() expects. +SET(PYTHON_LIBRARY_DEBUG "${PYTHON_DEBUG_LIBRARY}") +SET(PYTHON_LIBRARY_RELEASE "${PYTHON_LIBRARY}") +INCLUDE(SelectLibraryConfigurations) +SELECT_LIBRARY_CONFIGURATIONS(PYTHON) +# SELECT_LIBRARY_CONFIGURATIONS() sets ${PREFIX}_FOUND if it has a library. +# Unset this, this prefix doesn't match the module prefix, they are different +# for historical reasons. +UNSET(PYTHON_FOUND) + +INCLUDE(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(PythonLibs + REQUIRED_VARS PYTHON_LIBRARIES PYTHON_INCLUDE_DIRS + VERSION_VAR PYTHONLIBS_VERSION_STRING) + +# PYTHON_ADD_MODULE(<name> src1 src2 ... srcN) is used to build modules for python. +# PYTHON_WRITE_MODULES_HEADER(<filename>) writes a header file you can include +# in your sources to initialize the static python modules +FUNCTION(PYTHON_ADD_MODULE _NAME ) + GET_PROPERTY(_TARGET_SUPPORTS_SHARED_LIBS + GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS) + OPTION(PYTHON_ENABLE_MODULE_${_NAME} "Add module ${_NAME}" TRUE) + OPTION(PYTHON_MODULE_${_NAME}_BUILD_SHARED + "Add module ${_NAME} shared" ${_TARGET_SUPPORTS_SHARED_LIBS}) + + # Mark these options as advanced + MARK_AS_ADVANCED(PYTHON_ENABLE_MODULE_${_NAME} + PYTHON_MODULE_${_NAME}_BUILD_SHARED) + + IF(PYTHON_ENABLE_MODULE_${_NAME}) + IF(PYTHON_MODULE_${_NAME}_BUILD_SHARED) + SET(PY_MODULE_TYPE MODULE) + ELSE(PYTHON_MODULE_${_NAME}_BUILD_SHARED) + SET(PY_MODULE_TYPE STATIC) + SET_PROPERTY(GLOBAL APPEND PROPERTY PY_STATIC_MODULES_LIST ${_NAME}) + ENDIF(PYTHON_MODULE_${_NAME}_BUILD_SHARED) + + SET_PROPERTY(GLOBAL APPEND PROPERTY PY_MODULES_LIST ${_NAME}) + ADD_LIBRARY(${_NAME} ${PY_MODULE_TYPE} ${ARGN}) +# TARGET_LINK_LIBRARIES(${_NAME} ${PYTHON_LIBRARIES}) + + IF(PYTHON_MODULE_${_NAME}_BUILD_SHARED) + SET_TARGET_PROPERTIES(${_NAME} PROPERTIES PREFIX "${PYTHON_MODULE_PREFIX}") + IF(WIN32 AND NOT CYGWIN) + SET_TARGET_PROPERTIES(${_NAME} PROPERTIES SUFFIX ".pyd") + ENDIF(WIN32 AND NOT CYGWIN) + ENDIF(PYTHON_MODULE_${_NAME}_BUILD_SHARED) + + ENDIF(PYTHON_ENABLE_MODULE_${_NAME}) +ENDFUNCTION(PYTHON_ADD_MODULE) + +FUNCTION(PYTHON_WRITE_MODULES_HEADER _filename) + + GET_PROPERTY(PY_STATIC_MODULES_LIST GLOBAL PROPERTY PY_STATIC_MODULES_LIST) + + GET_FILENAME_COMPONENT(_name "${_filename}" NAME) + STRING(REPLACE "." "_" _name "${_name}") + STRING(TOUPPER ${_name} _nameUpper) + SET(_filename ${CMAKE_CURRENT_BINARY_DIR}/${_filename}) + + SET(_filenameTmp "${_filename}.in") + FILE(WRITE ${_filenameTmp} "/*Created by cmake, do not edit, changes will be lost*/\n") + FILE(APPEND ${_filenameTmp} +"#ifndef ${_nameUpper} +#define ${_nameUpper} + +#include <Python.h> + +#ifdef __cplusplus +extern \"C\" { +#endif /* __cplusplus */ + +") + + FOREACH(_currentModule ${PY_STATIC_MODULES_LIST}) + FILE(APPEND ${_filenameTmp} "extern void init${PYTHON_MODULE_PREFIX}${_currentModule}(void);\n\n") + ENDFOREACH(_currentModule ${PY_STATIC_MODULES_LIST}) + + FILE(APPEND ${_filenameTmp} +"#ifdef __cplusplus +} +#endif /* __cplusplus */ + +") + + + FOREACH(_currentModule ${PY_STATIC_MODULES_LIST}) + FILE(APPEND ${_filenameTmp} "int ${_name}_${_currentModule}(void) \n{\n static char name[]=\"${PYTHON_MODULE_PREFIX}${_currentModule}\"; return PyImport_AppendInittab(name, init${PYTHON_MODULE_PREFIX}${_currentModule});\n}\n\n") + ENDFOREACH(_currentModule ${PY_STATIC_MODULES_LIST}) + + FILE(APPEND ${_filenameTmp} "void ${_name}_LoadAllPythonModules(void)\n{\n") + FOREACH(_currentModule ${PY_STATIC_MODULES_LIST}) + FILE(APPEND ${_filenameTmp} " ${_name}_${_currentModule}();\n") + ENDFOREACH(_currentModule ${PY_STATIC_MODULES_LIST}) + FILE(APPEND ${_filenameTmp} "}\n\n") + FILE(APPEND ${_filenameTmp} "#ifndef EXCLUDE_LOAD_ALL_FUNCTION\nvoid CMakeLoadAllPythonModules(void)\n{\n ${_name}_LoadAllPythonModules();\n}\n#endif\n\n#endif\n") + +# with CONFIGURE_FILE() cmake complains that you may not use a file created using FILE(WRITE) as input file for CONFIGURE_FILE() + EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${_filenameTmp}" "${_filename}" OUTPUT_QUIET ERROR_QUIET) + +ENDFUNCTION(PYTHON_WRITE_MODULES_HEADER) diff --git a/HySoP/CMake/FindPythonModule.cmake b/HySoP/CMake/FindPythonModule.cmake new file mode 100755 index 0000000000000000000000000000000000000000..d16955492361d3688344bcfdde241191ca7d2136 --- /dev/null +++ b/HySoP/CMake/FindPythonModule.cmake @@ -0,0 +1,25 @@ +# Search for a particular python module. +# Sources : see http://www.cmake.org/pipermail/cmake/2011-January/041666.html +# +# Usage : find_python_module(mpi4py REQUIRED) +# +function(find_python_module module) + string(TOUPPER ${module} module_upper) + if(ARGC GREATER 1 AND ARGV1 STREQUAL "REQUIRED") + set(${module}_FIND_REQUIRED TRUE) + endif() + # A module's location is usually a directory, but for binary modules + # it's a .so file. + execute_process(COMMAND ${PYTHON_EXECUTABLE} -c + "import re, ${module}; print re.compile('/__init__.py.*').sub('',${module}.__file__)" + RESULT_VARIABLE _${module}_status + OUTPUT_VARIABLE _${module}_location + ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) + + if(NOT _${module}_status) + set(python_${module_upper} ${_${module}_location} CACHE STRING + "Location of Python module ${module}") + endif(NOT _${module}_status) + + find_package_handle_standard_args(${module} DEFAULT_MSG _${module}_location) +endfunction(find_python_module) diff --git a/HySoP/CMakeLists.txt b/HySoP/CMakeLists.txt index 3d36c521f9087b3072f4360156c088670cfb44c0..715d373cb1d9b73714073b622934b43f7c241946 100644 --- a/HySoP/CMakeLists.txt +++ b/HySoP/CMakeLists.txt @@ -63,18 +63,33 @@ endif(WITH_TESTS) # We search for libraries Parmes depends on and # set the compile/link conf (-I and -L opt) -# --- MPI --- +set(PARMES_LIBRARY_NAME parmes) +set(PACKAGE_NAME Parmes) + +# --- Python --- + +include(FindPythonInterp) +include(FindPythonLibs) +include(FindPythonModule) +if(NOT PYTHONLIBS_VERSION_STRING VERSION_EQUAL PYTHON_VERSION_STRING) + display(PYTHONLIBS_VERSION_STRING) + display(PYTHON_VERSION_STRING) + message(FATAL_ERROR "Python library and executable versions do not match.") +endif() + +find_python_module(numpy REQUIRED) #Install dir for python (default = --user) execute_process( - COMMAND python -c "import site ; print site.USER_SITE" + COMMAND ${PYTHON_EXECUTABLE} -c "import site ; print site.USER_SITE" OUTPUT_VARIABLE ${PROJECT_NAME}_INSTALL_DIR) string(STRIP ${${PROJECT_NAME}_INSTALL_DIR} ${PROJECT_NAME}_INSTALL_DIR) set(CMAKE_INSTALL_PREFIX ${${PROJECT_NAME}_INSTALL_DIR}/${PROJECT_NAME}) -set(PARMES_LIBRARY_NAME parmes) -set(PACKAGE_NAME Parmes) +# --- MPI --- + if(USE_MPI) + find_python_module(mpi4py REQUIRED) # Find MPI for C++ and fortran. find_package(MPI REQUIRED) # -I @@ -104,14 +119,13 @@ if(EXISTS ${CMAKE_SOURCE_DIR}/parmepy/__init__.py.in) configure_file(parmepy/__init__.py.in ${CMAKE_SOURCE_DIR}/parmepy/__init__.py) endif() -set(PYTHON_EXECUTABLE python) set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES ${CMAKE_BINARY_DIR}/build) -ADD_CUSTOM_TARGET(python-build ALL COMMAND python ${CMAKE_CURRENT_BINARY_DIR}/setup.py build config_fc --f90exec=${CMAKE_Fortran_COMPILER} +ADD_CUSTOM_TARGET(python-build ALL COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/setup.py build config_fc --f90exec=${CMAKE_Fortran_COMPILER} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMENT "build parmepy package") # To install python package AND parmes library and modules -ADD_CUSTOM_TARGET(python-install COMMAND python ${CMAKE_CURRENT_BINARY_DIR}/setup.py install --user config_fc --f90exec=${CMAKE_Fortran_COMPILER} +ADD_CUSTOM_TARGET(python-install COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/setup.py install --user config_fc --f90exec=${CMAKE_Fortran_COMPILER} COMMAND make install WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMENT "build/install parmepy package") @@ -141,6 +155,9 @@ set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) # ============= Summary ============= if(VERBOSE_MODE) message(STATUS "====================== Summary ======================") + message(STATUS " Python version :${PYTHON_VERSION_STRING}") + message(STATUS " Python executable : ${PYTHON_EXECUTABLE}"}) + message(STATUS " Python libraries : ${PYTHON_LIBRARIES}") message(STATUS " Compiler : ${CMAKE_Fortran_COMPILER}") message(STATUS " Sources are in : ${CMAKE_SOURCE_DIR}") message(STATUS " Project uses MPI : ${USE_MPI}") diff --git a/HySoP/hysop/domain/topology.py b/HySoP/hysop/domain/topology.py index d99ece672f73396be2c2ef59027de2fc4cef3685..f74b923fe5f2b0f465ab4b925f4fb56e2e5be493 100644 --- a/HySoP/hysop/domain/topology.py +++ b/HySoP/hysop/domain/topology.py @@ -15,7 +15,7 @@ class CartesianTopology(object): - dim : dimension of the topology - comm : MPI communicator used to create this topology - periods : periodicity of the topology (in each direction) - - ghosts : number of poinst in the ghost layer + - ghosts : number of points in the ghost layer """ def __init__(self, domain, resolution, dim=None, dims=None, comm=MPI.COMM_WORLD, periods=None, ghosts=None): diff --git a/HySoP/hysop/f2py/fftw2py.f90 b/HySoP/hysop/f2py/fftw2py.f90 new file mode 100755 index 0000000000000000000000000000000000000000..7e59d963dcb25149d1a8eccc92b70a12b5dc073d --- /dev/null +++ b/HySoP/hysop/f2py/fftw2py.f90 @@ -0,0 +1,42 @@ + +!> Interface to mpi-fftw utilities +module fftw2py + + use poisson + use parmesparam + + implicit none + +contains + + subroutine initFFTW(resolution,lengths) + + !> GLOBAL resolution + integer, dimension(:), intent(in) :: resolution + !> Length of the domain + real(kind=pk),dimension(:),intent(in) :: lengths + + print *, "Initialize fftw poisson solver ..." + call initFFTW2D(resolution,lengths) + + end subroutine initFFTW + + subroutine solve(resolution,fieldIn,res) + + integer, dimension(:), intent(in) :: resolution + real(kind=pk),dimension(6,6,1),intent(inout) :: fieldIn + real(kind=pk),dimension(6,6,1),intent(out) :: res + real(kind=pk),dimension(:,:,:,:),pointer :: dummy + + print *, "Start fftw-based poisson solver ..." + +! allocate(fieldIn(resolution(1),resolution(2),1)) + + + call solvePoisson(fieldIn,dummy,resolution) + print *, "sol ... ", fieldIn + res(:,:,:) = fieldIn(:,:,:) + + end subroutine solve + +end module fftw2py diff --git a/HySoP/hysop/scales2py/scales2py.f90 b/HySoP/hysop/f2py/scales2py.f90 similarity index 77% rename from HySoP/hysop/scales2py/scales2py.f90 rename to HySoP/hysop/f2py/scales2py.f90 index 74424b08fcca95610d34abc78a28b1c71f347449..d315a2f341f0842e1bdd22a2001e6ff5bc13efcd 100755 --- a/HySoP/hysop/scales2py/scales2py.f90 +++ b/HySoP/hysop/f2py/scales2py.f90 @@ -1,24 +1,23 @@ !> Specific parameters for parmepy interface !! to deal with the problem explained here: !! http://projects.scipy.org/numpy/ticket/1835 -module parmepyparameters - -implicit none - -integer, parameter :: mk = 8 -integer, parameter :: dim3 = 3 - -end module parmepyparameters - +!!$module parmepyparameters +!!$ +!!$implicit none +!!$ +!!$integer, parameter :: mk = 8 +!!$integer, parameter :: dim3 = 3 +!!$ +!!$end module parmepyparameters +!!$ !> Interface to scale code from Legi module scales2py use cart_topology, only : cart_create,set_group_size,discretisation_create,N_proc,coord,cart_rank use advec, only : advec_init,advec_step !!use precision, only : wp -use parmepyparameters use mpi - +use parmesparam implicit none !! problem dimension @@ -44,9 +43,9 @@ contains subroutine discretisationCreate(resolution,domainLengths) !! global resolution - integer, dimension(dim3),intent(in) :: resolution + integer, dimension(:),intent(in) :: resolution !! global domain dimensions - real(mk), dimension(dim3),intent(in) :: domainLengths + real(pk), dimension(:),intent(in) :: domainLengths call discretisation_create(resolution(1),resolution(2),resolution(3),domainLengths(1),domainLengths(2),domainLengths(3)) @@ -54,31 +53,35 @@ contains subroutine advecInit(order,stab_coeff) character(len=*), optional, intent(in) :: order - real(mk), optional, intent(inout) :: stab_coeff + real(pk), optional, intent(inout) :: stab_coeff call advec_init(order,stab_coeff) end subroutine advecInit subroutine getLocalResolution(resolution) + integer,dimension(dim3),intent(out) :: resolution resolution = N_proc + end subroutine getLocalResolution subroutine getTopoCoords(topocoords) + integer,dimension(dim3),intent(out) :: topocoords topocoords = coord end subroutine getTopoCoords subroutine advecStep(timeStep,Vx,Vy,Vz,scal,dim_split) - real(mk), intent(in) :: timeStep - real(mk), dimension(:,:,:), intent(in) :: Vx, Vy, Vz - real(mk), dimension(:,:,:), intent(inout) :: scal + + real(pk), intent(in) :: timeStep + real(pk), dimension(:,:,:), intent(in) :: Vx, Vy, Vz + real(pk), dimension(:,:,:), intent(inout) :: scal character(len=*), optional, intent(in) :: dim_split - real(mk) :: t0 + real(pk) :: t0 t0 = MPI_Wtime() call advec_step(timeStep,Vx,Vy,Vz,scal,dim_split) diff --git a/HySoP/hysop/fftw2py/fftw2py.f90 b/HySoP/hysop/fftw2py/fftw2py.f90 deleted file mode 100755 index 5d1c1b7b54cb1460e2a9bec0de6e4aa86740099a..0000000000000000000000000000000000000000 --- a/HySoP/hysop/fftw2py/fftw2py.f90 +++ /dev/null @@ -1,39 +0,0 @@ -!> Interface to mpi-fftw utilities -module fftw2py - -use parmepyparameters -!use poisson, only : testpoisson -use poisson - -implicit none - -contains - - subroutine initFFTW(resolution,lengths) - - !> GLOBAL resolution - integer, dimension(3), intent(in) :: resolution - !> Length of the domain - real(kind=8),dimension(3),intent(in) :: lengths - print *, "ahahaha" - - call initFFTW2D(resolution,lengths) - - print *, "ahahaha" - - end subroutine initFFTW - -!!$ subroutine initFFTW(resolution,lengths) -!!$ -!!$ !> GLOBAL resolution -!!$ integer, dimension(:), intent(in) :: resolution -!!$ !> Length of the domain -!!$ real(kind=8),dimension(:),intent(in) :: lengths -!!$ -!!$ print *, "this is a call to fftw-mpi ..." -!!$ -!!$ call initfftw2d(resolution,lengths) -!!$ -!!$ end subroutine initFFTW - -end module fftw2py diff --git a/HySoP/setup.py.in b/HySoP/setup.py.in index 225d2665e333ad378c7f52d48ee4ea06210d682d..0a5fdf5f595a8a75fd8bb9b2495de1ef91a5e817 100644 --- a/HySoP/setup.py.in +++ b/HySoP/setup.py.in @@ -32,37 +32,32 @@ parmes_libdir = ['@CMAKE_BINARY_DIR@/src'] parmeslib = ['@PARMES_LIBRARY_NAME@'] f2py_options = ['--no-lower'] -scales_src = glob.glob('@CMAKE_SOURCE_DIR@/parmepy/scales2py/*.f90') -scalesModule = Extension(name='parmepy.scales2py', - f2py_options=f2py_options, - sources=scales_src, - include_dirs=inc_dir, - library_dirs=parmes_libdir, - libraries=parmeslib, - define_macros=[('F2PY_REPORT_ON_ARRAY_COPY', '1')]) +## scales_src = glob.glob('@CMAKE_SOURCE_DIR@/parmepy/scales2py/*.f90') +## scalesModule = Extension(name='parmepy.scales2py', +## f2py_options=f2py_options, +## sources=scales_src, +## include_dirs=inc_dir, +## library_dirs=parmes_libdir, +## libraries=parmeslib, +## define_macros=[('F2PY_REPORT_ON_ARRAY_COPY', '1')]) -ext_modules = [scalesModule] - -test_src = glob.glob('@CMAKE_SOURCE_DIR@/parmepy/testf2py/*.f90') -testf2pyModule = Extension(name='parmepy.testf2py', - f2py_options=f2py_options, - sources=test_src, - include_dirs=inc_dir, - library_dirs=parmes_libdir, - libraries=parmeslib, - define_macros=[('F2PY_REPORT_ON_ARRAY_COPY', '1')]) - -ext_modules.append(testf2pyModule) +## ext_modules=[scalesModule] +ext_modules =[] withfftw = "@WITH_FFTW@" if(withfftw is "ON"): - fortran_src = glob.glob('@CMAKE_SOURCE_DIR@/parmepy/fftw2py/*.f90') + #fortran_src = glob.glob('@CMAKE_SOURCE_DIR@/parmepy/f2py/*.f90') + fortran_dir = '@CMAKE_SOURCE_DIR@/parmepy/f2py/' + fortran_src = [fortran_dir+'parameters.f90',fortran_dir+'fftw2py.f90',fortran_dir+'scales2py.f90'] + +# rep = '@CMAKE_SOURCE_DIR@/parmepy/f2py/' + # fortran_src.insert(0,rep+'/parameters.f90') fftwdir = '@FFTWLIB@' fftwdir = os.path.split(fftwdir)[0] parmeslib.append('fftw3') parmeslib.append('fftw3_mpi') parmes_libdir.append(fftwdir) - parpyModule = Extension(name='parmepy.fftw2py', + parpyModule = Extension(name='parmepy.f2py', f2py_options=f2py_options, sources=fortran_src, include_dirs=inc_dir, diff --git a/HySoP/src/CMakeLists.txt b/HySoP/src/CMakeLists.txt index 53beaa4519f6e29639ff3faaac81961d0c23e3a2..62487b93c35b5130e3f29191ef21b8b6a2caf595 100644 --- a/HySoP/src/CMakeLists.txt +++ b/HySoP/src/CMakeLists.txt @@ -16,8 +16,6 @@ set(EXE_NAME ${PARMES_LIBRARY_NAME}Run) set(${PARMES_LIBRARY_NAME}_SRCDIRS . poisson - #src/interfaces/Fortran2Cpp - # src/interfaces/ppm ) # --- scales --- if(WITH_SCALES)