Add N to get_vect.

This commit is contained in:
Salvatore Filippone
2018-09-04 17:40:51 +01:00
parent ae2e575a29
commit e5ed49a018
12 changed files with 125 additions and 84 deletions
+8 -3
View File
@@ -688,19 +688,24 @@ contains
!! \brief Extract a copy of the contents
!!
!
function c_base_get_vect(x) result(res)
function c_base_get_vect(x,n) result(res)
class(psb_c_base_vect_type), intent(inout) :: x
complex(psb_spk_), allocatable :: res(:)
integer(psb_ipk_) :: info
integer(psb_ipk_), optional :: n
! Local variables
integer(psb_ipk_) :: isz
if (.not.allocated(x%v)) return
if (.not.x%is_host()) call x%sync()
allocate(res(x%get_nrows()),stat=info)
isz = x%get_nrows()
if (present(n)) isz = max(0,min(isz,n))
allocate(res(isz),stat=info)
if (info /= 0) then
call psb_errpush(psb_err_alloc_dealloc_,'base_get_vect')
return
end if
res(:) = x%v(:)
res(1:isz) = x%v(1:isz)
end function c_base_get_vect
!
+3 -2
View File
@@ -227,13 +227,14 @@ contains
end subroutine c_vect_bld_n
function c_vect_get_vect(x) result(res)
function c_vect_get_vect(x,n) result(res)
class(psb_c_vect_type), intent(inout) :: x
complex(psb_spk_), allocatable :: res(:)
integer(psb_ipk_) :: info
integer(psb_ipk_), optional :: n
if (allocated(x%v)) then
res = x%v%get_vect()
res = x%v%get_vect(n)
end if
end function c_vect_get_vect
+8 -3
View File
@@ -688,19 +688,24 @@ contains
!! \brief Extract a copy of the contents
!!
!
function d_base_get_vect(x) result(res)
function d_base_get_vect(x,n) result(res)
class(psb_d_base_vect_type), intent(inout) :: x
real(psb_dpk_), allocatable :: res(:)
integer(psb_ipk_) :: info
integer(psb_ipk_), optional :: n
! Local variables
integer(psb_ipk_) :: isz
if (.not.allocated(x%v)) return
if (.not.x%is_host()) call x%sync()
allocate(res(x%get_nrows()),stat=info)
isz = x%get_nrows()
if (present(n)) isz = max(0,min(isz,n))
allocate(res(isz),stat=info)
if (info /= 0) then
call psb_errpush(psb_err_alloc_dealloc_,'base_get_vect')
return
end if
res(:) = x%v(:)
res(1:isz) = x%v(1:isz)
end function d_base_get_vect
!
+3 -2
View File
@@ -227,13 +227,14 @@ contains
end subroutine d_vect_bld_n
function d_vect_get_vect(x) result(res)
function d_vect_get_vect(x,n) result(res)
class(psb_d_vect_type), intent(inout) :: x
real(psb_dpk_), allocatable :: res(:)
integer(psb_ipk_) :: info
integer(psb_ipk_), optional :: n
if (allocated(x%v)) then
res = x%v%get_vect()
res = x%v%get_vect(n)
end if
end function d_vect_get_vect
+8 -3
View File
@@ -657,19 +657,24 @@ contains
!! \brief Extract a copy of the contents
!!
!
function i_base_get_vect(x) result(res)
function i_base_get_vect(x,n) result(res)
class(psb_i_base_vect_type), intent(inout) :: x
integer(psb_ipk_), allocatable :: res(:)
integer(psb_ipk_) :: info
integer(psb_ipk_), optional :: n
! Local variables
integer(psb_ipk_) :: isz
if (.not.allocated(x%v)) return
if (.not.x%is_host()) call x%sync()
allocate(res(x%get_nrows()),stat=info)
isz = x%get_nrows()
if (present(n)) isz = max(0,min(isz,n))
allocate(res(isz),stat=info)
if (info /= 0) then
call psb_errpush(psb_err_alloc_dealloc_,'base_get_vect')
return
end if
res(:) = x%v(:)
res(1:isz) = x%v(1:isz)
end function i_base_get_vect
!
+3 -2
View File
@@ -200,13 +200,14 @@ contains
end subroutine i_vect_bld_n
function i_vect_get_vect(x) result(res)
function i_vect_get_vect(x,n) result(res)
class(psb_i_vect_type), intent(inout) :: x
integer(psb_ipk_), allocatable :: res(:)
integer(psb_ipk_) :: info
integer(psb_ipk_), optional :: n
if (allocated(x%v)) then
res = x%v%get_vect()
res = x%v%get_vect(n)
end if
end function i_vect_get_vect
+8 -3
View File
@@ -688,19 +688,24 @@ contains
!! \brief Extract a copy of the contents
!!
!
function s_base_get_vect(x) result(res)
function s_base_get_vect(x,n) result(res)
class(psb_s_base_vect_type), intent(inout) :: x
real(psb_spk_), allocatable :: res(:)
integer(psb_ipk_) :: info
integer(psb_ipk_), optional :: n
! Local variables
integer(psb_ipk_) :: isz
if (.not.allocated(x%v)) return
if (.not.x%is_host()) call x%sync()
allocate(res(x%get_nrows()),stat=info)
isz = x%get_nrows()
if (present(n)) isz = max(0,min(isz,n))
allocate(res(isz),stat=info)
if (info /= 0) then
call psb_errpush(psb_err_alloc_dealloc_,'base_get_vect')
return
end if
res(:) = x%v(:)
res(1:isz) = x%v(1:isz)
end function s_base_get_vect
!
+3 -2
View File
@@ -227,13 +227,14 @@ contains
end subroutine s_vect_bld_n
function s_vect_get_vect(x) result(res)
function s_vect_get_vect(x,n) result(res)
class(psb_s_vect_type), intent(inout) :: x
real(psb_spk_), allocatable :: res(:)
integer(psb_ipk_) :: info
integer(psb_ipk_), optional :: n
if (allocated(x%v)) then
res = x%v%get_vect()
res = x%v%get_vect(n)
end if
end function s_vect_get_vect
+8 -3
View File
@@ -688,19 +688,24 @@ contains
!! \brief Extract a copy of the contents
!!
!
function z_base_get_vect(x) result(res)
function z_base_get_vect(x,n) result(res)
class(psb_z_base_vect_type), intent(inout) :: x
complex(psb_dpk_), allocatable :: res(:)
integer(psb_ipk_) :: info
integer(psb_ipk_), optional :: n
! Local variables
integer(psb_ipk_) :: isz
if (.not.allocated(x%v)) return
if (.not.x%is_host()) call x%sync()
allocate(res(x%get_nrows()),stat=info)
isz = x%get_nrows()
if (present(n)) isz = max(0,min(isz,n))
allocate(res(isz),stat=info)
if (info /= 0) then
call psb_errpush(psb_err_alloc_dealloc_,'base_get_vect')
return
end if
res(:) = x%v(:)
res(1:isz) = x%v(1:isz)
end function z_base_get_vect
!
+3 -2
View File
@@ -227,13 +227,14 @@ contains
end subroutine z_vect_bld_n
function z_vect_get_vect(x) result(res)
function z_vect_get_vect(x,n) result(res)
class(psb_z_vect_type), intent(inout) :: x
complex(psb_dpk_), allocatable :: res(:)
integer(psb_ipk_) :: info
integer(psb_ipk_), optional :: n
if (allocated(x%v)) then
res = x%v%get_vect()
res = x%v%get_vect(n)
end if
end function z_vect_get_vect