diff --git a/base/modules/serial/psb_c_base_mat_mod.F90 b/base/modules/serial/psb_c_base_mat_mod.F90 index fc8304fc..63e6c4c6 100644 --- a/base/modules/serial/psb_c_base_mat_mod.F90 +++ b/base/modules/serial/psb_c_base_mat_mod.F90 @@ -162,6 +162,7 @@ module psb_c_base_mat_mod procedure, pass(a) :: sizeof => c_coo_sizeof procedure, pass(a) :: reallocate_nz => psb_c_coo_reallocate_nz procedure, pass(a) :: allocate_mnnz => psb_c_coo_allocate_mnnz + procedure, pass(a) :: ensure_size => psb_c_coo_ensure_size procedure, pass(a) :: cp_to_coo => psb_c_cp_coo_to_coo procedure, pass(a) :: cp_from_coo => psb_c_cp_coo_from_coo procedure, pass(a) :: cp_to_fmt => psb_c_cp_coo_to_fmt @@ -348,6 +349,7 @@ module psb_c_base_mat_mod procedure, pass(a) :: sizeof => lc_coo_sizeof procedure, pass(a) :: reallocate_nz => psb_lc_coo_reallocate_nz procedure, pass(a) :: allocate_mnnz => psb_lc_coo_allocate_mnnz + procedure, pass(a) :: ensure_size => psb_lc_coo_ensure_size procedure, pass(a) :: cp_to_coo => psb_lc_cp_coo_to_coo procedure, pass(a) :: cp_from_coo => psb_lc_cp_coo_from_coo procedure, pass(a) :: cp_to_fmt => psb_lc_cp_coo_to_fmt @@ -1579,6 +1581,17 @@ module psb_c_base_mat_mod class(psb_c_coo_sparse_mat), intent(inout) :: a end subroutine psb_c_coo_reallocate_nz end interface + ! + !> + !! \memberof psb_c_coo_sparse_mat + ! + interface + subroutine psb_c_coo_ensure_size(nz,a) + import + integer(psb_ipk_), intent(in) :: nz + class(psb_c_coo_sparse_mat), intent(inout) :: a + end subroutine psb_c_coo_ensure_size + end interface ! !> @@ -3083,6 +3096,17 @@ module psb_c_base_mat_mod class(psb_lc_coo_sparse_mat), intent(inout) :: a end subroutine psb_lc_coo_reallocate_nz end interface + ! + !> + !! \memberof psb_lc_coo_sparse_mat + ! + interface + subroutine psb_lc_coo_ensure_size(nz,a) + import + integer(psb_lpk_), intent(in) :: nz + class(psb_lc_coo_sparse_mat), intent(inout) :: a + end subroutine psb_lc_coo_ensure_size + end interface ! !> diff --git a/base/modules/serial/psb_d_base_mat_mod.F90 b/base/modules/serial/psb_d_base_mat_mod.F90 index a49a7fd3..6e60168f 100644 --- a/base/modules/serial/psb_d_base_mat_mod.F90 +++ b/base/modules/serial/psb_d_base_mat_mod.F90 @@ -162,6 +162,7 @@ module psb_d_base_mat_mod procedure, pass(a) :: sizeof => d_coo_sizeof procedure, pass(a) :: reallocate_nz => psb_d_coo_reallocate_nz procedure, pass(a) :: allocate_mnnz => psb_d_coo_allocate_mnnz + procedure, pass(a) :: ensure_size => psb_d_coo_ensure_size procedure, pass(a) :: cp_to_coo => psb_d_cp_coo_to_coo procedure, pass(a) :: cp_from_coo => psb_d_cp_coo_from_coo procedure, pass(a) :: cp_to_fmt => psb_d_cp_coo_to_fmt @@ -348,6 +349,7 @@ module psb_d_base_mat_mod procedure, pass(a) :: sizeof => ld_coo_sizeof procedure, pass(a) :: reallocate_nz => psb_ld_coo_reallocate_nz procedure, pass(a) :: allocate_mnnz => psb_ld_coo_allocate_mnnz + procedure, pass(a) :: ensure_size => psb_ld_coo_ensure_size procedure, pass(a) :: cp_to_coo => psb_ld_cp_coo_to_coo procedure, pass(a) :: cp_from_coo => psb_ld_cp_coo_from_coo procedure, pass(a) :: cp_to_fmt => psb_ld_cp_coo_to_fmt @@ -1579,6 +1581,17 @@ module psb_d_base_mat_mod class(psb_d_coo_sparse_mat), intent(inout) :: a end subroutine psb_d_coo_reallocate_nz end interface + ! + !> + !! \memberof psb_d_coo_sparse_mat + ! + interface + subroutine psb_d_coo_ensure_size(nz,a) + import + integer(psb_ipk_), intent(in) :: nz + class(psb_d_coo_sparse_mat), intent(inout) :: a + end subroutine psb_d_coo_ensure_size + end interface ! !> @@ -3083,6 +3096,17 @@ module psb_d_base_mat_mod class(psb_ld_coo_sparse_mat), intent(inout) :: a end subroutine psb_ld_coo_reallocate_nz end interface + ! + !> + !! \memberof psb_ld_coo_sparse_mat + ! + interface + subroutine psb_ld_coo_ensure_size(nz,a) + import + integer(psb_lpk_), intent(in) :: nz + class(psb_ld_coo_sparse_mat), intent(inout) :: a + end subroutine psb_ld_coo_ensure_size + end interface ! !> diff --git a/base/modules/serial/psb_s_base_mat_mod.F90 b/base/modules/serial/psb_s_base_mat_mod.F90 index 195c35c4..99463aa1 100644 --- a/base/modules/serial/psb_s_base_mat_mod.F90 +++ b/base/modules/serial/psb_s_base_mat_mod.F90 @@ -162,6 +162,7 @@ module psb_s_base_mat_mod procedure, pass(a) :: sizeof => s_coo_sizeof procedure, pass(a) :: reallocate_nz => psb_s_coo_reallocate_nz procedure, pass(a) :: allocate_mnnz => psb_s_coo_allocate_mnnz + procedure, pass(a) :: ensure_size => psb_s_coo_ensure_size procedure, pass(a) :: cp_to_coo => psb_s_cp_coo_to_coo procedure, pass(a) :: cp_from_coo => psb_s_cp_coo_from_coo procedure, pass(a) :: cp_to_fmt => psb_s_cp_coo_to_fmt @@ -348,6 +349,7 @@ module psb_s_base_mat_mod procedure, pass(a) :: sizeof => ls_coo_sizeof procedure, pass(a) :: reallocate_nz => psb_ls_coo_reallocate_nz procedure, pass(a) :: allocate_mnnz => psb_ls_coo_allocate_mnnz + procedure, pass(a) :: ensure_size => psb_ls_coo_ensure_size procedure, pass(a) :: cp_to_coo => psb_ls_cp_coo_to_coo procedure, pass(a) :: cp_from_coo => psb_ls_cp_coo_from_coo procedure, pass(a) :: cp_to_fmt => psb_ls_cp_coo_to_fmt @@ -1579,6 +1581,17 @@ module psb_s_base_mat_mod class(psb_s_coo_sparse_mat), intent(inout) :: a end subroutine psb_s_coo_reallocate_nz end interface + ! + !> + !! \memberof psb_s_coo_sparse_mat + ! + interface + subroutine psb_s_coo_ensure_size(nz,a) + import + integer(psb_ipk_), intent(in) :: nz + class(psb_s_coo_sparse_mat), intent(inout) :: a + end subroutine psb_s_coo_ensure_size + end interface ! !> @@ -3083,6 +3096,17 @@ module psb_s_base_mat_mod class(psb_ls_coo_sparse_mat), intent(inout) :: a end subroutine psb_ls_coo_reallocate_nz end interface + ! + !> + !! \memberof psb_ls_coo_sparse_mat + ! + interface + subroutine psb_ls_coo_ensure_size(nz,a) + import + integer(psb_lpk_), intent(in) :: nz + class(psb_ls_coo_sparse_mat), intent(inout) :: a + end subroutine psb_ls_coo_ensure_size + end interface ! !> diff --git a/base/modules/serial/psb_z_base_mat_mod.F90 b/base/modules/serial/psb_z_base_mat_mod.F90 index 66d5a0b8..833fa8e8 100644 --- a/base/modules/serial/psb_z_base_mat_mod.F90 +++ b/base/modules/serial/psb_z_base_mat_mod.F90 @@ -162,6 +162,7 @@ module psb_z_base_mat_mod procedure, pass(a) :: sizeof => z_coo_sizeof procedure, pass(a) :: reallocate_nz => psb_z_coo_reallocate_nz procedure, pass(a) :: allocate_mnnz => psb_z_coo_allocate_mnnz + procedure, pass(a) :: ensure_size => psb_z_coo_ensure_size procedure, pass(a) :: cp_to_coo => psb_z_cp_coo_to_coo procedure, pass(a) :: cp_from_coo => psb_z_cp_coo_from_coo procedure, pass(a) :: cp_to_fmt => psb_z_cp_coo_to_fmt @@ -348,6 +349,7 @@ module psb_z_base_mat_mod procedure, pass(a) :: sizeof => lz_coo_sizeof procedure, pass(a) :: reallocate_nz => psb_lz_coo_reallocate_nz procedure, pass(a) :: allocate_mnnz => psb_lz_coo_allocate_mnnz + procedure, pass(a) :: ensure_size => psb_lz_coo_ensure_size procedure, pass(a) :: cp_to_coo => psb_lz_cp_coo_to_coo procedure, pass(a) :: cp_from_coo => psb_lz_cp_coo_from_coo procedure, pass(a) :: cp_to_fmt => psb_lz_cp_coo_to_fmt @@ -1579,6 +1581,17 @@ module psb_z_base_mat_mod class(psb_z_coo_sparse_mat), intent(inout) :: a end subroutine psb_z_coo_reallocate_nz end interface + ! + !> + !! \memberof psb_z_coo_sparse_mat + ! + interface + subroutine psb_z_coo_ensure_size(nz,a) + import + integer(psb_ipk_), intent(in) :: nz + class(psb_z_coo_sparse_mat), intent(inout) :: a + end subroutine psb_z_coo_ensure_size + end interface ! !> @@ -3083,6 +3096,17 @@ module psb_z_base_mat_mod class(psb_lz_coo_sparse_mat), intent(inout) :: a end subroutine psb_lz_coo_reallocate_nz end interface + ! + !> + !! \memberof psb_lz_coo_sparse_mat + ! + interface + subroutine psb_lz_coo_ensure_size(nz,a) + import + integer(psb_lpk_), intent(in) :: nz + class(psb_lz_coo_sparse_mat), intent(inout) :: a + end subroutine psb_lz_coo_ensure_size + end interface ! !> diff --git a/base/serial/impl/psb_c_coo_impl.f90 b/base/serial/impl/psb_c_coo_impl.f90 index cee06b36..0bc00bb2 100644 --- a/base/serial/impl/psb_c_coo_impl.f90 +++ b/base/serial/impl/psb_c_coo_impl.f90 @@ -211,6 +211,38 @@ subroutine psb_c_coo_reallocate_nz(nz,a) end subroutine psb_c_coo_reallocate_nz +subroutine psb_c_coo_ensure_size(nz,a) + use psb_c_base_mat_mod, psb_protect_name => psb_c_coo_ensure_size + use psb_error_mod + use psb_realloc_mod + implicit none + integer(psb_ipk_), intent(in) :: nz + class(psb_c_coo_sparse_mat), intent(inout) :: a + integer(psb_ipk_) :: err_act, info, nz_ + character(len=20) :: name='c_coo_ensure_size' + logical, parameter :: debug=.false. + + call psb_erractionsave(err_act) + + nz_ = max(nz,ione) + call psb_ensure_size(nz_,a%ia,info) + if (info == psb_success_) call psb_ensure_size(nz_,a%ja,info) + if (info == psb_success_) call psb_ensure_size(nz_,a%val,info) + + if (info /= psb_success_) then + call psb_errpush(psb_err_alloc_dealloc_,name) + goto 9999 + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine psb_c_coo_ensure_size + subroutine psb_c_coo_mold(a,b,info) use psb_c_base_mat_mod, psb_protect_name => psb_c_coo_mold use psb_error_mod @@ -1618,7 +1650,7 @@ subroutine psb_c_coo_csmm(alpha,a,x,beta,y,info,trans) end if !.....end testing on alpha - else if (ctra) then + else if (ctra) then ! if (alpha == cone) then i = 1 @@ -4555,6 +4587,38 @@ subroutine psb_lc_coo_reallocate_nz(nz,a) end subroutine psb_lc_coo_reallocate_nz +subroutine psb_lc_coo_ensure_size(nz,a) + use psb_c_base_mat_mod, psb_protect_name => psb_lc_coo_ensure_size + use psb_error_mod + use psb_realloc_mod + implicit none + integer(psb_lpk_), intent(in) :: nz + class(psb_lc_coo_sparse_mat), intent(inout) :: a + integer(psb_ipk_) :: err_act, info, nz_ + character(len=20) :: name='lc_coo_ensure_size' + logical, parameter :: debug=.false. + + call psb_erractionsave(err_act) + + nz_ = max(nz,ione) + call psb_ensure_size(nz_,a%ia,info) + if (info == psb_success_) call psb_ensure_size(nz_,a%ja,info) + if (info == psb_success_) call psb_ensure_size(nz_,a%val,info) + + if (info /= psb_success_) then + call psb_errpush(psb_err_alloc_dealloc_,name) + goto 9999 + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine psb_lc_coo_ensure_size + subroutine psb_lc_coo_mold(a,b,info) use psb_c_base_mat_mod, psb_protect_name => psb_lc_coo_mold use psb_error_mod diff --git a/base/serial/impl/psb_d_coo_impl.f90 b/base/serial/impl/psb_d_coo_impl.f90 index ff655f58..dff21bd2 100644 --- a/base/serial/impl/psb_d_coo_impl.f90 +++ b/base/serial/impl/psb_d_coo_impl.f90 @@ -211,6 +211,38 @@ subroutine psb_d_coo_reallocate_nz(nz,a) end subroutine psb_d_coo_reallocate_nz +subroutine psb_d_coo_ensure_size(nz,a) + use psb_d_base_mat_mod, psb_protect_name => psb_d_coo_ensure_size + use psb_error_mod + use psb_realloc_mod + implicit none + integer(psb_ipk_), intent(in) :: nz + class(psb_d_coo_sparse_mat), intent(inout) :: a + integer(psb_ipk_) :: err_act, info, nz_ + character(len=20) :: name='d_coo_ensure_size' + logical, parameter :: debug=.false. + + call psb_erractionsave(err_act) + + nz_ = max(nz,ione) + call psb_ensure_size(nz_,a%ia,info) + if (info == psb_success_) call psb_ensure_size(nz_,a%ja,info) + if (info == psb_success_) call psb_ensure_size(nz_,a%val,info) + + if (info /= psb_success_) then + call psb_errpush(psb_err_alloc_dealloc_,name) + goto 9999 + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine psb_d_coo_ensure_size + subroutine psb_d_coo_mold(a,b,info) use psb_d_base_mat_mod, psb_protect_name => psb_d_coo_mold use psb_error_mod @@ -1618,7 +1650,7 @@ subroutine psb_d_coo_csmm(alpha,a,x,beta,y,info,trans) end if !.....end testing on alpha - else if (ctra) then + else if (ctra) then ! if (alpha == done) then i = 1 @@ -4555,6 +4587,38 @@ subroutine psb_ld_coo_reallocate_nz(nz,a) end subroutine psb_ld_coo_reallocate_nz +subroutine psb_ld_coo_ensure_size(nz,a) + use psb_d_base_mat_mod, psb_protect_name => psb_ld_coo_ensure_size + use psb_error_mod + use psb_realloc_mod + implicit none + integer(psb_lpk_), intent(in) :: nz + class(psb_ld_coo_sparse_mat), intent(inout) :: a + integer(psb_ipk_) :: err_act, info, nz_ + character(len=20) :: name='ld_coo_ensure_size' + logical, parameter :: debug=.false. + + call psb_erractionsave(err_act) + + nz_ = max(nz,ione) + call psb_ensure_size(nz_,a%ia,info) + if (info == psb_success_) call psb_ensure_size(nz_,a%ja,info) + if (info == psb_success_) call psb_ensure_size(nz_,a%val,info) + + if (info /= psb_success_) then + call psb_errpush(psb_err_alloc_dealloc_,name) + goto 9999 + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine psb_ld_coo_ensure_size + subroutine psb_ld_coo_mold(a,b,info) use psb_d_base_mat_mod, psb_protect_name => psb_ld_coo_mold use psb_error_mod diff --git a/base/serial/impl/psb_s_coo_impl.f90 b/base/serial/impl/psb_s_coo_impl.f90 index 4b96893f..3d3c58a3 100644 --- a/base/serial/impl/psb_s_coo_impl.f90 +++ b/base/serial/impl/psb_s_coo_impl.f90 @@ -211,6 +211,38 @@ subroutine psb_s_coo_reallocate_nz(nz,a) end subroutine psb_s_coo_reallocate_nz +subroutine psb_s_coo_ensure_size(nz,a) + use psb_s_base_mat_mod, psb_protect_name => psb_s_coo_ensure_size + use psb_error_mod + use psb_realloc_mod + implicit none + integer(psb_ipk_), intent(in) :: nz + class(psb_s_coo_sparse_mat), intent(inout) :: a + integer(psb_ipk_) :: err_act, info, nz_ + character(len=20) :: name='s_coo_ensure_size' + logical, parameter :: debug=.false. + + call psb_erractionsave(err_act) + + nz_ = max(nz,ione) + call psb_ensure_size(nz_,a%ia,info) + if (info == psb_success_) call psb_ensure_size(nz_,a%ja,info) + if (info == psb_success_) call psb_ensure_size(nz_,a%val,info) + + if (info /= psb_success_) then + call psb_errpush(psb_err_alloc_dealloc_,name) + goto 9999 + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine psb_s_coo_ensure_size + subroutine psb_s_coo_mold(a,b,info) use psb_s_base_mat_mod, psb_protect_name => psb_s_coo_mold use psb_error_mod @@ -1618,7 +1650,7 @@ subroutine psb_s_coo_csmm(alpha,a,x,beta,y,info,trans) end if !.....end testing on alpha - else if (ctra) then + else if (ctra) then ! if (alpha == sone) then i = 1 @@ -4555,6 +4587,38 @@ subroutine psb_ls_coo_reallocate_nz(nz,a) end subroutine psb_ls_coo_reallocate_nz +subroutine psb_ls_coo_ensure_size(nz,a) + use psb_s_base_mat_mod, psb_protect_name => psb_ls_coo_ensure_size + use psb_error_mod + use psb_realloc_mod + implicit none + integer(psb_lpk_), intent(in) :: nz + class(psb_ls_coo_sparse_mat), intent(inout) :: a + integer(psb_ipk_) :: err_act, info, nz_ + character(len=20) :: name='ls_coo_ensure_size' + logical, parameter :: debug=.false. + + call psb_erractionsave(err_act) + + nz_ = max(nz,ione) + call psb_ensure_size(nz_,a%ia,info) + if (info == psb_success_) call psb_ensure_size(nz_,a%ja,info) + if (info == psb_success_) call psb_ensure_size(nz_,a%val,info) + + if (info /= psb_success_) then + call psb_errpush(psb_err_alloc_dealloc_,name) + goto 9999 + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine psb_ls_coo_ensure_size + subroutine psb_ls_coo_mold(a,b,info) use psb_s_base_mat_mod, psb_protect_name => psb_ls_coo_mold use psb_error_mod diff --git a/base/serial/impl/psb_z_coo_impl.f90 b/base/serial/impl/psb_z_coo_impl.f90 index ac3b46da..ee56c678 100644 --- a/base/serial/impl/psb_z_coo_impl.f90 +++ b/base/serial/impl/psb_z_coo_impl.f90 @@ -211,6 +211,38 @@ subroutine psb_z_coo_reallocate_nz(nz,a) end subroutine psb_z_coo_reallocate_nz +subroutine psb_z_coo_ensure_size(nz,a) + use psb_z_base_mat_mod, psb_protect_name => psb_z_coo_ensure_size + use psb_error_mod + use psb_realloc_mod + implicit none + integer(psb_ipk_), intent(in) :: nz + class(psb_z_coo_sparse_mat), intent(inout) :: a + integer(psb_ipk_) :: err_act, info, nz_ + character(len=20) :: name='z_coo_ensure_size' + logical, parameter :: debug=.false. + + call psb_erractionsave(err_act) + + nz_ = max(nz,ione) + call psb_ensure_size(nz_,a%ia,info) + if (info == psb_success_) call psb_ensure_size(nz_,a%ja,info) + if (info == psb_success_) call psb_ensure_size(nz_,a%val,info) + + if (info /= psb_success_) then + call psb_errpush(psb_err_alloc_dealloc_,name) + goto 9999 + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine psb_z_coo_ensure_size + subroutine psb_z_coo_mold(a,b,info) use psb_z_base_mat_mod, psb_protect_name => psb_z_coo_mold use psb_error_mod @@ -1618,7 +1650,7 @@ subroutine psb_z_coo_csmm(alpha,a,x,beta,y,info,trans) end if !.....end testing on alpha - else if (ctra) then + else if (ctra) then ! if (alpha == zone) then i = 1 @@ -4555,6 +4587,38 @@ subroutine psb_lz_coo_reallocate_nz(nz,a) end subroutine psb_lz_coo_reallocate_nz +subroutine psb_lz_coo_ensure_size(nz,a) + use psb_z_base_mat_mod, psb_protect_name => psb_lz_coo_ensure_size + use psb_error_mod + use psb_realloc_mod + implicit none + integer(psb_lpk_), intent(in) :: nz + class(psb_lz_coo_sparse_mat), intent(inout) :: a + integer(psb_ipk_) :: err_act, info, nz_ + character(len=20) :: name='lz_coo_ensure_size' + logical, parameter :: debug=.false. + + call psb_erractionsave(err_act) + + nz_ = max(nz,ione) + call psb_ensure_size(nz_,a%ia,info) + if (info == psb_success_) call psb_ensure_size(nz_,a%ja,info) + if (info == psb_success_) call psb_ensure_size(nz_,a%val,info) + + if (info /= psb_success_) then + call psb_errpush(psb_err_alloc_dealloc_,name) + goto 9999 + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine psb_lz_coo_ensure_size + subroutine psb_lz_coo_mold(a,b,info) use psb_z_base_mat_mod, psb_protect_name => psb_lz_coo_mold use psb_error_mod