From: michael Date: Thu, 13 Jan 2022 17:36:29 +0000 (+0100) Subject: Improved mpi4py petsc4py and slepc4py variables X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=5440a85a42edfd128f7ed14fc6fba5e8d8355460;p=tools%2Fsolverlab.git Improved mpi4py petsc4py and slepc4py variables --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 6136307..5d4db93 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -57,16 +57,12 @@ include(ExternalProject)#For PETSc, MED and MEDCoupling list (APPEND CMAKE_MODULE_PATH "${SOLVERLAB_SOURCE_DIR}/cmake_files") -##################### -# Detection of MPI # -##################### -if ( DEFINED ENV{MPI_ROOT_DIR} OR DEFINED MPI_ROOT_DIR ) - if ( DEFINED ENV{MPI_ROOT_DIR} ) - set(MPI_HOME $ENV{MPI_ROOT_DIR}) - else ( DEFINED ENV{MPI_ROOT_DIR} ) - set(MPI_HOME ${MPI_ROOT_DIR}) - endif( DEFINED ENV{MPI_ROOT_DIR} ) -endif( DEFINED ENV{MPI_ROOT_DIR} OR DEFINED MPI_ROOT_DIR ) +############################# +# Detection of MPI + MPI4PY # +############################# +if ( DEFINED MPI_ROOT_DIR ) + set(MPI_HOME ${MPI_ROOT_DIR}) +endif( DEFINED MPI_ROOT_DIR ) # Definition of SOLVERLAB_WITH_MPI if( DEFINED ENV{MPI_HOME} OR MPI_HOME ) @@ -80,7 +76,7 @@ else( DEFINED ENV{MPI_HOME} OR MPI_HOME ) set(SOLVERLAB_WITH_MPI OFF) endif( DEFINED ENV{MPI_HOME} OR MPI_HOME ) -# Definition of MPI4PY_ROOT_DIR +# Definition of MPI4PY_ROOT_DIR from either the environment or petsc if( ${SOLVERLAB_WITH_PYTHON} AND ${SOLVERLAB_WITH_MPI} AND NOT ${MPI4PY_ROOT_DIR}) message(STATUS "Defining MPI4PY directory" ) if( DEFINED ENV{MPI4PY_ROOT_DIR}) @@ -92,7 +88,7 @@ endif(${SOLVERLAB_WITH_PYTHON} AND ${SOLVERLAB_WITH_MPI} AND NOT ${MPI4PY_ROOT_D if( MPI4PY_ROOT_DIR) message(STATUS "MPI4PY directory is ${MPI4PY_ROOT_DIR}" ) - SET(CMAKE_SWIG_FLAGS ${CMAKE_SWIG_FLAGS} -DMPI4PY_ROOT_DIR=${MPI4PY_ROOT_DIR}) + SET(CMAKE_SWIG_FLAGS ${CMAKE_SWIG_FLAGS} -DMPI4PY_ROOT_DIR=${MPI4PY_ROOT_DIR})#Necessary for swig generation of mpi structures endif( MPI4PY_ROOT_DIR) ############################ @@ -347,13 +343,6 @@ endif( DEFINED ENV{HDF5_ROOT_DIR} OR DEFINED HDF5_ROOT_DIR ) set(HDF5_LIBRARY_DIR ${HDF5_ROOT}/lib) set(HDF5_INCLUDE_DIRS ${HDF5_ROOT}/include) - #define MPI variables - #set(SOLVERLAB_WITH_MPI ON) - #set(MPI_HOME ${PETSC_INSTALL} ) - #set(MPI_LIBRARY ${PETSC_INSTALL}/lib/libmpi.so) - #set(MPIEXEC ${PETSC_INSTALL}/bin/mpiexec) - #set(MPI4PY_ROOT_DIR ${PETSC_INSTALL}/lib/mpi4py ) - endif ( IS_DIRECTORY "/usr/include/petsc/" AND EXISTS "/usr/lib64/libpetsc.so" ) endif ( DEFINED ENV{PETSC_DIR} OR PETSC_DIR ) @@ -361,6 +350,11 @@ if ( ${PETSC_VERSION} VERSION_GREATER 3.5 ) add_definitions(-DPETSC_VERSION_GREATER_3_5) endif( ${PETSC_VERSION} VERSION_GREATER 3.5 ) +if ( ${SOLVERLAB_WITH_PYTHON} ) + set(SLEPC4PY_ROOT_DIR ${PETSC_DIR}/${PETSC_ARCH}/lib/slepc4py)# or use FindSLEPC4PY + set(PETSC4PY_ROOT_DIR ${PETSC_DIR}/${PETSC_ARCH}/lib/petsc4py)# or use FindPETSC4PY +endif( ${SOLVERLAB_WITH_PYTHON} ) + string(REPLACE ";" ":" PETSC_INCLUDES_INSTALL "${PETSC_INCLUDES}")# use colon instead of semicolon in environment file env_SOLVERLAB.sh add_library(petsc SHARED IMPORTED) diff --git a/CoreFlows/swig/CMakeLists.txt b/CoreFlows/swig/CMakeLists.txt index e78beb4..ad24596 100755 --- a/CoreFlows/swig/CMakeLists.txt +++ b/CoreFlows/swig/CMakeLists.txt @@ -18,14 +18,30 @@ IF( ${SOLVERLAB_WITH_MPI} ) ${PETSC_INCLUDES} ${SLEPC_INCLUDES} ) + + if(EXISTS ${MPI4PY_ROOT_DIR}/mpi4py/include/mpi4py/mpi4py.i) + INCLUDE_DIRECTORIES( ${MPI4PY_ROOT_DIR}/mpi4py/include + ${MPI4PY_ROOT_DIR}/mpi4py/include/mpi4py ) + elseif (EXISTS ${MPI4PY_ROOT_DIR}/include/mpi4py/mpi4py.i ) + INCLUDE_DIRECTORIES( ${MPI4PY_ROOT_DIR}/include + ${MPI4PY_ROOT_DIR}/include/mpi4py ) + endif() ENDIF( ${SOLVERLAB_WITH_MPI} ) -if(EXISTS ${MPI4PY_ROOT_DIR}/mpi4py/include/mpi4py/mpi4py.i) - INCLUDE_DIRECTORIES( ${MPI4PY_ROOT_DIR}/mpi4py/include - ${MPI4PY_ROOT_DIR}/mpi4py/include/mpi4py ) -elseif (EXISTS ${MPI4PY_ROOT_DIR}/include/mpi4py/mpi4py.i ) - INCLUDE_DIRECTORIES( ${MPI4PY_ROOT_DIR}/include - ${MPI4PY_ROOT_DIR}/include/mpi4py ) +if(EXISTS ${PETSC4PY_ROOT_DIR}/petsc4py/include/petsc4py/petsc4py.i) + INCLUDE_DIRECTORIES( ${PETSC4PY_ROOT_DIR}/petsc4py/include + ${PETSC4PY_ROOT_DIR}/petsc4py/include/petsc4py ) +elseif (EXISTS ${PETSC4PY_ROOT_DIR}/include/petsc4py/petsc4py.i ) + INCLUDE_DIRECTORIES( ${PETSC4PY_ROOT_DIR}/include + ${PETSC4PY_ROOT_DIR}/include/petsc4py ) +endif() + +if(EXISTS ${SLEPC4PY_ROOT_DIR}/slepc4py/include/slepc4py/slepc4py.i) + INCLUDE_DIRECTORIES( ${SLEPC4PY_ROOT_DIR}/slepc4py/include + ${SLEPC4PY_ROOT_DIR}/slepc4py/include/slepc4py ) +elseif (EXISTS ${SLEPC4PY_ROOT_DIR}/include/slepc4py/slepc4py.i ) + INCLUDE_DIRECTORIES( ${SLEPC4PY_ROOT_DIR}/include + ${SLEPC4PY_ROOT_DIR}/include/slepc4py ) endif() IF (${CMAKE_VERSION} VERSION_LESS "3.8.0") diff --git a/CoreFlows/swig/CoreFlows.i b/CoreFlows/swig/CoreFlows.i index e426b48..4216f8a 100755 --- a/CoreFlows/swig/CoreFlows.i +++ b/CoreFlows/swig/CoreFlows.i @@ -4,6 +4,8 @@ %include std_vector.i %include std_map.i +%include slepc4py.i + #ifdef MPI4PY_ROOT_DIR %include mpi4py.i %mpi4py_typemap(Comm, MPI_Comm);