|
|
|
@ -9,7 +9,7 @@ module psbn_d_mat_mod
|
|
|
|
|
class(psbn_d_base_sparse_mat), allocatable :: a
|
|
|
|
|
|
|
|
|
|
contains
|
|
|
|
|
|
|
|
|
|
! Setters
|
|
|
|
|
procedure, pass(a) :: set_nrows
|
|
|
|
|
procedure, pass(a) :: set_ncols
|
|
|
|
|
procedure, pass(a) :: set_dupl
|
|
|
|
@ -23,13 +23,12 @@ module psbn_d_mat_mod
|
|
|
|
|
procedure, pass(a) :: set_lower
|
|
|
|
|
procedure, pass(a) :: set_triangle
|
|
|
|
|
procedure, pass(a) :: set_unit
|
|
|
|
|
|
|
|
|
|
! Getters
|
|
|
|
|
procedure, pass(a) :: get_nrows
|
|
|
|
|
procedure, pass(a) :: get_ncols
|
|
|
|
|
procedure, pass(a) :: get_nzeros
|
|
|
|
|
procedure, pass(a) :: get_size
|
|
|
|
|
procedure, pass(a) :: get_state
|
|
|
|
|
|
|
|
|
|
procedure, pass(a) :: get_dupl
|
|
|
|
|
procedure, pass(a) :: is_null
|
|
|
|
|
procedure, pass(a) :: is_bld
|
|
|
|
@ -40,84 +39,54 @@ module psbn_d_mat_mod
|
|
|
|
|
procedure, pass(a) :: is_lower
|
|
|
|
|
procedure, pass(a) :: is_triangle
|
|
|
|
|
procedure, pass(a) :: is_unit
|
|
|
|
|
procedure, pass(a) :: get_neigh
|
|
|
|
|
procedure, pass(a) :: allocate_mnnz
|
|
|
|
|
procedure, pass(a) :: reallocate_nz
|
|
|
|
|
procedure, pass(a) :: free
|
|
|
|
|
procedure, pass(a) :: print => sparse_print
|
|
|
|
|
procedure, pass(a) :: get_fmt => sparse_get_fmt
|
|
|
|
|
|
|
|
|
|
generic, public :: allocate => allocate_mnnz
|
|
|
|
|
generic, public :: reallocate => reallocate_nz
|
|
|
|
|
! Memory/data management
|
|
|
|
|
procedure, pass(a) :: csall
|
|
|
|
|
procedure, pass(a) :: free
|
|
|
|
|
procedure, pass(a) :: csput
|
|
|
|
|
procedure, pass(a) :: csget
|
|
|
|
|
procedure, pass(a) :: reall => reallocate_nz
|
|
|
|
|
procedure, pass(a) :: get_neigh
|
|
|
|
|
procedure, pass(a) :: d_cscnv
|
|
|
|
|
procedure, pass(a) :: d_cscnv_ip
|
|
|
|
|
generic, public :: cscnv => d_cscnv, d_cscnv_ip
|
|
|
|
|
procedure, pass(a) :: print => sparse_print
|
|
|
|
|
|
|
|
|
|
! Computational routines
|
|
|
|
|
procedure, pass(a) :: d_csmv
|
|
|
|
|
procedure, pass(a) :: d_csmm
|
|
|
|
|
generic, public :: psbn_csmm => d_csmm, d_csmv
|
|
|
|
|
generic, public :: csmm => d_csmm, d_csmv
|
|
|
|
|
|
|
|
|
|
procedure, pass(a) :: d_cssv
|
|
|
|
|
procedure, pass(a) :: d_cssm
|
|
|
|
|
generic, public :: psbn_cssm => d_cssm, d_cssv
|
|
|
|
|
generic, public :: cssm => d_cssm, d_cssv
|
|
|
|
|
|
|
|
|
|
end type psbn_d_sparse_mat
|
|
|
|
|
|
|
|
|
|
private :: get_nrows, get_ncols, get_nzeros, get_size, &
|
|
|
|
|
& get_state, get_dupl, is_null, is_bld, is_upd, &
|
|
|
|
|
& is_asb, is_sorted, is_upper, is_lower, is_triangle, &
|
|
|
|
|
& is_unit, get_neigh, allocate_mnnz, &
|
|
|
|
|
& is_unit, get_neigh, csall, csput, csget, d_cscnv, d_cscnv_ip, &
|
|
|
|
|
& reallocate_nz, free, d_csmv, d_csmm, d_cssv, d_cssm, sparse_print, &
|
|
|
|
|
& set_nrows, set_ncols, set_dupl, set_state, set_null, set_bld, &
|
|
|
|
|
& set_upd, set_asb, set_sorted, set_upper, set_lower, set_triangle, &
|
|
|
|
|
& set_unit
|
|
|
|
|
|
|
|
|
|
contains
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
interface psbn_csall
|
|
|
|
|
subroutine psbn_d_csall(nr,nc,a,info,nz)
|
|
|
|
|
use psbn_d_base_mat_mod
|
|
|
|
|
import psbn_d_sparse_mat
|
|
|
|
|
type(psbn_d_sparse_mat), intent(out) :: a
|
|
|
|
|
integer, intent(in) :: nr,nc
|
|
|
|
|
integer, intent(out) :: info
|
|
|
|
|
integer, intent(in), optional :: nz
|
|
|
|
|
end subroutine psbn_d_csall
|
|
|
|
|
end interface
|
|
|
|
|
|
|
|
|
|
interface psbn_csins
|
|
|
|
|
subroutine psbn_d_csins(nz,val,ia,ja,a,imin,imax,jmin,jmax,info,gtl)
|
|
|
|
|
use psbn_d_base_mat_mod
|
|
|
|
|
import psbn_d_sparse_mat
|
|
|
|
|
type(psbn_d_sparse_mat), intent(inout) :: a
|
|
|
|
|
real(psb_dpk_), intent(in) :: val(:)
|
|
|
|
|
integer, intent(in) :: nz, ia(:), ja(:), imin,imax,jmin,jmax
|
|
|
|
|
integer, intent(out) :: info
|
|
|
|
|
integer, intent(in), optional :: gtl(:)
|
|
|
|
|
end subroutine psbn_d_csins
|
|
|
|
|
end interface
|
|
|
|
|
|
|
|
|
|
interface psbn_cscnv
|
|
|
|
|
subroutine psbn_d_spcnv(a,b,info,type,mold,upd,dupl)
|
|
|
|
|
use psbn_d_base_mat_mod
|
|
|
|
|
import psbn_d_sparse_mat
|
|
|
|
|
type(psbn_d_sparse_mat), intent(in) :: a
|
|
|
|
|
type(psbn_d_sparse_mat), intent(out) :: b
|
|
|
|
|
integer, intent(out) :: info
|
|
|
|
|
integer, optional, intent(in) :: dupl, upd
|
|
|
|
|
character(len=*), optional, intent(in) :: type
|
|
|
|
|
class(psbn_d_base_sparse_mat), intent(in), optional :: mold
|
|
|
|
|
|
|
|
|
|
end subroutine psbn_d_spcnv
|
|
|
|
|
subroutine psbn_d_spcnv_ip(a,info,type,mold,dupl)
|
|
|
|
|
use psbn_d_base_mat_mod
|
|
|
|
|
import psbn_d_sparse_mat
|
|
|
|
|
type(psbn_d_sparse_mat), intent(inout) :: a
|
|
|
|
|
integer, intent(out) :: info
|
|
|
|
|
integer,optional, intent(in) :: dupl
|
|
|
|
|
character(len=*), optional, intent(in) :: type
|
|
|
|
|
class(psbn_d_base_sparse_mat), intent(in), optional :: mold
|
|
|
|
|
end subroutine psbn_d_spcnv_ip
|
|
|
|
|
end interface
|
|
|
|
|
|
|
|
|
|
contains
|
|
|
|
|
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
|
|
|
!
|
|
|
|
|
!
|
|
|
|
|
!
|
|
|
|
|
! Getters
|
|
|
|
|
!
|
|
|
|
|
!
|
|
|
|
|
!
|
|
|
|
|
!
|
|
|
|
|
!
|
|
|
|
|
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function sparse_get_fmt(a) result(res)
|
|
|
|
@ -305,6 +274,88 @@ contains
|
|
|
|
|
end function is_sorted
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function get_nzeros(a) result(res)
|
|
|
|
|
use psb_error_mod
|
|
|
|
|
implicit none
|
|
|
|
|
class(psbn_d_sparse_mat), intent(in) :: a
|
|
|
|
|
integer :: res
|
|
|
|
|
|
|
|
|
|
Integer :: err_act, info
|
|
|
|
|
character(len=20) :: name='get_nzeros'
|
|
|
|
|
logical, parameter :: debug=.false.
|
|
|
|
|
|
|
|
|
|
call psb_erractionsave(err_act)
|
|
|
|
|
if (.not.allocated(a%a)) then
|
|
|
|
|
info = 1121
|
|
|
|
|
call psb_errpush(info,name)
|
|
|
|
|
goto 9999
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
res = a%a%get_nzeros()
|
|
|
|
|
|
|
|
|
|
call psb_erractionrestore(err_act)
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
9999 continue
|
|
|
|
|
call psb_erractionrestore(err_act)
|
|
|
|
|
|
|
|
|
|
if (err_act == psb_act_abort_) then
|
|
|
|
|
call psb_error()
|
|
|
|
|
return
|
|
|
|
|
end if
|
|
|
|
|
|
|
|
|
|
end function get_nzeros
|
|
|
|
|
|
|
|
|
|
function get_size(a) result(res)
|
|
|
|
|
use psb_error_mod
|
|
|
|
|
implicit none
|
|
|
|
|
class(psbn_d_sparse_mat), intent(in) :: a
|
|
|
|
|
integer :: res
|
|
|
|
|
|
|
|
|
|
Integer :: err_act, info
|
|
|
|
|
character(len=20) :: name='get_size'
|
|
|
|
|
logical, parameter :: debug=.false.
|
|
|
|
|
|
|
|
|
|
call psb_erractionsave(err_act)
|
|
|
|
|
if (.not.allocated(a%a)) then
|
|
|
|
|
info = 1121
|
|
|
|
|
call psb_errpush(info,name)
|
|
|
|
|
goto 9999
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
res = a%a%get_size()
|
|
|
|
|
|
|
|
|
|
call psb_erractionrestore(err_act)
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
9999 continue
|
|
|
|
|
call psb_erractionrestore(err_act)
|
|
|
|
|
|
|
|
|
|
if (err_act == psb_act_abort_) then
|
|
|
|
|
call psb_error()
|
|
|
|
|
return
|
|
|
|
|
end if
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
end function get_size
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
|
|
|
!
|
|
|
|
|
!
|
|
|
|
|
!
|
|
|
|
|
! Setters
|
|
|
|
|
!
|
|
|
|
|
!
|
|
|
|
|
!
|
|
|
|
|
!
|
|
|
|
|
!
|
|
|
|
|
!
|
|
|
|
|
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
subroutine set_nrows(m,a)
|
|
|
|
|
use psb_error_mod
|
|
|
|
|
implicit none
|
|
|
|
@ -711,18 +762,37 @@ contains
|
|
|
|
|
end subroutine set_upper
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
|
|
|
!
|
|
|
|
|
!
|
|
|
|
|
!
|
|
|
|
|
! Data management
|
|
|
|
|
!
|
|
|
|
|
!
|
|
|
|
|
!
|
|
|
|
|
!
|
|
|
|
|
!
|
|
|
|
|
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function get_nzeros(a) result(res)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
subroutine sparse_print(iout,a,iv,eirs,eics,head,ivr,ivc)
|
|
|
|
|
use psb_error_mod
|
|
|
|
|
implicit none
|
|
|
|
|
|
|
|
|
|
integer, intent(in) :: iout
|
|
|
|
|
class(psbn_d_sparse_mat), intent(in) :: a
|
|
|
|
|
integer :: res
|
|
|
|
|
integer, intent(in), optional :: iv(:)
|
|
|
|
|
integer, intent(in), optional :: eirs,eics
|
|
|
|
|
character(len=*), optional :: head
|
|
|
|
|
integer, intent(in), optional :: ivr(:), ivc(:)
|
|
|
|
|
|
|
|
|
|
Integer :: err_act, info
|
|
|
|
|
character(len=20) :: name='get_nzeros'
|
|
|
|
|
character(len=20) :: name='sparse_print'
|
|
|
|
|
logical, parameter :: debug=.false.
|
|
|
|
|
|
|
|
|
|
info = 0
|
|
|
|
|
call psb_erractionsave(err_act)
|
|
|
|
|
if (.not.allocated(a%a)) then
|
|
|
|
|
info = 1121
|
|
|
|
@ -730,7 +800,8 @@ contains
|
|
|
|
|
goto 9999
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
res = a%a%get_nzeros()
|
|
|
|
|
call a%a%print(iout,iv,eirs,eics,head,ivr,ivc)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
call psb_erractionrestore(err_act)
|
|
|
|
|
return
|
|
|
|
@ -742,19 +813,27 @@ contains
|
|
|
|
|
call psb_error()
|
|
|
|
|
return
|
|
|
|
|
end if
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
end function get_nzeros
|
|
|
|
|
end subroutine sparse_print
|
|
|
|
|
|
|
|
|
|
function get_size(a) result(res)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
subroutine get_neigh(a,idx,neigh,n,info,lev)
|
|
|
|
|
use psb_error_mod
|
|
|
|
|
implicit none
|
|
|
|
|
class(psbn_d_sparse_mat), intent(in) :: a
|
|
|
|
|
integer :: res
|
|
|
|
|
integer, intent(in) :: idx
|
|
|
|
|
integer, intent(out) :: n
|
|
|
|
|
integer, allocatable, intent(out) :: neigh(:)
|
|
|
|
|
integer, intent(out) :: info
|
|
|
|
|
integer, optional, intent(in) :: lev
|
|
|
|
|
|
|
|
|
|
Integer :: err_act, info
|
|
|
|
|
character(len=20) :: name='get_size'
|
|
|
|
|
Integer :: err_act
|
|
|
|
|
character(len=20) :: name='get_neigh'
|
|
|
|
|
logical, parameter :: debug=.false.
|
|
|
|
|
|
|
|
|
|
info = 0
|
|
|
|
|
call psb_erractionsave(err_act)
|
|
|
|
|
if (.not.allocated(a%a)) then
|
|
|
|
|
info = 1121
|
|
|
|
@ -762,7 +841,9 @@ contains
|
|
|
|
|
goto 9999
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
res = a%a%get_size()
|
|
|
|
|
call a%a%get_neigh(idx,neigh,n,info,lev)
|
|
|
|
|
|
|
|
|
|
if (info /= 0) goto 9999
|
|
|
|
|
|
|
|
|
|
call psb_erractionrestore(err_act)
|
|
|
|
|
return
|
|
|
|
@ -776,33 +857,66 @@ contains
|
|
|
|
|
end if
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
end function get_size
|
|
|
|
|
end subroutine get_neigh
|
|
|
|
|
|
|
|
|
|
subroutine sparse_print(iout,a,iv,eirs,eics,head,ivr,ivc)
|
|
|
|
|
|
|
|
|
|
subroutine csall(nr,nc,a,info,nz)
|
|
|
|
|
use psbn_d_base_mat_mod
|
|
|
|
|
use psb_error_mod
|
|
|
|
|
implicit none
|
|
|
|
|
class(psbn_d_sparse_mat), intent(out) :: a
|
|
|
|
|
integer, intent(in) :: nr,nc
|
|
|
|
|
integer, intent(out) :: info
|
|
|
|
|
integer, intent(in), optional :: nz
|
|
|
|
|
|
|
|
|
|
integer, intent(in) :: iout
|
|
|
|
|
class(psbn_d_sparse_mat), intent(in) :: a
|
|
|
|
|
integer, intent(in), optional :: iv(:)
|
|
|
|
|
integer, intent(in), optional :: eirs,eics
|
|
|
|
|
character(len=*), optional :: head
|
|
|
|
|
integer, intent(in), optional :: ivr(:), ivc(:)
|
|
|
|
|
Integer :: err_act
|
|
|
|
|
character(len=20) :: name='csall'
|
|
|
|
|
logical, parameter :: debug=.false.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
call psb_erractionsave(err_act)
|
|
|
|
|
info = 0
|
|
|
|
|
allocate(psbn_d_coo_sparse_mat :: a%a, stat=info)
|
|
|
|
|
if (info /= 0) then
|
|
|
|
|
info = 4000
|
|
|
|
|
call psb_errpush(info, name)
|
|
|
|
|
goto 9999
|
|
|
|
|
end if
|
|
|
|
|
call a%a%allocate(nr,nc,nz)
|
|
|
|
|
call a%set_bld()
|
|
|
|
|
|
|
|
|
|
call psb_erractionrestore(err_act)
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
9999 continue
|
|
|
|
|
call psb_erractionrestore(err_act)
|
|
|
|
|
|
|
|
|
|
if (err_act == psb_act_abort_) then
|
|
|
|
|
call psb_error()
|
|
|
|
|
return
|
|
|
|
|
end if
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
end subroutine csall
|
|
|
|
|
|
|
|
|
|
subroutine reallocate_nz(nz,a)
|
|
|
|
|
use psb_error_mod
|
|
|
|
|
implicit none
|
|
|
|
|
integer, intent(in) :: nz
|
|
|
|
|
class(psbn_d_sparse_mat), intent(inout) :: a
|
|
|
|
|
Integer :: err_act, info
|
|
|
|
|
character(len=20) :: name='sparse_print'
|
|
|
|
|
character(len=20) :: name='reallocate_nz'
|
|
|
|
|
logical, parameter :: debug=.false.
|
|
|
|
|
|
|
|
|
|
info = 0
|
|
|
|
|
call psb_erractionsave(err_act)
|
|
|
|
|
if (.not.allocated(a%a)) then
|
|
|
|
|
info = 1121
|
|
|
|
|
call psb_errpush(info,name)
|
|
|
|
|
goto 9999
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
call a%a%print(iout,iv,eirs,eics,head,ivr,ivc)
|
|
|
|
|
call a%a%reallocate(nz)
|
|
|
|
|
|
|
|
|
|
if (info /= 0) goto 9999
|
|
|
|
|
|
|
|
|
|
call psb_erractionrestore(err_act)
|
|
|
|
|
return
|
|
|
|
@ -816,23 +930,16 @@ contains
|
|
|
|
|
end if
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
end subroutine sparse_print
|
|
|
|
|
end subroutine reallocate_nz
|
|
|
|
|
|
|
|
|
|
subroutine get_neigh(a,idx,neigh,n,info,lev)
|
|
|
|
|
subroutine free(a)
|
|
|
|
|
use psb_error_mod
|
|
|
|
|
implicit none
|
|
|
|
|
class(psbn_d_sparse_mat), intent(in) :: a
|
|
|
|
|
integer, intent(in) :: idx
|
|
|
|
|
integer, intent(out) :: n
|
|
|
|
|
integer, allocatable, intent(out) :: neigh(:)
|
|
|
|
|
integer, intent(out) :: info
|
|
|
|
|
integer, optional, intent(in) :: lev
|
|
|
|
|
|
|
|
|
|
Integer :: err_act
|
|
|
|
|
character(len=20) :: name='get_neigh'
|
|
|
|
|
class(psbn_d_sparse_mat), intent(inout) :: a
|
|
|
|
|
Integer :: err_act, info
|
|
|
|
|
character(len=20) :: name='free'
|
|
|
|
|
logical, parameter :: debug=.false.
|
|
|
|
|
|
|
|
|
|
info = 0
|
|
|
|
|
call psb_erractionsave(err_act)
|
|
|
|
|
if (.not.allocated(a%a)) then
|
|
|
|
|
info = 1121
|
|
|
|
@ -840,9 +947,7 @@ contains
|
|
|
|
|
goto 9999
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
call a%a%get_neigh(idx,neigh,n,info,lev)
|
|
|
|
|
|
|
|
|
|
if (info /= 0) goto 9999
|
|
|
|
|
call a%a%free()
|
|
|
|
|
|
|
|
|
|
call psb_erractionrestore(err_act)
|
|
|
|
|
return
|
|
|
|
@ -856,63 +961,78 @@ contains
|
|
|
|
|
end if
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
end subroutine get_neigh
|
|
|
|
|
|
|
|
|
|
end subroutine free
|
|
|
|
|
|
|
|
|
|
subroutine allocate_mnnz(m,n,a,nz,type,mold)
|
|
|
|
|
subroutine csput(nz,val,ia,ja,a,imin,imax,jmin,jmax,info,gtl)
|
|
|
|
|
use psbn_d_base_mat_mod
|
|
|
|
|
use psb_error_mod
|
|
|
|
|
use psb_string_mod
|
|
|
|
|
implicit none
|
|
|
|
|
integer, intent(in) :: m,n
|
|
|
|
|
class(psbn_d_sparse_mat), intent(inout) :: a
|
|
|
|
|
integer, intent(in), optional :: nz
|
|
|
|
|
character(len=*), intent(in), optional :: type
|
|
|
|
|
class(psbn_d_base_sparse_mat), intent(in), optional :: mold
|
|
|
|
|
real(psb_dpk_), intent(in) :: val(:)
|
|
|
|
|
integer, intent(in) :: nz, ia(:), ja(:), imin,imax,jmin,jmax
|
|
|
|
|
integer, intent(out) :: info
|
|
|
|
|
integer, intent(in), optional :: gtl(:)
|
|
|
|
|
|
|
|
|
|
Integer :: err_act, info
|
|
|
|
|
character(len=20) :: name='allocate_mnnz'
|
|
|
|
|
character(len=8) :: type_
|
|
|
|
|
Integer :: err_act
|
|
|
|
|
character(len=20) :: name='csput'
|
|
|
|
|
logical, parameter :: debug=.false.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
call psb_erractionsave(err_act)
|
|
|
|
|
info = 0
|
|
|
|
|
if (allocated(a%a)) then
|
|
|
|
|
call a%a%free()
|
|
|
|
|
deallocate(a%a)
|
|
|
|
|
end if
|
|
|
|
|
call psb_erractionsave(err_act)
|
|
|
|
|
if (.not.a%is_bld()) then
|
|
|
|
|
info = 1121
|
|
|
|
|
call psb_errpush(info,name)
|
|
|
|
|
goto 9999
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
if (present(mold)) then
|
|
|
|
|
allocate(a%a, source=mold, stat=info)
|
|
|
|
|
|
|
|
|
|
else
|
|
|
|
|
call a%a%csput(nz,val,ia,ja,imin,imax,jmin,jmax,info,gtl)
|
|
|
|
|
if (info /= 0) goto 9999
|
|
|
|
|
|
|
|
|
|
if (present(type)) then
|
|
|
|
|
type_ = psb_toupper(type)
|
|
|
|
|
else
|
|
|
|
|
type_ = 'COO'
|
|
|
|
|
call psb_erractionrestore(err_act)
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
9999 continue
|
|
|
|
|
call psb_erractionrestore(err_act)
|
|
|
|
|
|
|
|
|
|
if (err_act == psb_act_abort_) then
|
|
|
|
|
call psb_error()
|
|
|
|
|
return
|
|
|
|
|
end if
|
|
|
|
|
|
|
|
|
|
select case(type)
|
|
|
|
|
case('COO')
|
|
|
|
|
allocate(psbn_d_coo_sparse_mat :: a%a, stat=info)
|
|
|
|
|
! Add here a few other data structures inplemented by default.
|
|
|
|
|
end subroutine csput
|
|
|
|
|
|
|
|
|
|
!!$ case('CSR')
|
|
|
|
|
!!$ allocate(psbn_d_csr_sparse_mat :: a%a, stat=info)
|
|
|
|
|
subroutine csget(nz,val,ia,ja,a,imin,imax,jmin,jmax,info,gtl)
|
|
|
|
|
use psbn_d_base_mat_mod
|
|
|
|
|
use psb_error_mod
|
|
|
|
|
implicit none
|
|
|
|
|
class(psbn_d_sparse_mat), intent(inout) :: a
|
|
|
|
|
real(psb_dpk_), intent(in) :: val(:)
|
|
|
|
|
integer, intent(out) :: nz, ia(:), ja(:)
|
|
|
|
|
integer, intent(in) :: imin,imax,jmin,jmax
|
|
|
|
|
integer, intent(out) :: info
|
|
|
|
|
integer, intent(in), optional :: gtl(:)
|
|
|
|
|
|
|
|
|
|
case default
|
|
|
|
|
allocate(psbn_d_coo_sparse_mat :: a%a, stat=info)
|
|
|
|
|
end select
|
|
|
|
|
Integer :: err_act
|
|
|
|
|
character(len=20) :: name='csput'
|
|
|
|
|
logical, parameter :: debug=.false.
|
|
|
|
|
|
|
|
|
|
end if
|
|
|
|
|
info = 0
|
|
|
|
|
call psb_erractionsave(err_act)
|
|
|
|
|
if (a%is_null()) then
|
|
|
|
|
info = 1121
|
|
|
|
|
call psb_errpush(info,name)
|
|
|
|
|
goto 9999
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
if (info /= 0) then
|
|
|
|
|
info = 4010
|
|
|
|
|
info = 700
|
|
|
|
|
call psb_errpush(info,name,a_err='CSGET')
|
|
|
|
|
goto 9999
|
|
|
|
|
end if
|
|
|
|
|
|
|
|
|
|
call a%a%allocate(m,n,nz)
|
|
|
|
|
|
|
|
|
|
!!$
|
|
|
|
|
!!$ call a%a%csget(nz,val,ia,ja,imin,imax,jmin,jmax,info,gtl)
|
|
|
|
|
!!$ if (info /= 0) goto 9999
|
|
|
|
|
|
|
|
|
|
call psb_erractionrestore(err_act)
|
|
|
|
|
return
|
|
|
|
@ -924,29 +1044,85 @@ contains
|
|
|
|
|
call psb_error()
|
|
|
|
|
return
|
|
|
|
|
end if
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
end subroutine csget
|
|
|
|
|
|
|
|
|
|
end subroutine allocate_mnnz
|
|
|
|
|
|
|
|
|
|
subroutine reallocate_nz(nz,a)
|
|
|
|
|
subroutine d_cscnv(a,b,info,type,mold,upd,dupl)
|
|
|
|
|
use psb_error_mod
|
|
|
|
|
use psb_string_mod
|
|
|
|
|
implicit none
|
|
|
|
|
integer, intent(in) :: nz
|
|
|
|
|
class(psbn_d_sparse_mat), intent(inout) :: a
|
|
|
|
|
Integer :: err_act, info
|
|
|
|
|
character(len=20) :: name='reallocate_nz'
|
|
|
|
|
class(psbn_d_sparse_mat), intent(in) :: a
|
|
|
|
|
class(psbn_d_sparse_mat), intent(out) :: b
|
|
|
|
|
integer, intent(out) :: info
|
|
|
|
|
integer,optional, intent(in) :: dupl, upd
|
|
|
|
|
character(len=*), optional, intent(in) :: type
|
|
|
|
|
class(psbn_d_base_sparse_mat), intent(in), optional :: mold
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class(psbn_d_base_sparse_mat), allocatable :: altmp
|
|
|
|
|
Integer :: err_act
|
|
|
|
|
character(len=20) :: name='cscnv'
|
|
|
|
|
logical, parameter :: debug=.false.
|
|
|
|
|
|
|
|
|
|
if (.not.allocated(a%a)) then
|
|
|
|
|
info = 0
|
|
|
|
|
call psb_erractionsave(err_act)
|
|
|
|
|
|
|
|
|
|
if (a%is_null()) then
|
|
|
|
|
info = 1121
|
|
|
|
|
call psb_errpush(info,name)
|
|
|
|
|
goto 9999
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
call a%a%reallocate(nz)
|
|
|
|
|
if (present(dupl)) then
|
|
|
|
|
call b%set_dupl(dupl)
|
|
|
|
|
else if (a%is_bld()) then
|
|
|
|
|
! Does this make sense at all?? Who knows..
|
|
|
|
|
call b%set_dupl(psbn_dupl_def_)
|
|
|
|
|
end if
|
|
|
|
|
|
|
|
|
|
if (info /= 0) goto 9999
|
|
|
|
|
if (count( (/present(mold),present(type) /)) > 1) then
|
|
|
|
|
info = 583
|
|
|
|
|
call psb_errpush(info,name,a_err='TYPE, MOLD')
|
|
|
|
|
goto 9999
|
|
|
|
|
end if
|
|
|
|
|
|
|
|
|
|
if (present(mold)) then
|
|
|
|
|
|
|
|
|
|
allocate(altmp, source=mold,stat=info)
|
|
|
|
|
|
|
|
|
|
else if (present(type)) then
|
|
|
|
|
|
|
|
|
|
select case (psb_toupper(type))
|
|
|
|
|
case ('CSR')
|
|
|
|
|
allocate(psbn_d_csr_sparse_mat :: altmp, stat=info)
|
|
|
|
|
case ('COO')
|
|
|
|
|
allocate(psbn_d_coo_sparse_mat :: altmp, stat=info)
|
|
|
|
|
case default
|
|
|
|
|
info = 136
|
|
|
|
|
call psb_errpush(info,name,a_err=type)
|
|
|
|
|
goto 9999
|
|
|
|
|
end select
|
|
|
|
|
else
|
|
|
|
|
allocate(psbn_d_csr_sparse_mat :: altmp, stat=info)
|
|
|
|
|
end if
|
|
|
|
|
|
|
|
|
|
if (info /= 0) then
|
|
|
|
|
info = 4000
|
|
|
|
|
call psb_errpush(info,name)
|
|
|
|
|
goto 9999
|
|
|
|
|
end if
|
|
|
|
|
|
|
|
|
|
call altmp%cp_from_fmt(a%a, info)
|
|
|
|
|
|
|
|
|
|
if (info /= 0) then
|
|
|
|
|
info = 4010
|
|
|
|
|
call psb_errpush(info,name,a_err="mv_from")
|
|
|
|
|
goto 9999
|
|
|
|
|
end if
|
|
|
|
|
|
|
|
|
|
call move_alloc(altmp,b%a)
|
|
|
|
|
call b%set_asb()
|
|
|
|
|
|
|
|
|
|
call psb_erractionrestore(err_act)
|
|
|
|
|
return
|
|
|
|
@ -958,26 +1134,84 @@ contains
|
|
|
|
|
call psb_error()
|
|
|
|
|
return
|
|
|
|
|
end if
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
end subroutine reallocate_nz
|
|
|
|
|
end subroutine d_cscnv
|
|
|
|
|
|
|
|
|
|
subroutine free(a)
|
|
|
|
|
|
|
|
|
|
subroutine d_cscnv_ip(a,info,type,mold,dupl)
|
|
|
|
|
use psb_error_mod
|
|
|
|
|
use psb_string_mod
|
|
|
|
|
implicit none
|
|
|
|
|
|
|
|
|
|
class(psbn_d_sparse_mat), intent(inout) :: a
|
|
|
|
|
Integer :: err_act, info
|
|
|
|
|
character(len=20) :: name='free'
|
|
|
|
|
integer, intent(out) :: info
|
|
|
|
|
integer,optional, intent(in) :: dupl
|
|
|
|
|
character(len=*), optional, intent(in) :: type
|
|
|
|
|
class(psbn_d_base_sparse_mat), intent(in), optional :: mold
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class(psbn_d_base_sparse_mat), allocatable :: altmp
|
|
|
|
|
Integer :: err_act
|
|
|
|
|
character(len=20) :: name='cscnv_ip'
|
|
|
|
|
logical, parameter :: debug=.false.
|
|
|
|
|
|
|
|
|
|
info = 0
|
|
|
|
|
call psb_erractionsave(err_act)
|
|
|
|
|
if (.not.allocated(a%a)) then
|
|
|
|
|
|
|
|
|
|
if (a%is_null()) then
|
|
|
|
|
info = 1121
|
|
|
|
|
call psb_errpush(info,name)
|
|
|
|
|
goto 9999
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
call a%a%free()
|
|
|
|
|
if (present(dupl)) then
|
|
|
|
|
call a%set_dupl(dupl)
|
|
|
|
|
else if (a%is_bld()) then
|
|
|
|
|
call a%set_dupl(psbn_dupl_def_)
|
|
|
|
|
end if
|
|
|
|
|
|
|
|
|
|
if (count( (/present(mold),present(type) /)) > 1) then
|
|
|
|
|
info = 583
|
|
|
|
|
call psb_errpush(info,name,a_err='TYPE, MOLD')
|
|
|
|
|
goto 9999
|
|
|
|
|
end if
|
|
|
|
|
|
|
|
|
|
if (present(mold)) then
|
|
|
|
|
|
|
|
|
|
allocate(altmp, source=mold,stat=info)
|
|
|
|
|
|
|
|
|
|
else if (present(type)) then
|
|
|
|
|
|
|
|
|
|
select case (psb_toupper(type))
|
|
|
|
|
case ('CSR')
|
|
|
|
|
allocate(psbn_d_csr_sparse_mat :: altmp, stat=info)
|
|
|
|
|
case ('COO')
|
|
|
|
|
allocate(psbn_d_coo_sparse_mat :: altmp, stat=info)
|
|
|
|
|
case default
|
|
|
|
|
info = 136
|
|
|
|
|
call psb_errpush(info,name,a_err=type)
|
|
|
|
|
goto 9999
|
|
|
|
|
end select
|
|
|
|
|
else
|
|
|
|
|
allocate(psbn_d_csr_sparse_mat :: altmp, stat=info)
|
|
|
|
|
end if
|
|
|
|
|
|
|
|
|
|
if (info /= 0) then
|
|
|
|
|
info = 4000
|
|
|
|
|
call psb_errpush(info,name)
|
|
|
|
|
goto 9999
|
|
|
|
|
end if
|
|
|
|
|
|
|
|
|
|
call altmp%mv_from_fmt(a%a, info)
|
|
|
|
|
|
|
|
|
|
if (info /= 0) then
|
|
|
|
|
info = 4010
|
|
|
|
|
call psb_errpush(info,name,a_err="mv_from")
|
|
|
|
|
goto 9999
|
|
|
|
|
end if
|
|
|
|
|
|
|
|
|
|
call move_alloc(altmp,a%a)
|
|
|
|
|
call a%set_asb()
|
|
|
|
|
|
|
|
|
|
call psb_erractionrestore(err_act)
|
|
|
|
|
return
|
|
|
|
@ -989,9 +1223,26 @@ contains
|
|
|
|
|
call psb_error()
|
|
|
|
|
return
|
|
|
|
|
end if
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
end subroutine free
|
|
|
|
|
end subroutine d_cscnv_ip
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
|
|
|
!
|
|
|
|
|
!
|
|
|
|
|
!
|
|
|
|
|
! Computational routines
|
|
|
|
|
!
|
|
|
|
|
!
|
|
|
|
|
!
|
|
|
|
|
!
|
|
|
|
|
!
|
|
|
|
|
!
|
|
|
|
|
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
subroutine d_csmm(alpha,a,x,beta,y,info,trans)
|
|
|
|
@ -1014,7 +1265,7 @@ contains
|
|
|
|
|
goto 9999
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
call a%a%psbn_csmm(alpha,x,beta,y,info,trans)
|
|
|
|
|
call a%a%csmm(alpha,x,beta,y,info,trans)
|
|
|
|
|
|
|
|
|
|
call psb_erractionrestore(err_act)
|
|
|
|
|
return
|
|
|
|
@ -1050,7 +1301,7 @@ contains
|
|
|
|
|
goto 9999
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
call a%a%psbn_csmm(alpha,x,beta,y,info,trans)
|
|
|
|
|
call a%a%csmm(alpha,x,beta,y,info,trans)
|
|
|
|
|
|
|
|
|
|
call psb_erractionrestore(err_act)
|
|
|
|
|
return
|
|
|
|
@ -1086,7 +1337,7 @@ contains
|
|
|
|
|
goto 9999
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
call a%a%psbn_cssm(alpha,x,beta,y,info,trans)
|
|
|
|
|
call a%a%cssm(alpha,x,beta,y,info,trans)
|
|
|
|
|
|
|
|
|
|
call psb_erractionrestore(err_act)
|
|
|
|
|
return
|
|
|
|
@ -1122,7 +1373,7 @@ contains
|
|
|
|
|
goto 9999
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
call a%a%psbn_cssm(alpha,x,beta,y,info,trans)
|
|
|
|
|
call a%a%cssm(alpha,x,beta,y,info,trans)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
call psb_erractionrestore(err_act)
|
|
|
|
|