From 798cd352b23bd0676ee26d18303147d4943b52e5 Mon Sep 17 00:00:00 2001 From: Salvatore Filippone Date: Wed, 30 Sep 2015 08:38:57 +0000 Subject: [PATCH] psblas: base/serial/impl/psb_c_coo_impl.f90 base/serial/impl/psb_c_csc_impl.f90 base/serial/impl/psb_c_csr_impl.f90 base/serial/impl/psb_d_coo_impl.f90 base/serial/impl/psb_d_csc_impl.f90 base/serial/impl/psb_d_csr_impl.f90 base/serial/impl/psb_s_coo_impl.f90 base/serial/impl/psb_s_csc_impl.f90 base/serial/impl/psb_s_csr_impl.f90 base/serial/impl/psb_z_coo_impl.f90 base/serial/impl/psb_z_csc_impl.f90 base/serial/impl/psb_z_csr_impl.f90 Make sure allocation is at least size 1. --- base/serial/impl/psb_c_coo_impl.f90 | 9 +++++---- base/serial/impl/psb_c_csc_impl.f90 | 11 ++++++----- base/serial/impl/psb_c_csr_impl.f90 | 8 ++++---- base/serial/impl/psb_d_coo_impl.f90 | 9 +++++---- base/serial/impl/psb_d_csc_impl.f90 | 11 ++++++----- base/serial/impl/psb_d_csr_impl.f90 | 8 ++++---- base/serial/impl/psb_s_coo_impl.f90 | 9 +++++---- base/serial/impl/psb_s_csc_impl.f90 | 11 ++++++----- base/serial/impl/psb_s_csr_impl.f90 | 8 ++++---- base/serial/impl/psb_z_coo_impl.f90 | 9 +++++---- base/serial/impl/psb_z_csc_impl.f90 | 11 ++++++----- base/serial/impl/psb_z_csr_impl.f90 | 8 ++++---- 12 files changed, 60 insertions(+), 52 deletions(-) diff --git a/base/serial/impl/psb_c_coo_impl.f90 b/base/serial/impl/psb_c_coo_impl.f90 index 4c697aea..2325f96b 100644 --- a/base/serial/impl/psb_c_coo_impl.f90 +++ b/base/serial/impl/psb_c_coo_impl.f90 @@ -193,14 +193,15 @@ subroutine psb_c_coo_reallocate_nz(nz,a) implicit none integer(psb_ipk_), intent(in) :: nz class(psb_c_coo_sparse_mat), intent(inout) :: a - integer(psb_ipk_) :: err_act, info + integer(psb_ipk_) :: err_act, info, nz_ integer(psb_ipk_) :: ierr(5) character(len=20) :: name='c_coo_reallocate_nz' logical, parameter :: debug=.false. call psb_erractionsave(err_act) - call psb_realloc(nz,a%ia,a%ja,a%val,info) + nz_ = max(nz,ione) + call psb_realloc(nz_,a%ia,a%ja,a%val,info) if (info /= psb_success_) then call psb_errpush(psb_err_alloc_dealloc_,name) @@ -357,9 +358,9 @@ subroutine psb_c_coo_allocate_mnnz(m,n,a,nz) goto 9999 endif if (present(nz)) then - nz_ = nz + nz_ = max(nz,ione) else - nz_ = max(7*m,7*n,1) + nz_ = max(7*m,7*n,ione) end if if (nz_ < 0) then info = psb_err_iarg_neg_ diff --git a/base/serial/impl/psb_c_csc_impl.f90 b/base/serial/impl/psb_c_csc_impl.f90 index 6b9b3ad5..dcf9f29b 100644 --- a/base/serial/impl/psb_c_csc_impl.f90 +++ b/base/serial/impl/psb_c_csc_impl.f90 @@ -2537,9 +2537,10 @@ subroutine psb_c_csc_reallocate_nz(nz,a) call psb_erractionsave(err_act) - call psb_realloc(nz,a%ia,info) - if (info == psb_success_) call psb_realloc(nz,a%val,info) - if (info == psb_success_) call psb_realloc(max(nz,a%get_nrows()+1,a%get_ncols()+1),a%icp,info) + call psb_realloc(max(nz,ione),a%ia,info) + if (info == psb_success_) call psb_realloc(max(nz,ione),a%val,info) + if (info == psb_success_) call psb_realloc(max(nz,a%get_nrows()+1,& + & a%get_ncols()+1), a%icp,info) if (info /= psb_success_) then call psb_errpush(psb_err_alloc_dealloc_,name) goto 9999 @@ -2715,9 +2716,9 @@ subroutine psb_c_csc_allocate_mnnz(m,n,a,nz) goto 9999 endif if (present(nz)) then - nz_ = nz + nz_ = max(nz,ione) else - nz_ = max(7*m,7*n,1) + nz_ = max(7*m,7*n,ione) end if if (nz_ < 0) then info = psb_err_iarg_neg_ diff --git a/base/serial/impl/psb_c_csr_impl.f90 b/base/serial/impl/psb_c_csr_impl.f90 index 66201ddc..0e08e9ca 100644 --- a/base/serial/impl/psb_c_csr_impl.f90 +++ b/base/serial/impl/psb_c_csr_impl.f90 @@ -1710,8 +1710,8 @@ subroutine psb_c_csr_reallocate_nz(nz,a) call psb_erractionsave(err_act) - call psb_realloc(nz,a%ja,info) - if (info == psb_success_) call psb_realloc(nz,a%val,info) + call psb_realloc(max(nz,ione),a%ja,info) + if (info == psb_success_) call psb_realloc(max(nz,ione),a%val,info) if (info == psb_success_) call psb_realloc(& & max(nz,a%get_nrows()+1,a%get_ncols()+1),a%irp,info) if (info /= psb_success_) then @@ -1789,9 +1789,9 @@ subroutine psb_c_csr_allocate_mnnz(m,n,a,nz) goto 9999 endif if (present(nz)) then - nz_ = nz + nz_ = max(nz,ione) else - nz_ = max(7*m,7*n,1) + nz_ = max(7*m,7*n,ione) end if if (nz_ < 0) then info = psb_err_iarg_neg_ diff --git a/base/serial/impl/psb_d_coo_impl.f90 b/base/serial/impl/psb_d_coo_impl.f90 index 5253cfc5..4b123836 100644 --- a/base/serial/impl/psb_d_coo_impl.f90 +++ b/base/serial/impl/psb_d_coo_impl.f90 @@ -193,14 +193,15 @@ subroutine psb_d_coo_reallocate_nz(nz,a) implicit none integer(psb_ipk_), intent(in) :: nz class(psb_d_coo_sparse_mat), intent(inout) :: a - integer(psb_ipk_) :: err_act, info + integer(psb_ipk_) :: err_act, info, nz_ integer(psb_ipk_) :: ierr(5) character(len=20) :: name='d_coo_reallocate_nz' logical, parameter :: debug=.false. call psb_erractionsave(err_act) - call psb_realloc(nz,a%ia,a%ja,a%val,info) + nz_ = max(nz,ione) + call psb_realloc(nz_,a%ia,a%ja,a%val,info) if (info /= psb_success_) then call psb_errpush(psb_err_alloc_dealloc_,name) @@ -357,9 +358,9 @@ subroutine psb_d_coo_allocate_mnnz(m,n,a,nz) goto 9999 endif if (present(nz)) then - nz_ = nz + nz_ = max(nz,ione) else - nz_ = max(7*m,7*n,1) + nz_ = max(7*m,7*n,ione) end if if (nz_ < 0) then info = psb_err_iarg_neg_ diff --git a/base/serial/impl/psb_d_csc_impl.f90 b/base/serial/impl/psb_d_csc_impl.f90 index 2f55f2f5..78dd44da 100644 --- a/base/serial/impl/psb_d_csc_impl.f90 +++ b/base/serial/impl/psb_d_csc_impl.f90 @@ -2537,9 +2537,10 @@ subroutine psb_d_csc_reallocate_nz(nz,a) call psb_erractionsave(err_act) - call psb_realloc(nz,a%ia,info) - if (info == psb_success_) call psb_realloc(nz,a%val,info) - if (info == psb_success_) call psb_realloc(max(nz,a%get_nrows()+1,a%get_ncols()+1),a%icp,info) + call psb_realloc(max(nz,ione),a%ia,info) + if (info == psb_success_) call psb_realloc(max(nz,ione),a%val,info) + if (info == psb_success_) call psb_realloc(max(nz,a%get_nrows()+1,& + & a%get_ncols()+1), a%icp,info) if (info /= psb_success_) then call psb_errpush(psb_err_alloc_dealloc_,name) goto 9999 @@ -2715,9 +2716,9 @@ subroutine psb_d_csc_allocate_mnnz(m,n,a,nz) goto 9999 endif if (present(nz)) then - nz_ = nz + nz_ = max(nz,ione) else - nz_ = max(7*m,7*n,1) + nz_ = max(7*m,7*n,ione) end if if (nz_ < 0) then info = psb_err_iarg_neg_ diff --git a/base/serial/impl/psb_d_csr_impl.f90 b/base/serial/impl/psb_d_csr_impl.f90 index 64394810..bd2b5994 100644 --- a/base/serial/impl/psb_d_csr_impl.f90 +++ b/base/serial/impl/psb_d_csr_impl.f90 @@ -1710,8 +1710,8 @@ subroutine psb_d_csr_reallocate_nz(nz,a) call psb_erractionsave(err_act) - call psb_realloc(nz,a%ja,info) - if (info == psb_success_) call psb_realloc(nz,a%val,info) + call psb_realloc(max(nz,ione),a%ja,info) + if (info == psb_success_) call psb_realloc(max(nz,ione),a%val,info) if (info == psb_success_) call psb_realloc(& & max(nz,a%get_nrows()+1,a%get_ncols()+1),a%irp,info) if (info /= psb_success_) then @@ -1789,9 +1789,9 @@ subroutine psb_d_csr_allocate_mnnz(m,n,a,nz) goto 9999 endif if (present(nz)) then - nz_ = nz + nz_ = max(nz,ione) else - nz_ = max(7*m,7*n,1) + nz_ = max(7*m,7*n,ione) end if if (nz_ < 0) then info = psb_err_iarg_neg_ diff --git a/base/serial/impl/psb_s_coo_impl.f90 b/base/serial/impl/psb_s_coo_impl.f90 index 36b83ec4..bd58d44a 100644 --- a/base/serial/impl/psb_s_coo_impl.f90 +++ b/base/serial/impl/psb_s_coo_impl.f90 @@ -193,14 +193,15 @@ subroutine psb_s_coo_reallocate_nz(nz,a) implicit none integer(psb_ipk_), intent(in) :: nz class(psb_s_coo_sparse_mat), intent(inout) :: a - integer(psb_ipk_) :: err_act, info + integer(psb_ipk_) :: err_act, info, nz_ integer(psb_ipk_) :: ierr(5) character(len=20) :: name='s_coo_reallocate_nz' logical, parameter :: debug=.false. call psb_erractionsave(err_act) - call psb_realloc(nz,a%ia,a%ja,a%val,info) + nz_ = max(nz,ione) + call psb_realloc(nz_,a%ia,a%ja,a%val,info) if (info /= psb_success_) then call psb_errpush(psb_err_alloc_dealloc_,name) @@ -357,9 +358,9 @@ subroutine psb_s_coo_allocate_mnnz(m,n,a,nz) goto 9999 endif if (present(nz)) then - nz_ = nz + nz_ = max(nz,ione) else - nz_ = max(7*m,7*n,1) + nz_ = max(7*m,7*n,ione) end if if (nz_ < 0) then info = psb_err_iarg_neg_ diff --git a/base/serial/impl/psb_s_csc_impl.f90 b/base/serial/impl/psb_s_csc_impl.f90 index ea236b84..da8350cc 100644 --- a/base/serial/impl/psb_s_csc_impl.f90 +++ b/base/serial/impl/psb_s_csc_impl.f90 @@ -2537,9 +2537,10 @@ subroutine psb_s_csc_reallocate_nz(nz,a) call psb_erractionsave(err_act) - call psb_realloc(nz,a%ia,info) - if (info == psb_success_) call psb_realloc(nz,a%val,info) - if (info == psb_success_) call psb_realloc(max(nz,a%get_nrows()+1,a%get_ncols()+1),a%icp,info) + call psb_realloc(max(nz,ione),a%ia,info) + if (info == psb_success_) call psb_realloc(max(nz,ione),a%val,info) + if (info == psb_success_) call psb_realloc(max(nz,a%get_nrows()+1,& + & a%get_ncols()+1), a%icp,info) if (info /= psb_success_) then call psb_errpush(psb_err_alloc_dealloc_,name) goto 9999 @@ -2715,9 +2716,9 @@ subroutine psb_s_csc_allocate_mnnz(m,n,a,nz) goto 9999 endif if (present(nz)) then - nz_ = nz + nz_ = max(nz,ione) else - nz_ = max(7*m,7*n,1) + nz_ = max(7*m,7*n,ione) end if if (nz_ < 0) then info = psb_err_iarg_neg_ diff --git a/base/serial/impl/psb_s_csr_impl.f90 b/base/serial/impl/psb_s_csr_impl.f90 index 3cadcaea..fd1d0a22 100644 --- a/base/serial/impl/psb_s_csr_impl.f90 +++ b/base/serial/impl/psb_s_csr_impl.f90 @@ -1710,8 +1710,8 @@ subroutine psb_s_csr_reallocate_nz(nz,a) call psb_erractionsave(err_act) - call psb_realloc(nz,a%ja,info) - if (info == psb_success_) call psb_realloc(nz,a%val,info) + call psb_realloc(max(nz,ione),a%ja,info) + if (info == psb_success_) call psb_realloc(max(nz,ione),a%val,info) if (info == psb_success_) call psb_realloc(& & max(nz,a%get_nrows()+1,a%get_ncols()+1),a%irp,info) if (info /= psb_success_) then @@ -1789,9 +1789,9 @@ subroutine psb_s_csr_allocate_mnnz(m,n,a,nz) goto 9999 endif if (present(nz)) then - nz_ = nz + nz_ = max(nz,ione) else - nz_ = max(7*m,7*n,1) + nz_ = max(7*m,7*n,ione) end if if (nz_ < 0) then info = psb_err_iarg_neg_ diff --git a/base/serial/impl/psb_z_coo_impl.f90 b/base/serial/impl/psb_z_coo_impl.f90 index ce19fbcd..6796fe80 100644 --- a/base/serial/impl/psb_z_coo_impl.f90 +++ b/base/serial/impl/psb_z_coo_impl.f90 @@ -193,14 +193,15 @@ subroutine psb_z_coo_reallocate_nz(nz,a) implicit none integer(psb_ipk_), intent(in) :: nz class(psb_z_coo_sparse_mat), intent(inout) :: a - integer(psb_ipk_) :: err_act, info + integer(psb_ipk_) :: err_act, info, nz_ integer(psb_ipk_) :: ierr(5) character(len=20) :: name='z_coo_reallocate_nz' logical, parameter :: debug=.false. call psb_erractionsave(err_act) - call psb_realloc(nz,a%ia,a%ja,a%val,info) + nz_ = max(nz,ione) + call psb_realloc(nz_,a%ia,a%ja,a%val,info) if (info /= psb_success_) then call psb_errpush(psb_err_alloc_dealloc_,name) @@ -357,9 +358,9 @@ subroutine psb_z_coo_allocate_mnnz(m,n,a,nz) goto 9999 endif if (present(nz)) then - nz_ = nz + nz_ = max(nz,ione) else - nz_ = max(7*m,7*n,1) + nz_ = max(7*m,7*n,ione) end if if (nz_ < 0) then info = psb_err_iarg_neg_ diff --git a/base/serial/impl/psb_z_csc_impl.f90 b/base/serial/impl/psb_z_csc_impl.f90 index 125a07c0..935a0b42 100644 --- a/base/serial/impl/psb_z_csc_impl.f90 +++ b/base/serial/impl/psb_z_csc_impl.f90 @@ -2537,9 +2537,10 @@ subroutine psb_z_csc_reallocate_nz(nz,a) call psb_erractionsave(err_act) - call psb_realloc(nz,a%ia,info) - if (info == psb_success_) call psb_realloc(nz,a%val,info) - if (info == psb_success_) call psb_realloc(max(nz,a%get_nrows()+1,a%get_ncols()+1),a%icp,info) + call psb_realloc(max(nz,ione),a%ia,info) + if (info == psb_success_) call psb_realloc(max(nz,ione),a%val,info) + if (info == psb_success_) call psb_realloc(max(nz,a%get_nrows()+1,& + & a%get_ncols()+1), a%icp,info) if (info /= psb_success_) then call psb_errpush(psb_err_alloc_dealloc_,name) goto 9999 @@ -2715,9 +2716,9 @@ subroutine psb_z_csc_allocate_mnnz(m,n,a,nz) goto 9999 endif if (present(nz)) then - nz_ = nz + nz_ = max(nz,ione) else - nz_ = max(7*m,7*n,1) + nz_ = max(7*m,7*n,ione) end if if (nz_ < 0) then info = psb_err_iarg_neg_ diff --git a/base/serial/impl/psb_z_csr_impl.f90 b/base/serial/impl/psb_z_csr_impl.f90 index b7541fa0..4abd54f2 100644 --- a/base/serial/impl/psb_z_csr_impl.f90 +++ b/base/serial/impl/psb_z_csr_impl.f90 @@ -1710,8 +1710,8 @@ subroutine psb_z_csr_reallocate_nz(nz,a) call psb_erractionsave(err_act) - call psb_realloc(nz,a%ja,info) - if (info == psb_success_) call psb_realloc(nz,a%val,info) + call psb_realloc(max(nz,ione),a%ja,info) + if (info == psb_success_) call psb_realloc(max(nz,ione),a%val,info) if (info == psb_success_) call psb_realloc(& & max(nz,a%get_nrows()+1,a%get_ncols()+1),a%irp,info) if (info /= psb_success_) then @@ -1789,9 +1789,9 @@ subroutine psb_z_csr_allocate_mnnz(m,n,a,nz) goto 9999 endif if (present(nz)) then - nz_ = nz + nz_ = max(nz,ione) else - nz_ = max(7*m,7*n,1) + nz_ = max(7*m,7*n,ione) end if if (nz_ < 0) then info = psb_err_iarg_neg_