Commit d23771a8 authored by Rémy Mozul's avatar Rémy Mozul
Browse files

[SPARSE] attempt to use petsc

parent c1c82a0a
...@@ -6,36 +6,53 @@ project(Systems Fortran) ...@@ -6,36 +6,53 @@ project(Systems Fortran)
find_package(LAPACK REQUIRED) find_package(LAPACK REQUIRED)
# looking for mumps # looking for mumps
message(STATUS "looking for mumps in ${MP}") if( MP )
find_library(MUMPS_FOUND dmumps HINTS ${MP} PATH_SUFFIXES lib NO_DEFAULT_PATH REQUIRED) message(STATUS "looking for mumps in ${MP}")
find_library(MUMPS_COMMON_FOUND mumps_common HINTS ${MP} PATH_SUFFIXES lib NO_DEFAULT_PATH REQUIRED) find_library(MUMPS_FOUND dmumps HINTS ${MP} PATH_SUFFIXES lib NO_DEFAULT_PATH REQUIRED)
find_library(PORD_FOUND pord HINTS ${MP} PATH_SUFFIXES lib NO_DEFAULT_PATH REQUIRED) find_library(MUMPS_COMMON_FOUND mumps_common HINTS ${MP} PATH_SUFFIXES lib NO_DEFAULT_PATH REQUIRED)
find_library(MPISEQ_FOUND mpiseq HINTS ${MP} PATH_SUFFIXES lib libseq REQUIRED) find_library(PORD_FOUND pord HINTS ${MP} PATH_SUFFIXES lib NO_DEFAULT_PATH REQUIRED)
find_path(MUMPS_INCLUDE_DIRS dmumps_struc.h NO_DEFAULT_PATH HINTS ${MP} ${MD} PATH_SUFFIXES include) find_library(MPISEQ_FOUND mpiseq HINTS ${MP} PATH_SUFFIXES lib libseq REQUIRED)
find_path(MUMPS_INCLUDE_DIR dmumps_struc.h NO_DEFAULT_PATH HINTS ${MP} ${MD} PATH_SUFFIXES include)
set(MUMPS_LIBRARIES ${MUMPS_FOUND} ${MUMPS_COMMON_FOUND} ${PORD_FOUND} ${MPISEQ_FOUND}) set(MUMPS_LIBRARIES ${MUMPS_FOUND} ${MUMPS_COMMON_FOUND} ${PORD_FOUND} ${MPISEQ_FOUND})
message(STATUS "MUMPs LIBRARIES: ${MUMPS_LIBRARIES}")
message(STATUS "MUMPs INCLUDE : ${MUMPS_INCLUDE_DIR}")
endif( MP )
# looking for petsc # looking for petsc
if( PP )
message(STATUS "looking for petsc in ${PP}")
find_library(PETSC_FOUND petsc HINTS ${PP} PATH_SUFFIXES lib NO_DEFAULT_PATH REQUIRED)
find_path(PETSC_C_INCLUDE_DIR petsc.h NO_DEFAULT_PATH HINTS ${PP} PATH_SUFFIXES include)
find_path(PETSC_F_INCLUDE_DIR finclude/petsc.h90 NO_DEFAULT_PATH HINTS ${PP} PATH_SUFFIXES include/petsc)
set(PETSC_LIBRARIES ${PETSC_FOUND})
message(STATUS "PETSc LIBRARIES: ${PETSC_LIBRARIES}")
message(STATUS "PETSc INCLUDE : ${PETSC_C_INCLUDE_DIR} ${PETSC_F_INCLUDE_DIR}")
endif( PP )
# mumps example # mumps example
if( ${MP} ) if( MUMPS_FOUND )
include_directories(${MUMPS_INCLUDE_DIRS}) include_directories(${MUMPS_INCLUDE_DIR})
add_library( mumpsAlgebra dataStructure.f90 mumps_binding.f90) add_library( mumpsAlgebra dataStructure.f90 mumps_binding.f90)
target_link_libraries( mumpsAlgebra ${MUMPS_LIBRARIES} ${LAPACK_LIBRARIES}) target_link_libraries( mumpsAlgebra ${MUMPS_LIBRARIES} ${LAPACK_LIBRARIES})
add_executable( mumpsTest reference_test.f90 ) add_executable( mumpsTest reference_test.f90 )
target_link_libraries( mumpsTest mumpsAlgebra ) target_link_libraries( mumpsTest mumpsAlgebra )
endif( ${MP} ) endif( MUMPS_FOUND )
# petsc example # petsc example
if( ${PP} ) if( PETSC_FOUND )
include_directories(${PETSC_INCLUDE_DIRS})
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -cpp")
include_directories(${PETSC_C_INCLUDE_DIR})
include_directories(${PETSC_F_INCLUDE_DIR})
add_library( petscAlgebra dataStructure.f90 petsc_binding.f90) add_library( petscAlgebra dataStructure.f90 petsc_binding.f90)
target_link_libraries( petscAlgebra ${PETSC_LIBRARIES} ${LAPACK_LIBRARIES}) target_link_libraries( petscAlgebra ${PETSC_LIBRARIES} )
add_executable( petscTest reference_test.f90 ) add_executable( petscTest reference_test.f90 )
target_link_libraries( petscTest petscAlgebra ) target_link_libraries( petscTest petscAlgebra )
endif( ${PP} ) endif( PETSC_FOUND )
...@@ -15,3 +15,11 @@ Descriptions des fichiers: ...@@ -15,3 +15,11 @@ Descriptions des fichiers:
- xxxx_binding.f90 : binding sur une bibliothèque de résolution - xxxx_binding.f90 : binding sur une bibliothèque de résolution
de système creux, quasiment identique aux modules de binding de LMGC90 de système creux, quasiment identique aux modules de binding de LMGC90
Utilisation :
mkdir build
cd build
cmake ../ -DMP=pathtomumps
make
...@@ -13,10 +13,18 @@ module LinearAlgebra ...@@ -13,10 +13,18 @@ module LinearAlgebra
end type sparse_mat end type sparse_mat
public declare, build, & public declare, build, &
solve, erase solve, erase, &
init, finalize
contains contains
subroutine init()
implicit none
print *, 'empty initialization'
end subroutine
subroutine declare(matrix, nb_dofs, nb_non_zero, i_indices, j_indices, is_sym, info) subroutine declare(matrix, nb_dofs, nb_non_zero, i_indices, j_indices, is_sym, info)
implicit none implicit none
...@@ -125,4 +133,11 @@ module LinearAlgebra ...@@ -125,4 +133,11 @@ module LinearAlgebra
end subroutine end subroutine
subroutine finalize()
implicit none
print *, 'empty finalization'
end subroutine
end module end module
...@@ -28,16 +28,16 @@ module LinearAlgebra ...@@ -28,16 +28,16 @@ module LinearAlgebra
end type sparse_mat end type sparse_mat
public sparse_init , & public init , &
sparse_declare, & declare, &
sparse_build , & build , &
sparse_solve , & solve , &
sparse_erase , & erase , &
sparse_finalize finalize
contains contains
subroutine sparse_init() subroutine init()
implicit none implicit none
! !
integer(kind=4) :: ierr integer(kind=4) :: ierr
...@@ -175,7 +175,7 @@ module LinearAlgebra ...@@ -175,7 +175,7 @@ module LinearAlgebra
end subroutine end subroutine
subroutine sparse_finalize() subroutine finalize()
implicit none implicit none
! !
integer(kind=4) :: ierr integer(kind=4) :: ierr
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
program test_systems program test_systems
use dataStructure, only : dstruc, systems_generation use dataStructure, only : dstruc, systems_generation
use LinearAlgebra, only : declare, build, solve, erase use LinearAlgebra, only : init, declare, build, solve, erase, finalize
implicit none implicit none
...@@ -13,6 +13,8 @@ program test_systems ...@@ -13,6 +13,8 @@ program test_systems
! !
integer(kind=4) :: i_sys, info integer(kind=4) :: i_sys, info
call init()
call systems_generation(systems) call systems_generation(systems)
!$OMP PARALLEL DEFAULT(SHARED) PRIVATE(i_sys) !$OMP PARALLEL DEFAULT(SHARED) PRIVATE(i_sys)
...@@ -66,4 +68,6 @@ program test_systems ...@@ -66,4 +68,6 @@ program test_systems
!$OMP END DO !$OMP END DO
!$OMP END PARALLEL !$OMP END PARALLEL
call finalize()
end program end program
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment