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.
230 lines
6.4 KiB
Fortran
230 lines
6.4 KiB
Fortran
8 years ago
|
!
|
||
|
!
|
||
4 years ago
|
! AMG4PSBLAS version 1.0
|
||
|
! Algebraic Multigrid Package
|
||
8 years ago
|
! based on PSBLAS (Parallel Sparse BLAS version 3.5)
|
||
8 years ago
|
!
|
||
4 years ago
|
! (C) Copyright 2020
|
||
8 years ago
|
!
|
||
7 years ago
|
! Salvatore Filippone
|
||
|
! Pasqua D'Ambra
|
||
4 years ago
|
! Fabio Durastante
|
||
8 years ago
|
!
|
||
|
! 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.
|
||
4 years ago
|
! 3. The name of the AMG4PSBLAS group or the names of its contributors may
|
||
8 years ago
|
! 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
|
||
4 years ago
|
! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AMG4PSBLAS GROUP OR ITS CONTRIBUTORS
|
||
8 years ago
|
! 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.
|
||
|
!
|
||
|
!
|
||
4 years ago
|
! File: amg_cprecset.f90
|
||
17 years ago
|
!
|
||
4 years ago
|
subroutine amg_cprecsetsm(p,val,info,ilev,ilmax,pos)
|
||
14 years ago
|
|
||
14 years ago
|
use psb_base_mod
|
||
4 years ago
|
use amg_c_prec_mod, amg_protect_name => amg_cprecsetsm
|
||
14 years ago
|
|
||
|
implicit none
|
||
|
|
||
|
! Arguments
|
||
4 years ago
|
class(amg_cprec_type), intent(inout) :: p
|
||
|
class(amg_c_base_smoother_type), intent(in) :: val
|
||
12 years ago
|
integer(psb_ipk_), intent(out) :: info
|
||
8 years ago
|
integer(psb_ipk_), optional, intent(in) :: ilev,ilmax
|
||
9 years ago
|
character(len=*), optional, intent(in) :: pos
|
||
14 years ago
|
|
||
|
! Local variables
|
||
8 years ago
|
integer(psb_ipk_) :: ilev_, nlev_, ilmin_, ilmax_
|
||
4 years ago
|
character(len=*), parameter :: name='amg_precsetsm'
|
||
14 years ago
|
|
||
|
info = psb_success_
|
||
|
|
||
|
if (.not.allocated(p%precv)) then
|
||
|
info = 3111
|
||
14 years ago
|
write(psb_err_unit,*) name,&
|
||
|
& ': Error: uninitialized preconditioner,',&
|
||
4 years ago
|
&' should call amg_PRECINIT'
|
||
14 years ago
|
return
|
||
|
endif
|
||
|
nlev_ = size(p%precv)
|
||
|
|
||
|
if (present(ilev)) then
|
||
|
ilev_ = ilev
|
||
8 years ago
|
ilmin_ = ilev
|
||
8 years ago
|
if (present(ilmax)) then
|
||
|
ilmax_ = ilmax
|
||
|
else
|
||
|
ilmax_ = ilev_
|
||
|
end if
|
||
14 years ago
|
else
|
||
|
ilev_ = 1
|
||
8 years ago
|
ilmin_ = 1
|
||
|
ilmax_ = nlev_
|
||
14 years ago
|
end if
|
||
|
|
||
|
if ((ilev_<1).or.(ilev_ > nlev_)) then
|
||
|
info = -1
|
||
14 years ago
|
write(psb_err_unit,*) name,&
|
||
|
& ': Error: invalid ILEV/NLEV combination',ilev_, nlev_
|
||
14 years ago
|
return
|
||
|
endif
|
||
8 years ago
|
if ((ilmax_<1).or.(ilmax_ > nlev_)) then
|
||
|
info = -1
|
||
|
write(psb_err_unit,*) name,&
|
||
|
&': Error: invalid ILMAX/NLEV combination',ilmax_, nlev_
|
||
|
return
|
||
|
endif
|
||
14 years ago
|
|
||
8 years ago
|
do ilev_ = ilmin_, ilmax_
|
||
9 years ago
|
call p%precv(ilev_)%set(val,info,pos=pos)
|
||
|
if (info /= 0) return
|
||
14 years ago
|
end do
|
||
|
|
||
4 years ago
|
end subroutine amg_cprecsetsm
|
||
14 years ago
|
|
||
4 years ago
|
subroutine amg_cprecsetsv(p,val,info,ilev,ilmax,pos)
|
||
14 years ago
|
|
||
14 years ago
|
use psb_base_mod
|
||
4 years ago
|
use amg_c_prec_mod, amg_protect_name => amg_cprecsetsv
|
||
14 years ago
|
|
||
|
implicit none
|
||
|
|
||
|
! Arguments
|
||
4 years ago
|
class(amg_cprec_type), intent(inout) :: p
|
||
|
class(amg_c_base_solver_type), intent(in) :: val
|
||
12 years ago
|
integer(psb_ipk_), intent(out) :: info
|
||
8 years ago
|
integer(psb_ipk_), optional, intent(in) :: ilev,ilmax
|
||
9 years ago
|
character(len=*), optional, intent(in) :: pos
|
||
14 years ago
|
|
||
|
! Local variables
|
||
8 years ago
|
integer(psb_ipk_) :: ilev_, nlev_, ilmin_, ilmax_
|
||
4 years ago
|
character(len=*), parameter :: name='amg_precsetsv'
|
||
14 years ago
|
|
||
|
info = psb_success_
|
||
|
|
||
|
if (.not.allocated(p%precv)) then
|
||
|
info = 3111
|
||
14 years ago
|
write(psb_err_unit,*) name,&
|
||
|
& ': Error: uninitialized preconditioner,',&
|
||
4 years ago
|
&' should call amg_PRECINIT'
|
||
14 years ago
|
return
|
||
|
endif
|
||
|
nlev_ = size(p%precv)
|
||
|
|
||
|
if (present(ilev)) then
|
||
|
ilev_ = ilev
|
||
8 years ago
|
ilmin_ = ilev
|
||
8 years ago
|
if (present(ilmax)) then
|
||
|
ilmax_ = ilmax
|
||
|
else
|
||
|
ilmax_ = ilev_
|
||
|
end if
|
||
14 years ago
|
else
|
||
|
ilev_ = 1
|
||
8 years ago
|
ilmin_ = 1
|
||
|
ilmax_ = nlev_
|
||
14 years ago
|
end if
|
||
|
|
||
|
if ((ilev_<1).or.(ilev_ > nlev_)) then
|
||
|
info = -1
|
||
14 years ago
|
write(psb_err_unit,*) name,&
|
||
|
& ': Error: invalid ILEV/NLEV combination',ilev_, nlev_
|
||
14 years ago
|
return
|
||
|
endif
|
||
8 years ago
|
if ((ilmax_<1).or.(ilmax_ > nlev_)) then
|
||
|
info = -1
|
||
|
write(psb_err_unit,*) name,&
|
||
|
&': Error: invalid ILMAX/NLEV combination',ilmax_, nlev_
|
||
|
return
|
||
|
endif
|
||
14 years ago
|
|
||
8 years ago
|
do ilev_ = ilmin_, ilmax_
|
||
9 years ago
|
call p%precv(ilev_)%set(val,info,pos=pos)
|
||
|
if (info /= 0) return
|
||
14 years ago
|
end do
|
||
|
|
||
4 years ago
|
end subroutine amg_cprecsetsv
|
||
14 years ago
|
|
||
4 years ago
|
subroutine amg_cprecsetag(p,val,info,ilev,ilmax,pos)
|
||
7 years ago
|
|
||
|
use psb_base_mod
|
||
4 years ago
|
use amg_c_prec_mod, amg_protect_name => amg_cprecsetag
|
||
7 years ago
|
|
||
|
implicit none
|
||
|
|
||
|
! Arguments
|
||
4 years ago
|
class(amg_cprec_type), intent(inout) :: p
|
||
|
class(amg_c_base_aggregator_type), intent(in) :: val
|
||
7 years ago
|
integer(psb_ipk_), intent(out) :: info
|
||
|
integer(psb_ipk_), optional, intent(in) :: ilev, ilmax
|
||
|
character(len=*), optional, intent(in) :: pos
|
||
|
|
||
|
! Local variables
|
||
|
integer(psb_ipk_) :: ilev_, nlev_, ilmin_, ilmax_
|
||
4 years ago
|
character(len=*), parameter :: name='amg_precsetag'
|
||
7 years ago
|
|
||
|
info = psb_success_
|
||
|
|
||
|
if (.not.allocated(p%precv)) then
|
||
|
info = 3111
|
||
|
write(psb_err_unit,*) name,&
|
||
|
& ': Error: uninitialized preconditioner,',&
|
||
4 years ago
|
&' should call amg_PRECINIT'
|
||
7 years ago
|
return
|
||
|
endif
|
||
|
nlev_ = size(p%precv)
|
||
|
|
||
|
if (present(ilev)) then
|
||
|
ilev_ = ilev
|
||
|
ilmin_ = ilev
|
||
|
if (present(ilmax)) then
|
||
|
ilmax_ = ilmax
|
||
|
else
|
||
|
ilmax_ = ilev_
|
||
|
end if
|
||
|
else
|
||
|
ilev_ = 1
|
||
|
ilmin_ = 1
|
||
|
ilmax_ = nlev_
|
||
|
end if
|
||
|
|
||
|
|
||
|
if ((ilev_<1).or.(ilev_ > nlev_)) then
|
||
|
info = -1
|
||
|
write(psb_err_unit,*) name,&
|
||
|
& ': Error: invalid ILEV/NLEV combination',ilev_, nlev_
|
||
|
return
|
||
|
endif
|
||
|
if ((ilmax_<1).or.(ilmax_ > nlev_)) then
|
||
|
info = -1
|
||
|
write(psb_err_unit,*) name,&
|
||
|
&': Error: invalid ILMAX/NLEV combination',ilmax_, nlev_
|
||
|
return
|
||
|
endif
|
||
|
|
||
|
do ilev_ = ilmin_, ilmax_
|
||
|
call p%precv(ilev_)%set(val,info,pos=pos)
|
||
|
if (info /= 0) return
|
||
|
end do
|
||
|
|
||
4 years ago
|
end subroutine amg_cprecsetag
|
||
7 years ago
|
|