diff --git a/base/serial/impl/psb_c_coo_impl.f90 b/base/serial/impl/psb_c_coo_impl.f90 index c85b6aa4..6d757d01 100644 --- a/base/serial/impl/psb_c_coo_impl.f90 +++ b/base/serial/impl/psb_c_coo_impl.f90 @@ -2630,8 +2630,12 @@ subroutine psb_c_coo_csput(nz,ia,ja,val,a,imin,imax,jmin,jmax,info,gtl) ! Build phase. Must handle reallocations in a sensible way. if (isza < (nza+nz)) then call a%reallocate(max(nza+nz,int(1.5*isza))) - isza = a%get_size() endif + isza = a%get_size() + if (isza < (nza+nz)) then + info = psb_err_alloc_dealloc_; call psb_errpush(info,name) + goto 9999 + end if call psb_inner_ins(nz,ia,ja,val,nza,a%ia,a%ja,a%val,isza,& & imin,imax,jmin,jmax,info,gtl) @@ -2696,10 +2700,6 @@ contains ic = gtl(ic) if ((ir >=imin).and.(ir<=imax).and.(ic>=jmin).and.(ic<=jmax)) then nza = nza + 1 - if (nza > maxsz) then - info = -91 - return - endif ia1(nza) = ir ia2(nza) = ic aspk(nza) = val(i) @@ -2713,10 +2713,6 @@ contains ic = ja(i) if ((ir >=imin).and.(ir<=imax).and.(ic>=jmin).and.(ic<=jmax)) then nza = nza + 1 - if (nza > maxsz) then - info = -92 - return - endif ia1(nza) = ir ia2(nza) = ic aspk(nza) = val(i) diff --git a/base/serial/impl/psb_d_coo_impl.f90 b/base/serial/impl/psb_d_coo_impl.f90 index 57636a06..819c6c95 100644 --- a/base/serial/impl/psb_d_coo_impl.f90 +++ b/base/serial/impl/psb_d_coo_impl.f90 @@ -2630,8 +2630,12 @@ subroutine psb_d_coo_csput(nz,ia,ja,val,a,imin,imax,jmin,jmax,info,gtl) ! Build phase. Must handle reallocations in a sensible way. if (isza < (nza+nz)) then call a%reallocate(max(nza+nz,int(1.5*isza))) - isza = a%get_size() endif + isza = a%get_size() + if (isza < (nza+nz)) then + info = psb_err_alloc_dealloc_; call psb_errpush(info,name) + goto 9999 + end if call psb_inner_ins(nz,ia,ja,val,nza,a%ia,a%ja,a%val,isza,& & imin,imax,jmin,jmax,info,gtl) @@ -2676,10 +2680,10 @@ contains implicit none integer(psb_ipk_), intent(in) :: nz, imin,imax,jmin,jmax,maxsz - integer(psb_ipk_), intent(in) :: ia(*),ja(*) - integer(psb_ipk_), intent(inout) :: nza,ia1(*),ia2(*) - real(psb_dpk_), intent(in) :: val(*) - real(psb_dpk_), intent(inout) :: aspk(*) + integer(psb_ipk_), intent(in) :: ia(:),ja(:) + integer(psb_ipk_), intent(inout) :: nza,ia1(:),ia2(:) + real(psb_dpk_), intent(in) :: val(:) + real(psb_dpk_), intent(inout) :: aspk(:) integer(psb_ipk_), intent(out) :: info integer(psb_ipk_), intent(in), optional :: gtl(:) integer(psb_ipk_) :: i,ir,ic,ng @@ -2696,10 +2700,6 @@ contains ic = gtl(ic) if ((ir >=imin).and.(ir<=imax).and.(ic>=jmin).and.(ic<=jmax)) then nza = nza + 1 -!!$ if (nza > maxsz) then -!!$ info = -91 -!!$ return -!!$ endif ia1(nza) = ir ia2(nza) = ic aspk(nza) = val(i) @@ -2713,10 +2713,6 @@ contains ic = ja(i) if ((ir >=imin).and.(ir<=imax).and.(ic>=jmin).and.(ic<=jmax)) then nza = nza + 1 -!!$ if (nza > maxsz) then -!!$ info = -92 -!!$ return -!!$ endif ia1(nza) = ir ia2(nza) = ic aspk(nza) = val(i) diff --git a/base/serial/impl/psb_s_coo_impl.f90 b/base/serial/impl/psb_s_coo_impl.f90 index 630892b8..8c84691a 100644 --- a/base/serial/impl/psb_s_coo_impl.f90 +++ b/base/serial/impl/psb_s_coo_impl.f90 @@ -2630,8 +2630,12 @@ subroutine psb_s_coo_csput(nz,ia,ja,val,a,imin,imax,jmin,jmax,info,gtl) ! Build phase. Must handle reallocations in a sensible way. if (isza < (nza+nz)) then call a%reallocate(max(nza+nz,int(1.5*isza))) - isza = a%get_size() endif + isza = a%get_size() + if (isza < (nza+nz)) then + info = psb_err_alloc_dealloc_; call psb_errpush(info,name) + goto 9999 + end if call psb_inner_ins(nz,ia,ja,val,nza,a%ia,a%ja,a%val,isza,& & imin,imax,jmin,jmax,info,gtl) @@ -2696,10 +2700,6 @@ contains ic = gtl(ic) if ((ir >=imin).and.(ir<=imax).and.(ic>=jmin).and.(ic<=jmax)) then nza = nza + 1 - if (nza > maxsz) then - info = -91 - return - endif ia1(nza) = ir ia2(nza) = ic aspk(nza) = val(i) @@ -2713,10 +2713,6 @@ contains ic = ja(i) if ((ir >=imin).and.(ir<=imax).and.(ic>=jmin).and.(ic<=jmax)) then nza = nza + 1 - if (nza > maxsz) then - info = -92 - return - endif ia1(nza) = ir ia2(nza) = ic aspk(nza) = val(i) diff --git a/base/serial/impl/psb_z_coo_impl.f90 b/base/serial/impl/psb_z_coo_impl.f90 index ddd2f78c..c14ade32 100644 --- a/base/serial/impl/psb_z_coo_impl.f90 +++ b/base/serial/impl/psb_z_coo_impl.f90 @@ -2630,8 +2630,12 @@ subroutine psb_z_coo_csput(nz,ia,ja,val,a,imin,imax,jmin,jmax,info,gtl) ! Build phase. Must handle reallocations in a sensible way. if (isza < (nza+nz)) then call a%reallocate(max(nza+nz,int(1.5*isza))) - isza = a%get_size() endif + isza = a%get_size() + if (isza < (nza+nz)) then + info = psb_err_alloc_dealloc_; call psb_errpush(info,name) + goto 9999 + end if call psb_inner_ins(nz,ia,ja,val,nza,a%ia,a%ja,a%val,isza,& & imin,imax,jmin,jmax,info,gtl) @@ -2696,10 +2700,6 @@ contains ic = gtl(ic) if ((ir >=imin).and.(ir<=imax).and.(ic>=jmin).and.(ic<=jmax)) then nza = nza + 1 - if (nza > maxsz) then - info = -91 - return - endif ia1(nza) = ir ia2(nza) = ic aspk(nza) = val(i) @@ -2713,10 +2713,6 @@ contains ic = ja(i) if ((ir >=imin).and.(ir<=imax).and.(ic>=jmin).and.(ic<=jmax)) then nza = nza + 1 - if (nza > maxsz) then - info = -92 - return - endif ia1(nza) = ir ia2(nza) = ic aspk(nza) = val(i)