|
|
|
@ -10,6 +10,7 @@ module psbn_d_base_mat_mod
|
|
|
|
|
procedure, pass(a) :: d_base_cssv
|
|
|
|
|
procedure, pass(a) :: d_base_cssm
|
|
|
|
|
generic, public :: cssm => d_base_cssm, d_base_cssv
|
|
|
|
|
procedure, pass(a) :: csnmi
|
|
|
|
|
procedure, pass(a) :: csput
|
|
|
|
|
procedure, pass(a) :: cp_to_coo
|
|
|
|
|
procedure, pass(a) :: cp_from_coo
|
|
|
|
@ -21,7 +22,7 @@ module psbn_d_base_mat_mod
|
|
|
|
|
procedure, pass(a) :: mv_from_fmt
|
|
|
|
|
end type psbn_d_base_sparse_mat
|
|
|
|
|
private :: d_base_csmv, d_base_csmm, d_base_cssv, d_base_cssm,&
|
|
|
|
|
& csput, cp_to_coo, cp_from_coo, cp_to_fmt, cp_from_fmt, &
|
|
|
|
|
& csnmi, csput, cp_to_coo, cp_from_coo, cp_to_fmt, cp_from_fmt, &
|
|
|
|
|
& mv_to_coo, mv_from_coo, mv_to_fmt, mv_from_fmt
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -40,6 +41,7 @@ module psbn_d_base_mat_mod
|
|
|
|
|
procedure, pass(a) :: d_base_csmv => d_coo_csmv
|
|
|
|
|
procedure, pass(a) :: d_base_cssm => d_coo_cssm
|
|
|
|
|
procedure, pass(a) :: d_base_cssv => d_coo_cssv
|
|
|
|
|
procedure, pass(a) :: csnmi => d_coo_csnmi
|
|
|
|
|
procedure, pass(a) :: csput => d_coo_csput
|
|
|
|
|
procedure, pass(a) :: reallocate_nz => d_coo_reallocate_nz
|
|
|
|
|
procedure, pass(a) :: allocate_mnnz => d_coo_allocate_mnnz
|
|
|
|
@ -58,7 +60,7 @@ module psbn_d_base_mat_mod
|
|
|
|
|
|
|
|
|
|
end type psbn_d_coo_sparse_mat
|
|
|
|
|
private :: d_coo_get_nzeros, d_coo_set_nzeros, &
|
|
|
|
|
& d_coo_csmm, d_coo_csmv, d_coo_cssm, d_coo_cssv, &
|
|
|
|
|
& d_coo_csmm, d_coo_csmv, d_coo_cssm, d_coo_cssv, d_coo_csnmi, &
|
|
|
|
|
& d_coo_csput, d_coo_reallocate_nz, d_coo_allocate_mnnz, &
|
|
|
|
|
& d_fix_coo, d_coo_free, d_coo_print, d_coo_get_fmt, &
|
|
|
|
|
& d_cp_coo_to_coo, d_cp_coo_from_coo, &
|
|
|
|
@ -221,9 +223,33 @@ module psbn_d_base_mat_mod
|
|
|
|
|
end subroutine d_coo_csmm_impl
|
|
|
|
|
end interface
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
interface d_coo_csnmi_impl
|
|
|
|
|
function d_coo_csnmi_impl(a) result(res)
|
|
|
|
|
use psb_const_mod
|
|
|
|
|
import psbn_d_coo_sparse_mat
|
|
|
|
|
class(psbn_d_coo_sparse_mat), intent(in) :: a
|
|
|
|
|
real(psb_dpk_) :: res
|
|
|
|
|
end function d_coo_csnmi_impl
|
|
|
|
|
end interface
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
contains
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
!====================================
|
|
|
|
|
!
|
|
|
|
|
!
|
|
|
|
|
!
|
|
|
|
|
! Data management
|
|
|
|
|
!
|
|
|
|
|
!
|
|
|
|
|
!
|
|
|
|
|
!
|
|
|
|
|
!
|
|
|
|
|
!====================================
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
subroutine cp_to_coo(a,b,info)
|
|
|
|
|
use psb_error_mod
|
|
|
|
|
use psb_realloc_mod
|
|
|
|
@ -236,7 +262,7 @@ contains
|
|
|
|
|
character(len=20) :: name='to_coo'
|
|
|
|
|
logical, parameter :: debug=.false.
|
|
|
|
|
|
|
|
|
|
call psb_erractionsave(err_act)
|
|
|
|
|
call psb_get_erraction(err_act)
|
|
|
|
|
! This is the base version. If we get here
|
|
|
|
|
! it means the derived class is incomplete,
|
|
|
|
|
! so we throw an error.
|
|
|
|
@ -262,7 +288,7 @@ contains
|
|
|
|
|
character(len=20) :: name='from_coo'
|
|
|
|
|
logical, parameter :: debug=.false.
|
|
|
|
|
|
|
|
|
|
call psb_erractionsave(err_act)
|
|
|
|
|
call psb_get_erraction(err_act)
|
|
|
|
|
! This is the base version. If we get here
|
|
|
|
|
! it means the derived class is incomplete,
|
|
|
|
|
! so we throw an error.
|
|
|
|
@ -289,7 +315,7 @@ contains
|
|
|
|
|
character(len=20) :: name='to_fmt'
|
|
|
|
|
logical, parameter :: debug=.false.
|
|
|
|
|
|
|
|
|
|
call psb_erractionsave(err_act)
|
|
|
|
|
call psb_get_erraction(err_act)
|
|
|
|
|
! This is the base version. If we get here
|
|
|
|
|
! it means the derived class is incomplete,
|
|
|
|
|
! so we throw an error.
|
|
|
|
@ -315,7 +341,7 @@ contains
|
|
|
|
|
character(len=20) :: name='from_fmt'
|
|
|
|
|
logical, parameter :: debug=.false.
|
|
|
|
|
|
|
|
|
|
call psb_erractionsave(err_act)
|
|
|
|
|
call psb_get_erraction(err_act)
|
|
|
|
|
! This is the base version. If we get here
|
|
|
|
|
! it means the derived class is incomplete,
|
|
|
|
|
! so we throw an error.
|
|
|
|
@ -342,7 +368,7 @@ contains
|
|
|
|
|
character(len=20) :: name='to_coo'
|
|
|
|
|
logical, parameter :: debug=.false.
|
|
|
|
|
|
|
|
|
|
call psb_erractionsave(err_act)
|
|
|
|
|
call psb_get_erraction(err_act)
|
|
|
|
|
! This is the base version. If we get here
|
|
|
|
|
! it means the derived class is incomplete,
|
|
|
|
|
! so we throw an error.
|
|
|
|
@ -368,7 +394,7 @@ contains
|
|
|
|
|
character(len=20) :: name='from_coo'
|
|
|
|
|
logical, parameter :: debug=.false.
|
|
|
|
|
|
|
|
|
|
call psb_erractionsave(err_act)
|
|
|
|
|
call psb_get_erraction(err_act)
|
|
|
|
|
! This is the base version. If we get here
|
|
|
|
|
! it means the derived class is incomplete,
|
|
|
|
|
! so we throw an error.
|
|
|
|
@ -395,7 +421,7 @@ contains
|
|
|
|
|
character(len=20) :: name='to_fmt'
|
|
|
|
|
logical, parameter :: debug=.false.
|
|
|
|
|
|
|
|
|
|
call psb_erractionsave(err_act)
|
|
|
|
|
call psb_get_erraction(err_act)
|
|
|
|
|
! This is the base version. If we get here
|
|
|
|
|
! it means the derived class is incomplete,
|
|
|
|
|
! so we throw an error.
|
|
|
|
@ -421,7 +447,7 @@ contains
|
|
|
|
|
character(len=20) :: name='from_fmt'
|
|
|
|
|
logical, parameter :: debug=.false.
|
|
|
|
|
|
|
|
|
|
call psb_erractionsave(err_act)
|
|
|
|
|
call psb_get_erraction(err_act)
|
|
|
|
|
! This is the base version. If we get here
|
|
|
|
|
! it means the derived class is incomplete,
|
|
|
|
|
! so we throw an error.
|
|
|
|
@ -435,47 +461,6 @@ contains
|
|
|
|
|
|
|
|
|
|
end subroutine mv_from_fmt
|
|
|
|
|
|
|
|
|
|
function d_coo_get_fmt(a) result(res)
|
|
|
|
|
implicit none
|
|
|
|
|
class(psbn_d_coo_sparse_mat), intent(in) :: a
|
|
|
|
|
character(len=5) :: res
|
|
|
|
|
res = 'COO'
|
|
|
|
|
end function d_coo_get_fmt
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
subroutine d_fix_coo(a,info,idir)
|
|
|
|
|
use psb_error_mod
|
|
|
|
|
use psb_const_mod
|
|
|
|
|
implicit none
|
|
|
|
|
class(psbn_d_coo_sparse_mat), intent(inout) :: a
|
|
|
|
|
integer, intent(out) :: info
|
|
|
|
|
integer, intent(in), optional :: idir
|
|
|
|
|
Integer :: err_act
|
|
|
|
|
character(len=20) :: name='fix_coo'
|
|
|
|
|
logical, parameter :: debug=.false.
|
|
|
|
|
|
|
|
|
|
call psb_erractionsave(err_act)
|
|
|
|
|
info = 0
|
|
|
|
|
call d_fix_coo_impl(a,info,idir)
|
|
|
|
|
|
|
|
|
|
if (info /= 0) goto 9999
|
|
|
|
|
|
|
|
|
|
call psb_erractionrestore(err_act)
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
9999 continue
|
|
|
|
|
call psb_erractionrestore(err_act)
|
|
|
|
|
|
|
|
|
|
call psb_errpush(info,name)
|
|
|
|
|
|
|
|
|
|
if (err_act /= psb_act_ret_) then
|
|
|
|
|
call psb_error()
|
|
|
|
|
end if
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
end subroutine d_fix_coo
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
subroutine csput(nz,val,ia,ja,a,imin,imax,jmin,jmax,info,gtl)
|
|
|
|
|
use psb_error_mod
|
|
|
|
@ -491,7 +476,7 @@ contains
|
|
|
|
|
character(len=20) :: name='csput'
|
|
|
|
|
logical, parameter :: debug=.false.
|
|
|
|
|
|
|
|
|
|
call psb_erractionsave(err_act)
|
|
|
|
|
call psb_get_erraction(err_act)
|
|
|
|
|
! This is the base version. If we get here
|
|
|
|
|
! it means the derived class is incomplete,
|
|
|
|
|
! so we throw an error.
|
|
|
|
@ -505,6 +490,19 @@ contains
|
|
|
|
|
|
|
|
|
|
end subroutine csput
|
|
|
|
|
|
|
|
|
|
!====================================
|
|
|
|
|
!
|
|
|
|
|
!
|
|
|
|
|
!
|
|
|
|
|
! Computational routines
|
|
|
|
|
!
|
|
|
|
|
!
|
|
|
|
|
!
|
|
|
|
|
!
|
|
|
|
|
!
|
|
|
|
|
!
|
|
|
|
|
!====================================
|
|
|
|
|
|
|
|
|
|
subroutine d_base_csmm(alpha,a,x,beta,y,info,trans)
|
|
|
|
|
use psb_error_mod
|
|
|
|
|
implicit none
|
|
|
|
@ -518,7 +516,7 @@ contains
|
|
|
|
|
character(len=20) :: name='d_base_csmm'
|
|
|
|
|
logical, parameter :: debug=.false.
|
|
|
|
|
|
|
|
|
|
call psb_erractionsave(err_act)
|
|
|
|
|
call psb_get_erraction(err_act)
|
|
|
|
|
! This is the base version. If we get here
|
|
|
|
|
! it means the derived class is incomplete,
|
|
|
|
|
! so we throw an error.
|
|
|
|
@ -545,7 +543,7 @@ contains
|
|
|
|
|
character(len=20) :: name='d_base_csmv'
|
|
|
|
|
logical, parameter :: debug=.false.
|
|
|
|
|
|
|
|
|
|
call psb_erractionsave(err_act)
|
|
|
|
|
call psb_get_erraction(err_act)
|
|
|
|
|
! This is the base version. If we get here
|
|
|
|
|
! it means the derived class is incomplete,
|
|
|
|
|
! so we throw an error.
|
|
|
|
@ -573,7 +571,7 @@ contains
|
|
|
|
|
character(len=20) :: name='d_base_cssm'
|
|
|
|
|
logical, parameter :: debug=.false.
|
|
|
|
|
|
|
|
|
|
call psb_erractionsave(err_act)
|
|
|
|
|
call psb_get_erraction(err_act)
|
|
|
|
|
! This is the base version. If we get here
|
|
|
|
|
! it means the derived class is incomplete,
|
|
|
|
|
! so we throw an error.
|
|
|
|
@ -600,7 +598,7 @@ contains
|
|
|
|
|
character(len=20) :: name='d_base_cssv'
|
|
|
|
|
logical, parameter :: debug=.false.
|
|
|
|
|
|
|
|
|
|
call psb_erractionsave(err_act)
|
|
|
|
|
call psb_get_erraction(err_act)
|
|
|
|
|
! This is the base version. If we get here
|
|
|
|
|
! it means the derived class is incomplete,
|
|
|
|
|
! so we throw an error.
|
|
|
|
@ -615,6 +613,158 @@ contains
|
|
|
|
|
|
|
|
|
|
end subroutine d_base_cssv
|
|
|
|
|
|
|
|
|
|
function csnmi(a) result(res)
|
|
|
|
|
use psb_error_mod
|
|
|
|
|
use psb_const_mod
|
|
|
|
|
implicit none
|
|
|
|
|
class(psbn_d_base_sparse_mat), intent(in) :: a
|
|
|
|
|
real(psb_dpk_) :: res
|
|
|
|
|
|
|
|
|
|
Integer :: err_act, info
|
|
|
|
|
character(len=20) :: name='csnmi'
|
|
|
|
|
logical, parameter :: debug=.false.
|
|
|
|
|
|
|
|
|
|
call psb_get_erraction(err_act)
|
|
|
|
|
! This is the base version. If we get here
|
|
|
|
|
! it means the derived class is incomplete,
|
|
|
|
|
! so we throw an error.
|
|
|
|
|
info = 700
|
|
|
|
|
call psb_errpush(info,name,a_err=a%get_fmt())
|
|
|
|
|
write(0,*) 'Got into error path',err_act,psb_act_ret_
|
|
|
|
|
if (err_act /= psb_act_ret_) then
|
|
|
|
|
call psb_error()
|
|
|
|
|
end if
|
|
|
|
|
res = -done
|
|
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
end function csnmi
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
!====================================
|
|
|
|
|
!
|
|
|
|
|
!
|
|
|
|
|
!
|
|
|
|
|
! Getters
|
|
|
|
|
!
|
|
|
|
|
!
|
|
|
|
|
!
|
|
|
|
|
!
|
|
|
|
|
!
|
|
|
|
|
!====================================
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function d_coo_get_fmt(a) result(res)
|
|
|
|
|
implicit none
|
|
|
|
|
class(psbn_d_coo_sparse_mat), intent(in) :: a
|
|
|
|
|
character(len=5) :: res
|
|
|
|
|
res = 'COO'
|
|
|
|
|
end function d_coo_get_fmt
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function d_coo_get_size(a) result(res)
|
|
|
|
|
implicit none
|
|
|
|
|
class(psbn_d_coo_sparse_mat), intent(in) :: a
|
|
|
|
|
integer :: res
|
|
|
|
|
res = -1
|
|
|
|
|
|
|
|
|
|
if (allocated(a%ia)) res = size(a%ia)
|
|
|
|
|
if (allocated(a%ja)) then
|
|
|
|
|
if (res >= 0) then
|
|
|
|
|
res = min(res,size(a%ja))
|
|
|
|
|
else
|
|
|
|
|
res = size(a%ja)
|
|
|
|
|
end if
|
|
|
|
|
end if
|
|
|
|
|
if (allocated(a%val)) then
|
|
|
|
|
if (res >= 0) then
|
|
|
|
|
res = min(res,size(a%val))
|
|
|
|
|
else
|
|
|
|
|
res = size(a%val)
|
|
|
|
|
end if
|
|
|
|
|
end if
|
|
|
|
|
end function d_coo_get_size
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function d_coo_get_nzeros(a) result(res)
|
|
|
|
|
implicit none
|
|
|
|
|
class(psbn_d_coo_sparse_mat), intent(in) :: a
|
|
|
|
|
integer :: res
|
|
|
|
|
res = a%nnz
|
|
|
|
|
end function d_coo_get_nzeros
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
!====================================
|
|
|
|
|
!
|
|
|
|
|
!
|
|
|
|
|
!
|
|
|
|
|
! Setters
|
|
|
|
|
!
|
|
|
|
|
!
|
|
|
|
|
!
|
|
|
|
|
!
|
|
|
|
|
!
|
|
|
|
|
!
|
|
|
|
|
!====================================
|
|
|
|
|
|
|
|
|
|
subroutine d_coo_set_nzeros(nz,a)
|
|
|
|
|
implicit none
|
|
|
|
|
integer, intent(in) :: nz
|
|
|
|
|
class(psbn_d_coo_sparse_mat), intent(inout) :: a
|
|
|
|
|
|
|
|
|
|
a%nnz = nz
|
|
|
|
|
|
|
|
|
|
end subroutine d_coo_set_nzeros
|
|
|
|
|
|
|
|
|
|
!====================================
|
|
|
|
|
!
|
|
|
|
|
!
|
|
|
|
|
!
|
|
|
|
|
! Data management
|
|
|
|
|
!
|
|
|
|
|
!
|
|
|
|
|
!
|
|
|
|
|
!
|
|
|
|
|
!
|
|
|
|
|
!====================================
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
subroutine d_fix_coo(a,info,idir)
|
|
|
|
|
use psb_error_mod
|
|
|
|
|
use psb_const_mod
|
|
|
|
|
implicit none
|
|
|
|
|
class(psbn_d_coo_sparse_mat), intent(inout) :: a
|
|
|
|
|
integer, intent(out) :: info
|
|
|
|
|
integer, intent(in), optional :: idir
|
|
|
|
|
Integer :: err_act
|
|
|
|
|
character(len=20) :: name='fix_coo'
|
|
|
|
|
logical, parameter :: debug=.false.
|
|
|
|
|
|
|
|
|
|
call psb_erractionsave(err_act)
|
|
|
|
|
info = 0
|
|
|
|
|
call d_fix_coo_impl(a,info,idir)
|
|
|
|
|
|
|
|
|
|
if (info /= 0) goto 9999
|
|
|
|
|
|
|
|
|
|
call psb_erractionrestore(err_act)
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
9999 continue
|
|
|
|
|
call psb_erractionrestore(err_act)
|
|
|
|
|
|
|
|
|
|
call psb_errpush(info,name)
|
|
|
|
|
|
|
|
|
|
if (err_act /= psb_act_ret_) then
|
|
|
|
|
call psb_error()
|
|
|
|
|
end if
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
end subroutine d_fix_coo
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
subroutine d_cp_coo_to_coo(a,b,info)
|
|
|
|
|
use psb_error_mod
|
|
|
|
@ -910,48 +1060,6 @@ contains
|
|
|
|
|
end subroutine d_coo_reallocate_nz
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function d_coo_get_size(a) result(res)
|
|
|
|
|
implicit none
|
|
|
|
|
class(psbn_d_coo_sparse_mat), intent(in) :: a
|
|
|
|
|
integer :: res
|
|
|
|
|
res = -1
|
|
|
|
|
|
|
|
|
|
if (allocated(a%ia)) res = size(a%ia)
|
|
|
|
|
if (allocated(a%ja)) then
|
|
|
|
|
if (res >= 0) then
|
|
|
|
|
res = min(res,size(a%ja))
|
|
|
|
|
else
|
|
|
|
|
res = size(a%ja)
|
|
|
|
|
end if
|
|
|
|
|
end if
|
|
|
|
|
if (allocated(a%val)) then
|
|
|
|
|
if (res >= 0) then
|
|
|
|
|
res = min(res,size(a%val))
|
|
|
|
|
else
|
|
|
|
|
res = size(a%val)
|
|
|
|
|
end if
|
|
|
|
|
end if
|
|
|
|
|
end function d_coo_get_size
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function d_coo_get_nzeros(a) result(res)
|
|
|
|
|
implicit none
|
|
|
|
|
class(psbn_d_coo_sparse_mat), intent(in) :: a
|
|
|
|
|
integer :: res
|
|
|
|
|
res = a%nnz
|
|
|
|
|
end function d_coo_get_nzeros
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
subroutine d_coo_set_nzeros(nz,a)
|
|
|
|
|
implicit none
|
|
|
|
|
integer, intent(in) :: nz
|
|
|
|
|
class(psbn_d_coo_sparse_mat), intent(inout) :: a
|
|
|
|
|
|
|
|
|
|
a%nnz = nz
|
|
|
|
|
|
|
|
|
|
end subroutine d_coo_set_nzeros
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
subroutine d_coo_csput(nz,val,ia,ja,a,imin,imax,jmin,jmax,info,gtl)
|
|
|
|
|
use psb_error_mod
|
|
|
|
|
use psb_realloc_mod
|
|
|
|
@ -1017,6 +1125,169 @@ contains
|
|
|
|
|
end subroutine d_coo_csput
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
subroutine d_coo_free(a)
|
|
|
|
|
implicit none
|
|
|
|
|
|
|
|
|
|
class(psbn_d_coo_sparse_mat), intent(inout) :: a
|
|
|
|
|
|
|
|
|
|
if (allocated(a%ia)) deallocate(a%ia)
|
|
|
|
|
if (allocated(a%ja)) deallocate(a%ja)
|
|
|
|
|
if (allocated(a%val)) deallocate(a%val)
|
|
|
|
|
call a%set_null()
|
|
|
|
|
call a%set_nrows(0)
|
|
|
|
|
call a%set_ncols(0)
|
|
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
end subroutine d_coo_free
|
|
|
|
|
|
|
|
|
|
subroutine d_coo_allocate_mnnz(m,n,a,nz)
|
|
|
|
|
use psb_error_mod
|
|
|
|
|
use psb_realloc_mod
|
|
|
|
|
implicit none
|
|
|
|
|
integer, intent(in) :: m,n
|
|
|
|
|
class(psbn_d_coo_sparse_mat), intent(inout) :: a
|
|
|
|
|
integer, intent(in), optional :: nz
|
|
|
|
|
Integer :: err_act, info, nz_
|
|
|
|
|
character(len=20) :: name='allocate_mnz'
|
|
|
|
|
logical, parameter :: debug=.false.
|
|
|
|
|
|
|
|
|
|
call psb_erractionsave(err_act)
|
|
|
|
|
info = 0
|
|
|
|
|
if (m < 0) then
|
|
|
|
|
info = 10
|
|
|
|
|
call psb_errpush(info,name,i_err=(/1,0,0,0,0/))
|
|
|
|
|
goto 9999
|
|
|
|
|
endif
|
|
|
|
|
if (n < 0) then
|
|
|
|
|
info = 10
|
|
|
|
|
call psb_errpush(info,name,i_err=(/2,0,0,0,0/))
|
|
|
|
|
goto 9999
|
|
|
|
|
endif
|
|
|
|
|
if (present(nz)) then
|
|
|
|
|
nz_ = nz
|
|
|
|
|
else
|
|
|
|
|
nz_ = max(7*m,7*n,1)
|
|
|
|
|
end if
|
|
|
|
|
if (nz_ < 0) then
|
|
|
|
|
info = 10
|
|
|
|
|
call psb_errpush(info,name,i_err=(/3,0,0,0,0/))
|
|
|
|
|
goto 9999
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
if (info == 0) call psb_realloc(nz_,a%ia,info)
|
|
|
|
|
if (info == 0) call psb_realloc(nz_,a%ja,info)
|
|
|
|
|
if (info == 0) call psb_realloc(nz_,a%val,info)
|
|
|
|
|
if (info == 0) then
|
|
|
|
|
call a%set_nrows(m)
|
|
|
|
|
call a%set_ncols(n)
|
|
|
|
|
call a%set_nzeros(0)
|
|
|
|
|
call a%set_bld()
|
|
|
|
|
call a%set_triangle(.false.)
|
|
|
|
|
call a%set_dupl(psbn_dupl_def_)
|
|
|
|
|
end if
|
|
|
|
|
if (info /= 0) goto 9999
|
|
|
|
|
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 d_coo_allocate_mnnz
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
subroutine d_coo_print(iout,a,iv,eirs,eics,head,ivr,ivc)
|
|
|
|
|
use psb_spmat_type
|
|
|
|
|
use psb_string_mod
|
|
|
|
|
implicit none
|
|
|
|
|
|
|
|
|
|
integer, intent(in) :: iout
|
|
|
|
|
class(psbn_d_coo_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='d_coo_print'
|
|
|
|
|
logical, parameter :: debug=.false.
|
|
|
|
|
|
|
|
|
|
character(len=80) :: frmtv
|
|
|
|
|
integer :: irs,ics,i,j, nmx, ni, nr, nc, nz
|
|
|
|
|
|
|
|
|
|
if (present(eirs)) then
|
|
|
|
|
irs = eirs
|
|
|
|
|
else
|
|
|
|
|
irs = 0
|
|
|
|
|
endif
|
|
|
|
|
if (present(eics)) then
|
|
|
|
|
ics = eics
|
|
|
|
|
else
|
|
|
|
|
ics = 0
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
if (present(head)) then
|
|
|
|
|
write(iout,'(a)') '%%MatrixMarket matrix coordinate real general'
|
|
|
|
|
write(iout,'(a,a)') '% ',head
|
|
|
|
|
write(iout,'(a)') '%'
|
|
|
|
|
write(iout,'(a,a)') '% COO'
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
nr = a%get_nrows()
|
|
|
|
|
nc = a%get_ncols()
|
|
|
|
|
nz = a%get_nzeros()
|
|
|
|
|
nmx = max(nr,nc,1)
|
|
|
|
|
ni = floor(log10(1.0*nmx)) + 1
|
|
|
|
|
|
|
|
|
|
write(frmtv,'(a,i3.3,a,i3.3,a)') '(2(i',ni,',1x),es26.18,1x,2(i',ni,',1x))'
|
|
|
|
|
write(iout,*) nr, nc, nz
|
|
|
|
|
if(present(iv)) then
|
|
|
|
|
do j=1,a%get_nzeros()
|
|
|
|
|
write(iout,frmtv) iv(a%ia(j)),iv(a%ja(j)),a%val(j)
|
|
|
|
|
enddo
|
|
|
|
|
else
|
|
|
|
|
if (present(ivr).and..not.present(ivc)) then
|
|
|
|
|
do j=1,a%get_nzeros()
|
|
|
|
|
write(iout,frmtv) ivr(a%ia(j)),a%ja(j),a%val(j)
|
|
|
|
|
enddo
|
|
|
|
|
else if (present(ivr).and.present(ivc)) then
|
|
|
|
|
do j=1,a%get_nzeros()
|
|
|
|
|
write(iout,frmtv) ivr(a%ia(j)),ivc(a%ja(j)),a%val(j)
|
|
|
|
|
enddo
|
|
|
|
|
else if (.not.present(ivr).and.present(ivc)) then
|
|
|
|
|
do j=1,a%get_nzeros()
|
|
|
|
|
write(iout,frmtv) a%ia(j),ivc(a%ja(j)),a%val(j)
|
|
|
|
|
enddo
|
|
|
|
|
else if (.not.present(ivr).and..not.present(ivc)) then
|
|
|
|
|
do j=1,a%get_nzeros()
|
|
|
|
|
write(iout,frmtv) a%ia(j),a%ja(j),a%val(j)
|
|
|
|
|
enddo
|
|
|
|
|
endif
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
end subroutine d_coo_print
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
!====================================
|
|
|
|
|
!
|
|
|
|
|
!
|
|
|
|
|
!
|
|
|
|
|
! Computational routines
|
|
|
|
|
!
|
|
|
|
|
!
|
|
|
|
|
!
|
|
|
|
|
!
|
|
|
|
|
!
|
|
|
|
|
!
|
|
|
|
|
!====================================
|
|
|
|
|
|
|
|
|
|
subroutine d_coo_csmv(alpha,a,x,beta,y,info,trans)
|
|
|
|
|
use psb_error_mod
|
|
|
|
|
implicit none
|
|
|
|
@ -1205,155 +1476,23 @@ contains
|
|
|
|
|
|
|
|
|
|
end subroutine d_coo_cssm
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
subroutine d_coo_free(a)
|
|
|
|
|
implicit none
|
|
|
|
|
|
|
|
|
|
class(psbn_d_coo_sparse_mat), intent(inout) :: a
|
|
|
|
|
|
|
|
|
|
if (allocated(a%ia)) deallocate(a%ia)
|
|
|
|
|
if (allocated(a%ja)) deallocate(a%ja)
|
|
|
|
|
if (allocated(a%val)) deallocate(a%val)
|
|
|
|
|
call a%set_null()
|
|
|
|
|
call a%set_nrows(0)
|
|
|
|
|
call a%set_ncols(0)
|
|
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
end subroutine d_coo_free
|
|
|
|
|
|
|
|
|
|
subroutine d_coo_allocate_mnnz(m,n,a,nz)
|
|
|
|
|
function d_coo_csnmi(a) result(res)
|
|
|
|
|
use psb_error_mod
|
|
|
|
|
use psb_realloc_mod
|
|
|
|
|
implicit none
|
|
|
|
|
integer, intent(in) :: m,n
|
|
|
|
|
class(psbn_d_coo_sparse_mat), intent(inout) :: a
|
|
|
|
|
integer, intent(in), optional :: nz
|
|
|
|
|
Integer :: err_act, info, nz_
|
|
|
|
|
character(len=20) :: name='allocate_mnz'
|
|
|
|
|
logical, parameter :: debug=.false.
|
|
|
|
|
|
|
|
|
|
call psb_erractionsave(err_act)
|
|
|
|
|
info = 0
|
|
|
|
|
if (m < 0) then
|
|
|
|
|
info = 10
|
|
|
|
|
call psb_errpush(info,name,i_err=(/1,0,0,0,0/))
|
|
|
|
|
goto 9999
|
|
|
|
|
endif
|
|
|
|
|
if (n < 0) then
|
|
|
|
|
info = 10
|
|
|
|
|
call psb_errpush(info,name,i_err=(/2,0,0,0,0/))
|
|
|
|
|
goto 9999
|
|
|
|
|
endif
|
|
|
|
|
if (present(nz)) then
|
|
|
|
|
nz_ = nz
|
|
|
|
|
else
|
|
|
|
|
nz_ = max(7*m,7*n,1)
|
|
|
|
|
end if
|
|
|
|
|
if (nz_ < 0) then
|
|
|
|
|
info = 10
|
|
|
|
|
call psb_errpush(info,name,i_err=(/3,0,0,0,0/))
|
|
|
|
|
goto 9999
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
if (info == 0) call psb_realloc(nz_,a%ia,info)
|
|
|
|
|
if (info == 0) call psb_realloc(nz_,a%ja,info)
|
|
|
|
|
if (info == 0) call psb_realloc(nz_,a%val,info)
|
|
|
|
|
if (info == 0) then
|
|
|
|
|
call a%set_nrows(m)
|
|
|
|
|
call a%set_ncols(n)
|
|
|
|
|
call a%set_nzeros(0)
|
|
|
|
|
call a%set_bld()
|
|
|
|
|
call a%set_triangle(.false.)
|
|
|
|
|
call a%set_dupl(psbn_dupl_def_)
|
|
|
|
|
end if
|
|
|
|
|
if (info /= 0) goto 9999
|
|
|
|
|
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 d_coo_allocate_mnnz
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
subroutine d_coo_print(iout,a,iv,eirs,eics,head,ivr,ivc)
|
|
|
|
|
use psb_spmat_type
|
|
|
|
|
use psb_string_mod
|
|
|
|
|
use psb_const_mod
|
|
|
|
|
implicit none
|
|
|
|
|
|
|
|
|
|
integer, intent(in) :: iout
|
|
|
|
|
class(psbn_d_coo_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(:)
|
|
|
|
|
real(psb_dpk_) :: res
|
|
|
|
|
|
|
|
|
|
Integer :: err_act
|
|
|
|
|
character(len=20) :: name='d_coo_print'
|
|
|
|
|
character(len=20) :: name='csnmi'
|
|
|
|
|
logical, parameter :: debug=.false.
|
|
|
|
|
|
|
|
|
|
character(len=80) :: frmtv
|
|
|
|
|
integer :: irs,ics,i,j, nmx, ni, nr, nc, nz
|
|
|
|
|
|
|
|
|
|
if (present(eirs)) then
|
|
|
|
|
irs = eirs
|
|
|
|
|
else
|
|
|
|
|
irs = 0
|
|
|
|
|
endif
|
|
|
|
|
if (present(eics)) then
|
|
|
|
|
ics = eics
|
|
|
|
|
else
|
|
|
|
|
ics = 0
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
if (present(head)) then
|
|
|
|
|
write(iout,'(a)') '%%MatrixMarket matrix coordinate real general'
|
|
|
|
|
write(iout,'(a,a)') '% ',head
|
|
|
|
|
write(iout,'(a)') '%'
|
|
|
|
|
write(iout,'(a,a)') '% COO'
|
|
|
|
|
endif
|
|
|
|
|
res = d_coo_csnmi_impl(a)
|
|
|
|
|
|
|
|
|
|
nr = a%get_nrows()
|
|
|
|
|
nc = a%get_ncols()
|
|
|
|
|
nz = a%get_nzeros()
|
|
|
|
|
nmx = max(nr,nc,1)
|
|
|
|
|
ni = floor(log10(1.0*nmx)) + 1
|
|
|
|
|
|
|
|
|
|
write(frmtv,'(a,i3.3,a,i3.3,a)') '(2(i',ni,',1x),es26.18,1x,2(i',ni,',1x))'
|
|
|
|
|
write(iout,*) nr, nc, nz
|
|
|
|
|
if(present(iv)) then
|
|
|
|
|
do j=1,a%get_nzeros()
|
|
|
|
|
write(iout,frmtv) iv(a%ia(j)),iv(a%ja(j)),a%val(j)
|
|
|
|
|
enddo
|
|
|
|
|
else
|
|
|
|
|
if (present(ivr).and..not.present(ivc)) then
|
|
|
|
|
do j=1,a%get_nzeros()
|
|
|
|
|
write(iout,frmtv) ivr(a%ia(j)),a%ja(j),a%val(j)
|
|
|
|
|
enddo
|
|
|
|
|
else if (present(ivr).and.present(ivc)) then
|
|
|
|
|
do j=1,a%get_nzeros()
|
|
|
|
|
write(iout,frmtv) ivr(a%ia(j)),ivc(a%ja(j)),a%val(j)
|
|
|
|
|
enddo
|
|
|
|
|
else if (.not.present(ivr).and.present(ivc)) then
|
|
|
|
|
do j=1,a%get_nzeros()
|
|
|
|
|
write(iout,frmtv) a%ia(j),ivc(a%ja(j)),a%val(j)
|
|
|
|
|
enddo
|
|
|
|
|
else if (.not.present(ivr).and..not.present(ivc)) then
|
|
|
|
|
do j=1,a%get_nzeros()
|
|
|
|
|
write(iout,frmtv) a%ia(j),a%ja(j),a%val(j)
|
|
|
|
|
enddo
|
|
|
|
|
endif
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
end subroutine d_coo_print
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
end function d_coo_csnmi
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
end module psbn_d_base_mat_mod
|
|
|
|
|