|
|
|
@ -93,7 +93,7 @@
|
|
|
|
|
! info - integer, output.
|
|
|
|
|
! Error code.
|
|
|
|
|
!
|
|
|
|
|
subroutine mld_caggrmat_smth_asb(a,desc_a,ilaggr,nlaggr,p,info)
|
|
|
|
|
subroutine mld_caggrmat_smth_asb(a,desc_a,ilaggr,nlaggr,parms,ac,op_prol,op_restr,info)
|
|
|
|
|
use psb_base_mod
|
|
|
|
|
use mld_c_inner_mod, mld_protect_name => mld_caggrmat_smth_asb
|
|
|
|
|
|
|
|
|
@ -103,9 +103,9 @@ subroutine mld_caggrmat_smth_asb(a,desc_a,ilaggr,nlaggr,p,info)
|
|
|
|
|
type(psb_cspmat_type), intent(in) :: a
|
|
|
|
|
type(psb_desc_type), intent(in) :: desc_a
|
|
|
|
|
integer, intent(inout) :: ilaggr(:), nlaggr(:)
|
|
|
|
|
type(mld_c_onelev_type), intent(inout), target :: p
|
|
|
|
|
type(mld_sml_parms), intent(inout) :: parms
|
|
|
|
|
type(psb_cspmat_type), intent(out) :: ac,op_prol,op_restr
|
|
|
|
|
integer, intent(out) :: info
|
|
|
|
|
type(psb_cspmat_type) :: op_prol, op_restr, b
|
|
|
|
|
|
|
|
|
|
! Local variables
|
|
|
|
|
integer :: nrow, nglob, ncol, ntaggr, ip, ndx,&
|
|
|
|
@ -113,7 +113,7 @@ subroutine mld_caggrmat_smth_asb(a,desc_a,ilaggr,nlaggr,p,info)
|
|
|
|
|
integer ::ictxt, np, me, err_act
|
|
|
|
|
character(len=20) :: name
|
|
|
|
|
type(psb_cspmat_type) :: am3, am4
|
|
|
|
|
type(psb_c_coo_sparse_mat) :: acoo, acoof, bcoo
|
|
|
|
|
type(psb_c_coo_sparse_mat) :: tmpcoo
|
|
|
|
|
type(psb_c_csr_sparse_mat) :: acsr1, acsr2, acsr3, acsrf, ptilde
|
|
|
|
|
complex(psb_spk_), allocatable :: adiag(:)
|
|
|
|
|
integer(psb_ipk_) :: ierr(5)
|
|
|
|
@ -138,14 +138,14 @@ subroutine mld_caggrmat_smth_asb(a,desc_a,ilaggr,nlaggr,p,info)
|
|
|
|
|
nrow = desc_a%get_local_rows()
|
|
|
|
|
ncol = desc_a%get_local_cols()
|
|
|
|
|
|
|
|
|
|
theta = p%parms%aggr_thresh
|
|
|
|
|
theta = parms%aggr_thresh
|
|
|
|
|
|
|
|
|
|
naggr = nlaggr(me+1)
|
|
|
|
|
ntaggr = sum(nlaggr)
|
|
|
|
|
|
|
|
|
|
naggrm1 = sum(nlaggr(1:me))
|
|
|
|
|
naggrp1 = sum(nlaggr(1:me+1))
|
|
|
|
|
filter_mat = (p%parms%aggr_filter == mld_filter_mat_)
|
|
|
|
|
filter_mat = (parms%aggr_filter == mld_filter_mat_)
|
|
|
|
|
|
|
|
|
|
ilaggr(1:nrow) = ilaggr(1:nrow) + naggrm1
|
|
|
|
|
call psb_halo(ilaggr,desc_a,info)
|
|
|
|
@ -177,16 +177,16 @@ subroutine mld_caggrmat_smth_asb(a,desc_a,ilaggr,nlaggr,p,info)
|
|
|
|
|
end if
|
|
|
|
|
|
|
|
|
|
! 1. Allocate Ptilde in sparse matrix form
|
|
|
|
|
call acoo%allocate(ncol,ntaggr,ncol)
|
|
|
|
|
call tmpcoo%allocate(ncol,ntaggr,ncol)
|
|
|
|
|
do i=1,ncol
|
|
|
|
|
acoo%val(i) = cone
|
|
|
|
|
acoo%ia(i) = i
|
|
|
|
|
acoo%ja(i) = ilaggr(i)
|
|
|
|
|
tmpcoo%val(i) = cone
|
|
|
|
|
tmpcoo%ia(i) = i
|
|
|
|
|
tmpcoo%ja(i) = ilaggr(i)
|
|
|
|
|
end do
|
|
|
|
|
call acoo%set_nzeros(ncol)
|
|
|
|
|
call acoo%set_dupl(psb_dupl_add_)
|
|
|
|
|
call tmpcoo%set_nzeros(ncol)
|
|
|
|
|
call tmpcoo%set_dupl(psb_dupl_add_)
|
|
|
|
|
|
|
|
|
|
call ptilde%mv_from_coo(acoo,info)
|
|
|
|
|
call ptilde%mv_from_coo(tmpcoo,info)
|
|
|
|
|
if (info == psb_success_) call a%cscnv(acsr3,info,dupl=psb_dupl_add_)
|
|
|
|
|
|
|
|
|
|
if (debug_level >= psb_debug_outer_) &
|
|
|
|
@ -217,19 +217,19 @@ subroutine mld_caggrmat_smth_asb(a,desc_a,ilaggr,nlaggr,p,info)
|
|
|
|
|
end if
|
|
|
|
|
enddo
|
|
|
|
|
! Take out zeroed terms
|
|
|
|
|
call acsrf%mv_to_coo(acoof,info)
|
|
|
|
|
call acsrf%mv_to_coo(tmpcoo,info)
|
|
|
|
|
k = 0
|
|
|
|
|
do j=1,acoof%get_nzeros()
|
|
|
|
|
if ((acoof%val(j) /= czero) .or. (acoof%ia(j) == acoof%ja(j))) then
|
|
|
|
|
do j=1,tmpcoo%get_nzeros()
|
|
|
|
|
if ((tmpcoo%val(j) /= czero) .or. (tmpcoo%ia(j) == tmpcoo%ja(j))) then
|
|
|
|
|
k = k + 1
|
|
|
|
|
acoof%val(k) = acoof%val(j)
|
|
|
|
|
acoof%ia(k) = acoof%ia(j)
|
|
|
|
|
acoof%ja(k) = acoof%ja(j)
|
|
|
|
|
tmpcoo%val(k) = tmpcoo%val(j)
|
|
|
|
|
tmpcoo%ia(k) = tmpcoo%ia(j)
|
|
|
|
|
tmpcoo%ja(k) = tmpcoo%ja(j)
|
|
|
|
|
end if
|
|
|
|
|
end do
|
|
|
|
|
call acoof%set_nzeros(k)
|
|
|
|
|
call acoof%set_dupl(psb_dupl_add_)
|
|
|
|
|
call acsrf%mv_from_coo(acoof,info)
|
|
|
|
|
call tmpcoo%set_nzeros(k)
|
|
|
|
|
call tmpcoo%set_dupl(psb_dupl_add_)
|
|
|
|
|
call acsrf%mv_from_coo(tmpcoo,info)
|
|
|
|
|
end if
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -246,13 +246,13 @@ subroutine mld_caggrmat_smth_asb(a,desc_a,ilaggr,nlaggr,p,info)
|
|
|
|
|
if (info /= psb_success_) goto 9999
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (p%parms%aggr_omega_alg == mld_eig_est_) then
|
|
|
|
|
if (parms%aggr_omega_alg == mld_eig_est_) then
|
|
|
|
|
|
|
|
|
|
if (p%parms%aggr_eig == mld_max_norm_) then
|
|
|
|
|
if (parms%aggr_eig == mld_max_norm_) then
|
|
|
|
|
|
|
|
|
|
anorm = acsr3%csnmi()
|
|
|
|
|
omega = 4.d0/(3.d0*anorm)
|
|
|
|
|
p%parms%aggr_omega_val = omega
|
|
|
|
|
parms%aggr_omega_val = omega
|
|
|
|
|
|
|
|
|
|
else
|
|
|
|
|
info = psb_err_internal_error_
|
|
|
|
@ -260,11 +260,11 @@ subroutine mld_caggrmat_smth_asb(a,desc_a,ilaggr,nlaggr,p,info)
|
|
|
|
|
goto 9999
|
|
|
|
|
end if
|
|
|
|
|
|
|
|
|
|
else if (p%parms%aggr_omega_alg == mld_user_choice_) then
|
|
|
|
|
else if (parms%aggr_omega_alg == mld_user_choice_) then
|
|
|
|
|
|
|
|
|
|
omega = p%parms%aggr_omega_val
|
|
|
|
|
omega = parms%aggr_omega_val
|
|
|
|
|
|
|
|
|
|
else if (p%parms%aggr_omega_alg /= mld_user_choice_) then
|
|
|
|
|
else if (parms%aggr_omega_alg /= mld_user_choice_) then
|
|
|
|
|
info = psb_err_internal_error_
|
|
|
|
|
call psb_errpush(info,name,a_err='invalid mld_aggr_omega_alg_')
|
|
|
|
|
goto 9999
|
|
|
|
@ -369,27 +369,27 @@ subroutine mld_caggrmat_smth_asb(a,desc_a,ilaggr,nlaggr,p,info)
|
|
|
|
|
call psb_numbmm(a,op_prol,am3)
|
|
|
|
|
if (debug_level >= psb_debug_outer_) &
|
|
|
|
|
& write(debug_unit,*) me,' ',trim(name),&
|
|
|
|
|
& 'Done NUMBMM 2',p%parms%aggr_kind, mld_smooth_prol_
|
|
|
|
|
& 'Done NUMBMM 2',parms%aggr_kind, mld_smooth_prol_
|
|
|
|
|
|
|
|
|
|
call op_prol%transp(op_restr)
|
|
|
|
|
call op_restr%mv_to(acoo)
|
|
|
|
|
nzl = acoo%get_nzeros()
|
|
|
|
|
call op_restr%mv_to(tmpcoo)
|
|
|
|
|
nzl = tmpcoo%get_nzeros()
|
|
|
|
|
i=0
|
|
|
|
|
!
|
|
|
|
|
! Now we have to fix this. The only rows of B that are correct
|
|
|
|
|
! are those corresponding to "local" aggregates, i.e. indices in ilaggr(:)
|
|
|
|
|
!
|
|
|
|
|
do k=1, nzl
|
|
|
|
|
if ((naggrm1 < acoo%ia(k)) .and.(acoo%ia(k) <= naggrp1)) then
|
|
|
|
|
if ((naggrm1 < tmpcoo%ia(k)) .and.(tmpcoo%ia(k) <= naggrp1)) then
|
|
|
|
|
i = i+1
|
|
|
|
|
acoo%val(i) = acoo%val(k)
|
|
|
|
|
acoo%ia(i) = acoo%ia(k)
|
|
|
|
|
acoo%ja(i) = acoo%ja(k)
|
|
|
|
|
tmpcoo%val(i) = tmpcoo%val(k)
|
|
|
|
|
tmpcoo%ia(i) = tmpcoo%ia(k)
|
|
|
|
|
tmpcoo%ja(i) = tmpcoo%ja(k)
|
|
|
|
|
end if
|
|
|
|
|
end do
|
|
|
|
|
call acoo%set_nzeros(i)
|
|
|
|
|
call acoo%trim()
|
|
|
|
|
call op_restr%mv_from(acoo)
|
|
|
|
|
call tmpcoo%set_nzeros(i)
|
|
|
|
|
call tmpcoo%trim()
|
|
|
|
|
call op_restr%mv_from(tmpcoo)
|
|
|
|
|
call op_restr%cscnv(info,type='csr',dupl=psb_dupl_add_)
|
|
|
|
|
if (info /= psb_success_) then
|
|
|
|
|
call psb_errpush(psb_err_from_subroutine_,name,a_err='spcnv op_restr')
|
|
|
|
@ -413,113 +413,12 @@ subroutine mld_caggrmat_smth_asb(a,desc_a,ilaggr,nlaggr,p,info)
|
|
|
|
|
if (debug_level >= psb_debug_outer_) &
|
|
|
|
|
& write(debug_unit,*) me,' ',trim(name),&
|
|
|
|
|
& 'starting symbmm 3'
|
|
|
|
|
call psb_symbmm(op_restr,am3,b,info)
|
|
|
|
|
if (info == psb_success_) call psb_numbmm(op_restr,am3,b)
|
|
|
|
|
call psb_symbmm(op_restr,am3,ac,info)
|
|
|
|
|
if (info == psb_success_) call psb_numbmm(op_restr,am3,ac)
|
|
|
|
|
if (info == psb_success_) call am3%free()
|
|
|
|
|
if (info == psb_success_) call b%cscnv(info,type='coo',dupl=psb_dupl_add_)
|
|
|
|
|
if (info == psb_success_) call ac%cscnv(info,type='coo',dupl=psb_dupl_add_)
|
|
|
|
|
if (info /= psb_success_) then
|
|
|
|
|
call psb_errpush(psb_err_internal_error_,name,a_err='Build b = op_restr x am3')
|
|
|
|
|
goto 9999
|
|
|
|
|
end if
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
select case(p%parms%coarse_mat)
|
|
|
|
|
|
|
|
|
|
case(mld_distr_mat_)
|
|
|
|
|
|
|
|
|
|
nzl = b%get_nzeros()
|
|
|
|
|
call b%mv_to(bcoo)
|
|
|
|
|
|
|
|
|
|
if (info == psb_success_) call psb_cdall(ictxt,p%desc_ac,info,nl=nlaggr(me+1))
|
|
|
|
|
if (info == psb_success_) call psb_cdins(nzl,bcoo%ia,bcoo%ja,p%desc_ac,info)
|
|
|
|
|
if (info == psb_success_) call psb_cdasb(p%desc_ac,info)
|
|
|
|
|
if (info == psb_success_) call psb_glob_to_loc(bcoo%ia(1:nzl),p%desc_ac,info,iact='I')
|
|
|
|
|
if (info == psb_success_) call psb_glob_to_loc(bcoo%ja(1:nzl),p%desc_ac,info,iact='I')
|
|
|
|
|
if (info /= psb_success_) then
|
|
|
|
|
call psb_errpush(psb_err_internal_error_,name,&
|
|
|
|
|
& a_err='Creating p%desc_ac and converting ac')
|
|
|
|
|
goto 9999
|
|
|
|
|
end if
|
|
|
|
|
if (debug_level >= psb_debug_outer_) &
|
|
|
|
|
& write(debug_unit,*) me,' ',trim(name),&
|
|
|
|
|
& 'Assembld aux descr. distr.'
|
|
|
|
|
call p%ac%mv_from(bcoo)
|
|
|
|
|
|
|
|
|
|
call p%ac%set_nrows(p%desc_ac%get_local_rows())
|
|
|
|
|
call p%ac%set_ncols(p%desc_ac%get_local_cols())
|
|
|
|
|
call p%ac%set_asb()
|
|
|
|
|
|
|
|
|
|
if (info /= psb_success_) then
|
|
|
|
|
call psb_errpush(psb_err_from_subroutine_,name,a_err='psb_sp_free')
|
|
|
|
|
goto 9999
|
|
|
|
|
end if
|
|
|
|
|
|
|
|
|
|
if (np>1) then
|
|
|
|
|
call op_prol%mv_to(acsr1)
|
|
|
|
|
nzl = acsr1%get_nzeros()
|
|
|
|
|
call psb_glob_to_loc(acsr1%ja(1:nzl),p%desc_ac,info,'I')
|
|
|
|
|
if(info /= psb_success_) then
|
|
|
|
|
call psb_errpush(psb_err_from_subroutine_,name,a_err='psb_glob_to_loc')
|
|
|
|
|
goto 9999
|
|
|
|
|
end if
|
|
|
|
|
call op_prol%mv_from(acsr1)
|
|
|
|
|
endif
|
|
|
|
|
call op_prol%set_ncols(p%desc_ac%get_local_cols())
|
|
|
|
|
|
|
|
|
|
if (np>1) then
|
|
|
|
|
call op_restr%cscnv(info,type='coo',dupl=psb_dupl_add_)
|
|
|
|
|
call op_restr%mv_to(acoo)
|
|
|
|
|
nzl = acoo%get_nzeros()
|
|
|
|
|
if (info == psb_success_) call psb_glob_to_loc(acoo%ia(1:nzl),p%desc_ac,info,'I')
|
|
|
|
|
call acoo%set_dupl(psb_dupl_add_)
|
|
|
|
|
if (info == psb_success_) call op_restr%mv_from(acoo)
|
|
|
|
|
if (info == psb_success_) call op_restr%cscnv(info,type='csr')
|
|
|
|
|
if(info /= psb_success_) then
|
|
|
|
|
call psb_errpush(psb_err_internal_error_,name,a_err='Converting op_restr to local')
|
|
|
|
|
goto 9999
|
|
|
|
|
end if
|
|
|
|
|
end if
|
|
|
|
|
call op_restr%set_nrows(p%desc_ac%get_local_cols())
|
|
|
|
|
|
|
|
|
|
if (debug_level >= psb_debug_outer_) &
|
|
|
|
|
& write(debug_unit,*) me,' ',trim(name),&
|
|
|
|
|
& 'Done ac '
|
|
|
|
|
|
|
|
|
|
case(mld_repl_mat_)
|
|
|
|
|
!
|
|
|
|
|
!
|
|
|
|
|
call psb_cdall(ictxt,p%desc_ac,info,mg=ntaggr,repl=.true.)
|
|
|
|
|
if (info == psb_success_) call psb_cdasb(p%desc_ac,info)
|
|
|
|
|
if (info == psb_success_) &
|
|
|
|
|
& call psb_gather(p%ac,b,p%desc_ac,info,dupl=psb_dupl_add_,keeploc=.false.)
|
|
|
|
|
|
|
|
|
|
if (info /= psb_success_) goto 9999
|
|
|
|
|
|
|
|
|
|
case default
|
|
|
|
|
info = psb_err_internal_error_
|
|
|
|
|
call psb_errpush(info,name,a_err='invalid mld_coarse_mat_')
|
|
|
|
|
goto 9999
|
|
|
|
|
end select
|
|
|
|
|
|
|
|
|
|
call p%ac%cscnv(info,type='csr',dupl=psb_dupl_add_)
|
|
|
|
|
if(info /= psb_success_) then
|
|
|
|
|
call psb_errpush(psb_err_from_subroutine_,name,a_err='spcnv')
|
|
|
|
|
goto 9999
|
|
|
|
|
end if
|
|
|
|
|
|
|
|
|
|
!
|
|
|
|
|
! Copy the prolongation/restriction matrices into the descriptor map.
|
|
|
|
|
! op_restr => PR^T i.e. restriction operator
|
|
|
|
|
! op_prol => PR i.e. prolongation operator
|
|
|
|
|
!
|
|
|
|
|
|
|
|
|
|
p%map = psb_linmap(psb_map_aggr_,desc_a,&
|
|
|
|
|
& p%desc_ac,op_restr,op_prol,ilaggr,nlaggr)
|
|
|
|
|
if (info == psb_success_) call op_prol%free()
|
|
|
|
|
if (info == psb_success_) call op_restr%free()
|
|
|
|
|
if(info /= psb_success_) then
|
|
|
|
|
call psb_errpush(psb_err_from_subroutine_,name,a_err='sp_Free')
|
|
|
|
|
call psb_errpush(psb_err_internal_error_,name,a_err='Build ac = op_restr x am3')
|
|
|
|
|
goto 9999
|
|
|
|
|
end if
|
|
|
|
|
|
|
|
|
|