You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
142 lines
3.4 KiB
Fortran
142 lines
3.4 KiB
Fortran
13 years ago
|
subroutine psb_z_mat_renum(alg,mat,info,perm)
|
||
14 years ago
|
use psb_base_mod
|
||
13 years ago
|
use psb_renum_mod, psb_protect_name => psb_z_mat_renum
|
||
14 years ago
|
implicit none
|
||
14 years ago
|
integer, intent(in) :: alg
|
||
13 years ago
|
type(psb_zspmat_type), intent(inout) :: mat
|
||
14 years ago
|
integer, intent(out) :: info
|
||
13 years ago
|
integer, allocatable, optional, intent(out) :: perm(:)
|
||
14 years ago
|
|
||
|
integer :: err_act
|
||
14 years ago
|
character(len=20) :: name
|
||
14 years ago
|
|
||
|
info = psb_success_
|
||
14 years ago
|
name = 'mat_renum'
|
||
14 years ago
|
call psb_erractionsave(err_act)
|
||
|
|
||
|
info = psb_success_
|
||
|
|
||
14 years ago
|
select case (alg)
|
||
14 years ago
|
case(psb_mat_renum_gps_)
|
||
14 years ago
|
|
||
13 years ago
|
call psb_mat_renum_gps(mat,info,perm)
|
||
14 years ago
|
|
||
14 years ago
|
case default
|
||
|
info = psb_err_input_value_invalid_i_
|
||
|
call psb_errpush(info,name,i_err=(/1,alg,0,0,0/))
|
||
|
goto 9999
|
||
|
end select
|
||
|
|
||
|
if (info /= psb_success_) then
|
||
|
info = psb_err_from_subroutine_non_
|
||
|
call psb_errpush(info,name)
|
||
|
goto 9999
|
||
|
end if
|
||
|
|
||
14 years ago
|
call psb_erractionrestore(err_act)
|
||
|
return
|
||
|
|
||
|
9999 continue
|
||
|
call psb_erractionrestore(err_act)
|
||
|
if (err_act == psb_act_abort_) then
|
||
14 years ago
|
call psb_error()
|
||
14 years ago
|
return
|
||
|
end if
|
||
|
return
|
||
|
|
||
14 years ago
|
contains
|
||
14 years ago
|
|
||
13 years ago
|
subroutine psb_mat_renum_gps(a,info,operm)
|
||
14 years ago
|
use psb_base_mod
|
||
|
use psb_gps_mod
|
||
|
implicit none
|
||
13 years ago
|
type(psb_zspmat_type), intent(inout) :: a
|
||
14 years ago
|
integer, intent(out) :: info
|
||
13 years ago
|
integer, allocatable, optional, intent(out) :: operm(:)
|
||
14 years ago
|
|
||
|
!
|
||
13 years ago
|
class(psb_z_base_sparse_mat), allocatable :: aa
|
||
|
type(psb_z_csr_sparse_mat) :: acsr
|
||
|
type(psb_z_coo_sparse_mat) :: acoo
|
||
14 years ago
|
|
||
|
integer :: err_act
|
||
|
character(len=20) :: name
|
||
14 years ago
|
integer, allocatable :: ndstk(:,:), iold(:), ndeg(:), perm(:)
|
||
|
integer :: i, j, k, ideg, nr, ibw, ipf, idpth
|
||
14 years ago
|
|
||
|
info = psb_success_
|
||
|
name = 'mat_renum'
|
||
|
call psb_erractionsave(err_act)
|
||
|
|
||
|
info = psb_success_
|
||
|
|
||
14 years ago
|
call a%mold(aa)
|
||
|
call a%mv_to(aa)
|
||
14 years ago
|
call aa%mv_to_fmt(acsr,info)
|
||
|
! Insert call to gps_reduce
|
||
14 years ago
|
nr = acsr%get_nrows()
|
||
|
ideg = 0
|
||
|
do i=1, nr
|
||
|
ideg = max(ideg,acsr%irp(i+1)-acsr%irp(i))
|
||
|
end do
|
||
|
allocate(ndstk(nr,ideg), iold(nr), perm(nr+1), ndeg(nr),stat=info)
|
||
|
if (info /= 0) then
|
||
|
info = psb_err_alloc_dealloc_
|
||
|
call psb_errpush(info, name)
|
||
|
goto 9999
|
||
|
end if
|
||
|
do i=1, nr
|
||
|
iold(i) = i
|
||
14 years ago
|
ndstk(i,:) = 0
|
||
|
k = 0
|
||
|
do j=acsr%irp(i),acsr%irp(i+1)-1
|
||
|
k = k + 1
|
||
|
ndstk(i,k) = acsr%ja(j)
|
||
|
end do
|
||
14 years ago
|
end do
|
||
|
perm = 0
|
||
|
|
||
|
call psb_gps_reduce(ndstk,nr,ideg,iold,perm,ndeg,ibw,ipf,idpth)
|
||
14 years ago
|
|
||
14 years ago
|
if (.not.psb_isaperm(nr,perm)) then
|
||
|
write(0,*) 'Something wrong: bad perm from gps_reduce'
|
||
|
info = psb_err_from_subroutine_
|
||
|
call psb_errpush(info,name)
|
||
|
goto 9999
|
||
|
end if
|
||
14 years ago
|
! Move to coordinate to apply renumbering
|
||
|
call acsr%mv_to_coo(acoo,info)
|
||
14 years ago
|
do i=1, acoo%get_nzeros()
|
||
|
acoo%ia(i) = perm(acoo%ia(i))
|
||
|
acoo%ja(i) = perm(acoo%ja(i))
|
||
|
end do
|
||
|
call acoo%fix(info)
|
||
14 years ago
|
|
||
|
! Get back to where we started from
|
||
|
call aa%mv_from_coo(acoo,info)
|
||
|
call a%mv_from(aa)
|
||
13 years ago
|
if (present(operm)) then
|
||
|
call psb_realloc(nr,operm,info)
|
||
|
if (info /= psb_success_) then
|
||
|
info = psb_err_alloc_dealloc_
|
||
|
call psb_errpush(info,name)
|
||
|
goto 9999
|
||
|
end if
|
||
|
operm(1:nr) = perm(1:nr)
|
||
|
end if
|
||
|
|
||
14 years ago
|
deallocate(aa)
|
||
|
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 psb_mat_renum_gps
|
||
14 years ago
|
|
||
13 years ago
|
end subroutine psb_z_mat_renum
|