Added modules and implementation for AINV solver

merge-amgext
Cirdans-Home 4 years ago
parent b5cbfd5356
commit 8f5ff61a55

@ -13,7 +13,8 @@ DMODOBJS=amg_d_prec_type.o \
amg_d_base_solver_mod.o amg_d_base_smoother_mod.o amg_d_onelev_mod.o \
amg_d_gs_solver.o amg_d_mumps_solver.o \
amg_d_base_aggregator_mod.o \
amg_d_dec_aggregator_mod.o amg_d_symdec_aggregator_mod.o
amg_d_dec_aggregator_mod.o amg_d_symdec_aggregator_mod.o \
amg_d_ainv_solver.o amg_d_base_ainv_mod.o
#amg_d_bcmatch_aggregator_mod.o
SMODOBJS=amg_s_prec_type.o amg_s_ilu_fact_mod.o \
@ -22,7 +23,8 @@ SMODOBJS=amg_s_prec_type.o amg_s_ilu_fact_mod.o \
amg_s_base_solver_mod.o amg_s_base_smoother_mod.o amg_s_onelev_mod.o \
amg_s_gs_solver.o amg_s_mumps_solver.o \
amg_s_base_aggregator_mod.o \
amg_s_dec_aggregator_mod.o amg_s_symdec_aggregator_mod.o
amg_s_dec_aggregator_mod.o amg_s_symdec_aggregator_mod.o \
amg_s_ainv_solver.o amg_s_base_ainv_mod.o
ZMODOBJS=amg_z_prec_type.o amg_z_ilu_fact_mod.o \
amg_z_inner_mod.o amg_z_ilu_solver.o amg_z_diag_solver.o amg_z_jac_smoother.o amg_z_as_smoother.o \
@ -30,7 +32,8 @@ ZMODOBJS=amg_z_prec_type.o amg_z_ilu_fact_mod.o \
amg_z_base_solver_mod.o amg_z_base_smoother_mod.o amg_z_onelev_mod.o \
amg_z_gs_solver.o amg_z_mumps_solver.o \
amg_z_base_aggregator_mod.o \
amg_z_dec_aggregator_mod.o amg_z_symdec_aggregator_mod.o
amg_z_dec_aggregator_mod.o amg_z_symdec_aggregator_mod.o \
amg_z_ainv_solver.o amg_z_base_ainv_mod.o
CMODOBJS=amg_c_prec_type.o amg_c_ilu_fact_mod.o \
amg_c_inner_mod.o amg_c_ilu_solver.o amg_c_diag_solver.o amg_c_jac_smoother.o amg_c_as_smoother.o \
@ -38,12 +41,14 @@ CMODOBJS=amg_c_prec_type.o amg_c_ilu_fact_mod.o \
amg_c_base_solver_mod.o amg_c_base_smoother_mod.o amg_c_onelev_mod.o \
amg_c_gs_solver.o amg_c_mumps_solver.o \
amg_c_base_aggregator_mod.o \
amg_c_dec_aggregator_mod.o amg_c_symdec_aggregator_mod.o
amg_c_dec_aggregator_mod.o amg_c_symdec_aggregator_mod.o \
amg_c_ainv_solver.o amg_c_base_ainv_mod.o
MODOBJS=amg_base_prec_type.o amg_prec_type.o amg_prec_mod.o \
amg_s_prec_mod.o amg_d_prec_mod.o amg_c_prec_mod.o amg_z_prec_mod.o \
amg_base_ainv_mod.o \
$(SMODOBJS) $(DMODOBJS) $(CMODOBJS) $(ZMODOBJS)
@ -163,7 +168,12 @@ amg_cprecinit.o amg_cprecset.o: amg_c_diag_solver.o amg_c_ilu_solver.o \
amg_c_as_smoother.o amg_c_jac_smoother.o \
amg_c_id_solver.o amg_c_slu_solver.o amg_c_sludist_solver.o
amg_base_ainv_mod.o: amg_base_prec_type.o
amg_s_base_ainv_mod.o amg_d_base_ainv_mod.o amg_c_base_ainv_mod.o amg_z_base_ainv_mod.o: amg_base_ainv_mod.o
amg_s_ainv_solver.o: amg_base_ainv_mod.o amg_s_base_ainv_mod.o
amg_d_ainv_solver.o: amg_base_ainv_mod.o amg_d_base_ainv_mod.o
amg_c_ainv_solver.o: amg_base_ainv_mod.o amg_c_base_ainv_mod.o
amg_z_ainv_solver.o: amg_base_ainv_mod.o amg_z_base_ainv_mod.o
veryclean: clean
/bin/rm -f $(LIBNAME)

@ -0,0 +1,63 @@
!
!
! AMG-AINV: Approximate Inverse plugin for
! AMG4PSBLAS version 1.0
!
! (C) Copyright 2020
!
! Salvatore Filippone University of Rome Tor Vergata
!
! 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 AMG4PSBLAS 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 AMG4PSBLAS 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.
!
!
!
module amg_base_ainv_mod
use amg_base_prec_type
integer, parameter :: amg_inv_fillin_ = amg_ifpsz_ + 1
integer, parameter :: amg_ainv_alg_ = amg_inv_fillin_ + 1
integer, parameter :: amg_inv_thresh_ = amg_max_sub_solve_ + 1
#if 0
integer, parameter :: amg_ainv_orth1_ = amg_inv_thresh_ + 1
integer, parameter :: amg_ainv_orth2_ = amg_ainv_orth1_ + 1
integer, parameter :: amg_ainv_orth3_ = amg_ainv_orth2_ + 1
integer, parameter :: amg_ainv_orth4_ = amg_ainv_orth3_ + 1
integer, parameter :: amg_ainv_llk_ = amg_ainv_orth4_ + 1
#else
integer, parameter :: amg_ainv_llk_ = amg_inv_thresh_ + 1
#endif
integer, parameter :: amg_ainv_s_llk_ = amg_ainv_llk_ + 1
integer, parameter :: amg_ainv_s_ft_llk_ = amg_ainv_s_llk_ + 1
integer, parameter :: amg_ainv_llk_noth_ = amg_ainv_s_ft_llk_ + 1
integer, parameter :: amg_ainv_mlk_ = amg_ainv_llk_noth_ + 1
integer, parameter :: amg_ainv_lmx_ = amg_ainv_mlk_
#if defined(HAVE_TUMA_SAINV)
integer, parameter :: amg_ainv_s_tuma_ = amg_ainv_lmx_ + 1
integer, parameter :: amg_ainv_l_tuma_ = amg_ainv_s_tuma_ + 1
#endif
end module amg_base_ainv_mod

@ -0,0 +1,322 @@
!
!
! AMG-AINV: Approximate Inverse plugin for
! AMG4PSBLAS version 1.0
!
! (C) Copyright 2020
!
! Salvatore Filippone University of Rome Tor Vergata
!
! 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 AMG4PSBLAS 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 AMG4PSBLAS 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.
!
!
!
!
!
!
!
module amg_c_ainv_solver
use amg_c_prec_type
use amg_c_base_ainv_mod
use psb_base_mod, only : psb_d_vect_type
type, extends(amg_c_base_ainv_solver_type) :: amg_c_ainv_solver_type
!
! Compute an approximate factorization
! A^-1 = Z D^-1 W^T
! Note that here W is going to be transposed explicitly,
! so that the component w will in the end contain W^T.
!
integer(psb_ipk_) :: alg, fill_in
real(psb_spk_) :: thresh
contains
procedure, pass(sv) :: check => amg_c_ainv_solver_check
procedure, pass(sv) :: build => amg_c_ainv_solver_bld
procedure, pass(sv) :: clone => amg_c_ainv_solver_clone
procedure, pass(sv) :: cseti => amg_c_ainv_solver_cseti
procedure, pass(sv) :: csetc => amg_c_ainv_solver_csetc
procedure, pass(sv) :: csetr => amg_c_ainv_solver_csetr
procedure, pass(sv) :: seti => amg_c_ainv_solver_seti
procedure, pass(sv) :: setc => amg_c_ainv_solver_setc
procedure, pass(sv) :: setr => amg_c_ainv_solver_setr
generic, public :: set => seti, setr, setc
procedure, pass(sv) :: descr => amg_c_ainv_solver_descr
procedure, pass(sv) :: default => c_ainv_solver_default
procedure, nopass :: stringval => c_ainv_stringval
procedure, nopass :: algname => c_ainv_algname
end type amg_c_ainv_solver_type
private :: c_ainv_stringval, c_ainv_solver_default, &
& c_ainv_algname
interface
subroutine amg_c_ainv_solver_clone(sv,svout,info)
import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, &
& amg_c_base_solver_type, psb_dpk_, amg_c_ainv_solver_type, psb_ipk_
Implicit None
class(amg_c_ainv_solver_type), intent(inout) :: sv
class(amg_c_base_solver_type), allocatable, intent(inout) :: svout
integer(psb_ipk_), intent(out) :: info
end subroutine amg_c_ainv_solver_clone
end interface
interface
subroutine amg_c_ainv_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold)
import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, &
& psb_d_vect_type, psb_c_base_vect_type, psb_dpk_,&
& amg_c_ainv_solver_type, psb_i_base_vect_type, psb_ipk_
Implicit None
! Arguments
type(psb_cspmat_type), intent(in), target :: a
Type(psb_desc_type), Intent(inout) :: desc_a
class(amg_c_ainv_solver_type), intent(inout) :: sv
integer(psb_ipk_), intent(out) :: info
type(psb_cspmat_type), intent(in), target, optional :: b
class(psb_c_base_sparse_mat), intent(in), optional :: amold
class(psb_c_base_vect_type), intent(in), optional :: vmold
class(psb_i_base_vect_type), intent(in), optional :: imold
end subroutine amg_c_ainv_solver_bld
end interface
interface
subroutine amg_c_ainv_solver_check(sv,info)
import :: psb_dpk_, amg_c_ainv_solver_type, psb_ipk_
Implicit None
! Arguments
class(amg_c_ainv_solver_type), intent(inout) :: sv
integer(psb_ipk_), intent(out) :: info
end subroutine amg_c_ainv_solver_check
end interface
interface
subroutine amg_c_ainv_solver_cseti(sv,what,val,info,idx)
import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, psb_ipk_,&
& psb_d_vect_type, psb_c_base_vect_type, psb_dpk_, amg_c_ainv_solver_type
Implicit None
! Arguments
class(amg_c_ainv_solver_type), intent(inout) :: sv
character(len=*), intent(in) :: what
integer(psb_ipk_), intent(in) :: val
integer(psb_ipk_), intent(out) :: info
integer(psb_ipk_), intent(in), optional :: idx
end subroutine amg_c_ainv_solver_cseti
end interface
interface
subroutine amg_c_ainv_solver_csetc(sv,what,val,info,idx)
import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, psb_ipk_,&
& psb_d_vect_type, psb_c_base_vect_type, psb_dpk_, amg_c_ainv_solver_type
Implicit None
! Arguments
class(amg_c_ainv_solver_type), intent(inout) :: sv
character(len=*), intent(in) :: what
character(len=*), intent(in) :: val
integer(psb_ipk_), intent(out) :: info
integer(psb_ipk_), intent(in), optional :: idx
end subroutine amg_c_ainv_solver_csetc
end interface
interface
subroutine amg_c_ainv_solver_csetr(sv,what,val,info,idx)
import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, psb_ipk_,&
& psb_d_vect_type, psb_c_base_vect_type, psb_spk_, amg_c_ainv_solver_type
Implicit None
! Arguments
class(amg_c_ainv_solver_type), intent(inout) :: sv
character(len=*), intent(in) :: what
real(psb_spk_), intent(in) :: val
integer(psb_ipk_), intent(out) :: info
integer(psb_ipk_), intent(in), optional :: idx
end subroutine amg_c_ainv_solver_csetr
end interface
interface
subroutine amg_c_ainv_solver_setc(sv,what,val,info)
import :: amg_c_ainv_solver_type, psb_ipk_
Implicit none
! Arguments
class(amg_c_ainv_solver_type), intent(inout) :: sv
integer(psb_ipk_), intent(in) :: what
character(len=*), intent(in) :: val
integer(psb_ipk_), intent(out) :: info
end subroutine amg_c_ainv_solver_setc
end interface
interface
subroutine amg_c_ainv_solver_seti(sv,what,val,info)
import :: amg_c_ainv_solver_type, psb_ipk_
Implicit none
! Arguments
class(amg_c_ainv_solver_type), intent(inout) :: sv
integer(psb_ipk_), intent(in) :: what
integer(psb_ipk_), intent(in) :: val
integer(psb_ipk_), intent(out) :: info
end subroutine amg_c_ainv_solver_seti
end interface
interface
subroutine amg_c_ainv_solver_setr(sv,what,val,info)
import :: amg_c_ainv_solver_type, psb_ipk_, psb_spk_
Implicit none
! Arguments
class(amg_c_ainv_solver_type), intent(inout) :: sv
integer(psb_ipk_), intent(in) :: what
real(psb_spk_), intent(in) :: val
integer(psb_ipk_), intent(out) :: info
end subroutine amg_c_ainv_solver_setr
end interface
interface
subroutine amg_c_ainv_solver_descr(sv,info,iout,coarse)
import :: psb_dpk_, amg_c_ainv_solver_type, psb_ipk_
Implicit None
! Arguments
class(amg_c_ainv_solver_type), intent(in) :: sv
integer(psb_ipk_), intent(out) :: info
integer(psb_ipk_), intent(in), optional :: iout
logical, intent(in), optional :: coarse
end subroutine amg_c_ainv_solver_descr
end interface
interface amg_ainv_bld
subroutine amg_c_ainv_bld(a,alg,fillin,thresh,wmat,d,zmat,desc,info,blck,iscale)
import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, &
& psb_d_vect_type, psb_c_base_vect_type, psb_spk_, psb_ipk_
implicit none
type(psb_cspmat_type), intent(in), target :: a
integer(psb_ipk_), intent(in) :: fillin,alg
real(psb_spk_), intent(in) :: thresh
type(psb_cspmat_type), intent(inout) :: wmat, zmat
complex(psb_spk_), allocatable :: d(:)
Type(psb_desc_type), Intent(inout) :: desc
integer(psb_ipk_), intent(out) :: info
type(psb_cspmat_type), intent(in), optional :: blck
integer(psb_ipk_), intent(in), optional :: iscale
end subroutine amg_c_ainv_bld
end interface
contains
subroutine c_ainv_solver_default(sv)
use psb_base_mod
Implicit None
! Arguments
class(amg_c_ainv_solver_type), intent(inout) :: sv
sv%alg = amg_ainv_llk_
sv%fill_in = 0
sv%thresh = dzero
return
end subroutine c_ainv_solver_default
function is_positive_nz_min(ip) result(res)
implicit none
integer(psb_ipk_), intent(in) :: ip
logical :: res
res = (ip >= 1)
return
end function is_positive_nz_min
function c_ainv_stringval(string) result(val)
use psb_base_mod, only : psb_ipk_,psb_toupper
implicit none
! Arguments
character(len=*), intent(in) :: string
integer(psb_ipk_) :: val
character(len=*), parameter :: name='d_ainv_stringval'
select case(psb_toupper(trim(string)))
case('LLK')
val = amg_ainv_llk_
case('STAB-LLK')
val = amg_ainv_s_ft_llk_
case('SYM-LLK')
val = amg_ainv_s_llk_
case('MLK')
val = amg_ainv_mlk_
#if defined(HAVE_TUMA_SAINV)
case('SAINV-TUMA')
val = amg_ainv_s_tuma_
case('LAINV-TUMA')
val = amg_ainv_l_tuma_
#endif
case default
val = amg_stringval(string)
end select
end function c_ainv_stringval
function c_ainv_algname(ialg) result(val)
integer(psb_ipk_), intent(in) :: ialg
character(len=40) :: val
character(len=*), parameter :: mlkname = 'Left-looking, list merge '
character(len=*), parameter :: llkname = 'Left-looking '
character(len=*), parameter :: stabllkname = 'Stabilized Left-looking '
character(len=*), parameter :: sllkname = 'Symmetric Left-looking '
character(len=*), parameter :: sainvname = 'SAINV (Benzi & Tuma) '
character(len=*), parameter :: lainvname = 'LAINV (Benzi & Tuma) '
character(len=*), parameter :: defname = 'Unknown alg variant '
select case (ialg)
case(amg_ainv_mlk_)
val = mlkname
case(amg_ainv_llk_)
val = llkname
case(amg_ainv_s_llk_)
val = sllkname
case(amg_ainv_s_ft_llk_)
val = stabllkname
#if defined(HAVE_TUMA_SAINV)
case(amg_ainv_s_tuma_ )
val = sainvname
case(amg_ainv_l_tuma_ )
val = lainvname
#endif
case default
val = defname
end select
end function c_ainv_algname
end module amg_c_ainv_solver

@ -0,0 +1,199 @@
!
!
! AMG-AINV: Approximate Inverse plugin for
! AMG4PSBLAS version 1.0
!
! (C) Copyright 2020
!
! Salvatore Filippone University of Rome Tor Vergata
!
! 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 AMG4PSBLAS 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 AMG4PSBLAS 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.
!
!
!
module amg_c_base_ainv_mod
use amg_base_ainv_mod
use amg_c_prec_type
use psb_c_ainv_tools_mod
use psb_base_mod, only : psb_c_vect_type, psb_spk_, psb_epk_
type, extends(amg_c_base_solver_type) :: amg_c_base_ainv_solver_type
!
! Compute an approximate factorization
! A^-1 = Z D^-1 W^T
! Note that here W is going to be transposed explicitly,
! so that the component w will in the end contain W^T.
!
type(psb_cspmat_type) :: w, z
type(psb_c_vect_type) :: dv
complex(psb_spk_), allocatable :: d(:)
contains
procedure, pass(sv) :: cnv => amg_c_base_ainv_solver_cnv
procedure, pass(sv) :: dump => amg_c_base_ainv_solver_dmp
procedure, pass(sv) :: apply_v => amg_c_base_ainv_solver_apply_vect
procedure, pass(sv) :: apply_a => amg_c_base_ainv_solver_apply
procedure, pass(sv) :: free => amg_c_base_ainv_solver_free
procedure, pass(sv) :: sizeof => c_base_ainv_solver_sizeof
procedure, pass(sv) :: get_nzeros => c_base_ainv_get_nzeros
procedure, nopass :: get_wrksz => c_base_ainv_get_wrksize
procedure, pass(sv) :: update_a => amg_c_base_ainv_update_a
generic, public :: update => update_a
end type amg_c_base_ainv_solver_type
private :: c_base_ainv_solver_sizeof, &
& c_base_ainv_get_nzeros, c_base_ainv_get_wrksize
interface
subroutine amg_c_base_ainv_solver_cnv(sv,info,amold,vmold,imold)
import :: psb_c_base_sparse_mat, psb_c_base_vect_type, psb_spk_, &
& amg_c_base_ainv_solver_type, psb_ipk_, psb_i_base_vect_type
Implicit None
! Arguments
class(amg_c_base_ainv_solver_type), intent(inout) :: sv
integer(psb_ipk_), intent(out) :: info
class(psb_c_base_sparse_mat), intent(in), optional :: amold
class(psb_c_base_vect_type), intent(in), optional :: vmold
class(psb_i_base_vect_type), intent(in), optional :: imold
end subroutine amg_c_base_ainv_solver_cnv
end interface
interface
subroutine amg_c_base_ainv_update_a(sv,x,desc_data,info)
import :: psb_desc_type, psb_spk_,amg_c_base_ainv_solver_type, psb_c_vect_type, psb_ipk_
type(psb_desc_type), intent(in) :: desc_data
class(amg_c_base_ainv_solver_type), intent(inout) :: sv
complex(psb_spk_),intent(in) :: x(:)
integer(psb_ipk_), intent(out) :: info
end subroutine amg_c_base_ainv_update_a
end interface
interface
subroutine amg_c_base_ainv_solver_apply(alpha,sv,x,beta,y,desc_data,&
& trans,work,info,init,initu)
import :: psb_desc_type, psb_spk_,amg_c_base_ainv_solver_type, psb_ipk_
type(psb_desc_type), intent(in) :: desc_data
class(amg_c_base_ainv_solver_type), intent(inout) :: sv
complex(psb_spk_),intent(inout) :: x(:)
complex(psb_spk_),intent(inout) :: y(:)
complex(psb_spk_),intent(in) :: alpha,beta
character(len=1),intent(in) :: trans
complex(psb_spk_),target, intent(inout) :: work(:)
integer(psb_ipk_), intent(out) :: info
character, intent(in), optional :: init
complex(psb_spk_),intent(inout), optional :: initu(:)
end subroutine amg_c_base_ainv_solver_apply
end interface
interface
subroutine amg_c_base_ainv_solver_apply_vect(alpha,sv,x,beta,y,desc_data,&
& trans,work,wv,info,init,initu)
import :: psb_desc_type, psb_spk_,amg_c_base_ainv_solver_type, psb_c_vect_type, psb_ipk_
type(psb_desc_type), intent(in) :: desc_data
class(amg_c_base_ainv_solver_type), intent(inout) :: sv
type(psb_c_vect_type),intent(inout) :: x
type(psb_c_vect_type),intent(inout) :: y
complex(psb_spk_),intent(in) :: alpha,beta
character(len=1),intent(in) :: trans
complex(psb_spk_),target, intent(inout) :: work(:)
type(psb_c_vect_type),intent(inout) :: wv(:)
integer(psb_ipk_), intent(out) :: info
character, intent(in), optional :: init
type(psb_c_vect_type),intent(inout), optional :: initu
end subroutine amg_c_base_ainv_solver_apply_vect
end interface
interface
subroutine amg_c_base_ainv_solver_free(sv,info)
import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, &
& psb_c_vect_type, psb_c_base_vect_type, psb_spk_, amg_c_base_ainv_solver_type, psb_ipk_
Implicit None
! Arguments
class(amg_c_base_ainv_solver_type), intent(inout) :: sv
integer(psb_ipk_), intent(out) :: info
end subroutine amg_c_base_ainv_solver_free
end interface
interface
subroutine amg_c_base_ainv_solver_dmp(sv,desc,level,info,prefix,head,solver,global_num)
import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, &
& psb_c_vect_type, psb_c_base_vect_type, psb_spk_, amg_c_base_ainv_solver_type, psb_ipk_
implicit none
class(amg_c_base_ainv_solver_type), intent(in) :: sv
type(psb_desc_type), intent(in) :: desc
integer(psb_ipk_), intent(in) :: level
integer(psb_ipk_), intent(out) :: info
character(len=*), intent(in), optional :: prefix, head
logical, optional, intent(in) :: solver, global_num
end subroutine amg_c_base_ainv_solver_dmp
end interface
contains
function c_base_ainv_get_nzeros(sv) result(val)
implicit none
! Arguments
class(amg_c_base_ainv_solver_type), intent(in) :: sv
integer(psb_epk_) :: val
integer :: i
val = 0
val = val + sv%dv%get_nrows()
val = val + sv%w%get_nzeros()
val = val + sv%z%get_nzeros()
return
end function c_base_ainv_get_nzeros
function c_base_ainv_solver_sizeof(sv) result(val)
implicit none
! Arguments
class(amg_c_base_ainv_solver_type), intent(in) :: sv
integer(psb_epk_) :: val
integer :: i
val = 2*psb_sizeof_ip + psb_sizeof_dp
val = val + sv%dv%sizeof()
val = val + sv%w%sizeof()
val = val + sv%z%sizeof()
return
end function c_base_ainv_solver_sizeof
function c_base_ainv_get_wrksize() result(val)
implicit none
integer(psb_ipk_) :: val
val = 2
end function c_base_ainv_get_wrksize
end module amg_c_base_ainv_mod

@ -0,0 +1,322 @@
!
!
! AMG-AINV: Approximate Inverse plugin for
! AMG4PSBLAS version 1.0
!
! (C) Copyright 2020
!
! Salvatore Filippone University of Rome Tor Vergata
!
! 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 AMG4PSBLAS 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 AMG4PSBLAS 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.
!
!
!
!
!
!
!
module amg_d_ainv_solver
use amg_d_prec_type
use amg_d_base_ainv_mod
use psb_base_mod, only : psb_d_vect_type
type, extends(amg_d_base_ainv_solver_type) :: amg_d_ainv_solver_type
!
! Compute an approximate factorization
! A^-1 = Z D^-1 W^T
! Note that here W is going to be transposed explicitly,
! so that the component w will in the end contain W^T.
!
integer(psb_ipk_) :: alg, fill_in
real(psb_dpk_) :: thresh
contains
procedure, pass(sv) :: check => amg_d_ainv_solver_check
procedure, pass(sv) :: build => amg_d_ainv_solver_bld
procedure, pass(sv) :: clone => amg_d_ainv_solver_clone
procedure, pass(sv) :: cseti => amg_d_ainv_solver_cseti
procedure, pass(sv) :: csetc => amg_d_ainv_solver_csetc
procedure, pass(sv) :: csetr => amg_d_ainv_solver_csetr
procedure, pass(sv) :: seti => amg_d_ainv_solver_seti
procedure, pass(sv) :: setc => amg_d_ainv_solver_setc
procedure, pass(sv) :: setr => amg_d_ainv_solver_setr
generic, public :: set => seti, setr, setc
procedure, pass(sv) :: descr => amg_d_ainv_solver_descr
procedure, pass(sv) :: default => d_ainv_solver_default
procedure, nopass :: stringval => d_ainv_stringval
procedure, nopass :: algname => d_ainv_algname
end type amg_d_ainv_solver_type
private :: d_ainv_stringval, d_ainv_solver_default, &
& d_ainv_algname
interface
subroutine amg_d_ainv_solver_clone(sv,svout,info)
import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, &
& amg_d_base_solver_type, psb_dpk_, amg_d_ainv_solver_type, psb_ipk_
Implicit None
class(amg_d_ainv_solver_type), intent(inout) :: sv
class(amg_d_base_solver_type), allocatable, intent(inout) :: svout
integer(psb_ipk_), intent(out) :: info
end subroutine amg_d_ainv_solver_clone
end interface
interface
subroutine amg_d_ainv_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold)
import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, &
& psb_d_vect_type, psb_d_base_vect_type, psb_dpk_,&
& amg_d_ainv_solver_type, psb_i_base_vect_type, psb_ipk_
Implicit None
! Arguments
type(psb_dspmat_type), intent(in), target :: a
Type(psb_desc_type), Intent(inout) :: desc_a
class(amg_d_ainv_solver_type), intent(inout) :: sv
integer(psb_ipk_), intent(out) :: info
type(psb_dspmat_type), intent(in), target, optional :: b
class(psb_d_base_sparse_mat), intent(in), optional :: amold
class(psb_d_base_vect_type), intent(in), optional :: vmold
class(psb_i_base_vect_type), intent(in), optional :: imold
end subroutine amg_d_ainv_solver_bld
end interface
interface
subroutine amg_d_ainv_solver_check(sv,info)
import :: psb_dpk_, amg_d_ainv_solver_type, psb_ipk_
Implicit None
! Arguments
class(amg_d_ainv_solver_type), intent(inout) :: sv
integer(psb_ipk_), intent(out) :: info
end subroutine amg_d_ainv_solver_check
end interface
interface
subroutine amg_d_ainv_solver_cseti(sv,what,val,info,idx)
import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, psb_ipk_,&
& psb_d_vect_type, psb_d_base_vect_type, psb_dpk_, amg_d_ainv_solver_type
Implicit None
! Arguments
class(amg_d_ainv_solver_type), intent(inout) :: sv
character(len=*), intent(in) :: what
integer(psb_ipk_), intent(in) :: val
integer(psb_ipk_), intent(out) :: info
integer(psb_ipk_), intent(in), optional :: idx
end subroutine amg_d_ainv_solver_cseti
end interface
interface
subroutine amg_d_ainv_solver_csetc(sv,what,val,info,idx)
import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, psb_ipk_,&
& psb_d_vect_type, psb_d_base_vect_type, psb_dpk_, amg_d_ainv_solver_type
Implicit None
! Arguments
class(amg_d_ainv_solver_type), intent(inout) :: sv
character(len=*), intent(in) :: what
character(len=*), intent(in) :: val
integer(psb_ipk_), intent(out) :: info
integer(psb_ipk_), intent(in), optional :: idx
end subroutine amg_d_ainv_solver_csetc
end interface
interface
subroutine amg_d_ainv_solver_csetr(sv,what,val,info,idx)
import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, psb_ipk_,&
& psb_d_vect_type, psb_d_base_vect_type, psb_dpk_, amg_d_ainv_solver_type
Implicit None
! Arguments
class(amg_d_ainv_solver_type), intent(inout) :: sv
character(len=*), intent(in) :: what
real(psb_dpk_), intent(in) :: val
integer(psb_ipk_), intent(out) :: info
integer(psb_ipk_), intent(in), optional :: idx
end subroutine amg_d_ainv_solver_csetr
end interface
interface
subroutine amg_d_ainv_solver_setc(sv,what,val,info)
import :: amg_d_ainv_solver_type, psb_ipk_
Implicit none
! Arguments
class(amg_d_ainv_solver_type), intent(inout) :: sv
integer(psb_ipk_), intent(in) :: what
character(len=*), intent(in) :: val
integer(psb_ipk_), intent(out) :: info
end subroutine amg_d_ainv_solver_setc
end interface
interface
subroutine amg_d_ainv_solver_seti(sv,what,val,info)
import :: amg_d_ainv_solver_type, psb_ipk_
Implicit none
! Arguments
class(amg_d_ainv_solver_type), intent(inout) :: sv
integer(psb_ipk_), intent(in) :: what
integer(psb_ipk_), intent(in) :: val
integer(psb_ipk_), intent(out) :: info
end subroutine amg_d_ainv_solver_seti
end interface
interface
subroutine amg_d_ainv_solver_setr(sv,what,val,info)
import :: amg_d_ainv_solver_type, psb_ipk_, psb_dpk_
Implicit none
! Arguments
class(amg_d_ainv_solver_type), intent(inout) :: sv
integer(psb_ipk_), intent(in) :: what
real(psb_dpk_), intent(in) :: val
integer(psb_ipk_), intent(out) :: info
end subroutine amg_d_ainv_solver_setr
end interface
interface
subroutine amg_d_ainv_solver_descr(sv,info,iout,coarse)
import :: psb_dpk_, amg_d_ainv_solver_type, psb_ipk_
Implicit None
! Arguments
class(amg_d_ainv_solver_type), intent(in) :: sv
integer(psb_ipk_), intent(out) :: info
integer(psb_ipk_), intent(in), optional :: iout
logical, intent(in), optional :: coarse
end subroutine amg_d_ainv_solver_descr
end interface
interface amg_ainv_bld
subroutine amg_d_ainv_bld(a,alg,fillin,thresh,wmat,d,zmat,desc,info,blck,iscale)
import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, &
& psb_d_vect_type, psb_d_base_vect_type, psb_dpk_, psb_ipk_
implicit none
type(psb_dspmat_type), intent(in), target :: a
integer(psb_ipk_), intent(in) :: fillin,alg
real(psb_dpk_), intent(in) :: thresh
type(psb_dspmat_type), intent(inout) :: wmat, zmat
real(psb_dpk_), allocatable :: d(:)
Type(psb_desc_type), Intent(inout) :: desc
integer(psb_ipk_), intent(out) :: info
type(psb_dspmat_type), intent(in), optional :: blck
integer(psb_ipk_), intent(in), optional :: iscale
end subroutine amg_d_ainv_bld
end interface
contains
subroutine d_ainv_solver_default(sv)
use psb_base_mod
Implicit None
! Arguments
class(amg_d_ainv_solver_type), intent(inout) :: sv
sv%alg = amg_ainv_llk_
sv%fill_in = 0
sv%thresh = dzero
return
end subroutine d_ainv_solver_default
function is_positive_nz_min(ip) result(res)
implicit none
integer(psb_ipk_), intent(in) :: ip
logical :: res
res = (ip >= 1)
return
end function is_positive_nz_min
function d_ainv_stringval(string) result(val)
use psb_base_mod, only : psb_ipk_,psb_toupper
implicit none
! Arguments
character(len=*), intent(in) :: string
integer(psb_ipk_) :: val
character(len=*), parameter :: name='d_ainv_stringval'
select case(psb_toupper(trim(string)))
case('LLK')
val = amg_ainv_llk_
case('STAB-LLK')
val = amg_ainv_s_ft_llk_
case('SYM-LLK')
val = amg_ainv_s_llk_
case('MLK')
val = amg_ainv_mlk_
#if defined(HAVE_TUMA_SAINV)
case('SAINV-TUMA')
val = amg_ainv_s_tuma_
case('LAINV-TUMA')
val = amg_ainv_l_tuma_
#endif
case default
val = amg_stringval(string)
end select
end function d_ainv_stringval
function d_ainv_algname(ialg) result(val)
integer(psb_ipk_), intent(in) :: ialg
character(len=40) :: val
character(len=*), parameter :: mlkname = 'Left-looking, list merge '
character(len=*), parameter :: llkname = 'Left-looking '
character(len=*), parameter :: stabllkname = 'Stabilized Left-looking '
character(len=*), parameter :: sllkname = 'Symmetric Left-looking '
character(len=*), parameter :: sainvname = 'SAINV (Benzi & Tuma) '
character(len=*), parameter :: lainvname = 'LAINV (Benzi & Tuma) '
character(len=*), parameter :: defname = 'Unknown alg variant '
select case (ialg)
case(amg_ainv_mlk_)
val = mlkname
case(amg_ainv_llk_)
val = llkname
case(amg_ainv_s_llk_)
val = sllkname
case(amg_ainv_s_ft_llk_)
val = stabllkname
#if defined(HAVE_TUMA_SAINV)
case(amg_ainv_s_tuma_ )
val = sainvname
case(amg_ainv_l_tuma_ )
val = lainvname
#endif
case default
val = defname
end select
end function d_ainv_algname
end module amg_d_ainv_solver

@ -0,0 +1,199 @@
!
!
! AMG-AINV: Approximate Inverse plugin for
! AMG4PSBLAS version 1.0
!
! (C) Copyright 2020
!
! Salvatore Filippone University of Rome Tor Vergata
!
! 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 AMG4PSBLAS 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 AMG4PSBLAS 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.
!
!
!
module amg_d_base_ainv_mod
use amg_base_ainv_mod
use amg_d_prec_type
use psb_d_ainv_tools_mod
use psb_base_mod, only : psb_d_vect_type, psb_dpk_, psb_epk_
type, extends(amg_d_base_solver_type) :: amg_d_base_ainv_solver_type
!
! Compute an approximate factorization
! A^-1 = Z D^-1 W^T
! Note that here W is going to be transposed explicitly,
! so that the component w will in the end contain W^T.
!
type(psb_dspmat_type) :: w, z
type(psb_d_vect_type) :: dv
real(psb_dpk_), allocatable :: d(:)
contains
procedure, pass(sv) :: cnv => amg_d_base_ainv_solver_cnv
procedure, pass(sv) :: dump => amg_d_base_ainv_solver_dmp
procedure, pass(sv) :: apply_v => amg_d_base_ainv_solver_apply_vect
procedure, pass(sv) :: apply_a => amg_d_base_ainv_solver_apply
procedure, pass(sv) :: free => amg_d_base_ainv_solver_free
procedure, pass(sv) :: sizeof => d_base_ainv_solver_sizeof
procedure, pass(sv) :: get_nzeros => d_base_ainv_get_nzeros
procedure, nopass :: get_wrksz => d_base_ainv_get_wrksize
procedure, pass(sv) :: update_a => amg_d_base_ainv_update_a
generic, public :: update => update_a
end type amg_d_base_ainv_solver_type
private :: d_base_ainv_solver_sizeof, &
& d_base_ainv_get_nzeros, d_base_ainv_get_wrksize
interface
subroutine amg_d_base_ainv_solver_cnv(sv,info,amold,vmold,imold)
import :: psb_d_base_sparse_mat, psb_d_base_vect_type, psb_dpk_, &
& amg_d_base_ainv_solver_type, psb_ipk_, psb_i_base_vect_type
Implicit None
! Arguments
class(amg_d_base_ainv_solver_type), intent(inout) :: sv
integer(psb_ipk_), intent(out) :: info
class(psb_d_base_sparse_mat), intent(in), optional :: amold
class(psb_d_base_vect_type), intent(in), optional :: vmold
class(psb_i_base_vect_type), intent(in), optional :: imold
end subroutine amg_d_base_ainv_solver_cnv
end interface
interface
subroutine amg_d_base_ainv_update_a(sv,x,desc_data,info)
import :: psb_desc_type, psb_dpk_,amg_d_base_ainv_solver_type, psb_d_vect_type, psb_ipk_
type(psb_desc_type), intent(in) :: desc_data
class(amg_d_base_ainv_solver_type), intent(inout) :: sv
real(psb_dpk_),intent(in) :: x(:)
integer(psb_ipk_), intent(out) :: info
end subroutine amg_d_base_ainv_update_a
end interface
interface
subroutine amg_d_base_ainv_solver_apply(alpha,sv,x,beta,y,desc_data,&
& trans,work,info,init,initu)
import :: psb_desc_type, psb_dpk_,amg_d_base_ainv_solver_type, psb_ipk_
type(psb_desc_type), intent(in) :: desc_data
class(amg_d_base_ainv_solver_type), intent(inout) :: sv
real(psb_dpk_),intent(inout) :: x(:)
real(psb_dpk_),intent(inout) :: y(:)
real(psb_dpk_),intent(in) :: alpha,beta
character(len=1),intent(in) :: trans
real(psb_dpk_),target, intent(inout) :: work(:)
integer(psb_ipk_), intent(out) :: info
character, intent(in), optional :: init
real(psb_dpk_),intent(inout), optional :: initu(:)
end subroutine amg_d_base_ainv_solver_apply
end interface
interface
subroutine amg_d_base_ainv_solver_apply_vect(alpha,sv,x,beta,y,desc_data,&
& trans,work,wv,info,init,initu)
import :: psb_desc_type, psb_dpk_,amg_d_base_ainv_solver_type, psb_d_vect_type, psb_ipk_
type(psb_desc_type), intent(in) :: desc_data
class(amg_d_base_ainv_solver_type), intent(inout) :: sv
type(psb_d_vect_type),intent(inout) :: x
type(psb_d_vect_type),intent(inout) :: y
real(psb_dpk_),intent(in) :: alpha,beta
character(len=1),intent(in) :: trans
real(psb_dpk_),target, intent(inout) :: work(:)
type(psb_d_vect_type),intent(inout) :: wv(:)
integer(psb_ipk_), intent(out) :: info
character, intent(in), optional :: init
type(psb_d_vect_type),intent(inout), optional :: initu
end subroutine amg_d_base_ainv_solver_apply_vect
end interface
interface
subroutine amg_d_base_ainv_solver_free(sv,info)
import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, &
& psb_d_vect_type, psb_d_base_vect_type, psb_dpk_, amg_d_base_ainv_solver_type, psb_ipk_
Implicit None
! Arguments
class(amg_d_base_ainv_solver_type), intent(inout) :: sv
integer(psb_ipk_), intent(out) :: info
end subroutine amg_d_base_ainv_solver_free
end interface
interface
subroutine amg_d_base_ainv_solver_dmp(sv,desc,level,info,prefix,head,solver,global_num)
import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, &
& psb_d_vect_type, psb_d_base_vect_type, psb_dpk_, amg_d_base_ainv_solver_type, psb_ipk_
implicit none
class(amg_d_base_ainv_solver_type), intent(in) :: sv
type(psb_desc_type), intent(in) :: desc
integer(psb_ipk_), intent(in) :: level
integer(psb_ipk_), intent(out) :: info
character(len=*), intent(in), optional :: prefix, head
logical, optional, intent(in) :: solver, global_num
end subroutine amg_d_base_ainv_solver_dmp
end interface
contains
function d_base_ainv_get_nzeros(sv) result(val)
implicit none
! Arguments
class(amg_d_base_ainv_solver_type), intent(in) :: sv
integer(psb_epk_) :: val
integer :: i
val = 0
val = val + sv%dv%get_nrows()
val = val + sv%w%get_nzeros()
val = val + sv%z%get_nzeros()
return
end function d_base_ainv_get_nzeros
function d_base_ainv_solver_sizeof(sv) result(val)
implicit none
! Arguments
class(amg_d_base_ainv_solver_type), intent(in) :: sv
integer(psb_epk_) :: val
integer :: i
val = 2*psb_sizeof_ip + psb_sizeof_dp
val = val + sv%dv%sizeof()
val = val + sv%w%sizeof()
val = val + sv%z%sizeof()
return
end function d_base_ainv_solver_sizeof
function d_base_ainv_get_wrksize() result(val)
implicit none
integer(psb_ipk_) :: val
val = 2
end function d_base_ainv_get_wrksize
end module amg_d_base_ainv_mod

@ -0,0 +1,322 @@
!
!
! AMG-AINV: Approximate Inverse plugin for
! AMG4PSBLAS version 1.0
!
! (C) Copyright 2020
!
! Salvatore Filippone University of Rome Tor Vergata
!
! 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 AMG4PSBLAS 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 AMG4PSBLAS 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.
!
!
!
!
!
!
!
module amg_s_ainv_solver
use amg_s_prec_type
use amg_s_base_ainv_mod
use psb_base_mod, only : psb_d_vect_type
type, extends(amg_s_base_ainv_solver_type) :: amg_s_ainv_solver_type
!
! Compute an approximate factorization
! A^-1 = Z D^-1 W^T
! Note that here W is going to be transposed explicitly,
! so that the component w will in the end contain W^T.
!
integer(psb_ipk_) :: alg, fill_in
real(psb_spk_) :: thresh
contains
procedure, pass(sv) :: check => amg_s_ainv_solver_check
procedure, pass(sv) :: build => amg_s_ainv_solver_bld
procedure, pass(sv) :: clone => amg_s_ainv_solver_clone
procedure, pass(sv) :: cseti => amg_s_ainv_solver_cseti
procedure, pass(sv) :: csetc => amg_s_ainv_solver_csetc
procedure, pass(sv) :: csetr => amg_s_ainv_solver_csetr
procedure, pass(sv) :: seti => amg_s_ainv_solver_seti
procedure, pass(sv) :: setc => amg_s_ainv_solver_setc
procedure, pass(sv) :: setr => amg_s_ainv_solver_setr
generic, public :: set => seti, setr, setc
procedure, pass(sv) :: descr => amg_s_ainv_solver_descr
procedure, pass(sv) :: default => s_ainv_solver_default
procedure, nopass :: stringval => s_ainv_stringval
procedure, nopass :: algname => s_ainv_algname
end type amg_s_ainv_solver_type
private :: s_ainv_stringval, s_ainv_solver_default, &
& s_ainv_algname
interface
subroutine amg_s_ainv_solver_clone(sv,svout,info)
import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, &
& amg_s_base_solver_type, psb_dpk_, amg_s_ainv_solver_type, psb_ipk_
Implicit None
class(amg_s_ainv_solver_type), intent(inout) :: sv
class(amg_s_base_solver_type), allocatable, intent(inout) :: svout
integer(psb_ipk_), intent(out) :: info
end subroutine amg_s_ainv_solver_clone
end interface
interface
subroutine amg_s_ainv_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold)
import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, &
& psb_d_vect_type, psb_s_base_vect_type, psb_dpk_,&
& amg_s_ainv_solver_type, psb_i_base_vect_type, psb_ipk_
Implicit None
! Arguments
type(psb_sspmat_type), intent(in), target :: a
Type(psb_desc_type), Intent(inout) :: desc_a
class(amg_s_ainv_solver_type), intent(inout) :: sv
integer(psb_ipk_), intent(out) :: info
type(psb_sspmat_type), intent(in), target, optional :: b
class(psb_s_base_sparse_mat), intent(in), optional :: amold
class(psb_s_base_vect_type), intent(in), optional :: vmold
class(psb_i_base_vect_type), intent(in), optional :: imold
end subroutine amg_s_ainv_solver_bld
end interface
interface
subroutine amg_s_ainv_solver_check(sv,info)
import :: psb_dpk_, amg_s_ainv_solver_type, psb_ipk_
Implicit None
! Arguments
class(amg_s_ainv_solver_type), intent(inout) :: sv
integer(psb_ipk_), intent(out) :: info
end subroutine amg_s_ainv_solver_check
end interface
interface
subroutine amg_s_ainv_solver_cseti(sv,what,val,info,idx)
import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, psb_ipk_,&
& psb_d_vect_type, psb_s_base_vect_type, psb_dpk_, amg_s_ainv_solver_type
Implicit None
! Arguments
class(amg_s_ainv_solver_type), intent(inout) :: sv
character(len=*), intent(in) :: what
integer(psb_ipk_), intent(in) :: val
integer(psb_ipk_), intent(out) :: info
integer(psb_ipk_), intent(in), optional :: idx
end subroutine amg_s_ainv_solver_cseti
end interface
interface
subroutine amg_s_ainv_solver_csetc(sv,what,val,info,idx)
import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, psb_ipk_,&
& psb_d_vect_type, psb_s_base_vect_type, psb_dpk_, amg_s_ainv_solver_type
Implicit None
! Arguments
class(amg_s_ainv_solver_type), intent(inout) :: sv
character(len=*), intent(in) :: what
character(len=*), intent(in) :: val
integer(psb_ipk_), intent(out) :: info
integer(psb_ipk_), intent(in), optional :: idx
end subroutine amg_s_ainv_solver_csetc
end interface
interface
subroutine amg_s_ainv_solver_csetr(sv,what,val,info,idx)
import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, psb_ipk_,&
& psb_d_vect_type, psb_s_base_vect_type, psb_spk_, amg_s_ainv_solver_type
Implicit None
! Arguments
class(amg_s_ainv_solver_type), intent(inout) :: sv
character(len=*), intent(in) :: what
real(psb_spk_), intent(in) :: val
integer(psb_ipk_), intent(out) :: info
integer(psb_ipk_), intent(in), optional :: idx
end subroutine amg_s_ainv_solver_csetr
end interface
interface
subroutine amg_s_ainv_solver_setc(sv,what,val,info)
import :: amg_s_ainv_solver_type, psb_ipk_
Implicit none
! Arguments
class(amg_s_ainv_solver_type), intent(inout) :: sv
integer(psb_ipk_), intent(in) :: what
character(len=*), intent(in) :: val
integer(psb_ipk_), intent(out) :: info
end subroutine amg_s_ainv_solver_setc
end interface
interface
subroutine amg_s_ainv_solver_seti(sv,what,val,info)
import :: amg_s_ainv_solver_type, psb_ipk_
Implicit none
! Arguments
class(amg_s_ainv_solver_type), intent(inout) :: sv
integer(psb_ipk_), intent(in) :: what
integer(psb_ipk_), intent(in) :: val
integer(psb_ipk_), intent(out) :: info
end subroutine amg_s_ainv_solver_seti
end interface
interface
subroutine amg_s_ainv_solver_setr(sv,what,val,info)
import :: amg_s_ainv_solver_type, psb_ipk_, psb_spk_
Implicit none
! Arguments
class(amg_s_ainv_solver_type), intent(inout) :: sv
integer(psb_ipk_), intent(in) :: what
real(psb_spk_), intent(in) :: val
integer(psb_ipk_), intent(out) :: info
end subroutine amg_s_ainv_solver_setr
end interface
interface
subroutine amg_s_ainv_solver_descr(sv,info,iout,coarse)
import :: psb_dpk_, amg_s_ainv_solver_type, psb_ipk_
Implicit None
! Arguments
class(amg_s_ainv_solver_type), intent(in) :: sv
integer(psb_ipk_), intent(out) :: info
integer(psb_ipk_), intent(in), optional :: iout
logical, intent(in), optional :: coarse
end subroutine amg_s_ainv_solver_descr
end interface
interface amg_ainv_bld
subroutine amg_s_ainv_bld(a,alg,fillin,thresh,wmat,d,zmat,desc,info,blck,iscale)
import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, &
& psb_d_vect_type, psb_s_base_vect_type, psb_spk_, psb_ipk_
implicit none
type(psb_sspmat_type), intent(in), target :: a
integer(psb_ipk_), intent(in) :: fillin,alg
real(psb_spk_), intent(in) :: thresh
type(psb_sspmat_type), intent(inout) :: wmat, zmat
real(psb_spk_), allocatable :: d(:)
Type(psb_desc_type), Intent(inout) :: desc
integer(psb_ipk_), intent(out) :: info
type(psb_sspmat_type), intent(in), optional :: blck
integer(psb_ipk_), intent(in), optional :: iscale
end subroutine amg_s_ainv_bld
end interface
contains
subroutine s_ainv_solver_default(sv)
use psb_base_mod
Implicit None
! Arguments
class(amg_s_ainv_solver_type), intent(inout) :: sv
sv%alg = amg_ainv_llk_
sv%fill_in = 0
sv%thresh = dzero
return
end subroutine s_ainv_solver_default
function is_positive_nz_min(ip) result(res)
implicit none
integer(psb_ipk_), intent(in) :: ip
logical :: res
res = (ip >= 1)
return
end function is_positive_nz_min
function s_ainv_stringval(string) result(val)
use psb_base_mod, only : psb_ipk_,psb_toupper
implicit none
! Arguments
character(len=*), intent(in) :: string
integer(psb_ipk_) :: val
character(len=*), parameter :: name='d_ainv_stringval'
select case(psb_toupper(trim(string)))
case('LLK')
val = amg_ainv_llk_
case('STAB-LLK')
val = amg_ainv_s_ft_llk_
case('SYM-LLK')
val = amg_ainv_s_llk_
case('MLK')
val = amg_ainv_mlk_
#if defined(HAVE_TUMA_SAINV)
case('SAINV-TUMA')
val = amg_ainv_s_tuma_
case('LAINV-TUMA')
val = amg_ainv_l_tuma_
#endif
case default
val = amg_stringval(string)
end select
end function s_ainv_stringval
function s_ainv_algname(ialg) result(val)
integer(psb_ipk_), intent(in) :: ialg
character(len=40) :: val
character(len=*), parameter :: mlkname = 'Left-looking, list merge '
character(len=*), parameter :: llkname = 'Left-looking '
character(len=*), parameter :: stabllkname = 'Stabilized Left-looking '
character(len=*), parameter :: sllkname = 'Symmetric Left-looking '
character(len=*), parameter :: sainvname = 'SAINV (Benzi & Tuma) '
character(len=*), parameter :: lainvname = 'LAINV (Benzi & Tuma) '
character(len=*), parameter :: defname = 'Unknown alg variant '
select case (ialg)
case(amg_ainv_mlk_)
val = mlkname
case(amg_ainv_llk_)
val = llkname
case(amg_ainv_s_llk_)
val = sllkname
case(amg_ainv_s_ft_llk_)
val = stabllkname
#if defined(HAVE_TUMA_SAINV)
case(amg_ainv_s_tuma_ )
val = sainvname
case(amg_ainv_l_tuma_ )
val = lainvname
#endif
case default
val = defname
end select
end function s_ainv_algname
end module amg_s_ainv_solver

@ -0,0 +1,199 @@
!
!
! AMG-AINV: Approximate Inverse plugin for
! AMG4PSBLAS version 1.0
!
! (C) Copyright 2020
!
! Salvatore Filippone University of Rome Tor Vergata
!
! 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 AMG4PSBLAS 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 AMG4PSBLAS 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.
!
!
!
module amg_s_base_ainv_mod
use amg_base_ainv_mod
use amg_s_prec_type
use psb_s_ainv_tools_mod
use psb_base_mod, only : psb_s_vect_type, psb_spk_, psb_epk_
type, extends(amg_s_base_solver_type) :: amg_s_base_ainv_solver_type
!
! Compute an approximate factorization
! A^-1 = Z D^-1 W^T
! Note that here W is going to be transposed explicitly,
! so that the component w will in the end contain W^T.
!
type(psb_sspmat_type) :: w, z
type(psb_s_vect_type) :: dv
real(psb_spk_), allocatable :: d(:)
contains
procedure, pass(sv) :: cnv => amg_s_base_ainv_solver_cnv
procedure, pass(sv) :: dump => amg_s_base_ainv_solver_dmp
procedure, pass(sv) :: apply_v => amg_s_base_ainv_solver_apply_vect
procedure, pass(sv) :: apply_a => amg_s_base_ainv_solver_apply
procedure, pass(sv) :: free => amg_s_base_ainv_solver_free
procedure, pass(sv) :: sizeof => s_base_ainv_solver_sizeof
procedure, pass(sv) :: get_nzeros => s_base_ainv_get_nzeros
procedure, nopass :: get_wrksz => s_base_ainv_get_wrksize
procedure, pass(sv) :: update_a => amg_s_base_ainv_update_a
generic, public :: update => update_a
end type amg_s_base_ainv_solver_type
private :: s_base_ainv_solver_sizeof, &
& s_base_ainv_get_nzeros, s_base_ainv_get_wrksize
interface
subroutine amg_s_base_ainv_solver_cnv(sv,info,amold,vmold,imold)
import :: psb_s_base_sparse_mat, psb_s_base_vect_type, psb_spk_, &
& amg_s_base_ainv_solver_type, psb_ipk_, psb_i_base_vect_type
Implicit None
! Arguments
class(amg_s_base_ainv_solver_type), intent(inout) :: sv
integer(psb_ipk_), intent(out) :: info
class(psb_s_base_sparse_mat), intent(in), optional :: amold
class(psb_s_base_vect_type), intent(in), optional :: vmold
class(psb_i_base_vect_type), intent(in), optional :: imold
end subroutine amg_s_base_ainv_solver_cnv
end interface
interface
subroutine amg_s_base_ainv_update_a(sv,x,desc_data,info)
import :: psb_desc_type, psb_spk_,amg_s_base_ainv_solver_type, psb_s_vect_type, psb_ipk_
type(psb_desc_type), intent(in) :: desc_data
class(amg_s_base_ainv_solver_type), intent(inout) :: sv
real(psb_spk_),intent(in) :: x(:)
integer(psb_ipk_), intent(out) :: info
end subroutine amg_s_base_ainv_update_a
end interface
interface
subroutine amg_s_base_ainv_solver_apply(alpha,sv,x,beta,y,desc_data,&
& trans,work,info,init,initu)
import :: psb_desc_type, psb_spk_,amg_s_base_ainv_solver_type, psb_ipk_
type(psb_desc_type), intent(in) :: desc_data
class(amg_s_base_ainv_solver_type), intent(inout) :: sv
real(psb_spk_),intent(inout) :: x(:)
real(psb_spk_),intent(inout) :: y(:)
real(psb_spk_),intent(in) :: alpha,beta
character(len=1),intent(in) :: trans
real(psb_spk_),target, intent(inout) :: work(:)
integer(psb_ipk_), intent(out) :: info
character, intent(in), optional :: init
real(psb_spk_),intent(inout), optional :: initu(:)
end subroutine amg_s_base_ainv_solver_apply
end interface
interface
subroutine amg_s_base_ainv_solver_apply_vect(alpha,sv,x,beta,y,desc_data,&
& trans,work,wv,info,init,initu)
import :: psb_desc_type, psb_spk_,amg_s_base_ainv_solver_type, psb_s_vect_type, psb_ipk_
type(psb_desc_type), intent(in) :: desc_data
class(amg_s_base_ainv_solver_type), intent(inout) :: sv
type(psb_s_vect_type),intent(inout) :: x
type(psb_s_vect_type),intent(inout) :: y
real(psb_spk_),intent(in) :: alpha,beta
character(len=1),intent(in) :: trans
real(psb_spk_),target, intent(inout) :: work(:)
type(psb_s_vect_type),intent(inout) :: wv(:)
integer(psb_ipk_), intent(out) :: info
character, intent(in), optional :: init
type(psb_s_vect_type),intent(inout), optional :: initu
end subroutine amg_s_base_ainv_solver_apply_vect
end interface
interface
subroutine amg_s_base_ainv_solver_free(sv,info)
import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, &
& psb_s_vect_type, psb_s_base_vect_type, psb_spk_, amg_s_base_ainv_solver_type, psb_ipk_
Implicit None
! Arguments
class(amg_s_base_ainv_solver_type), intent(inout) :: sv
integer(psb_ipk_), intent(out) :: info
end subroutine amg_s_base_ainv_solver_free
end interface
interface
subroutine amg_s_base_ainv_solver_dmp(sv,desc,level,info,prefix,head,solver,global_num)
import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, &
& psb_s_vect_type, psb_s_base_vect_type, psb_spk_, amg_s_base_ainv_solver_type, psb_ipk_
implicit none
class(amg_s_base_ainv_solver_type), intent(in) :: sv
type(psb_desc_type), intent(in) :: desc
integer(psb_ipk_), intent(in) :: level
integer(psb_ipk_), intent(out) :: info
character(len=*), intent(in), optional :: prefix, head
logical, optional, intent(in) :: solver, global_num
end subroutine amg_s_base_ainv_solver_dmp
end interface
contains
function s_base_ainv_get_nzeros(sv) result(val)
implicit none
! Arguments
class(amg_s_base_ainv_solver_type), intent(in) :: sv
integer(psb_epk_) :: val
integer :: i
val = 0
val = val + sv%dv%get_nrows()
val = val + sv%w%get_nzeros()
val = val + sv%z%get_nzeros()
return
end function s_base_ainv_get_nzeros
function s_base_ainv_solver_sizeof(sv) result(val)
implicit none
! Arguments
class(amg_s_base_ainv_solver_type), intent(in) :: sv
integer(psb_epk_) :: val
integer :: i
val = 2*psb_sizeof_ip + psb_sizeof_dp
val = val + sv%dv%sizeof()
val = val + sv%w%sizeof()
val = val + sv%z%sizeof()
return
end function s_base_ainv_solver_sizeof
function s_base_ainv_get_wrksize() result(val)
implicit none
integer(psb_ipk_) :: val
val = 2
end function s_base_ainv_get_wrksize
end module amg_s_base_ainv_mod

@ -0,0 +1,322 @@
!
!
! AMG-AINV: Approximate Inverse plugin for
! AMG4PSBLAS version 1.0
!
! (C) Copyright 2020
!
! Salvatore Filippone University of Rome Tor Vergata
!
! 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 AMG4PSBLAS 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 AMG4PSBLAS 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.
!
!
!
!
!
!
!
module amg_z_ainv_solver
use amg_z_prec_type
use amg_z_base_ainv_mod
use psb_base_mod, only : psb_d_vect_type
type, extends(amg_z_base_ainv_solver_type) :: amg_z_ainv_solver_type
!
! Compute an approximate factorization
! A^-1 = Z D^-1 W^T
! Note that here W is going to be transposed explicitly,
! so that the component w will in the end contain W^T.
!
integer(psb_ipk_) :: alg, fill_in
real(psb_dpk_) :: thresh
contains
procedure, pass(sv) :: check => amg_z_ainv_solver_check
procedure, pass(sv) :: build => amg_z_ainv_solver_bld
procedure, pass(sv) :: clone => amg_z_ainv_solver_clone
procedure, pass(sv) :: cseti => amg_z_ainv_solver_cseti
procedure, pass(sv) :: csetc => amg_z_ainv_solver_csetc
procedure, pass(sv) :: csetr => amg_z_ainv_solver_csetr
procedure, pass(sv) :: seti => amg_z_ainv_solver_seti
procedure, pass(sv) :: setc => amg_z_ainv_solver_setc
procedure, pass(sv) :: setr => amg_z_ainv_solver_setr
generic, public :: set => seti, setr, setc
procedure, pass(sv) :: descr => amg_z_ainv_solver_descr
procedure, pass(sv) :: default => z_ainv_solver_default
procedure, nopass :: stringval => z_ainv_stringval
procedure, nopass :: algname => z_ainv_algname
end type amg_z_ainv_solver_type
private :: z_ainv_stringval, z_ainv_solver_default, &
& z_ainv_algname
interface
subroutine amg_z_ainv_solver_clone(sv,svout,info)
import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, &
& amg_z_base_solver_type, psb_dpk_, amg_z_ainv_solver_type, psb_ipk_
Implicit None
class(amg_z_ainv_solver_type), intent(inout) :: sv
class(amg_z_base_solver_type), allocatable, intent(inout) :: svout
integer(psb_ipk_), intent(out) :: info
end subroutine amg_z_ainv_solver_clone
end interface
interface
subroutine amg_z_ainv_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold)
import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, &
& psb_d_vect_type, psb_z_base_vect_type, psb_dpk_,&
& amg_z_ainv_solver_type, psb_i_base_vect_type, psb_ipk_
Implicit None
! Arguments
type(psb_zspmat_type), intent(in), target :: a
Type(psb_desc_type), Intent(inout) :: desc_a
class(amg_z_ainv_solver_type), intent(inout) :: sv
integer(psb_ipk_), intent(out) :: info
type(psb_zspmat_type), intent(in), target, optional :: b
class(psb_z_base_sparse_mat), intent(in), optional :: amold
class(psb_z_base_vect_type), intent(in), optional :: vmold
class(psb_i_base_vect_type), intent(in), optional :: imold
end subroutine amg_z_ainv_solver_bld
end interface
interface
subroutine amg_z_ainv_solver_check(sv,info)
import :: psb_dpk_, amg_z_ainv_solver_type, psb_ipk_
Implicit None
! Arguments
class(amg_z_ainv_solver_type), intent(inout) :: sv
integer(psb_ipk_), intent(out) :: info
end subroutine amg_z_ainv_solver_check
end interface
interface
subroutine amg_z_ainv_solver_cseti(sv,what,val,info,idx)
import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, psb_ipk_,&
& psb_d_vect_type, psb_z_base_vect_type, psb_dpk_, amg_z_ainv_solver_type
Implicit None
! Arguments
class(amg_z_ainv_solver_type), intent(inout) :: sv
character(len=*), intent(in) :: what
integer(psb_ipk_), intent(in) :: val
integer(psb_ipk_), intent(out) :: info
integer(psb_ipk_), intent(in), optional :: idx
end subroutine amg_z_ainv_solver_cseti
end interface
interface
subroutine amg_z_ainv_solver_csetc(sv,what,val,info,idx)
import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, psb_ipk_,&
& psb_d_vect_type, psb_z_base_vect_type, psb_dpk_, amg_z_ainv_solver_type
Implicit None
! Arguments
class(amg_z_ainv_solver_type), intent(inout) :: sv
character(len=*), intent(in) :: what
character(len=*), intent(in) :: val
integer(psb_ipk_), intent(out) :: info
integer(psb_ipk_), intent(in), optional :: idx
end subroutine amg_z_ainv_solver_csetc
end interface
interface
subroutine amg_z_ainv_solver_csetr(sv,what,val,info,idx)
import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, psb_ipk_,&
& psb_d_vect_type, psb_z_base_vect_type, psb_dpk_, amg_z_ainv_solver_type
Implicit None
! Arguments
class(amg_z_ainv_solver_type), intent(inout) :: sv
character(len=*), intent(in) :: what
real(psb_dpk_), intent(in) :: val
integer(psb_ipk_), intent(out) :: info
integer(psb_ipk_), intent(in), optional :: idx
end subroutine amg_z_ainv_solver_csetr
end interface
interface
subroutine amg_z_ainv_solver_setc(sv,what,val,info)
import :: amg_z_ainv_solver_type, psb_ipk_
Implicit none
! Arguments
class(amg_z_ainv_solver_type), intent(inout) :: sv
integer(psb_ipk_), intent(in) :: what
character(len=*), intent(in) :: val
integer(psb_ipk_), intent(out) :: info
end subroutine amg_z_ainv_solver_setc
end interface
interface
subroutine amg_z_ainv_solver_seti(sv,what,val,info)
import :: amg_z_ainv_solver_type, psb_ipk_
Implicit none
! Arguments
class(amg_z_ainv_solver_type), intent(inout) :: sv
integer(psb_ipk_), intent(in) :: what
integer(psb_ipk_), intent(in) :: val
integer(psb_ipk_), intent(out) :: info
end subroutine amg_z_ainv_solver_seti
end interface
interface
subroutine amg_z_ainv_solver_setr(sv,what,val,info)
import :: amg_z_ainv_solver_type, psb_ipk_, psb_dpk_
Implicit none
! Arguments
class(amg_z_ainv_solver_type), intent(inout) :: sv
integer(psb_ipk_), intent(in) :: what
real(psb_dpk_), intent(in) :: val
integer(psb_ipk_), intent(out) :: info
end subroutine amg_z_ainv_solver_setr
end interface
interface
subroutine amg_z_ainv_solver_descr(sv,info,iout,coarse)
import :: psb_dpk_, amg_z_ainv_solver_type, psb_ipk_
Implicit None
! Arguments
class(amg_z_ainv_solver_type), intent(in) :: sv
integer(psb_ipk_), intent(out) :: info
integer(psb_ipk_), intent(in), optional :: iout
logical, intent(in), optional :: coarse
end subroutine amg_z_ainv_solver_descr
end interface
interface amg_ainv_bld
subroutine amg_z_ainv_bld(a,alg,fillin,thresh,wmat,d,zmat,desc,info,blck,iscale)
import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, &
& psb_d_vect_type, psb_z_base_vect_type, psb_dpk_, psb_ipk_
implicit none
type(psb_zspmat_type), intent(in), target :: a
integer(psb_ipk_), intent(in) :: fillin,alg
real(psb_dpk_), intent(in) :: thresh
type(psb_zspmat_type), intent(inout) :: wmat, zmat
complex(psb_dpk_), allocatable :: d(:)
Type(psb_desc_type), Intent(inout) :: desc
integer(psb_ipk_), intent(out) :: info
type(psb_zspmat_type), intent(in), optional :: blck
integer(psb_ipk_), intent(in), optional :: iscale
end subroutine amg_z_ainv_bld
end interface
contains
subroutine z_ainv_solver_default(sv)
use psb_base_mod
Implicit None
! Arguments
class(amg_z_ainv_solver_type), intent(inout) :: sv
sv%alg = amg_ainv_llk_
sv%fill_in = 0
sv%thresh = dzero
return
end subroutine z_ainv_solver_default
function is_positive_nz_min(ip) result(res)
implicit none
integer(psb_ipk_), intent(in) :: ip
logical :: res
res = (ip >= 1)
return
end function is_positive_nz_min
function z_ainv_stringval(string) result(val)
use psb_base_mod, only : psb_ipk_,psb_toupper
implicit none
! Arguments
character(len=*), intent(in) :: string
integer(psb_ipk_) :: val
character(len=*), parameter :: name='d_ainv_stringval'
select case(psb_toupper(trim(string)))
case('LLK')
val = amg_ainv_llk_
case('STAB-LLK')
val = amg_ainv_s_ft_llk_
case('SYM-LLK')
val = amg_ainv_s_llk_
case('MLK')
val = amg_ainv_mlk_
#if defined(HAVE_TUMA_SAINV)
case('SAINV-TUMA')
val = amg_ainv_s_tuma_
case('LAINV-TUMA')
val = amg_ainv_l_tuma_
#endif
case default
val = amg_stringval(string)
end select
end function z_ainv_stringval
function z_ainv_algname(ialg) result(val)
integer(psb_ipk_), intent(in) :: ialg
character(len=40) :: val
character(len=*), parameter :: mlkname = 'Left-looking, list merge '
character(len=*), parameter :: llkname = 'Left-looking '
character(len=*), parameter :: stabllkname = 'Stabilized Left-looking '
character(len=*), parameter :: sllkname = 'Symmetric Left-looking '
character(len=*), parameter :: sainvname = 'SAINV (Benzi & Tuma) '
character(len=*), parameter :: lainvname = 'LAINV (Benzi & Tuma) '
character(len=*), parameter :: defname = 'Unknown alg variant '
select case (ialg)
case(amg_ainv_mlk_)
val = mlkname
case(amg_ainv_llk_)
val = llkname
case(amg_ainv_s_llk_)
val = sllkname
case(amg_ainv_s_ft_llk_)
val = stabllkname
#if defined(HAVE_TUMA_SAINV)
case(amg_ainv_s_tuma_ )
val = sainvname
case(amg_ainv_l_tuma_ )
val = lainvname
#endif
case default
val = defname
end select
end function z_ainv_algname
end module amg_z_ainv_solver

@ -0,0 +1,199 @@
!
!
! AMG-AINV: Approximate Inverse plugin for
! AMG4PSBLAS version 1.0
!
! (C) Copyright 2020
!
! Salvatore Filippone University of Rome Tor Vergata
!
! 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 AMG4PSBLAS 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 AMG4PSBLAS 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.
!
!
!
module amg_z_base_ainv_mod
use amg_base_ainv_mod
use amg_z_prec_type
use psb_z_ainv_tools_mod
use psb_base_mod, only : psb_z_vect_type, psb_dpk_, psb_epk_
type, extends(amg_z_base_solver_type) :: amg_z_base_ainv_solver_type
!
! Compute an approximate factorization
! A^-1 = Z D^-1 W^T
! Note that here W is going to be transposed explicitly,
! so that the component w will in the end contain W^T.
!
type(psb_zspmat_type) :: w, z
type(psb_z_vect_type) :: dv
complex(psb_dpk_), allocatable :: d(:)
contains
procedure, pass(sv) :: cnv => amg_z_base_ainv_solver_cnv
procedure, pass(sv) :: dump => amg_z_base_ainv_solver_dmp
procedure, pass(sv) :: apply_v => amg_z_base_ainv_solver_apply_vect
procedure, pass(sv) :: apply_a => amg_z_base_ainv_solver_apply
procedure, pass(sv) :: free => amg_z_base_ainv_solver_free
procedure, pass(sv) :: sizeof => z_base_ainv_solver_sizeof
procedure, pass(sv) :: get_nzeros => z_base_ainv_get_nzeros
procedure, nopass :: get_wrksz => z_base_ainv_get_wrksize
procedure, pass(sv) :: update_a => amg_z_base_ainv_update_a
generic, public :: update => update_a
end type amg_z_base_ainv_solver_type
private :: z_base_ainv_solver_sizeof, &
& z_base_ainv_get_nzeros, z_base_ainv_get_wrksize
interface
subroutine amg_z_base_ainv_solver_cnv(sv,info,amold,vmold,imold)
import :: psb_z_base_sparse_mat, psb_z_base_vect_type, psb_dpk_, &
& amg_z_base_ainv_solver_type, psb_ipk_, psb_i_base_vect_type
Implicit None
! Arguments
class(amg_z_base_ainv_solver_type), intent(inout) :: sv
integer(psb_ipk_), intent(out) :: info
class(psb_z_base_sparse_mat), intent(in), optional :: amold
class(psb_z_base_vect_type), intent(in), optional :: vmold
class(psb_i_base_vect_type), intent(in), optional :: imold
end subroutine amg_z_base_ainv_solver_cnv
end interface
interface
subroutine amg_z_base_ainv_update_a(sv,x,desc_data,info)
import :: psb_desc_type, psb_dpk_,amg_z_base_ainv_solver_type, psb_z_vect_type, psb_ipk_
type(psb_desc_type), intent(in) :: desc_data
class(amg_z_base_ainv_solver_type), intent(inout) :: sv
complex(psb_dpk_),intent(in) :: x(:)
integer(psb_ipk_), intent(out) :: info
end subroutine amg_z_base_ainv_update_a
end interface
interface
subroutine amg_z_base_ainv_solver_apply(alpha,sv,x,beta,y,desc_data,&
& trans,work,info,init,initu)
import :: psb_desc_type, psb_dpk_,amg_z_base_ainv_solver_type, psb_ipk_
type(psb_desc_type), intent(in) :: desc_data
class(amg_z_base_ainv_solver_type), intent(inout) :: sv
complex(psb_dpk_),intent(inout) :: x(:)
complex(psb_dpk_),intent(inout) :: y(:)
complex(psb_dpk_),intent(in) :: alpha,beta
character(len=1),intent(in) :: trans
complex(psb_dpk_),target, intent(inout) :: work(:)
integer(psb_ipk_), intent(out) :: info
character, intent(in), optional :: init
complex(psb_dpk_),intent(inout), optional :: initu(:)
end subroutine amg_z_base_ainv_solver_apply
end interface
interface
subroutine amg_z_base_ainv_solver_apply_vect(alpha,sv,x,beta,y,desc_data,&
& trans,work,wv,info,init,initu)
import :: psb_desc_type, psb_dpk_,amg_z_base_ainv_solver_type, psb_z_vect_type, psb_ipk_
type(psb_desc_type), intent(in) :: desc_data
class(amg_z_base_ainv_solver_type), intent(inout) :: sv
type(psb_z_vect_type),intent(inout) :: x
type(psb_z_vect_type),intent(inout) :: y
complex(psb_dpk_),intent(in) :: alpha,beta
character(len=1),intent(in) :: trans
complex(psb_dpk_),target, intent(inout) :: work(:)
type(psb_z_vect_type),intent(inout) :: wv(:)
integer(psb_ipk_), intent(out) :: info
character, intent(in), optional :: init
type(psb_z_vect_type),intent(inout), optional :: initu
end subroutine amg_z_base_ainv_solver_apply_vect
end interface
interface
subroutine amg_z_base_ainv_solver_free(sv,info)
import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, &
& psb_z_vect_type, psb_z_base_vect_type, psb_dpk_, amg_z_base_ainv_solver_type, psb_ipk_
Implicit None
! Arguments
class(amg_z_base_ainv_solver_type), intent(inout) :: sv
integer(psb_ipk_), intent(out) :: info
end subroutine amg_z_base_ainv_solver_free
end interface
interface
subroutine amg_z_base_ainv_solver_dmp(sv,desc,level,info,prefix,head,solver,global_num)
import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, &
& psb_z_vect_type, psb_z_base_vect_type, psb_dpk_, amg_z_base_ainv_solver_type, psb_ipk_
implicit none
class(amg_z_base_ainv_solver_type), intent(in) :: sv
type(psb_desc_type), intent(in) :: desc
integer(psb_ipk_), intent(in) :: level
integer(psb_ipk_), intent(out) :: info
character(len=*), intent(in), optional :: prefix, head
logical, optional, intent(in) :: solver, global_num
end subroutine amg_z_base_ainv_solver_dmp
end interface
contains
function z_base_ainv_get_nzeros(sv) result(val)
implicit none
! Arguments
class(amg_z_base_ainv_solver_type), intent(in) :: sv
integer(psb_epk_) :: val
integer :: i
val = 0
val = val + sv%dv%get_nrows()
val = val + sv%w%get_nzeros()
val = val + sv%z%get_nzeros()
return
end function z_base_ainv_get_nzeros
function z_base_ainv_solver_sizeof(sv) result(val)
implicit none
! Arguments
class(amg_z_base_ainv_solver_type), intent(in) :: sv
integer(psb_epk_) :: val
integer :: i
val = 2*psb_sizeof_ip + psb_sizeof_dp
val = val + sv%dv%sizeof()
val = val + sv%w%sizeof()
val = val + sv%z%sizeof()
return
end function z_base_ainv_solver_sizeof
function z_base_ainv_get_wrksize() result(val)
implicit none
integer(psb_ipk_) :: val
val = 2
end function z_base_ainv_get_wrksize
end module amg_z_base_ainv_mod

@ -191,7 +191,60 @@ amg_z_ilu_solver_dmp.o \
amg_z_mumps_solver_apply.o \
amg_z_mumps_solver_apply_vect.o \
amg_z_mumps_solver_bld.o \
amg_s_ainv_solver_bld.o \
amg_s_ainv_solver_check.o \
amg_s_ainv_solver_clone.o \
amg_s_ainv_solver_csetc.o \
amg_s_ainv_solver_cseti.o \
amg_s_ainv_solver_csetr.o \
amg_s_ainv_solver_descr.o \
amg_s_ainv_solver_setc.o \
amg_s_ainv_solver_seti.o \
amg_s_ainv_solver_setr.o \
amg_d_ainv_solver_bld.o \
amg_d_ainv_solver_check.o \
amg_d_ainv_solver_clone.o \
amg_d_ainv_solver_csetc.o \
amg_d_ainv_solver_cseti.o \
amg_d_ainv_solver_csetr.o \
amg_d_ainv_solver_descr.o \
amg_d_ainv_solver_setc.o \
amg_d_ainv_solver_seti.o \
amg_d_ainv_solver_setr.o \
amg_c_ainv_solver_bld.o \
amg_c_ainv_solver_check.o \
amg_c_ainv_solver_clone.o \
amg_c_ainv_solver_csetc.o \
amg_c_ainv_solver_cseti.o \
amg_c_ainv_solver_csetr.o \
amg_c_ainv_solver_descr.o \
amg_c_ainv_solver_setc.o \
amg_c_ainv_solver_seti.o \
amg_c_ainv_solver_setr.o \
amg_s_base_ainv_solver_apply_vect.o \
amg_s_base_ainv_solver_apply.o \
amg_s_base_ainv_solver_cnv.o \
amg_s_base_ainv_solver_dmp.o \
amg_s_base_ainv_solver_free.o \
amg_s_base_ainv_update_a.o \
amg_d_base_ainv_solver_apply_vect.o \
amg_d_base_ainv_solver_apply.o \
amg_d_base_ainv_solver_cnv.o \
amg_d_base_ainv_solver_dmp.o \
amg_d_base_ainv_solver_free.o \
amg_d_base_ainv_update_a.o \
amg_c_base_ainv_solver_apply_vect.o \
amg_c_base_ainv_solver_apply.o \
amg_c_base_ainv_solver_cnv.o \
amg_c_base_ainv_solver_dmp.o \
amg_c_base_ainv_solver_free.o \
amg_c_base_ainv_update_a.o \
amg_z_base_ainv_solver_apply_vect.o \
amg_z_base_ainv_solver_apply.o \
amg_z_base_ainv_solver_cnv.o \
amg_z_base_ainv_solver_dmp.o \
amg_z_base_ainv_solver_free.o \
amg_z_base_ainv_update_a.o
LIBNAME=libamg_prec.a
@ -208,4 +261,3 @@ veryclean: clean
clean:
/bin/rm -f $(OBJS) $(LOCAL_MODS)

@ -0,0 +1,99 @@
!
!
! AMG-AINV: Approximate Inverse plugin for
! AMG4PSBLAS version 1.0
!
! (C) Copyright 2020
!
! Salvatore Filippone University of Rome Tor Vergata
!
! 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 AMG4PSBLAS 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 AMG4PSBLAS 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.
!
!
subroutine amg_c_ainv_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold)
use psb_base_mod
use psb_c_ainv_fact_mod
use amg_prec_mod
use amg_c_ainv_solver, amg_protect_name => amg_c_ainv_solver_bld
Implicit None
! Arguments
type(psb_cspmat_type), intent(in), target :: a
Type(psb_desc_type), Intent(inout) :: desc_a
class(amg_c_ainv_solver_type), intent(inout) :: sv
integer(psb_ipk_), intent(out) :: info
type(psb_cspmat_type), intent(in), target, optional :: b
class(psb_c_base_sparse_mat), intent(in), optional :: amold
class(psb_c_base_vect_type), intent(in), optional :: vmold
class(psb_i_base_vect_type), intent(in), optional :: imold
! Local variables
integer(psb_ipk_) :: n_row,n_col, nrow_a, nztota
complex(psb_spk_), pointer :: ww(:), aux(:), tx(:),ty(:)
integer(psb_ipk_) :: np,me,i, err_act, debug_unit, debug_level
type(psb_ctxt_type) :: ctxt
character(len=20) :: name='amg_c_ainv_solver_bld', ch_err
info=psb_success_
call psb_erractionsave(err_act)
debug_unit = psb_get_debug_unit()
debug_level = psb_get_debug_level()
ctxt = desc_a%get_context()
call psb_info(ctxt, me, np)
if (debug_level >= psb_debug_outer_) &
& write(debug_unit,*) me,' ',trim(name),' start'
call psb_c_ainv_bld(a,sv%alg,sv%fill_in,sv%thresh,&
& sv%w,sv%d,sv%z,desc_a,info,b,iscale=amg_ilu_scale_maxval_)
if ((info == psb_success_) .and.present(amold)) then
call sv%w%set_asb()
call sv%w%trim()
call sv%z%set_asb()
call sv%z%trim()
call sv%w%cscnv(info,mold=amold)
if (info == psb_success_) &
& call sv%z%cscnv(info,mold=amold)
end if
if (info == psb_success_) &
& call sv%dv%bld(sv%d,mold=vmold)
if (info /= psb_success_) then
call psb_errpush(psb_err_internal_error_,name)
goto 9999
end if
if (debug_level >= psb_debug_outer_) &
& write(debug_unit,*) me,' ',trim(name),' end'
call psb_erractionrestore(err_act)
return
9999 call psb_error_handler(err_act)
return
end subroutine amg_c_ainv_solver_bld

@ -0,0 +1,65 @@
!
!
! AMG-AINV: Approximate Inverse plugin for
! AMG4PSBLAS version 1.0
!
! (C) Copyright 2020
!
! Salvatore Filippone University of Rome Tor Vergata
!
! 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 AMG4PSBLAS 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 AMG4PSBLAS 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.
!
!
subroutine amg_c_ainv_solver_check(sv,info)
use psb_base_mod
use amg_c_ainv_solver, amg_protect_name => amg_c_ainv_solver_check
Implicit None
! Arguments
class(amg_c_ainv_solver_type), intent(inout) :: sv
integer(psb_ipk_), intent(out) :: info
!
integer(psb_ipk_) :: err_act
character(len=20) :: name='amg_c_ainv_solver_check'
call psb_erractionsave(err_act)
info = psb_success_
call amg_check_def(sv%fill_in,&
& 'Nzmin',ione,is_positive_nz_min)
call amg_check_def(sv%thresh,&
& 'Eps',szero,is_legal_s_fact_thrs)
if (info /= psb_success_) goto 9999
call psb_erractionrestore(err_act)
return
9999 call psb_error_handler(err_act)
return
end subroutine amg_c_ainv_solver_check

@ -0,0 +1,91 @@
!
!
! AMG4PSBLAS version 1.0
! MultiLevel Domain Decomposition Parallel Preconditioners Package
! based on PSBLAS (Parallel Sparse BLAS version 3.0)
!
! (C) Copyright 2008,2009,2010,2010,2012
!
! Salvatore Filippone University of Rome Tor Vergata
! Alfredo Buttari CNRS-IRIT, Toulouse
! 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 AMG4PSBLAS 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 AMG4PSBLAS 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.
!
!
subroutine amg_c_ainv_solver_clone(sv,svout,info)
use psb_base_mod
use amg_c_ainv_solver, amg_protect_name => amg_c_ainv_solver_clone
Implicit None
! Arguments
class(amg_c_ainv_solver_type), intent(inout) :: sv
class(amg_c_base_solver_type), allocatable, intent(inout) :: svout
integer(psb_ipk_), intent(out) :: info
! Local variables
integer(psb_ipk_) :: err_act
info=psb_success_
call psb_erractionsave(err_act)
if (allocated(svout)) then
call svout%free(info)
if (info == psb_success_) deallocate(svout, stat=info)
end if
if (info == psb_success_) &
& allocate(amg_c_ainv_solver_type :: svout, stat=info)
if (info /= 0) then
info = psb_err_alloc_dealloc_
goto 9999
end if
select type(svo => svout)
type is (amg_c_ainv_solver_type)
svo%alg = sv%alg
svo%fill_in = sv%fill_in
svo%thresh = sv%thresh
call psb_safe_ab_cpy(sv%d,svo%d,info)
if (info == psb_success_) &
& call sv%dv%clone(svo%dv,info)
if (info == psb_success_) &
& call sv%w%clone(svo%w,info)
if (info == psb_success_) &
& call sv%z%clone(svo%z,info)
class default
info = psb_err_internal_error_
end select
if (info /= 0) goto 9999
call psb_erractionrestore(err_act)
return
9999 call psb_error_handler(err_act)
return
end subroutine amg_c_ainv_solver_clone

@ -0,0 +1,79 @@
!
!
! AMG-AINV: Approximate Inverse plugin for
! AMG4PSBLAS version 1.0
!
! (C) Copyright 2020
!
! Salvatore Filippone University of Rome Tor Vergata
!
! 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 AMG4PSBLAS 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 AMG4PSBLAS 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.
!
!
subroutine amg_c_ainv_solver_csetc(sv,what,val,info,idx)
use psb_base_mod
use amg_c_ainv_solver, amg_protect_name => amg_c_ainv_solver_csetc
Implicit None
! Arguments
class(amg_c_ainv_solver_type), intent(inout) :: sv
character(len=*), intent(in) :: what
character(len=*), intent(in) :: val
integer(psb_ipk_), intent(out) :: info
integer(psb_ipk_), intent(in), optional :: idx
!
integer(psb_ipk_ ) :: err_act, ival
character(len=20) :: name='amg_c_ainv_solver_setc'
info = psb_success_
call psb_erractionsave(err_act)
!!$ select case(psb_toupper(trim(what)))
!!$ case('AINV_ALG')
!!$ sv%alg = sv%stringval(val)
!!$ case default
!!$ call sv%mld_d_base_solver_type%set(what,val,info)
!!$ end select
ival = sv%stringval(val)
if (ival >=0) then
call sv%set(what,ival,info)
end if
if (info /= psb_success_) then
info = psb_err_from_subroutine_
call psb_errpush(info, name)
goto 9999
end if
call psb_erractionrestore(err_act)
return
9999 call psb_error_handler(err_act)
return
end subroutine amg_c_ainv_solver_csetc

@ -0,0 +1,69 @@
!
!
! AMG-AINV: Approximate Inverse plugin for
! AMG4PSBLAS version 1.0
!
! (C) Copyright 2020
!
! Salvatore Filippone University of Rome Tor Vergata
!
! 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 AMG4PSBLAS 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 AMG4PSBLAS 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.
!
!
subroutine amg_c_ainv_solver_cseti(sv,what,val,info,idx)
use psb_base_mod
use amg_c_ainv_solver, amg_protect_name => amg_c_ainv_solver_cseti
Implicit None
! Arguments
class(amg_c_ainv_solver_type), intent(inout) :: sv
character(len=*), intent(in) :: what
integer(psb_ipk_), intent(in) :: val
integer(psb_ipk_), intent(out) :: info
integer(psb_ipk_), intent(in), optional :: idx
!
integer(psb_ipk_) :: err_act
character(len=20) :: name='amg_c_ainv_solver_cseti'
info = psb_success_
call psb_erractionsave(err_act)
select case(psb_toupper(trim(what)))
case('SUB_FILLIN')
sv%fill_in = val
case('AINV_ALG')
sv%alg = val
case default
call sv%amg_c_base_solver_type%set(what,val,info)
end select
call psb_erractionrestore(err_act)
return
9999 call psb_error_handler(err_act)
return
end subroutine amg_c_ainv_solver_cseti

@ -0,0 +1,67 @@
!
!
! AMG-AINV: Approximate Inverse plugin for
! AMG4PSBLAS version 1.0
!
! (C) Copyright 2020
!
! Salvatore Filippone University of Rome Tor Vergata
!
! 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 AMG4PSBLAS 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 AMG4PSBLAS 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.
!
!
subroutine amg_c_ainv_solver_csetr(sv,what,val,info,idx)
use psb_base_mod
use amg_c_ainv_solver, amg_protect_name => amg_c_ainv_solver_csetr
Implicit None
! Arguments
class(amg_c_ainv_solver_type), intent(inout) :: sv
character(len=*), intent(in) :: what
real(psb_spk_), intent(in) :: val
integer(psb_ipk_), intent(out) :: info
integer(psb_ipk_), intent(in), optional :: idx
!
integer(psb_ipk_) :: err_act
character(len=20) :: name='amg_c_ainv_solver_csetr'
call psb_erractionsave(err_act)
info = psb_success_
select case(psb_toupper(what))
case('SUB_ILUTHRS')
sv%thresh = val
case default
call sv%amg_c_base_solver_type%set(what,val,info)
end select
call psb_erractionrestore(err_act)
return
9999 call psb_error_handler(err_act)
return
end subroutine amg_c_ainv_solver_csetr

@ -0,0 +1,73 @@
!
!
! AMG-AINV: Approximate Inverse plugin for
! AMG4PSBLAS version 1.0
!
! (C) Copyright 2020
!
! Salvatore Filippone University of Rome Tor Vergata
!
! 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 AMG4PSBLAS 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 AMG4PSBLAS 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.
!
!
subroutine amg_c_ainv_solver_descr(sv,info,iout,coarse)
use psb_base_mod
use amg_c_ainv_solver, amg_protect_name => amg_c_ainv_solver_descr
Implicit None
! Arguments
class(amg_c_ainv_solver_type), intent(in) :: sv
integer(psb_ipk_), intent(out) :: info
integer(psb_ipk_), intent(in), optional :: iout
logical, intent(in), optional :: coarse
! Local variables
integer(psb_ipk_) :: err_act
integer(psb_ipk_) :: ictxt, me, np
character(len=20), parameter :: name='amg_c_ainv_solver_descr'
integer(psb_ipk_) :: iout_
call psb_erractionsave(err_act)
info = psb_success_
if (present(iout)) then
iout_ = iout
else
iout_ = 6
endif
write(iout_,*) ' AINV: Approximate Inverse with sparse biconjugation '
write(iout_,*) ' Algorithm variant : ',sv%algname(sv%alg)
write(iout_,*) ' Fill level : ',sv%fill_in
write(iout_,*) ' Fill threshold : ',sv%thresh
call psb_erractionrestore(err_act)
return
9999 call psb_error_handler(err_act)
return
end subroutine amg_c_ainv_solver_descr

@ -0,0 +1,71 @@
!
!
! AMG-AINV: Approximate Inverse plugin for
! AMG4PSBLAS version 1.0
!
! (C) Copyright 2020
!
! Salvatore Filippone University of Rome Tor Vergata
!
! 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 AMG4PSBLAS 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 AMG4PSBLAS 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.
!
!
subroutine amg_c_ainv_solver_setc(sv,what,val,info)
use psb_base_mod
use amg_c_ainv_solver, amg_protect_name => amg_c_ainv_solver_setc
Implicit None
! Arguments
class(amg_c_ainv_solver_type), intent(inout) :: sv
integer(psb_ipk_), intent(in) :: what
character(len=*), intent(in) :: val
integer(psb_ipk_), intent(out) :: info
!
integer(psb_ipk_) :: err_act, ival
character(len=20) :: name='amg_c_ainv_solver_setc'
info = psb_success_
call psb_erractionsave(err_act)
ival = sv%stringval(val)
if (ival >=0) then
call sv%set(what,ival,info)
end if
if (info /= psb_success_) then
info = psb_err_from_subroutine_
call psb_errpush(info, name)
goto 9999
end if
call psb_erractionrestore(err_act)
return
9999 call psb_error_handler(err_act)
return
end subroutine amg_c_ainv_solver_setc

@ -0,0 +1,70 @@
!
!
! AMG-AINV: Approximate Inverse plugin for
! AMG4PSBLAS version 1.0
!
! (C) Copyright 2020
!
! Salvatore Filippone University of Rome Tor Vergata
!
! 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 AMG4PSBLAS 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 AMG4PSBLAS 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.
!
!
subroutine amg_c_ainv_solver_seti(sv,what,val,info)
use psb_base_mod
use amg_c_ainv_solver, amg_protect_name => amg_c_ainv_solver_seti
Implicit None
! Arguments
class(amg_c_ainv_solver_type), intent(inout) :: sv
integer(psb_ipk_), intent(in) :: what
integer(psb_ipk_), intent(in) :: val
integer(psb_ipk_), intent(out) :: info
!
integer(psb_ipk_) :: err_act
character(len=20) :: name='amg_c_ainv_solver_seti'
info = psb_success_
call psb_erractionsave(err_act)
select case(what)
case(amg_sub_fillin_)
sv%fill_in = val
case(amg_ainv_alg_)
sv%alg = val
case default
!!$ write(0,*) name,': Error: invalid WHAT'
!!$ info = -2
end select
call psb_erractionrestore(err_act)
return
9999 call psb_error_handler(err_act)
return
end subroutine amg_c_ainv_solver_seti

@ -0,0 +1,69 @@
!
!
! AMG-AINV: Approximate Inverse plugin for
! AMG4PSBLAS version 1.0
!
! (C) Copyright 2020
!
! Salvatore Filippone University of Rome Tor Vergata
!
! 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 AMG4PSBLAS 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 AMG4PSBLAS 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.
!
!
subroutine amg_c_ainv_solver_setr(sv,what,val,info)
use psb_base_mod
use amg_c_ainv_solver, amg_protect_name => amg_c_ainv_solver_setr
Implicit None
! Arguments
class(amg_c_ainv_solver_type), intent(inout) :: sv
integer(psb_ipk_), intent(in) :: what
real(psb_spk_), intent(in) :: val
integer(psb_ipk_), intent(out) :: info
!
integer(psb_ipk_) :: err_act
character(len=20) :: name='amg_c_ainv_solver_setr'
call psb_erractionsave(err_act)
info = psb_success_
select case(what)
case(amg_sub_iluthrs_)
sv%thresh = val
case default
!!$ write(0,*) name,': Error: invalid WHAT'
!!$ info = -2
!!$ goto 9999
end select
call psb_erractionrestore(err_act)
return
9999 call psb_error_handler(err_act)
return
end subroutine amg_c_ainv_solver_setr

@ -0,0 +1,153 @@
!
!
! AMG-AINV: Approximate Inverse plugin for
! AMG4PSBLAS version 1.0
!
! (C) Copyright 2020
!
! Salvatore Filippone University of Rome Tor Vergata
!
! 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 AMG4PSBLAS 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 AMG4PSBLAS 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.
!
!
subroutine amg_c_base_ainv_solver_apply(alpha,sv,x,beta,y,desc_data,&
& trans,work,info,init,initu)
use psb_base_mod
use amg_c_base_ainv_mod, amg_protect_name => amg_c_base_ainv_solver_apply
implicit none
type(psb_desc_type), intent(in) :: desc_data
class(amg_c_base_ainv_solver_type), intent(inout) :: sv
complex(psb_spk_),intent(inout) :: x(:)
complex(psb_spk_),intent(inout) :: y(:)
complex(psb_spk_),intent(in) :: alpha,beta
character(len=1),intent(in) :: trans
complex(psb_spk_),target, intent(inout) :: work(:)
integer(psb_ipk_), intent(out) :: info
character, intent(in), optional :: init
complex(psb_spk_),intent(inout), optional :: initu(:)
!
integer(psb_ipk_) :: n_row,n_col
complex(psb_spk_), pointer :: ww(:), aux(:), tx(:),ty(:)
integer(psb_ipk_) :: np,me,i, err_act
type(psb_ctxt_type) :: ctxt
character :: trans_
character(len=20) :: name='d_base_ainv_solver_apply'
call psb_erractionsave(err_act)
info = psb_success_
trans_ = psb_toupper(trans)
select case(trans_)
case('N')
case('T','C')
case default
call psb_errpush(psb_err_iarg_invalid_i_,name)
goto 9999
end select
!
! For non-iterative solvers, init and initu are ignored.
!
n_row = psb_cd_get_local_rows(desc_data)
n_col = psb_cd_get_local_cols(desc_data)
if (n_col <= size(work)) then
ww => work(1:n_col)
if ((4*n_col+n_col) <= size(work)) then
aux => work(n_col+1:)
else
allocate(aux(4*n_col),stat=info)
if (info /= psb_success_) then
info=psb_err_alloc_request_
call psb_errpush(info,name,i_err=(/4*n_col/),&
& a_err='real(psb_dpk_)')
goto 9999
end if
endif
else
allocate(ww(n_col),aux(4*n_col),stat=info)
if (info /= psb_success_) then
info=psb_err_alloc_request_
call psb_errpush(info,name,i_err=(/5*n_col/),&
& a_err='real(psb_dpk_)')
goto 9999
end if
endif
select case(trans_)
case('N')
call psb_spmm(cone,sv%w,x,czero,ww,desc_data,info,&
& trans=trans_,work=aux,doswap=.false.)
ww(1:n_row) = ww(1:n_row) * sv%d(1:n_row)
if (info == psb_success_) &
& call psb_spmm(alpha,sv%z,ww,beta,y,desc_data,info,&
& trans=trans_,work=aux,doswap=.false.)
case('T','C')
call psb_spmm(cone,sv%z,x,czero,ww,desc_data,info,&
& trans=trans_,work=aux,doswap=.false.)
ww(1:n_row) = ww(1:n_row) * sv%d(1:n_row)
if (info == psb_success_) &
& call psb_spmm(alpha,sv%w,ww,beta,y,desc_data,info,&
& trans=trans_,work=aux,doswap=.false.)
case default
call psb_errpush(psb_err_internal_error_,name,&
& a_err='Invalid TRANS in ainv subsolve')
goto 9999
end select
if (info /= psb_success_) then
call psb_errpush(psb_err_internal_error_,name,&
& a_err='Error in subsolve')
goto 9999
endif
if (n_col <= size(work)) then
if ((4*n_col+n_col) <= size(work)) then
else
deallocate(aux,stat=info)
endif
else
deallocate(ww,aux,stat=info)
endif
if (info /= psb_success_) then
call psb_errpush(psb_err_internal_error_,name,&
& a_err='Deallocate')
goto 9999
endif
call psb_erractionrestore(err_act)
return
9999 call psb_error_handler(err_act)
return
end subroutine amg_c_base_ainv_solver_apply

@ -0,0 +1,167 @@
!
!
! AMG-AINV: Approximate Inverse plugin for
! AMG4PSBLAS version 1.0
!
! (C) Copyright 2020
!
! Salvatore Filippone University of Rome Tor Vergata
!
! 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 AMG4PSBLAS 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 AMG4PSBLAS 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.
!
!
subroutine amg_c_base_ainv_solver_apply_vect(alpha,sv,x,beta,y,desc_data,&
& trans,work,wv,info,init,initu)
use psb_base_mod
use amg_c_base_ainv_mod, amg_protect_name => amg_c_base_ainv_solver_apply_vect
implicit none
type(psb_desc_type), intent(in) :: desc_data
class(amg_c_base_ainv_solver_type), intent(inout) :: sv
type(psb_c_vect_type), intent(inout) :: x
type(psb_c_vect_type), intent(inout) :: y
complex(psb_spk_), intent(in) :: alpha,beta
character(len=1), intent(in) :: trans
complex(psb_spk_),target, intent(inout) :: work(:)
type(psb_c_vect_type),intent(inout) :: wv(:)
integer(psb_ipk_), intent(out) :: info
character, intent(in), optional :: init
type(psb_c_vect_type),intent(inout), optional :: initu
!
integer(psb_ipk_) :: n_row,n_col
complex(psb_spk_), pointer :: ww(:), aux(:)
type(psb_c_vect_type) :: tx,ty
integer(psb_ipk_) :: np,me,i, err_act
type(psb_ctxt_type) :: ctxt
character :: trans_
character(len=20) :: name='d_base_ainv_solver_apply'
call psb_erractionsave(err_act)
info = psb_success_
trans_ = psb_toupper(trans)
select case(trans_)
case('N')
case('T','C')
case default
call psb_errpush(psb_err_iarg_invalid_i_,name)
goto 9999
end select
!
! For non-iterative solvers, init and initu are ignored.
!
n_row = psb_cd_get_local_rows(desc_data)
n_col = psb_cd_get_local_cols(desc_data)
if (n_col <= size(work)) then
ww => work(1:n_col)
if ((4*n_col+n_col) <= size(work)) then
aux => work(n_col+1:)
else
allocate(aux(4*n_col),stat=info)
if (info /= psb_success_) then
info=psb_err_alloc_request_
call psb_errpush(info,name,i_err=(/4*n_col/),&
& a_err='real(psb_dpk_)')
goto 9999
end if
endif
else
allocate(ww(n_col),aux(4*n_col),stat=info)
if (info /= psb_success_) then
info=psb_err_alloc_request_
call psb_errpush(info,name,i_err=(/5*n_col/),&
& a_err='real(psb_dpk_)')
goto 9999
end if
endif
if (size(wv) < 2) then
info = psb_err_internal_error_
call psb_errpush(info,name,&
& a_err='invalid wv size')
goto 9999
end if
associate(tx => wv(1), ty => wv(2))
select case(trans_)
case('N')
call psb_spmm(cone,sv%w,x,czero,tx,desc_data,info,&
& trans=trans_,work=aux,doswap=.false.)
if (info == psb_success_) call ty%mlt(cone,sv%dv,tx,czero,info)
if (info == psb_success_) &
& call psb_spmm(alpha,sv%z,ty,beta,y,desc_data,info,&
& trans=trans_,work=aux,doswap=.false.)
case('T','C')
call psb_spmm(cone,sv%z,x,czero,tx,desc_data,info,&
& trans=trans_,work=aux,doswap=.false.)
if (info == psb_success_) call ty%mlt(cone,sv%dv,tx,czero,info)
if (info == psb_success_) &
& call psb_spmm(alpha,sv%w,ty,beta,y,desc_data,info,&
& trans=trans_,work=aux,doswap=.false.)
case default
call psb_errpush(psb_err_internal_error_,name,&
& a_err='Invalid TRANS in ainv subsolve')
goto 9999
end select
if (info /= psb_success_) then
call psb_errpush(psb_err_internal_error_,name,&
& a_err='Error in subsolve')
goto 9999
endif
end associate
if (n_col <= size(work)) then
if ((4*n_col+n_col) <= size(work)) then
else
deallocate(aux,stat=info)
endif
else
deallocate(ww,aux,stat=info)
endif
if (info /= psb_success_) then
call psb_errpush(psb_err_internal_error_,name,&
& a_err='Deallocate')
goto 9999
endif
call psb_erractionrestore(err_act)
return
9999 call psb_error_handler(err_act)
return
end subroutine amg_c_base_ainv_solver_apply_vect

@ -0,0 +1,63 @@
!
!
! AMG-AINV: Approximate Inverse plugin for
! AMG4PSBLAS version 1.0
!
! (C) Copyright 2020
!
! Salvatore Filippone University of Rome Tor Vergata
!
! 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 AMG4PSBLAS 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 AMG4PSBLAS 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.
!
!
subroutine amg_c_base_ainv_solver_cnv(sv,info,amold,vmold,imold)
use psb_base_mod
use amg_c_base_ainv_mod, amg_protect_name => amg_c_base_ainv_solver_cnv
Implicit None
! Arguments
class(amg_c_base_ainv_solver_type), intent(inout) :: sv
integer(psb_ipk_), intent(out) :: info
class(psb_c_base_sparse_mat), intent(in), optional :: amold
class(psb_c_base_vect_type), intent(in), optional :: vmold
class(psb_i_base_vect_type), intent(in), optional :: imold
!local
integer(psb_ipk_) :: i, j, il1, iln, lname, lev
integer(psb_ipk_) :: iam, np
type(psb_ctxt_type) :: ctxt
character(len=80) :: prefix_
character(len=120) :: fname ! len should be at least 20 more than
logical :: solver_
! len of prefix_
info = 0
if (present(amold)) then
call sv%w%cscnv(info,mold=amold)
call sv%z%cscnv(info,mold=amold)
end if
call sv%dv%cnv(mold=vmold)
end subroutine amg_c_base_ainv_solver_cnv

@ -0,0 +1,93 @@
!
!
! AMG-AINV: Approximate Inverse plugin for
! AMG4PSBLAS version 1.0
!
! (C) Copyright 2020
!
! Salvatore Filippone University of Rome Tor Vergata
!
! 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 AMG4PSBLAS 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 AMG4PSBLAS 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.
!
!
subroutine amg_c_base_ainv_solver_dmp(sv,desc,level,info,prefix,head,solver,global_num)
use psb_base_mod
use amg_c_base_ainv_mod, amg_protect_name => amg_c_base_ainv_solver_dmp
implicit none
class(amg_c_base_ainv_solver_type), intent(in) :: sv
type(psb_desc_type), intent(in) :: desc
integer(psb_ipk_), intent(in) :: level
integer(psb_ipk_), intent(out) :: info
character(len=*), intent(in), optional :: prefix, head
logical, optional, intent(in) :: solver, global_num
!
integer(psb_ipk_) :: i, j, il1, iln, lname, lev
integer(psb_ipk_) :: iam, np
type(psb_ctxt_type) :: ctxt
character(len=80) :: prefix_
character(len=120) :: fname ! len should be at least 20 more than
logical :: solver_, global_num_
! len of prefix_
info = 0
if (present(prefix)) then
prefix_ = trim(prefix(1:min(len(prefix),len(prefix_))))
else
prefix_ = "dump_ainv_d"
end if
ctxt = desc%get_context()
call psb_info(ctxt,iam,np)
if (present(solver)) then
solver_ = solver
else
solver_ = .false.
end if
if (present(global_num)) then
global_num_ = global_num
else
global_num_ = .false.
end if
lname = len_trim(prefix_)
fname = trim(prefix_)
write(fname(lname+1:lname+5),'(a,i3.3)') '_p',iam
lname = lname + 5
if (solver_) then
write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_wmat.mtx'
if (sv%w%is_asb()) &
& call sv%w%print(fname,head=head)
write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_diag.mtx'
if (allocated(sv%d)) &
& call psb_geprt(fname,sv%d,head=head)
write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_zmat.mtx'
if (sv%z%is_asb()) &
& call sv%z%print(fname,head=head)
end if
end subroutine amg_c_base_ainv_solver_dmp

@ -0,0 +1,70 @@
!
!
! AMG-AINV: Approximate Inverse plugin for
! AMG4PSBLAS version 1.0
!
! (C) Copyright 2020
!
! Salvatore Filippone University of Rome Tor Vergata
!
! 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 AMG4PSBLAS 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 AMG4PSBLAS 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.
!
!
subroutine amg_c_base_ainv_solver_free(sv,info)
use psb_base_mod
use amg_c_base_ainv_mod, amg_protect_name => amg_c_base_ainv_solver_free
Implicit None
! Arguments
class(amg_c_base_ainv_solver_type), intent(inout) :: sv
integer(psb_ipk_), intent(out) :: info
!
integer(psb_ipk_) :: err_act
character(len=20) :: name='amg_c_base_ainv_solver_free'
call psb_erractionsave(err_act)
info = psb_success_
call sv%clear_data(info)
if (allocated(sv%d)) then
deallocate(sv%d,stat=info)
if (info /= psb_success_) then
info = psb_err_alloc_dealloc_
call psb_errpush(info,name)
goto 9999
end if
end if
call sv%w%free()
call sv%z%free()
call sv%dv%free(info)
call psb_erractionrestore(err_act)
return
9999 call psb_error_handler(err_act)
return
end subroutine amg_c_base_ainv_solver_free

@ -0,0 +1,81 @@
!
!
! AMG-AINV: Approximate Inverse plugin for
! AMG4PSBLAS version 1.0
!
! (C) Copyright 2020
!
! Salvatore Filippone University of Rome Tor Vergata
!
! 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 AMG4PSBLAS 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 AMG4PSBLAS 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.
!
!
subroutine amg_c_base_ainv_update_a(sv,x,desc_data,info)
use amg_c_base_ainv_mod, amg_protect_name => amg_c_base_ainv_update_a
use psb_base_mod
implicit none
type(psb_desc_type), intent(in) :: desc_data
class(amg_c_base_ainv_solver_type), intent(inout) :: sv
complex(psb_spk_),intent(in) :: x(:)
integer(psb_ipk_), intent(out) :: info
! Local variables
complex(psb_spk_), allocatable :: dd(:), ee(:)
integer(psb_ipk_) :: nrows, ncols, i, j, k, nzr, nzc, ir, ic
type(psb_c_csc_sparse_mat) :: ac
type(psb_c_csr_sparse_mat) :: ar
dd = sv%dv%get_vect()
if (size(x)<size(dd)) then
write(0,*) 'Wrong size in update',size(x),size(dd)
info = -1
return
end if
ee = x(1:size(dd))
call sv%z%cp_to(ac)
call sv%w%cp_to(ar)
! Compute diag(W ee Z)
! First ee Z
call ac%scal(ee,info,side='L')
! Then diag(W (ee Z))
do i=1,ar%get_nrows()
ir = ar%irp(i); nzr = ar%irp(i+1)-ar%irp(i)
ic = ac%icp(i); nzc = ac%icp(i+1)-ac%icp(i)
ee(i) = psb_spdot_srtd(&
& nzr,ar%ja(ir:ir+nzr-1),ar%val(ir:ir+nzr-1),&
& nzc,ac%ia(ic:ic+nzc-1),ac%val(ic:ic+nzc-1))
end do
! Now invert diagonal
dd = done/dd
dd = dd + ee
dd = done/dd
sv%d = dd
call sv%dv%bld(dd,mold=sv%dv%v)
end subroutine amg_c_base_ainv_update_a

@ -0,0 +1,99 @@
!
!
! AMG-AINV: Approximate Inverse plugin for
! AMG4PSBLAS version 1.0
!
! (C) Copyright 2020
!
! Salvatore Filippone University of Rome Tor Vergata
!
! 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 AMG4PSBLAS 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 AMG4PSBLAS 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.
!
!
subroutine amg_d_ainv_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold)
use psb_base_mod
use psb_d_ainv_fact_mod
use amg_prec_mod
use amg_d_ainv_solver, amg_protect_name => amg_d_ainv_solver_bld
Implicit None
! Arguments
type(psb_dspmat_type), intent(in), target :: a
Type(psb_desc_type), Intent(inout) :: desc_a
class(amg_d_ainv_solver_type), intent(inout) :: sv
integer(psb_ipk_), intent(out) :: info
type(psb_dspmat_type), intent(in), target, optional :: b
class(psb_d_base_sparse_mat), intent(in), optional :: amold
class(psb_d_base_vect_type), intent(in), optional :: vmold
class(psb_i_base_vect_type), intent(in), optional :: imold
! Local variables
integer(psb_ipk_) :: n_row,n_col, nrow_a, nztota
real(psb_dpk_), pointer :: ww(:), aux(:), tx(:),ty(:)
integer(psb_ipk_) :: np,me,i, err_act, debug_unit, debug_level
type(psb_ctxt_type) :: ctxt
character(len=20) :: name='amg_d_ainv_solver_bld', ch_err
info=psb_success_
call psb_erractionsave(err_act)
debug_unit = psb_get_debug_unit()
debug_level = psb_get_debug_level()
ctxt = desc_a%get_context()
call psb_info(ctxt, me, np)
if (debug_level >= psb_debug_outer_) &
& write(debug_unit,*) me,' ',trim(name),' start'
call psb_d_ainv_bld(a,sv%alg,sv%fill_in,sv%thresh,&
& sv%w,sv%d,sv%z,desc_a,info,b,iscale=amg_ilu_scale_maxval_)
if ((info == psb_success_) .and.present(amold)) then
call sv%w%set_asb()
call sv%w%trim()
call sv%z%set_asb()
call sv%z%trim()
call sv%w%cscnv(info,mold=amold)
if (info == psb_success_) &
& call sv%z%cscnv(info,mold=amold)
end if
if (info == psb_success_) &
& call sv%dv%bld(sv%d,mold=vmold)
if (info /= psb_success_) then
call psb_errpush(psb_err_internal_error_,name)
goto 9999
end if
if (debug_level >= psb_debug_outer_) &
& write(debug_unit,*) me,' ',trim(name),' end'
call psb_erractionrestore(err_act)
return
9999 call psb_error_handler(err_act)
return
end subroutine amg_d_ainv_solver_bld

@ -0,0 +1,65 @@
!
!
! AMG-AINV: Approximate Inverse plugin for
! AMG4PSBLAS version 1.0
!
! (C) Copyright 2020
!
! Salvatore Filippone University of Rome Tor Vergata
!
! 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 AMG4PSBLAS 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 AMG4PSBLAS 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.
!
!
subroutine amg_d_ainv_solver_check(sv,info)
use psb_base_mod
use amg_d_ainv_solver, amg_protect_name => amg_d_ainv_solver_check
Implicit None
! Arguments
class(amg_d_ainv_solver_type), intent(inout) :: sv
integer(psb_ipk_), intent(out) :: info
!
integer(psb_ipk_) :: err_act
character(len=20) :: name='amg_d_ainv_solver_check'
call psb_erractionsave(err_act)
info = psb_success_
call amg_check_def(sv%fill_in,&
& 'Nzmin',ione,is_positive_nz_min)
call amg_check_def(sv%thresh,&
& 'Eps',dzero,is_legal_d_fact_thrs)
if (info /= psb_success_) goto 9999
call psb_erractionrestore(err_act)
return
9999 call psb_error_handler(err_act)
return
end subroutine amg_d_ainv_solver_check

@ -0,0 +1,91 @@
!
!
! AMG4PSBLAS version 1.0
! MultiLevel Domain Decomposition Parallel Preconditioners Package
! based on PSBLAS (Parallel Sparse BLAS version 3.0)
!
! (C) Copyright 2008,2009,2010,2010,2012
!
! Salvatore Filippone University of Rome Tor Vergata
! Alfredo Buttari CNRS-IRIT, Toulouse
! 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 AMG4PSBLAS 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 AMG4PSBLAS 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.
!
!
subroutine amg_d_ainv_solver_clone(sv,svout,info)
use psb_base_mod
use amg_d_ainv_solver, amg_protect_name => amg_d_ainv_solver_clone
Implicit None
! Arguments
class(amg_d_ainv_solver_type), intent(inout) :: sv
class(amg_d_base_solver_type), allocatable, intent(inout) :: svout
integer(psb_ipk_), intent(out) :: info
! Local variables
integer(psb_ipk_) :: err_act
info=psb_success_
call psb_erractionsave(err_act)
if (allocated(svout)) then
call svout%free(info)
if (info == psb_success_) deallocate(svout, stat=info)
end if
if (info == psb_success_) &
& allocate(amg_d_ainv_solver_type :: svout, stat=info)
if (info /= 0) then
info = psb_err_alloc_dealloc_
goto 9999
end if
select type(svo => svout)
type is (amg_d_ainv_solver_type)
svo%alg = sv%alg
svo%fill_in = sv%fill_in
svo%thresh = sv%thresh
call psb_safe_ab_cpy(sv%d,svo%d,info)
if (info == psb_success_) &
& call sv%dv%clone(svo%dv,info)
if (info == psb_success_) &
& call sv%w%clone(svo%w,info)
if (info == psb_success_) &
& call sv%z%clone(svo%z,info)
class default
info = psb_err_internal_error_
end select
if (info /= 0) goto 9999
call psb_erractionrestore(err_act)
return
9999 call psb_error_handler(err_act)
return
end subroutine amg_d_ainv_solver_clone

@ -0,0 +1,79 @@
!
!
! AMG-AINV: Approximate Inverse plugin for
! AMG4PSBLAS version 1.0
!
! (C) Copyright 2020
!
! Salvatore Filippone University of Rome Tor Vergata
!
! 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 AMG4PSBLAS 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 AMG4PSBLAS 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.
!
!
subroutine amg_d_ainv_solver_csetc(sv,what,val,info,idx)
use psb_base_mod
use amg_d_ainv_solver, amg_protect_name => amg_d_ainv_solver_csetc
Implicit None
! Arguments
class(amg_d_ainv_solver_type), intent(inout) :: sv
character(len=*), intent(in) :: what
character(len=*), intent(in) :: val
integer(psb_ipk_), intent(out) :: info
integer(psb_ipk_), intent(in), optional :: idx
!
integer(psb_ipk_ ) :: err_act, ival
character(len=20) :: name='amg_d_ainv_solver_setc'
info = psb_success_
call psb_erractionsave(err_act)
!!$ select case(psb_toupper(trim(what)))
!!$ case('AINV_ALG')
!!$ sv%alg = sv%stringval(val)
!!$ case default
!!$ call sv%mld_d_base_solver_type%set(what,val,info)
!!$ end select
ival = sv%stringval(val)
if (ival >=0) then
call sv%set(what,ival,info)
end if
if (info /= psb_success_) then
info = psb_err_from_subroutine_
call psb_errpush(info, name)
goto 9999
end if
call psb_erractionrestore(err_act)
return
9999 call psb_error_handler(err_act)
return
end subroutine amg_d_ainv_solver_csetc

@ -0,0 +1,69 @@
!
!
! AMG-AINV: Approximate Inverse plugin for
! AMG4PSBLAS version 1.0
!
! (C) Copyright 2020
!
! Salvatore Filippone University of Rome Tor Vergata
!
! 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 AMG4PSBLAS 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 AMG4PSBLAS 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.
!
!
subroutine amg_d_ainv_solver_cseti(sv,what,val,info,idx)
use psb_base_mod
use amg_d_ainv_solver, amg_protect_name => amg_d_ainv_solver_cseti
Implicit None
! Arguments
class(amg_d_ainv_solver_type), intent(inout) :: sv
character(len=*), intent(in) :: what
integer(psb_ipk_), intent(in) :: val
integer(psb_ipk_), intent(out) :: info
integer(psb_ipk_), intent(in), optional :: idx
!
integer(psb_ipk_) :: err_act
character(len=20) :: name='amg_d_ainv_solver_cseti'
info = psb_success_
call psb_erractionsave(err_act)
select case(psb_toupper(trim(what)))
case('SUB_FILLIN')
sv%fill_in = val
case('AINV_ALG')
sv%alg = val
case default
call sv%amg_d_base_solver_type%set(what,val,info)
end select
call psb_erractionrestore(err_act)
return
9999 call psb_error_handler(err_act)
return
end subroutine amg_d_ainv_solver_cseti

@ -0,0 +1,67 @@
!
!
! AMG-AINV: Approximate Inverse plugin for
! AMG4PSBLAS version 1.0
!
! (C) Copyright 2020
!
! Salvatore Filippone University of Rome Tor Vergata
!
! 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 AMG4PSBLAS 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 AMG4PSBLAS 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.
!
!
subroutine amg_d_ainv_solver_csetr(sv,what,val,info,idx)
use psb_base_mod
use amg_d_ainv_solver, amg_protect_name => amg_d_ainv_solver_csetr
Implicit None
! Arguments
class(amg_d_ainv_solver_type), intent(inout) :: sv
character(len=*), intent(in) :: what
real(psb_dpk_), intent(in) :: val
integer(psb_ipk_), intent(out) :: info
integer(psb_ipk_), intent(in), optional :: idx
!
integer(psb_ipk_) :: err_act
character(len=20) :: name='amg_d_ainv_solver_csetr'
call psb_erractionsave(err_act)
info = psb_success_
select case(psb_toupper(what))
case('SUB_ILUTHRS')
sv%thresh = val
case default
call sv%amg_d_base_solver_type%set(what,val,info)
end select
call psb_erractionrestore(err_act)
return
9999 call psb_error_handler(err_act)
return
end subroutine amg_d_ainv_solver_csetr

@ -0,0 +1,73 @@
!
!
! AMG-AINV: Approximate Inverse plugin for
! AMG4PSBLAS version 1.0
!
! (C) Copyright 2020
!
! Salvatore Filippone University of Rome Tor Vergata
!
! 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 AMG4PSBLAS 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 AMG4PSBLAS 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.
!
!
subroutine amg_d_ainv_solver_descr(sv,info,iout,coarse)
use psb_base_mod
use amg_d_ainv_solver, amg_protect_name => amg_d_ainv_solver_descr
Implicit None
! Arguments
class(amg_d_ainv_solver_type), intent(in) :: sv
integer(psb_ipk_), intent(out) :: info
integer(psb_ipk_), intent(in), optional :: iout
logical, intent(in), optional :: coarse
! Local variables
integer(psb_ipk_) :: err_act
integer(psb_ipk_) :: ictxt, me, np
character(len=20), parameter :: name='amg_d_ainv_solver_descr'
integer(psb_ipk_) :: iout_
call psb_erractionsave(err_act)
info = psb_success_
if (present(iout)) then
iout_ = iout
else
iout_ = 6
endif
write(iout_,*) ' AINV: Approximate Inverse with sparse biconjugation '
write(iout_,*) ' Algorithm variant : ',sv%algname(sv%alg)
write(iout_,*) ' Fill level : ',sv%fill_in
write(iout_,*) ' Fill threshold : ',sv%thresh
call psb_erractionrestore(err_act)
return
9999 call psb_error_handler(err_act)
return
end subroutine amg_d_ainv_solver_descr

@ -0,0 +1,71 @@
!
!
! AMG-AINV: Approximate Inverse plugin for
! AMG4PSBLAS version 1.0
!
! (C) Copyright 2020
!
! Salvatore Filippone University of Rome Tor Vergata
!
! 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 AMG4PSBLAS 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 AMG4PSBLAS 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.
!
!
subroutine amg_d_ainv_solver_setc(sv,what,val,info)
use psb_base_mod
use amg_d_ainv_solver, amg_protect_name => amg_d_ainv_solver_setc
Implicit None
! Arguments
class(amg_d_ainv_solver_type), intent(inout) :: sv
integer(psb_ipk_), intent(in) :: what
character(len=*), intent(in) :: val
integer(psb_ipk_), intent(out) :: info
!
integer(psb_ipk_) :: err_act, ival
character(len=20) :: name='amg_d_ainv_solver_setc'
info = psb_success_
call psb_erractionsave(err_act)
ival = sv%stringval(val)
if (ival >=0) then
call sv%set(what,ival,info)
end if
if (info /= psb_success_) then
info = psb_err_from_subroutine_
call psb_errpush(info, name)
goto 9999
end if
call psb_erractionrestore(err_act)
return
9999 call psb_error_handler(err_act)
return
end subroutine amg_d_ainv_solver_setc

@ -0,0 +1,70 @@
!
!
! AMG-AINV: Approximate Inverse plugin for
! AMG4PSBLAS version 1.0
!
! (C) Copyright 2020
!
! Salvatore Filippone University of Rome Tor Vergata
!
! 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 AMG4PSBLAS 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 AMG4PSBLAS 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.
!
!
subroutine amg_d_ainv_solver_seti(sv,what,val,info)
use psb_base_mod
use amg_d_ainv_solver, amg_protect_name => amg_d_ainv_solver_seti
Implicit None
! Arguments
class(amg_d_ainv_solver_type), intent(inout) :: sv
integer(psb_ipk_), intent(in) :: what
integer(psb_ipk_), intent(in) :: val
integer(psb_ipk_), intent(out) :: info
!
integer(psb_ipk_) :: err_act
character(len=20) :: name='amg_d_ainv_solver_seti'
info = psb_success_
call psb_erractionsave(err_act)
select case(what)
case(amg_sub_fillin_)
sv%fill_in = val
case(amg_ainv_alg_)
sv%alg = val
case default
!!$ write(0,*) name,': Error: invalid WHAT'
!!$ info = -2
end select
call psb_erractionrestore(err_act)
return
9999 call psb_error_handler(err_act)
return
end subroutine amg_d_ainv_solver_seti

@ -0,0 +1,69 @@
!
!
! AMG-AINV: Approximate Inverse plugin for
! AMG4PSBLAS version 1.0
!
! (C) Copyright 2020
!
! Salvatore Filippone University of Rome Tor Vergata
!
! 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 AMG4PSBLAS 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 AMG4PSBLAS 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.
!
!
subroutine amg_d_ainv_solver_setr(sv,what,val,info)
use psb_base_mod
use amg_d_ainv_solver, amg_protect_name => amg_d_ainv_solver_setr
Implicit None
! Arguments
class(amg_d_ainv_solver_type), intent(inout) :: sv
integer(psb_ipk_), intent(in) :: what
real(psb_dpk_), intent(in) :: val
integer(psb_ipk_), intent(out) :: info
!
integer(psb_ipk_) :: err_act
character(len=20) :: name='amg_d_ainv_solver_setr'
call psb_erractionsave(err_act)
info = psb_success_
select case(what)
case(amg_sub_iluthrs_)
sv%thresh = val
case default
!!$ write(0,*) name,': Error: invalid WHAT'
!!$ info = -2
!!$ goto 9999
end select
call psb_erractionrestore(err_act)
return
9999 call psb_error_handler(err_act)
return
end subroutine amg_d_ainv_solver_setr

@ -0,0 +1,153 @@
!
!
! AMG-AINV: Approximate Inverse plugin for
! AMG4PSBLAS version 1.0
!
! (C) Copyright 2020
!
! Salvatore Filippone University of Rome Tor Vergata
!
! 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 AMG4PSBLAS 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 AMG4PSBLAS 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.
!
!
subroutine amg_d_base_ainv_solver_apply(alpha,sv,x,beta,y,desc_data,&
& trans,work,info,init,initu)
use psb_base_mod
use amg_d_base_ainv_mod, amg_protect_name => amg_d_base_ainv_solver_apply
implicit none
type(psb_desc_type), intent(in) :: desc_data
class(amg_d_base_ainv_solver_type), intent(inout) :: sv
real(psb_dpk_),intent(inout) :: x(:)
real(psb_dpk_),intent(inout) :: y(:)
real(psb_dpk_),intent(in) :: alpha,beta
character(len=1),intent(in) :: trans
real(psb_dpk_),target, intent(inout) :: work(:)
integer(psb_ipk_), intent(out) :: info
character, intent(in), optional :: init
real(psb_dpk_),intent(inout), optional :: initu(:)
!
integer(psb_ipk_) :: n_row,n_col
real(psb_dpk_), pointer :: ww(:), aux(:), tx(:),ty(:)
integer(psb_ipk_) :: np,me,i, err_act
type(psb_ctxt_type) :: ctxt
character :: trans_
character(len=20) :: name='d_base_ainv_solver_apply'
call psb_erractionsave(err_act)
info = psb_success_
trans_ = psb_toupper(trans)
select case(trans_)
case('N')
case('T','C')
case default
call psb_errpush(psb_err_iarg_invalid_i_,name)
goto 9999
end select
!
! For non-iterative solvers, init and initu are ignored.
!
n_row = psb_cd_get_local_rows(desc_data)
n_col = psb_cd_get_local_cols(desc_data)
if (n_col <= size(work)) then
ww => work(1:n_col)
if ((4*n_col+n_col) <= size(work)) then
aux => work(n_col+1:)
else
allocate(aux(4*n_col),stat=info)
if (info /= psb_success_) then
info=psb_err_alloc_request_
call psb_errpush(info,name,i_err=(/4*n_col/),&
& a_err='real(psb_dpk_)')
goto 9999
end if
endif
else
allocate(ww(n_col),aux(4*n_col),stat=info)
if (info /= psb_success_) then
info=psb_err_alloc_request_
call psb_errpush(info,name,i_err=(/5*n_col/),&
& a_err='real(psb_dpk_)')
goto 9999
end if
endif
select case(trans_)
case('N')
call psb_spmm(done,sv%w,x,dzero,ww,desc_data,info,&
& trans=trans_,work=aux,doswap=.false.)
ww(1:n_row) = ww(1:n_row) * sv%d(1:n_row)
if (info == psb_success_) &
& call psb_spmm(alpha,sv%z,ww,beta,y,desc_data,info,&
& trans=trans_,work=aux,doswap=.false.)
case('T','C')
call psb_spmm(done,sv%z,x,dzero,ww,desc_data,info,&
& trans=trans_,work=aux,doswap=.false.)
ww(1:n_row) = ww(1:n_row) * sv%d(1:n_row)
if (info == psb_success_) &
& call psb_spmm(alpha,sv%w,ww,beta,y,desc_data,info,&
& trans=trans_,work=aux,doswap=.false.)
case default
call psb_errpush(psb_err_internal_error_,name,&
& a_err='Invalid TRANS in ainv subsolve')
goto 9999
end select
if (info /= psb_success_) then
call psb_errpush(psb_err_internal_error_,name,&
& a_err='Error in subsolve')
goto 9999
endif
if (n_col <= size(work)) then
if ((4*n_col+n_col) <= size(work)) then
else
deallocate(aux,stat=info)
endif
else
deallocate(ww,aux,stat=info)
endif
if (info /= psb_success_) then
call psb_errpush(psb_err_internal_error_,name,&
& a_err='Deallocate')
goto 9999
endif
call psb_erractionrestore(err_act)
return
9999 call psb_error_handler(err_act)
return
end subroutine amg_d_base_ainv_solver_apply

@ -0,0 +1,167 @@
!
!
! AMG-AINV: Approximate Inverse plugin for
! AMG4PSBLAS version 1.0
!
! (C) Copyright 2020
!
! Salvatore Filippone University of Rome Tor Vergata
!
! 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 AMG4PSBLAS 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 AMG4PSBLAS 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.
!
!
subroutine amg_d_base_ainv_solver_apply_vect(alpha,sv,x,beta,y,desc_data,&
& trans,work,wv,info,init,initu)
use psb_base_mod
use amg_d_base_ainv_mod, amg_protect_name => amg_d_base_ainv_solver_apply_vect
implicit none
type(psb_desc_type), intent(in) :: desc_data
class(amg_d_base_ainv_solver_type), intent(inout) :: sv
type(psb_d_vect_type), intent(inout) :: x
type(psb_d_vect_type), intent(inout) :: y
real(psb_dpk_), intent(in) :: alpha,beta
character(len=1), intent(in) :: trans
real(psb_dpk_),target, intent(inout) :: work(:)
type(psb_d_vect_type),intent(inout) :: wv(:)
integer(psb_ipk_), intent(out) :: info
character, intent(in), optional :: init
type(psb_d_vect_type),intent(inout), optional :: initu
!
integer(psb_ipk_) :: n_row,n_col
real(psb_dpk_), pointer :: ww(:), aux(:)
type(psb_d_vect_type) :: tx,ty
integer(psb_ipk_) :: np,me,i, err_act
type(psb_ctxt_type) :: ctxt
character :: trans_
character(len=20) :: name='d_base_ainv_solver_apply'
call psb_erractionsave(err_act)
info = psb_success_
trans_ = psb_toupper(trans)
select case(trans_)
case('N')
case('T','C')
case default
call psb_errpush(psb_err_iarg_invalid_i_,name)
goto 9999
end select
!
! For non-iterative solvers, init and initu are ignored.
!
n_row = psb_cd_get_local_rows(desc_data)
n_col = psb_cd_get_local_cols(desc_data)
if (n_col <= size(work)) then
ww => work(1:n_col)
if ((4*n_col+n_col) <= size(work)) then
aux => work(n_col+1:)
else
allocate(aux(4*n_col),stat=info)
if (info /= psb_success_) then
info=psb_err_alloc_request_
call psb_errpush(info,name,i_err=(/4*n_col/),&
& a_err='real(psb_dpk_)')
goto 9999
end if
endif
else
allocate(ww(n_col),aux(4*n_col),stat=info)
if (info /= psb_success_) then
info=psb_err_alloc_request_
call psb_errpush(info,name,i_err=(/5*n_col/),&
& a_err='real(psb_dpk_)')
goto 9999
end if
endif
if (size(wv) < 2) then
info = psb_err_internal_error_
call psb_errpush(info,name,&
& a_err='invalid wv size')
goto 9999
end if
associate(tx => wv(1), ty => wv(2))
select case(trans_)
case('N')
call psb_spmm(done,sv%w,x,dzero,tx,desc_data,info,&
& trans=trans_,work=aux,doswap=.false.)
if (info == psb_success_) call ty%mlt(done,sv%dv,tx,dzero,info)
if (info == psb_success_) &
& call psb_spmm(alpha,sv%z,ty,beta,y,desc_data,info,&
& trans=trans_,work=aux,doswap=.false.)
case('T','C')
call psb_spmm(done,sv%z,x,dzero,tx,desc_data,info,&
& trans=trans_,work=aux,doswap=.false.)
if (info == psb_success_) call ty%mlt(done,sv%dv,tx,dzero,info)
if (info == psb_success_) &
& call psb_spmm(alpha,sv%w,ty,beta,y,desc_data,info,&
& trans=trans_,work=aux,doswap=.false.)
case default
call psb_errpush(psb_err_internal_error_,name,&
& a_err='Invalid TRANS in ainv subsolve')
goto 9999
end select
if (info /= psb_success_) then
call psb_errpush(psb_err_internal_error_,name,&
& a_err='Error in subsolve')
goto 9999
endif
end associate
if (n_col <= size(work)) then
if ((4*n_col+n_col) <= size(work)) then
else
deallocate(aux,stat=info)
endif
else
deallocate(ww,aux,stat=info)
endif
if (info /= psb_success_) then
call psb_errpush(psb_err_internal_error_,name,&
& a_err='Deallocate')
goto 9999
endif
call psb_erractionrestore(err_act)
return
9999 call psb_error_handler(err_act)
return
end subroutine amg_d_base_ainv_solver_apply_vect

@ -0,0 +1,63 @@
!
!
! AMG-AINV: Approximate Inverse plugin for
! AMG4PSBLAS version 1.0
!
! (C) Copyright 2020
!
! Salvatore Filippone University of Rome Tor Vergata
!
! 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 AMG4PSBLAS 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 AMG4PSBLAS 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.
!
!
subroutine amg_d_base_ainv_solver_cnv(sv,info,amold,vmold,imold)
use psb_base_mod
use amg_d_base_ainv_mod, amg_protect_name => amg_d_base_ainv_solver_cnv
Implicit None
! Arguments
class(amg_d_base_ainv_solver_type), intent(inout) :: sv
integer(psb_ipk_), intent(out) :: info
class(psb_d_base_sparse_mat), intent(in), optional :: amold
class(psb_d_base_vect_type), intent(in), optional :: vmold
class(psb_i_base_vect_type), intent(in), optional :: imold
!local
integer(psb_ipk_) :: i, j, il1, iln, lname, lev
integer(psb_ipk_) :: iam, np
type(psb_ctxt_type) :: ctxt
character(len=80) :: prefix_
character(len=120) :: fname ! len should be at least 20 more than
logical :: solver_
! len of prefix_
info = 0
if (present(amold)) then
call sv%w%cscnv(info,mold=amold)
call sv%z%cscnv(info,mold=amold)
end if
call sv%dv%cnv(mold=vmold)
end subroutine amg_d_base_ainv_solver_cnv

@ -0,0 +1,93 @@
!
!
! AMG-AINV: Approximate Inverse plugin for
! AMG4PSBLAS version 1.0
!
! (C) Copyright 2020
!
! Salvatore Filippone University of Rome Tor Vergata
!
! 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 AMG4PSBLAS 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 AMG4PSBLAS 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.
!
!
subroutine amg_d_base_ainv_solver_dmp(sv,desc,level,info,prefix,head,solver,global_num)
use psb_base_mod
use amg_d_base_ainv_mod, amg_protect_name => amg_d_base_ainv_solver_dmp
implicit none
class(amg_d_base_ainv_solver_type), intent(in) :: sv
type(psb_desc_type), intent(in) :: desc
integer(psb_ipk_), intent(in) :: level
integer(psb_ipk_), intent(out) :: info
character(len=*), intent(in), optional :: prefix, head
logical, optional, intent(in) :: solver, global_num
!
integer(psb_ipk_) :: i, j, il1, iln, lname, lev
integer(psb_ipk_) :: iam, np
type(psb_ctxt_type) :: ctxt
character(len=80) :: prefix_
character(len=120) :: fname ! len should be at least 20 more than
logical :: solver_, global_num_
! len of prefix_
info = 0
if (present(prefix)) then
prefix_ = trim(prefix(1:min(len(prefix),len(prefix_))))
else
prefix_ = "dump_ainv_d"
end if
ctxt = desc%get_context()
call psb_info(ctxt,iam,np)
if (present(solver)) then
solver_ = solver
else
solver_ = .false.
end if
if (present(global_num)) then
global_num_ = global_num
else
global_num_ = .false.
end if
lname = len_trim(prefix_)
fname = trim(prefix_)
write(fname(lname+1:lname+5),'(a,i3.3)') '_p',iam
lname = lname + 5
if (solver_) then
write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_wmat.mtx'
if (sv%w%is_asb()) &
& call sv%w%print(fname,head=head)
write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_diag.mtx'
if (allocated(sv%d)) &
& call psb_geprt(fname,sv%d,head=head)
write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_zmat.mtx'
if (sv%z%is_asb()) &
& call sv%z%print(fname,head=head)
end if
end subroutine amg_d_base_ainv_solver_dmp

@ -0,0 +1,70 @@
!
!
! AMG-AINV: Approximate Inverse plugin for
! AMG4PSBLAS version 1.0
!
! (C) Copyright 2020
!
! Salvatore Filippone University of Rome Tor Vergata
!
! 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 AMG4PSBLAS 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 AMG4PSBLAS 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.
!
!
subroutine amg_d_base_ainv_solver_free(sv,info)
use psb_base_mod
use amg_d_base_ainv_mod, amg_protect_name => amg_d_base_ainv_solver_free
Implicit None
! Arguments
class(amg_d_base_ainv_solver_type), intent(inout) :: sv
integer(psb_ipk_), intent(out) :: info
!
integer(psb_ipk_) :: err_act
character(len=20) :: name='amg_d_base_ainv_solver_free'
call psb_erractionsave(err_act)
info = psb_success_
call sv%clear_data(info)
if (allocated(sv%d)) then
deallocate(sv%d,stat=info)
if (info /= psb_success_) then
info = psb_err_alloc_dealloc_
call psb_errpush(info,name)
goto 9999
end if
end if
call sv%w%free()
call sv%z%free()
call sv%dv%free(info)
call psb_erractionrestore(err_act)
return
9999 call psb_error_handler(err_act)
return
end subroutine amg_d_base_ainv_solver_free

@ -0,0 +1,81 @@
!
!
! AMG-AINV: Approximate Inverse plugin for
! AMG4PSBLAS version 1.0
!
! (C) Copyright 2020
!
! Salvatore Filippone University of Rome Tor Vergata
!
! 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 AMG4PSBLAS 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 AMG4PSBLAS 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.
!
!
subroutine amg_d_base_ainv_update_a(sv,x,desc_data,info)
use amg_d_base_ainv_mod, amg_protect_name => amg_d_base_ainv_update_a
use psb_base_mod
implicit none
type(psb_desc_type), intent(in) :: desc_data
class(amg_d_base_ainv_solver_type), intent(inout) :: sv
real(psb_dpk_),intent(in) :: x(:)
integer(psb_ipk_), intent(out) :: info
! Local variables
real(psb_dpk_), allocatable :: dd(:), ee(:)
integer(psb_ipk_) :: nrows, ncols, i, j, k, nzr, nzc, ir, ic
type(psb_d_csc_sparse_mat) :: ac
type(psb_d_csr_sparse_mat) :: ar
dd = sv%dv%get_vect()
if (size(x)<size(dd)) then
write(0,*) 'Wrong size in update',size(x),size(dd)
info = -1
return
end if
ee = x(1:size(dd))
call sv%z%cp_to(ac)
call sv%w%cp_to(ar)
! Compute diag(W ee Z)
! First ee Z
call ac%scal(ee,info,side='L')
! Then diag(W (ee Z))
do i=1,ar%get_nrows()
ir = ar%irp(i); nzr = ar%irp(i+1)-ar%irp(i)
ic = ac%icp(i); nzc = ac%icp(i+1)-ac%icp(i)
ee(i) = psb_spdot_srtd(&
& nzr,ar%ja(ir:ir+nzr-1),ar%val(ir:ir+nzr-1),&
& nzc,ac%ia(ic:ic+nzc-1),ac%val(ic:ic+nzc-1))
end do
! Now invert diagonal
dd = done/dd
dd = dd + ee
dd = done/dd
sv%d = dd
call sv%dv%bld(dd,mold=sv%dv%v)
end subroutine amg_d_base_ainv_update_a

@ -0,0 +1,99 @@
!
!
! AMG-AINV: Approximate Inverse plugin for
! AMG4PSBLAS version 1.0
!
! (C) Copyright 2020
!
! Salvatore Filippone University of Rome Tor Vergata
!
! 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 AMG4PSBLAS 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 AMG4PSBLAS 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.
!
!
subroutine amg_s_ainv_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold)
use psb_base_mod
use psb_s_ainv_fact_mod
use amg_prec_mod
use amg_s_ainv_solver, amg_protect_name => amg_s_ainv_solver_bld
Implicit None
! Arguments
type(psb_sspmat_type), intent(in), target :: a
Type(psb_desc_type), Intent(inout) :: desc_a
class(amg_s_ainv_solver_type), intent(inout) :: sv
integer(psb_ipk_), intent(out) :: info
type(psb_sspmat_type), intent(in), target, optional :: b
class(psb_s_base_sparse_mat), intent(in), optional :: amold
class(psb_s_base_vect_type), intent(in), optional :: vmold
class(psb_i_base_vect_type), intent(in), optional :: imold
! Local variables
integer(psb_ipk_) :: n_row,n_col, nrow_a, nztota
real(psb_spk_), pointer :: ww(:), aux(:), tx(:),ty(:)
integer(psb_ipk_) :: np,me,i, err_act, debug_unit, debug_level
type(psb_ctxt_type) :: ctxt
character(len=20) :: name='amg_s_ainv_solver_bld', ch_err
info=psb_success_
call psb_erractionsave(err_act)
debug_unit = psb_get_debug_unit()
debug_level = psb_get_debug_level()
ctxt = desc_a%get_context()
call psb_info(ctxt, me, np)
if (debug_level >= psb_debug_outer_) &
& write(debug_unit,*) me,' ',trim(name),' start'
call psb_s_ainv_bld(a,sv%alg,sv%fill_in,sv%thresh,&
& sv%w,sv%d,sv%z,desc_a,info,b,iscale=amg_ilu_scale_maxval_)
if ((info == psb_success_) .and.present(amold)) then
call sv%w%set_asb()
call sv%w%trim()
call sv%z%set_asb()
call sv%z%trim()
call sv%w%cscnv(info,mold=amold)
if (info == psb_success_) &
& call sv%z%cscnv(info,mold=amold)
end if
if (info == psb_success_) &
& call sv%dv%bld(sv%d,mold=vmold)
if (info /= psb_success_) then
call psb_errpush(psb_err_internal_error_,name)
goto 9999
end if
if (debug_level >= psb_debug_outer_) &
& write(debug_unit,*) me,' ',trim(name),' end'
call psb_erractionrestore(err_act)
return
9999 call psb_error_handler(err_act)
return
end subroutine amg_s_ainv_solver_bld

@ -0,0 +1,65 @@
!
!
! AMG-AINV: Approximate Inverse plugin for
! AMG4PSBLAS version 1.0
!
! (C) Copyright 2020
!
! Salvatore Filippone University of Rome Tor Vergata
!
! 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 AMG4PSBLAS 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 AMG4PSBLAS 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.
!
!
subroutine amg_s_ainv_solver_check(sv,info)
use psb_base_mod
use amg_s_ainv_solver, amg_protect_name => amg_s_ainv_solver_check
Implicit None
! Arguments
class(amg_s_ainv_solver_type), intent(inout) :: sv
integer(psb_ipk_), intent(out) :: info
!
integer(psb_ipk_) :: err_act
character(len=20) :: name='amg_s_ainv_solver_check'
call psb_erractionsave(err_act)
info = psb_success_
call amg_check_def(sv%fill_in,&
& 'Nzmin',ione,is_positive_nz_min)
call amg_check_def(sv%thresh,&
& 'Eps',szero,is_legal_s_fact_thrs)
if (info /= psb_success_) goto 9999
call psb_erractionrestore(err_act)
return
9999 call psb_error_handler(err_act)
return
end subroutine amg_s_ainv_solver_check

@ -0,0 +1,91 @@
!
!
! AMG4PSBLAS version 1.0
! MultiLevel Domain Decomposition Parallel Preconditioners Package
! based on PSBLAS (Parallel Sparse BLAS version 3.0)
!
! (C) Copyright 2008,2009,2010,2010,2012
!
! Salvatore Filippone University of Rome Tor Vergata
! Alfredo Buttari CNRS-IRIT, Toulouse
! 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 AMG4PSBLAS 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 AMG4PSBLAS 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.
!
!
subroutine amg_s_ainv_solver_clone(sv,svout,info)
use psb_base_mod
use amg_s_ainv_solver, amg_protect_name => amg_s_ainv_solver_clone
Implicit None
! Arguments
class(amg_s_ainv_solver_type), intent(inout) :: sv
class(amg_s_base_solver_type), allocatable, intent(inout) :: svout
integer(psb_ipk_), intent(out) :: info
! Local variables
integer(psb_ipk_) :: err_act
info=psb_success_
call psb_erractionsave(err_act)
if (allocated(svout)) then
call svout%free(info)
if (info == psb_success_) deallocate(svout, stat=info)
end if
if (info == psb_success_) &
& allocate(amg_s_ainv_solver_type :: svout, stat=info)
if (info /= 0) then
info = psb_err_alloc_dealloc_
goto 9999
end if
select type(svo => svout)
type is (amg_s_ainv_solver_type)
svo%alg = sv%alg
svo%fill_in = sv%fill_in
svo%thresh = sv%thresh
call psb_safe_ab_cpy(sv%d,svo%d,info)
if (info == psb_success_) &
& call sv%dv%clone(svo%dv,info)
if (info == psb_success_) &
& call sv%w%clone(svo%w,info)
if (info == psb_success_) &
& call sv%z%clone(svo%z,info)
class default
info = psb_err_internal_error_
end select
if (info /= 0) goto 9999
call psb_erractionrestore(err_act)
return
9999 call psb_error_handler(err_act)
return
end subroutine amg_s_ainv_solver_clone

@ -0,0 +1,79 @@
!
!
! AMG-AINV: Approximate Inverse plugin for
! AMG4PSBLAS version 1.0
!
! (C) Copyright 2020
!
! Salvatore Filippone University of Rome Tor Vergata
!
! 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 AMG4PSBLAS 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 AMG4PSBLAS 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.
!
!
subroutine amg_s_ainv_solver_csetc(sv,what,val,info,idx)
use psb_base_mod
use amg_s_ainv_solver, amg_protect_name => amg_s_ainv_solver_csetc
Implicit None
! Arguments
class(amg_s_ainv_solver_type), intent(inout) :: sv
character(len=*), intent(in) :: what
character(len=*), intent(in) :: val
integer(psb_ipk_), intent(out) :: info
integer(psb_ipk_), intent(in), optional :: idx
!
integer(psb_ipk_ ) :: err_act, ival
character(len=20) :: name='amg_s_ainv_solver_setc'
info = psb_success_
call psb_erractionsave(err_act)
!!$ select case(psb_toupper(trim(what)))
!!$ case('AINV_ALG')
!!$ sv%alg = sv%stringval(val)
!!$ case default
!!$ call sv%mld_d_base_solver_type%set(what,val,info)
!!$ end select
ival = sv%stringval(val)
if (ival >=0) then
call sv%set(what,ival,info)
end if
if (info /= psb_success_) then
info = psb_err_from_subroutine_
call psb_errpush(info, name)
goto 9999
end if
call psb_erractionrestore(err_act)
return
9999 call psb_error_handler(err_act)
return
end subroutine amg_s_ainv_solver_csetc

@ -0,0 +1,69 @@
!
!
! AMG-AINV: Approximate Inverse plugin for
! AMG4PSBLAS version 1.0
!
! (C) Copyright 2020
!
! Salvatore Filippone University of Rome Tor Vergata
!
! 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 AMG4PSBLAS 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 AMG4PSBLAS 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.
!
!
subroutine amg_s_ainv_solver_cseti(sv,what,val,info,idx)
use psb_base_mod
use amg_s_ainv_solver, amg_protect_name => amg_s_ainv_solver_cseti
Implicit None
! Arguments
class(amg_s_ainv_solver_type), intent(inout) :: sv
character(len=*), intent(in) :: what
integer(psb_ipk_), intent(in) :: val
integer(psb_ipk_), intent(out) :: info
integer(psb_ipk_), intent(in), optional :: idx
!
integer(psb_ipk_) :: err_act
character(len=20) :: name='amg_s_ainv_solver_cseti'
info = psb_success_
call psb_erractionsave(err_act)
select case(psb_toupper(trim(what)))
case('SUB_FILLIN')
sv%fill_in = val
case('AINV_ALG')
sv%alg = val
case default
call sv%amg_s_base_solver_type%set(what,val,info)
end select
call psb_erractionrestore(err_act)
return
9999 call psb_error_handler(err_act)
return
end subroutine amg_s_ainv_solver_cseti

@ -0,0 +1,67 @@
!
!
! AMG-AINV: Approximate Inverse plugin for
! AMG4PSBLAS version 1.0
!
! (C) Copyright 2020
!
! Salvatore Filippone University of Rome Tor Vergata
!
! 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 AMG4PSBLAS 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 AMG4PSBLAS 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.
!
!
subroutine amg_s_ainv_solver_csetr(sv,what,val,info,idx)
use psb_base_mod
use amg_s_ainv_solver, amg_protect_name => amg_s_ainv_solver_csetr
Implicit None
! Arguments
class(amg_s_ainv_solver_type), intent(inout) :: sv
character(len=*), intent(in) :: what
real(psb_spk_), intent(in) :: val
integer(psb_ipk_), intent(out) :: info
integer(psb_ipk_), intent(in), optional :: idx
!
integer(psb_ipk_) :: err_act
character(len=20) :: name='amg_s_ainv_solver_csetr'
call psb_erractionsave(err_act)
info = psb_success_
select case(psb_toupper(what))
case('SUB_ILUTHRS')
sv%thresh = val
case default
call sv%amg_s_base_solver_type%set(what,val,info)
end select
call psb_erractionrestore(err_act)
return
9999 call psb_error_handler(err_act)
return
end subroutine amg_s_ainv_solver_csetr

@ -0,0 +1,73 @@
!
!
! AMG-AINV: Approximate Inverse plugin for
! AMG4PSBLAS version 1.0
!
! (C) Copyright 2020
!
! Salvatore Filippone University of Rome Tor Vergata
!
! 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 AMG4PSBLAS 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 AMG4PSBLAS 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.
!
!
subroutine amg_s_ainv_solver_descr(sv,info,iout,coarse)
use psb_base_mod
use amg_s_ainv_solver, amg_protect_name => amg_s_ainv_solver_descr
Implicit None
! Arguments
class(amg_s_ainv_solver_type), intent(in) :: sv
integer(psb_ipk_), intent(out) :: info
integer(psb_ipk_), intent(in), optional :: iout
logical, intent(in), optional :: coarse
! Local variables
integer(psb_ipk_) :: err_act
integer(psb_ipk_) :: ictxt, me, np
character(len=20), parameter :: name='amg_s_ainv_solver_descr'
integer(psb_ipk_) :: iout_
call psb_erractionsave(err_act)
info = psb_success_
if (present(iout)) then
iout_ = iout
else
iout_ = 6
endif
write(iout_,*) ' AINV: Approximate Inverse with sparse biconjugation '
write(iout_,*) ' Algorithm variant : ',sv%algname(sv%alg)
write(iout_,*) ' Fill level : ',sv%fill_in
write(iout_,*) ' Fill threshold : ',sv%thresh
call psb_erractionrestore(err_act)
return
9999 call psb_error_handler(err_act)
return
end subroutine amg_s_ainv_solver_descr

@ -0,0 +1,71 @@
!
!
! AMG-AINV: Approximate Inverse plugin for
! AMG4PSBLAS version 1.0
!
! (C) Copyright 2020
!
! Salvatore Filippone University of Rome Tor Vergata
!
! 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 AMG4PSBLAS 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 AMG4PSBLAS 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.
!
!
subroutine amg_s_ainv_solver_setc(sv,what,val,info)
use psb_base_mod
use amg_s_ainv_solver, amg_protect_name => amg_s_ainv_solver_setc
Implicit None
! Arguments
class(amg_s_ainv_solver_type), intent(inout) :: sv
integer(psb_ipk_), intent(in) :: what
character(len=*), intent(in) :: val
integer(psb_ipk_), intent(out) :: info
!
integer(psb_ipk_) :: err_act, ival
character(len=20) :: name='amg_s_ainv_solver_setc'
info = psb_success_
call psb_erractionsave(err_act)
ival = sv%stringval(val)
if (ival >=0) then
call sv%set(what,ival,info)
end if
if (info /= psb_success_) then
info = psb_err_from_subroutine_
call psb_errpush(info, name)
goto 9999
end if
call psb_erractionrestore(err_act)
return
9999 call psb_error_handler(err_act)
return
end subroutine amg_s_ainv_solver_setc

@ -0,0 +1,70 @@
!
!
! AMG-AINV: Approximate Inverse plugin for
! AMG4PSBLAS version 1.0
!
! (C) Copyright 2020
!
! Salvatore Filippone University of Rome Tor Vergata
!
! 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 AMG4PSBLAS 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 AMG4PSBLAS 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.
!
!
subroutine amg_s_ainv_solver_seti(sv,what,val,info)
use psb_base_mod
use amg_s_ainv_solver, amg_protect_name => amg_s_ainv_solver_seti
Implicit None
! Arguments
class(amg_s_ainv_solver_type), intent(inout) :: sv
integer(psb_ipk_), intent(in) :: what
integer(psb_ipk_), intent(in) :: val
integer(psb_ipk_), intent(out) :: info
!
integer(psb_ipk_) :: err_act
character(len=20) :: name='amg_s_ainv_solver_seti'
info = psb_success_
call psb_erractionsave(err_act)
select case(what)
case(amg_sub_fillin_)
sv%fill_in = val
case(amg_ainv_alg_)
sv%alg = val
case default
!!$ write(0,*) name,': Error: invalid WHAT'
!!$ info = -2
end select
call psb_erractionrestore(err_act)
return
9999 call psb_error_handler(err_act)
return
end subroutine amg_s_ainv_solver_seti

@ -0,0 +1,69 @@
!
!
! AMG-AINV: Approximate Inverse plugin for
! AMG4PSBLAS version 1.0
!
! (C) Copyright 2020
!
! Salvatore Filippone University of Rome Tor Vergata
!
! 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 AMG4PSBLAS 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 AMG4PSBLAS 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.
!
!
subroutine amg_s_ainv_solver_setr(sv,what,val,info)
use psb_base_mod
use amg_s_ainv_solver, amg_protect_name => amg_s_ainv_solver_setr
Implicit None
! Arguments
class(amg_s_ainv_solver_type), intent(inout) :: sv
integer(psb_ipk_), intent(in) :: what
real(psb_spk_), intent(in) :: val
integer(psb_ipk_), intent(out) :: info
!
integer(psb_ipk_) :: err_act
character(len=20) :: name='amg_s_ainv_solver_setr'
call psb_erractionsave(err_act)
info = psb_success_
select case(what)
case(amg_sub_iluthrs_)
sv%thresh = val
case default
!!$ write(0,*) name,': Error: invalid WHAT'
!!$ info = -2
!!$ goto 9999
end select
call psb_erractionrestore(err_act)
return
9999 call psb_error_handler(err_act)
return
end subroutine amg_s_ainv_solver_setr

@ -0,0 +1,153 @@
!
!
! AMG-AINV: Approximate Inverse plugin for
! AMG4PSBLAS version 1.0
!
! (C) Copyright 2020
!
! Salvatore Filippone University of Rome Tor Vergata
!
! 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 AMG4PSBLAS 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 AMG4PSBLAS 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.
!
!
subroutine amg_s_base_ainv_solver_apply(alpha,sv,x,beta,y,desc_data,&
& trans,work,info,init,initu)
use psb_base_mod
use amg_s_base_ainv_mod, amg_protect_name => amg_s_base_ainv_solver_apply
implicit none
type(psb_desc_type), intent(in) :: desc_data
class(amg_s_base_ainv_solver_type), intent(inout) :: sv
real(psb_spk_),intent(inout) :: x(:)
real(psb_spk_),intent(inout) :: y(:)
real(psb_spk_),intent(in) :: alpha,beta
character(len=1),intent(in) :: trans
real(psb_spk_),target, intent(inout) :: work(:)
integer(psb_ipk_), intent(out) :: info
character, intent(in), optional :: init
real(psb_spk_),intent(inout), optional :: initu(:)
!
integer(psb_ipk_) :: n_row,n_col
real(psb_spk_), pointer :: ww(:), aux(:), tx(:),ty(:)
integer(psb_ipk_) :: np,me,i, err_act
type(psb_ctxt_type) :: ctxt
character :: trans_
character(len=20) :: name='d_base_ainv_solver_apply'
call psb_erractionsave(err_act)
info = psb_success_
trans_ = psb_toupper(trans)
select case(trans_)
case('N')
case('T','C')
case default
call psb_errpush(psb_err_iarg_invalid_i_,name)
goto 9999
end select
!
! For non-iterative solvers, init and initu are ignored.
!
n_row = psb_cd_get_local_rows(desc_data)
n_col = psb_cd_get_local_cols(desc_data)
if (n_col <= size(work)) then
ww => work(1:n_col)
if ((4*n_col+n_col) <= size(work)) then
aux => work(n_col+1:)
else
allocate(aux(4*n_col),stat=info)
if (info /= psb_success_) then
info=psb_err_alloc_request_
call psb_errpush(info,name,i_err=(/4*n_col/),&
& a_err='real(psb_dpk_)')
goto 9999
end if
endif
else
allocate(ww(n_col),aux(4*n_col),stat=info)
if (info /= psb_success_) then
info=psb_err_alloc_request_
call psb_errpush(info,name,i_err=(/5*n_col/),&
& a_err='real(psb_dpk_)')
goto 9999
end if
endif
select case(trans_)
case('N')
call psb_spmm(sone,sv%w,x,szero,ww,desc_data,info,&
& trans=trans_,work=aux,doswap=.false.)
ww(1:n_row) = ww(1:n_row) * sv%d(1:n_row)
if (info == psb_success_) &
& call psb_spmm(alpha,sv%z,ww,beta,y,desc_data,info,&
& trans=trans_,work=aux,doswap=.false.)
case('T','C')
call psb_spmm(sone,sv%z,x,szero,ww,desc_data,info,&
& trans=trans_,work=aux,doswap=.false.)
ww(1:n_row) = ww(1:n_row) * sv%d(1:n_row)
if (info == psb_success_) &
& call psb_spmm(alpha,sv%w,ww,beta,y,desc_data,info,&
& trans=trans_,work=aux,doswap=.false.)
case default
call psb_errpush(psb_err_internal_error_,name,&
& a_err='Invalid TRANS in ainv subsolve')
goto 9999
end select
if (info /= psb_success_) then
call psb_errpush(psb_err_internal_error_,name,&
& a_err='Error in subsolve')
goto 9999
endif
if (n_col <= size(work)) then
if ((4*n_col+n_col) <= size(work)) then
else
deallocate(aux,stat=info)
endif
else
deallocate(ww,aux,stat=info)
endif
if (info /= psb_success_) then
call psb_errpush(psb_err_internal_error_,name,&
& a_err='Deallocate')
goto 9999
endif
call psb_erractionrestore(err_act)
return
9999 call psb_error_handler(err_act)
return
end subroutine amg_s_base_ainv_solver_apply

@ -0,0 +1,167 @@
!
!
! AMG-AINV: Approximate Inverse plugin for
! AMG4PSBLAS version 1.0
!
! (C) Copyright 2020
!
! Salvatore Filippone University of Rome Tor Vergata
!
! 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 AMG4PSBLAS 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 AMG4PSBLAS 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.
!
!
subroutine amg_s_base_ainv_solver_apply_vect(alpha,sv,x,beta,y,desc_data,&
& trans,work,wv,info,init,initu)
use psb_base_mod
use amg_s_base_ainv_mod, amg_protect_name => amg_s_base_ainv_solver_apply_vect
implicit none
type(psb_desc_type), intent(in) :: desc_data
class(amg_s_base_ainv_solver_type), intent(inout) :: sv
type(psb_s_vect_type), intent(inout) :: x
type(psb_s_vect_type), intent(inout) :: y
real(psb_spk_), intent(in) :: alpha,beta
character(len=1), intent(in) :: trans
real(psb_spk_),target, intent(inout) :: work(:)
type(psb_s_vect_type),intent(inout) :: wv(:)
integer(psb_ipk_), intent(out) :: info
character, intent(in), optional :: init
type(psb_s_vect_type),intent(inout), optional :: initu
!
integer(psb_ipk_) :: n_row,n_col
real(psb_spk_), pointer :: ww(:), aux(:)
type(psb_s_vect_type) :: tx,ty
integer(psb_ipk_) :: np,me,i, err_act
type(psb_ctxt_type) :: ctxt
character :: trans_
character(len=20) :: name='d_base_ainv_solver_apply'
call psb_erractionsave(err_act)
info = psb_success_
trans_ = psb_toupper(trans)
select case(trans_)
case('N')
case('T','C')
case default
call psb_errpush(psb_err_iarg_invalid_i_,name)
goto 9999
end select
!
! For non-iterative solvers, init and initu are ignored.
!
n_row = psb_cd_get_local_rows(desc_data)
n_col = psb_cd_get_local_cols(desc_data)
if (n_col <= size(work)) then
ww => work(1:n_col)
if ((4*n_col+n_col) <= size(work)) then
aux => work(n_col+1:)
else
allocate(aux(4*n_col),stat=info)
if (info /= psb_success_) then
info=psb_err_alloc_request_
call psb_errpush(info,name,i_err=(/4*n_col/),&
& a_err='real(psb_dpk_)')
goto 9999
end if
endif
else
allocate(ww(n_col),aux(4*n_col),stat=info)
if (info /= psb_success_) then
info=psb_err_alloc_request_
call psb_errpush(info,name,i_err=(/5*n_col/),&
& a_err='real(psb_dpk_)')
goto 9999
end if
endif
if (size(wv) < 2) then
info = psb_err_internal_error_
call psb_errpush(info,name,&
& a_err='invalid wv size')
goto 9999
end if
associate(tx => wv(1), ty => wv(2))
select case(trans_)
case('N')
call psb_spmm(sone,sv%w,x,szero,tx,desc_data,info,&
& trans=trans_,work=aux,doswap=.false.)
if (info == psb_success_) call ty%mlt(sone,sv%dv,tx,szero,info)
if (info == psb_success_) &
& call psb_spmm(alpha,sv%z,ty,beta,y,desc_data,info,&
& trans=trans_,work=aux,doswap=.false.)
case('T','C')
call psb_spmm(sone,sv%z,x,szero,tx,desc_data,info,&
& trans=trans_,work=aux,doswap=.false.)
if (info == psb_success_) call ty%mlt(sone,sv%dv,tx,szero,info)
if (info == psb_success_) &
& call psb_spmm(alpha,sv%w,ty,beta,y,desc_data,info,&
& trans=trans_,work=aux,doswap=.false.)
case default
call psb_errpush(psb_err_internal_error_,name,&
& a_err='Invalid TRANS in ainv subsolve')
goto 9999
end select
if (info /= psb_success_) then
call psb_errpush(psb_err_internal_error_,name,&
& a_err='Error in subsolve')
goto 9999
endif
end associate
if (n_col <= size(work)) then
if ((4*n_col+n_col) <= size(work)) then
else
deallocate(aux,stat=info)
endif
else
deallocate(ww,aux,stat=info)
endif
if (info /= psb_success_) then
call psb_errpush(psb_err_internal_error_,name,&
& a_err='Deallocate')
goto 9999
endif
call psb_erractionrestore(err_act)
return
9999 call psb_error_handler(err_act)
return
end subroutine amg_s_base_ainv_solver_apply_vect

@ -0,0 +1,63 @@
!
!
! AMG-AINV: Approximate Inverse plugin for
! AMG4PSBLAS version 1.0
!
! (C) Copyright 2020
!
! Salvatore Filippone University of Rome Tor Vergata
!
! 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 AMG4PSBLAS 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 AMG4PSBLAS 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.
!
!
subroutine amg_s_base_ainv_solver_cnv(sv,info,amold,vmold,imold)
use psb_base_mod
use amg_s_base_ainv_mod, amg_protect_name => amg_s_base_ainv_solver_cnv
Implicit None
! Arguments
class(amg_s_base_ainv_solver_type), intent(inout) :: sv
integer(psb_ipk_), intent(out) :: info
class(psb_s_base_sparse_mat), intent(in), optional :: amold
class(psb_s_base_vect_type), intent(in), optional :: vmold
class(psb_i_base_vect_type), intent(in), optional :: imold
!local
integer(psb_ipk_) :: i, j, il1, iln, lname, lev
integer(psb_ipk_) :: iam, np
type(psb_ctxt_type) :: ctxt
character(len=80) :: prefix_
character(len=120) :: fname ! len should be at least 20 more than
logical :: solver_
! len of prefix_
info = 0
if (present(amold)) then
call sv%w%cscnv(info,mold=amold)
call sv%z%cscnv(info,mold=amold)
end if
call sv%dv%cnv(mold=vmold)
end subroutine amg_s_base_ainv_solver_cnv

@ -0,0 +1,93 @@
!
!
! AMG-AINV: Approximate Inverse plugin for
! AMG4PSBLAS version 1.0
!
! (C) Copyright 2020
!
! Salvatore Filippone University of Rome Tor Vergata
!
! 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 AMG4PSBLAS 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 AMG4PSBLAS 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.
!
!
subroutine amg_s_base_ainv_solver_dmp(sv,desc,level,info,prefix,head,solver,global_num)
use psb_base_mod
use amg_s_base_ainv_mod, amg_protect_name => amg_s_base_ainv_solver_dmp
implicit none
class(amg_s_base_ainv_solver_type), intent(in) :: sv
type(psb_desc_type), intent(in) :: desc
integer(psb_ipk_), intent(in) :: level
integer(psb_ipk_), intent(out) :: info
character(len=*), intent(in), optional :: prefix, head
logical, optional, intent(in) :: solver, global_num
!
integer(psb_ipk_) :: i, j, il1, iln, lname, lev
integer(psb_ipk_) :: iam, np
type(psb_ctxt_type) :: ctxt
character(len=80) :: prefix_
character(len=120) :: fname ! len should be at least 20 more than
logical :: solver_, global_num_
! len of prefix_
info = 0
if (present(prefix)) then
prefix_ = trim(prefix(1:min(len(prefix),len(prefix_))))
else
prefix_ = "dump_ainv_d"
end if
ctxt = desc%get_context()
call psb_info(ctxt,iam,np)
if (present(solver)) then
solver_ = solver
else
solver_ = .false.
end if
if (present(global_num)) then
global_num_ = global_num
else
global_num_ = .false.
end if
lname = len_trim(prefix_)
fname = trim(prefix_)
write(fname(lname+1:lname+5),'(a,i3.3)') '_p',iam
lname = lname + 5
if (solver_) then
write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_wmat.mtx'
if (sv%w%is_asb()) &
& call sv%w%print(fname,head=head)
write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_diag.mtx'
if (allocated(sv%d)) &
& call psb_geprt(fname,sv%d,head=head)
write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_zmat.mtx'
if (sv%z%is_asb()) &
& call sv%z%print(fname,head=head)
end if
end subroutine amg_s_base_ainv_solver_dmp

@ -0,0 +1,70 @@
!
!
! AMG-AINV: Approximate Inverse plugin for
! AMG4PSBLAS version 1.0
!
! (C) Copyright 2020
!
! Salvatore Filippone University of Rome Tor Vergata
!
! 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 AMG4PSBLAS 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 AMG4PSBLAS 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.
!
!
subroutine amg_s_base_ainv_solver_free(sv,info)
use psb_base_mod
use amg_s_base_ainv_mod, amg_protect_name => amg_s_base_ainv_solver_free
Implicit None
! Arguments
class(amg_s_base_ainv_solver_type), intent(inout) :: sv
integer(psb_ipk_), intent(out) :: info
!
integer(psb_ipk_) :: err_act
character(len=20) :: name='amg_s_base_ainv_solver_free'
call psb_erractionsave(err_act)
info = psb_success_
call sv%clear_data(info)
if (allocated(sv%d)) then
deallocate(sv%d,stat=info)
if (info /= psb_success_) then
info = psb_err_alloc_dealloc_
call psb_errpush(info,name)
goto 9999
end if
end if
call sv%w%free()
call sv%z%free()
call sv%dv%free(info)
call psb_erractionrestore(err_act)
return
9999 call psb_error_handler(err_act)
return
end subroutine amg_s_base_ainv_solver_free

@ -0,0 +1,81 @@
!
!
! AMG-AINV: Approximate Inverse plugin for
! AMG4PSBLAS version 1.0
!
! (C) Copyright 2020
!
! Salvatore Filippone University of Rome Tor Vergata
!
! 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 AMG4PSBLAS 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 AMG4PSBLAS 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.
!
!
subroutine amg_s_base_ainv_update_a(sv,x,desc_data,info)
use amg_s_base_ainv_mod, amg_protect_name => amg_s_base_ainv_update_a
use psb_base_mod
implicit none
type(psb_desc_type), intent(in) :: desc_data
class(amg_s_base_ainv_solver_type), intent(inout) :: sv
real(psb_spk_),intent(in) :: x(:)
integer(psb_ipk_), intent(out) :: info
! Local variables
real(psb_spk_), allocatable :: dd(:), ee(:)
integer(psb_ipk_) :: nrows, ncols, i, j, k, nzr, nzc, ir, ic
type(psb_s_csc_sparse_mat) :: ac
type(psb_s_csr_sparse_mat) :: ar
dd = sv%dv%get_vect()
if (size(x)<size(dd)) then
write(0,*) 'Wrong size in update',size(x),size(dd)
info = -1
return
end if
ee = x(1:size(dd))
call sv%z%cp_to(ac)
call sv%w%cp_to(ar)
! Compute diag(W ee Z)
! First ee Z
call ac%scal(ee,info,side='L')
! Then diag(W (ee Z))
do i=1,ar%get_nrows()
ir = ar%irp(i); nzr = ar%irp(i+1)-ar%irp(i)
ic = ac%icp(i); nzc = ac%icp(i+1)-ac%icp(i)
ee(i) = psb_spdot_srtd(&
& nzr,ar%ja(ir:ir+nzr-1),ar%val(ir:ir+nzr-1),&
& nzc,ac%ia(ic:ic+nzc-1),ac%val(ic:ic+nzc-1))
end do
! Now invert diagonal
dd = done/dd
dd = dd + ee
dd = done/dd
sv%d = dd
call sv%dv%bld(dd,mold=sv%dv%v)
end subroutine amg_s_base_ainv_update_a

@ -0,0 +1,99 @@
!
!
! AMG-AINV: Approximate Inverse plugin for
! AMG4PSBLAS version 1.0
!
! (C) Copyright 2020
!
! Salvatore Filippone University of Rome Tor Vergata
!
! 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 AMG4PSBLAS 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 AMG4PSBLAS 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.
!
!
subroutine amg_z_ainv_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold)
use psb_base_mod
use psb_z_ainv_fact_mod
use amg_prec_mod
use amg_z_ainv_solver, amg_protect_name => amg_z_ainv_solver_bld
Implicit None
! Arguments
type(psb_zspmat_type), intent(in), target :: a
Type(psb_desc_type), Intent(inout) :: desc_a
class(amg_z_ainv_solver_type), intent(inout) :: sv
integer(psb_ipk_), intent(out) :: info
type(psb_zspmat_type), intent(in), target, optional :: b
class(psb_z_base_sparse_mat), intent(in), optional :: amold
class(psb_z_base_vect_type), intent(in), optional :: vmold
class(psb_i_base_vect_type), intent(in), optional :: imold
! Local variables
integer(psb_ipk_) :: n_row,n_col, nrow_a, nztota
complex(psb_dpk_), pointer :: ww(:), aux(:), tx(:),ty(:)
integer(psb_ipk_) :: np,me,i, err_act, debug_unit, debug_level
type(psb_ctxt_type) :: ctxt
character(len=20) :: name='amg_z_ainv_solver_bld', ch_err
info=psb_success_
call psb_erractionsave(err_act)
debug_unit = psb_get_debug_unit()
debug_level = psb_get_debug_level()
ctxt = desc_a%get_context()
call psb_info(ctxt, me, np)
if (debug_level >= psb_debug_outer_) &
& write(debug_unit,*) me,' ',trim(name),' start'
call psb_z_ainv_bld(a,sv%alg,sv%fill_in,sv%thresh,&
& sv%w,sv%d,sv%z,desc_a,info,b,iscale=amg_ilu_scale_maxval_)
if ((info == psb_success_) .and.present(amold)) then
call sv%w%set_asb()
call sv%w%trim()
call sv%z%set_asb()
call sv%z%trim()
call sv%w%cscnv(info,mold=amold)
if (info == psb_success_) &
& call sv%z%cscnv(info,mold=amold)
end if
if (info == psb_success_) &
& call sv%dv%bld(sv%d,mold=vmold)
if (info /= psb_success_) then
call psb_errpush(psb_err_internal_error_,name)
goto 9999
end if
if (debug_level >= psb_debug_outer_) &
& write(debug_unit,*) me,' ',trim(name),' end'
call psb_erractionrestore(err_act)
return
9999 call psb_error_handler(err_act)
return
end subroutine amg_z_ainv_solver_bld

@ -0,0 +1,65 @@
!
!
! AMG-AINV: Approximate Inverse plugin for
! AMG4PSBLAS version 1.0
!
! (C) Copyright 2020
!
! Salvatore Filippone University of Rome Tor Vergata
!
! 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 AMG4PSBLAS 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 AMG4PSBLAS 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.
!
!
subroutine amg_z_ainv_solver_check(sv,info)
use psb_base_mod
use amg_z_ainv_solver, amg_protect_name => amg_z_ainv_solver_check
Implicit None
! Arguments
class(amg_z_ainv_solver_type), intent(inout) :: sv
integer(psb_ipk_), intent(out) :: info
!
integer(psb_ipk_) :: err_act
character(len=20) :: name='amg_z_ainv_solver_check'
call psb_erractionsave(err_act)
info = psb_success_
call amg_check_def(sv%fill_in,&
& 'Nzmin',ione,is_positive_nz_min)
call amg_check_def(sv%thresh,&
& 'Eps',dzero,is_legal_d_fact_thrs)
if (info /= psb_success_) goto 9999
call psb_erractionrestore(err_act)
return
9999 call psb_error_handler(err_act)
return
end subroutine amg_z_ainv_solver_check

@ -0,0 +1,91 @@
!
!
! AMG4PSBLAS version 1.0
! MultiLevel Domain Decomposition Parallel Preconditioners Package
! based on PSBLAS (Parallel Sparse BLAS version 3.0)
!
! (C) Copyright 2008,2009,2010,2010,2012
!
! Salvatore Filippone University of Rome Tor Vergata
! Alfredo Buttari CNRS-IRIT, Toulouse
! 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 AMG4PSBLAS 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 AMG4PSBLAS 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.
!
!
subroutine amg_z_ainv_solver_clone(sv,svout,info)
use psb_base_mod
use amg_z_ainv_solver, amg_protect_name => amg_z_ainv_solver_clone
Implicit None
! Arguments
class(amg_z_ainv_solver_type), intent(inout) :: sv
class(amg_z_base_solver_type), allocatable, intent(inout) :: svout
integer(psb_ipk_), intent(out) :: info
! Local variables
integer(psb_ipk_) :: err_act
info=psb_success_
call psb_erractionsave(err_act)
if (allocated(svout)) then
call svout%free(info)
if (info == psb_success_) deallocate(svout, stat=info)
end if
if (info == psb_success_) &
& allocate(amg_z_ainv_solver_type :: svout, stat=info)
if (info /= 0) then
info = psb_err_alloc_dealloc_
goto 9999
end if
select type(svo => svout)
type is (amg_z_ainv_solver_type)
svo%alg = sv%alg
svo%fill_in = sv%fill_in
svo%thresh = sv%thresh
call psb_safe_ab_cpy(sv%d,svo%d,info)
if (info == psb_success_) &
& call sv%dv%clone(svo%dv,info)
if (info == psb_success_) &
& call sv%w%clone(svo%w,info)
if (info == psb_success_) &
& call sv%z%clone(svo%z,info)
class default
info = psb_err_internal_error_
end select
if (info /= 0) goto 9999
call psb_erractionrestore(err_act)
return
9999 call psb_error_handler(err_act)
return
end subroutine amg_z_ainv_solver_clone

@ -0,0 +1,79 @@
!
!
! AMG-AINV: Approximate Inverse plugin for
! AMG4PSBLAS version 1.0
!
! (C) Copyright 2020
!
! Salvatore Filippone University of Rome Tor Vergata
!
! 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 AMG4PSBLAS 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 AMG4PSBLAS 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.
!
!
subroutine amg_z_ainv_solver_csetc(sv,what,val,info,idx)
use psb_base_mod
use amg_z_ainv_solver, amg_protect_name => amg_z_ainv_solver_csetc
Implicit None
! Arguments
class(amg_z_ainv_solver_type), intent(inout) :: sv
character(len=*), intent(in) :: what
character(len=*), intent(in) :: val
integer(psb_ipk_), intent(out) :: info
integer(psb_ipk_), intent(in), optional :: idx
!
integer(psb_ipk_ ) :: err_act, ival
character(len=20) :: name='amg_z_ainv_solver_setc'
info = psb_success_
call psb_erractionsave(err_act)
!!$ select case(psb_toupper(trim(what)))
!!$ case('AINV_ALG')
!!$ sv%alg = sv%stringval(val)
!!$ case default
!!$ call sv%mld_d_base_solver_type%set(what,val,info)
!!$ end select
ival = sv%stringval(val)
if (ival >=0) then
call sv%set(what,ival,info)
end if
if (info /= psb_success_) then
info = psb_err_from_subroutine_
call psb_errpush(info, name)
goto 9999
end if
call psb_erractionrestore(err_act)
return
9999 call psb_error_handler(err_act)
return
end subroutine amg_z_ainv_solver_csetc

@ -0,0 +1,69 @@
!
!
! AMG-AINV: Approximate Inverse plugin for
! AMG4PSBLAS version 1.0
!
! (C) Copyright 2020
!
! Salvatore Filippone University of Rome Tor Vergata
!
! 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 AMG4PSBLAS 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 AMG4PSBLAS 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.
!
!
subroutine amg_z_ainv_solver_cseti(sv,what,val,info,idx)
use psb_base_mod
use amg_z_ainv_solver, amg_protect_name => amg_z_ainv_solver_cseti
Implicit None
! Arguments
class(amg_z_ainv_solver_type), intent(inout) :: sv
character(len=*), intent(in) :: what
integer(psb_ipk_), intent(in) :: val
integer(psb_ipk_), intent(out) :: info
integer(psb_ipk_), intent(in), optional :: idx
!
integer(psb_ipk_) :: err_act
character(len=20) :: name='amg_z_ainv_solver_cseti'
info = psb_success_
call psb_erractionsave(err_act)
select case(psb_toupper(trim(what)))
case('SUB_FILLIN')
sv%fill_in = val
case('AINV_ALG')
sv%alg = val
case default
call sv%amg_z_base_solver_type%set(what,val,info)
end select
call psb_erractionrestore(err_act)
return
9999 call psb_error_handler(err_act)
return
end subroutine amg_z_ainv_solver_cseti

@ -0,0 +1,67 @@
!
!
! AMG-AINV: Approximate Inverse plugin for
! AMG4PSBLAS version 1.0
!
! (C) Copyright 2020
!
! Salvatore Filippone University of Rome Tor Vergata
!
! 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 AMG4PSBLAS 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 AMG4PSBLAS 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.
!
!
subroutine amg_z_ainv_solver_csetr(sv,what,val,info,idx)
use psb_base_mod
use amg_z_ainv_solver, amg_protect_name => amg_z_ainv_solver_csetr
Implicit None
! Arguments
class(amg_z_ainv_solver_type), intent(inout) :: sv
character(len=*), intent(in) :: what
real(psb_dpk_), intent(in) :: val
integer(psb_ipk_), intent(out) :: info
integer(psb_ipk_), intent(in), optional :: idx
!
integer(psb_ipk_) :: err_act
character(len=20) :: name='amg_z_ainv_solver_csetr'
call psb_erractionsave(err_act)
info = psb_success_
select case(psb_toupper(what))
case('SUB_ILUTHRS')
sv%thresh = val
case default
call sv%amg_z_base_solver_type%set(what,val,info)
end select
call psb_erractionrestore(err_act)
return
9999 call psb_error_handler(err_act)
return
end subroutine amg_z_ainv_solver_csetr

@ -0,0 +1,73 @@
!
!
! AMG-AINV: Approximate Inverse plugin for
! AMG4PSBLAS version 1.0
!
! (C) Copyright 2020
!
! Salvatore Filippone University of Rome Tor Vergata
!
! 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 AMG4PSBLAS 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 AMG4PSBLAS 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.
!
!
subroutine amg_z_ainv_solver_descr(sv,info,iout,coarse)
use psb_base_mod
use amg_z_ainv_solver, amg_protect_name => amg_z_ainv_solver_descr
Implicit None
! Arguments
class(amg_z_ainv_solver_type), intent(in) :: sv
integer(psb_ipk_), intent(out) :: info
integer(psb_ipk_), intent(in), optional :: iout
logical, intent(in), optional :: coarse
! Local variables
integer(psb_ipk_) :: err_act
integer(psb_ipk_) :: ictxt, me, np
character(len=20), parameter :: name='amg_z_ainv_solver_descr'
integer(psb_ipk_) :: iout_
call psb_erractionsave(err_act)
info = psb_success_
if (present(iout)) then
iout_ = iout
else
iout_ = 6
endif
write(iout_,*) ' AINV: Approximate Inverse with sparse biconjugation '
write(iout_,*) ' Algorithm variant : ',sv%algname(sv%alg)
write(iout_,*) ' Fill level : ',sv%fill_in
write(iout_,*) ' Fill threshold : ',sv%thresh
call psb_erractionrestore(err_act)
return
9999 call psb_error_handler(err_act)
return
end subroutine amg_z_ainv_solver_descr

@ -0,0 +1,71 @@
!
!
! AMG-AINV: Approximate Inverse plugin for
! AMG4PSBLAS version 1.0
!
! (C) Copyright 2020
!
! Salvatore Filippone University of Rome Tor Vergata
!
! 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 AMG4PSBLAS 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 AMG4PSBLAS 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.
!
!
subroutine amg_z_ainv_solver_setc(sv,what,val,info)
use psb_base_mod
use amg_z_ainv_solver, amg_protect_name => amg_z_ainv_solver_setc
Implicit None
! Arguments
class(amg_z_ainv_solver_type), intent(inout) :: sv
integer(psb_ipk_), intent(in) :: what
character(len=*), intent(in) :: val
integer(psb_ipk_), intent(out) :: info
!
integer(psb_ipk_) :: err_act, ival
character(len=20) :: name='amg_z_ainv_solver_setc'
info = psb_success_
call psb_erractionsave(err_act)
ival = sv%stringval(val)
if (ival >=0) then
call sv%set(what,ival,info)
end if
if (info /= psb_success_) then
info = psb_err_from_subroutine_
call psb_errpush(info, name)
goto 9999
end if
call psb_erractionrestore(err_act)
return
9999 call psb_error_handler(err_act)
return
end subroutine amg_z_ainv_solver_setc

@ -0,0 +1,70 @@
!
!
! AMG-AINV: Approximate Inverse plugin for
! AMG4PSBLAS version 1.0
!
! (C) Copyright 2020
!
! Salvatore Filippone University of Rome Tor Vergata
!
! 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 AMG4PSBLAS 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 AMG4PSBLAS 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.
!
!
subroutine amg_z_ainv_solver_seti(sv,what,val,info)
use psb_base_mod
use amg_z_ainv_solver, amg_protect_name => amg_z_ainv_solver_seti
Implicit None
! Arguments
class(amg_z_ainv_solver_type), intent(inout) :: sv
integer(psb_ipk_), intent(in) :: what
integer(psb_ipk_), intent(in) :: val
integer(psb_ipk_), intent(out) :: info
!
integer(psb_ipk_) :: err_act
character(len=20) :: name='amg_z_ainv_solver_seti'
info = psb_success_
call psb_erractionsave(err_act)
select case(what)
case(amg_sub_fillin_)
sv%fill_in = val
case(amg_ainv_alg_)
sv%alg = val
case default
!!$ write(0,*) name,': Error: invalid WHAT'
!!$ info = -2
end select
call psb_erractionrestore(err_act)
return
9999 call psb_error_handler(err_act)
return
end subroutine amg_z_ainv_solver_seti

@ -0,0 +1,69 @@
!
!
! AMG-AINV: Approximate Inverse plugin for
! AMG4PSBLAS version 1.0
!
! (C) Copyright 2020
!
! Salvatore Filippone University of Rome Tor Vergata
!
! 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 AMG4PSBLAS 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 AMG4PSBLAS 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.
!
!
subroutine amg_z_ainv_solver_setr(sv,what,val,info)
use psb_base_mod
use amg_z_ainv_solver, amg_protect_name => amg_z_ainv_solver_setr
Implicit None
! Arguments
class(amg_z_ainv_solver_type), intent(inout) :: sv
integer(psb_ipk_), intent(in) :: what
real(psb_dpk_), intent(in) :: val
integer(psb_ipk_), intent(out) :: info
!
integer(psb_ipk_) :: err_act
character(len=20) :: name='amg_z_ainv_solver_setr'
call psb_erractionsave(err_act)
info = psb_success_
select case(what)
case(amg_sub_iluthrs_)
sv%thresh = val
case default
!!$ write(0,*) name,': Error: invalid WHAT'
!!$ info = -2
!!$ goto 9999
end select
call psb_erractionrestore(err_act)
return
9999 call psb_error_handler(err_act)
return
end subroutine amg_z_ainv_solver_setr

@ -0,0 +1,153 @@
!
!
! AMG-AINV: Approximate Inverse plugin for
! AMG4PSBLAS version 1.0
!
! (C) Copyright 2020
!
! Salvatore Filippone University of Rome Tor Vergata
!
! 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 AMG4PSBLAS 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 AMG4PSBLAS 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.
!
!
subroutine amg_z_base_ainv_solver_apply(alpha,sv,x,beta,y,desc_data,&
& trans,work,info,init,initu)
use psb_base_mod
use amg_z_base_ainv_mod, amg_protect_name => amg_z_base_ainv_solver_apply
implicit none
type(psb_desc_type), intent(in) :: desc_data
class(amg_z_base_ainv_solver_type), intent(inout) :: sv
complex(psb_dpk_),intent(inout) :: x(:)
complex(psb_dpk_),intent(inout) :: y(:)
complex(psb_dpk_),intent(in) :: alpha,beta
character(len=1),intent(in) :: trans
complex(psb_dpk_),target, intent(inout) :: work(:)
integer(psb_ipk_), intent(out) :: info
character, intent(in), optional :: init
complex(psb_dpk_),intent(inout), optional :: initu(:)
!
integer(psb_ipk_) :: n_row,n_col
complex(psb_dpk_), pointer :: ww(:), aux(:), tx(:),ty(:)
integer(psb_ipk_) :: np,me,i, err_act
type(psb_ctxt_type) :: ctxt
character :: trans_
character(len=20) :: name='d_base_ainv_solver_apply'
call psb_erractionsave(err_act)
info = psb_success_
trans_ = psb_toupper(trans)
select case(trans_)
case('N')
case('T','C')
case default
call psb_errpush(psb_err_iarg_invalid_i_,name)
goto 9999
end select
!
! For non-iterative solvers, init and initu are ignored.
!
n_row = psb_cd_get_local_rows(desc_data)
n_col = psb_cd_get_local_cols(desc_data)
if (n_col <= size(work)) then
ww => work(1:n_col)
if ((4*n_col+n_col) <= size(work)) then
aux => work(n_col+1:)
else
allocate(aux(4*n_col),stat=info)
if (info /= psb_success_) then
info=psb_err_alloc_request_
call psb_errpush(info,name,i_err=(/4*n_col/),&
& a_err='real(psb_dpk_)')
goto 9999
end if
endif
else
allocate(ww(n_col),aux(4*n_col),stat=info)
if (info /= psb_success_) then
info=psb_err_alloc_request_
call psb_errpush(info,name,i_err=(/5*n_col/),&
& a_err='real(psb_dpk_)')
goto 9999
end if
endif
select case(trans_)
case('N')
call psb_spmm(zone,sv%w,x,zzero,ww,desc_data,info,&
& trans=trans_,work=aux,doswap=.false.)
ww(1:n_row) = ww(1:n_row) * sv%d(1:n_row)
if (info == psb_success_) &
& call psb_spmm(alpha,sv%z,ww,beta,y,desc_data,info,&
& trans=trans_,work=aux,doswap=.false.)
case('T','C')
call psb_spmm(zone,sv%z,x,zzero,ww,desc_data,info,&
& trans=trans_,work=aux,doswap=.false.)
ww(1:n_row) = ww(1:n_row) * sv%d(1:n_row)
if (info == psb_success_) &
& call psb_spmm(alpha,sv%w,ww,beta,y,desc_data,info,&
& trans=trans_,work=aux,doswap=.false.)
case default
call psb_errpush(psb_err_internal_error_,name,&
& a_err='Invalid TRANS in ainv subsolve')
goto 9999
end select
if (info /= psb_success_) then
call psb_errpush(psb_err_internal_error_,name,&
& a_err='Error in subsolve')
goto 9999
endif
if (n_col <= size(work)) then
if ((4*n_col+n_col) <= size(work)) then
else
deallocate(aux,stat=info)
endif
else
deallocate(ww,aux,stat=info)
endif
if (info /= psb_success_) then
call psb_errpush(psb_err_internal_error_,name,&
& a_err='Deallocate')
goto 9999
endif
call psb_erractionrestore(err_act)
return
9999 call psb_error_handler(err_act)
return
end subroutine amg_z_base_ainv_solver_apply

@ -0,0 +1,167 @@
!
!
! AMG-AINV: Approximate Inverse plugin for
! AMG4PSBLAS version 1.0
!
! (C) Copyright 2020
!
! Salvatore Filippone University of Rome Tor Vergata
!
! 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 AMG4PSBLAS 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 AMG4PSBLAS 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.
!
!
subroutine amg_z_base_ainv_solver_apply_vect(alpha,sv,x,beta,y,desc_data,&
& trans,work,wv,info,init,initu)
use psb_base_mod
use amg_z_base_ainv_mod, amg_protect_name => amg_z_base_ainv_solver_apply_vect
implicit none
type(psb_desc_type), intent(in) :: desc_data
class(amg_z_base_ainv_solver_type), intent(inout) :: sv
type(psb_z_vect_type), intent(inout) :: x
type(psb_z_vect_type), intent(inout) :: y
complex(psb_dpk_), intent(in) :: alpha,beta
character(len=1), intent(in) :: trans
complex(psb_dpk_),target, intent(inout) :: work(:)
type(psb_z_vect_type),intent(inout) :: wv(:)
integer(psb_ipk_), intent(out) :: info
character, intent(in), optional :: init
type(psb_z_vect_type),intent(inout), optional :: initu
!
integer(psb_ipk_) :: n_row,n_col
complex(psb_dpk_), pointer :: ww(:), aux(:)
type(psb_z_vect_type) :: tx,ty
integer(psb_ipk_) :: np,me,i, err_act
type(psb_ctxt_type) :: ctxt
character :: trans_
character(len=20) :: name='d_base_ainv_solver_apply'
call psb_erractionsave(err_act)
info = psb_success_
trans_ = psb_toupper(trans)
select case(trans_)
case('N')
case('T','C')
case default
call psb_errpush(psb_err_iarg_invalid_i_,name)
goto 9999
end select
!
! For non-iterative solvers, init and initu are ignored.
!
n_row = psb_cd_get_local_rows(desc_data)
n_col = psb_cd_get_local_cols(desc_data)
if (n_col <= size(work)) then
ww => work(1:n_col)
if ((4*n_col+n_col) <= size(work)) then
aux => work(n_col+1:)
else
allocate(aux(4*n_col),stat=info)
if (info /= psb_success_) then
info=psb_err_alloc_request_
call psb_errpush(info,name,i_err=(/4*n_col/),&
& a_err='real(psb_dpk_)')
goto 9999
end if
endif
else
allocate(ww(n_col),aux(4*n_col),stat=info)
if (info /= psb_success_) then
info=psb_err_alloc_request_
call psb_errpush(info,name,i_err=(/5*n_col/),&
& a_err='real(psb_dpk_)')
goto 9999
end if
endif
if (size(wv) < 2) then
info = psb_err_internal_error_
call psb_errpush(info,name,&
& a_err='invalid wv size')
goto 9999
end if
associate(tx => wv(1), ty => wv(2))
select case(trans_)
case('N')
call psb_spmm(zone,sv%w,x,zzero,tx,desc_data,info,&
& trans=trans_,work=aux,doswap=.false.)
if (info == psb_success_) call ty%mlt(zone,sv%dv,tx,zzero,info)
if (info == psb_success_) &
& call psb_spmm(alpha,sv%z,ty,beta,y,desc_data,info,&
& trans=trans_,work=aux,doswap=.false.)
case('T','C')
call psb_spmm(zone,sv%z,x,zzero,tx,desc_data,info,&
& trans=trans_,work=aux,doswap=.false.)
if (info == psb_success_) call ty%mlt(zone,sv%dv,tx,zzero,info)
if (info == psb_success_) &
& call psb_spmm(alpha,sv%w,ty,beta,y,desc_data,info,&
& trans=trans_,work=aux,doswap=.false.)
case default
call psb_errpush(psb_err_internal_error_,name,&
& a_err='Invalid TRANS in ainv subsolve')
goto 9999
end select
if (info /= psb_success_) then
call psb_errpush(psb_err_internal_error_,name,&
& a_err='Error in subsolve')
goto 9999
endif
end associate
if (n_col <= size(work)) then
if ((4*n_col+n_col) <= size(work)) then
else
deallocate(aux,stat=info)
endif
else
deallocate(ww,aux,stat=info)
endif
if (info /= psb_success_) then
call psb_errpush(psb_err_internal_error_,name,&
& a_err='Deallocate')
goto 9999
endif
call psb_erractionrestore(err_act)
return
9999 call psb_error_handler(err_act)
return
end subroutine amg_z_base_ainv_solver_apply_vect

@ -0,0 +1,63 @@
!
!
! AMG-AINV: Approximate Inverse plugin for
! AMG4PSBLAS version 1.0
!
! (C) Copyright 2020
!
! Salvatore Filippone University of Rome Tor Vergata
!
! 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 AMG4PSBLAS 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 AMG4PSBLAS 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.
!
!
subroutine amg_z_base_ainv_solver_cnv(sv,info,amold,vmold,imold)
use psb_base_mod
use amg_z_base_ainv_mod, amg_protect_name => amg_z_base_ainv_solver_cnv
Implicit None
! Arguments
class(amg_z_base_ainv_solver_type), intent(inout) :: sv
integer(psb_ipk_), intent(out) :: info
class(psb_z_base_sparse_mat), intent(in), optional :: amold
class(psb_z_base_vect_type), intent(in), optional :: vmold
class(psb_i_base_vect_type), intent(in), optional :: imold
!local
integer(psb_ipk_) :: i, j, il1, iln, lname, lev
integer(psb_ipk_) :: iam, np
type(psb_ctxt_type) :: ctxt
character(len=80) :: prefix_
character(len=120) :: fname ! len should be at least 20 more than
logical :: solver_
! len of prefix_
info = 0
if (present(amold)) then
call sv%w%cscnv(info,mold=amold)
call sv%z%cscnv(info,mold=amold)
end if
call sv%dv%cnv(mold=vmold)
end subroutine amg_z_base_ainv_solver_cnv

@ -0,0 +1,93 @@
!
!
! AMG-AINV: Approximate Inverse plugin for
! AMG4PSBLAS version 1.0
!
! (C) Copyright 2020
!
! Salvatore Filippone University of Rome Tor Vergata
!
! 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 AMG4PSBLAS 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 AMG4PSBLAS 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.
!
!
subroutine amg_z_base_ainv_solver_dmp(sv,desc,level,info,prefix,head,solver,global_num)
use psb_base_mod
use amg_z_base_ainv_mod, amg_protect_name => amg_z_base_ainv_solver_dmp
implicit none
class(amg_z_base_ainv_solver_type), intent(in) :: sv
type(psb_desc_type), intent(in) :: desc
integer(psb_ipk_), intent(in) :: level
integer(psb_ipk_), intent(out) :: info
character(len=*), intent(in), optional :: prefix, head
logical, optional, intent(in) :: solver, global_num
!
integer(psb_ipk_) :: i, j, il1, iln, lname, lev
integer(psb_ipk_) :: iam, np
type(psb_ctxt_type) :: ctxt
character(len=80) :: prefix_
character(len=120) :: fname ! len should be at least 20 more than
logical :: solver_, global_num_
! len of prefix_
info = 0
if (present(prefix)) then
prefix_ = trim(prefix(1:min(len(prefix),len(prefix_))))
else
prefix_ = "dump_ainv_d"
end if
ctxt = desc%get_context()
call psb_info(ctxt,iam,np)
if (present(solver)) then
solver_ = solver
else
solver_ = .false.
end if
if (present(global_num)) then
global_num_ = global_num
else
global_num_ = .false.
end if
lname = len_trim(prefix_)
fname = trim(prefix_)
write(fname(lname+1:lname+5),'(a,i3.3)') '_p',iam
lname = lname + 5
if (solver_) then
write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_wmat.mtx'
if (sv%w%is_asb()) &
& call sv%w%print(fname,head=head)
write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_diag.mtx'
if (allocated(sv%d)) &
& call psb_geprt(fname,sv%d,head=head)
write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_zmat.mtx'
if (sv%z%is_asb()) &
& call sv%z%print(fname,head=head)
end if
end subroutine amg_z_base_ainv_solver_dmp

@ -0,0 +1,70 @@
!
!
! AMG-AINV: Approximate Inverse plugin for
! AMG4PSBLAS version 1.0
!
! (C) Copyright 2020
!
! Salvatore Filippone University of Rome Tor Vergata
!
! 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 AMG4PSBLAS 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 AMG4PSBLAS 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.
!
!
subroutine amg_z_base_ainv_solver_free(sv,info)
use psb_base_mod
use amg_z_base_ainv_mod, amg_protect_name => amg_z_base_ainv_solver_free
Implicit None
! Arguments
class(amg_z_base_ainv_solver_type), intent(inout) :: sv
integer(psb_ipk_), intent(out) :: info
!
integer(psb_ipk_) :: err_act
character(len=20) :: name='amg_z_base_ainv_solver_free'
call psb_erractionsave(err_act)
info = psb_success_
call sv%clear_data(info)
if (allocated(sv%d)) then
deallocate(sv%d,stat=info)
if (info /= psb_success_) then
info = psb_err_alloc_dealloc_
call psb_errpush(info,name)
goto 9999
end if
end if
call sv%w%free()
call sv%z%free()
call sv%dv%free(info)
call psb_erractionrestore(err_act)
return
9999 call psb_error_handler(err_act)
return
end subroutine amg_z_base_ainv_solver_free

@ -0,0 +1,81 @@
!
!
! AMG-AINV: Approximate Inverse plugin for
! AMG4PSBLAS version 1.0
!
! (C) Copyright 2020
!
! Salvatore Filippone University of Rome Tor Vergata
!
! 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 AMG4PSBLAS 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 AMG4PSBLAS 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.
!
!
subroutine amg_z_base_ainv_update_a(sv,x,desc_data,info)
use amg_z_base_ainv_mod, amg_protect_name => amg_z_base_ainv_update_a
use psb_base_mod
implicit none
type(psb_desc_type), intent(in) :: desc_data
class(amg_z_base_ainv_solver_type), intent(inout) :: sv
complex(psb_dpk_),intent(in) :: x(:)
integer(psb_ipk_), intent(out) :: info
! Local variables
complex(psb_dpk_), allocatable :: dd(:), ee(:)
integer(psb_ipk_) :: nrows, ncols, i, j, k, nzr, nzc, ir, ic
type(psb_z_csc_sparse_mat) :: ac
type(psb_z_csr_sparse_mat) :: ar
dd = sv%dv%get_vect()
if (size(x)<size(dd)) then
write(0,*) 'Wrong size in update',size(x),size(dd)
info = -1
return
end if
ee = x(1:size(dd))
call sv%z%cp_to(ac)
call sv%w%cp_to(ar)
! Compute diag(W ee Z)
! First ee Z
call ac%scal(ee,info,side='L')
! Then diag(W (ee Z))
do i=1,ar%get_nrows()
ir = ar%irp(i); nzr = ar%irp(i+1)-ar%irp(i)
ic = ac%icp(i); nzc = ac%icp(i+1)-ac%icp(i)
ee(i) = psb_spdot_srtd(&
& nzr,ar%ja(ir:ir+nzr-1),ar%val(ir:ir+nzr-1),&
& nzc,ac%ia(ic:ic+nzc-1),ac%val(ic:ic+nzc-1))
end do
! Now invert diagonal
dd = done/dd
dd = dd + ee
dd = done/dd
sv%d = dd
call sv%dv%bld(dd,mold=sv%dv%v)
end subroutine amg_z_base_ainv_update_a
Loading…
Cancel
Save