|
|
@ -65,7 +65,7 @@ subroutine psb_zscatterm(globx, locx, desc_a, info, iroot)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
! locals
|
|
|
|
! locals
|
|
|
|
integer :: int_err(5), ictxt, np, me, &
|
|
|
|
integer :: int_err(5), ictxt, np, me,&
|
|
|
|
& err_act, m, n, i, j, idx, nrow, iiroot, iglobx, jglobx,&
|
|
|
|
& err_act, m, n, i, j, idx, nrow, iiroot, iglobx, jglobx,&
|
|
|
|
& ilocx, jlocx, lda_locx, lda_globx, lock, globk, icomm, k, maxk, root, ilx,&
|
|
|
|
& ilocx, jlocx, lda_locx, lda_globx, lock, globk, icomm, k, maxk, root, ilx,&
|
|
|
|
& jlx, myrank, rootrank, c, pos
|
|
|
|
& jlx, myrank, rootrank, c, pos
|
|
|
@ -103,12 +103,10 @@ subroutine psb_zscatterm(globx, locx, desc_a, info, iroot)
|
|
|
|
iiroot = psb_root_
|
|
|
|
iiroot = psb_root_
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
iglobx = 1
|
|
|
|
iglobx = 1
|
|
|
|
jglobx = 1
|
|
|
|
jglobx = 1
|
|
|
|
ilocx = 1
|
|
|
|
ilocx = 1
|
|
|
|
jlocx = 1
|
|
|
|
jlocx = 1
|
|
|
|
|
|
|
|
|
|
|
|
lda_globx = size(globx,1)
|
|
|
|
lda_globx = size(globx,1)
|
|
|
|
lda_locx = size(locx, 1)
|
|
|
|
lda_locx = size(locx, 1)
|
|
|
|
|
|
|
|
|
|
|
@ -119,10 +117,10 @@ subroutine psb_zscatterm(globx, locx, desc_a, info, iroot)
|
|
|
|
globk=size(globx,2)-jglobx+1
|
|
|
|
globk=size(globx,2)-jglobx+1
|
|
|
|
maxk=min(lock,globk)
|
|
|
|
maxk=min(lock,globk)
|
|
|
|
k = maxk
|
|
|
|
k = maxk
|
|
|
|
|
|
|
|
|
|
|
|
call psb_get_mpicomm(ictxt,icomm)
|
|
|
|
call psb_get_mpicomm(ictxt,icomm)
|
|
|
|
call psb_get_rank(myrank,ictxt,me)
|
|
|
|
call psb_get_rank(myrank,ictxt,me)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lda_globx = size(globx)
|
|
|
|
lda_globx = size(globx)
|
|
|
|
lda_locx = size(locx)
|
|
|
|
lda_locx = size(locx)
|
|
|
|
|
|
|
|
|
|
|
@ -134,8 +132,7 @@ subroutine psb_zscatterm(globx, locx, desc_a, info, iroot)
|
|
|
|
! there should be a global check on k here!!!
|
|
|
|
! there should be a global check on k here!!!
|
|
|
|
|
|
|
|
|
|
|
|
call psb_chkglobvect(m,n,size(globx),iglobx,jglobx,desc_a,info)
|
|
|
|
call psb_chkglobvect(m,n,size(globx),iglobx,jglobx,desc_a,info)
|
|
|
|
if (info == 0) &
|
|
|
|
if (info == 0) call psb_chkvect(m,n,size(locx),ilocx,jlocx,desc_a,info,ilx,jlx)
|
|
|
|
& call psb_chkvect(m,n,size(locx),ilocx,jlocx,desc_a,info,ilx,jlx)
|
|
|
|
|
|
|
|
if(info /= 0) then
|
|
|
|
if(info /= 0) then
|
|
|
|
info=4010
|
|
|
|
info=4010
|
|
|
|
ch_err='psb_chk(glob)vect'
|
|
|
|
ch_err='psb_chk(glob)vect'
|
|
|
@ -151,7 +148,7 @@ subroutine psb_zscatterm(globx, locx, desc_a, info, iroot)
|
|
|
|
|
|
|
|
|
|
|
|
nrow=psb_cd_get_local_rows(desc_a)
|
|
|
|
nrow=psb_cd_get_local_rows(desc_a)
|
|
|
|
|
|
|
|
|
|
|
|
if(root == -1) then
|
|
|
|
if ((root == -1).or.(np==1)) then
|
|
|
|
! extract my chunk
|
|
|
|
! extract my chunk
|
|
|
|
do j=1,k
|
|
|
|
do j=1,k
|
|
|
|
do i=1, nrow
|
|
|
|
do i=1, nrow
|
|
|
@ -161,59 +158,61 @@ subroutine psb_zscatterm(globx, locx, desc_a, info, iroot)
|
|
|
|
end do
|
|
|
|
end do
|
|
|
|
else
|
|
|
|
else
|
|
|
|
call psb_get_rank(rootrank,ictxt,root)
|
|
|
|
call psb_get_rank(rootrank,ictxt,root)
|
|
|
|
end if
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
! root has to gather size information
|
|
|
|
! root has to gather size information
|
|
|
|
allocate(displ(np),all_dim(np),stat=info)
|
|
|
|
allocate(displ(np),all_dim(np),stat=info)
|
|
|
|
if(info /= 0) then
|
|
|
|
|
|
|
|
info=4010
|
|
|
|
|
|
|
|
ch_err='Allocate'
|
|
|
|
|
|
|
|
call psb_errpush(info,name,a_err=ch_err)
|
|
|
|
|
|
|
|
goto 9999
|
|
|
|
|
|
|
|
end if
|
|
|
|
|
|
|
|
call mpi_gather(nrow,1,mpi_integer,all_dim,&
|
|
|
|
|
|
|
|
& np,mpi_integer,rootrank,icomm,info)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
displ(1)=1
|
|
|
|
|
|
|
|
displ(2:)=all_dim(1:np-1)+1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
! root has to gather loc_glob from each process
|
|
|
|
|
|
|
|
if(me == root) then
|
|
|
|
|
|
|
|
allocate(l_t_g_all(sum(all_dim)),scatterv(sum(all_dim)),stat=info)
|
|
|
|
|
|
|
|
if(info /= 0) then
|
|
|
|
if(info /= 0) then
|
|
|
|
info=4010
|
|
|
|
info=4010
|
|
|
|
ch_err='Allocate'
|
|
|
|
ch_err='Allocate'
|
|
|
|
call psb_errpush(info,name,a_err=ch_err)
|
|
|
|
call psb_errpush(info,name,a_err=ch_err)
|
|
|
|
goto 9999
|
|
|
|
goto 9999
|
|
|
|
end if
|
|
|
|
end if
|
|
|
|
|
|
|
|
call mpi_gather(nrow,1,mpi_integer,all_dim,&
|
|
|
|
|
|
|
|
& 1,mpi_integer,rootrank,icomm,info)
|
|
|
|
|
|
|
|
|
|
|
|
end if
|
|
|
|
if (me == root) then
|
|
|
|
|
|
|
|
displ(1)=0
|
|
|
|
|
|
|
|
do i=2,np
|
|
|
|
|
|
|
|
displ(i)=displ(i-1)+all_dim(i-1)
|
|
|
|
|
|
|
|
end do
|
|
|
|
|
|
|
|
|
|
|
|
call mpi_gatherv(desc_a%loc_to_glob,nrow,&
|
|
|
|
! root has to gather loc_glob from each process
|
|
|
|
& mpi_integer,l_t_g_all,all_dim,&
|
|
|
|
allocate(l_t_g_all(sum(all_dim)),scatterv(sum(all_dim)),stat=info)
|
|
|
|
& displ,mpi_integer,rootrank,icomm,info)
|
|
|
|
if(info /= 0) then
|
|
|
|
|
|
|
|
info=4010
|
|
|
|
|
|
|
|
ch_err='Allocate'
|
|
|
|
|
|
|
|
call psb_errpush(info,name,a_err=ch_err)
|
|
|
|
|
|
|
|
goto 9999
|
|
|
|
|
|
|
|
end if
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
end if
|
|
|
|
|
|
|
|
|
|
|
|
do c=1, k
|
|
|
|
call mpi_gatherv(desc_a%loc_to_glob,nrow,&
|
|
|
|
! prepare vector to scatter
|
|
|
|
& mpi_integer,l_t_g_all,all_dim,&
|
|
|
|
if(me == root) then
|
|
|
|
& displ,mpi_integer,rootrank,icomm,info)
|
|
|
|
do i=1,np
|
|
|
|
|
|
|
|
pos=displ(i)
|
|
|
|
|
|
|
|
do j=1, all_dim(i)
|
|
|
|
do c=1, k
|
|
|
|
idx=l_t_g_all(pos+j-1)
|
|
|
|
! prepare vector to scatter
|
|
|
|
scatterv(pos+j-1)=globx(idx,jglobx+c-1)
|
|
|
|
if(me == root) then
|
|
|
|
|
|
|
|
do i=1,np
|
|
|
|
|
|
|
|
pos=displ(i)
|
|
|
|
|
|
|
|
do j=1, all_dim(i)
|
|
|
|
|
|
|
|
idx=l_t_g_all(pos+j)
|
|
|
|
|
|
|
|
scatterv(pos+j)=globx(idx,jglobx+c-1)
|
|
|
|
|
|
|
|
end do
|
|
|
|
end do
|
|
|
|
end do
|
|
|
|
end do
|
|
|
|
end if
|
|
|
|
end if
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
! scatter !!!
|
|
|
|
! scatter !!!
|
|
|
|
call mpi_scatterv(scatterv,all_dim,displ,&
|
|
|
|
call mpi_scatterv(scatterv,all_dim,displ,&
|
|
|
|
& mpi_double_complex,locx(1,jlocx+c-1),nrow,&
|
|
|
|
& mpi_double_complex,locx(1,jlocx+c-1),nrow,&
|
|
|
|
& mpi_double_complex,rootrank,icomm,info)
|
|
|
|
& mpi_double_complex,rootrank,icomm,info)
|
|
|
|
|
|
|
|
|
|
|
|
end do
|
|
|
|
end do
|
|
|
|
|
|
|
|
|
|
|
|
deallocate(all_dim, l_t_g_all, displ, scatterv)
|
|
|
|
if (me==root) deallocate(all_dim, l_t_g_all, displ, scatterv)
|
|
|
|
|
|
|
|
end if
|
|
|
|
|
|
|
|
|
|
|
|
call psb_erractionrestore(err_act)
|
|
|
|
call psb_erractionrestore(err_act)
|
|
|
|
return
|
|
|
|
return
|
|
|
@ -304,13 +303,16 @@ subroutine psb_zscatterv(globx, locx, desc_a, info, iroot)
|
|
|
|
complex(psb_dpk_), allocatable :: scatterv(:)
|
|
|
|
complex(psb_dpk_), allocatable :: scatterv(:)
|
|
|
|
integer, allocatable :: displ(:), l_t_g_all(:), all_dim(:)
|
|
|
|
integer, allocatable :: displ(:), l_t_g_all(:), all_dim(:)
|
|
|
|
character(len=20) :: name, ch_err
|
|
|
|
character(len=20) :: name, ch_err
|
|
|
|
|
|
|
|
integer :: debug_level, debug_unit
|
|
|
|
|
|
|
|
|
|
|
|
name='psb_scatterv'
|
|
|
|
name='psb_scatterv'
|
|
|
|
if(psb_get_errstatus() /= 0) return
|
|
|
|
if (psb_get_errstatus() /= 0) return
|
|
|
|
info=0
|
|
|
|
info=0
|
|
|
|
call psb_erractionsave(err_act)
|
|
|
|
call psb_erractionsave(err_act)
|
|
|
|
|
|
|
|
|
|
|
|
ictxt=psb_cd_get_context(desc_a)
|
|
|
|
ictxt=psb_cd_get_context(desc_a)
|
|
|
|
|
|
|
|
debug_unit = psb_get_debug_unit()
|
|
|
|
|
|
|
|
debug_level = psb_get_debug_level()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
! check on blacs grid
|
|
|
|
! check on blacs grid
|
|
|
|
call psb_info(ictxt, me, np)
|
|
|
|
call psb_info(ictxt, me, np)
|
|
|
@ -321,20 +323,24 @@ subroutine psb_zscatterv(globx, locx, desc_a, info, iroot)
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
|
|
if (present(iroot)) then
|
|
|
|
if (present(iroot)) then
|
|
|
|
root = iroot
|
|
|
|
root = iroot
|
|
|
|
if((root < -1).or.(root > np)) then
|
|
|
|
if((root < -1).or.(root > np)) then
|
|
|
|
info=30
|
|
|
|
info=30
|
|
|
|
int_err(1:2)=(/5,root/)
|
|
|
|
int_err(1:2)=(/5,root/)
|
|
|
|
call psb_errpush(info,name,i_err=int_err)
|
|
|
|
call psb_errpush(info,name,i_err=int_err)
|
|
|
|
goto 9999
|
|
|
|
goto 9999
|
|
|
|
end if
|
|
|
|
end if
|
|
|
|
else
|
|
|
|
else
|
|
|
|
root = -1
|
|
|
|
root = -1
|
|
|
|
end if
|
|
|
|
end if
|
|
|
|
|
|
|
|
|
|
|
|
call psb_get_mpicomm(ictxt,icomm)
|
|
|
|
call psb_get_mpicomm(ictxt,icomm)
|
|
|
|
call psb_get_rank(myrank,ictxt,me)
|
|
|
|
call psb_get_rank(myrank,ictxt,me)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
iglobx = 1
|
|
|
|
|
|
|
|
jglobx = 1
|
|
|
|
|
|
|
|
ilocx = 1
|
|
|
|
|
|
|
|
jlocx = 1
|
|
|
|
lda_globx = size(globx)
|
|
|
|
lda_globx = size(globx)
|
|
|
|
lda_locx = size(locx)
|
|
|
|
lda_locx = size(locx)
|
|
|
|
|
|
|
|
|
|
|
@ -342,28 +348,27 @@ subroutine psb_zscatterv(globx, locx, desc_a, info, iroot)
|
|
|
|
n = psb_cd_get_global_cols(desc_a)
|
|
|
|
n = psb_cd_get_global_cols(desc_a)
|
|
|
|
|
|
|
|
|
|
|
|
k = 1
|
|
|
|
k = 1
|
|
|
|
|
|
|
|
|
|
|
|
! there should be a global check on k here!!!
|
|
|
|
! there should be a global check on k here!!!
|
|
|
|
|
|
|
|
|
|
|
|
call psb_chkglobvect(m,n,size(globx),iglobx,jglobx,desc_a,info)
|
|
|
|
call psb_chkglobvect(m,n,size(globx),iglobx,jglobx,desc_a,info)
|
|
|
|
if (info == 0) &
|
|
|
|
if (info == 0) &
|
|
|
|
& call psb_chkvect(m,n,size(locx),ilocx,jlocx,desc_a,info,ilx,jlx)
|
|
|
|
& call psb_chkvect(m,n,size(locx),ilocx,jlocx,desc_a,info,ilx,jlx)
|
|
|
|
if(info /= 0) then
|
|
|
|
if(info /= 0) then
|
|
|
|
info=4010
|
|
|
|
info=4010
|
|
|
|
ch_err='psb_chk(glob)vect'
|
|
|
|
ch_err='psb_chk(glob)vect'
|
|
|
|
call psb_errpush(info,name,a_err=ch_err)
|
|
|
|
call psb_errpush(info,name,a_err=ch_err)
|
|
|
|
goto 9999
|
|
|
|
goto 9999
|
|
|
|
end if
|
|
|
|
end if
|
|
|
|
|
|
|
|
|
|
|
|
if ((ilx /= 1).or.(iglobx /= 1)) then
|
|
|
|
if ((ilx /= 1).or.(iglobx /= 1)) then
|
|
|
|
info=3040
|
|
|
|
info=3040
|
|
|
|
call psb_errpush(info,name)
|
|
|
|
call psb_errpush(info,name)
|
|
|
|
goto 9999
|
|
|
|
goto 9999
|
|
|
|
end if
|
|
|
|
end if
|
|
|
|
|
|
|
|
|
|
|
|
nrow=psb_cd_get_local_rows(desc_a)
|
|
|
|
nrow = psb_cd_get_local_rows(desc_a)
|
|
|
|
|
|
|
|
|
|
|
|
if(root == -1) then
|
|
|
|
if ((root == -1).or.(np==1)) then
|
|
|
|
! extract my chunk
|
|
|
|
! extract my chunk
|
|
|
|
do i=1, nrow
|
|
|
|
do i=1, nrow
|
|
|
|
idx=desc_a%loc_to_glob(i)
|
|
|
|
idx=desc_a%loc_to_glob(i)
|
|
|
@ -371,41 +376,49 @@ subroutine psb_zscatterv(globx, locx, desc_a, info, iroot)
|
|
|
|
end do
|
|
|
|
end do
|
|
|
|
else
|
|
|
|
else
|
|
|
|
call psb_get_rank(rootrank,ictxt,root)
|
|
|
|
call psb_get_rank(rootrank,ictxt,root)
|
|
|
|
end if
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
! root has to gather size information
|
|
|
|
! root has to gather size information
|
|
|
|
allocate(displ(np),all_dim(np))
|
|
|
|
allocate(displ(np),all_dim(np))
|
|
|
|
call mpi_gather(nrow,1,mpi_integer,all_dim,&
|
|
|
|
|
|
|
|
& np,mpi_integer,rootrank,icomm,info)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
displ(1)=1
|
|
|
|
call mpi_gather(nrow,1,mpi_integer,all_dim,&
|
|
|
|
displ(2:)=all_dim(1:np-1)+1
|
|
|
|
& 1,mpi_integer,rootrank,icomm,info)
|
|
|
|
|
|
|
|
|
|
|
|
! root has to gather loc_glob from each process
|
|
|
|
if(me == root) then
|
|
|
|
if(me == root) then
|
|
|
|
displ(1)=0
|
|
|
|
allocate(l_t_g_all(sum(all_dim)),scatterv(sum(all_dim)))
|
|
|
|
do i=2,np
|
|
|
|
end if
|
|
|
|
displ(i)=displ(i-1) + all_dim(i-1)
|
|
|
|
|
|
|
|
end do
|
|
|
|
|
|
|
|
if (debug_level >= psb_debug_inner_) then
|
|
|
|
|
|
|
|
write(debug_unit,*) me,' ',trim(name),' displ:',displ(1:np), &
|
|
|
|
|
|
|
|
&' dim',all_dim(1:np), sum(all_dim)
|
|
|
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
! root has to gather loc_glob from each process
|
|
|
|
|
|
|
|
allocate(l_t_g_all(sum(all_dim)),scatterv(sum(all_dim)))
|
|
|
|
|
|
|
|
end if
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
call mpi_gatherv(desc_a%loc_to_glob,nrow,&
|
|
|
|
|
|
|
|
& mpi_integer,l_t_g_all,all_dim,&
|
|
|
|
|
|
|
|
& displ,mpi_integer,rootrank,icomm,info)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
! prepare vector to scatter
|
|
|
|
|
|
|
|
if (me == root) then
|
|
|
|
|
|
|
|
do i=1,np
|
|
|
|
|
|
|
|
pos=displ(i)
|
|
|
|
|
|
|
|
do j=1, all_dim(i)
|
|
|
|
|
|
|
|
idx=l_t_g_all(pos+j)
|
|
|
|
|
|
|
|
scatterv(pos+j)=globx(idx)
|
|
|
|
|
|
|
|
|
|
|
|
call mpi_gatherv(desc_a%loc_to_glob,nrow,&
|
|
|
|
end do
|
|
|
|
& mpi_integer,l_t_g_all,all_dim,&
|
|
|
|
|
|
|
|
& displ,mpi_integer,rootrank,icomm,info)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
! prepare vector to scatter
|
|
|
|
|
|
|
|
if(me == root) then
|
|
|
|
|
|
|
|
do i=1,np
|
|
|
|
|
|
|
|
pos=displ(i)
|
|
|
|
|
|
|
|
do j=1, all_dim(i)
|
|
|
|
|
|
|
|
idx=l_t_g_all(pos+j-1)
|
|
|
|
|
|
|
|
scatterv(pos+j-1)=globx(idx)
|
|
|
|
|
|
|
|
end do
|
|
|
|
end do
|
|
|
|
end do
|
|
|
|
end if
|
|
|
|
end if
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
call mpi_scatterv(scatterv,all_dim,displ,&
|
|
|
|
call mpi_scatterv(scatterv,all_dim,displ,&
|
|
|
|
& mpi_double_precision,locx,nrow,&
|
|
|
|
& mpi_double_complex,locx,nrow,&
|
|
|
|
& mpi_double_precision,rootrank,icomm,info)
|
|
|
|
& mpi_double_complex,rootrank,icomm,info)
|
|
|
|
|
|
|
|
|
|
|
|
deallocate(all_dim, l_t_g_all, displ, scatterv)
|
|
|
|
if (me==root) deallocate(all_dim, l_t_g_all, displ, scatterv)
|
|
|
|
|
|
|
|
end if
|
|
|
|
|
|
|
|
|
|
|
|
call psb_erractionrestore(err_act)
|
|
|
|
call psb_erractionrestore(err_act)
|
|
|
|
return
|
|
|
|
return
|
|
|
|