|
|
|
@ -28,7 +28,7 @@
|
|
|
|
|
!!$ POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
!!$
|
|
|
|
|
!!$
|
|
|
|
|
! File: psbdcoins.f90
|
|
|
|
|
! File: psbzcoins.f90
|
|
|
|
|
! Subroutine:
|
|
|
|
|
! Parameters:
|
|
|
|
|
subroutine psb_zcoins(nz,ia,ja,val,a,gtl,imin,imax,jmin,jmax,info)
|
|
|
|
@ -50,7 +50,7 @@ subroutine psb_zcoins(nz,ia,ja,val,a,gtl,imin,imax,jmin,jmax,info)
|
|
|
|
|
character(len=5) :: ufida
|
|
|
|
|
integer :: i,j,ir,ic,nr,nc, ng, nza, isza,spstate, nnz,&
|
|
|
|
|
& ip1, nzl, err_act, int_err(5), iupd
|
|
|
|
|
logical, parameter :: debug=.true.
|
|
|
|
|
logical, parameter :: debug=.false.
|
|
|
|
|
character(len=20) :: name, ch_err
|
|
|
|
|
|
|
|
|
|
name='psb_zcoins'
|
|
|
|
@ -91,6 +91,7 @@ subroutine psb_zcoins(nz,ia,ja,val,a,gtl,imin,imax,jmin,jmax,info)
|
|
|
|
|
spstate = psb_sp_getifld(psb_state_,a,info)
|
|
|
|
|
|
|
|
|
|
select case(spstate)
|
|
|
|
|
|
|
|
|
|
case(psb_spmat_bld_)
|
|
|
|
|
if ((ufida /= 'COO').and.(ufida/='COI')) then
|
|
|
|
|
info = 134
|
|
|
|
@ -116,7 +117,7 @@ subroutine psb_zcoins(nz,ia,ja,val,a,gtl,imin,imax,jmin,jmax,info)
|
|
|
|
|
goto 9999
|
|
|
|
|
endif
|
|
|
|
|
endif
|
|
|
|
|
call psb_inner_ins(nz,ia,ja,val,nza,a%ia1,a%ia2,a%aspk,gtl,&
|
|
|
|
|
call psb_inner_ins(nz,ia,ja,val,nza,a%ia1,a%ia2,a%aspk,gtl,ng,&
|
|
|
|
|
& imin,imax,jmin,jmax,info)
|
|
|
|
|
if(info.ne.izero) then
|
|
|
|
|
info=4010
|
|
|
|
@ -129,10 +130,10 @@ subroutine psb_zcoins(nz,ia,ja,val,a,gtl,imin,imax,jmin,jmax,info)
|
|
|
|
|
write(0,*) 'PSB_COINS: insert discarded items '
|
|
|
|
|
end if
|
|
|
|
|
end if
|
|
|
|
|
if ((nza - a%infoa(psb_nnz_)) /= nz) then
|
|
|
|
|
a%infoa(psb_del_bnd_) = nza
|
|
|
|
|
if ((nza - psb_sp_getifld(psb_nnz_,a,info)) /= nz) then
|
|
|
|
|
call psb_sp_setifld(nza,psb_del_bnd_,a,info)
|
|
|
|
|
endif
|
|
|
|
|
a%infoa(psb_nnz_) = nza
|
|
|
|
|
call psb_sp_setifld(nza,psb_nnz_,a,info)
|
|
|
|
|
|
|
|
|
|
case(psb_spmat_upd_)
|
|
|
|
|
|
|
|
|
@ -143,8 +144,12 @@ subroutine psb_zcoins(nz,ia,ja,val,a,gtl,imin,imax,jmin,jmax,info)
|
|
|
|
|
nzl = psb_sp_getifld(psb_del_bnd_,a,info)
|
|
|
|
|
nza = a%ia2(ip1+psb_nnz_)
|
|
|
|
|
|
|
|
|
|
call psb_inner_upd(nz,ia,ja,val,nza,a%aspk,gtl,&
|
|
|
|
|
nza = a%ia2(ip1+psb_nnz_)
|
|
|
|
|
nzl = a%infoa(psb_del_bnd_)
|
|
|
|
|
|
|
|
|
|
call psb_inner_upd(nz,ia,ja,val,nza,a%aspk,gtl,ng,&
|
|
|
|
|
& imin,imax,jmin,jmax,nzl,info)
|
|
|
|
|
|
|
|
|
|
if(info.ne.izero) then
|
|
|
|
|
info=4010
|
|
|
|
|
ch_err='psb_inner_upd'
|
|
|
|
@ -156,19 +161,37 @@ subroutine psb_zcoins(nz,ia,ja,val,a,gtl,imin,imax,jmin,jmax,info)
|
|
|
|
|
write(0,*) 'PSB_COINS: update discarded items '
|
|
|
|
|
end if
|
|
|
|
|
end if
|
|
|
|
|
|
|
|
|
|
a%ia2(ip1+psb_nnz_) = nza
|
|
|
|
|
|
|
|
|
|
if (debug) write(0,*) 'From COINS(UPD) : NZA:',nza
|
|
|
|
|
|
|
|
|
|
case (psb_upd_dflt_, psb_upd_srch_)
|
|
|
|
|
write(0,*) 'Default & search inner update to be implemented'
|
|
|
|
|
info = 2230
|
|
|
|
|
call psb_errpush(info,name)
|
|
|
|
|
goto 9999
|
|
|
|
|
|
|
|
|
|
select case(toupper(a%fida))
|
|
|
|
|
case ('CSR')
|
|
|
|
|
!!$ write(0,*) 'Calling csr_inner_upd'
|
|
|
|
|
call csr_inner_upd(nz,ia,ja,val,nza,a,gtl,ng,&
|
|
|
|
|
& imin,imax,jmin,jmax,nzl,info)
|
|
|
|
|
!!$ write(0,*) 'From csr_inner_upd:',info
|
|
|
|
|
case ('COO')
|
|
|
|
|
call coo_inner_upd(nz,ia,ja,val,nza,a,gtl,ng,&
|
|
|
|
|
& imin,imax,jmin,jmax,nzl,info)
|
|
|
|
|
|
|
|
|
|
case default
|
|
|
|
|
|
|
|
|
|
info = 2230
|
|
|
|
|
call psb_errpush(info,name)
|
|
|
|
|
goto 9999
|
|
|
|
|
end select
|
|
|
|
|
|
|
|
|
|
case default
|
|
|
|
|
|
|
|
|
|
info = 2231
|
|
|
|
|
call psb_errpush(info,name)
|
|
|
|
|
goto 9999
|
|
|
|
|
end select
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case default
|
|
|
|
|
info = 2232
|
|
|
|
|
call psb_errpush(info,name)
|
|
|
|
@ -188,10 +211,12 @@ subroutine psb_zcoins(nz,ia,ja,val,a,gtl,imin,imax,jmin,jmax,info)
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
contains
|
|
|
|
|
subroutine psb_inner_upd(nz,ia,ja,val,nza,aspk,gtl,imin,imax,jmin,jmax,nzl,info)
|
|
|
|
|
|
|
|
|
|
subroutine psb_inner_upd(nz,ia,ja,val,nza,aspk,gtl,ng,&
|
|
|
|
|
& imin,imax,jmin,jmax,nzl,info)
|
|
|
|
|
implicit none
|
|
|
|
|
|
|
|
|
|
integer, intent(in) :: nz, imin,imax,jmin,jmax,nzl
|
|
|
|
|
integer, intent(in) :: nz, imin,imax,jmin,jmax,nzl,ng
|
|
|
|
|
integer, intent(in) :: ia(*),ja(*),gtl(*)
|
|
|
|
|
integer, intent(inout) :: nza
|
|
|
|
|
complex(kind(1.d0)), intent(in) :: val(*)
|
|
|
|
@ -199,8 +224,6 @@ contains
|
|
|
|
|
integer, intent(out) :: info
|
|
|
|
|
integer :: i,ir,ic
|
|
|
|
|
|
|
|
|
|
info = 0
|
|
|
|
|
|
|
|
|
|
if (nza >= nzl) then
|
|
|
|
|
do i=1, nz
|
|
|
|
|
nza = nza + 1
|
|
|
|
@ -223,11 +246,11 @@ contains
|
|
|
|
|
|
|
|
|
|
end subroutine psb_inner_upd
|
|
|
|
|
|
|
|
|
|
subroutine psb_inner_ins(nz,ia,ja,val,nza,ia1,ia2,aspk,gtl,&
|
|
|
|
|
subroutine psb_inner_ins(nz,ia,ja,val,nza,ia1,ia2,aspk,gtl,ng,&
|
|
|
|
|
& imin,imax,jmin,jmax,info)
|
|
|
|
|
implicit none
|
|
|
|
|
|
|
|
|
|
integer, intent(in) :: nz, imin,imax,jmin,jmax
|
|
|
|
|
integer, intent(in) :: nz, imin,imax,jmin,jmax,ng
|
|
|
|
|
integer, intent(in) :: ia(*),ja(*),gtl(*)
|
|
|
|
|
integer, intent(inout) :: nza,ia1(*),ia2(*)
|
|
|
|
|
complex(kind(1.d0)), intent(in) :: val(*)
|
|
|
|
@ -254,5 +277,215 @@ contains
|
|
|
|
|
end do
|
|
|
|
|
|
|
|
|
|
end subroutine psb_inner_ins
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
subroutine csr_inner_upd(nz,ia,ja,val,nza,a,gtl,ng,&
|
|
|
|
|
& imin,imax,jmin,jmax,nzl,info)
|
|
|
|
|
implicit none
|
|
|
|
|
|
|
|
|
|
type(psb_zspmat_type), intent(inout) :: a
|
|
|
|
|
integer, intent(in) :: nz, imin,imax,jmin,jmax,nzl,ng
|
|
|
|
|
integer, intent(in) :: ia(*),ja(*),gtl(*)
|
|
|
|
|
integer, intent(inout) :: nza
|
|
|
|
|
complex(kind(1.d0)), intent(in) :: val(*)
|
|
|
|
|
integer, intent(out) :: info
|
|
|
|
|
integer :: i,ir,ic,check_flag, ilr, ilc, ip, &
|
|
|
|
|
& i1,i2,nc,lb,ub,m,nnz,dupl
|
|
|
|
|
|
|
|
|
|
info = 0
|
|
|
|
|
|
|
|
|
|
dupl = psb_sp_getifld(psb_dupl_,a,info)
|
|
|
|
|
|
|
|
|
|
select case(dupl)
|
|
|
|
|
case(psb_dupl_ovwrt_,psb_dupl_err_)
|
|
|
|
|
! Overwrite.
|
|
|
|
|
! Cannot test for error, should have been caught earlier.
|
|
|
|
|
|
|
|
|
|
ilr = -1
|
|
|
|
|
ilc = -1
|
|
|
|
|
do i=1, nz
|
|
|
|
|
ir = ia(i)
|
|
|
|
|
ic = ja(i)
|
|
|
|
|
if ((ir >=1).and.(ir<=ng).and.(ic>=1).and.(ic<=ng)) then
|
|
|
|
|
ir = gtl(ir)
|
|
|
|
|
ic = gtl(ic)
|
|
|
|
|
i1 = a%ia2(ir)
|
|
|
|
|
i2 = a%ia2(ir+1)
|
|
|
|
|
nc=i2-i1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (.true.) then
|
|
|
|
|
call issrch(ip,ic,nc,a%ia1(i1:i2-1))
|
|
|
|
|
if (ip>0) then
|
|
|
|
|
a%aspk(i1+ip-1) = val(i)
|
|
|
|
|
else
|
|
|
|
|
write(0,*)'Was searching ',ic,' in: ',i1,i2,' : ',a%ia1(i1:i2-1)
|
|
|
|
|
info = -1
|
|
|
|
|
return
|
|
|
|
|
end if
|
|
|
|
|
|
|
|
|
|
else
|
|
|
|
|
!!$
|
|
|
|
|
ip = -1
|
|
|
|
|
lb = i1
|
|
|
|
|
ub = i2-1
|
|
|
|
|
do
|
|
|
|
|
if (lb > ub) exit
|
|
|
|
|
m = (lb+ub)/2
|
|
|
|
|
!!$ write(0,*) 'Debug: ',lb,m,ub
|
|
|
|
|
if (ic == a%ia1(m)) then
|
|
|
|
|
ip = m
|
|
|
|
|
lb = ub + 1
|
|
|
|
|
else if (ic < a%ia1(m)) then
|
|
|
|
|
ub = m-1
|
|
|
|
|
else
|
|
|
|
|
lb = m + 1
|
|
|
|
|
end if
|
|
|
|
|
enddo
|
|
|
|
|
|
|
|
|
|
if (ip>0) then
|
|
|
|
|
a%aspk(ip) = val(i)
|
|
|
|
|
else
|
|
|
|
|
write(0,*)'Was searching ',ic,' in: ',i1,i2,' : ',a%ia1(i1:i2-1)
|
|
|
|
|
info = -1
|
|
|
|
|
return
|
|
|
|
|
end if
|
|
|
|
|
|
|
|
|
|
end if
|
|
|
|
|
end if
|
|
|
|
|
end do
|
|
|
|
|
|
|
|
|
|
case(psb_dupl_add_)
|
|
|
|
|
! Add
|
|
|
|
|
ilr = -1
|
|
|
|
|
ilc = -1
|
|
|
|
|
do i=1, nz
|
|
|
|
|
ir = ia(i)
|
|
|
|
|
ic = ja(i)
|
|
|
|
|
if ((ir >=1).and.(ir<=ng).and.(ic>=1).and.(ic<=ng)) then
|
|
|
|
|
ir = gtl(ir)
|
|
|
|
|
ic = gtl(ic)
|
|
|
|
|
i1 = a%ia2(ir)
|
|
|
|
|
i2 = a%ia2(ir+1)
|
|
|
|
|
nc = i2-i1
|
|
|
|
|
call issrch(ip,ic,nc,a%ia1(i1:i2-1))
|
|
|
|
|
if (ip>0) then
|
|
|
|
|
a%aspk(i1+ip-1) = a%aspk(i1+ip-1) + val(i)
|
|
|
|
|
else
|
|
|
|
|
info = -2
|
|
|
|
|
return
|
|
|
|
|
end if
|
|
|
|
|
end if
|
|
|
|
|
end do
|
|
|
|
|
|
|
|
|
|
case default
|
|
|
|
|
info = -3
|
|
|
|
|
write(0,*) 'Duplicate handling: ',dupl
|
|
|
|
|
end select
|
|
|
|
|
end subroutine csr_inner_upd
|
|
|
|
|
|
|
|
|
|
subroutine coo_inner_upd(nz,ia,ja,val,nza,a,gtl,ng,&
|
|
|
|
|
& imin,imax,jmin,jmax,nzl,info)
|
|
|
|
|
implicit none
|
|
|
|
|
|
|
|
|
|
type(psb_zspmat_type), intent(inout) :: a
|
|
|
|
|
integer, intent(in) :: nz, imin,imax,jmin,jmax,nzl,ng
|
|
|
|
|
integer, intent(in) :: ia(*),ja(*),gtl(*)
|
|
|
|
|
integer, intent(inout) :: nza
|
|
|
|
|
complex(kind(1.d0)), intent(in) :: val(*)
|
|
|
|
|
integer, intent(out) :: info
|
|
|
|
|
integer :: i,ir,ic,check_flag, ilr, ilc, ip, &
|
|
|
|
|
& i1,i2,nc,lb,ub,m,nnz,dupl,isrt
|
|
|
|
|
|
|
|
|
|
info = 0
|
|
|
|
|
|
|
|
|
|
dupl = psb_sp_getifld(psb_dupl_,a,info)
|
|
|
|
|
|
|
|
|
|
if (psb_sp_getifld(psb_srtd_,a,info) /= psb_isrtdcoo_) then
|
|
|
|
|
info = -4
|
|
|
|
|
return
|
|
|
|
|
end if
|
|
|
|
|
|
|
|
|
|
ilr = -1
|
|
|
|
|
ilc = -1
|
|
|
|
|
nnz = psb_sp_getifld(psb_nnz_,a,info)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
select case(dupl)
|
|
|
|
|
case(psb_dupl_ovwrt_,psb_dupl_err_)
|
|
|
|
|
! Overwrite.
|
|
|
|
|
! Cannot test for error, should have been caught earlier.
|
|
|
|
|
do i=1, nz
|
|
|
|
|
ir = ia(i)
|
|
|
|
|
ic = ja(i)
|
|
|
|
|
if ((ir >=1).and.(ir<=ng).and.(ic>=1).and.(ic<=ng)) then
|
|
|
|
|
ir = gtl(ir)
|
|
|
|
|
ic = gtl(ic)
|
|
|
|
|
if (ir /= ilr) then
|
|
|
|
|
call ibsrch(i1,ir,nnz,a%ia1)
|
|
|
|
|
i2 = i1
|
|
|
|
|
do
|
|
|
|
|
if (i2+1 > nnz) exit
|
|
|
|
|
if (a%ia1(i2+1) /= a%ia1(i2)) exit
|
|
|
|
|
i2 = i2 + 1
|
|
|
|
|
end do
|
|
|
|
|
do
|
|
|
|
|
if (i1-1 < 1) exit
|
|
|
|
|
if (a%ia1(i1-1) /= a%ia1(i1)) exit
|
|
|
|
|
i1 = i1 - 1
|
|
|
|
|
end do
|
|
|
|
|
ilr = ir
|
|
|
|
|
end if
|
|
|
|
|
nc = i2-i1+1
|
|
|
|
|
call issrch(ip,ic,nc,a%ia2(i1:i2))
|
|
|
|
|
if (ip>0) then
|
|
|
|
|
a%aspk(i1+ip-1) = val(i)
|
|
|
|
|
else
|
|
|
|
|
info = -2
|
|
|
|
|
return
|
|
|
|
|
end if
|
|
|
|
|
end if
|
|
|
|
|
end do
|
|
|
|
|
case(psb_dupl_add_)
|
|
|
|
|
! Add
|
|
|
|
|
do i=1, nz
|
|
|
|
|
ir = ia(i)
|
|
|
|
|
ic = ja(i)
|
|
|
|
|
if ((ir >=1).and.(ir<=ng).and.(ic>=1).and.(ic<=ng)) then
|
|
|
|
|
ir = gtl(ir)
|
|
|
|
|
ic = gtl(ic)
|
|
|
|
|
if (ir /= ilr) then
|
|
|
|
|
call ibsrch(i1,ir,nnz,a%ia1)
|
|
|
|
|
i2 = i1
|
|
|
|
|
do
|
|
|
|
|
if (i2+1 > nnz) exit
|
|
|
|
|
if (a%ia1(i2+1) /= a%ia1(i2)) exit
|
|
|
|
|
i2 = i2 + 1
|
|
|
|
|
end do
|
|
|
|
|
do
|
|
|
|
|
if (i1-1 < 1) exit
|
|
|
|
|
if (a%ia1(i1-1) /= a%ia1(i1)) exit
|
|
|
|
|
i1 = i1 - 1
|
|
|
|
|
end do
|
|
|
|
|
ilr = ir
|
|
|
|
|
end if
|
|
|
|
|
nc = i2-i1+1
|
|
|
|
|
call issrch(ip,ic,nc,a%ia2(i1:i2))
|
|
|
|
|
if (ip>0) then
|
|
|
|
|
a%aspk(i1+ip-1) = a%aspk(i1+ip-1) + val(i)
|
|
|
|
|
else
|
|
|
|
|
info = -2
|
|
|
|
|
return
|
|
|
|
|
end if
|
|
|
|
|
end if
|
|
|
|
|
end do
|
|
|
|
|
|
|
|
|
|
case default
|
|
|
|
|
info = -3
|
|
|
|
|
write(0,*) 'Duplicate handling: ',dupl
|
|
|
|
|
end select
|
|
|
|
|
|
|
|
|
|
end subroutine coo_inner_upd
|
|
|
|
|
|
|
|
|
|
end subroutine psb_zcoins
|
|
|
|
|
|
|
|
|
|