|
|
|
@ -161,7 +161,7 @@ subroutine psb_c_bjac_apply_vect(alpha,prec,x,beta,y,desc_data,info,trans,work)
|
|
|
|
|
associate (wv => prec%wrk(1), wv1 => prec%wrk(2))
|
|
|
|
|
|
|
|
|
|
select case(prec%iprcparm(psb_f_type_))
|
|
|
|
|
case(psb_f_ilu_n_)
|
|
|
|
|
case(psb_f_ilu_n_,psb_f_ilu_k_,psb_f_ilu_t_)
|
|
|
|
|
|
|
|
|
|
select case(trans_)
|
|
|
|
|
case('N')
|
|
|
|
@ -314,7 +314,7 @@ subroutine psb_c_bjac_apply(alpha,prec,x,beta,y,desc_data,info,trans,work)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
select case(prec%iprcparm(psb_f_type_))
|
|
|
|
|
case(psb_f_ilu_n_)
|
|
|
|
|
case(psb_f_ilu_n_,psb_f_ilu_k_,psb_f_ilu_t_)
|
|
|
|
|
|
|
|
|
|
select case(trans_)
|
|
|
|
|
case('N')
|
|
|
|
@ -389,6 +389,7 @@ subroutine psb_c_bjac_precinit(prec,info)
|
|
|
|
|
|
|
|
|
|
info = psb_success_
|
|
|
|
|
call psb_realloc(psb_ifpsz,prec%iprcparm,info)
|
|
|
|
|
call psb_realloc(psb_rfpsz,prec%rprcparm,info)
|
|
|
|
|
if (info /= psb_success_) then
|
|
|
|
|
info = psb_err_alloc_dealloc_
|
|
|
|
|
call psb_Errpush(info,name)
|
|
|
|
@ -399,6 +400,11 @@ subroutine psb_c_bjac_precinit(prec,info)
|
|
|
|
|
prec%iprcparm(psb_p_type_) = psb_bjac_
|
|
|
|
|
prec%iprcparm(psb_f_type_) = psb_f_ilu_n_
|
|
|
|
|
prec%iprcparm(psb_ilu_fill_in_) = 0
|
|
|
|
|
prec%iprcparm(psb_ilu_ialg_) = psb_ilu_n_
|
|
|
|
|
prec%iprcparm(psb_ilu_scale_) = psb_ilu_scale_none_
|
|
|
|
|
|
|
|
|
|
prec%rprcparm(:) = 0
|
|
|
|
|
prec%rprcparm(psb_fact_eps_) = 1E-1_psb_spk_
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
call psb_erractionrestore(err_act)
|
|
|
|
@ -413,7 +419,7 @@ end subroutine psb_c_bjac_precinit
|
|
|
|
|
subroutine psb_c_bjac_precbld(a,desc_a,prec,info,amold,vmold,imold)
|
|
|
|
|
|
|
|
|
|
use psb_base_mod
|
|
|
|
|
use psb_prec_mod, only : psb_ilu_fct
|
|
|
|
|
use psb_c_ilu_fact_mod
|
|
|
|
|
use psb_c_bjacprec, psb_protect_name => psb_c_bjac_precbld
|
|
|
|
|
Implicit None
|
|
|
|
|
|
|
|
|
@ -426,11 +432,12 @@ subroutine psb_c_bjac_precbld(a,desc_a,prec,info,amold,vmold,imold)
|
|
|
|
|
class(psb_i_base_vect_type), intent(in), optional :: imold
|
|
|
|
|
|
|
|
|
|
! .. Local Scalars ..
|
|
|
|
|
integer(psb_ipk_) :: i, m
|
|
|
|
|
integer(psb_ipk_) :: i, m, ialg, fill_in, iscale
|
|
|
|
|
integer(psb_ipk_) :: ierr(5)
|
|
|
|
|
character :: trans, unitd
|
|
|
|
|
type(psb_c_csr_sparse_mat), allocatable :: lf, uf
|
|
|
|
|
type(psb_cspmat_type), allocatable :: lf, uf
|
|
|
|
|
complex(psb_spk_), allocatable :: dd(:)
|
|
|
|
|
real(psb_spk_) :: fact_eps
|
|
|
|
|
integer(psb_ipk_) :: nztota, err_act, n_row, nrow_a,n_col, nhalo
|
|
|
|
|
integer(psb_ipk_) :: ictxt,np,me
|
|
|
|
|
character(len=20) :: name='c_bjac_precbld'
|
|
|
|
@ -458,9 +465,204 @@ subroutine psb_c_bjac_precbld(a,desc_a,prec,info,amold,vmold,imold)
|
|
|
|
|
trans = 'N'
|
|
|
|
|
unitd = 'U'
|
|
|
|
|
|
|
|
|
|
! We check if all the information contained in the preconditioner structure
|
|
|
|
|
! are meaningful, otherwise we give an error and get out of the build
|
|
|
|
|
! procedure
|
|
|
|
|
ialg = prec%iprcparm(psb_ilu_ialg_)
|
|
|
|
|
if ((ialg == psb_ilu_n_).or.(ialg == psb_milu_n_).or.(ialg == psb_ilu_t_)) then
|
|
|
|
|
! Do nothing: admissible request
|
|
|
|
|
else
|
|
|
|
|
info=psb_err_from_subroutine_
|
|
|
|
|
ch_err='psb_ilu_ialg_'
|
|
|
|
|
call psb_errpush(info,name,a_err=ch_err)
|
|
|
|
|
goto 9999
|
|
|
|
|
end if
|
|
|
|
|
iscale = prec%iprcparm(psb_ilu_scale_)
|
|
|
|
|
if ((iscale == psb_ilu_scale_none_).or.&
|
|
|
|
|
(iscale == psb_ilu_scale_maxval_).or.&
|
|
|
|
|
(iscale == psb_ilu_scale_diag_).or.&
|
|
|
|
|
(iscale == psb_ilu_scale_arwsum_).or.&
|
|
|
|
|
(iscale == psb_ilu_scale_aclsum_).or.&
|
|
|
|
|
(iscale == psb_ilu_scale_arcsum_)) then
|
|
|
|
|
! Do nothing: admissible request
|
|
|
|
|
else
|
|
|
|
|
info=psb_err_from_subroutine_
|
|
|
|
|
ch_err='psb_ilu_scale_'
|
|
|
|
|
call psb_errpush(info,name,a_err=ch_err)
|
|
|
|
|
goto 9999
|
|
|
|
|
end if
|
|
|
|
|
fact_eps = prec%rprcparm(psb_fact_eps_)
|
|
|
|
|
if(fact_eps > 1 ) then
|
|
|
|
|
info=psb_err_from_subroutine_
|
|
|
|
|
ch_err='psb_fact_eps_'
|
|
|
|
|
call psb_errpush(info,name,a_err=ch_err)
|
|
|
|
|
goto 9999
|
|
|
|
|
end if
|
|
|
|
|
fill_in = prec%iprcparm(psb_ilu_fill_in_)
|
|
|
|
|
if(fill_in < 0) then
|
|
|
|
|
info=psb_err_from_subroutine_
|
|
|
|
|
ch_err='psb_ilu_fill_in_'
|
|
|
|
|
call psb_errpush(info,name,a_err=ch_err)
|
|
|
|
|
goto 9999
|
|
|
|
|
else if (fill_in == 0) then
|
|
|
|
|
! If the requested level of fill is equal to zero, we default to the
|
|
|
|
|
! specialized ILU(0) routine
|
|
|
|
|
prec%iprcparm(psb_f_type_) = psb_f_ilu_n_
|
|
|
|
|
end if
|
|
|
|
|
|
|
|
|
|
! Select on the type of factorization to be used
|
|
|
|
|
select case(prec%iprcparm(psb_f_type_))
|
|
|
|
|
|
|
|
|
|
case(psb_f_ilu_n_)
|
|
|
|
|
! ILU(0) Factorization: the total number of nonzeros of the factorized matrix
|
|
|
|
|
! is equal to the one of the input matrix
|
|
|
|
|
|
|
|
|
|
if (allocated(prec%av)) then
|
|
|
|
|
if (size(prec%av) < psb_bp_ilu_avsz) then
|
|
|
|
|
do i=1,size(prec%av)
|
|
|
|
|
call prec%av(i)%free()
|
|
|
|
|
enddo
|
|
|
|
|
deallocate(prec%av,stat=info)
|
|
|
|
|
endif
|
|
|
|
|
end if
|
|
|
|
|
if (.not.allocated(prec%av)) then
|
|
|
|
|
allocate(prec%av(psb_max_avsz),stat=info)
|
|
|
|
|
if (info /= psb_success_) then
|
|
|
|
|
call psb_errpush(psb_err_alloc_dealloc_,name)
|
|
|
|
|
goto 9999
|
|
|
|
|
end if
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
nrow_a = desc_a%get_local_rows()
|
|
|
|
|
nztota = a%get_nzeros()
|
|
|
|
|
|
|
|
|
|
n_col = desc_a%get_local_cols()
|
|
|
|
|
nhalo = n_col-nrow_a
|
|
|
|
|
n_row = nrow_a
|
|
|
|
|
|
|
|
|
|
allocate(lf,uf,stat=info)
|
|
|
|
|
if (info == psb_success_) call lf%allocate(n_row,n_row,nztota)
|
|
|
|
|
if (info == psb_success_) call uf%allocate(n_row,n_row,nztota)
|
|
|
|
|
|
|
|
|
|
if(info /= psb_success_) then
|
|
|
|
|
info=psb_err_from_subroutine_
|
|
|
|
|
ch_err='psb_sp_all'
|
|
|
|
|
call psb_errpush(info,name,a_err=ch_err)
|
|
|
|
|
goto 9999
|
|
|
|
|
end if
|
|
|
|
|
|
|
|
|
|
allocate(dd(n_row),stat=info)
|
|
|
|
|
if (info == psb_success_) then
|
|
|
|
|
allocate(prec%dv, stat=info)
|
|
|
|
|
if (info == 0) then
|
|
|
|
|
if (present(vmold)) then
|
|
|
|
|
allocate(prec%dv%v,mold=vmold,stat=info)
|
|
|
|
|
else
|
|
|
|
|
allocate(psb_c_base_vect_type :: prec%dv%v,stat=info)
|
|
|
|
|
end if
|
|
|
|
|
end if
|
|
|
|
|
end if
|
|
|
|
|
|
|
|
|
|
if (info /= psb_success_) then
|
|
|
|
|
call psb_errpush(psb_err_from_subroutine_,name,a_err='Allocate')
|
|
|
|
|
goto 9999
|
|
|
|
|
endif
|
|
|
|
|
! This is where we have no renumbering, thus no need
|
|
|
|
|
! call psb_ilu_fct(a,lf,uf,dd,info)
|
|
|
|
|
call psb_ilu0_fact(ialg,a,lf,uf,dd,info)
|
|
|
|
|
|
|
|
|
|
if(info == psb_success_) then
|
|
|
|
|
call prec%av(psb_l_pr_)%mv_from(lf%a)
|
|
|
|
|
call prec%av(psb_u_pr_)%mv_from(uf%a)
|
|
|
|
|
call prec%av(psb_l_pr_)%set_asb()
|
|
|
|
|
call prec%av(psb_u_pr_)%set_asb()
|
|
|
|
|
call prec%av(psb_l_pr_)%trim()
|
|
|
|
|
call prec%av(psb_u_pr_)%trim()
|
|
|
|
|
call prec%dv%bld(dd)
|
|
|
|
|
! call move_alloc(dd,prec%d)
|
|
|
|
|
else
|
|
|
|
|
info=psb_err_from_subroutine_
|
|
|
|
|
ch_err='psb_ilu0_fact'
|
|
|
|
|
call psb_errpush(info,name,a_err=ch_err)
|
|
|
|
|
goto 9999
|
|
|
|
|
end if
|
|
|
|
|
|
|
|
|
|
case(psb_f_ilu_k_)
|
|
|
|
|
! ILU(N) Incomplete LU-factorization with N levels of fill-in. Depending on
|
|
|
|
|
! the type of the variant of the algorithm the may be forgotten or added to
|
|
|
|
|
! the diagonal (MILU)
|
|
|
|
|
|
|
|
|
|
if (allocated(prec%av)) then
|
|
|
|
|
if (size(prec%av) < psb_bp_ilu_avsz) then
|
|
|
|
|
do i=1,size(prec%av)
|
|
|
|
|
call prec%av(i)%free()
|
|
|
|
|
enddo
|
|
|
|
|
deallocate(prec%av,stat=info)
|
|
|
|
|
endif
|
|
|
|
|
end if
|
|
|
|
|
if (.not.allocated(prec%av)) then
|
|
|
|
|
allocate(prec%av(psb_max_avsz),stat=info)
|
|
|
|
|
if (info /= psb_success_) then
|
|
|
|
|
call psb_errpush(psb_err_alloc_dealloc_,name)
|
|
|
|
|
goto 9999
|
|
|
|
|
end if
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
nrow_a = desc_a%get_local_rows()
|
|
|
|
|
nztota = a%get_nzeros()
|
|
|
|
|
|
|
|
|
|
n_col = desc_a%get_local_cols()
|
|
|
|
|
nhalo = n_col-nrow_a
|
|
|
|
|
n_row = nrow_a
|
|
|
|
|
|
|
|
|
|
allocate(lf,uf,stat=info)
|
|
|
|
|
if (info == psb_success_) call lf%allocate(n_row,n_row,nztota)
|
|
|
|
|
if (info == psb_success_) call uf%allocate(n_row,n_row,nztota)
|
|
|
|
|
|
|
|
|
|
if(info /= psb_success_) then
|
|
|
|
|
info=psb_err_from_subroutine_
|
|
|
|
|
ch_err='psb_sp_all'
|
|
|
|
|
call psb_errpush(info,name,a_err=ch_err)
|
|
|
|
|
goto 9999
|
|
|
|
|
end if
|
|
|
|
|
|
|
|
|
|
allocate(dd(n_row),stat=info)
|
|
|
|
|
if (info == psb_success_) then
|
|
|
|
|
allocate(prec%dv, stat=info)
|
|
|
|
|
if (info == 0) then
|
|
|
|
|
if (present(vmold)) then
|
|
|
|
|
allocate(prec%dv%v,mold=vmold,stat=info)
|
|
|
|
|
else
|
|
|
|
|
allocate(psb_c_base_vect_type :: prec%dv%v,stat=info)
|
|
|
|
|
end if
|
|
|
|
|
end if
|
|
|
|
|
end if
|
|
|
|
|
|
|
|
|
|
if (info /= psb_success_) then
|
|
|
|
|
call psb_errpush(psb_err_from_subroutine_,name,a_err='Allocate')
|
|
|
|
|
goto 9999
|
|
|
|
|
endif
|
|
|
|
|
! This is where we have no renumbering, thus no need
|
|
|
|
|
call psb_iluk_fact(fill_in,ialg,a,lf,uf,dd,info)
|
|
|
|
|
|
|
|
|
|
if(info == psb_success_) then
|
|
|
|
|
call prec%av(psb_l_pr_)%mv_from(lf%a)
|
|
|
|
|
call prec%av(psb_u_pr_)%mv_from(uf%a)
|
|
|
|
|
call prec%av(psb_l_pr_)%set_asb()
|
|
|
|
|
call prec%av(psb_u_pr_)%set_asb()
|
|
|
|
|
call prec%av(psb_l_pr_)%trim()
|
|
|
|
|
call prec%av(psb_u_pr_)%trim()
|
|
|
|
|
call prec%dv%bld(dd)
|
|
|
|
|
! call move_alloc(dd,prec%d)
|
|
|
|
|
else
|
|
|
|
|
info=psb_err_from_subroutine_
|
|
|
|
|
ch_err='psb_iluk_fact'
|
|
|
|
|
call psb_errpush(info,name,a_err=ch_err)
|
|
|
|
|
goto 9999
|
|
|
|
|
end if
|
|
|
|
|
|
|
|
|
|
case(psb_f_ilu_t_)
|
|
|
|
|
! ILU(N,E) Incomplete LU factorization with thresholding and level of fill
|
|
|
|
|
|
|
|
|
|
if (allocated(prec%av)) then
|
|
|
|
|
if (size(prec%av) < psb_bp_ilu_avsz) then
|
|
|
|
@ -513,11 +715,11 @@ subroutine psb_c_bjac_precbld(a,desc_a,prec,info,amold,vmold,imold)
|
|
|
|
|
goto 9999
|
|
|
|
|
endif
|
|
|
|
|
! This is where we have no renumbering, thus no need
|
|
|
|
|
call psb_ilu_fct(a,lf,uf,dd,info)
|
|
|
|
|
call psb_ilut_fact(fill_in,fact_eps,a,lf,uf,dd,info,iscale=iscale)
|
|
|
|
|
|
|
|
|
|
if(info == psb_success_) then
|
|
|
|
|
call prec%av(psb_l_pr_)%mv_from(lf)
|
|
|
|
|
call prec%av(psb_u_pr_)%mv_from(uf)
|
|
|
|
|
call prec%av(psb_l_pr_)%mv_from(lf%a)
|
|
|
|
|
call prec%av(psb_u_pr_)%mv_from(uf%a)
|
|
|
|
|
call prec%av(psb_l_pr_)%set_asb()
|
|
|
|
|
call prec%av(psb_u_pr_)%set_asb()
|
|
|
|
|
call prec%av(psb_l_pr_)%trim()
|
|
|
|
@ -526,7 +728,7 @@ subroutine psb_c_bjac_precbld(a,desc_a,prec,info,amold,vmold,imold)
|
|
|
|
|
! call move_alloc(dd,prec%d)
|
|
|
|
|
else
|
|
|
|
|
info=psb_err_from_subroutine_
|
|
|
|
|
ch_err='psb_ilu_fct'
|
|
|
|
|
ch_err='psb_ilut_fact'
|
|
|
|
|
call psb_errpush(info,name,a_err=ch_err)
|
|
|
|
|
goto 9999
|
|
|
|
|
end if
|
|
|
|
@ -590,7 +792,8 @@ subroutine psb_c_bjac_precseti(prec,what,val,info)
|
|
|
|
|
|
|
|
|
|
case (psb_ilu_fill_in_)
|
|
|
|
|
if ((prec%iprcparm(psb_p_type_) /= psb_bjac_).or.&
|
|
|
|
|
& (prec%iprcparm(psb_f_type_) /= psb_f_ilu_n_)) then
|
|
|
|
|
& ((prec%iprcparm(psb_f_type_) /= psb_f_ilu_n_).or.&
|
|
|
|
|
& (prec%iprcparm(psb_f_type_) /= psb_f_ilu_t_))) then
|
|
|
|
|
write(psb_err_unit,*) 'WHAT is invalid for current preconditioner ',&
|
|
|
|
|
& prec%iprcparm(psb_p_type_),&
|
|
|
|
|
& 'ignoring user specification'
|
|
|
|
@ -598,6 +801,24 @@ subroutine psb_c_bjac_precseti(prec,what,val,info)
|
|
|
|
|
endif
|
|
|
|
|
prec%iprcparm(psb_ilu_fill_in_) = val
|
|
|
|
|
|
|
|
|
|
case (psb_ilu_ialg_)
|
|
|
|
|
if (prec%iprcparm(psb_p_type_) /= psb_bjac_) then
|
|
|
|
|
write(psb_err_unit,*) 'WHAT is invalid for current preconditioner ',&
|
|
|
|
|
& prec%iprcparm(psb_p_type_),&
|
|
|
|
|
& 'ignoring user specification'
|
|
|
|
|
return
|
|
|
|
|
endif
|
|
|
|
|
prec%iprcparm(psb_ilu_ialg_) = val
|
|
|
|
|
|
|
|
|
|
case (psb_ilu_scale_)
|
|
|
|
|
if (prec%iprcparm(psb_p_type_) /= psb_bjac_) then
|
|
|
|
|
write(psb_err_unit,*) 'WHAT is invalid for current preconditioner ',&
|
|
|
|
|
& prec%iprcparm(psb_p_type_),&
|
|
|
|
|
& 'ignoring user specification'
|
|
|
|
|
return
|
|
|
|
|
endif
|
|
|
|
|
prec%iprcparm(psb_ilu_scale_) = val
|
|
|
|
|
|
|
|
|
|
case default
|
|
|
|
|
write(psb_err_unit,*) 'WHAT is invalid, ignoring user specification'
|
|
|
|
|
|
|
|
|
@ -609,3 +830,57 @@ subroutine psb_c_bjac_precseti(prec,what,val,info)
|
|
|
|
|
9999 call psb_error_handler(err_act)
|
|
|
|
|
return
|
|
|
|
|
end subroutine psb_c_bjac_precseti
|
|
|
|
|
|
|
|
|
|
subroutine psb_c_bjac_precsetr(prec,what,val,info)
|
|
|
|
|
|
|
|
|
|
use psb_base_mod
|
|
|
|
|
use psb_c_bjacprec, psb_protect_name => psb_c_bjac_precsetr
|
|
|
|
|
Implicit None
|
|
|
|
|
|
|
|
|
|
class(psb_c_bjac_prec_type),intent(inout) :: prec
|
|
|
|
|
integer(psb_ipk_), intent(in) :: what
|
|
|
|
|
real(psb_spk_), intent(in) :: val
|
|
|
|
|
integer(psb_ipk_), intent(out) :: info
|
|
|
|
|
integer(psb_ipk_) :: err_act, nrow
|
|
|
|
|
character(len=20) :: name='c_bjac_precset'
|
|
|
|
|
|
|
|
|
|
call psb_erractionsave(err_act)
|
|
|
|
|
|
|
|
|
|
info = psb_success_
|
|
|
|
|
if (.not.allocated(prec%iprcparm)) then
|
|
|
|
|
info = 1124
|
|
|
|
|
call psb_errpush(info,name,a_err="preconditioner")
|
|
|
|
|
goto 9999
|
|
|
|
|
end if
|
|
|
|
|
|
|
|
|
|
select case(what)
|
|
|
|
|
case (psb_f_type_)
|
|
|
|
|
if (prec%iprcparm(psb_p_type_) /= psb_bjac_) then
|
|
|
|
|
write(psb_err_unit,*) 'WHAT is invalid for current preconditioner ',&
|
|
|
|
|
& prec%iprcparm(psb_p_type_),&
|
|
|
|
|
& 'ignoring user specification'
|
|
|
|
|
return
|
|
|
|
|
endif
|
|
|
|
|
prec%iprcparm(psb_f_type_) = val
|
|
|
|
|
|
|
|
|
|
case (psb_fact_eps_)
|
|
|
|
|
if ((prec%iprcparm(psb_p_type_) /= psb_bjac_).or.&
|
|
|
|
|
& (prec%iprcparm(psb_f_type_) /= psb_f_ilu_n_)) then
|
|
|
|
|
write(psb_err_unit,*) 'WHAT is invalid for current preconditioner ',&
|
|
|
|
|
& prec%iprcparm(psb_p_type_),&
|
|
|
|
|
& 'ignoring user specification'
|
|
|
|
|
return
|
|
|
|
|
endif
|
|
|
|
|
prec%rprcparm(psb_fact_eps_) = val
|
|
|
|
|
|
|
|
|
|
case default
|
|
|
|
|
write(psb_err_unit,*) 'WHAT is invalid, ignoring user specification'
|
|
|
|
|
|
|
|
|
|
end select
|
|
|
|
|
|
|
|
|
|
call psb_erractionrestore(err_act)
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
9999 call psb_error_handler(err_act)
|
|
|
|
|
return
|
|
|
|
|
end subroutine psb_c_bjac_precsetr
|
|
|
|
|