You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
222 lines
8.1 KiB
Fortran
222 lines
8.1 KiB
Fortran
17 years ago
|
!!$
|
||
|
!!$
|
||
15 years ago
|
!!$ MLD2P4 version 2.0
|
||
17 years ago
|
!!$ MultiLevel Domain Decomposition Parallel Preconditioners Package
|
||
15 years ago
|
!!$ based on PSBLAS (Parallel Sparse BLAS version 3.0)
|
||
17 years ago
|
!!$
|
||
15 years ago
|
!!$ (C) Copyright 2008,2009,2010
|
||
17 years ago
|
!!$
|
||
16 years ago
|
!!$ Salvatore Filippone University of Rome Tor Vergata
|
||
15 years ago
|
!!$ Alfredo Buttari CNRS-IRIT, Toulouse
|
||
17 years ago
|
!!$ Pasqua D'Ambra ICAR-CNR, Naples
|
||
|
!!$ Daniela di Serafino Second University of Naples
|
||
|
!!$
|
||
|
!!$ Redistribution and use in source and binary forms, with or without
|
||
|
!!$ modification, are permitted provided that the following conditions
|
||
|
!!$ are met:
|
||
|
!!$ 1. Redistributions of source code must retain the above copyright
|
||
|
!!$ notice, this list of conditions and the following disclaimer.
|
||
|
!!$ 2. Redistributions in binary form must reproduce the above copyright
|
||
|
!!$ notice, this list of conditions, and the following disclaimer in the
|
||
|
!!$ documentation and/or other materials provided with the distribution.
|
||
|
!!$ 3. The name of the MLD2P4 group or the names of its contributors may
|
||
|
!!$ not be used to endorse or promote products derived from this
|
||
|
!!$ software without specific written permission.
|
||
|
!!$
|
||
|
!!$ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||
|
!!$ ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||
|
!!$ TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||
|
!!$ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS
|
||
|
!!$ BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||
|
!!$ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||
|
!!$ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||
|
!!$ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||
|
!!$ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||
|
!!$ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||
|
!!$ POSSIBILITY OF SUCH DAMAGE.
|
||
|
!!$
|
||
|
!!$
|
||
|
! File: mld_cprecinit.f90
|
||
|
!
|
||
|
! Subroutine: mld_cprecinit
|
||
|
! Version: complex
|
||
|
!
|
||
|
! This routine allocates and initializes the preconditioner data structure,
|
||
|
! according to the preconditioner type chosen by the user.
|
||
|
!
|
||
|
! A default preconditioner is set for each preconditioner type
|
||
|
! specified by the user:
|
||
|
!
|
||
17 years ago
|
! 'NOPREC' - no preconditioner
|
||
17 years ago
|
!
|
||
|
! 'DIAG' - diagonal preconditioner
|
||
|
!
|
||
14 years ago
|
! 'PJAC' - point Jacobi preconditioner
|
||
|
!
|
||
17 years ago
|
! 'BJAC' - block Jacobi preconditioner, with ILU(0)
|
||
|
! on the local blocks
|
||
|
!
|
||
|
! 'AS' - Restricted Additive Schwarz (RAS), with
|
||
|
! overlap 1 and ILU(0) on the local submatrices
|
||
|
!
|
||
|
! 'ML' - Multilevel hybrid preconditioner (additive on the
|
||
|
! same level and multiplicative through the levels),
|
||
17 years ago
|
! with 2 levels and post-smoothing only. RAS with
|
||
|
! overlap 1 and ILU(0) on the local blocks is
|
||
|
! applied as post-smoother at each level, but the
|
||
|
! coarsest one; four sweeps of the block-Jacobi solver,
|
||
13 years ago
|
! with LU from UMFPACK on the blocks, are applied at
|
||
17 years ago
|
! the coarsest level, on the distributed coarse matrix.
|
||
17 years ago
|
! The smoothed aggregation algorithm with threshold 0
|
||
|
! is used to build the coarse matrix.
|
||
17 years ago
|
!
|
||
|
! For the multilevel preconditioners, the levels are numbered in increasing
|
||
|
! order starting from the finest one, i.e. level 1 is the finest level.
|
||
|
!
|
||
|
!
|
||
|
! Arguments:
|
||
|
! p - type(mld_cprec_type), input/output.
|
||
|
! The preconditioner data structure.
|
||
|
! ptype - character(len=*), input.
|
||
17 years ago
|
! The type of preconditioner. Its values are 'NOPREC',
|
||
|
! 'DIAG', 'BJAC', 'AS', 'ML' (and the corresponding
|
||
17 years ago
|
! lowercase strings).
|
||
|
! info - integer, output.
|
||
|
! Error code.
|
||
|
! nlev - integer, optional, input.
|
||
|
! The number of levels of the multilevel preconditioner.
|
||
|
! If nlev is not present and ptype='ML', then nlev=2
|
||
15 years ago
|
! is assumed. If ptype /= 'ML', nlev is ignored.
|
||
17 years ago
|
!
|
||
|
subroutine mld_cprecinit(p,ptype,info,nlev)
|
||
|
|
||
14 years ago
|
use psb_base_mod
|
||
14 years ago
|
use mld_c_prec_mod, mld_protect_name => mld_cprecinit
|
||
14 years ago
|
use mld_c_jac_smoother
|
||
|
use mld_c_as_smoother
|
||
14 years ago
|
use mld_c_id_solver
|
||
14 years ago
|
use mld_c_diag_solver
|
||
|
use mld_c_ilu_solver
|
||
13 years ago
|
#if defined(HAVE_UMF_) && 0
|
||
13 years ago
|
use mld_c_umf_solver
|
||
|
#endif
|
||
14 years ago
|
#if defined(HAVE_SLU_)
|
||
|
use mld_c_slu_solver
|
||
|
#endif
|
||
14 years ago
|
|
||
17 years ago
|
|
||
|
implicit none
|
||
|
|
||
14 years ago
|
! Arguments
|
||
13 years ago
|
type(mld_cprec_type), intent(inout) :: p
|
||
|
character(len=*), intent(in) :: ptype
|
||
|
integer, intent(out) :: info
|
||
|
integer, optional, intent(in) :: nlev
|
||
17 years ago
|
|
||
14 years ago
|
! Local variables
|
||
13 years ago
|
integer :: nlev_, ilev_
|
||
14 years ago
|
real(psb_spk_) :: thr
|
||
13 years ago
|
character(len=*), parameter :: name='mld_precinit'
|
||
15 years ago
|
info = psb_success_
|
||
14 years ago
|
|
||
16 years ago
|
if (allocated(p%precv)) then
|
||
17 years ago
|
call mld_precfree(p,info)
|
||
15 years ago
|
if (info /= psb_success_) then
|
||
17 years ago
|
! Do we want to do something?
|
||
|
endif
|
||
|
endif
|
||
|
|
||
|
select case(psb_toupper(ptype(1:len_trim(ptype))))
|
||
14 years ago
|
case ('NOPREC','NONE')
|
||
17 years ago
|
nlev_ = 1
|
||
|
ilev_ = 1
|
||
16 years ago
|
allocate(p%precv(nlev_),stat=info)
|
||
14 years ago
|
allocate(mld_c_base_smoother_type :: p%precv(ilev_)%sm, stat=info)
|
||
15 years ago
|
if (info /= psb_success_) return
|
||
14 years ago
|
allocate(mld_c_id_solver_type :: p%precv(ilev_)%sm%sv, stat=info)
|
||
|
call p%precv(ilev_)%default()
|
||
14 years ago
|
|
||
14 years ago
|
case ('JAC','DIAG','JACOBI')
|
||
17 years ago
|
nlev_ = 1
|
||
|
ilev_ = 1
|
||
16 years ago
|
allocate(p%precv(nlev_),stat=info)
|
||
14 years ago
|
allocate(mld_c_jac_smoother_type :: p%precv(ilev_)%sm, stat=info)
|
||
15 years ago
|
if (info /= psb_success_) return
|
||
14 years ago
|
allocate(mld_c_diag_solver_type :: p%precv(ilev_)%sm%sv, stat=info)
|
||
|
call p%precv(ilev_)%default()
|
||
17 years ago
|
|
||
|
case ('BJAC')
|
||
|
nlev_ = 1
|
||
|
ilev_ = 1
|
||
16 years ago
|
allocate(p%precv(nlev_),stat=info)
|
||
14 years ago
|
allocate(mld_c_jac_smoother_type :: p%precv(ilev_)%sm, stat=info)
|
||
15 years ago
|
if (info /= psb_success_) return
|
||
14 years ago
|
allocate(mld_c_ilu_solver_type :: p%precv(ilev_)%sm%sv, stat=info)
|
||
|
call p%precv(ilev_)%default()
|
||
14 years ago
|
|
||
17 years ago
|
case ('AS')
|
||
|
nlev_ = 1
|
||
|
ilev_ = 1
|
||
16 years ago
|
allocate(p%precv(nlev_),stat=info)
|
||
14 years ago
|
allocate(mld_c_as_smoother_type :: p%precv(ilev_)%sm, stat=info)
|
||
15 years ago
|
if (info /= psb_success_) return
|
||
14 years ago
|
allocate(mld_c_ilu_solver_type :: p%precv(ilev_)%sm%sv, stat=info)
|
||
|
call p%precv(ilev_)%default()
|
||
17 years ago
|
|
||
|
|
||
|
case ('ML')
|
||
14 years ago
|
|
||
17 years ago
|
if (present(nlev)) then
|
||
|
nlev_ = max(1,nlev)
|
||
|
else
|
||
|
nlev_ = 2
|
||
|
end if
|
||
|
ilev_ = 1
|
||
16 years ago
|
allocate(p%precv(nlev_),stat=info)
|
||
14 years ago
|
allocate(mld_c_as_smoother_type :: p%precv(ilev_)%sm, stat=info)
|
||
15 years ago
|
if (info /= psb_success_) return
|
||
14 years ago
|
allocate(mld_c_ilu_solver_type :: p%precv(ilev_)%sm%sv, stat=info)
|
||
|
call p%precv(ilev_)%default()
|
||
17 years ago
|
|
||
14 years ago
|
|
||
|
if (nlev_ == 1) return
|
||
17 years ago
|
do ilev_ = 2, nlev_ -1
|
||
14 years ago
|
allocate(mld_c_as_smoother_type :: p%precv(ilev_)%sm, stat=info)
|
||
15 years ago
|
if (info /= psb_success_) return
|
||
14 years ago
|
allocate(mld_c_ilu_solver_type :: p%precv(ilev_)%sm%sv, stat=info)
|
||
|
call p%precv(ilev_)%default()
|
||
|
|
||
17 years ago
|
end do
|
||
|
ilev_ = nlev_
|
||
14 years ago
|
allocate(mld_c_jac_smoother_type :: p%precv(ilev_)%sm, stat=info)
|
||
15 years ago
|
if (info /= psb_success_) return
|
||
13 years ago
|
#if defined(HAVE_UMF_) && 0
|
||
13 years ago
|
allocate(mld_c_umf_solver_type :: p%precv(ilev_)%sm%sv, stat=info)
|
||
|
#elif defined(HAVE_SLU_)
|
||
14 years ago
|
allocate(mld_c_slu_solver_type :: p%precv(ilev_)%sm%sv, stat=info)
|
||
17 years ago
|
#else
|
||
14 years ago
|
allocate(mld_c_ilu_solver_type :: p%precv(ilev_)%sm%sv, stat=info)
|
||
17 years ago
|
#endif
|
||
14 years ago
|
call p%precv(ilev_)%default()
|
||
13 years ago
|
p%precv(ilev_)%parms%coarse_solve = mld_bjac_
|
||
14 years ago
|
call p%precv(ilev_)%set(mld_smoother_sweeps_,4,info)
|
||
|
call p%precv(ilev_)%set(mld_sub_restr_,psb_none_,info)
|
||
|
call p%precv(ilev_)%set(mld_sub_prol_,psb_none_,info)
|
||
|
call p%precv(ilev_)%set(mld_sub_ovr_,0,info)
|
||
|
|
||
13 years ago
|
thr = 0.16d0
|
||
14 years ago
|
do ilev_=1,nlev_
|
||
|
call p%precv(ilev_)%set(mld_aggr_thresh_,thr,info)
|
||
|
thr = thr/2
|
||
|
end do
|
||
13 years ago
|
|
||
17 years ago
|
case default
|
||
14 years ago
|
write(psb_err_unit,*) name,&
|
||
13 years ago
|
&': Warning: Unknown preconditioner type request "',ptype,'"'
|
||
15 years ago
|
info = psb_err_pivot_too_small_
|
||
17 years ago
|
|
||
|
end select
|
||
|
|
||
|
|
||
|
end subroutine mld_cprecinit
|