You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
533 lines
17 KiB
Fortran
533 lines
17 KiB
Fortran
8 years ago
|
!
|
||
|
!
|
||
4 years ago
|
! AMG4PSBLAS version 1.0
|
||
|
! Algebraic Multigrid Package
|
||
4 years ago
|
! based on PSBLAS (Parallel Sparse BLAS version 3.7)
|
||
8 years ago
|
!
|
||
4 years ago
|
! (C) Copyright 2021
|
||
8 years ago
|
!
|
||
7 years ago
|
! Salvatore Filippone
|
||
|
! Pasqua D'Ambra
|
||
4 years ago
|
! Fabio Durastante
|
||
8 years ago
|
!
|
||
|
! Redistribution and use in source and binary forms, with or without
|
||
|
! modification, are permitted provided that the following conditions
|
||
|
! are met:
|
||
|
! 1. Redistributions of source code must retain the above copyright
|
||
|
! notice, this list of conditions and the following disclaimer.
|
||
|
! 2. Redistributions in binary form must reproduce the above copyright
|
||
|
! notice, this list of conditions, and the following disclaimer in the
|
||
|
! documentation and/or other materials provided with the distribution.
|
||
4 years ago
|
! 3. The name of the AMG4PSBLAS group or the names of its contributors may
|
||
8 years ago
|
! not be used to endorse or promote products derived from this
|
||
|
! software without specific written permission.
|
||
|
!
|
||
|
! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||
|
! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||
|
! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||
4 years ago
|
! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AMG4PSBLAS GROUP OR ITS CONTRIBUTORS
|
||
8 years ago
|
! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||
|
! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||
|
! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||
|
! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||
|
! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||
|
! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||
|
! POSSIBILITY OF SUCH DAMAGE.
|
||
|
!
|
||
|
!
|
||
8 years ago
|
!
|
||
4 years ago
|
! File: amg_z_soc1_map__bld.f90
|
||
8 years ago
|
!
|
||
4 years ago
|
! Subroutine: amg_z_soc1_map_bld
|
||
8 years ago
|
! Version: complex
|
||
|
!
|
||
|
! This routine builds the tentative prolongator based on the
|
||
7 years ago
|
! strength of connection aggregation algorithm presented in
|
||
8 years ago
|
!
|
||
|
! M. Brezina and P. Vanek, A black-box iterative solver based on a
|
||
|
! two-level Schwarz method, Computing, 63 (1999), 233-263.
|
||
6 years ago
|
! P. Vanek, J. Mandel and M. Brezina, Algebraic Multigrid by Smoothed
|
||
|
! Aggregation for Second and Fourth Order Elliptic Problems, Computing, 56
|
||
|
! (1996), 179-196.
|
||
8 years ago
|
!
|
||
|
! Note: upon exit
|
||
|
!
|
||
|
! Arguments:
|
||
|
! a - type(psb_zspmat_type).
|
||
|
! The sparse matrix structure containing the local part of the
|
||
|
! matrix to be preconditioned.
|
||
|
! desc_a - type(psb_desc_type), input.
|
||
|
! The communication descriptor of a.
|
||
4 years ago
|
! p - type(amg_zprec_type), input/output.
|
||
8 years ago
|
! The preconditioner data structure; upon exit it contains
|
||
|
! the multilevel hierarchy of prolongators, restrictors
|
||
|
! and coarse matrices.
|
||
|
! info - integer, output.
|
||
|
! Error code.
|
||
|
!
|
||
|
!
|
||
|
!
|
||
4 years ago
|
subroutine amg_z_soc1_map_bld(iorder,theta,clean_zeros,a,desc_a,nlaggr,ilaggr,info)
|
||
14 years ago
|
|
||
|
use psb_base_mod
|
||
4 years ago
|
use amg_base_prec_type
|
||
|
use amg_z_inner_mod
|
||
1 year ago
|
#if defined(OPENMP)
|
||
|
use omp_lib
|
||
|
#endif
|
||
14 years ago
|
implicit none
|
||
|
|
||
|
! Arguments
|
||
9 years ago
|
integer(psb_ipk_), intent(in) :: iorder
|
||
6 years ago
|
logical, intent(in) :: clean_zeros
|
||
14 years ago
|
type(psb_zspmat_type), intent(in) :: a
|
||
13 years ago
|
type(psb_desc_type), intent(in) :: desc_a
|
||
|
real(psb_dpk_), intent(in) :: theta
|
||
6 years ago
|
integer(psb_lpk_), allocatable, intent(out) :: ilaggr(:),nlaggr(:)
|
||
12 years ago
|
integer(psb_ipk_), intent(out) :: info
|
||
14 years ago
|
|
||
|
! Local variables
|
||
6 years ago
|
integer(psb_ipk_), allocatable :: ils(:), neigh(:), irow(:), icol(:),&
|
||
|
& ideg(:), idxs(:)
|
||
|
integer(psb_lpk_), allocatable :: tmpaggr(:)
|
||
14 years ago
|
complex(psb_dpk_), allocatable :: val(:), diag(:)
|
||
6 years ago
|
integer(psb_ipk_) :: icnt,nlp,k,n,ia,isz,nr, nc, naggr,i,j,m, nz, ilg, ii, ip
|
||
9 years ago
|
type(psb_z_csr_sparse_mat) :: acsr
|
||
14 years ago
|
real(psb_dpk_) :: cpling, tcl
|
||
8 years ago
|
logical :: disjoint
|
||
12 years ago
|
integer(psb_ipk_) :: debug_level, debug_unit,err_act
|
||
4 years ago
|
type(psb_ctxt_type) :: ctxt
|
||
|
integer(psb_ipk_) :: np, me
|
||
|
integer(psb_ipk_) :: nrow, ncol, n_ne
|
||
|
integer(psb_lpk_) :: nrglob
|
||
|
character(len=20) :: name, ch_err
|
||
1 year ago
|
integer(psb_ipk_), save :: idx_soc1_p1=-1, idx_soc1_p2=-1, idx_soc1_p3=-1
|
||
|
integer(psb_ipk_), save :: idx_soc1_p0=-1
|
||
|
logical, parameter :: do_timings=.true.
|
||
14 years ago
|
|
||
|
info=psb_success_
|
||
4 years ago
|
name = 'amg_soc1_map_bld'
|
||
14 years ago
|
call psb_erractionsave(err_act)
|
||
6 years ago
|
if (psb_errstatus_fatal()) then
|
||
|
info = psb_err_internal_error_; goto 9999
|
||
|
end if
|
||
14 years ago
|
debug_unit = psb_get_debug_unit()
|
||
|
debug_level = psb_get_debug_level()
|
||
|
!
|
||
4 years ago
|
ctxt=desc_a%get_context()
|
||
|
call psb_info(ctxt,me,np)
|
||
6 years ago
|
nrow = desc_a%get_local_rows()
|
||
|
ncol = desc_a%get_local_cols()
|
||
6 years ago
|
nrglob = desc_a%get_global_rows()
|
||
1 year ago
|
if ((do_timings).and.(idx_soc1_p0==-1)) &
|
||
|
& idx_soc1_p0 = psb_get_timer_idx("SOC1_MAP: phase0")
|
||
|
if ((do_timings).and.(idx_soc1_p1==-1)) &
|
||
|
& idx_soc1_p1 = psb_get_timer_idx("SOC1_MAP: phase1")
|
||
|
if ((do_timings).and.(idx_soc1_p2==-1)) &
|
||
|
& idx_soc1_p2 = psb_get_timer_idx("SOC1_MAP: phase2")
|
||
|
if ((do_timings).and.(idx_soc1_p3==-1)) &
|
||
|
& idx_soc1_p3 = psb_get_timer_idx("SOC1_MAP: phase3")
|
||
14 years ago
|
|
||
|
nr = a%get_nrows()
|
||
6 years ago
|
nc = a%get_ncols()
|
||
6 years ago
|
allocate(ilaggr(nr),neigh(nr),ideg(nr),idxs(nr),&
|
||
6 years ago
|
& icol(nc),val(nc),stat=info)
|
||
14 years ago
|
if(info /= psb_success_) then
|
||
|
info=psb_err_alloc_request_
|
||
12 years ago
|
call psb_errpush(info,name,i_err=(/2*nr,izero,izero,izero,izero/),&
|
||
14 years ago
|
& a_err='integer')
|
||
|
goto 9999
|
||
|
end if
|
||
|
|
||
11 years ago
|
diag = a%get_diag(info)
|
||
14 years ago
|
if(info /= psb_success_) then
|
||
|
info=psb_err_from_subroutine_
|
||
|
call psb_errpush(info,name,a_err='psb_sp_getdiag')
|
||
|
goto 9999
|
||
|
end if
|
||
|
|
||
1 year ago
|
if (do_timings) call psb_tic(idx_soc1_p0)
|
||
6 years ago
|
call a%cp_to(acsr)
|
||
1 year ago
|
if (do_timings) call psb_toc(idx_soc1_p0)
|
||
6 years ago
|
if (clean_zeros) call acsr%clean_zeros(info)
|
||
4 years ago
|
if (iorder == amg_aggr_ord_nat_) then
|
||
1 year ago
|
!$omp parallel do private(i)
|
||
9 years ago
|
do i=1, nr
|
||
|
ilaggr(i) = -(nr+1)
|
||
|
idxs(i) = i
|
||
|
end do
|
||
1 year ago
|
!$omp end parallel do
|
||
|
else
|
||
|
!$omp parallel do private(i)
|
||
9 years ago
|
do i=1, nr
|
||
|
ilaggr(i) = -(nr+1)
|
||
|
ideg(i) = acsr%irp(i+1) - acsr%irp(i)
|
||
|
end do
|
||
1 year ago
|
!$omp end parallel do
|
||
9 years ago
|
call psb_msort(ideg,ix=idxs,dir=psb_sort_down_)
|
||
|
end if
|
||
1 year ago
|
if (do_timings) call psb_tic(idx_soc1_p1)
|
||
8 years ago
|
|
||
14 years ago
|
!
|
||
8 years ago
|
! Phase one: Start with disjoint groups.
|
||
14 years ago
|
!
|
||
|
naggr = 0
|
||
1 year ago
|
#if 0&&defined(OPENMP)
|
||
|
block
|
||
|
integer(psb_ipk_), allocatable :: bnds(:), locnaggr(:)
|
||
|
integer(psb_ipk_) :: myth,nths, kk
|
||
|
!$omp parallel shared(bnds,locnaggr,ilaggr,nr,naggr,diag,theta,nths) private(icol,val,myth,kk)
|
||
|
block
|
||
|
integer(psb_ipk_) :: ii,nlp,k,n,ia,isz, nc, i,j,m, nz, ilg, ip, rsz, minip
|
||
|
nths = omp_get_num_threads()
|
||
|
myth = omp_get_thread_num()
|
||
|
rsz = nr/nths
|
||
|
if (myth < mod(nr,nths)) rsz = rsz + 1
|
||
|
!!$ write(0,*) 'From thread : rsz ',myth,rsz
|
||
|
!$omp master
|
||
|
allocate(bnds(0:nths),locnaggr(0:nths))
|
||
|
locnaggr(:) = 0
|
||
|
bnds(0) = 1
|
||
|
!$omp end master
|
||
|
!$omp barrier
|
||
|
bnds(myth+1) = rsz
|
||
|
!$omp master
|
||
|
!!$ write(0,*) 'From master 1: ',bnds
|
||
|
do i=1,nths
|
||
|
bnds(i) = bnds(i) + bnds(i-1)
|
||
|
end do
|
||
|
!!$ write(0,*) 'From master 2: ',bnds
|
||
|
!$omp end master
|
||
|
!$omp barrier
|
||
|
|
||
|
!$omp do schedule(static)
|
||
|
do kk=0, nths-1
|
||
|
!!$ write(0,*) 'From thread ',myth,kk,bnds(kk),bnds(kk+1)-1
|
||
|
step1: do ii=bnds(kk), bnds(kk+1)-1
|
||
|
if (info /= 0) cycle
|
||
|
i = idxs(ii)
|
||
|
if ((i<1).or.(i>nr)) then
|
||
|
info=psb_err_internal_error_
|
||
|
call psb_errpush(info,name)
|
||
|
cycle step1
|
||
|
!goto 9999
|
||
|
end if
|
||
|
|
||
|
if (ilaggr(i) == -(nr+1)) then
|
||
|
nz = (acsr%irp(i+1)-acsr%irp(i))
|
||
|
if ((nz<0).or.(nz>size(icol))) then
|
||
|
info=psb_err_internal_error_
|
||
|
call psb_errpush(info,name)
|
||
|
cycle step1
|
||
|
!goto 9999
|
||
|
end if
|
||
|
|
||
|
icol(1:nz) = acsr%ja(acsr%irp(i):acsr%irp(i+1)-1)
|
||
|
val(1:nz) = acsr%val(acsr%irp(i):acsr%irp(i+1)-1)
|
||
|
|
||
|
!
|
||
|
! Build the set of all strongly coupled nodes
|
||
|
!
|
||
|
if (.false.) then
|
||
|
ip = 0
|
||
|
do k=1, nz
|
||
|
j = icol(k)
|
||
|
if ((bnds(myth)<=j).and.(j<=(bnds(myth+1)-1))) then
|
||
|
if (abs(val(k)) > theta*sqrt(abs(diag(i)*diag(j)))) then
|
||
|
ip = ip + 1
|
||
|
icol(ip) = icol(k)
|
||
|
end if
|
||
|
end if
|
||
|
enddo
|
||
|
|
||
|
!
|
||
|
! If the whole strongly coupled neighborhood of I is
|
||
|
! as yet unconnected, turn it into the next aggregate.
|
||
|
! Same if ip==0 (in which case, neighborhood only
|
||
|
! contains I even if it does not look like it from matrix)
|
||
|
!
|
||
|
disjoint = all(ilaggr(icol(1:ip)) == -(nr+1)).or.(ip==0)
|
||
|
if (disjoint) then
|
||
|
locnaggr(kk) = locnaggr(kk) + 1
|
||
|
do k=1, ip
|
||
|
ilaggr(icol(k)) = locnaggr(kk)
|
||
|
end do
|
||
|
ilaggr(i) = locnaggr(kk)
|
||
|
end if
|
||
|
else
|
||
|
ip = 0
|
||
|
minip = nr +1
|
||
|
do k=1, nz
|
||
|
j = icol(k)
|
||
|
if (abs(val(k)) > theta*sqrt(abs(diag(i)*diag(j)))) then
|
||
|
ip = ip + 1
|
||
|
icol(ip) = icol(k)
|
||
|
minip = min(icol(ip),minip)
|
||
|
end if
|
||
|
enddo
|
||
|
if (bnds(myth)<=minip) then
|
||
|
|
||
|
!
|
||
|
! If the whole strongly coupled neighborhood of I is
|
||
|
! as yet unconnected, turn it into the next aggregate.
|
||
|
! Same if ip==0 (in which case, neighborhood only
|
||
|
! contains I even if it does not look like it from matrix)
|
||
|
!
|
||
|
disjoint = all(ilaggr(icol(1:ip)) == -(nr+1)).or.(ip==0)
|
||
|
if (disjoint) then
|
||
|
!$omp critical(update_ilaggr)
|
||
|
disjoint = all(ilaggr(icol(1:ip)) == -(nr+1)).or.(ip==0)
|
||
|
if (disjoint) then
|
||
|
locnaggr(kk) = locnaggr(kk) + 1
|
||
|
do k=1, ip
|
||
|
ilaggr(icol(k)) = locnaggr(kk)
|
||
|
end do
|
||
|
ilaggr(i) = locnaggr(kk)
|
||
|
end if
|
||
|
!$omp end critical(update_ilaggr)
|
||
|
end if
|
||
|
endif
|
||
|
end if
|
||
|
end if
|
||
|
enddo step1
|
||
|
end do
|
||
|
!$omp end do
|
||
|
!$omp barrier
|
||
|
!$omp master
|
||
|
naggr = sum(locnaggr(0:nths-1))
|
||
|
!!$ write(0,*) 'NAGGR ',naggr, 'locnaggr ',locnaggr(0:nths-1)
|
||
|
do i=1,nths
|
||
|
locnaggr(i) = locnaggr(i) + locnaggr(i-1)
|
||
|
end do
|
||
|
do i=nths,1,-1
|
||
|
locnaggr(i) = locnaggr(i-1)
|
||
|
end do
|
||
|
locnaggr(0) = 0
|
||
|
!$omp end master
|
||
|
!$omp barrier
|
||
|
!$omp do schedule(static)
|
||
|
do kk=0, nths-1
|
||
|
do ii=bnds(kk), bnds(kk+1)-1
|
||
|
if (ilaggr(ii) > 0) ilaggr(ii) = ilaggr(ii) + locnaggr(kk)
|
||
|
end do
|
||
|
end do
|
||
|
!$omp end do
|
||
|
end block
|
||
|
!$omp end parallel
|
||
|
end block
|
||
|
!!$ write(0,*) 'Out of parallel looop NAGGR ',naggr
|
||
|
#else
|
||
8 years ago
|
step1: do ii=1, nr
|
||
1 year ago
|
if (info /= 0) cycle
|
||
8 years ago
|
i = idxs(ii)
|
||
6 years ago
|
if ((i<1).or.(i>nr)) then
|
||
|
info=psb_err_internal_error_
|
||
|
call psb_errpush(info,name)
|
||
1 year ago
|
cycle step1
|
||
|
!goto 9999
|
||
6 years ago
|
end if
|
||
1 year ago
|
|
||
6 years ago
|
if (ilaggr(i) == -(nr+1)) then
|
||
|
nz = (acsr%irp(i+1)-acsr%irp(i))
|
||
6 years ago
|
if ((nz<0).or.(nz>size(icol))) then
|
||
|
info=psb_err_internal_error_
|
||
|
call psb_errpush(info,name)
|
||
1 year ago
|
cycle step1
|
||
|
!goto 9999
|
||
6 years ago
|
end if
|
||
|
|
||
6 years ago
|
icol(1:nz) = acsr%ja(acsr%irp(i):acsr%irp(i+1)-1)
|
||
|
val(1:nz) = acsr%val(acsr%irp(i):acsr%irp(i+1)-1)
|
||
14 years ago
|
|
||
8 years ago
|
!
|
||
|
! Build the set of all strongly coupled nodes
|
||
|
!
|
||
1 year ago
|
ip = 0
|
||
8 years ago
|
do k=1, nz
|
||
|
j = icol(k)
|
||
|
if ((1<=j).and.(j<=nr)) then
|
||
|
if (abs(val(k)) > theta*sqrt(abs(diag(i)*diag(j)))) then
|
||
|
ip = ip + 1
|
||
|
icol(ip) = icol(k)
|
||
14 years ago
|
end if
|
||
8 years ago
|
end if
|
||
|
enddo
|
||
14 years ago
|
|
||
8 years ago
|
!
|
||
|
! If the whole strongly coupled neighborhood of I is
|
||
|
! as yet unconnected, turn it into the next aggregate.
|
||
|
! Same if ip==0 (in which case, neighborhood only
|
||
6 years ago
|
! contains I even if it does not look like it from matrix)
|
||
8 years ago
|
!
|
||
|
disjoint = all(ilaggr(icol(1:ip)) == -(nr+1)).or.(ip==0)
|
||
1 year ago
|
if (disjoint) then
|
||
8 years ago
|
naggr = naggr + 1
|
||
|
do k=1, ip
|
||
|
ilaggr(icol(k)) = naggr
|
||
|
end do
|
||
|
ilaggr(i) = naggr
|
||
|
end if
|
||
|
endif
|
||
|
enddo step1
|
||
1 year ago
|
!!$ write(0,*) 'NAGGR ',naggr
|
||
|
#endif
|
||
14 years ago
|
if (debug_level >= psb_debug_outer_) then
|
||
|
write(debug_unit,*) me,' ',trim(name),&
|
||
1 year ago
|
& ' Check 1:',naggr,count(ilaggr(1:nr) == -(nr+1)), count(ilaggr(1:nr)>0),&
|
||
|
& count(ilaggr(1:nr) == -(nr+1))+count(ilaggr(1:nr)>0),nr
|
||
14 years ago
|
end if
|
||
1 year ago
|
if (do_timings) call psb_toc(idx_soc1_p1)
|
||
|
if (do_timings) call psb_tic(idx_soc1_p2)
|
||
14 years ago
|
!
|
||
8 years ago
|
! Phase two: join the neighbours
|
||
8 years ago
|
!
|
||
1 year ago
|
! $ omp workshare
|
||
8 years ago
|
tmpaggr = ilaggr
|
||
1 year ago
|
! $ omp end workshare
|
||
|
! $ omp parallel do schedule(static) shared(tmpaggr,ilaggr,nr,naggr,diag,theta) private(ii,i,j,k,nz,icol,val,ip)
|
||
8 years ago
|
step2: do ii=1,nr
|
||
|
i = idxs(ii)
|
||
14 years ago
|
|
||
8 years ago
|
if (ilaggr(i) == -(nr+1)) then
|
||
6 years ago
|
nz = (acsr%irp(i+1)-acsr%irp(i))
|
||
6 years ago
|
if (nz == 1) cycle step2
|
||
6 years ago
|
icol(1:nz) = acsr%ja(acsr%irp(i):acsr%irp(i+1)-1)
|
||
|
val(1:nz) = acsr%val(acsr%irp(i):acsr%irp(i+1)-1)
|
||
6 years ago
|
|
||
8 years ago
|
!
|
||
|
! Find the most strongly connected neighbour that is
|
||
|
! already aggregated, if any, and join its aggregate
|
||
|
!
|
||
|
cpling = dzero
|
||
|
ip = 0
|
||
|
do k=1, nz
|
||
|
j = icol(k)
|
||
|
if ((1<=j).and.(j<=nr)) then
|
||
|
if ((abs(val(k)) > theta*sqrt(abs(diag(i)*diag(j))))&
|
||
8 years ago
|
& .and. (tmpaggr(j) > 0).and. (abs(val(k)) > cpling)) then
|
||
8 years ago
|
ip = k
|
||
|
cpling = abs(val(k))
|
||
|
end if
|
||
14 years ago
|
end if
|
||
|
enddo
|
||
8 years ago
|
if (ip > 0) then
|
||
|
ilaggr(i) = ilaggr(icol(ip))
|
||
|
end if
|
||
|
end if
|
||
|
end do step2
|
||
1 year ago
|
! $ omp end parallel do
|
||
|
if (do_timings) call psb_toc(idx_soc1_p2)
|
||
|
if (debug_level >= psb_debug_outer_) then
|
||
|
write(debug_unit,*) me,' ',trim(name),&
|
||
|
& ' Check 1.5:',naggr,count(ilaggr(1:nr) == -(nr+1)), count(ilaggr(1:nr)>0),&
|
||
|
& count(ilaggr(1:nr) == -(nr+1))+count(ilaggr(1:nr)>0),nr
|
||
|
end if
|
||
|
|
||
|
if (do_timings) call psb_tic(idx_soc1_p3)
|
||
8 years ago
|
!
|
||
|
! Phase three: sweep over leftovers, if any
|
||
|
!
|
||
|
step3: do ii=1,nr
|
||
|
i = idxs(ii)
|
||
14 years ago
|
|
||
8 years ago
|
if (ilaggr(i) < 0) then
|
||
6 years ago
|
nz = (acsr%irp(i+1)-acsr%irp(i))
|
||
6 years ago
|
if (nz == 1) cycle step3
|
||
6 years ago
|
icol(1:nz) = acsr%ja(acsr%irp(i):acsr%irp(i+1)-1)
|
||
|
val(1:nz) = acsr%val(acsr%irp(i):acsr%irp(i+1)-1)
|
||
8 years ago
|
!
|
||
8 years ago
|
! Find its strongly connected neighbourhood not
|
||
|
! already aggregated, and make it into a new aggregate.
|
||
8 years ago
|
!
|
||
|
cpling = dzero
|
||
|
ip = 0
|
||
|
do k=1, nz
|
||
|
j = icol(k)
|
||
|
if ((1<=j).and.(j<=nr)) then
|
||
|
if ((abs(val(k)) > theta*sqrt(abs(diag(i)*diag(j))))&
|
||
|
& .and. (ilaggr(j) < 0)) then
|
||
|
ip = ip + 1
|
||
|
icol(ip) = icol(k)
|
||
|
end if
|
||
14 years ago
|
end if
|
||
8 years ago
|
enddo
|
||
|
if (ip > 0) then
|
||
|
naggr = naggr + 1
|
||
|
ilaggr(i) = naggr
|
||
|
do k=1, ip
|
||
|
ilaggr(icol(k)) = naggr
|
||
|
end do
|
||
|
else
|
||
|
!
|
||
6 years ago
|
! This should not happen: we did not even connect with ourselves,
|
||
|
! but it's not a singleton.
|
||
8 years ago
|
!
|
||
|
naggr = naggr + 1
|
||
|
ilaggr(i) = naggr
|
||
|
end if
|
||
14 years ago
|
end if
|
||
8 years ago
|
end do step3
|
||
|
|
||
6 years ago
|
! Any leftovers?
|
||
|
do i=1, nr
|
||
|
if (ilaggr(i) < 0) then
|
||
|
nz = (acsr%irp(i+1)-acsr%irp(i))
|
||
|
if (nz == 1) then
|
||
|
! Mark explicitly as a singleton so that
|
||
|
! it will be ignored in map_to_tprol.
|
||
|
! Need to use -(nrglob+nr) to make sure
|
||
|
! it's still negative when shifted and combined with
|
||
|
! other processes.
|
||
|
ilaggr(i) = -(nrglob+nr)
|
||
|
else
|
||
|
info=psb_err_internal_error_
|
||
|
call psb_errpush(info,name,a_err='Fatal error: non-singleton leftovers')
|
||
|
goto 9999
|
||
|
endif
|
||
|
end if
|
||
|
end do
|
||
1 year ago
|
if (do_timings) call psb_toc(idx_soc1_p3)
|
||
14 years ago
|
if (naggr > ncol) then
|
||
6 years ago
|
!write(0,*) name,'Error : naggr > ncol',naggr,ncol
|
||
14 years ago
|
info=psb_err_internal_error_
|
||
|
call psb_errpush(info,name,a_err='Fatal error: naggr>ncol')
|
||
|
goto 9999
|
||
|
end if
|
||
|
|
||
|
call psb_realloc(ncol,ilaggr,info)
|
||
|
if (info /= psb_success_) then
|
||
|
info=psb_err_from_subroutine_
|
||
|
ch_err='psb_realloc'
|
||
|
call psb_errpush(info,name,a_err=ch_err)
|
||
|
goto 9999
|
||
|
end if
|
||
|
|
||
|
allocate(nlaggr(np),stat=info)
|
||
|
if (info /= psb_success_) then
|
||
|
info=psb_err_alloc_request_
|
||
12 years ago
|
call psb_errpush(info,name,i_err=(/np,izero,izero,izero,izero/),&
|
||
14 years ago
|
& a_err='integer')
|
||
|
goto 9999
|
||
|
end if
|
||
|
|
||
|
nlaggr(:) = 0
|
||
|
nlaggr(me+1) = naggr
|
||
4 years ago
|
call psb_sum(ctxt,nlaggr(1:np))
|
||
1 year ago
|
if (debug_level >= psb_debug_outer_) then
|
||
|
write(debug_unit,*) me,' ',trim(name),&
|
||
|
& ' Check 2:',naggr,count(ilaggr(1:nr) == -(nr+1)), count(ilaggr(1:nr)>0),&
|
||
|
& count(ilaggr(1:nr) == -(nr+1))+count(ilaggr(1:nr)>0),nr
|
||
|
end if
|
||
|
!!$ write(0,*) nlaggr(1:np),'ILAGGR : ',ilaggr(1:nr)
|
||
14 years ago
|
|
||
6 years ago
|
call acsr%free()
|
||
14 years ago
|
call psb_erractionrestore(err_act)
|
||
|
return
|
||
|
|
||
10 years ago
|
9999 call psb_error_handler(err_act)
|
||
|
|
||
14 years ago
|
return
|
||
|
|
||
4 years ago
|
end subroutine amg_z_soc1_map_bld
|
||
13 years ago
|
|