@ -43,6 +43,12 @@ module psbn_d_mat_mod
end type psbn_d_sparse_mat
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_mn , allocate_mnnz , &
& reallocate_nz , free , d_csmv , d_csmm , d_cssv , d_cssm
contains
contains
function get_dupl ( a ) result ( res )
function get_dupl ( a ) result ( res )
@ -51,7 +57,7 @@ contains
integer :: res
integer :: res
if ( allocated ( a % a ) ) then
if ( allocated ( a % a ) ) then
res = a % a % get_dupl
res = a % a % get_dupl ( )
else
else
res = psbn_invalid_
res = psbn_invalid_
end if
end if
@ -304,48 +310,140 @@ contains
end subroutine get_neigh
end subroutine get_neigh
subroutine allocate_mn ( m , n , a )
subroutine allocate_mn ( m , n , a ,type , mold )
use psb_error_mod
use psb_error_mod
use psb_string_mod
integer , intent ( in ) :: m , n
integer , intent ( in ) :: m , n
class ( psbn_d_sparse_mat ) , intent ( inout ) :: a
class ( psbn_d_sparse_mat ) , intent ( inout ) :: a
character ( len = * ) , intent ( in ) , optional :: type
class ( psbn_d_base_sparse_mat ) , intent ( in ) , optional :: mold
Integer :: err_act
Integer :: err_act , info
character ( len = 20 ) :: name = 'allocate_mn'
character ( len = 20 ) :: name = 'allocate_mn'
character ( len = 8 ) :: type_
logical , parameter :: debug = . false .
logical , parameter :: debug = . false .
call psb_erractionsave ( err_act )
call psb_erractionsave ( err_act )
! This is the base version . If we get here
info = 0
! it means the derived class is incomplete ,
if ( allocated ( a % a ) ) then
! so we throw an error .
call a % a % free ( )
call psb_errpush ( 700 , name )
deallocate ( a % a )
end if
if ( present ( mold ) ) then
allocate ( a % a , source = mold , stat = info )
else
if ( present ( type ) ) then
type_ = psb_toupper ( type )
else
type_ = 'COO'
end if
if ( err_act / = psb_act_ret_ ) then
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 .
! ! $ case ( 'CSR' )
! ! $ allocate ( psbn_d_csr_sparse_mat :: a % a , stat = info )
case default
allocate ( psbn_d_coo_sparse_mat :: a % a , stat = info )
end select
end if
if ( info / = 0 ) then
info = 4010
go to 9999
end if
call a % a % allocate ( m , n )
call psb_erractionrestore ( err_act )
return
9999 continue
call psb_erractionrestore ( err_act )
if ( err_act == psb_act_abort_ ) then
call psb_error ( )
call psb_error ( )
return
end if
end if
return
return
end subroutine allocate_mn
end subroutine allocate_mn
subroutine allocate_mnnz ( m , n , nz , a )
subroutine allocate_mnnz ( m , n , nz , a ,type , mold )
use psb_error_mod
use psb_error_mod
use psb_string_mod
integer , intent ( in ) :: m , n , nz
integer , intent ( in ) :: m , n , nz
class ( psbn_d_sparse_mat ) , intent ( inout ) :: a
class ( psbn_d_sparse_mat ) , intent ( inout ) :: a
Integer :: err_act
character ( len = * ) , intent ( in ) , optional :: type
character ( len = 20 ) :: name = 'allocate_mnz'
class ( psbn_d_base_sparse_mat ) , intent ( in ) , optional :: mold
Integer :: err_act , info
character ( len = 20 ) :: name = 'allocate_mnnz'
character ( len = 8 ) :: type_
logical , parameter :: debug = . false .
logical , parameter :: debug = . false .
call psb_erractionsave ( err_act )
call psb_erractionsave ( err_act )
! This is the base version . If we get here
info = 0
! it means the derived class is incomplete ,
if ( allocated ( a % a ) ) then
! so we throw an error .
call a % a % free ( )
call psb_errpush ( 700 , name )
deallocate ( a % a )
end if
if ( present ( mold ) ) then
allocate ( a % a , source = mold , stat = info )
else
if ( present ( type ) ) then
type_ = psb_toupper ( type )
else
type_ = 'COO'
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 .
! ! $ case ( 'CSR' )
! ! $ allocate ( psbn_d_csr_sparse_mat :: a % a , stat = info )
if ( err_act / = psb_act_ret_ ) then
case default
allocate ( psbn_d_coo_sparse_mat :: a % a , stat = info )
end select
end if
if ( info / = 0 ) then
info = 4010
go to 9999
end if
call a % a % allocate ( m , n , nz )
call psb_erractionrestore ( err_act )
return
9999 continue
call psb_erractionrestore ( err_act )
if ( err_act == psb_act_abort_ ) then
call psb_error ( )
call psb_error ( )
return
end if
end if
return
return
end subroutine allocate_mnnz
end subroutine allocate_mnnz
subroutine reallocate_nz ( nz , a )
subroutine reallocate_nz ( nz , a )
@ -356,14 +454,25 @@ contains
character ( len = 20 ) :: name = 'reallocate_nz'
character ( len = 20 ) :: name = 'reallocate_nz'
logical , parameter :: debug = . false .
logical , parameter :: debug = . false .
call psb_erractionsave ( err_act )
if ( . not . allocated ( a % a ) ) then
! This is the base version . If we get here
info = 1121
! it means the derived class is incomplete ,
call psb_errpush ( info , name )
! so we throw an error .
go to 9999
call psb_errpush ( 700 , name )
endif
if ( err_act / = psb_act_ret_ ) then
call a % a % reallocate ( nz )
if ( info / = 0 ) go to 9999
call psb_erractionrestore ( err_act )
return
9999 continue
call psb_erractionrestore ( err_act )
if ( err_act == psb_act_abort_ ) then
call psb_error ( )
call psb_error ( )
return
end if
end if
return
return
@ -385,6 +494,16 @@ contains
call a % a % free ( )
call a % a % free ( )
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
return
end subroutine free
end subroutine free