Merged new serial code.
parent
2875be5e2d
commit
7cbb943e6c
@ -0,0 +1,361 @@
|
||||
!!$
|
||||
!!$ Parallel Sparse BLAS v2.0
|
||||
!!$ (C) Copyright 2006 Salvatore Filippone University of Rome Tor Vergata
|
||||
!!$ Alfredo Buttari University of Rome Tor Vergata
|
||||
!!$
|
||||
!!$ Redistribution and use in source and binary forms, with or without
|
||||
!!$ modification, are permitted provided that the following conditions
|
||||
!!$ are met:
|
||||
!!$ 1. Redistributions of source code must retain the above copyright
|
||||
!!$ notice, this list of conditions and the following disclaimer.
|
||||
!!$ 2. Redistributions in binary form must reproduce the above copyright
|
||||
!!$ notice, this list of conditions, and the following disclaimer in the
|
||||
!!$ documentation and/or other materials provided with the distribution.
|
||||
!!$ 3. The name of the PSBLAS group or the names of its contributors may
|
||||
!!$ not be used to endorse or promote products derived from this
|
||||
!!$ software without specific written permission.
|
||||
!!$
|
||||
!!$ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
!!$ ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
!!$ TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
!!$ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PSBLAS GROUP OR ITS CONTRIBUTORS
|
||||
!!$ BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
!!$ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
!!$ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
!!$ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
!!$ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
!!$ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
!!$ POSSIBILITY OF SUCH DAMAGE.
|
||||
!!$
|
||||
!!$
|
||||
|
||||
subroutine dasr(n,x,dir)
|
||||
use psb_serial_mod
|
||||
implicit none
|
||||
!
|
||||
! Quicksort on absolute value.
|
||||
! Adapted from a number of sources, including Don Knuth's TAOCP.
|
||||
!
|
||||
! .. Scalar Arguments ..
|
||||
integer, intent(in) :: n, dir
|
||||
real(kind(1.d0)) :: x(n)
|
||||
! ..
|
||||
! .. Local Scalars ..
|
||||
real(kind(1.d0)) :: xx, piv, xt, xk
|
||||
integer i, j, ilx, iux, istp, lpiv
|
||||
integer n1, n2
|
||||
|
||||
integer, parameter :: maxstack=64,nparms=3,ithrs=16
|
||||
integer :: istack(nparms,maxstack)
|
||||
! ..
|
||||
|
||||
!
|
||||
! small inputs will only get through insertion sort.
|
||||
!
|
||||
select case(dir)
|
||||
|
||||
case(psb_asort_up_)
|
||||
|
||||
if (n > ithrs) then
|
||||
!
|
||||
! Init stack pointer
|
||||
!
|
||||
istp = 1
|
||||
istack(1,istp) = 1
|
||||
istack(2,istp) = n
|
||||
|
||||
do
|
||||
if (istp <= 0) exit
|
||||
ilx = istack(1,istp)
|
||||
iux = istack(2,istp)
|
||||
istp = istp - 1
|
||||
!$$$ write(0,*) 'Debug 1: ',ilx,iux
|
||||
!
|
||||
! Choose a pivot with median-of-three heuristics, leave it
|
||||
! in the LPIV location
|
||||
!
|
||||
i = ilx
|
||||
j = iux
|
||||
lpiv = (i+j)/2
|
||||
piv = abs(x(lpiv))
|
||||
if (piv < abs(x(i))) then
|
||||
xt = x(i)
|
||||
x(i) = x(lpiv)
|
||||
x(lpiv) = xt
|
||||
piv = abs(x(lpiv))
|
||||
endif
|
||||
if (piv > abs(x(j))) then
|
||||
xt = x(j)
|
||||
x(j) = x(lpiv)
|
||||
x(lpiv) = xt
|
||||
piv = abs(x(lpiv))
|
||||
endif
|
||||
if (piv < abs(x(i))) then
|
||||
xt = x(i)
|
||||
x(i) = x(lpiv)
|
||||
x(lpiv) = xt
|
||||
piv = abs(x(lpiv))
|
||||
endif
|
||||
!
|
||||
! now piv is correct; place it into first location
|
||||
|
||||
xt = x(i)
|
||||
x(i) = x(lpiv)
|
||||
x(lpiv) = xt
|
||||
|
||||
i = ilx - 1
|
||||
j = iux + 1
|
||||
|
||||
outer_up: do
|
||||
in_up1: do
|
||||
i = i + 1
|
||||
xk = abs(x(i))
|
||||
if (xk >= piv) exit in_up1
|
||||
end do in_up1
|
||||
!
|
||||
! Ensure finite termination for next loop
|
||||
!
|
||||
xt = x(i)
|
||||
x(i) = piv
|
||||
in_up2:do
|
||||
j = j - 1
|
||||
xk = abs(x(j))
|
||||
if (xk <= piv) exit in_up2
|
||||
end do in_up2
|
||||
x(i) = xt
|
||||
|
||||
if (j > i) then
|
||||
xt = x(i)
|
||||
x(i) = x(j)
|
||||
x(j) = xt
|
||||
else
|
||||
exit outer_up
|
||||
end if
|
||||
end do outer_up
|
||||
if (i == ilx) then
|
||||
if (x(i) /= piv) then
|
||||
write(0,*) 'Should never ever get here????!!!!'
|
||||
stop
|
||||
endif
|
||||
i = i + 1
|
||||
endif
|
||||
|
||||
n1 = (i-1)-ilx+1
|
||||
n2 = iux-(i)+1
|
||||
if (n1 > n2) then
|
||||
if (n1 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = ilx
|
||||
istack(2,istp) = i-1
|
||||
else
|
||||
call disr_up(n1,x(ilx:i-1))
|
||||
endif
|
||||
if (n2 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = i
|
||||
istack(2,istp) = iux
|
||||
else
|
||||
call disr_up(n2,x(i:iux))
|
||||
endif
|
||||
else
|
||||
if (n2 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = i
|
||||
istack(2,istp) = iux
|
||||
else
|
||||
call disr_up(n2,x(i:iux))
|
||||
endif
|
||||
if (n1 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = ilx
|
||||
istack(2,istp) = i-1
|
||||
else
|
||||
call disr_up(n1,x(ilx:i-1))
|
||||
endif
|
||||
endif
|
||||
enddo
|
||||
else
|
||||
call disr_up(n,x)
|
||||
endif
|
||||
|
||||
case(psb_asort_down_)
|
||||
|
||||
|
||||
if (n > ithrs) then
|
||||
!
|
||||
! Init stack pointer
|
||||
!
|
||||
istp = 1
|
||||
istack(1,istp) = 1
|
||||
istack(2,istp) = n
|
||||
|
||||
do
|
||||
if (istp <= 0) exit
|
||||
ilx = istack(1,istp)
|
||||
iux = istack(2,istp)
|
||||
istp = istp - 1
|
||||
!$$$ write(0,*) 'Debug 1: ',ilx,iux
|
||||
!
|
||||
! Choose a pivot with median-of-three heuristics, leave it
|
||||
! in the LPIV location
|
||||
!
|
||||
i = ilx
|
||||
j = iux
|
||||
lpiv = (i+j)/2
|
||||
piv = abs(x(lpiv))
|
||||
if (piv > abs(x(i))) then
|
||||
xt = x(i)
|
||||
x(i) = x(lpiv)
|
||||
x(lpiv) = xt
|
||||
piv = abs(x(lpiv))
|
||||
endif
|
||||
if (piv < abs(x(j))) then
|
||||
xt = x(j)
|
||||
x(j) = x(lpiv)
|
||||
x(lpiv) = xt
|
||||
piv = abs(x(lpiv))
|
||||
endif
|
||||
if (piv > abs(x(i))) then
|
||||
xt = x(i)
|
||||
x(i) = x(lpiv)
|
||||
x(lpiv) = xt
|
||||
piv = abs(x(lpiv))
|
||||
endif
|
||||
!
|
||||
! now piv is correct; place it into first location
|
||||
|
||||
xt = x(i)
|
||||
x(i) = x(lpiv)
|
||||
x(lpiv) = xt
|
||||
|
||||
i = ilx - 1
|
||||
j = iux + 1
|
||||
|
||||
outer_dw: do
|
||||
in_dw1: do
|
||||
i = i + 1
|
||||
xk = abs(x(i))
|
||||
if (xk <= piv) exit in_dw1
|
||||
end do in_dw1
|
||||
!
|
||||
! Ensure finite termination for next loop
|
||||
!
|
||||
xt = x(i)
|
||||
x(i) = piv
|
||||
in_dw2:do
|
||||
j = j - 1
|
||||
xk = abs(x(j))
|
||||
if (xk >= piv) exit in_dw2
|
||||
end do in_dw2
|
||||
x(i) = xt
|
||||
|
||||
if (j > i) then
|
||||
xt = x(i)
|
||||
x(i) = x(j)
|
||||
x(j) = xt
|
||||
else
|
||||
exit outer_dw
|
||||
end if
|
||||
end do outer_dw
|
||||
if (i == ilx) then
|
||||
if (x(i) /= piv) then
|
||||
write(0,*) 'Should never ever get here????!!!!'
|
||||
stop
|
||||
endif
|
||||
i = i + 1
|
||||
endif
|
||||
|
||||
n1 = (i-1)-ilx+1
|
||||
n2 = iux-(i)+1
|
||||
if (n1 > n2) then
|
||||
if (n1 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = ilx
|
||||
istack(2,istp) = i-1
|
||||
else
|
||||
call disr_dw(n1,x(ilx:i-1))
|
||||
endif
|
||||
if (n2 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = i
|
||||
istack(2,istp) = iux
|
||||
else
|
||||
call disr_dw(n2,x(i:iux))
|
||||
endif
|
||||
else
|
||||
if (n2 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = i
|
||||
istack(2,istp) = iux
|
||||
else
|
||||
call disr_dw(n2,x(i:iux))
|
||||
endif
|
||||
if (n1 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = ilx
|
||||
istack(2,istp) = i-1
|
||||
else
|
||||
call disr_dw(n1,x(ilx:i-1))
|
||||
endif
|
||||
endif
|
||||
enddo
|
||||
else
|
||||
call disr_dw(n,x)
|
||||
endif
|
||||
|
||||
case default
|
||||
write(0,*) 'isr error !',dir
|
||||
end select
|
||||
|
||||
|
||||
return
|
||||
|
||||
contains
|
||||
|
||||
subroutine disr_up(n,x)
|
||||
implicit none
|
||||
integer :: n
|
||||
real(kind(1.d0)) :: x(n)
|
||||
integer :: i,j
|
||||
real(kind(1.d0)) :: xx,xax
|
||||
|
||||
do j=n-1,1,-1
|
||||
if (abs(x(j+1)) < abs(x(j))) then
|
||||
xx = x(j)
|
||||
xax = abs(xx)
|
||||
i=j+1
|
||||
do
|
||||
x(i-1) = x(i)
|
||||
i = i+1
|
||||
if (i>n) exit
|
||||
if (abs(x(i)) >= xax) exit
|
||||
end do
|
||||
x(i-1) = xx
|
||||
endif
|
||||
enddo
|
||||
end subroutine disr_up
|
||||
|
||||
subroutine disr_dw(n,x)
|
||||
implicit none
|
||||
integer :: n
|
||||
real(kind(1.d0)) :: x(n)
|
||||
integer :: i,j
|
||||
real(kind(1.d0)) :: xx,xax
|
||||
|
||||
do j=n-1,1,-1
|
||||
if (abs(x(j+1)) > abs(x(j))) then
|
||||
xx = x(j)
|
||||
xax = abs(xx)
|
||||
i=j+1
|
||||
do
|
||||
x(i-1) = x(i)
|
||||
i = i+1
|
||||
if (i>n) exit
|
||||
if (abs(x(i)) <= xax) exit
|
||||
end do
|
||||
x(i-1) = xx
|
||||
endif
|
||||
enddo
|
||||
end subroutine disr_dw
|
||||
|
||||
end subroutine dasr
|
||||
@ -0,0 +1,409 @@
|
||||
!!$
|
||||
!!$ Parallel Sparse BLAS v2.0
|
||||
!!$ (C) Copyright 2006 Salvatore Filippone University of Rome Tor Vergata
|
||||
!!$ Alfredo Buttari University of Rome Tor Vergata
|
||||
!!$
|
||||
!!$ Redistribution and use in source and binary forms, with or without
|
||||
!!$ modification, are permitted provided that the following conditions
|
||||
!!$ are met:
|
||||
!!$ 1. Redistributions of source code must retain the above copyright
|
||||
!!$ notice, this list of conditions and the following disclaimer.
|
||||
!!$ 2. Redistributions in binary form must reproduce the above copyright
|
||||
!!$ notice, this list of conditions, and the following disclaimer in the
|
||||
!!$ documentation and/or other materials provided with the distribution.
|
||||
!!$ 3. The name of the PSBLAS group or the names of its contributors may
|
||||
!!$ not be used to endorse or promote products derived from this
|
||||
!!$ software without specific written permission.
|
||||
!!$
|
||||
!!$ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
!!$ ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
!!$ TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
!!$ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PSBLAS GROUP OR ITS CONTRIBUTORS
|
||||
!!$ BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
!!$ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
!!$ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
!!$ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
!!$ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
!!$ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
!!$ POSSIBILITY OF SUCH DAMAGE.
|
||||
!!$
|
||||
!!$
|
||||
subroutine dasrx(n,x,indx,dir,flag)
|
||||
use psb_serial_mod
|
||||
implicit none
|
||||
!
|
||||
! Quicksort on absolute value with indices into original positions.
|
||||
! Adapted from a number of sources, including Don Knuth's TAOCP.
|
||||
!
|
||||
! .. Scalar Arguments ..
|
||||
integer, intent(in) :: n, dir, flag
|
||||
real(kind(1.d0)) :: x(n)
|
||||
integer :: indx(n)
|
||||
! ..
|
||||
! .. Local Scalars ..
|
||||
real(kind(1.d0)) :: xx, piv, xt, xk
|
||||
integer i, j, ii, ilx, iux, istp, lpiv
|
||||
integer ixt, n1, n2
|
||||
|
||||
integer, parameter :: maxstack=64,nparms=3,ithrs=16
|
||||
integer :: istack(nparms,maxstack)
|
||||
! ..
|
||||
|
||||
select case(flag)
|
||||
case(psb_sort_ovw_idx_)
|
||||
do i=1, n
|
||||
indx(i) = i
|
||||
enddo
|
||||
case(psb_sort_keep_idx_)
|
||||
! do nothing
|
||||
case default
|
||||
write(0,*) 'Error in isrx: invalid flag',flag
|
||||
end select
|
||||
!
|
||||
|
||||
!
|
||||
! small inputs will only get through insertion sort.
|
||||
!
|
||||
select case(dir)
|
||||
|
||||
case(psb_asort_up_)
|
||||
|
||||
if (n > ithrs) then
|
||||
!
|
||||
! Init stack pointer
|
||||
!
|
||||
istp = 1
|
||||
istack(1,istp) = 1
|
||||
istack(2,istp) = n
|
||||
|
||||
do
|
||||
if (istp <= 0) exit
|
||||
ilx = istack(1,istp)
|
||||
iux = istack(2,istp)
|
||||
istp = istp - 1
|
||||
!$$$ write(0,*) 'Debug 1: ',ilx,iux
|
||||
!
|
||||
! Choose a pivot with median-of-three heuristics, leave it
|
||||
! in the LPIV location
|
||||
!
|
||||
i = ilx
|
||||
j = iux
|
||||
lpiv = (i+j)/2
|
||||
piv = abs(x(lpiv))
|
||||
if (piv < abs(x(i))) then
|
||||
xt = x(i)
|
||||
ixt = indx(i)
|
||||
x(i) = x(lpiv)
|
||||
indx(i) = indx(lpiv)
|
||||
x(lpiv) = xt
|
||||
indx(lpiv) = ixt
|
||||
piv = abs(x(lpiv))
|
||||
endif
|
||||
if (piv > abs(x(j))) then
|
||||
xt = x(j)
|
||||
ixt = indx(j)
|
||||
x(j) = x(lpiv)
|
||||
indx(j) = indx(lpiv)
|
||||
x(lpiv) = xt
|
||||
indx(lpiv) = ixt
|
||||
piv = abs(x(lpiv))
|
||||
endif
|
||||
if (piv < abs(x(i))) then
|
||||
xt = x(i)
|
||||
ixt = indx(i)
|
||||
x(i) = x(lpiv)
|
||||
indx(i) = indx(lpiv)
|
||||
x(lpiv) = xt
|
||||
indx(lpiv) = ixt
|
||||
piv = abs(x(lpiv))
|
||||
endif
|
||||
!
|
||||
! now piv is correct; place it into first location
|
||||
xt = x(i)
|
||||
ixt = indx(i)
|
||||
x(i) = x(lpiv)
|
||||
indx(i) = indx(lpiv)
|
||||
x(lpiv) = xt
|
||||
indx(lpiv) = ixt
|
||||
|
||||
i = ilx - 1
|
||||
j = iux + 1
|
||||
|
||||
outer_up: do
|
||||
in_up1: do
|
||||
i = i + 1
|
||||
xk = abs(x(i))
|
||||
if (xk >= piv) exit in_up1
|
||||
end do in_up1
|
||||
!
|
||||
! Ensure finite termination for next loop
|
||||
!
|
||||
xt = x(i)
|
||||
x(i) = piv
|
||||
in_up2:do
|
||||
j = j - 1
|
||||
xk = abs(x(j))
|
||||
if (xk <= piv) exit in_up2
|
||||
end do in_up2
|
||||
x(i) = xt
|
||||
|
||||
if (j > i) then
|
||||
xt = x(i)
|
||||
ixt = indx(i)
|
||||
x(i) = x(j)
|
||||
indx(i) = indx(j)
|
||||
x(j) = xt
|
||||
indx(j) = ixt
|
||||
else
|
||||
exit outer_up
|
||||
end if
|
||||
end do outer_up
|
||||
if (i == ilx) then
|
||||
if (x(i) /= piv) then
|
||||
write(0,*) 'Should never ever get here????!!!!'
|
||||
stop
|
||||
endif
|
||||
i = i + 1
|
||||
endif
|
||||
|
||||
n1 = (i-1)-ilx+1
|
||||
n2 = iux-(i)+1
|
||||
if (n1 > n2) then
|
||||
if (n1 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = ilx
|
||||
istack(2,istp) = i-1
|
||||
else
|
||||
call idasrx_up(n1,x(ilx:i-1),indx(ilx:i-1))
|
||||
endif
|
||||
if (n2 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = i
|
||||
istack(2,istp) = iux
|
||||
else
|
||||
call idasrx_up(n2,x(i:iux),indx(i:iux))
|
||||
endif
|
||||
else
|
||||
if (n2 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = i
|
||||
istack(2,istp) = iux
|
||||
else
|
||||
call idasrx_up(n2,x(i:iux),indx(i:iux))
|
||||
endif
|
||||
if (n1 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = ilx
|
||||
istack(2,istp) = i-1
|
||||
else
|
||||
call idasrx_up(n1,x(ilx:i-1),indx(ilx:i-1))
|
||||
endif
|
||||
endif
|
||||
enddo
|
||||
else
|
||||
call idasrx_up(n,x,indx)
|
||||
endif
|
||||
|
||||
case(psb_asort_down_)
|
||||
|
||||
|
||||
if (n > ithrs) then
|
||||
!
|
||||
! Init stack pointer
|
||||
!
|
||||
istp = 1
|
||||
istack(1,istp) = 1
|
||||
istack(2,istp) = n
|
||||
|
||||
do
|
||||
if (istp <= 0) exit
|
||||
ilx = istack(1,istp)
|
||||
iux = istack(2,istp)
|
||||
istp = istp - 1
|
||||
!$$$ write(0,*) 'Debug 1: ',ilx,iux
|
||||
!
|
||||
! Choose a pivot with median-of-three heuristics, leave it
|
||||
! in the LPIV location
|
||||
!
|
||||
i = ilx
|
||||
j = iux
|
||||
lpiv = (i+j)/2
|
||||
piv = abs(x(lpiv))
|
||||
if (piv > abs(x(i))) then
|
||||
xt = x(i)
|
||||
ixt = indx(i)
|
||||
x(i) = x(lpiv)
|
||||
indx(i) = indx(lpiv)
|
||||
x(lpiv) = xt
|
||||
indx(lpiv) = ixt
|
||||
piv = abs(x(lpiv))
|
||||
endif
|
||||
if (piv < abs(x(j))) then
|
||||
xt = x(j)
|
||||
ixt = indx(j)
|
||||
x(j) = x(lpiv)
|
||||
indx(j) = indx(lpiv)
|
||||
x(lpiv) = xt
|
||||
indx(lpiv) = ixt
|
||||
piv = abs(x(lpiv))
|
||||
endif
|
||||
if (piv > abs(x(i))) then
|
||||
xt = x(i)
|
||||
ixt = indx(i)
|
||||
x(i) = x(lpiv)
|
||||
indx(i) = indx(lpiv)
|
||||
x(lpiv) = xt
|
||||
indx(lpiv) = ixt
|
||||
piv = abs(x(lpiv))
|
||||
endif
|
||||
!
|
||||
! now piv is correct; place it into first location
|
||||
xt = x(i)
|
||||
ixt = indx(i)
|
||||
x(i) = x(lpiv)
|
||||
indx(i) = indx(lpiv)
|
||||
x(lpiv) = xt
|
||||
indx(lpiv) = ixt
|
||||
|
||||
i = ilx - 1
|
||||
j = iux + 1
|
||||
|
||||
outer_dw: do
|
||||
in_dw1: do
|
||||
i = i + 1
|
||||
xk = abs(x(i))
|
||||
if (xk <= piv) exit in_dw1
|
||||
end do in_dw1
|
||||
!
|
||||
! Ensure finite termination for next loop
|
||||
!
|
||||
xt = x(i)
|
||||
x(i) = piv
|
||||
in_dw2:do
|
||||
j = j - 1
|
||||
xk = abs(x(j))
|
||||
if (xk >= piv) exit in_dw2
|
||||
end do in_dw2
|
||||
x(i) = xt
|
||||
|
||||
if (j > i) then
|
||||
xt = x(i)
|
||||
ixt = indx(i)
|
||||
x(i) = x(j)
|
||||
indx(i) = indx(j)
|
||||
x(j) = xt
|
||||
indx(j) = ixt
|
||||
else
|
||||
exit outer_dw
|
||||
end if
|
||||
end do outer_dw
|
||||
if (i == ilx) then
|
||||
if (x(i) /= piv) then
|
||||
write(0,*) 'Should never ever get here????!!!!'
|
||||
stop
|
||||
endif
|
||||
i = i + 1
|
||||
endif
|
||||
|
||||
n1 = (i-1)-ilx+1
|
||||
n2 = iux-(i)+1
|
||||
if (n1 > n2) then
|
||||
if (n1 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = ilx
|
||||
istack(2,istp) = i-1
|
||||
else
|
||||
call idasrx_dw(n1,x(ilx:i-1),indx(ilx:i-1))
|
||||
endif
|
||||
if (n2 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = i
|
||||
istack(2,istp) = iux
|
||||
else
|
||||
call idasrx_dw(n2,x(i:iux),indx(i:iux))
|
||||
endif
|
||||
else
|
||||
if (n2 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = i
|
||||
istack(2,istp) = iux
|
||||
else
|
||||
call idasrx_dw(n2,x(i:iux),indx(i:iux))
|
||||
endif
|
||||
if (n1 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = ilx
|
||||
istack(2,istp) = i-1
|
||||
else
|
||||
call idasrx_dw(n1,x(ilx:i-1),indx(ilx:i-1))
|
||||
endif
|
||||
endif
|
||||
enddo
|
||||
else
|
||||
call idasrx_dw(n,x,indx)
|
||||
endif
|
||||
|
||||
case default
|
||||
write(0,*) 'isrx error dir ',dir
|
||||
end select
|
||||
|
||||
|
||||
return
|
||||
|
||||
contains
|
||||
|
||||
subroutine idasrx_up(n,x,indx)
|
||||
implicit none
|
||||
integer :: n
|
||||
real(kind(1.d0)) :: x(n)
|
||||
integer :: indx(n)
|
||||
integer :: i,j,ix
|
||||
real(kind(1.d0)) :: xx,xax
|
||||
|
||||
do j=n-1,1,-1
|
||||
if (abs(x(j+1)) < abs(x(j))) then
|
||||
xx = x(j)
|
||||
ix = indx(j)
|
||||
xax = abs(xx)
|
||||
i=j+1
|
||||
do
|
||||
x(i-1) = x(i)
|
||||
indx(i-1) = indx(i)
|
||||
i = i+1
|
||||
if (i>n) exit
|
||||
if (abs(x(i)) >= xax) exit
|
||||
end do
|
||||
x(i-1) = xx
|
||||
indx(i-1) = ix
|
||||
endif
|
||||
enddo
|
||||
end subroutine idasrx_up
|
||||
|
||||
subroutine idasrx_dw(n,x,indx)
|
||||
implicit none
|
||||
integer :: n
|
||||
real(kind(1.d0)) :: x(n)
|
||||
integer :: indx(n)
|
||||
integer :: i,j,ix
|
||||
real(kind(1.d0)) :: xx,xax
|
||||
|
||||
do j=n-1,1,-1
|
||||
if (abs(x(j+1)) > abs(x(j))) then
|
||||
xx = x(j)
|
||||
ix = indx(j)
|
||||
xax = abs(xx)
|
||||
i=j+1
|
||||
do
|
||||
x(i-1) = x(i)
|
||||
indx(i-1) = indx(i)
|
||||
i = i+1
|
||||
if (i>n) exit
|
||||
if (abs(x(i)) <= xax) exit
|
||||
end do
|
||||
x(i-1) = xx
|
||||
indx(i-1) = ix
|
||||
endif
|
||||
enddo
|
||||
end subroutine idasrx_dw
|
||||
|
||||
end subroutine dasrx
|
||||
@ -0,0 +1,359 @@
|
||||
!!$
|
||||
!!$ Parallel Sparse BLAS v2.0
|
||||
!!$ (C) Copyright 2006 Salvatore Filippone University of Rome Tor Vergata
|
||||
!!$ Alfredo Buttari University of Rome Tor Vergata
|
||||
!!$
|
||||
!!$ Redistribution and use in source and binary forms, with or without
|
||||
!!$ modification, are permitted provided that the following conditions
|
||||
!!$ are met:
|
||||
!!$ 1. Redistributions of source code must retain the above copyright
|
||||
!!$ notice, this list of conditions and the following disclaimer.
|
||||
!!$ 2. Redistributions in binary form must reproduce the above copyright
|
||||
!!$ notice, this list of conditions, and the following disclaimer in the
|
||||
!!$ documentation and/or other materials provided with the distribution.
|
||||
!!$ 3. The name of the PSBLAS group or the names of its contributors may
|
||||
!!$ not be used to endorse or promote products derived from this
|
||||
!!$ software without specific written permission.
|
||||
!!$
|
||||
!!$ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
!!$ ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
!!$ TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
!!$ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PSBLAS GROUP OR ITS CONTRIBUTORS
|
||||
!!$ BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
!!$ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
!!$ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
!!$ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
!!$ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
!!$ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
!!$ POSSIBILITY OF SUCH DAMAGE.
|
||||
!!$
|
||||
!!$
|
||||
|
||||
subroutine dsr(n,x,dir)
|
||||
use psb_serial_mod
|
||||
implicit none
|
||||
!
|
||||
! Quicksort.
|
||||
! Adapted from a number of sources, including Don Knuth's TAOCP.
|
||||
!
|
||||
! .. Scalar Arguments ..
|
||||
integer, intent(in) :: n, dir
|
||||
real(kind(1.d0)) :: x(n)
|
||||
! ..
|
||||
! .. Local Scalars ..
|
||||
real(kind(1.d0)) :: xx, piv, xt, xk
|
||||
integer i, j, ilx, iux, istp, lpiv
|
||||
integer n1, n2
|
||||
|
||||
integer, parameter :: maxstack=64,nparms=3,ithrs=16
|
||||
integer :: istack(nparms,maxstack)
|
||||
! ..
|
||||
|
||||
!
|
||||
! small inputs will only get through insertion sort.
|
||||
!
|
||||
select case(dir)
|
||||
|
||||
case(psb_sort_up_)
|
||||
|
||||
if (n > ithrs) then
|
||||
!
|
||||
! Init stack pointer
|
||||
!
|
||||
istp = 1
|
||||
istack(1,istp) = 1
|
||||
istack(2,istp) = n
|
||||
|
||||
do
|
||||
if (istp <= 0) exit
|
||||
ilx = istack(1,istp)
|
||||
iux = istack(2,istp)
|
||||
istp = istp - 1
|
||||
!$$$ write(0,*) 'Debug 1: ',ilx,iux
|
||||
!
|
||||
! Choose a pivot with median-of-three heuristics, leave it
|
||||
! in the LPIV location
|
||||
!
|
||||
i = ilx
|
||||
j = iux
|
||||
lpiv = (i+j)/2
|
||||
piv = x(lpiv)
|
||||
if (piv < x(i)) then
|
||||
xt = x(i)
|
||||
x(i) = x(lpiv)
|
||||
x(lpiv) = xt
|
||||
piv = x(lpiv)
|
||||
endif
|
||||
if (piv > x(j)) then
|
||||
xt = x(j)
|
||||
x(j) = x(lpiv)
|
||||
x(lpiv) = xt
|
||||
piv = x(lpiv)
|
||||
endif
|
||||
if (piv < x(i)) then
|
||||
xt = x(i)
|
||||
x(i) = x(lpiv)
|
||||
x(lpiv) = xt
|
||||
piv = x(lpiv)
|
||||
endif
|
||||
!
|
||||
! now piv is correct; place it into first location
|
||||
|
||||
xt = x(i)
|
||||
x(i) = x(lpiv)
|
||||
x(lpiv) = xt
|
||||
|
||||
i = ilx - 1
|
||||
j = iux + 1
|
||||
|
||||
outer_up: do
|
||||
in_up1: do
|
||||
i = i + 1
|
||||
xk = x(i)
|
||||
if (xk >= piv) exit in_up1
|
||||
end do in_up1
|
||||
!
|
||||
! Ensure finite termination for next loop
|
||||
!
|
||||
xt = xk
|
||||
x(i) = piv
|
||||
in_up2:do
|
||||
j = j - 1
|
||||
xk = x(j)
|
||||
if (xk <= piv) exit in_up2
|
||||
end do in_up2
|
||||
x(i) = xt
|
||||
|
||||
if (j > i) then
|
||||
xt = x(i)
|
||||
x(i) = x(j)
|
||||
x(j) = xt
|
||||
else
|
||||
exit outer_up
|
||||
end if
|
||||
end do outer_up
|
||||
if (i == ilx) then
|
||||
if (x(i) /= piv) then
|
||||
write(0,*) 'Should never ever get here????!!!!'
|
||||
stop
|
||||
endif
|
||||
i = i + 1
|
||||
endif
|
||||
|
||||
n1 = (i-1)-ilx+1
|
||||
n2 = iux-(i)+1
|
||||
if (n1 > n2) then
|
||||
if (n1 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = ilx
|
||||
istack(2,istp) = i-1
|
||||
else
|
||||
call disr_up(n1,x(ilx:i-1))
|
||||
endif
|
||||
if (n2 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = i
|
||||
istack(2,istp) = iux
|
||||
else
|
||||
call disr_up(n2,x(i:iux))
|
||||
endif
|
||||
else
|
||||
if (n2 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = i
|
||||
istack(2,istp) = iux
|
||||
else
|
||||
call disr_up(n2,x(i:iux))
|
||||
endif
|
||||
if (n1 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = ilx
|
||||
istack(2,istp) = i-1
|
||||
else
|
||||
call disr_up(n1,x(ilx:i-1))
|
||||
endif
|
||||
endif
|
||||
enddo
|
||||
else
|
||||
call disr_up(n,x)
|
||||
endif
|
||||
|
||||
case(psb_sort_down_)
|
||||
|
||||
|
||||
if (n > ithrs) then
|
||||
!
|
||||
! Init stack pointer
|
||||
!
|
||||
istp = 1
|
||||
istack(1,istp) = 1
|
||||
istack(2,istp) = n
|
||||
|
||||
do
|
||||
if (istp <= 0) exit
|
||||
ilx = istack(1,istp)
|
||||
iux = istack(2,istp)
|
||||
istp = istp - 1
|
||||
!$$$ write(0,*) 'Debug 1: ',ilx,iux
|
||||
!
|
||||
! Choose a pivot with median-of-three heuristics, leave it
|
||||
! in the LPIV location
|
||||
!
|
||||
i = ilx
|
||||
j = iux
|
||||
lpiv = (i+j)/2
|
||||
piv = x(lpiv)
|
||||
if (piv > x(i)) then
|
||||
xt = x(i)
|
||||
x(i) = x(lpiv)
|
||||
x(lpiv) = xt
|
||||
piv = x(lpiv)
|
||||
endif
|
||||
if (piv < x(j)) then
|
||||
xt = x(j)
|
||||
x(j) = x(lpiv)
|
||||
x(lpiv) = xt
|
||||
piv = x(lpiv)
|
||||
endif
|
||||
if (piv > x(i)) then
|
||||
xt = x(i)
|
||||
x(i) = x(lpiv)
|
||||
x(lpiv) = xt
|
||||
piv = x(lpiv)
|
||||
endif
|
||||
!
|
||||
! now piv is correct; place it into first location
|
||||
|
||||
xt = x(i)
|
||||
x(i) = x(lpiv)
|
||||
x(lpiv) = xt
|
||||
|
||||
i = ilx - 1
|
||||
j = iux + 1
|
||||
|
||||
outer_dw: do
|
||||
in_dw1: do
|
||||
i = i + 1
|
||||
xk = x(i)
|
||||
if (xk <= piv) exit in_dw1
|
||||
end do in_dw1
|
||||
!
|
||||
! Ensure finite termination for next loop
|
||||
!
|
||||
xt = xk
|
||||
x(i) = piv
|
||||
in_dw2:do
|
||||
j = j - 1
|
||||
xk = x(j)
|
||||
if (xk >= piv) exit in_dw2
|
||||
end do in_dw2
|
||||
x(i) = xt
|
||||
|
||||
if (j > i) then
|
||||
xt = x(i)
|
||||
x(i) = x(j)
|
||||
x(j) = xt
|
||||
else
|
||||
exit outer_dw
|
||||
end if
|
||||
end do outer_dw
|
||||
if (i == ilx) then
|
||||
if (x(i) /= piv) then
|
||||
write(0,*) 'Should never ever get here????!!!!'
|
||||
stop
|
||||
endif
|
||||
i = i + 1
|
||||
endif
|
||||
|
||||
n1 = (i-1)-ilx+1
|
||||
n2 = iux-(i)+1
|
||||
if (n1 > n2) then
|
||||
if (n1 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = ilx
|
||||
istack(2,istp) = i-1
|
||||
else
|
||||
call disr_dw(n1,x(ilx:i-1))
|
||||
endif
|
||||
if (n2 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = i
|
||||
istack(2,istp) = iux
|
||||
else
|
||||
call disr_dw(n2,x(i:iux))
|
||||
endif
|
||||
else
|
||||
if (n2 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = i
|
||||
istack(2,istp) = iux
|
||||
else
|
||||
call disr_dw(n2,x(i:iux))
|
||||
endif
|
||||
if (n1 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = ilx
|
||||
istack(2,istp) = i-1
|
||||
else
|
||||
call disr_dw(n1,x(ilx:i-1))
|
||||
endif
|
||||
endif
|
||||
enddo
|
||||
else
|
||||
call disr_dw(n,x)
|
||||
endif
|
||||
|
||||
case default
|
||||
write(0,*) 'isr error !',dir
|
||||
end select
|
||||
|
||||
|
||||
return
|
||||
|
||||
contains
|
||||
|
||||
subroutine disr_up(n,x)
|
||||
implicit none
|
||||
integer :: n
|
||||
real(kind(1.d0)) :: x(n)
|
||||
integer :: i,j
|
||||
real(kind(1.d0)) :: xx
|
||||
|
||||
do j=n-1,1,-1
|
||||
if (x(j+1) < x(j)) then
|
||||
xx = x(j)
|
||||
i=j+1
|
||||
do
|
||||
x(i-1) = x(i)
|
||||
i = i+1
|
||||
if (i>n) exit
|
||||
if (x(i) >= xx) exit
|
||||
end do
|
||||
x(i-1) = xx
|
||||
endif
|
||||
enddo
|
||||
end subroutine disr_up
|
||||
|
||||
subroutine disr_dw(n,x)
|
||||
implicit none
|
||||
integer :: n
|
||||
real(kind(1.d0)) :: x(n)
|
||||
integer :: i,j
|
||||
real(kind(1.d0)) :: xx
|
||||
|
||||
do j=n-1,1,-1
|
||||
if (x(j+1) > x(j)) then
|
||||
xx = x(j)
|
||||
i=j+1
|
||||
do
|
||||
x(i-1) = x(i)
|
||||
i = i+1
|
||||
if (i>n) exit
|
||||
if (x(i) <= xx) exit
|
||||
end do
|
||||
x(i-1) = xx
|
||||
endif
|
||||
enddo
|
||||
end subroutine disr_dw
|
||||
|
||||
end subroutine dsr
|
||||
@ -0,0 +1,409 @@
|
||||
!!$
|
||||
!!$ Parallel Sparse BLAS v2.0
|
||||
!!$ (C) Copyright 2006 Salvatore Filippone University of Rome Tor Vergata
|
||||
!!$ Alfredo Buttari University of Rome Tor Vergata
|
||||
!!$
|
||||
!!$ Redistribution and use in source and binary forms, with or without
|
||||
!!$ modification, are permitted provided that the following conditions
|
||||
!!$ are met:
|
||||
!!$ 1. Redistributions of source code must retain the above copyright
|
||||
!!$ notice, this list of conditions and the following disclaimer.
|
||||
!!$ 2. Redistributions in binary form must reproduce the above copyright
|
||||
!!$ notice, this list of conditions, and the following disclaimer in the
|
||||
!!$ documentation and/or other materials provided with the distribution.
|
||||
!!$ 3. The name of the PSBLAS group or the names of its contributors may
|
||||
!!$ not be used to endorse or promote products derived from this
|
||||
!!$ software without specific written permission.
|
||||
!!$
|
||||
!!$ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
!!$ ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
!!$ TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
!!$ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PSBLAS GROUP OR ITS CONTRIBUTORS
|
||||
!!$ BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
!!$ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
!!$ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
!!$ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
!!$ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
!!$ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
!!$ POSSIBILITY OF SUCH DAMAGE.
|
||||
!!$
|
||||
!!$
|
||||
subroutine dsrx(n,x,indx,dir,flag)
|
||||
use psb_serial_mod
|
||||
implicit none
|
||||
!
|
||||
! Quicksort with indices into original positions.
|
||||
! Adapted from a number of sources, including Don Knuth's TAOCP.
|
||||
!
|
||||
! .. Scalar Arguments ..
|
||||
integer, intent(in) :: n, dir, flag
|
||||
real(kind(1.d0)) :: x(n)
|
||||
integer :: indx(n)
|
||||
! ..
|
||||
! .. Local Scalars ..
|
||||
real(kind(1.d0)) :: xx, piv, xk, xt
|
||||
integer i, j, ii, ilx, iux, istp, lpiv
|
||||
integer ixt, n1, n2
|
||||
|
||||
integer, parameter :: maxstack=64,nparms=3,ithrs=16
|
||||
integer :: istack(nparms,maxstack)
|
||||
! ..
|
||||
|
||||
select case(flag)
|
||||
case(psb_sort_ovw_idx_)
|
||||
do i=1, n
|
||||
indx(i) = i
|
||||
enddo
|
||||
case(psb_sort_keep_idx_)
|
||||
! do nothing
|
||||
case default
|
||||
write(0,*) 'Error in isrx: invalid flag',flag
|
||||
end select
|
||||
!
|
||||
|
||||
!
|
||||
! small inputs will only get through insertion sort.
|
||||
!
|
||||
select case(dir)
|
||||
|
||||
case(psb_sort_up_)
|
||||
|
||||
if (n > ithrs) then
|
||||
!
|
||||
! Init stack pointer
|
||||
!
|
||||
istp = 1
|
||||
istack(1,istp) = 1
|
||||
istack(2,istp) = n
|
||||
|
||||
do
|
||||
if (istp <= 0) exit
|
||||
ilx = istack(1,istp)
|
||||
iux = istack(2,istp)
|
||||
istp = istp - 1
|
||||
!$$$ write(0,*) 'Debug 1: ',ilx,iux
|
||||
!
|
||||
! Choose a pivot with median-of-three heuristics, leave it
|
||||
! in the LPIV location
|
||||
!
|
||||
i = ilx
|
||||
j = iux
|
||||
lpiv = (i+j)/2
|
||||
piv = x(lpiv)
|
||||
if (piv < x(i)) then
|
||||
xt = x(i)
|
||||
ixt = indx(i)
|
||||
x(i) = x(lpiv)
|
||||
indx(i) = indx(lpiv)
|
||||
x(lpiv) = xt
|
||||
indx(lpiv) = ixt
|
||||
piv = x(lpiv)
|
||||
endif
|
||||
if (piv > x(j)) then
|
||||
xt = x(j)
|
||||
ixt = indx(j)
|
||||
x(j) = x(lpiv)
|
||||
indx(j) = indx(lpiv)
|
||||
x(lpiv) = xt
|
||||
indx(lpiv) = ixt
|
||||
piv = x(lpiv)
|
||||
endif
|
||||
if (piv < x(i)) then
|
||||
xt = x(i)
|
||||
ixt = indx(i)
|
||||
x(i) = x(lpiv)
|
||||
indx(i) = indx(lpiv)
|
||||
x(lpiv) = xt
|
||||
indx(lpiv) = ixt
|
||||
piv = x(lpiv)
|
||||
endif
|
||||
!
|
||||
! now piv is correct; place it into first location
|
||||
xt = x(i)
|
||||
ixt = indx(i)
|
||||
x(i) = x(lpiv)
|
||||
indx(i) = indx(lpiv)
|
||||
x(lpiv) = xt
|
||||
indx(lpiv) = ixt
|
||||
piv = x(lpiv)
|
||||
|
||||
i = ilx - 1
|
||||
j = iux + 1
|
||||
|
||||
outer_up: do
|
||||
in_up1: do
|
||||
i = i + 1
|
||||
xk = x(i)
|
||||
if (xk >= piv) exit in_up1
|
||||
end do in_up1
|
||||
!
|
||||
! Ensure finite termination for next loop
|
||||
!
|
||||
xt = xk
|
||||
x(i) = piv
|
||||
in_up2:do
|
||||
j = j - 1
|
||||
xk = x(j)
|
||||
if (xk <= piv) exit in_up2
|
||||
end do in_up2
|
||||
x(i) = xt
|
||||
|
||||
if (j > i) then
|
||||
xt = x(i)
|
||||
ixt = indx(i)
|
||||
x(i) = x(j)
|
||||
indx(i) = indx(j)
|
||||
x(j) = xt
|
||||
indx(j) = ixt
|
||||
else
|
||||
exit outer_up
|
||||
end if
|
||||
end do outer_up
|
||||
if (i == ilx) then
|
||||
if (x(i) /= piv) then
|
||||
write(0,*) 'Should never ever get here????!!!!'
|
||||
stop
|
||||
endif
|
||||
i = i + 1
|
||||
endif
|
||||
|
||||
n1 = (i-1)-ilx+1
|
||||
n2 = iux-(i)+1
|
||||
if (n1 > n2) then
|
||||
if (n1 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = ilx
|
||||
istack(2,istp) = i-1
|
||||
else
|
||||
call idsrx_up(n1,x(ilx:i-1),indx(ilx:i-1))
|
||||
endif
|
||||
if (n2 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = i
|
||||
istack(2,istp) = iux
|
||||
else
|
||||
call idsrx_up(n2,x(i:iux),indx(i:iux))
|
||||
endif
|
||||
else
|
||||
if (n2 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = i
|
||||
istack(2,istp) = iux
|
||||
else
|
||||
call idsrx_up(n2,x(i:iux),indx(i:iux))
|
||||
endif
|
||||
if (n1 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = ilx
|
||||
istack(2,istp) = i-1
|
||||
else
|
||||
call idsrx_up(n1,x(ilx:i-1),indx(ilx:i-1))
|
||||
endif
|
||||
endif
|
||||
enddo
|
||||
else
|
||||
call idsrx_up(n,x,indx)
|
||||
endif
|
||||
|
||||
case(psb_sort_down_)
|
||||
|
||||
|
||||
if (n > ithrs) then
|
||||
!
|
||||
! Init stack pointer
|
||||
!
|
||||
istp = 1
|
||||
istack(1,istp) = 1
|
||||
istack(2,istp) = n
|
||||
|
||||
do
|
||||
if (istp <= 0) exit
|
||||
ilx = istack(1,istp)
|
||||
iux = istack(2,istp)
|
||||
istp = istp - 1
|
||||
!$$$ write(0,*) 'Debug 1: ',ilx,iux
|
||||
!
|
||||
! Choose a pivot with median-of-three heuristics, leave it
|
||||
! in the LPIV location
|
||||
!
|
||||
i = ilx
|
||||
j = iux
|
||||
lpiv = (i+j)/2
|
||||
piv = x(lpiv)
|
||||
if (piv > x(i)) then
|
||||
xt = x(i)
|
||||
ixt = indx(i)
|
||||
x(i) = x(lpiv)
|
||||
indx(i) = indx(lpiv)
|
||||
x(lpiv) = xt
|
||||
indx(lpiv) = ixt
|
||||
piv = x(lpiv)
|
||||
endif
|
||||
if (piv < x(j)) then
|
||||
xt = x(j)
|
||||
ixt = indx(j)
|
||||
x(j) = x(lpiv)
|
||||
indx(j) = indx(lpiv)
|
||||
x(lpiv) = xt
|
||||
indx(lpiv) = ixt
|
||||
piv = x(lpiv)
|
||||
endif
|
||||
if (piv > x(i)) then
|
||||
xt = x(i)
|
||||
ixt = indx(i)
|
||||
x(i) = x(lpiv)
|
||||
indx(i) = indx(lpiv)
|
||||
x(lpiv) = xt
|
||||
indx(lpiv) = ixt
|
||||
piv = x(lpiv)
|
||||
endif
|
||||
!
|
||||
! now piv is correct; place it into first location
|
||||
xt = x(i)
|
||||
ixt = indx(i)
|
||||
x(i) = x(lpiv)
|
||||
indx(i) = indx(lpiv)
|
||||
x(lpiv) = xt
|
||||
indx(lpiv) = ixt
|
||||
piv = x(lpiv)
|
||||
|
||||
i = ilx - 1
|
||||
j = iux + 1
|
||||
|
||||
outer_dw: do
|
||||
in_dw1: do
|
||||
i = i + 1
|
||||
xk = x(i)
|
||||
if (xk <= piv) exit in_dw1
|
||||
end do in_dw1
|
||||
!
|
||||
! Ensure finite termination for next loop
|
||||
!
|
||||
xt = xk
|
||||
x(i) = piv
|
||||
in_dw2:do
|
||||
j = j - 1
|
||||
xk = x(j)
|
||||
if (xk >= piv) exit in_dw2
|
||||
end do in_dw2
|
||||
x(i) = xt
|
||||
|
||||
if (j > i) then
|
||||
xt = x(i)
|
||||
ixt = indx(i)
|
||||
x(i) = x(j)
|
||||
indx(i) = indx(j)
|
||||
x(j) = xt
|
||||
indx(j) = ixt
|
||||
else
|
||||
exit outer_dw
|
||||
end if
|
||||
end do outer_dw
|
||||
if (i == ilx) then
|
||||
if (x(i) /= piv) then
|
||||
write(0,*) 'Should never ever get here????!!!!'
|
||||
stop
|
||||
endif
|
||||
i = i + 1
|
||||
endif
|
||||
|
||||
n1 = (i-1)-ilx+1
|
||||
n2 = iux-(i)+1
|
||||
if (n1 > n2) then
|
||||
if (n1 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = ilx
|
||||
istack(2,istp) = i-1
|
||||
else
|
||||
call idsrx_dw(n1,x(ilx:i-1),indx(ilx:i-1))
|
||||
endif
|
||||
if (n2 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = i
|
||||
istack(2,istp) = iux
|
||||
else
|
||||
call idsrx_dw(n2,x(i:iux),indx(i:iux))
|
||||
endif
|
||||
else
|
||||
if (n2 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = i
|
||||
istack(2,istp) = iux
|
||||
else
|
||||
call idsrx_dw(n2,x(i:iux),indx(i:iux))
|
||||
endif
|
||||
if (n1 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = ilx
|
||||
istack(2,istp) = i-1
|
||||
else
|
||||
call idsrx_dw(n1,x(ilx:i-1),indx(ilx:i-1))
|
||||
endif
|
||||
endif
|
||||
enddo
|
||||
else
|
||||
call idsrx_dw(n,x,indx)
|
||||
endif
|
||||
|
||||
case default
|
||||
write(0,*) 'isrx error dir ',dir
|
||||
end select
|
||||
|
||||
|
||||
return
|
||||
|
||||
contains
|
||||
|
||||
subroutine idsrx_up(n,x,indx)
|
||||
implicit none
|
||||
integer :: n
|
||||
real(kind(1.d0)) :: x(n)
|
||||
integer :: indx(n)
|
||||
integer :: i,j,ix
|
||||
real(kind(1.d0)) :: xx
|
||||
|
||||
do j=n-1,1,-1
|
||||
if (x(j+1) < x(j)) then
|
||||
xx = x(j)
|
||||
ix = indx(j)
|
||||
i=j+1
|
||||
do
|
||||
x(i-1) = x(i)
|
||||
indx(i-1) = indx(i)
|
||||
i = i+1
|
||||
if (i>n) exit
|
||||
if (x(i) >= xx) exit
|
||||
end do
|
||||
x(i-1) = xx
|
||||
indx(i-1) = ix
|
||||
endif
|
||||
enddo
|
||||
end subroutine idsrx_up
|
||||
|
||||
subroutine idsrx_dw(n,x,indx)
|
||||
implicit none
|
||||
integer :: n
|
||||
real(kind(1.d0)) :: x(n)
|
||||
integer :: indx(n)
|
||||
integer :: i,j,ix
|
||||
real(kind(1.d0)) :: xx
|
||||
|
||||
do j=n-1,1,-1
|
||||
if (x(j+1) > x(j)) then
|
||||
xx = x(j)
|
||||
ix = indx(j)
|
||||
i=j+1
|
||||
do
|
||||
x(i-1) = x(i)
|
||||
indx(i-1) = indx(i)
|
||||
i = i+1
|
||||
if (i>n) exit
|
||||
if (x(i) <= xx) exit
|
||||
end do
|
||||
x(i-1) = xx
|
||||
indx(i-1) = ix
|
||||
endif
|
||||
enddo
|
||||
end subroutine idsrx_dw
|
||||
|
||||
end subroutine dsrx
|
||||
@ -0,0 +1,361 @@
|
||||
!!$
|
||||
!!$ Parallel Sparse BLAS v2.0
|
||||
!!$ (C) Copyright 2006 Salvatore Filippone University of Rome Tor Vergata
|
||||
!!$ Alfredo Buttari University of Rome Tor Vergata
|
||||
!!$
|
||||
!!$ Redistribution and use in source and binary forms, with or without
|
||||
!!$ modification, are permitted provided that the following conditions
|
||||
!!$ are met:
|
||||
!!$ 1. Redistributions of source code must retain the above copyright
|
||||
!!$ notice, this list of conditions and the following disclaimer.
|
||||
!!$ 2. Redistributions in binary form must reproduce the above copyright
|
||||
!!$ notice, this list of conditions, and the following disclaimer in the
|
||||
!!$ documentation and/or other materials provided with the distribution.
|
||||
!!$ 3. The name of the PSBLAS group or the names of its contributors may
|
||||
!!$ not be used to endorse or promote products derived from this
|
||||
!!$ software without specific written permission.
|
||||
!!$
|
||||
!!$ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
!!$ ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
!!$ TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
!!$ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PSBLAS GROUP OR ITS CONTRIBUTORS
|
||||
!!$ BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
!!$ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
!!$ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
!!$ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
!!$ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
!!$ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
!!$ POSSIBILITY OF SUCH DAMAGE.
|
||||
!!$
|
||||
!!$
|
||||
|
||||
subroutine iasr(n,x,dir)
|
||||
use psb_serial_mod
|
||||
implicit none
|
||||
!
|
||||
! Quicksort on absolute value.
|
||||
! Adapted from a number of sources, including Don Knuth's TAOCP.
|
||||
!
|
||||
! .. Scalar Arguments ..
|
||||
integer, intent(in) :: n, dir
|
||||
integer :: x(n)
|
||||
! ..
|
||||
! .. Local Scalars ..
|
||||
integer :: xx, piv, xt, xk
|
||||
integer i, j, ilx, iux, istp, lpiv
|
||||
integer n1, n2
|
||||
|
||||
integer, parameter :: maxstack=64,nparms=3,ithrs=16
|
||||
integer :: istack(nparms,maxstack)
|
||||
! ..
|
||||
|
||||
!
|
||||
! small inputs will only get through insertion sort.
|
||||
!
|
||||
select case(dir)
|
||||
|
||||
case(psb_asort_up_)
|
||||
|
||||
if (n > ithrs) then
|
||||
!
|
||||
! Init stack pointer
|
||||
!
|
||||
istp = 1
|
||||
istack(1,istp) = 1
|
||||
istack(2,istp) = n
|
||||
|
||||
do
|
||||
if (istp <= 0) exit
|
||||
ilx = istack(1,istp)
|
||||
iux = istack(2,istp)
|
||||
istp = istp - 1
|
||||
!$$$ write(0,*) 'Debug 1: ',ilx,iux
|
||||
!
|
||||
! Choose a pivot with median-of-three heuristics, leave it
|
||||
! in the LPIV location
|
||||
!
|
||||
i = ilx
|
||||
j = iux
|
||||
lpiv = (i+j)/2
|
||||
piv = abs(x(lpiv))
|
||||
if (piv < abs(x(i))) then
|
||||
xt = x(i)
|
||||
x(i) = x(lpiv)
|
||||
x(lpiv) = xt
|
||||
piv = abs(x(lpiv))
|
||||
endif
|
||||
if (piv > abs(x(j))) then
|
||||
xt = x(j)
|
||||
x(j) = x(lpiv)
|
||||
x(lpiv) = xt
|
||||
piv = abs(x(lpiv))
|
||||
endif
|
||||
if (piv < abs(x(i))) then
|
||||
xt = x(i)
|
||||
x(i) = x(lpiv)
|
||||
x(lpiv) = xt
|
||||
piv = abs(x(lpiv))
|
||||
endif
|
||||
!
|
||||
! now piv is correct; place it into first location
|
||||
|
||||
xt = x(i)
|
||||
x(i) = x(lpiv)
|
||||
x(lpiv) = xt
|
||||
|
||||
i = ilx - 1
|
||||
j = iux + 1
|
||||
|
||||
outer_up: do
|
||||
in_up1: do
|
||||
i = i + 1
|
||||
xk = abs(x(i))
|
||||
if (xk >= piv) exit in_up1
|
||||
end do in_up1
|
||||
!
|
||||
! Ensure finite termination for next loop
|
||||
!
|
||||
xt = x(i)
|
||||
x(i) = piv
|
||||
in_up2:do
|
||||
j = j - 1
|
||||
xk = abs(x(j))
|
||||
if (xk <= piv) exit in_up2
|
||||
end do in_up2
|
||||
x(i) = xt
|
||||
|
||||
if (j > i) then
|
||||
xt = x(i)
|
||||
x(i) = x(j)
|
||||
x(j) = xt
|
||||
else
|
||||
exit outer_up
|
||||
end if
|
||||
end do outer_up
|
||||
if (i == ilx) then
|
||||
if (x(i) /= piv) then
|
||||
write(0,*) 'Should never ever get here????!!!!'
|
||||
stop
|
||||
endif
|
||||
i = i + 1
|
||||
endif
|
||||
|
||||
n1 = (i-1)-ilx+1
|
||||
n2 = iux-(i)+1
|
||||
if (n1 > n2) then
|
||||
if (n1 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = ilx
|
||||
istack(2,istp) = i-1
|
||||
else
|
||||
call iaisr_up(n1,x(ilx:i-1))
|
||||
endif
|
||||
if (n2 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = i
|
||||
istack(2,istp) = iux
|
||||
else
|
||||
call iaisr_up(n2,x(i:iux))
|
||||
endif
|
||||
else
|
||||
if (n2 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = i
|
||||
istack(2,istp) = iux
|
||||
else
|
||||
call iaisr_up(n2,x(i:iux))
|
||||
endif
|
||||
if (n1 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = ilx
|
||||
istack(2,istp) = i-1
|
||||
else
|
||||
call iaisr_up(n1,x(ilx:i-1))
|
||||
endif
|
||||
endif
|
||||
enddo
|
||||
else
|
||||
call iaisr_up(n,x)
|
||||
endif
|
||||
|
||||
case(psb_asort_down_)
|
||||
|
||||
|
||||
if (n > ithrs) then
|
||||
!
|
||||
! Init stack pointer
|
||||
!
|
||||
istp = 1
|
||||
istack(1,istp) = 1
|
||||
istack(2,istp) = n
|
||||
|
||||
do
|
||||
if (istp <= 0) exit
|
||||
ilx = istack(1,istp)
|
||||
iux = istack(2,istp)
|
||||
istp = istp - 1
|
||||
!$$$ write(0,*) 'Debug 1: ',ilx,iux
|
||||
!
|
||||
! Choose a pivot with median-of-three heuristics, leave it
|
||||
! in the LPIV location
|
||||
!
|
||||
i = ilx
|
||||
j = iux
|
||||
lpiv = (i+j)/2
|
||||
piv = abs(x(lpiv))
|
||||
if (piv > abs(x(i))) then
|
||||
xt = x(i)
|
||||
x(i) = x(lpiv)
|
||||
x(lpiv) = xt
|
||||
piv = abs(x(lpiv))
|
||||
endif
|
||||
if (piv < abs(x(j))) then
|
||||
xt = x(j)
|
||||
x(j) = x(lpiv)
|
||||
x(lpiv) = xt
|
||||
piv = abs(x(lpiv))
|
||||
endif
|
||||
if (piv > abs(x(i))) then
|
||||
xt = x(i)
|
||||
x(i) = x(lpiv)
|
||||
x(lpiv) = xt
|
||||
piv = abs(x(lpiv))
|
||||
endif
|
||||
!
|
||||
! now piv is correct; place it into first location
|
||||
|
||||
xt = x(i)
|
||||
x(i) = x(lpiv)
|
||||
x(lpiv) = xt
|
||||
|
||||
i = ilx - 1
|
||||
j = iux + 1
|
||||
|
||||
outer_dw: do
|
||||
in_dw1: do
|
||||
i = i + 1
|
||||
xk = abs(x(i))
|
||||
if (xk <= piv) exit in_dw1
|
||||
end do in_dw1
|
||||
!
|
||||
! Ensure finite termination for next loop
|
||||
!
|
||||
xt = x(i)
|
||||
x(i) = piv
|
||||
in_dw2:do
|
||||
j = j - 1
|
||||
xk = abs(x(j))
|
||||
if (xk >= piv) exit in_dw2
|
||||
end do in_dw2
|
||||
x(i) = xt
|
||||
|
||||
if (j > i) then
|
||||
xt = x(i)
|
||||
x(i) = x(j)
|
||||
x(j) = xt
|
||||
else
|
||||
exit outer_dw
|
||||
end if
|
||||
end do outer_dw
|
||||
if (i == ilx) then
|
||||
if (x(i) /= piv) then
|
||||
write(0,*) 'Should never ever get here????!!!!'
|
||||
stop
|
||||
endif
|
||||
i = i + 1
|
||||
endif
|
||||
|
||||
n1 = (i-1)-ilx+1
|
||||
n2 = iux-(i)+1
|
||||
if (n1 > n2) then
|
||||
if (n1 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = ilx
|
||||
istack(2,istp) = i-1
|
||||
else
|
||||
call iaisr_dw(n1,x(ilx:i-1))
|
||||
endif
|
||||
if (n2 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = i
|
||||
istack(2,istp) = iux
|
||||
else
|
||||
call iaisr_dw(n2,x(i:iux))
|
||||
endif
|
||||
else
|
||||
if (n2 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = i
|
||||
istack(2,istp) = iux
|
||||
else
|
||||
call iaisr_dw(n2,x(i:iux))
|
||||
endif
|
||||
if (n1 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = ilx
|
||||
istack(2,istp) = i-1
|
||||
else
|
||||
call iaisr_dw(n1,x(ilx:i-1))
|
||||
endif
|
||||
endif
|
||||
enddo
|
||||
else
|
||||
call iaisr_dw(n,x)
|
||||
endif
|
||||
|
||||
case default
|
||||
write(0,*) 'isr error !',dir
|
||||
end select
|
||||
|
||||
|
||||
return
|
||||
|
||||
contains
|
||||
|
||||
subroutine iaisr_up(n,x)
|
||||
implicit none
|
||||
integer :: n
|
||||
integer :: x(n)
|
||||
integer :: i,j
|
||||
integer :: xx,xax
|
||||
|
||||
do j=n-1,1,-1
|
||||
if (abs(x(j+1)) < abs(x(j))) then
|
||||
xx = x(j)
|
||||
xax = abs(xx)
|
||||
i=j+1
|
||||
do
|
||||
x(i-1) = x(i)
|
||||
i = i+1
|
||||
if (i>n) exit
|
||||
if (abs(x(i)) >= xax) exit
|
||||
end do
|
||||
x(i-1) = xx
|
||||
endif
|
||||
enddo
|
||||
end subroutine iaisr_up
|
||||
|
||||
subroutine iaisr_dw(n,x)
|
||||
implicit none
|
||||
integer :: n
|
||||
integer :: x(n)
|
||||
integer :: i,j
|
||||
integer :: xx,xax
|
||||
|
||||
do j=n-1,1,-1
|
||||
if (abs(x(j+1)) > abs(x(j))) then
|
||||
xx = x(j)
|
||||
xax = abs(xx)
|
||||
i=j+1
|
||||
do
|
||||
x(i-1) = x(i)
|
||||
i = i+1
|
||||
if (i>n) exit
|
||||
if (abs(x(i)) <= xax) exit
|
||||
end do
|
||||
x(i-1) = xx
|
||||
endif
|
||||
enddo
|
||||
end subroutine iaisr_dw
|
||||
|
||||
end subroutine iasr
|
||||
@ -0,0 +1,409 @@
|
||||
!!$
|
||||
!!$ Parallel Sparse BLAS v2.0
|
||||
!!$ (C) Copyright 2006 Salvatore Filippone University of Rome Tor Vergata
|
||||
!!$ Alfredo Buttari University of Rome Tor Vergata
|
||||
!!$
|
||||
!!$ Redistribution and use in source and binary forms, with or without
|
||||
!!$ modification, are permitted provided that the following conditions
|
||||
!!$ are met:
|
||||
!!$ 1. Redistributions of source code must retain the above copyright
|
||||
!!$ notice, this list of conditions and the following disclaimer.
|
||||
!!$ 2. Redistributions in binary form must reproduce the above copyright
|
||||
!!$ notice, this list of conditions, and the following disclaimer in the
|
||||
!!$ documentation and/or other materials provided with the distribution.
|
||||
!!$ 3. The name of the PSBLAS group or the names of its contributors may
|
||||
!!$ not be used to endorse or promote products derived from this
|
||||
!!$ software without specific written permission.
|
||||
!!$
|
||||
!!$ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
!!$ ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
!!$ TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
!!$ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PSBLAS GROUP OR ITS CONTRIBUTORS
|
||||
!!$ BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
!!$ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
!!$ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
!!$ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
!!$ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
!!$ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
!!$ POSSIBILITY OF SUCH DAMAGE.
|
||||
!!$
|
||||
!!$
|
||||
subroutine iasrx(n,x,indx,dir,flag)
|
||||
use psb_serial_mod
|
||||
implicit none
|
||||
!
|
||||
! Quicksort on absolute value with indices into original positions.
|
||||
! Adapted from a number of sources, including Don Knuth's TAOCP.
|
||||
!
|
||||
! .. Scalar Arguments ..
|
||||
integer, intent(in) :: n, dir, flag
|
||||
integer :: x(n)
|
||||
integer :: indx(n)
|
||||
! ..
|
||||
! .. Local Scalars ..
|
||||
integer :: xx, piv, xt, xk
|
||||
integer i, j, ii, ilx, iux, istp, lpiv
|
||||
integer ixt, n1, n2
|
||||
|
||||
integer, parameter :: maxstack=64,nparms=3,ithrs=16
|
||||
integer :: istack(nparms,maxstack)
|
||||
! ..
|
||||
|
||||
select case(flag)
|
||||
case(psb_sort_ovw_idx_)
|
||||
do i=1, n
|
||||
indx(i) = i
|
||||
enddo
|
||||
case(psb_sort_keep_idx_)
|
||||
! do nothing
|
||||
case default
|
||||
write(0,*) 'Error in isrx: invalid flag',flag
|
||||
end select
|
||||
!
|
||||
|
||||
!
|
||||
! small inputs will only get through insertion sort.
|
||||
!
|
||||
select case(dir)
|
||||
|
||||
case(psb_asort_up_)
|
||||
|
||||
if (n > ithrs) then
|
||||
!
|
||||
! Init stack pointer
|
||||
!
|
||||
istp = 1
|
||||
istack(1,istp) = 1
|
||||
istack(2,istp) = n
|
||||
|
||||
do
|
||||
if (istp <= 0) exit
|
||||
ilx = istack(1,istp)
|
||||
iux = istack(2,istp)
|
||||
istp = istp - 1
|
||||
!$$$ write(0,*) 'Debug 1: ',ilx,iux
|
||||
!
|
||||
! Choose a pivot with median-of-three heuristics, leave it
|
||||
! in the LPIV location
|
||||
!
|
||||
i = ilx
|
||||
j = iux
|
||||
lpiv = (i+j)/2
|
||||
piv = abs(x(lpiv))
|
||||
if (piv < abs(x(i))) then
|
||||
xt = x(i)
|
||||
ixt = indx(i)
|
||||
x(i) = x(lpiv)
|
||||
indx(i) = indx(lpiv)
|
||||
x(lpiv) = xt
|
||||
indx(lpiv) = ixt
|
||||
piv = abs(x(lpiv))
|
||||
endif
|
||||
if (piv > abs(x(j))) then
|
||||
xt = x(j)
|
||||
ixt = indx(j)
|
||||
x(j) = x(lpiv)
|
||||
indx(j) = indx(lpiv)
|
||||
x(lpiv) = xt
|
||||
indx(lpiv) = ixt
|
||||
piv = abs(x(lpiv))
|
||||
endif
|
||||
if (piv < abs(x(i))) then
|
||||
xt = x(i)
|
||||
ixt = indx(i)
|
||||
x(i) = x(lpiv)
|
||||
indx(i) = indx(lpiv)
|
||||
x(lpiv) = xt
|
||||
indx(lpiv) = ixt
|
||||
piv = abs(x(lpiv))
|
||||
endif
|
||||
!
|
||||
! now piv is correct; place it into first location
|
||||
xt = x(i)
|
||||
ixt = indx(i)
|
||||
x(i) = x(lpiv)
|
||||
indx(i) = indx(lpiv)
|
||||
x(lpiv) = xt
|
||||
indx(lpiv) = ixt
|
||||
|
||||
i = ilx - 1
|
||||
j = iux + 1
|
||||
|
||||
outer_up: do
|
||||
in_up1: do
|
||||
i = i + 1
|
||||
xk = abs(x(i))
|
||||
if (xk >= piv) exit in_up1
|
||||
end do in_up1
|
||||
!
|
||||
! Ensure finite termination for next loop
|
||||
!
|
||||
xt = x(i)
|
||||
x(i) = piv
|
||||
in_up2:do
|
||||
j = j - 1
|
||||
xk = abs(x(j))
|
||||
if (xk <= piv) exit in_up2
|
||||
end do in_up2
|
||||
x(i) = xt
|
||||
|
||||
if (j > i) then
|
||||
xt = x(i)
|
||||
ixt = indx(i)
|
||||
x(i) = x(j)
|
||||
indx(i) = indx(j)
|
||||
x(j) = xt
|
||||
indx(j) = ixt
|
||||
else
|
||||
exit outer_up
|
||||
end if
|
||||
end do outer_up
|
||||
if (i == ilx) then
|
||||
if (x(i) /= piv) then
|
||||
write(0,*) 'Should never ever get here????!!!!'
|
||||
stop
|
||||
endif
|
||||
i = i + 1
|
||||
endif
|
||||
|
||||
n1 = (i-1)-ilx+1
|
||||
n2 = iux-(i)+1
|
||||
if (n1 > n2) then
|
||||
if (n1 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = ilx
|
||||
istack(2,istp) = i-1
|
||||
else
|
||||
call iiasrx_up(n1,x(ilx:i-1),indx(ilx:i-1))
|
||||
endif
|
||||
if (n2 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = i
|
||||
istack(2,istp) = iux
|
||||
else
|
||||
call iiasrx_up(n2,x(i:iux),indx(i:iux))
|
||||
endif
|
||||
else
|
||||
if (n2 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = i
|
||||
istack(2,istp) = iux
|
||||
else
|
||||
call iiasrx_up(n2,x(i:iux),indx(i:iux))
|
||||
endif
|
||||
if (n1 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = ilx
|
||||
istack(2,istp) = i-1
|
||||
else
|
||||
call iiasrx_up(n1,x(ilx:i-1),indx(ilx:i-1))
|
||||
endif
|
||||
endif
|
||||
enddo
|
||||
else
|
||||
call iiasrx_up(n,x,indx)
|
||||
endif
|
||||
|
||||
case(psb_asort_down_)
|
||||
|
||||
|
||||
if (n > ithrs) then
|
||||
!
|
||||
! Init stack pointer
|
||||
!
|
||||
istp = 1
|
||||
istack(1,istp) = 1
|
||||
istack(2,istp) = n
|
||||
|
||||
do
|
||||
if (istp <= 0) exit
|
||||
ilx = istack(1,istp)
|
||||
iux = istack(2,istp)
|
||||
istp = istp - 1
|
||||
!$$$ write(0,*) 'Debug 1: ',ilx,iux
|
||||
!
|
||||
! Choose a pivot with median-of-three heuristics, leave it
|
||||
! in the LPIV location
|
||||
!
|
||||
i = ilx
|
||||
j = iux
|
||||
lpiv = (i+j)/2
|
||||
piv = abs(x(lpiv))
|
||||
if (piv > abs(x(i))) then
|
||||
xt = x(i)
|
||||
ixt = indx(i)
|
||||
x(i) = x(lpiv)
|
||||
indx(i) = indx(lpiv)
|
||||
x(lpiv) = xt
|
||||
indx(lpiv) = ixt
|
||||
piv = abs(x(lpiv))
|
||||
endif
|
||||
if (piv < abs(x(j))) then
|
||||
xt = x(j)
|
||||
ixt = indx(j)
|
||||
x(j) = x(lpiv)
|
||||
indx(j) = indx(lpiv)
|
||||
x(lpiv) = xt
|
||||
indx(lpiv) = ixt
|
||||
piv = abs(x(lpiv))
|
||||
endif
|
||||
if (piv > abs(x(i))) then
|
||||
xt = x(i)
|
||||
ixt = indx(i)
|
||||
x(i) = x(lpiv)
|
||||
indx(i) = indx(lpiv)
|
||||
x(lpiv) = xt
|
||||
indx(lpiv) = ixt
|
||||
piv = abs(x(lpiv))
|
||||
endif
|
||||
!
|
||||
! now piv is correct; place it into first location
|
||||
xt = x(i)
|
||||
ixt = indx(i)
|
||||
x(i) = x(lpiv)
|
||||
indx(i) = indx(lpiv)
|
||||
x(lpiv) = xt
|
||||
indx(lpiv) = ixt
|
||||
|
||||
i = ilx - 1
|
||||
j = iux + 1
|
||||
|
||||
outer_dw: do
|
||||
in_dw1: do
|
||||
i = i + 1
|
||||
xk = abs(x(i))
|
||||
if (xk <= piv) exit in_dw1
|
||||
end do in_dw1
|
||||
!
|
||||
! Ensure finite termination for next loop
|
||||
!
|
||||
xt = x(i)
|
||||
x(i) = piv
|
||||
in_dw2:do
|
||||
j = j - 1
|
||||
xk = abs(x(j))
|
||||
if (xk >= piv) exit in_dw2
|
||||
end do in_dw2
|
||||
x(i) = xt
|
||||
|
||||
if (j > i) then
|
||||
xt = x(i)
|
||||
ixt = indx(i)
|
||||
x(i) = x(j)
|
||||
indx(i) = indx(j)
|
||||
x(j) = xt
|
||||
indx(j) = ixt
|
||||
else
|
||||
exit outer_dw
|
||||
end if
|
||||
end do outer_dw
|
||||
if (i == ilx) then
|
||||
if (x(i) /= piv) then
|
||||
write(0,*) 'Should never ever get here????!!!!'
|
||||
stop
|
||||
endif
|
||||
i = i + 1
|
||||
endif
|
||||
|
||||
n1 = (i-1)-ilx+1
|
||||
n2 = iux-(i)+1
|
||||
if (n1 > n2) then
|
||||
if (n1 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = ilx
|
||||
istack(2,istp) = i-1
|
||||
else
|
||||
call iiasrx_dw(n1,x(ilx:i-1),indx(ilx:i-1))
|
||||
endif
|
||||
if (n2 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = i
|
||||
istack(2,istp) = iux
|
||||
else
|
||||
call iiasrx_dw(n2,x(i:iux),indx(i:iux))
|
||||
endif
|
||||
else
|
||||
if (n2 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = i
|
||||
istack(2,istp) = iux
|
||||
else
|
||||
call iiasrx_dw(n2,x(i:iux),indx(i:iux))
|
||||
endif
|
||||
if (n1 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = ilx
|
||||
istack(2,istp) = i-1
|
||||
else
|
||||
call iiasrx_dw(n1,x(ilx:i-1),indx(ilx:i-1))
|
||||
endif
|
||||
endif
|
||||
enddo
|
||||
else
|
||||
call iiasrx_dw(n,x,indx)
|
||||
endif
|
||||
|
||||
case default
|
||||
write(0,*) 'isrx error dir ',dir
|
||||
end select
|
||||
|
||||
|
||||
return
|
||||
|
||||
contains
|
||||
|
||||
subroutine iiasrx_up(n,x,indx)
|
||||
implicit none
|
||||
integer :: n
|
||||
integer :: x(n)
|
||||
integer :: indx(n)
|
||||
integer :: i,j,ix
|
||||
integer :: xx,xax
|
||||
|
||||
do j=n-1,1,-1
|
||||
if (abs(x(j+1)) < abs(x(j))) then
|
||||
xx = x(j)
|
||||
ix = indx(j)
|
||||
xax = abs(xx)
|
||||
i=j+1
|
||||
do
|
||||
x(i-1) = x(i)
|
||||
indx(i-1) = indx(i)
|
||||
i = i+1
|
||||
if (i>n) exit
|
||||
if (abs(x(i)) >= xax) exit
|
||||
end do
|
||||
x(i-1) = xx
|
||||
indx(i-1) = ix
|
||||
endif
|
||||
enddo
|
||||
end subroutine iiasrx_up
|
||||
|
||||
subroutine iiasrx_dw(n,x,indx)
|
||||
implicit none
|
||||
integer :: n
|
||||
integer :: x(n)
|
||||
integer :: indx(n)
|
||||
integer :: i,j,ix
|
||||
integer :: xx,xax
|
||||
|
||||
do j=n-1,1,-1
|
||||
if (abs(x(j+1)) > abs(x(j))) then
|
||||
xx = x(j)
|
||||
ix = indx(j)
|
||||
xax = abs(xx)
|
||||
i=j+1
|
||||
do
|
||||
x(i-1) = x(i)
|
||||
indx(i-1) = indx(i)
|
||||
i = i+1
|
||||
if (i>n) exit
|
||||
if (abs(x(i)) <= xax) exit
|
||||
end do
|
||||
x(i-1) = xx
|
||||
indx(i-1) = ix
|
||||
endif
|
||||
enddo
|
||||
end subroutine iiasrx_dw
|
||||
|
||||
end subroutine iasrx
|
||||
@ -0,0 +1,44 @@
|
||||
module zacmp_mod
|
||||
interface operator(<)
|
||||
module procedure zalt
|
||||
end interface
|
||||
interface operator(<=)
|
||||
module procedure zale
|
||||
end interface
|
||||
interface operator(>)
|
||||
module procedure zagt
|
||||
end interface
|
||||
interface operator(>=)
|
||||
module procedure zage
|
||||
end interface
|
||||
|
||||
contains
|
||||
|
||||
function zalt(a,b)
|
||||
complex(kind(1.d0)), intent(in) :: a,b
|
||||
logical :: zalt
|
||||
|
||||
zalt = ((abs(real(a))+abs(aimag(a))) < (abs(real(b))+abs(aimag(b))))
|
||||
end function zalt
|
||||
function zale(a,b)
|
||||
complex(kind(1.d0)), intent(in) :: a,b
|
||||
logical :: zale
|
||||
|
||||
zale = ((abs(real(a))+abs(aimag(a))) <= (abs(real(b))+abs(aimag(b))))
|
||||
end function zale
|
||||
|
||||
function zagt(a,b)
|
||||
complex(kind(1.d0)), intent(in) :: a,b
|
||||
logical :: zagt
|
||||
|
||||
zagt = ((abs(real(a))+abs(aimag(a))) > (abs(real(b))+abs(aimag(b))))
|
||||
end function zagt
|
||||
function zage(a,b)
|
||||
complex(kind(1.d0)), intent(in) :: a,b
|
||||
logical :: zage
|
||||
|
||||
zage = ((abs(real(a))+abs(aimag(a))) >= (abs(real(b))+abs(aimag(b))))
|
||||
end function zage
|
||||
|
||||
end module zacmp_mod
|
||||
|
||||
@ -0,0 +1,48 @@
|
||||
module zalcmp_mod
|
||||
interface operator(<)
|
||||
module procedure zallt
|
||||
end interface
|
||||
interface operator(<=)
|
||||
module procedure zalle
|
||||
end interface
|
||||
interface operator(>)
|
||||
module procedure zalgt
|
||||
end interface
|
||||
interface operator(>=)
|
||||
module procedure zalge
|
||||
end interface
|
||||
|
||||
contains
|
||||
|
||||
function zallt(a,b)
|
||||
complex(kind(1.d0)), intent(in) :: a,b
|
||||
logical :: zallt
|
||||
|
||||
zallt = (abs(real(a))<abs(real(b))).or. &
|
||||
& ((abs(real(a))==abs(real(b))).and.(abs(aimag(a))<abs(aimag(b))))
|
||||
end function zallt
|
||||
function zalle(a,b)
|
||||
complex(kind(1.d0)), intent(in) :: a,b
|
||||
logical :: zalle
|
||||
|
||||
zalle = (abs(real(a))<abs(real(b))).or. &
|
||||
& ((abs(real(a))==abs(real(b))).and.(abs(aimag(a))<=abs(aimag(b))))
|
||||
end function zalle
|
||||
|
||||
function zalgt(a,b)
|
||||
complex(kind(1.d0)), intent(in) :: a,b
|
||||
logical :: zalgt
|
||||
|
||||
zalgt = (abs(real(a))>abs(real(b))).or. &
|
||||
& ((abs(real(a))==abs(real(b))).and.(abs(aimag(a))>abs(aimag(b))))
|
||||
end function zalgt
|
||||
function zalge(a,b)
|
||||
complex(kind(1.d0)), intent(in) :: a,b
|
||||
logical :: zalge
|
||||
|
||||
zalge = (abs(real(a))>abs(real(b))).or. &
|
||||
& ((abs(real(a))==abs(real(b))).and.(abs(aimag(a))>=abs(aimag(b))))
|
||||
end function zalge
|
||||
|
||||
end module zalcmp_mod
|
||||
|
||||
@ -0,0 +1,362 @@
|
||||
!!$
|
||||
!!$ Parallel Sparse BLAS v2.0
|
||||
!!$ (C) Copyright 2006 Salvatore Filippone University of Rome Tor Vergata
|
||||
!!$ Alfredo Buttari University of Rome Tor Vergata
|
||||
!!$
|
||||
!!$ Redistribution and use in source and binary forms, with or without
|
||||
!!$ modification, are permitted provided that the following conditions
|
||||
!!$ are met:
|
||||
!!$ 1. Redistributions of source code must retain the above copyright
|
||||
!!$ notice, this list of conditions and the following disclaimer.
|
||||
!!$ 2. Redistributions in binary form must reproduce the above copyright
|
||||
!!$ notice, this list of conditions, and the following disclaimer in the
|
||||
!!$ documentation and/or other materials provided with the distribution.
|
||||
!!$ 3. The name of the PSBLAS group or the names of its contributors may
|
||||
!!$ not be used to endorse or promote products derived from this
|
||||
!!$ software without specific written permission.
|
||||
!!$
|
||||
!!$ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
!!$ ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
!!$ TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
!!$ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PSBLAS GROUP OR ITS CONTRIBUTORS
|
||||
!!$ BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
!!$ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
!!$ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
!!$ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
!!$ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
!!$ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
!!$ POSSIBILITY OF SUCH DAMAGE.
|
||||
!!$
|
||||
!!$
|
||||
|
||||
subroutine zalsr(n,x,dir)
|
||||
use psb_serial_mod
|
||||
use zalcmp_mod
|
||||
implicit none
|
||||
!
|
||||
! Quicksort on lexicographic comparison of complex numbers.
|
||||
! Adapted from a number of sources, including Don Knuth's TAOCP.
|
||||
!
|
||||
! .. Scalar Arguments ..
|
||||
integer, intent(in) :: n, dir
|
||||
complex(kind(1.d0)) :: x(n)
|
||||
! ..
|
||||
! .. Local Scalars ..
|
||||
complex(kind(1.d0)) :: xx, xk, piv, xt
|
||||
integer i, j, ilx, iux, istp, lpiv
|
||||
integer n1, n2
|
||||
|
||||
integer, parameter :: maxstack=64,nparms=3,ithrs=16
|
||||
integer :: istack(nparms,maxstack)
|
||||
! ..
|
||||
|
||||
!
|
||||
! small inputs will only get through insertion sort.
|
||||
!
|
||||
select case(dir)
|
||||
|
||||
case(psb_alsort_up_)
|
||||
|
||||
if (n > ithrs) then
|
||||
!
|
||||
! Init stack pointer
|
||||
!
|
||||
istp = 1
|
||||
istack(1,istp) = 1
|
||||
istack(2,istp) = n
|
||||
|
||||
do
|
||||
if (istp <= 0) exit
|
||||
ilx = istack(1,istp)
|
||||
iux = istack(2,istp)
|
||||
istp = istp - 1
|
||||
!$$$ write(0,*) 'Debug 1: ',ilx,iux
|
||||
!
|
||||
! Choose a pivot with median-of-three heuristics, leave it
|
||||
! in the LPIV location
|
||||
!
|
||||
i = ilx
|
||||
j = iux
|
||||
lpiv = (i+j)/2
|
||||
piv = x(lpiv)
|
||||
if (piv < x(i)) then
|
||||
xt = x(i)
|
||||
x(i) = x(lpiv)
|
||||
x(lpiv) = xt
|
||||
piv = x(lpiv)
|
||||
endif
|
||||
if (piv > x(j)) then
|
||||
xt = x(j)
|
||||
x(j) = x(lpiv)
|
||||
x(lpiv) = xt
|
||||
piv = x(lpiv)
|
||||
endif
|
||||
if (piv < x(i)) then
|
||||
xt = x(i)
|
||||
x(i) = x(lpiv)
|
||||
x(lpiv) = xt
|
||||
piv = x(lpiv)
|
||||
endif
|
||||
!
|
||||
! now piv is correct; place it into first location
|
||||
|
||||
xt = x(i)
|
||||
x(i) = x(lpiv)
|
||||
x(lpiv) = xt
|
||||
|
||||
i = ilx - 1
|
||||
j = iux + 1
|
||||
|
||||
outer_up: do
|
||||
in_up1: do
|
||||
i = i + 1
|
||||
xk = x(i)
|
||||
if (xk >= piv) exit in_up1
|
||||
end do in_up1
|
||||
!
|
||||
! Ensure finite termination for next loop
|
||||
!
|
||||
xt = xk
|
||||
x(i) = piv
|
||||
in_up2:do
|
||||
j = j - 1
|
||||
xk = x(j)
|
||||
if (xk <= piv) exit in_up2
|
||||
end do in_up2
|
||||
x(i) = xt
|
||||
|
||||
if (j > i) then
|
||||
xt = x(i)
|
||||
x(i) = x(j)
|
||||
x(j) = xt
|
||||
else
|
||||
exit outer_up
|
||||
end if
|
||||
end do outer_up
|
||||
if (i == ilx) then
|
||||
if (x(i) /= piv) then
|
||||
write(0,*) 'Should never ever get here????!!!!'
|
||||
stop
|
||||
endif
|
||||
i = i + 1
|
||||
endif
|
||||
|
||||
n1 = (i-1)-ilx+1
|
||||
n2 = iux-(i)+1
|
||||
if (n1 > n2) then
|
||||
if (n1 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = ilx
|
||||
istack(2,istp) = i-1
|
||||
else
|
||||
call izalsr_up(n1,x(ilx:i-1))
|
||||
endif
|
||||
if (n2 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = i
|
||||
istack(2,istp) = iux
|
||||
else
|
||||
call izalsr_up(n2,x(i:iux))
|
||||
endif
|
||||
else
|
||||
if (n2 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = i
|
||||
istack(2,istp) = iux
|
||||
else
|
||||
call izalsr_up(n2,x(i:iux))
|
||||
endif
|
||||
if (n1 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = ilx
|
||||
istack(2,istp) = i-1
|
||||
else
|
||||
call izalsr_up(n1,x(ilx:i-1))
|
||||
endif
|
||||
endif
|
||||
enddo
|
||||
else
|
||||
call izalsr_up(n,x)
|
||||
endif
|
||||
|
||||
case(psb_alsort_down_)
|
||||
|
||||
|
||||
if (n > ithrs) then
|
||||
!
|
||||
! Init stack pointer
|
||||
!
|
||||
istp = 1
|
||||
istack(1,istp) = 1
|
||||
istack(2,istp) = n
|
||||
|
||||
do
|
||||
if (istp <= 0) exit
|
||||
ilx = istack(1,istp)
|
||||
iux = istack(2,istp)
|
||||
istp = istp - 1
|
||||
!$$$ write(0,*) 'Debug 1: ',ilx,iux
|
||||
!
|
||||
! Choose a pivot with median-of-three heuristics, leave it
|
||||
! in the LPIV location
|
||||
!
|
||||
i = ilx
|
||||
j = iux
|
||||
lpiv = (i+j)/2
|
||||
piv = x(lpiv)
|
||||
if (piv > x(i)) then
|
||||
xt = x(i)
|
||||
x(i) = x(lpiv)
|
||||
x(lpiv) = xt
|
||||
piv = x(lpiv)
|
||||
endif
|
||||
if (piv < x(j)) then
|
||||
xt = x(j)
|
||||
x(j) = x(lpiv)
|
||||
x(lpiv) = xt
|
||||
piv = x(lpiv)
|
||||
endif
|
||||
if (piv > x(i)) then
|
||||
xt = x(i)
|
||||
x(i) = x(lpiv)
|
||||
x(lpiv) = xt
|
||||
piv = x(lpiv)
|
||||
endif
|
||||
!
|
||||
! now piv is correct; place it into first location
|
||||
|
||||
xt = x(i)
|
||||
x(i) = x(lpiv)
|
||||
x(lpiv) = xt
|
||||
|
||||
i = ilx - 1
|
||||
j = iux + 1
|
||||
|
||||
outer_dw: do
|
||||
in_dw1: do
|
||||
i = i + 1
|
||||
xk = x(i)
|
||||
if (xk <= piv) exit in_dw1
|
||||
end do in_dw1
|
||||
!
|
||||
! Ensure finite termination for next loop
|
||||
!
|
||||
xt = xk
|
||||
x(i) = piv
|
||||
in_dw2:do
|
||||
j = j - 1
|
||||
xk = x(j)
|
||||
if (xk >= piv) exit in_dw2
|
||||
end do in_dw2
|
||||
x(i) = xt
|
||||
|
||||
if (j > i) then
|
||||
xt = x(i)
|
||||
x(i) = x(j)
|
||||
x(j) = xt
|
||||
else
|
||||
exit outer_dw
|
||||
end if
|
||||
end do outer_dw
|
||||
if (i == ilx) then
|
||||
if (x(i) /= piv) then
|
||||
write(0,*) 'Should never ever get here????!!!!'
|
||||
stop
|
||||
endif
|
||||
i = i + 1
|
||||
endif
|
||||
|
||||
n1 = (i-1)-ilx+1
|
||||
n2 = iux-(i)+1
|
||||
if (n1 > n2) then
|
||||
if (n1 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = ilx
|
||||
istack(2,istp) = i-1
|
||||
else
|
||||
call izalsr_dw(n1,x(ilx:i-1))
|
||||
endif
|
||||
if (n2 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = i
|
||||
istack(2,istp) = iux
|
||||
else
|
||||
call izalsr_dw(n2,x(i:iux))
|
||||
endif
|
||||
else
|
||||
if (n2 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = i
|
||||
istack(2,istp) = iux
|
||||
else
|
||||
call izalsr_dw(n2,x(i:iux))
|
||||
endif
|
||||
if (n1 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = ilx
|
||||
istack(2,istp) = i-1
|
||||
else
|
||||
call izalsr_dw(n1,x(ilx:i-1))
|
||||
endif
|
||||
endif
|
||||
enddo
|
||||
else
|
||||
call izalsr_dw(n,x)
|
||||
endif
|
||||
|
||||
case default
|
||||
write(0,*) 'isr error !',dir
|
||||
end select
|
||||
|
||||
|
||||
return
|
||||
|
||||
contains
|
||||
|
||||
subroutine izalsr_up(n,x)
|
||||
use zalcmp_mod
|
||||
implicit none
|
||||
integer :: n
|
||||
complex(kind(1.d0)) :: x(n)
|
||||
integer :: i,j
|
||||
complex(kind(1.d0)) :: xx
|
||||
|
||||
do j=n-1,1,-1
|
||||
if (x(j+1) < x(j)) then
|
||||
xx = x(j)
|
||||
i=j+1
|
||||
do
|
||||
x(i-1) = x(i)
|
||||
i = i+1
|
||||
if (i>n) exit
|
||||
if (x(i) >= xx) exit
|
||||
end do
|
||||
x(i-1) = xx
|
||||
endif
|
||||
enddo
|
||||
end subroutine izalsr_up
|
||||
|
||||
subroutine izalsr_dw(n,x)
|
||||
use zalcmp_mod
|
||||
implicit none
|
||||
integer :: n
|
||||
complex(kind(1.d0)) :: x(n)
|
||||
integer :: i,j
|
||||
complex(kind(1.d0)) :: xx
|
||||
|
||||
do j=n-1,1,-1
|
||||
if (x(j+1) > x(j)) then
|
||||
xx = x(j)
|
||||
i=j+1
|
||||
do
|
||||
x(i-1) = x(i)
|
||||
i = i+1
|
||||
if (i>n) exit
|
||||
if (x(i) <= xx) exit
|
||||
end do
|
||||
x(i-1) = xx
|
||||
endif
|
||||
enddo
|
||||
end subroutine izalsr_dw
|
||||
|
||||
end subroutine zalsr
|
||||
@ -0,0 +1,413 @@
|
||||
!!$
|
||||
!!$ Parallel Sparse BLAS v2.0
|
||||
!!$ (C) Copyright 2006 Salvatore Filippone University of Rome Tor Vergata
|
||||
!!$ Alfredo Buttari University of Rome Tor Vergata
|
||||
!!$
|
||||
!!$ Redistribution and use in source and binary forms, with or without
|
||||
!!$ modification, are permitted provided that the following conditions
|
||||
!!$ are met:
|
||||
!!$ 1. Redistributions of source code must retain the above copyright
|
||||
!!$ notice, this list of conditions and the following disclaimer.
|
||||
!!$ 2. Redistributions in binary form must reproduce the above copyright
|
||||
!!$ notice, this list of conditions, and the following disclaimer in the
|
||||
!!$ documentation and/or other materials provided with the distribution.
|
||||
!!$ 3. The name of the PSBLAS group or the names of its contributors may
|
||||
!!$ not be used to endorse or promote products derived from this
|
||||
!!$ software without specific written permission.
|
||||
!!$
|
||||
!!$ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
!!$ ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
!!$ TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
!!$ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PSBLAS GROUP OR ITS CONTRIBUTORS
|
||||
!!$ BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
!!$ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
!!$ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
!!$ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
!!$ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
!!$ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
!!$ POSSIBILITY OF SUCH DAMAGE.
|
||||
!!$
|
||||
!!$
|
||||
subroutine zalsrx(n,x,indx,dir,flag)
|
||||
use psb_serial_mod
|
||||
use zalcmp_mod
|
||||
implicit none
|
||||
!
|
||||
! Quicksort with indices into original positions.
|
||||
! Adapted from a number of sources, including Don Knuth's TAOCP.
|
||||
!
|
||||
! .. Scalar Arguments ..
|
||||
integer, intent(in) :: n, dir, flag
|
||||
complex(kind(1.d0)) :: x(n)
|
||||
integer :: indx(n)
|
||||
! ..
|
||||
! .. Local Scalars ..
|
||||
complex(kind(1.d0)) :: xx, piv, xk, xt
|
||||
integer i, j, ii, ilx, iux, istp, lpiv
|
||||
integer ixt, n1, n2
|
||||
|
||||
integer, parameter :: maxstack=64,nparms=3,ithrs=16
|
||||
integer :: istack(nparms,maxstack)
|
||||
! ..
|
||||
|
||||
select case(flag)
|
||||
case(psb_sort_ovw_idx_)
|
||||
do i=1, n
|
||||
indx(i) = i
|
||||
enddo
|
||||
case(psb_sort_keep_idx_)
|
||||
! do nothing
|
||||
case default
|
||||
write(0,*) 'Error in isrx: invalid flag',flag
|
||||
end select
|
||||
!
|
||||
|
||||
!
|
||||
! small inputs will only get through insertion sort.
|
||||
!
|
||||
select case(dir)
|
||||
|
||||
case(psb_alsort_up_)
|
||||
|
||||
if (n > ithrs) then
|
||||
!
|
||||
! Init stack pointer
|
||||
!
|
||||
istp = 1
|
||||
istack(1,istp) = 1
|
||||
istack(2,istp) = n
|
||||
|
||||
do
|
||||
if (istp <= 0) exit
|
||||
ilx = istack(1,istp)
|
||||
iux = istack(2,istp)
|
||||
istp = istp - 1
|
||||
!$$$ write(0,*) 'Debug 1: ',ilx,iux
|
||||
!
|
||||
! Choose a pivot with median-of-three heuristics, leave it
|
||||
! in the LPIV location
|
||||
!
|
||||
i = ilx
|
||||
j = iux
|
||||
lpiv = (i+j)/2
|
||||
piv = x(lpiv)
|
||||
if (piv < x(i)) then
|
||||
xt = x(i)
|
||||
ixt = indx(i)
|
||||
x(i) = x(lpiv)
|
||||
indx(i) = indx(lpiv)
|
||||
x(lpiv) = xt
|
||||
indx(lpiv) = ixt
|
||||
piv = x(lpiv)
|
||||
endif
|
||||
if (piv > x(j)) then
|
||||
xt = x(j)
|
||||
ixt = indx(j)
|
||||
x(j) = x(lpiv)
|
||||
indx(j) = indx(lpiv)
|
||||
x(lpiv) = xt
|
||||
indx(lpiv) = ixt
|
||||
piv = x(lpiv)
|
||||
endif
|
||||
if (piv < x(i)) then
|
||||
xt = x(i)
|
||||
ixt = indx(i)
|
||||
x(i) = x(lpiv)
|
||||
indx(i) = indx(lpiv)
|
||||
x(lpiv) = xt
|
||||
indx(lpiv) = ixt
|
||||
piv = x(lpiv)
|
||||
endif
|
||||
!
|
||||
! now piv is correct; place it into first location
|
||||
xt = x(i)
|
||||
ixt = indx(i)
|
||||
x(i) = x(lpiv)
|
||||
indx(i) = indx(lpiv)
|
||||
x(lpiv) = xt
|
||||
indx(lpiv) = ixt
|
||||
piv = x(lpiv)
|
||||
|
||||
i = ilx - 1
|
||||
j = iux + 1
|
||||
|
||||
outer_up: do
|
||||
in_up1: do
|
||||
i = i + 1
|
||||
xk = x(i)
|
||||
if (xk >= piv) exit in_up1
|
||||
end do in_up1
|
||||
!
|
||||
! Ensure finite termination for next loop
|
||||
!
|
||||
xt = xk
|
||||
x(i) = piv
|
||||
in_up2:do
|
||||
j = j - 1
|
||||
xk = x(j)
|
||||
if (xk <= piv) exit in_up2
|
||||
end do in_up2
|
||||
x(i) = xt
|
||||
|
||||
if (j > i) then
|
||||
xt = x(i)
|
||||
ixt = indx(i)
|
||||
x(i) = x(j)
|
||||
indx(i) = indx(j)
|
||||
x(j) = xt
|
||||
indx(j) = ixt
|
||||
else
|
||||
exit outer_up
|
||||
end if
|
||||
end do outer_up
|
||||
if (i == ilx) then
|
||||
if (x(i) /= piv) then
|
||||
write(0,*) 'Should never ever get here????!!!!'
|
||||
stop
|
||||
endif
|
||||
i = i + 1
|
||||
endif
|
||||
|
||||
n1 = (i-1)-ilx+1
|
||||
n2 = iux-(i)+1
|
||||
if (n1 > n2) then
|
||||
if (n1 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = ilx
|
||||
istack(2,istp) = i-1
|
||||
else
|
||||
call izalsrx_up(n1,x(ilx:i-1),indx(ilx:i-1))
|
||||
endif
|
||||
if (n2 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = i
|
||||
istack(2,istp) = iux
|
||||
else
|
||||
call izalsrx_up(n2,x(i:iux),indx(i:iux))
|
||||
endif
|
||||
else
|
||||
if (n2 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = i
|
||||
istack(2,istp) = iux
|
||||
else
|
||||
call izalsrx_up(n2,x(i:iux),indx(i:iux))
|
||||
endif
|
||||
if (n1 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = ilx
|
||||
istack(2,istp) = i-1
|
||||
else
|
||||
call izalsrx_up(n1,x(ilx:i-1),indx(ilx:i-1))
|
||||
endif
|
||||
endif
|
||||
enddo
|
||||
else
|
||||
call izalsrx_up(n,x,indx)
|
||||
endif
|
||||
|
||||
case(psb_alsort_down_)
|
||||
|
||||
|
||||
|
||||
if (n > ithrs) then
|
||||
!
|
||||
! Init stack pointer
|
||||
!
|
||||
istp = 1
|
||||
istack(1,istp) = 1
|
||||
istack(2,istp) = n
|
||||
|
||||
do
|
||||
if (istp <= 0) exit
|
||||
ilx = istack(1,istp)
|
||||
iux = istack(2,istp)
|
||||
istp = istp - 1
|
||||
!$$$ write(0,*) 'Debug 1: ',ilx,iux
|
||||
!
|
||||
! Choose a pivot with median-of-three heuristics, leave it
|
||||
! in the LPIV location
|
||||
!
|
||||
i = ilx
|
||||
j = iux
|
||||
lpiv = (i+j)/2
|
||||
piv = x(lpiv)
|
||||
if (piv > x(i)) then
|
||||
xt = x(i)
|
||||
ixt = indx(i)
|
||||
x(i) = x(lpiv)
|
||||
indx(i) = indx(lpiv)
|
||||
x(lpiv) = xt
|
||||
indx(lpiv) = ixt
|
||||
piv = x(lpiv)
|
||||
endif
|
||||
if (piv < x(j)) then
|
||||
xt = x(j)
|
||||
ixt = indx(j)
|
||||
x(j) = x(lpiv)
|
||||
indx(j) = indx(lpiv)
|
||||
x(lpiv) = xt
|
||||
indx(lpiv) = ixt
|
||||
piv = x(lpiv)
|
||||
endif
|
||||
if (piv > x(i)) then
|
||||
xt = x(i)
|
||||
ixt = indx(i)
|
||||
x(i) = x(lpiv)
|
||||
indx(i) = indx(lpiv)
|
||||
x(lpiv) = xt
|
||||
indx(lpiv) = ixt
|
||||
piv = x(lpiv)
|
||||
endif
|
||||
!
|
||||
! now piv is correct; place it into first location
|
||||
xt = x(i)
|
||||
ixt = indx(i)
|
||||
x(i) = x(lpiv)
|
||||
indx(i) = indx(lpiv)
|
||||
x(lpiv) = xt
|
||||
indx(lpiv) = ixt
|
||||
piv = x(lpiv)
|
||||
|
||||
i = ilx - 1
|
||||
j = iux + 1
|
||||
|
||||
outer_dw: do
|
||||
in_dw1: do
|
||||
i = i + 1
|
||||
xk = x(i)
|
||||
if (xk <= piv) exit in_dw1
|
||||
end do in_dw1
|
||||
!
|
||||
! Ensure finite termination for next loop
|
||||
!
|
||||
xt = xk
|
||||
x(i) = piv
|
||||
in_dw2:do
|
||||
j = j - 1
|
||||
xk = x(j)
|
||||
if (xk >= piv) exit in_dw2
|
||||
end do in_dw2
|
||||
x(i) = xt
|
||||
|
||||
if (j > i) then
|
||||
xt = x(i)
|
||||
ixt = indx(i)
|
||||
x(i) = x(j)
|
||||
indx(i) = indx(j)
|
||||
x(j) = xt
|
||||
indx(j) = ixt
|
||||
else
|
||||
exit outer_dw
|
||||
end if
|
||||
end do outer_dw
|
||||
if (i == ilx) then
|
||||
if (x(i) /= piv) then
|
||||
write(0,*) 'Should never ever get here????!!!!'
|
||||
stop
|
||||
endif
|
||||
i = i + 1
|
||||
endif
|
||||
|
||||
n1 = (i-1)-ilx+1
|
||||
n2 = iux-(i)+1
|
||||
if (n1 > n2) then
|
||||
if (n1 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = ilx
|
||||
istack(2,istp) = i-1
|
||||
else
|
||||
call izalsrx_dw(n1,x(ilx:i-1),indx(ilx:i-1))
|
||||
endif
|
||||
if (n2 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = i
|
||||
istack(2,istp) = iux
|
||||
else
|
||||
call izalsrx_dw(n2,x(i:iux),indx(i:iux))
|
||||
endif
|
||||
else
|
||||
if (n2 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = i
|
||||
istack(2,istp) = iux
|
||||
else
|
||||
call izalsrx_dw(n2,x(i:iux),indx(i:iux))
|
||||
endif
|
||||
if (n1 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = ilx
|
||||
istack(2,istp) = i-1
|
||||
else
|
||||
call izalsrx_dw(n1,x(ilx:i-1),indx(ilx:i-1))
|
||||
endif
|
||||
endif
|
||||
enddo
|
||||
else
|
||||
call izalsrx_dw(n,x,indx)
|
||||
endif
|
||||
|
||||
case default
|
||||
write(0,*) 'isrx error dir ',dir
|
||||
end select
|
||||
|
||||
|
||||
return
|
||||
|
||||
contains
|
||||
|
||||
subroutine izalsrx_up(n,x,indx)
|
||||
use zalcmp_mod
|
||||
implicit none
|
||||
integer :: n
|
||||
complex(kind(1.d0)) :: x(n)
|
||||
integer :: indx(n)
|
||||
integer :: i,j,ix
|
||||
complex(kind(1.d0)) :: xx
|
||||
|
||||
do j=n-1,1,-1
|
||||
if (x(j+1) < x(j)) then
|
||||
xx = x(j)
|
||||
ix = indx(j)
|
||||
i=j+1
|
||||
do
|
||||
x(i-1) = x(i)
|
||||
indx(i-1) = indx(i)
|
||||
i = i+1
|
||||
if (i>n) exit
|
||||
if (x(i) >= xx) exit
|
||||
end do
|
||||
x(i-1) = xx
|
||||
indx(i-1) = ix
|
||||
endif
|
||||
enddo
|
||||
end subroutine izalsrx_up
|
||||
|
||||
subroutine izalsrx_dw(n,x,indx)
|
||||
use zalcmp_mod
|
||||
implicit none
|
||||
integer :: n
|
||||
complex(kind(1.d0)) :: x(n)
|
||||
integer :: indx(n)
|
||||
integer :: i,j,ix
|
||||
complex(kind(1.d0)) :: xx
|
||||
|
||||
do j=n-1,1,-1
|
||||
if (x(j+1) > x(j)) then
|
||||
xx = x(j)
|
||||
ix = indx(j)
|
||||
i=j+1
|
||||
do
|
||||
x(i-1) = x(i)
|
||||
indx(i-1) = indx(i)
|
||||
i = i+1
|
||||
if (i>n) exit
|
||||
if (x(i) <= xx) exit
|
||||
end do
|
||||
x(i-1) = xx
|
||||
indx(i-1) = ix
|
||||
endif
|
||||
enddo
|
||||
end subroutine izalsrx_dw
|
||||
|
||||
end subroutine zalsrx
|
||||
@ -0,0 +1,362 @@
|
||||
!!$
|
||||
!!$ Parallel Sparse BLAS v2.0
|
||||
!!$ (C) Copyright 2006 Salvatore Filippone University of Rome Tor Vergata
|
||||
!!$ Alfredo Buttari University of Rome Tor Vergata
|
||||
!!$
|
||||
!!$ Redistribution and use in source and binary forms, with or without
|
||||
!!$ modification, are permitted provided that the following conditions
|
||||
!!$ are met:
|
||||
!!$ 1. Redistributions of source code must retain the above copyright
|
||||
!!$ notice, this list of conditions and the following disclaimer.
|
||||
!!$ 2. Redistributions in binary form must reproduce the above copyright
|
||||
!!$ notice, this list of conditions, and the following disclaimer in the
|
||||
!!$ documentation and/or other materials provided with the distribution.
|
||||
!!$ 3. The name of the PSBLAS group or the names of its contributors may
|
||||
!!$ not be used to endorse or promote products derived from this
|
||||
!!$ software without specific written permission.
|
||||
!!$
|
||||
!!$ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
!!$ ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
!!$ TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
!!$ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PSBLAS GROUP OR ITS CONTRIBUTORS
|
||||
!!$ BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
!!$ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
!!$ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
!!$ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
!!$ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
!!$ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
!!$ POSSIBILITY OF SUCH DAMAGE.
|
||||
!!$
|
||||
!!$
|
||||
|
||||
subroutine zasr(n,x,dir)
|
||||
use psb_serial_mod
|
||||
use zacmp_mod
|
||||
implicit none
|
||||
!
|
||||
! Quicksort on lexicographic comparison of complex numbers.
|
||||
! Adapted from a number of sources, including Don Knuth's TAOCP.
|
||||
!
|
||||
! .. Scalar Arguments ..
|
||||
integer, intent(in) :: n, dir
|
||||
complex(kind(1.d0)) :: x(n)
|
||||
! ..
|
||||
! .. Local Scalars ..
|
||||
complex(kind(1.d0)) :: xx, xk, piv, xt
|
||||
integer i, j, ilx, iux, istp, lpiv
|
||||
integer n1, n2
|
||||
|
||||
integer, parameter :: maxstack=64,nparms=3,ithrs=16
|
||||
integer :: istack(nparms,maxstack)
|
||||
! ..
|
||||
|
||||
!
|
||||
! small inputs will only get through insertion sort.
|
||||
!
|
||||
select case(dir)
|
||||
|
||||
case(psb_alsort_up_)
|
||||
|
||||
if (n > ithrs) then
|
||||
!
|
||||
! Init stack pointer
|
||||
!
|
||||
istp = 1
|
||||
istack(1,istp) = 1
|
||||
istack(2,istp) = n
|
||||
|
||||
do
|
||||
if (istp <= 0) exit
|
||||
ilx = istack(1,istp)
|
||||
iux = istack(2,istp)
|
||||
istp = istp - 1
|
||||
!$$$ write(0,*) 'Debug 1: ',ilx,iux
|
||||
!
|
||||
! Choose a pivot with median-of-three heuristics, leave it
|
||||
! in the LPIV location
|
||||
!
|
||||
i = ilx
|
||||
j = iux
|
||||
lpiv = (i+j)/2
|
||||
piv = x(lpiv)
|
||||
if (piv < x(i)) then
|
||||
xt = x(i)
|
||||
x(i) = x(lpiv)
|
||||
x(lpiv) = xt
|
||||
piv = x(lpiv)
|
||||
endif
|
||||
if (piv > x(j)) then
|
||||
xt = x(j)
|
||||
x(j) = x(lpiv)
|
||||
x(lpiv) = xt
|
||||
piv = x(lpiv)
|
||||
endif
|
||||
if (piv < x(i)) then
|
||||
xt = x(i)
|
||||
x(i) = x(lpiv)
|
||||
x(lpiv) = xt
|
||||
piv = x(lpiv)
|
||||
endif
|
||||
!
|
||||
! now piv is correct; place it into first location
|
||||
|
||||
xt = x(i)
|
||||
x(i) = x(lpiv)
|
||||
x(lpiv) = xt
|
||||
|
||||
i = ilx - 1
|
||||
j = iux + 1
|
||||
|
||||
outer_up: do
|
||||
in_up1: do
|
||||
i = i + 1
|
||||
xk = x(i)
|
||||
if (xk >= piv) exit in_up1
|
||||
end do in_up1
|
||||
!
|
||||
! Ensure finite termination for next loop
|
||||
!
|
||||
xt = xk
|
||||
x(i) = piv
|
||||
in_up2:do
|
||||
j = j - 1
|
||||
xk = x(j)
|
||||
if (xk <= piv) exit in_up2
|
||||
end do in_up2
|
||||
x(i) = xt
|
||||
|
||||
if (j > i) then
|
||||
xt = x(i)
|
||||
x(i) = x(j)
|
||||
x(j) = xt
|
||||
else
|
||||
exit outer_up
|
||||
end if
|
||||
end do outer_up
|
||||
if (i == ilx) then
|
||||
if (x(i) /= piv) then
|
||||
write(0,*) 'Should never ever get here????!!!!'
|
||||
stop
|
||||
endif
|
||||
i = i + 1
|
||||
endif
|
||||
|
||||
n1 = (i-1)-ilx+1
|
||||
n2 = iux-(i)+1
|
||||
if (n1 > n2) then
|
||||
if (n1 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = ilx
|
||||
istack(2,istp) = i-1
|
||||
else
|
||||
call izasr_up(n1,x(ilx:i-1))
|
||||
endif
|
||||
if (n2 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = i
|
||||
istack(2,istp) = iux
|
||||
else
|
||||
call izasr_up(n2,x(i:iux))
|
||||
endif
|
||||
else
|
||||
if (n2 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = i
|
||||
istack(2,istp) = iux
|
||||
else
|
||||
call izasr_up(n2,x(i:iux))
|
||||
endif
|
||||
if (n1 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = ilx
|
||||
istack(2,istp) = i-1
|
||||
else
|
||||
call izasr_up(n1,x(ilx:i-1))
|
||||
endif
|
||||
endif
|
||||
enddo
|
||||
else
|
||||
call izasr_up(n,x)
|
||||
endif
|
||||
|
||||
case(psb_alsort_down_)
|
||||
|
||||
|
||||
if (n > ithrs) then
|
||||
!
|
||||
! Init stack pointer
|
||||
!
|
||||
istp = 1
|
||||
istack(1,istp) = 1
|
||||
istack(2,istp) = n
|
||||
|
||||
do
|
||||
if (istp <= 0) exit
|
||||
ilx = istack(1,istp)
|
||||
iux = istack(2,istp)
|
||||
istp = istp - 1
|
||||
!$$$ write(0,*) 'Debug 1: ',ilx,iux
|
||||
!
|
||||
! Choose a pivot with median-of-three heuristics, leave it
|
||||
! in the LPIV location
|
||||
!
|
||||
i = ilx
|
||||
j = iux
|
||||
lpiv = (i+j)/2
|
||||
piv = x(lpiv)
|
||||
if (piv > x(i)) then
|
||||
xt = x(i)
|
||||
x(i) = x(lpiv)
|
||||
x(lpiv) = xt
|
||||
piv = x(lpiv)
|
||||
endif
|
||||
if (piv < x(j)) then
|
||||
xt = x(j)
|
||||
x(j) = x(lpiv)
|
||||
x(lpiv) = xt
|
||||
piv = x(lpiv)
|
||||
endif
|
||||
if (piv > x(i)) then
|
||||
xt = x(i)
|
||||
x(i) = x(lpiv)
|
||||
x(lpiv) = xt
|
||||
piv = x(lpiv)
|
||||
endif
|
||||
!
|
||||
! now piv is correct; place it into first location
|
||||
|
||||
xt = x(i)
|
||||
x(i) = x(lpiv)
|
||||
x(lpiv) = xt
|
||||
|
||||
i = ilx - 1
|
||||
j = iux + 1
|
||||
|
||||
outer_dw: do
|
||||
in_dw1: do
|
||||
i = i + 1
|
||||
xk = x(i)
|
||||
if (xk <= piv) exit in_dw1
|
||||
end do in_dw1
|
||||
!
|
||||
! Ensure finite termination for next loop
|
||||
!
|
||||
xt = xk
|
||||
x(i) = piv
|
||||
in_dw2:do
|
||||
j = j - 1
|
||||
xk = x(j)
|
||||
if (xk >= piv) exit in_dw2
|
||||
end do in_dw2
|
||||
x(i) = xt
|
||||
|
||||
if (j > i) then
|
||||
xt = x(i)
|
||||
x(i) = x(j)
|
||||
x(j) = xt
|
||||
else
|
||||
exit outer_dw
|
||||
end if
|
||||
end do outer_dw
|
||||
if (i == ilx) then
|
||||
if (x(i) /= piv) then
|
||||
write(0,*) 'Should never ever get here????!!!!'
|
||||
stop
|
||||
endif
|
||||
i = i + 1
|
||||
endif
|
||||
|
||||
n1 = (i-1)-ilx+1
|
||||
n2 = iux-(i)+1
|
||||
if (n1 > n2) then
|
||||
if (n1 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = ilx
|
||||
istack(2,istp) = i-1
|
||||
else
|
||||
call izasr_dw(n1,x(ilx:i-1))
|
||||
endif
|
||||
if (n2 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = i
|
||||
istack(2,istp) = iux
|
||||
else
|
||||
call izasr_dw(n2,x(i:iux))
|
||||
endif
|
||||
else
|
||||
if (n2 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = i
|
||||
istack(2,istp) = iux
|
||||
else
|
||||
call izasr_dw(n2,x(i:iux))
|
||||
endif
|
||||
if (n1 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = ilx
|
||||
istack(2,istp) = i-1
|
||||
else
|
||||
call izasr_dw(n1,x(ilx:i-1))
|
||||
endif
|
||||
endif
|
||||
enddo
|
||||
else
|
||||
call izasr_dw(n,x)
|
||||
endif
|
||||
|
||||
case default
|
||||
write(0,*) 'isr error !',dir
|
||||
end select
|
||||
|
||||
|
||||
return
|
||||
|
||||
contains
|
||||
|
||||
subroutine izasr_up(n,x)
|
||||
use zacmp_mod
|
||||
implicit none
|
||||
integer :: n
|
||||
complex(kind(1.d0)) :: x(n)
|
||||
integer :: i,j
|
||||
complex(kind(1.d0)) :: xx
|
||||
|
||||
do j=n-1,1,-1
|
||||
if (x(j+1) < x(j)) then
|
||||
xx = x(j)
|
||||
i=j+1
|
||||
do
|
||||
x(i-1) = x(i)
|
||||
i = i+1
|
||||
if (i>n) exit
|
||||
if (x(i) >= xx) exit
|
||||
end do
|
||||
x(i-1) = xx
|
||||
endif
|
||||
enddo
|
||||
end subroutine izasr_up
|
||||
|
||||
subroutine izasr_dw(n,x)
|
||||
use zacmp_mod
|
||||
implicit none
|
||||
integer :: n
|
||||
complex(kind(1.d0)) :: x(n)
|
||||
integer :: i,j
|
||||
complex(kind(1.d0)) :: xx
|
||||
|
||||
do j=n-1,1,-1
|
||||
if (x(j+1) > x(j)) then
|
||||
xx = x(j)
|
||||
i=j+1
|
||||
do
|
||||
x(i-1) = x(i)
|
||||
i = i+1
|
||||
if (i>n) exit
|
||||
if (x(i) <= xx) exit
|
||||
end do
|
||||
x(i-1) = xx
|
||||
endif
|
||||
enddo
|
||||
end subroutine izasr_dw
|
||||
|
||||
end subroutine zasr
|
||||
@ -0,0 +1,413 @@
|
||||
!!$
|
||||
!!$ Parallel Sparse BLAS v2.0
|
||||
!!$ (C) Copyright 2006 Salvatore Filippone University of Rome Tor Vergata
|
||||
!!$ Alfredo Buttari University of Rome Tor Vergata
|
||||
!!$
|
||||
!!$ Redistribution and use in source and binary forms, with or without
|
||||
!!$ modification, are permitted provided that the following conditions
|
||||
!!$ are met:
|
||||
!!$ 1. Redistributions of source code must retain the above copyright
|
||||
!!$ notice, this list of conditions and the following disclaimer.
|
||||
!!$ 2. Redistributions in binary form must reproduce the above copyright
|
||||
!!$ notice, this list of conditions, and the following disclaimer in the
|
||||
!!$ documentation and/or other materials provided with the distribution.
|
||||
!!$ 3. The name of the PSBLAS group or the names of its contributors may
|
||||
!!$ not be used to endorse or promote products derived from this
|
||||
!!$ software without specific written permission.
|
||||
!!$
|
||||
!!$ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
!!$ ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
!!$ TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
!!$ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PSBLAS GROUP OR ITS CONTRIBUTORS
|
||||
!!$ BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
!!$ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
!!$ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
!!$ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
!!$ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
!!$ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
!!$ POSSIBILITY OF SUCH DAMAGE.
|
||||
!!$
|
||||
!!$
|
||||
subroutine zasrx(n,x,indx,dir,flag)
|
||||
use psb_serial_mod
|
||||
use zacmp_mod
|
||||
implicit none
|
||||
!
|
||||
! Quicksort with indices into original positions.
|
||||
! Adapted from a number of sources, including Don Knuth's TAOCP.
|
||||
!
|
||||
! .. Scalar Arguments ..
|
||||
integer, intent(in) :: n, dir, flag
|
||||
complex(kind(1.d0)) :: x(n)
|
||||
integer :: indx(n)
|
||||
! ..
|
||||
! .. Local Scalars ..
|
||||
complex(kind(1.d0)) :: xx, piv, xk, xt
|
||||
integer i, j, ii, ilx, iux, istp, lpiv
|
||||
integer ixt, n1, n2
|
||||
|
||||
integer, parameter :: maxstack=64,nparms=3,ithrs=16
|
||||
integer :: istack(nparms,maxstack)
|
||||
! ..
|
||||
|
||||
select case(flag)
|
||||
case(psb_sort_ovw_idx_)
|
||||
do i=1, n
|
||||
indx(i) = i
|
||||
enddo
|
||||
case(psb_sort_keep_idx_)
|
||||
! do nothing
|
||||
case default
|
||||
write(0,*) 'Error in isrx: invalid flag',flag
|
||||
end select
|
||||
!
|
||||
|
||||
!
|
||||
! small inputs will only get through insertion sort.
|
||||
!
|
||||
select case(dir)
|
||||
|
||||
case(psb_alsort_up_)
|
||||
|
||||
if (n > ithrs) then
|
||||
!
|
||||
! Init stack pointer
|
||||
!
|
||||
istp = 1
|
||||
istack(1,istp) = 1
|
||||
istack(2,istp) = n
|
||||
|
||||
do
|
||||
if (istp <= 0) exit
|
||||
ilx = istack(1,istp)
|
||||
iux = istack(2,istp)
|
||||
istp = istp - 1
|
||||
!$$$ write(0,*) 'Debug 1: ',ilx,iux
|
||||
!
|
||||
! Choose a pivot with median-of-three heuristics, leave it
|
||||
! in the LPIV location
|
||||
!
|
||||
i = ilx
|
||||
j = iux
|
||||
lpiv = (i+j)/2
|
||||
piv = x(lpiv)
|
||||
if (piv < x(i)) then
|
||||
xt = x(i)
|
||||
ixt = indx(i)
|
||||
x(i) = x(lpiv)
|
||||
indx(i) = indx(lpiv)
|
||||
x(lpiv) = xt
|
||||
indx(lpiv) = ixt
|
||||
piv = x(lpiv)
|
||||
endif
|
||||
if (piv > x(j)) then
|
||||
xt = x(j)
|
||||
ixt = indx(j)
|
||||
x(j) = x(lpiv)
|
||||
indx(j) = indx(lpiv)
|
||||
x(lpiv) = xt
|
||||
indx(lpiv) = ixt
|
||||
piv = x(lpiv)
|
||||
endif
|
||||
if (piv < x(i)) then
|
||||
xt = x(i)
|
||||
ixt = indx(i)
|
||||
x(i) = x(lpiv)
|
||||
indx(i) = indx(lpiv)
|
||||
x(lpiv) = xt
|
||||
indx(lpiv) = ixt
|
||||
piv = x(lpiv)
|
||||
endif
|
||||
!
|
||||
! now piv is correct; place it into first location
|
||||
xt = x(i)
|
||||
ixt = indx(i)
|
||||
x(i) = x(lpiv)
|
||||
indx(i) = indx(lpiv)
|
||||
x(lpiv) = xt
|
||||
indx(lpiv) = ixt
|
||||
piv = x(lpiv)
|
||||
|
||||
i = ilx - 1
|
||||
j = iux + 1
|
||||
|
||||
outer_up: do
|
||||
in_up1: do
|
||||
i = i + 1
|
||||
xk = x(i)
|
||||
if (xk >= piv) exit in_up1
|
||||
end do in_up1
|
||||
!
|
||||
! Ensure finite termination for next loop
|
||||
!
|
||||
xt = xk
|
||||
x(i) = piv
|
||||
in_up2:do
|
||||
j = j - 1
|
||||
xk = x(j)
|
||||
if (xk <= piv) exit in_up2
|
||||
end do in_up2
|
||||
x(i) = xt
|
||||
|
||||
if (j > i) then
|
||||
xt = x(i)
|
||||
ixt = indx(i)
|
||||
x(i) = x(j)
|
||||
indx(i) = indx(j)
|
||||
x(j) = xt
|
||||
indx(j) = ixt
|
||||
else
|
||||
exit outer_up
|
||||
end if
|
||||
end do outer_up
|
||||
if (i == ilx) then
|
||||
if (x(i) /= piv) then
|
||||
write(0,*) 'Should never ever get here????!!!!'
|
||||
stop
|
||||
endif
|
||||
i = i + 1
|
||||
endif
|
||||
|
||||
n1 = (i-1)-ilx+1
|
||||
n2 = iux-(i)+1
|
||||
if (n1 > n2) then
|
||||
if (n1 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = ilx
|
||||
istack(2,istp) = i-1
|
||||
else
|
||||
call izasrx_up(n1,x(ilx:i-1),indx(ilx:i-1))
|
||||
endif
|
||||
if (n2 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = i
|
||||
istack(2,istp) = iux
|
||||
else
|
||||
call izasrx_up(n2,x(i:iux),indx(i:iux))
|
||||
endif
|
||||
else
|
||||
if (n2 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = i
|
||||
istack(2,istp) = iux
|
||||
else
|
||||
call izasrx_up(n2,x(i:iux),indx(i:iux))
|
||||
endif
|
||||
if (n1 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = ilx
|
||||
istack(2,istp) = i-1
|
||||
else
|
||||
call izasrx_up(n1,x(ilx:i-1),indx(ilx:i-1))
|
||||
endif
|
||||
endif
|
||||
enddo
|
||||
else
|
||||
call izasrx_up(n,x,indx)
|
||||
endif
|
||||
|
||||
case(psb_alsort_down_)
|
||||
|
||||
|
||||
|
||||
if (n > ithrs) then
|
||||
!
|
||||
! Init stack pointer
|
||||
!
|
||||
istp = 1
|
||||
istack(1,istp) = 1
|
||||
istack(2,istp) = n
|
||||
|
||||
do
|
||||
if (istp <= 0) exit
|
||||
ilx = istack(1,istp)
|
||||
iux = istack(2,istp)
|
||||
istp = istp - 1
|
||||
!$$$ write(0,*) 'Debug 1: ',ilx,iux
|
||||
!
|
||||
! Choose a pivot with median-of-three heuristics, leave it
|
||||
! in the LPIV location
|
||||
!
|
||||
i = ilx
|
||||
j = iux
|
||||
lpiv = (i+j)/2
|
||||
piv = x(lpiv)
|
||||
if (piv > x(i)) then
|
||||
xt = x(i)
|
||||
ixt = indx(i)
|
||||
x(i) = x(lpiv)
|
||||
indx(i) = indx(lpiv)
|
||||
x(lpiv) = xt
|
||||
indx(lpiv) = ixt
|
||||
piv = x(lpiv)
|
||||
endif
|
||||
if (piv < x(j)) then
|
||||
xt = x(j)
|
||||
ixt = indx(j)
|
||||
x(j) = x(lpiv)
|
||||
indx(j) = indx(lpiv)
|
||||
x(lpiv) = xt
|
||||
indx(lpiv) = ixt
|
||||
piv = x(lpiv)
|
||||
endif
|
||||
if (piv > x(i)) then
|
||||
xt = x(i)
|
||||
ixt = indx(i)
|
||||
x(i) = x(lpiv)
|
||||
indx(i) = indx(lpiv)
|
||||
x(lpiv) = xt
|
||||
indx(lpiv) = ixt
|
||||
piv = x(lpiv)
|
||||
endif
|
||||
!
|
||||
! now piv is correct; place it into first location
|
||||
xt = x(i)
|
||||
ixt = indx(i)
|
||||
x(i) = x(lpiv)
|
||||
indx(i) = indx(lpiv)
|
||||
x(lpiv) = xt
|
||||
indx(lpiv) = ixt
|
||||
piv = x(lpiv)
|
||||
|
||||
i = ilx - 1
|
||||
j = iux + 1
|
||||
|
||||
outer_dw: do
|
||||
in_dw1: do
|
||||
i = i + 1
|
||||
xk = x(i)
|
||||
if (xk <= piv) exit in_dw1
|
||||
end do in_dw1
|
||||
!
|
||||
! Ensure finite termination for next loop
|
||||
!
|
||||
xt = xk
|
||||
x(i) = piv
|
||||
in_dw2:do
|
||||
j = j - 1
|
||||
xk = x(j)
|
||||
if (xk >= piv) exit in_dw2
|
||||
end do in_dw2
|
||||
x(i) = xt
|
||||
|
||||
if (j > i) then
|
||||
xt = x(i)
|
||||
ixt = indx(i)
|
||||
x(i) = x(j)
|
||||
indx(i) = indx(j)
|
||||
x(j) = xt
|
||||
indx(j) = ixt
|
||||
else
|
||||
exit outer_dw
|
||||
end if
|
||||
end do outer_dw
|
||||
if (i == ilx) then
|
||||
if (x(i) /= piv) then
|
||||
write(0,*) 'Should never ever get here????!!!!'
|
||||
stop
|
||||
endif
|
||||
i = i + 1
|
||||
endif
|
||||
|
||||
n1 = (i-1)-ilx+1
|
||||
n2 = iux-(i)+1
|
||||
if (n1 > n2) then
|
||||
if (n1 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = ilx
|
||||
istack(2,istp) = i-1
|
||||
else
|
||||
call izasrx_dw(n1,x(ilx:i-1),indx(ilx:i-1))
|
||||
endif
|
||||
if (n2 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = i
|
||||
istack(2,istp) = iux
|
||||
else
|
||||
call izasrx_dw(n2,x(i:iux),indx(i:iux))
|
||||
endif
|
||||
else
|
||||
if (n2 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = i
|
||||
istack(2,istp) = iux
|
||||
else
|
||||
call izasrx_dw(n2,x(i:iux),indx(i:iux))
|
||||
endif
|
||||
if (n1 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = ilx
|
||||
istack(2,istp) = i-1
|
||||
else
|
||||
call izasrx_dw(n1,x(ilx:i-1),indx(ilx:i-1))
|
||||
endif
|
||||
endif
|
||||
enddo
|
||||
else
|
||||
call izasrx_dw(n,x,indx)
|
||||
endif
|
||||
|
||||
case default
|
||||
write(0,*) 'isrx error dir ',dir
|
||||
end select
|
||||
|
||||
|
||||
return
|
||||
|
||||
contains
|
||||
|
||||
subroutine izasrx_up(n,x,indx)
|
||||
use zacmp_mod
|
||||
implicit none
|
||||
integer :: n
|
||||
complex(kind(1.d0)) :: x(n)
|
||||
integer :: indx(n)
|
||||
integer :: i,j,ix
|
||||
complex(kind(1.d0)) :: xx
|
||||
|
||||
do j=n-1,1,-1
|
||||
if (x(j+1) < x(j)) then
|
||||
xx = x(j)
|
||||
ix = indx(j)
|
||||
i=j+1
|
||||
do
|
||||
x(i-1) = x(i)
|
||||
indx(i-1) = indx(i)
|
||||
i = i+1
|
||||
if (i>n) exit
|
||||
if (x(i) >= xx) exit
|
||||
end do
|
||||
x(i-1) = xx
|
||||
indx(i-1) = ix
|
||||
endif
|
||||
enddo
|
||||
end subroutine izasrx_up
|
||||
|
||||
subroutine izasrx_dw(n,x,indx)
|
||||
use zacmp_mod
|
||||
implicit none
|
||||
integer :: n
|
||||
complex(kind(1.d0)) :: x(n)
|
||||
integer :: indx(n)
|
||||
integer :: i,j,ix
|
||||
complex(kind(1.d0)) :: xx
|
||||
|
||||
do j=n-1,1,-1
|
||||
if (x(j+1) > x(j)) then
|
||||
xx = x(j)
|
||||
ix = indx(j)
|
||||
i=j+1
|
||||
do
|
||||
x(i-1) = x(i)
|
||||
indx(i-1) = indx(i)
|
||||
i = i+1
|
||||
if (i>n) exit
|
||||
if (x(i) <= xx) exit
|
||||
end do
|
||||
x(i-1) = xx
|
||||
indx(i-1) = ix
|
||||
endif
|
||||
enddo
|
||||
end subroutine izasrx_dw
|
||||
|
||||
end subroutine zasrx
|
||||
@ -0,0 +1,44 @@
|
||||
module zlcmp_mod
|
||||
interface operator(<)
|
||||
module procedure zllt
|
||||
end interface
|
||||
interface operator(<=)
|
||||
module procedure zlle
|
||||
end interface
|
||||
interface operator(>)
|
||||
module procedure zlgt
|
||||
end interface
|
||||
interface operator(>=)
|
||||
module procedure zlge
|
||||
end interface
|
||||
|
||||
contains
|
||||
|
||||
function zllt(a,b)
|
||||
complex(kind(1.d0)), intent(in) :: a,b
|
||||
logical :: zllt
|
||||
|
||||
zllt = (real(a)<real(b)).or.((real(a)==real(b)).and.(aimag(a)<aimag(b)))
|
||||
end function zllt
|
||||
function zlle(a,b)
|
||||
complex(kind(1.d0)), intent(in) :: a,b
|
||||
logical :: zlle
|
||||
|
||||
zlle = (real(a)<real(b)).or.((real(a)==real(b)).and.(aimag(a)<=aimag(b)))
|
||||
end function zlle
|
||||
|
||||
function zlgt(a,b)
|
||||
complex(kind(1.d0)), intent(in) :: a,b
|
||||
logical :: zlgt
|
||||
|
||||
zlgt = (real(a)>real(b)).or.((real(a)==real(b)).and.(aimag(a)>aimag(b)))
|
||||
end function zlgt
|
||||
function zlge(a,b)
|
||||
complex(kind(1.d0)), intent(in) :: a,b
|
||||
logical :: zlge
|
||||
|
||||
zlge = (real(a)>real(b)).or.((real(a)==real(b)).and.(aimag(a)>=aimag(b)))
|
||||
end function zlge
|
||||
|
||||
end module zlcmp_mod
|
||||
|
||||
@ -0,0 +1,362 @@
|
||||
!!$
|
||||
!!$ Parallel Sparse BLAS v2.0
|
||||
!!$ (C) Copyright 2006 Salvatore Filippone University of Rome Tor Vergata
|
||||
!!$ Alfredo Buttari University of Rome Tor Vergata
|
||||
!!$
|
||||
!!$ Redistribution and use in source and binary forms, with or without
|
||||
!!$ modification, are permitted provided that the following conditions
|
||||
!!$ are met:
|
||||
!!$ 1. Redistributions of source code must retain the above copyright
|
||||
!!$ notice, this list of conditions and the following disclaimer.
|
||||
!!$ 2. Redistributions in binary form must reproduce the above copyright
|
||||
!!$ notice, this list of conditions, and the following disclaimer in the
|
||||
!!$ documentation and/or other materials provided with the distribution.
|
||||
!!$ 3. The name of the PSBLAS group or the names of its contributors may
|
||||
!!$ not be used to endorse or promote products derived from this
|
||||
!!$ software without specific written permission.
|
||||
!!$
|
||||
!!$ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
!!$ ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
!!$ TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
!!$ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PSBLAS GROUP OR ITS CONTRIBUTORS
|
||||
!!$ BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
!!$ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
!!$ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
!!$ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
!!$ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
!!$ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
!!$ POSSIBILITY OF SUCH DAMAGE.
|
||||
!!$
|
||||
!!$
|
||||
|
||||
subroutine zlsr(n,x,dir)
|
||||
use psb_serial_mod
|
||||
use zlcmp_mod
|
||||
implicit none
|
||||
!
|
||||
! Quicksort on lexicographic comparison of complex numbers.
|
||||
! Adapted from a number of sources, including Don Knuth's TAOCP.
|
||||
!
|
||||
! .. Scalar Arguments ..
|
||||
integer, intent(in) :: n, dir
|
||||
complex(kind(1.d0)) :: x(n)
|
||||
! ..
|
||||
! .. Local Scalars ..
|
||||
complex(kind(1.d0)) :: xx, xk, piv, xt
|
||||
integer i, j, ilx, iux, istp, lpiv
|
||||
integer n1, n2
|
||||
|
||||
integer, parameter :: maxstack=64,nparms=3,ithrs=16
|
||||
integer :: istack(nparms,maxstack)
|
||||
! ..
|
||||
|
||||
!
|
||||
! small inputs will only get through insertion sort.
|
||||
!
|
||||
select case(dir)
|
||||
|
||||
case(psb_lsort_up_)
|
||||
|
||||
if (n > ithrs) then
|
||||
!
|
||||
! Init stack pointer
|
||||
!
|
||||
istp = 1
|
||||
istack(1,istp) = 1
|
||||
istack(2,istp) = n
|
||||
|
||||
do
|
||||
if (istp <= 0) exit
|
||||
ilx = istack(1,istp)
|
||||
iux = istack(2,istp)
|
||||
istp = istp - 1
|
||||
!$$$ write(0,*) 'Debug 1: ',ilx,iux
|
||||
!
|
||||
! Choose a pivot with median-of-three heuristics, leave it
|
||||
! in the LPIV location
|
||||
!
|
||||
i = ilx
|
||||
j = iux
|
||||
lpiv = (i+j)/2
|
||||
piv = x(lpiv)
|
||||
if (piv < x(i)) then
|
||||
xt = x(i)
|
||||
x(i) = x(lpiv)
|
||||
x(lpiv) = xt
|
||||
piv = x(lpiv)
|
||||
endif
|
||||
if (piv > x(j)) then
|
||||
xt = x(j)
|
||||
x(j) = x(lpiv)
|
||||
x(lpiv) = xt
|
||||
piv = x(lpiv)
|
||||
endif
|
||||
if (piv < x(i)) then
|
||||
xt = x(i)
|
||||
x(i) = x(lpiv)
|
||||
x(lpiv) = xt
|
||||
piv = x(lpiv)
|
||||
endif
|
||||
!
|
||||
! now piv is correct; place it into first location
|
||||
|
||||
xt = x(i)
|
||||
x(i) = x(lpiv)
|
||||
x(lpiv) = xt
|
||||
|
||||
i = ilx - 1
|
||||
j = iux + 1
|
||||
|
||||
outer_up: do
|
||||
in_up1: do
|
||||
i = i + 1
|
||||
xk = x(i)
|
||||
if (xk >= piv) exit in_up1
|
||||
end do in_up1
|
||||
!
|
||||
! Ensure finite termination for next loop
|
||||
!
|
||||
xt = xk
|
||||
x(i) = piv
|
||||
in_up2:do
|
||||
j = j - 1
|
||||
xk = x(j)
|
||||
if (xk <= piv) exit in_up2
|
||||
end do in_up2
|
||||
x(i) = xt
|
||||
|
||||
if (j > i) then
|
||||
xt = x(i)
|
||||
x(i) = x(j)
|
||||
x(j) = xt
|
||||
else
|
||||
exit outer_up
|
||||
end if
|
||||
end do outer_up
|
||||
if (i == ilx) then
|
||||
if (x(i) /= piv) then
|
||||
write(0,*) 'Should never ever get here????!!!!'
|
||||
stop
|
||||
endif
|
||||
i = i + 1
|
||||
endif
|
||||
|
||||
n1 = (i-1)-ilx+1
|
||||
n2 = iux-(i)+1
|
||||
if (n1 > n2) then
|
||||
if (n1 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = ilx
|
||||
istack(2,istp) = i-1
|
||||
else
|
||||
call izlsr_up(n1,x(ilx:i-1))
|
||||
endif
|
||||
if (n2 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = i
|
||||
istack(2,istp) = iux
|
||||
else
|
||||
call izlsr_up(n2,x(i:iux))
|
||||
endif
|
||||
else
|
||||
if (n2 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = i
|
||||
istack(2,istp) = iux
|
||||
else
|
||||
call izlsr_up(n2,x(i:iux))
|
||||
endif
|
||||
if (n1 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = ilx
|
||||
istack(2,istp) = i-1
|
||||
else
|
||||
call izlsr_up(n1,x(ilx:i-1))
|
||||
endif
|
||||
endif
|
||||
enddo
|
||||
else
|
||||
call izlsr_up(n,x)
|
||||
endif
|
||||
|
||||
case(psb_lsort_down_)
|
||||
|
||||
|
||||
if (n > ithrs) then
|
||||
!
|
||||
! Init stack pointer
|
||||
!
|
||||
istp = 1
|
||||
istack(1,istp) = 1
|
||||
istack(2,istp) = n
|
||||
|
||||
do
|
||||
if (istp <= 0) exit
|
||||
ilx = istack(1,istp)
|
||||
iux = istack(2,istp)
|
||||
istp = istp - 1
|
||||
!$$$ write(0,*) 'Debug 1: ',ilx,iux
|
||||
!
|
||||
! Choose a pivot with median-of-three heuristics, leave it
|
||||
! in the LPIV location
|
||||
!
|
||||
i = ilx
|
||||
j = iux
|
||||
lpiv = (i+j)/2
|
||||
piv = x(lpiv)
|
||||
if (piv > x(i)) then
|
||||
xt = x(i)
|
||||
x(i) = x(lpiv)
|
||||
x(lpiv) = xt
|
||||
piv = x(lpiv)
|
||||
endif
|
||||
if (piv < x(j)) then
|
||||
xt = x(j)
|
||||
x(j) = x(lpiv)
|
||||
x(lpiv) = xt
|
||||
piv = x(lpiv)
|
||||
endif
|
||||
if (piv > x(i)) then
|
||||
xt = x(i)
|
||||
x(i) = x(lpiv)
|
||||
x(lpiv) = xt
|
||||
piv = x(lpiv)
|
||||
endif
|
||||
!
|
||||
! now piv is correct; place it into first location
|
||||
|
||||
xt = x(i)
|
||||
x(i) = x(lpiv)
|
||||
x(lpiv) = xt
|
||||
|
||||
i = ilx - 1
|
||||
j = iux + 1
|
||||
|
||||
outer_dw: do
|
||||
in_dw1: do
|
||||
i = i + 1
|
||||
xk = x(i)
|
||||
if (xk <= piv) exit in_dw1
|
||||
end do in_dw1
|
||||
!
|
||||
! Ensure finite termination for next loop
|
||||
!
|
||||
xt = xk
|
||||
x(i) = piv
|
||||
in_dw2:do
|
||||
j = j - 1
|
||||
xk = x(j)
|
||||
if (xk >= piv) exit in_dw2
|
||||
end do in_dw2
|
||||
x(i) = xt
|
||||
|
||||
if (j > i) then
|
||||
xt = x(i)
|
||||
x(i) = x(j)
|
||||
x(j) = xt
|
||||
else
|
||||
exit outer_dw
|
||||
end if
|
||||
end do outer_dw
|
||||
if (i == ilx) then
|
||||
if (x(i) /= piv) then
|
||||
write(0,*) 'Should never ever get here????!!!!'
|
||||
stop
|
||||
endif
|
||||
i = i + 1
|
||||
endif
|
||||
|
||||
n1 = (i-1)-ilx+1
|
||||
n2 = iux-(i)+1
|
||||
if (n1 > n2) then
|
||||
if (n1 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = ilx
|
||||
istack(2,istp) = i-1
|
||||
else
|
||||
call izlsr_dw(n1,x(ilx:i-1))
|
||||
endif
|
||||
if (n2 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = i
|
||||
istack(2,istp) = iux
|
||||
else
|
||||
call izlsr_dw(n2,x(i:iux))
|
||||
endif
|
||||
else
|
||||
if (n2 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = i
|
||||
istack(2,istp) = iux
|
||||
else
|
||||
call izlsr_dw(n2,x(i:iux))
|
||||
endif
|
||||
if (n1 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = ilx
|
||||
istack(2,istp) = i-1
|
||||
else
|
||||
call izlsr_dw(n1,x(ilx:i-1))
|
||||
endif
|
||||
endif
|
||||
enddo
|
||||
else
|
||||
call izlsr_dw(n,x)
|
||||
endif
|
||||
|
||||
case default
|
||||
write(0,*) 'isr error !',dir
|
||||
end select
|
||||
|
||||
|
||||
return
|
||||
|
||||
contains
|
||||
|
||||
subroutine izlsr_up(n,x)
|
||||
use zlcmp_mod
|
||||
implicit none
|
||||
integer :: n
|
||||
complex(kind(1.d0)) :: x(n)
|
||||
integer :: i,j
|
||||
complex(kind(1.d0)) :: xx
|
||||
|
||||
do j=n-1,1,-1
|
||||
if (x(j+1) < x(j)) then
|
||||
xx = x(j)
|
||||
i=j+1
|
||||
do
|
||||
x(i-1) = x(i)
|
||||
i = i+1
|
||||
if (i>n) exit
|
||||
if (x(i) >= xx) exit
|
||||
end do
|
||||
x(i-1) = xx
|
||||
endif
|
||||
enddo
|
||||
end subroutine izlsr_up
|
||||
|
||||
subroutine izlsr_dw(n,x)
|
||||
use zlcmp_mod
|
||||
implicit none
|
||||
integer :: n
|
||||
complex(kind(1.d0)) :: x(n)
|
||||
integer :: i,j
|
||||
complex(kind(1.d0)) :: xx
|
||||
|
||||
do j=n-1,1,-1
|
||||
if (x(j+1) > x(j)) then
|
||||
xx = x(j)
|
||||
i=j+1
|
||||
do
|
||||
x(i-1) = x(i)
|
||||
i = i+1
|
||||
if (i>n) exit
|
||||
if (x(i) <= xx) exit
|
||||
end do
|
||||
x(i-1) = xx
|
||||
endif
|
||||
enddo
|
||||
end subroutine izlsr_dw
|
||||
|
||||
end subroutine zlsr
|
||||
@ -0,0 +1,413 @@
|
||||
!!$
|
||||
!!$ Parallel Sparse BLAS v2.0
|
||||
!!$ (C) Copyright 2006 Salvatore Filippone University of Rome Tor Vergata
|
||||
!!$ Alfredo Buttari University of Rome Tor Vergata
|
||||
!!$
|
||||
!!$ Redistribution and use in source and binary forms, with or without
|
||||
!!$ modification, are permitted provided that the following conditions
|
||||
!!$ are met:
|
||||
!!$ 1. Redistributions of source code must retain the above copyright
|
||||
!!$ notice, this list of conditions and the following disclaimer.
|
||||
!!$ 2. Redistributions in binary form must reproduce the above copyright
|
||||
!!$ notice, this list of conditions, and the following disclaimer in the
|
||||
!!$ documentation and/or other materials provided with the distribution.
|
||||
!!$ 3. The name of the PSBLAS group or the names of its contributors may
|
||||
!!$ not be used to endorse or promote products derived from this
|
||||
!!$ software without specific written permission.
|
||||
!!$
|
||||
!!$ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
!!$ ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
!!$ TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
!!$ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PSBLAS GROUP OR ITS CONTRIBUTORS
|
||||
!!$ BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
!!$ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
!!$ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
!!$ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
!!$ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
!!$ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
!!$ POSSIBILITY OF SUCH DAMAGE.
|
||||
!!$
|
||||
!!$
|
||||
subroutine zlsrx(n,x,indx,dir,flag)
|
||||
use psb_serial_mod
|
||||
use zlcmp_mod
|
||||
implicit none
|
||||
!
|
||||
! Quicksort with indices into original positions.
|
||||
! Adapted from a number of sources, including Don Knuth's TAOCP.
|
||||
!
|
||||
! .. Scalar Arguments ..
|
||||
integer, intent(in) :: n, dir, flag
|
||||
complex(kind(1.d0)) :: x(n)
|
||||
integer :: indx(n)
|
||||
! ..
|
||||
! .. Local Scalars ..
|
||||
complex(kind(1.d0)) :: xx, piv, xk, xt
|
||||
integer i, j, ii, ilx, iux, istp, lpiv
|
||||
integer ixt, n1, n2
|
||||
|
||||
integer, parameter :: maxstack=64,nparms=3,ithrs=16
|
||||
integer :: istack(nparms,maxstack)
|
||||
! ..
|
||||
|
||||
select case(flag)
|
||||
case(psb_sort_ovw_idx_)
|
||||
do i=1, n
|
||||
indx(i) = i
|
||||
enddo
|
||||
case(psb_sort_keep_idx_)
|
||||
! do nothing
|
||||
case default
|
||||
write(0,*) 'Error in isrx: invalid flag',flag
|
||||
end select
|
||||
!
|
||||
|
||||
!
|
||||
! small inputs will only get through insertion sort.
|
||||
!
|
||||
select case(dir)
|
||||
|
||||
case(psb_lsort_up_)
|
||||
|
||||
if (n > ithrs) then
|
||||
!
|
||||
! Init stack pointer
|
||||
!
|
||||
istp = 1
|
||||
istack(1,istp) = 1
|
||||
istack(2,istp) = n
|
||||
|
||||
do
|
||||
if (istp <= 0) exit
|
||||
ilx = istack(1,istp)
|
||||
iux = istack(2,istp)
|
||||
istp = istp - 1
|
||||
!$$$ write(0,*) 'Debug 1: ',ilx,iux
|
||||
!
|
||||
! Choose a pivot with median-of-three heuristics, leave it
|
||||
! in the LPIV location
|
||||
!
|
||||
i = ilx
|
||||
j = iux
|
||||
lpiv = (i+j)/2
|
||||
piv = x(lpiv)
|
||||
if (piv < x(i)) then
|
||||
xt = x(i)
|
||||
ixt = indx(i)
|
||||
x(i) = x(lpiv)
|
||||
indx(i) = indx(lpiv)
|
||||
x(lpiv) = xt
|
||||
indx(lpiv) = ixt
|
||||
piv = x(lpiv)
|
||||
endif
|
||||
if (piv > x(j)) then
|
||||
xt = x(j)
|
||||
ixt = indx(j)
|
||||
x(j) = x(lpiv)
|
||||
indx(j) = indx(lpiv)
|
||||
x(lpiv) = xt
|
||||
indx(lpiv) = ixt
|
||||
piv = x(lpiv)
|
||||
endif
|
||||
if (piv < x(i)) then
|
||||
xt = x(i)
|
||||
ixt = indx(i)
|
||||
x(i) = x(lpiv)
|
||||
indx(i) = indx(lpiv)
|
||||
x(lpiv) = xt
|
||||
indx(lpiv) = ixt
|
||||
piv = x(lpiv)
|
||||
endif
|
||||
!
|
||||
! now piv is correct; place it into first location
|
||||
xt = x(i)
|
||||
ixt = indx(i)
|
||||
x(i) = x(lpiv)
|
||||
indx(i) = indx(lpiv)
|
||||
x(lpiv) = xt
|
||||
indx(lpiv) = ixt
|
||||
piv = x(lpiv)
|
||||
|
||||
i = ilx - 1
|
||||
j = iux + 1
|
||||
|
||||
outer_up: do
|
||||
in_up1: do
|
||||
i = i + 1
|
||||
xk = x(i)
|
||||
if (xk >= piv) exit in_up1
|
||||
end do in_up1
|
||||
!
|
||||
! Ensure finite termination for next loop
|
||||
!
|
||||
xt = xk
|
||||
x(i) = piv
|
||||
in_up2:do
|
||||
j = j - 1
|
||||
xk = x(j)
|
||||
if (xk <= piv) exit in_up2
|
||||
end do in_up2
|
||||
x(i) = xt
|
||||
|
||||
if (j > i) then
|
||||
xt = x(i)
|
||||
ixt = indx(i)
|
||||
x(i) = x(j)
|
||||
indx(i) = indx(j)
|
||||
x(j) = xt
|
||||
indx(j) = ixt
|
||||
else
|
||||
exit outer_up
|
||||
end if
|
||||
end do outer_up
|
||||
if (i == ilx) then
|
||||
if (x(i) /= piv) then
|
||||
write(0,*) 'Should never ever get here????!!!!'
|
||||
stop
|
||||
endif
|
||||
i = i + 1
|
||||
endif
|
||||
|
||||
n1 = (i-1)-ilx+1
|
||||
n2 = iux-(i)+1
|
||||
if (n1 > n2) then
|
||||
if (n1 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = ilx
|
||||
istack(2,istp) = i-1
|
||||
else
|
||||
call izlsrx_up(n1,x(ilx:i-1),indx(ilx:i-1))
|
||||
endif
|
||||
if (n2 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = i
|
||||
istack(2,istp) = iux
|
||||
else
|
||||
call izlsrx_up(n2,x(i:iux),indx(i:iux))
|
||||
endif
|
||||
else
|
||||
if (n2 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = i
|
||||
istack(2,istp) = iux
|
||||
else
|
||||
call izlsrx_up(n2,x(i:iux),indx(i:iux))
|
||||
endif
|
||||
if (n1 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = ilx
|
||||
istack(2,istp) = i-1
|
||||
else
|
||||
call izlsrx_up(n1,x(ilx:i-1),indx(ilx:i-1))
|
||||
endif
|
||||
endif
|
||||
enddo
|
||||
else
|
||||
call izlsrx_up(n,x,indx)
|
||||
endif
|
||||
|
||||
case(psb_lsort_down_)
|
||||
|
||||
|
||||
|
||||
if (n > ithrs) then
|
||||
!
|
||||
! Init stack pointer
|
||||
!
|
||||
istp = 1
|
||||
istack(1,istp) = 1
|
||||
istack(2,istp) = n
|
||||
|
||||
do
|
||||
if (istp <= 0) exit
|
||||
ilx = istack(1,istp)
|
||||
iux = istack(2,istp)
|
||||
istp = istp - 1
|
||||
!$$$ write(0,*) 'Debug 1: ',ilx,iux
|
||||
!
|
||||
! Choose a pivot with median-of-three heuristics, leave it
|
||||
! in the LPIV location
|
||||
!
|
||||
i = ilx
|
||||
j = iux
|
||||
lpiv = (i+j)/2
|
||||
piv = x(lpiv)
|
||||
if (piv > x(i)) then
|
||||
xt = x(i)
|
||||
ixt = indx(i)
|
||||
x(i) = x(lpiv)
|
||||
indx(i) = indx(lpiv)
|
||||
x(lpiv) = xt
|
||||
indx(lpiv) = ixt
|
||||
piv = x(lpiv)
|
||||
endif
|
||||
if (piv < x(j)) then
|
||||
xt = x(j)
|
||||
ixt = indx(j)
|
||||
x(j) = x(lpiv)
|
||||
indx(j) = indx(lpiv)
|
||||
x(lpiv) = xt
|
||||
indx(lpiv) = ixt
|
||||
piv = x(lpiv)
|
||||
endif
|
||||
if (piv > x(i)) then
|
||||
xt = x(i)
|
||||
ixt = indx(i)
|
||||
x(i) = x(lpiv)
|
||||
indx(i) = indx(lpiv)
|
||||
x(lpiv) = xt
|
||||
indx(lpiv) = ixt
|
||||
piv = x(lpiv)
|
||||
endif
|
||||
!
|
||||
! now piv is correct; place it into first location
|
||||
xt = x(i)
|
||||
ixt = indx(i)
|
||||
x(i) = x(lpiv)
|
||||
indx(i) = indx(lpiv)
|
||||
x(lpiv) = xt
|
||||
indx(lpiv) = ixt
|
||||
piv = x(lpiv)
|
||||
|
||||
i = ilx - 1
|
||||
j = iux + 1
|
||||
|
||||
outer_dw: do
|
||||
in_dw1: do
|
||||
i = i + 1
|
||||
xk = x(i)
|
||||
if (xk <= piv) exit in_dw1
|
||||
end do in_dw1
|
||||
!
|
||||
! Ensure finite termination for next loop
|
||||
!
|
||||
xt = xk
|
||||
x(i) = piv
|
||||
in_dw2:do
|
||||
j = j - 1
|
||||
xk = x(j)
|
||||
if (xk >= piv) exit in_dw2
|
||||
end do in_dw2
|
||||
x(i) = xt
|
||||
|
||||
if (j > i) then
|
||||
xt = x(i)
|
||||
ixt = indx(i)
|
||||
x(i) = x(j)
|
||||
indx(i) = indx(j)
|
||||
x(j) = xt
|
||||
indx(j) = ixt
|
||||
else
|
||||
exit outer_dw
|
||||
end if
|
||||
end do outer_dw
|
||||
if (i == ilx) then
|
||||
if (x(i) /= piv) then
|
||||
write(0,*) 'Should never ever get here????!!!!'
|
||||
stop
|
||||
endif
|
||||
i = i + 1
|
||||
endif
|
||||
|
||||
n1 = (i-1)-ilx+1
|
||||
n2 = iux-(i)+1
|
||||
if (n1 > n2) then
|
||||
if (n1 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = ilx
|
||||
istack(2,istp) = i-1
|
||||
else
|
||||
call izlsrx_dw(n1,x(ilx:i-1),indx(ilx:i-1))
|
||||
endif
|
||||
if (n2 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = i
|
||||
istack(2,istp) = iux
|
||||
else
|
||||
call izlsrx_dw(n2,x(i:iux),indx(i:iux))
|
||||
endif
|
||||
else
|
||||
if (n2 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = i
|
||||
istack(2,istp) = iux
|
||||
else
|
||||
call izlsrx_dw(n2,x(i:iux),indx(i:iux))
|
||||
endif
|
||||
if (n1 > ithrs) then
|
||||
istp = istp + 1
|
||||
istack(1,istp) = ilx
|
||||
istack(2,istp) = i-1
|
||||
else
|
||||
call izlsrx_dw(n1,x(ilx:i-1),indx(ilx:i-1))
|
||||
endif
|
||||
endif
|
||||
enddo
|
||||
else
|
||||
call izlsrx_dw(n,x,indx)
|
||||
endif
|
||||
|
||||
case default
|
||||
write(0,*) 'isrx error dir ',dir
|
||||
end select
|
||||
|
||||
|
||||
return
|
||||
|
||||
contains
|
||||
|
||||
subroutine izlsrx_up(n,x,indx)
|
||||
use zlcmp_mod
|
||||
implicit none
|
||||
integer :: n
|
||||
complex(kind(1.d0)) :: x(n)
|
||||
integer :: indx(n)
|
||||
integer :: i,j,ix
|
||||
complex(kind(1.d0)) :: xx
|
||||
|
||||
do j=n-1,1,-1
|
||||
if (x(j+1) < x(j)) then
|
||||
xx = x(j)
|
||||
ix = indx(j)
|
||||
i=j+1
|
||||
do
|
||||
x(i-1) = x(i)
|
||||
indx(i-1) = indx(i)
|
||||
i = i+1
|
||||
if (i>n) exit
|
||||
if (x(i) >= xx) exit
|
||||
end do
|
||||
x(i-1) = xx
|
||||
indx(i-1) = ix
|
||||
endif
|
||||
enddo
|
||||
end subroutine izlsrx_up
|
||||
|
||||
subroutine izlsrx_dw(n,x,indx)
|
||||
use zlcmp_mod
|
||||
implicit none
|
||||
integer :: n
|
||||
complex(kind(1.d0)) :: x(n)
|
||||
integer :: indx(n)
|
||||
integer :: i,j,ix
|
||||
complex(kind(1.d0)) :: xx
|
||||
|
||||
do j=n-1,1,-1
|
||||
if (x(j+1) > x(j)) then
|
||||
xx = x(j)
|
||||
ix = indx(j)
|
||||
i=j+1
|
||||
do
|
||||
x(i-1) = x(i)
|
||||
indx(i-1) = indx(i)
|
||||
i = i+1
|
||||
if (i>n) exit
|
||||
if (x(i) <= xx) exit
|
||||
end do
|
||||
x(i-1) = xx
|
||||
indx(i-1) = ix
|
||||
endif
|
||||
enddo
|
||||
end subroutine izlsrx_dw
|
||||
|
||||
end subroutine zlsrx
|
||||
@ -1,515 +0,0 @@
|
||||
!!$
|
||||
!!$ Parallel Sparse BLAS v2.0
|
||||
!!$ (C) Copyright 2006 Salvatore Filippone University of Rome Tor Vergata
|
||||
!!$ Alfredo Buttari University of Rome Tor Vergata
|
||||
!!$
|
||||
!!$ Redistribution and use in source and binary forms, with or without
|
||||
!!$ modification, are permitted provided that the following conditions
|
||||
!!$ are met:
|
||||
!!$ 1. Redistributions of source code must retain the above copyright
|
||||
!!$ notice, this list of conditions and the following disclaimer.
|
||||
!!$ 2. Redistributions in binary form must reproduce the above copyright
|
||||
!!$ notice, this list of conditions, and the following disclaimer in the
|
||||
!!$ documentation and/or other materials provided with the distribution.
|
||||
!!$ 3. The name of the PSBLAS group or the names of its contributors may
|
||||
!!$ not be used to endorse or promote products derived from this
|
||||
!!$ software without specific written permission.
|
||||
!!$
|
||||
!!$ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
!!$ ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
!!$ TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
!!$ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PSBLAS GROUP OR ITS CONTRIBUTORS
|
||||
!!$ BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
!!$ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
!!$ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
!!$ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
!!$ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
!!$ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
!!$ POSSIBILITY OF SUCH DAMAGE.
|
||||
!!$
|
||||
!!$
|
||||
! File: psb_dcsdp.f90
|
||||
!
|
||||
! Subroutine: psb_dcsdp
|
||||
! This subroutine performs the assembly of
|
||||
! the local part of a sparse distributed matrix
|
||||
!
|
||||
! Parameters:
|
||||
! a - type(<psb_spmat_type>). The input matrix to be assembled.
|
||||
! b - type(<psb_spmat_type>). The assembled output matrix.
|
||||
! info - integer. Eventually returns an error code.
|
||||
! ifc - integer(optional). ???
|
||||
! check - character(optional). ???
|
||||
! trans - character(optional). ???
|
||||
! unitd - character(optional). ???
|
||||
!
|
||||
subroutine psb_dcsdp(a, b,info,ifc,check,trans,unitd,upd,dupl)
|
||||
use psb_const_mod
|
||||
use psb_error_mod
|
||||
use psb_spmat_type
|
||||
use psb_string_mod
|
||||
use psb_serial_mod, psb_protect_name => psb_dcsdp
|
||||
implicit none
|
||||
!....Parameters...
|
||||
Type(psb_dspmat_type), intent(in) :: A
|
||||
Type(psb_dspmat_type), intent(inout) :: B
|
||||
Integer, intent(out) :: info
|
||||
Integer, intent(in), optional :: ifc,upd,dupl
|
||||
character, intent(in), optional :: check,trans,unitd
|
||||
|
||||
!...Locals...
|
||||
real(kind(1.d0)) :: d(1)
|
||||
real(kind(1.d0)), allocatable :: work(:)
|
||||
type(psb_dspmat_type) :: temp_a
|
||||
Integer :: nzr, ntry, ifc_, ia1_size,&
|
||||
& ia2_size, aspk_size,size_req,n_row,n_col,upd_,dupl_
|
||||
integer :: ip1, ip2, nnz, iflag, ichk, nnzt,&
|
||||
& ipc, i, count, err_act, i1, i2, ia
|
||||
character :: check_,trans_,unitd_
|
||||
Integer, Parameter :: maxtry=8
|
||||
logical, parameter :: debug=.false.
|
||||
character(len=20) :: name, ch_err
|
||||
|
||||
name='psb_csdp'
|
||||
info = 0
|
||||
call psb_erractionsave(err_act)
|
||||
|
||||
ntry=0
|
||||
if (present(ifc)) then
|
||||
ifc_ = max(1,ifc)
|
||||
else
|
||||
ifc_ = 1
|
||||
endif
|
||||
if (present(check)) then
|
||||
check_ = toupper(check)
|
||||
else
|
||||
check_ = 'N'
|
||||
endif
|
||||
if (present(trans)) then
|
||||
trans_ = toupper(trans)
|
||||
else
|
||||
trans_ = 'N'
|
||||
endif
|
||||
if (present(unitd)) then
|
||||
unitd_ = toupper(unitd)
|
||||
else
|
||||
unitd_ = 'U'
|
||||
endif
|
||||
|
||||
|
||||
if (check_=='R') then
|
||||
allocate(work(max(size(a%aspk),size(b%aspk))+1000),stat=info)
|
||||
else
|
||||
allocate(work(max(size(a%ia1),size(a%ia2))+max(a%m,b%m)+1000),stat=info)
|
||||
endif
|
||||
|
||||
if (info /= 0) then
|
||||
info=2040
|
||||
call psb_errpush(info,name)
|
||||
goto 9999
|
||||
end if
|
||||
if (ifc_<1) then
|
||||
write(0,*) 'csdp90 Error: invalid ifc ',ifc_
|
||||
info = -4
|
||||
call psb_errpush(info,name)
|
||||
goto 9999
|
||||
endif
|
||||
|
||||
if((check_=='Y').or.(check_=='C')) then
|
||||
if(toupper(a%fida(1:3))=='CSR') then
|
||||
call dcsrck(trans,a%m,a%k,a%descra,a%aspk,a%ia1,a%ia2,work,size(work),info)
|
||||
if(info /= 0) then
|
||||
info=4010
|
||||
ch_err='dcsrck'
|
||||
call psb_errpush(info,name,a_err=ch_err)
|
||||
goto 9999
|
||||
end if
|
||||
|
||||
else
|
||||
write(0,'("Check not yet suported for the ",a3," storage format")')a%fida(1:3)
|
||||
end if
|
||||
|
||||
end if
|
||||
|
||||
if (check_/='R') then
|
||||
|
||||
if (present(upd)) then
|
||||
call psb_sp_setifld(upd,psb_upd_,b,info)
|
||||
end if
|
||||
if (present(dupl)) then
|
||||
call psb_sp_setifld(dupl,psb_dupl_,b,info)
|
||||
end if
|
||||
|
||||
upd_ = psb_sp_getifld(psb_upd_,b,info)
|
||||
select case(upd_)
|
||||
case(psb_upd_dflt_,psb_upd_srch_,psb_upd_perm_)
|
||||
! Legal value, do nothing
|
||||
case default
|
||||
! Fix bad value
|
||||
upd_ = psb_upd_dflt_
|
||||
call psb_sp_setifld(upd_,psb_upd_,b,info)
|
||||
end select
|
||||
dupl_ = psb_sp_getifld(psb_dupl_,b,info)
|
||||
select case(dupl_)
|
||||
case(psb_dupl_ovwrt_,psb_dupl_add_,psb_dupl_err_)
|
||||
! Legal value, do nothing
|
||||
case default
|
||||
! Fix bad value
|
||||
dupl_ = psb_dupl_def_
|
||||
call psb_sp_setifld(dupl_,psb_dupl_,b,info)
|
||||
end select
|
||||
|
||||
! ...matrix conversion...
|
||||
b%m=a%m
|
||||
b%k=a%k
|
||||
size_req = psb_sp_get_nnzeros(a)
|
||||
if (debug) write(0,*) 'DCSDP : size_req 1:',size_req
|
||||
!
|
||||
|
||||
n_row=b%m
|
||||
n_col=b%k
|
||||
call psb_cest(b%fida, n_row,n_col,size_req,&
|
||||
& ia1_size, ia2_size, aspk_size, upd_,info)
|
||||
|
||||
if (info /= psb_no_err_) then
|
||||
info=4010
|
||||
ch_err='psb_cest'
|
||||
call psb_errpush(info,name,a_err=ch_err)
|
||||
goto 9999
|
||||
endif
|
||||
if (.not.allocated(b%aspk).or.&
|
||||
&.not.allocated(b%ia1).or.&
|
||||
&.not.allocated(b%ia2).or.&
|
||||
&.not.allocated(b%pl).or.&
|
||||
&.not.allocated(b%pr)) then
|
||||
call psb_sp_reall(b,ia1_size,ia2_size,aspk_size,info)
|
||||
else if ((size(b%aspk) < aspk_size) .or.&
|
||||
&(size(b%ia1) < ia1_size) .or.&
|
||||
&(size(b%ia2) < ia2_size) .or.&
|
||||
&(size(b%pl) < b%m) .or.&
|
||||
&(size(b%pr) < b%k )) then
|
||||
call psb_sp_reall(b,ia1_size,ia2_size,aspk_size,info)
|
||||
endif
|
||||
|
||||
if (info /= psb_no_err_) then
|
||||
info=4010
|
||||
ch_err='psb_sp_reall'
|
||||
call psb_errpush(info,name,a_err=ch_err)
|
||||
goto 9999
|
||||
endif
|
||||
|
||||
b%pl(:) = 0
|
||||
b%pr(:) = 0
|
||||
|
||||
b%descra = a%descra
|
||||
|
||||
select case (toupper(a%fida(1:3)))
|
||||
|
||||
case ('CSR')
|
||||
|
||||
select case (toupper(b%fida(1:3)))
|
||||
|
||||
case ('CSR')
|
||||
|
||||
call dcrcr(trans_, a%m, a%k, unitd_, d, a%descra, a%aspk,&
|
||||
& a%ia1, a%ia2, a%infoa, b%pl, b%descra, b%aspk, b%ia1,&
|
||||
& b%ia2, b%infoa, b%pr, size(b%aspk), size(b%ia1),&
|
||||
& size(b%ia2), work, size(work), info)
|
||||
|
||||
|
||||
if (info/=0) then
|
||||
info=4010
|
||||
ch_err='dcrcr'
|
||||
call psb_errpush(info,name,a_err=ch_err)
|
||||
goto 9999
|
||||
end if
|
||||
|
||||
case ('JAD')
|
||||
|
||||
!...converting to JAD
|
||||
!...output matrix may not be big enough
|
||||
do
|
||||
|
||||
call dcrjd(trans_, a%m, a%k, unitd_, d, a%descra, a%aspk,&
|
||||
& a%ia1, a%ia2, a%infoa, b%pl, b%descra, b%aspk, b%ia1,&
|
||||
& b%ia2, b%infoa, b%pr, size(b%aspk), size(b%ia1),&
|
||||
& size(b%ia2), work, size(work), nzr, info)
|
||||
if (info /= 0) then
|
||||
call psb_errpush(4010,name,a_err='dcrjd')
|
||||
goto 9999
|
||||
endif
|
||||
|
||||
ntry = ntry + 1
|
||||
if (debug) then
|
||||
write(0,*) 'On out from dcrjad ',nzr,info
|
||||
end if
|
||||
if (nzr == 0) exit
|
||||
if (ntry > maxtry ) then
|
||||
write(0,*) 'Tried reallocating for DCRJAD for ',maxtry,': giving up now.'
|
||||
info=2040
|
||||
call psb_errpush(info,name)
|
||||
goto 9999
|
||||
endif
|
||||
|
||||
call psb_sp_reall(b,nzr,info,ifc=ifc_)
|
||||
if (info /= 0) then
|
||||
info=2040
|
||||
call psb_errpush(info,name)
|
||||
goto 9999
|
||||
endif
|
||||
|
||||
end do
|
||||
|
||||
if (info/=0) then
|
||||
call psb_errpush(info,name)
|
||||
goto 9999
|
||||
end if
|
||||
|
||||
case ('COO')
|
||||
if (debug) write(0,*) 'Calling CRCO ',a%descra
|
||||
call dcrco(trans_, a%m, a%k, unitd_, d, a%descra, a%aspk,&
|
||||
& a%ia1, a%ia2, a%infoa, b%pl, b%descra, b%aspk, b%ia1,&
|
||||
& b%ia2, b%infoa, b%pr, size(b%aspk), size(b%ia1),&
|
||||
& size(b%ia2), work, size(work), info)
|
||||
|
||||
if (info/=0) then
|
||||
call psb_errpush(4010,name,a_err='dcrco')
|
||||
goto 9999
|
||||
end if
|
||||
case default
|
||||
info=4010
|
||||
call psb_errpush(info,name)
|
||||
goto 9999
|
||||
|
||||
end select
|
||||
|
||||
case ('COO','COI')
|
||||
|
||||
select case (toupper(b%fida(1:3)))
|
||||
|
||||
case ('CSR')
|
||||
|
||||
call dcocr(trans_, a%m, a%k, unitd_, d, a%descra, a%aspk,&
|
||||
& a%ia2, a%ia1, a%infoa, b%pl, b%descra, b%aspk, b%ia1,&
|
||||
& b%ia2, b%infoa, b%pr, size(b%aspk), size(b%ia1),&
|
||||
& size(b%ia2), work, 2*size(work), info)
|
||||
|
||||
if (info/=0) then
|
||||
call psb_errpush(4010,name,a_err='dcocr')
|
||||
goto 9999
|
||||
end if
|
||||
|
||||
case ('JAD')
|
||||
|
||||
call psb_sp_all(temp_a, size(b%ia1),size(b%ia2),size(b%aspk),info)
|
||||
if (info /= 0) then
|
||||
info=2040
|
||||
call psb_errpush(info,name)
|
||||
goto 9999
|
||||
endif
|
||||
temp_a%m = a%m
|
||||
temp_a%k = a%k
|
||||
|
||||
!...Dirty trick: converting to CSR and then to JAD
|
||||
|
||||
call dcocr(trans_, a%m, a%k, unitd_, d, a%descra, a%aspk,&
|
||||
& a%ia2, a%ia1, a%infoa, temp_a%pl, temp_a%descra, &
|
||||
& temp_a%aspk, temp_a%ia1, temp_a%ia2, temp_a%infoa, temp_a%pr, &
|
||||
& size(temp_a%aspk), size(temp_a%ia1),&
|
||||
& size(temp_a%ia2), work, 2*size(work), info)
|
||||
|
||||
if (info/=0) then
|
||||
call psb_errpush(4010,name,a_err='dcocr')
|
||||
goto 9999
|
||||
end if
|
||||
|
||||
do
|
||||
call dcrjd(trans_, temp_a%m, temp_a%k, unitd_, d, temp_a%descra, &
|
||||
& temp_a%aspk, temp_a%ia1, temp_a%ia2, temp_a%infoa, &
|
||||
& b%pl, b%descra, b%aspk, b%ia1, b%ia2, b%infoa, b%pr, &
|
||||
& size(b%aspk), size(b%ia1),&
|
||||
& size(b%ia2), work, size(work), nzr, info)
|
||||
if (info/=0) then
|
||||
call psb_errpush(4010,name,a_err='dcrjd')
|
||||
goto 9999
|
||||
end if
|
||||
|
||||
ntry = ntry + 1
|
||||
if (debug) then
|
||||
write(0,*) 'On out from dcrjad ',nzr,info
|
||||
end if
|
||||
if (nzr == 0) exit
|
||||
if (ntry > maxtry ) then
|
||||
write(0,*) 'Tried reallocating for DCRJAD for ',maxtry,&
|
||||
& ': giving up now.'
|
||||
info=2040
|
||||
call psb_errpush(info,name)
|
||||
goto 9999
|
||||
endif
|
||||
|
||||
call psb_sp_reall(b,nzr,info,ifc=ifc_)
|
||||
if (info /= 0) then
|
||||
info=2040
|
||||
call psb_errpush(info,name)
|
||||
goto 9999
|
||||
endif
|
||||
|
||||
end do
|
||||
|
||||
case ('COO')
|
||||
|
||||
call dcoco(trans_, a%m, a%k, unitd_, d, a%descra, a%aspk,&
|
||||
& a%ia1, a%ia2, a%infoa, b%pl, b%descra, b%aspk, b%ia1,&
|
||||
& b%ia2, b%infoa, b%pr, size(b%aspk), size(b%ia1),&
|
||||
& size(b%ia2), work, 2*size(work), info)
|
||||
if (info/=0) then
|
||||
call psb_errpush(4010,name,a_err='dcoco')
|
||||
goto 9999
|
||||
end if
|
||||
|
||||
case default
|
||||
info=4010
|
||||
call psb_errpush(info,name)
|
||||
goto 9999
|
||||
end select
|
||||
|
||||
case default
|
||||
info=4010
|
||||
call psb_errpush(info,name)
|
||||
goto 9999
|
||||
|
||||
end select
|
||||
|
||||
if (psb_sp_getifld(psb_upd_,b,info) /= psb_upd_perm_) &
|
||||
& call psb_sp_trim(b,info)
|
||||
|
||||
else if (check_=='R') then
|
||||
|
||||
!...Regenerating matrix
|
||||
|
||||
if (psb_sp_getifld(psb_state_,b,info) /= psb_spmat_upd_) then
|
||||
info = 8888
|
||||
call psb_errpush(info,name)
|
||||
goto 9999
|
||||
endif
|
||||
|
||||
!
|
||||
! dupl_ and upd_ fields should not be changed.
|
||||
!
|
||||
select case(psb_sp_getifld(psb_upd_,b,info))
|
||||
|
||||
case(psb_upd_perm_)
|
||||
if (debug) write(0,*) 'Regeneration with psb_upd_perm_'
|
||||
if (toupper(b%fida(1:3))/='JAD') then
|
||||
ip1 = psb_sp_getifld(psb_upd_pnt_,b,info)
|
||||
ip2 = b%ia2(ip1+psb_ip2_)
|
||||
nnz = b%ia2(ip1+psb_nnz_)
|
||||
iflag = b%ia2(ip1+psb_iflag_)
|
||||
ichk = b%ia2(ip1+psb_ichk_)
|
||||
nnzt = b%ia2(ip1+psb_nnzt_)
|
||||
if (debug) write(*,*) 'Regeneration start: ',&
|
||||
& b%infoa(psb_upd_),psb_upd_perm_,nnz,nnzt ,iflag,info
|
||||
|
||||
if ((ichk/=nnzt+iflag).or.(nnz/=nnzt)) then
|
||||
info = 8889
|
||||
write(*,*) 'Regeneration start error: ',&
|
||||
& b%infoa(psb_upd_),psb_upd_perm_,nnz,nnzt ,iflag,ichk
|
||||
call psb_errpush(info,name)
|
||||
goto 9999
|
||||
endif
|
||||
do i= 1, nnz
|
||||
work(i) = 0.d0
|
||||
enddo
|
||||
select case(iflag)
|
||||
case(psb_dupl_ovwrt_,psb_dupl_err_)
|
||||
do i=1, nnz
|
||||
work(b%ia2(ip2+i-1)) = b%aspk(i)
|
||||
enddo
|
||||
case(psb_dupl_add_)
|
||||
do i=1, nnz
|
||||
work(b%ia2(ip2+i-1)) = b%aspk(i) + work(b%ia2(ip2+i-1))
|
||||
enddo
|
||||
case default
|
||||
info = 8887
|
||||
call psb_errpush(info,name)
|
||||
goto 9999
|
||||
end select
|
||||
|
||||
do i=1, nnz
|
||||
b%aspk(i) = work(i)
|
||||
enddo
|
||||
|
||||
else if (toupper(b%fida(1:3)) == 'JAD') then
|
||||
|
||||
|
||||
ip1 = psb_sp_getifld(psb_upd_pnt_,b,info)
|
||||
ip2 = b%ia1(ip1+psb_ip2_)
|
||||
count = b%ia1(ip1+psb_zero_)
|
||||
ipc = b%ia1(ip1+psb_ipc_)
|
||||
nnz = b%ia1(ip1+psb_nnz_)
|
||||
iflag = b%ia1(ip1+psb_iflag_)
|
||||
ichk = b%ia1(ip1+psb_ichk_)
|
||||
nnzt = b%ia1(ip1+psb_nnzt_)
|
||||
if (debug) write(*,*) 'Regeneration start: ',&
|
||||
& b%infoa(psb_upd_),psb_upd_perm_,nnz,nnzt,count, &
|
||||
& iflag,info
|
||||
|
||||
if ((ichk/=nnzt+iflag).or.(nnz/=nnzt)) then
|
||||
info = 10
|
||||
write(*,*) 'Regeneration start error: ',&
|
||||
& b%infoa(psb_upd_),psb_upd_perm_,nnz,nnzt ,iflag,ichk
|
||||
call psb_errpush(info,name)
|
||||
goto 9999
|
||||
endif
|
||||
|
||||
do i= 1, nnz+count
|
||||
work(i) = 0.d0
|
||||
enddo
|
||||
select case(iflag)
|
||||
case(psb_dupl_ovwrt_,psb_dupl_err_)
|
||||
do i=1, nnz
|
||||
work(b%ia1(ip2+i-1)) = b%aspk(i)
|
||||
enddo
|
||||
case(psb_dupl_add_)
|
||||
do i=1, nnz
|
||||
work(b%ia1(ip2+i-1)) = b%aspk(i) + work(b%ia1(ip2+i-1))
|
||||
enddo
|
||||
case default
|
||||
info = 8887
|
||||
call psb_errpush(info,name)
|
||||
goto 9999
|
||||
end select
|
||||
|
||||
do i=1, nnz+count
|
||||
b%aspk(i) = work(i)
|
||||
enddo
|
||||
do i=1, count
|
||||
b%aspk(b%ia1(ipc+i-1)) = 0.d0
|
||||
end do
|
||||
endif
|
||||
|
||||
case(psb_upd_dflt_,psb_upd_srch_)
|
||||
! Nothing to be done here.
|
||||
if (debug) write(0,*) 'Going through on regeneration with psb_upd_srch_'
|
||||
case default
|
||||
! Wrong value
|
||||
info = 8888
|
||||
call psb_errpush(info,name)
|
||||
goto 9999
|
||||
|
||||
end select
|
||||
end if
|
||||
call psb_sp_setifld(psb_spmat_asb_,psb_state_,b,info)
|
||||
|
||||
call psb_erractionrestore(err_act)
|
||||
return
|
||||
|
||||
9999 continue
|
||||
call psb_erractionrestore(err_act)
|
||||
if (err_act.eq.psb_act_abort_) then
|
||||
call psb_error()
|
||||
return
|
||||
end if
|
||||
return
|
||||
|
||||
end subroutine psb_dcsdp
|
||||
@ -0,0 +1,553 @@
|
||||
!!$
|
||||
!!$ Parallel Sparse BLAS v2.0
|
||||
!!$ (C) Copyright 2006 Salvatore Filippone University of Rome Tor Vergata
|
||||
!!$ Alfredo Buttari University of Rome Tor Vergata
|
||||
!!$
|
||||
!!$ Redistribution and use in source and binary forms, with or without
|
||||
!!$ modification, are permitted provided that the following conditions
|
||||
!!$ are met:
|
||||
!!$ 1. Redistributions of source code must retain the above copyright
|
||||
!!$ notice, this list of conditions and the following disclaimer.
|
||||
!!$ 2. Redistributions in binary form must reproduce the above copyright
|
||||
!!$ notice, this list of conditions, and the following disclaimer in the
|
||||
!!$ documentation and/or other materials provided with the distribution.
|
||||
!!$ 3. The name of the PSBLAS group or the names of its contributors may
|
||||
!!$ not be used to endorse or promote products derived from this
|
||||
!!$ software without specific written permission.
|
||||
!!$
|
||||
!!$ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
!!$ ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
!!$ TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
!!$ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PSBLAS GROUP OR ITS CONTRIBUTORS
|
||||
!!$ BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
!!$ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
!!$ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
!!$ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
!!$ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
!!$ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
!!$ POSSIBILITY OF SUCH DAMAGE.
|
||||
!!$
|
||||
!!$
|
||||
! File: psb_dcsdp.f90
|
||||
!
|
||||
! Subroutine: psb_dcsdp
|
||||
! This subroutine performs the assembly of
|
||||
! the local part of a sparse distributed matrix
|
||||
!
|
||||
! Parameters:
|
||||
! a - type(<psb_spmat_type>). The input matrix to be assembled.
|
||||
! b - type(<psb_spmat_type>). The assembled output matrix.
|
||||
! info - integer. Eventually returns an error code.
|
||||
! ifc - integer(optional). ???
|
||||
! check - character(optional). ???
|
||||
! trans - character(optional). ???
|
||||
! unitd - character(optional). ???
|
||||
!
|
||||
subroutine psb_dspcnv2(a, b,info,afmt,upd,dupl)
|
||||
use psb_const_mod
|
||||
use psb_error_mod
|
||||
use psb_spmat_type
|
||||
use psb_string_mod
|
||||
use psb_serial_mod, psb_protect_name => psb_dspcnv2
|
||||
implicit none
|
||||
!....Parameters...
|
||||
Type(psb_dspmat_type), intent(in) :: A
|
||||
Type(psb_dspmat_type), intent(out) :: B
|
||||
Integer, intent(out) :: info
|
||||
Integer, intent(in), optional :: upd,dupl
|
||||
character(len=*), optional, intent(in) :: afmt
|
||||
|
||||
!...Locals...
|
||||
real(kind(1.d0)) :: d(1)
|
||||
real(kind(1.d0)), allocatable :: work(:)
|
||||
type(psb_dspmat_type) :: temp_a
|
||||
Integer :: nzr, ntry, ifc_, ia1_size,&
|
||||
& ia2_size, aspk_size,size_req,n_row,n_col,upd_,dupl_
|
||||
integer :: ip1, ip2, nnz, iflag, ichk, nnzt,&
|
||||
& ipc, i, count, err_act, i1, i2, ia
|
||||
character :: check_,trans_,unitd_
|
||||
character(len=5) :: afmt_
|
||||
Integer, Parameter :: maxtry=8
|
||||
logical, parameter :: debug=.false.
|
||||
character(len=20) :: name, ch_err
|
||||
|
||||
name='psb_spcnv'
|
||||
info = 0
|
||||
call psb_erractionsave(err_act)
|
||||
|
||||
ntry=0
|
||||
|
||||
ifc_ = 2
|
||||
|
||||
|
||||
check_ = 'N'
|
||||
trans_ = 'N'
|
||||
unitd_ = 'U'
|
||||
allocate(work(max(size(a%ia1),size(a%ia2))+max(a%m,b%m)+1000),stat=info)
|
||||
|
||||
if (info /= 0) then
|
||||
info=2040
|
||||
call psb_errpush(info,name)
|
||||
goto 9999
|
||||
end if
|
||||
|
||||
|
||||
if (present(upd)) then
|
||||
call psb_sp_setifld(upd,psb_upd_,b,info)
|
||||
end if
|
||||
if (present(dupl)) then
|
||||
call psb_sp_setifld(dupl,psb_dupl_,b,info)
|
||||
end if
|
||||
if (present(afmt)) then
|
||||
afmt_ = afmt
|
||||
else
|
||||
afmt_ = psb_fidef_
|
||||
end if
|
||||
|
||||
upd_ = psb_sp_getifld(psb_upd_,b,info)
|
||||
select case(upd_)
|
||||
case(psb_upd_srch_,psb_upd_perm_)
|
||||
! Legal value, do nothing
|
||||
case default
|
||||
! Fix bad value
|
||||
upd_ = psb_upd_dflt_
|
||||
call psb_sp_setifld(upd_,psb_upd_,b,info)
|
||||
end select
|
||||
|
||||
dupl_ = psb_sp_getifld(psb_dupl_,b,info)
|
||||
select case(dupl_)
|
||||
case(psb_dupl_ovwrt_,psb_dupl_add_,psb_dupl_err_)
|
||||
! Legal value, do nothing
|
||||
case default
|
||||
! Fix bad value
|
||||
dupl_ = psb_dupl_def_
|
||||
call psb_sp_setifld(dupl_,psb_dupl_,b,info)
|
||||
end select
|
||||
|
||||
! ...matrix conversion...
|
||||
b%m=a%m
|
||||
b%k=a%k
|
||||
b%fida=afmt_
|
||||
size_req = psb_sp_get_nnzeros(a)
|
||||
if (debug) write(0,*) 'DCSDP : size_req 1:',size_req
|
||||
!
|
||||
n_row=b%m
|
||||
n_col=b%k
|
||||
call psb_cest(afmt_,n_row,n_col,size_req,&
|
||||
& ia1_size, ia2_size, aspk_size, upd_,info)
|
||||
b%fida=afmt_
|
||||
|
||||
if (info /= psb_no_err_) then
|
||||
info=4010
|
||||
ch_err='psb_cest'
|
||||
call psb_errpush(info,name,a_err=ch_err)
|
||||
goto 9999
|
||||
endif
|
||||
if (.not.allocated(b%aspk).or.&
|
||||
&.not.allocated(b%ia1).or.&
|
||||
&.not.allocated(b%ia2).or.&
|
||||
&.not.allocated(b%pl).or.&
|
||||
&.not.allocated(b%pr)) then
|
||||
call psb_sp_reall(b,ia1_size,ia2_size,aspk_size,info)
|
||||
else if ((size(b%aspk) < aspk_size) .or.&
|
||||
&(size(b%ia1) < ia1_size) .or.&
|
||||
&(size(b%ia2) < ia2_size) .or.&
|
||||
&(size(b%pl) < b%m) .or.&
|
||||
&(size(b%pr) < b%k )) then
|
||||
call psb_sp_reall(b,ia1_size,ia2_size,aspk_size,info)
|
||||
endif
|
||||
|
||||
if (info /= psb_no_err_) then
|
||||
info=4010
|
||||
ch_err='psb_sp_reall'
|
||||
call psb_errpush(info,name,a_err=ch_err)
|
||||
goto 9999
|
||||
endif
|
||||
|
||||
b%pl(:) = 0
|
||||
b%pr(:) = 0
|
||||
|
||||
b%descra = a%descra
|
||||
|
||||
select case (tolower(a%fida))
|
||||
|
||||
case ('csr')
|
||||
|
||||
select case (tolower(b%fida))
|
||||
|
||||
case ('csr')
|
||||
|
||||
call dcrcr(trans_, a%m, a%k, unitd_, d, a%descra, a%aspk,&
|
||||
& a%ia1, a%ia2, a%infoa, b%pl, b%descra, b%aspk, b%ia1,&
|
||||
& b%ia2, b%infoa, b%pr, size(b%aspk), size(b%ia1),&
|
||||
& size(b%ia2), work, size(work), info)
|
||||
|
||||
|
||||
if (info/=0) then
|
||||
info=4010
|
||||
ch_err='dcrcr'
|
||||
call psb_errpush(info,name,a_err=ch_err)
|
||||
goto 9999
|
||||
end if
|
||||
|
||||
case ('jad')
|
||||
|
||||
!...converting to JAD
|
||||
!...output matrix may not be big enough
|
||||
do
|
||||
|
||||
call dcrjd(trans_, a%m, a%k, unitd_, d, a%descra, a%aspk,&
|
||||
& a%ia1, a%ia2, a%infoa, b%pl, b%descra, b%aspk, b%ia1,&
|
||||
& b%ia2, b%infoa, b%pr, size(b%aspk), size(b%ia1),&
|
||||
& size(b%ia2), work, size(work), nzr, info)
|
||||
if (info /= 0) then
|
||||
call psb_errpush(4010,name,a_err='dcrjd')
|
||||
goto 9999
|
||||
endif
|
||||
|
||||
ntry = ntry + 1
|
||||
if (debug) then
|
||||
write(0,*) 'On out from dcrjad ',nzr,info
|
||||
end if
|
||||
if (nzr == 0) exit
|
||||
if (ntry > maxtry ) then
|
||||
write(0,*) 'Tried reallocating for DCRJAD for ',maxtry,': giving up now.'
|
||||
info=2040
|
||||
call psb_errpush(info,name)
|
||||
goto 9999
|
||||
endif
|
||||
call psb_cest(afmt_,n_row,n_col,nzr,&
|
||||
& ia1_size, ia2_size, aspk_size, upd_,info)
|
||||
call psb_sp_reall(b,ia1_size,ia2_size,aspk_size,info)
|
||||
if (info /= 0) then
|
||||
info=2040
|
||||
call psb_errpush(info,name)
|
||||
goto 9999
|
||||
endif
|
||||
|
||||
end do
|
||||
|
||||
if (info/=0) then
|
||||
call psb_errpush(info,name)
|
||||
goto 9999
|
||||
end if
|
||||
|
||||
case ('coo')
|
||||
if (debug) write(0,*) 'Calling CRCO ',a%descra
|
||||
call dcrco(trans_, a%m, a%k, unitd_, d, a%descra, a%aspk,&
|
||||
& a%ia1, a%ia2, a%infoa, b%pl, b%descra, b%aspk, b%ia1,&
|
||||
& b%ia2, b%infoa, b%pr, size(b%aspk), size(b%ia1),&
|
||||
& size(b%ia2), work, size(work), info)
|
||||
|
||||
if (info/=0) then
|
||||
call psb_errpush(4010,name,a_err='dcrco')
|
||||
goto 9999
|
||||
end if
|
||||
case default
|
||||
info=4010
|
||||
call psb_errpush(info,name)
|
||||
goto 9999
|
||||
|
||||
end select
|
||||
|
||||
case ('coo','coi')
|
||||
|
||||
select case (tolower(b%fida))
|
||||
|
||||
case ('csr')
|
||||
|
||||
call dcocr(trans_, a%m, a%k, unitd_, d, a%descra, a%aspk,&
|
||||
& a%ia2, a%ia1, a%infoa, b%pl, b%descra, b%aspk, b%ia1,&
|
||||
& b%ia2, b%infoa, b%pr, size(b%aspk), size(b%ia1),&
|
||||
& size(b%ia2), work, 2*size(work), info)
|
||||
|
||||
if (info/=0) then
|
||||
call psb_errpush(4010,name,a_err='dcocr')
|
||||
goto 9999
|
||||
end if
|
||||
|
||||
case ('jad')
|
||||
|
||||
call psb_sp_all(temp_a, size(b%ia1),size(b%ia2),size(b%aspk),info)
|
||||
if (info /= 0) then
|
||||
info=2040
|
||||
call psb_errpush(info,name)
|
||||
goto 9999
|
||||
endif
|
||||
temp_a%m = a%m
|
||||
temp_a%k = a%k
|
||||
temp_a%infoa=b%infoa
|
||||
!...Dirty trick: converting to CSR and then to JAD
|
||||
|
||||
call dcocr(trans_, a%m, a%k, unitd_, d, a%descra, a%aspk,&
|
||||
& a%ia2, a%ia1, a%infoa, temp_a%pl, temp_a%descra, &
|
||||
& temp_a%aspk, temp_a%ia1, temp_a%ia2, temp_a%infoa, temp_a%pr, &
|
||||
& size(temp_a%aspk), size(temp_a%ia1),&
|
||||
& size(temp_a%ia2), work, 2*size(work), info)
|
||||
|
||||
if (info/=0) then
|
||||
call psb_errpush(4010,name,a_err='dcocr')
|
||||
goto 9999
|
||||
end if
|
||||
|
||||
do
|
||||
call dcrjd(trans_, temp_a%m, temp_a%k, unitd_, d, temp_a%descra, &
|
||||
& temp_a%aspk, temp_a%ia1, temp_a%ia2, temp_a%infoa, &
|
||||
& b%pl, b%descra, b%aspk, b%ia1, b%ia2, b%infoa, b%pr, &
|
||||
& size(b%aspk), size(b%ia1),&
|
||||
& size(b%ia2), work, size(work), nzr, info)
|
||||
if (info/=0) then
|
||||
call psb_errpush(4010,name,a_err='dcrjd')
|
||||
goto 9999
|
||||
end if
|
||||
|
||||
ntry = ntry + 1
|
||||
if (debug) then
|
||||
write(0,*) 'On out from dcrjad ',nzr,info
|
||||
end if
|
||||
if (nzr == 0) exit
|
||||
if (ntry > maxtry ) then
|
||||
write(0,*) 'Tried reallocating for DCRJAD for ',maxtry,&
|
||||
& ': giving up now.'
|
||||
info=2040
|
||||
call psb_errpush(info,name)
|
||||
goto 9999
|
||||
endif
|
||||
|
||||
call psb_sp_reall(b,nzr,info,ifc=ifc_)
|
||||
if (info /= 0) then
|
||||
info=2040
|
||||
call psb_errpush(info,name)
|
||||
goto 9999
|
||||
endif
|
||||
|
||||
end do
|
||||
|
||||
case ('coo')
|
||||
|
||||
call dcoco(trans_, a%m, a%k, unitd_, d, a%descra, a%aspk,&
|
||||
& a%ia1, a%ia2, a%infoa, b%pl, b%descra, b%aspk, b%ia1,&
|
||||
& b%ia2, b%infoa, b%pr, size(b%aspk), size(b%ia1),&
|
||||
& size(b%ia2), work, 2*size(work), info)
|
||||
if (info/=0) then
|
||||
call psb_errpush(4010,name,a_err='dcoco')
|
||||
goto 9999
|
||||
end if
|
||||
|
||||
case default
|
||||
info=4010
|
||||
call psb_errpush(info,name)
|
||||
goto 9999
|
||||
end select
|
||||
|
||||
case default
|
||||
info=4010
|
||||
call psb_errpush(info,name)
|
||||
goto 9999
|
||||
|
||||
end select
|
||||
|
||||
if (psb_sp_getifld(psb_upd_,b,info) /= psb_upd_perm_) &
|
||||
& call psb_sp_trim(b,info)
|
||||
|
||||
|
||||
call psb_sp_setifld(psb_spmat_asb_,psb_state_,b,info)
|
||||
|
||||
call psb_erractionrestore(err_act)
|
||||
return
|
||||
|
||||
9999 continue
|
||||
call psb_erractionrestore(err_act)
|
||||
if (err_act.eq.psb_act_abort_) then
|
||||
call psb_error()
|
||||
return
|
||||
end if
|
||||
return
|
||||
|
||||
end subroutine psb_dspcnv2
|
||||
|
||||
|
||||
subroutine psb_dspcnv1(a, info, afmt, upd, dupl)
|
||||
|
||||
use psb_spmat_type
|
||||
use psb_regen_mod
|
||||
use psb_serial_mod, psb_protect_name => psb_dspcnv1
|
||||
use psb_const_mod
|
||||
use psi_mod
|
||||
use psb_error_mod
|
||||
use psb_string_mod
|
||||
!use psb_penv_mod
|
||||
|
||||
implicit none
|
||||
|
||||
|
||||
!...Parameters....
|
||||
type(psb_dspmat_type), intent (inout) :: a
|
||||
integer, intent(out) :: info
|
||||
integer,optional, intent(in) :: dupl, upd
|
||||
character(len=*), optional, intent(in) :: afmt
|
||||
|
||||
integer :: int_err(5)
|
||||
type(psb_dspmat_type) :: atemp
|
||||
integer :: np,me,n_col,iout, err_act
|
||||
integer :: spstate
|
||||
integer :: upd_, dupl_
|
||||
integer :: ictxt,n_row
|
||||
logical, parameter :: debug=.false., debugwrt=.false.
|
||||
character(len=20) :: name, ch_err
|
||||
|
||||
info = 0
|
||||
int_err(1)=0
|
||||
name = 'psb_spcnv'
|
||||
call psb_erractionsave(err_act)
|
||||
|
||||
if (present(upd)) then
|
||||
call psb_sp_setifld(upd,psb_upd_,a,info)
|
||||
end if
|
||||
if (present(dupl)) then
|
||||
call psb_sp_setifld(dupl,psb_dupl_,a,info)
|
||||
end if
|
||||
|
||||
upd_ = psb_sp_getifld(psb_upd_,a,info)
|
||||
select case(upd_)
|
||||
case(psb_upd_srch_,psb_upd_perm_)
|
||||
! Legal value, do nothing
|
||||
case default
|
||||
! Fix bad value
|
||||
upd_ = psb_upd_dflt_
|
||||
call psb_sp_setifld(upd_,psb_upd_,a,info)
|
||||
end select
|
||||
|
||||
dupl_ = psb_sp_getifld(psb_dupl_,a,info)
|
||||
select case(dupl_)
|
||||
case(psb_dupl_ovwrt_,psb_dupl_add_,psb_dupl_err_)
|
||||
! Legal value, do nothing
|
||||
case default
|
||||
! Fix bad value
|
||||
dupl_ = psb_dupl_def_
|
||||
call psb_sp_setifld(dupl_,psb_dupl_,a,info)
|
||||
end select
|
||||
|
||||
|
||||
spstate = psb_sp_getifld(psb_state_,a,info)
|
||||
if (info /= 0) then
|
||||
goto 9999
|
||||
endif
|
||||
if (debug) write(0,*) 'Sparse matrix state:',spstate,psb_spmat_bld_,psb_spmat_upd_
|
||||
if (spstate /= psb_spmat_upd_) then
|
||||
! Should we first figure out if we can do it in place?
|
||||
if (debug) write(0,*) 'Update:',upd_,psb_upd_srch_,psb_upd_perm_
|
||||
if (upd_ == psb_upd_srch_) then
|
||||
if (present(afmt)) then
|
||||
select case (tolower(a%fida))
|
||||
case('coo')
|
||||
select case(tolower(afmt))
|
||||
case('coo')
|
||||
call psb_fixcoo(a,info)
|
||||
goto 9998
|
||||
case('csr')
|
||||
call psb_ipcoo2csr(a,info)
|
||||
goto 9998
|
||||
case('csc')
|
||||
call psb_ipcoo2csc(a,info)
|
||||
goto 9998
|
||||
end select
|
||||
case('csr')
|
||||
select case(tolower(afmt))
|
||||
case('coo')
|
||||
call psb_ipcsr2coo(a,info)
|
||||
goto 9998
|
||||
end select
|
||||
end select
|
||||
end if
|
||||
end if
|
||||
|
||||
call psb_sp_clone(a,atemp,info)
|
||||
if(info /= psb_no_err_) then
|
||||
info=4010
|
||||
ch_err='psb_sp_clone'
|
||||
call psb_errpush(info,name,a_err=ch_err)
|
||||
goto 9999
|
||||
! convert to user requested format after the temp copy
|
||||
end if
|
||||
|
||||
if (debugwrt) then
|
||||
iout = 30+me
|
||||
open(iout)
|
||||
call psb_csprt(iout,atemp,head='Input mat')
|
||||
close(iout)
|
||||
endif
|
||||
|
||||
! Do the real conversion into the requested storage format
|
||||
! result is put in A
|
||||
call psb_spcnv(atemp,a,info,afmt=afmt,upd=upd,dupl=dupl)
|
||||
|
||||
IF (debug) WRITE (*, *) me,' ASB: From SPCNV',info,' ',A%FIDA
|
||||
if (info /= psb_no_err_) then
|
||||
info=4010
|
||||
ch_err='psb_csdp'
|
||||
call psb_errpush(info,name,a_err=ch_err)
|
||||
goto 9999
|
||||
endif
|
||||
|
||||
if (debugwrt) then
|
||||
iout = 60+me
|
||||
open(iout)
|
||||
call psb_csprt(iout,a,head='Output mat')
|
||||
close(iout)
|
||||
endif
|
||||
|
||||
call psb_sp_free(atemp,info)
|
||||
|
||||
else if (spstate == psb_spmat_upd_) then
|
||||
!
|
||||
! Second case: we come from an update loop.
|
||||
!
|
||||
select case(tolower(a%fida))
|
||||
case('csr')
|
||||
call csr_regen(a,info)
|
||||
case ('coo','coi')
|
||||
call coo_regen(a,info)
|
||||
case('jad')
|
||||
call jad_regen(a,info)
|
||||
case default
|
||||
info=136
|
||||
ch_err=a%fida
|
||||
call psb_errpush(info,name,a_err=ch_err)
|
||||
goto 9999
|
||||
end select
|
||||
|
||||
|
||||
! check on error retuned by dcsdp
|
||||
if (info /= psb_no_err_) then
|
||||
info = 4010
|
||||
ch_err='xx_regen'
|
||||
call psb_errpush(info,name,a_err=ch_err)
|
||||
goto 9999
|
||||
end if
|
||||
|
||||
else
|
||||
|
||||
info = 600
|
||||
call psb_errpush(info,name)
|
||||
goto 9999
|
||||
if (debug) write(0,*) 'Sparse matrix state:',spstate,psb_spmat_bld_,psb_spmat_upd_
|
||||
|
||||
endif
|
||||
|
||||
9998 continue
|
||||
|
||||
call psb_sp_setifld(psb_spmat_asb_,psb_state_,a,info)
|
||||
|
||||
call psb_erractionrestore(err_act)
|
||||
return
|
||||
|
||||
9999 continue
|
||||
call psb_erractionrestore(err_act)
|
||||
if (err_act.eq.psb_act_abort_) then
|
||||
call psb_error()
|
||||
return
|
||||
end if
|
||||
return
|
||||
|
||||
end subroutine psb_dspcnv1
|
||||
@ -0,0 +1,613 @@
|
||||
module psb_regen_mod
|
||||
|
||||
interface csr_regen
|
||||
module procedure csr_dsp_regen, csr_zsp_regen
|
||||
end interface
|
||||
interface coo_regen
|
||||
module procedure coo_dsp_regen, coo_zsp_regen
|
||||
end interface
|
||||
interface jad_regen
|
||||
module procedure jad_dsp_regen, jad_zsp_regen
|
||||
end interface
|
||||
|
||||
contains
|
||||
|
||||
subroutine csr_dsp_regen(a,info)
|
||||
|
||||
use psb_spmat_type
|
||||
use psb_const_mod
|
||||
use psb_error_mod
|
||||
implicit none
|
||||
|
||||
type(psb_dspmat_type), intent(inout) :: a
|
||||
integer :: info
|
||||
|
||||
integer :: i,j, k, ip1,ip2,nnz,iflag,ichk,nnzt
|
||||
real(kind(1.d0)), allocatable :: work(:)
|
||||
integer :: err_act
|
||||
character(len=20) :: name, ch_err
|
||||
logical, parameter :: debug=.false.
|
||||
|
||||
name='psb_spcnv'
|
||||
info = 0
|
||||
call psb_erractionsave(err_act)
|
||||
|
||||
|
||||
!
|
||||
! dupl_ and upd_ fields should not be changed.
|
||||
!
|
||||
select case(psb_sp_getifld(psb_upd_,a,info))
|
||||
|
||||
case(psb_upd_perm_)
|
||||
|
||||
allocate(work(size(a%aspk)+1000),stat=info)
|
||||
if (info /= 0) then
|
||||
info=2040
|
||||
call psb_errpush(info,name)
|
||||
goto 9999
|
||||
end if
|
||||
|
||||
if (debug) write(0,*) 'Regeneration with psb_upd_perm_'
|
||||
ip1 = psb_sp_getifld(psb_upd_pnt_,a,info)
|
||||
ip2 = a%ia2(ip1+psb_ip2_)
|
||||
nnz = a%ia2(ip1+psb_nnz_)
|
||||
iflag = a%ia2(ip1+psb_iflag_)
|
||||
ichk = a%ia2(ip1+psb_ichk_)
|
||||
nnzt = a%ia2(ip1+psb_nnzt_)
|
||||
if (debug) write(*,*) 'Regeneration start: ',&
|
||||
& a%infoa(psb_upd_),psb_upd_perm_,nnz,nnzt ,iflag,info
|
||||
|
||||
if ((ichk/=nnzt+iflag).or.(nnz/=nnzt)) then
|
||||
info = 8889
|
||||
write(*,*) 'Regeneration start error: ',&
|
||||
& a%infoa(psb_upd_),psb_upd_perm_,nnz,nnzt ,iflag,ichk
|
||||
call psb_errpush(info,name)
|
||||
goto 9999
|
||||
endif
|
||||
do i= 1, nnz
|
||||
work(i) = dzero
|
||||
enddo
|
||||
select case(iflag)
|
||||
case(psb_dupl_ovwrt_,psb_dupl_err_)
|
||||
do i=1, nnz
|
||||
work(a%ia2(ip2+i-1)) = a%aspk(i)
|
||||
enddo
|
||||
case(psb_dupl_add_)
|
||||
do i=1, nnz
|
||||
work(a%ia2(ip2+i-1)) = a%aspk(i) + work(a%ia2(ip2+i-1))
|
||||
enddo
|
||||
case default
|
||||
info = 8887
|
||||
call psb_errpush(info,name)
|
||||
goto 9999
|
||||
end select
|
||||
|
||||
do i=1, nnz
|
||||
a%aspk(i) = work(i)
|
||||
enddo
|
||||
|
||||
|
||||
case(psb_upd_srch_)
|
||||
! Nothing to be done here.
|
||||
if (debug) write(0,*) 'Going through on regeneration with psb_upd_srch_'
|
||||
case default
|
||||
! Wrong value
|
||||
info = 8888
|
||||
call psb_errpush(info,name)
|
||||
goto 9999
|
||||
|
||||
end select
|
||||
|
||||
call psb_erractionrestore(err_act)
|
||||
return
|
||||
|
||||
9999 continue
|
||||
call psb_erractionrestore(err_act)
|
||||
if (err_act.eq.psb_act_abort_) then
|
||||
call psb_error()
|
||||
return
|
||||
end if
|
||||
return
|
||||
|
||||
end subroutine csr_dsp_regen
|
||||
|
||||
subroutine coo_dsp_regen(a,info)
|
||||
|
||||
use psb_spmat_type
|
||||
use psb_const_mod
|
||||
use psb_error_mod
|
||||
implicit none
|
||||
|
||||
type(psb_dspmat_type), intent(inout) :: a
|
||||
integer :: info
|
||||
|
||||
integer :: i,j, k, ip1,ip2,nnz,iflag,ichk,nnzt
|
||||
real(kind(1.d0)), allocatable :: work(:)
|
||||
integer :: err_act
|
||||
character(len=20) :: name, ch_err
|
||||
logical, parameter :: debug=.false.
|
||||
|
||||
name='psb_spcnv'
|
||||
info = 0
|
||||
call psb_erractionsave(err_act)
|
||||
|
||||
|
||||
!
|
||||
! dupl_ and upd_ fields should not be changed.
|
||||
!
|
||||
select case(psb_sp_getifld(psb_upd_,a,info))
|
||||
|
||||
case(psb_upd_perm_)
|
||||
|
||||
allocate(work(size(a%aspk)+1000),stat=info)
|
||||
if (info /= 0) then
|
||||
info=2040
|
||||
call psb_errpush(info,name)
|
||||
goto 9999
|
||||
end if
|
||||
|
||||
if (debug) write(0,*) 'Regeneration with psb_upd_perm_'
|
||||
ip1 = psb_sp_getifld(psb_upd_pnt_,a,info)
|
||||
ip2 = a%ia2(ip1+psb_ip2_)
|
||||
nnz = a%ia2(ip1+psb_nnz_)
|
||||
iflag = a%ia2(ip1+psb_iflag_)
|
||||
ichk = a%ia2(ip1+psb_ichk_)
|
||||
nnzt = a%ia2(ip1+psb_nnzt_)
|
||||
if (debug) write(*,*) 'Regeneration start: ',&
|
||||
& a%infoa(psb_upd_),psb_upd_perm_,nnz,nnzt ,iflag,info
|
||||
|
||||
if ((ichk/=nnzt+iflag).or.(nnz/=nnzt)) then
|
||||
info = 8889
|
||||
write(*,*) 'Regeneration start error: ',&
|
||||
& a%infoa(psb_upd_),psb_upd_perm_,nnz,nnzt ,iflag,ichk
|
||||
call psb_errpush(info,name)
|
||||
goto 9999
|
||||
endif
|
||||
do i= 1, nnz
|
||||
work(i) = dzero
|
||||
enddo
|
||||
select case(iflag)
|
||||
case(psb_dupl_ovwrt_,psb_dupl_err_)
|
||||
do i=1, nnz
|
||||
work(a%ia2(ip2+i-1)) = a%aspk(i)
|
||||
enddo
|
||||
case(psb_dupl_add_)
|
||||
do i=1, nnz
|
||||
work(a%ia2(ip2+i-1)) = a%aspk(i) + work(a%ia2(ip2+i-1))
|
||||
enddo
|
||||
case default
|
||||
info = 8887
|
||||
call psb_errpush(info,name)
|
||||
goto 9999
|
||||
end select
|
||||
|
||||
do i=1, nnz
|
||||
a%aspk(i) = work(i)
|
||||
enddo
|
||||
|
||||
|
||||
case(psb_upd_srch_)
|
||||
! Nothing to be done here.
|
||||
if (debug) write(0,*) 'Going through on regeneration with psb_upd_srch_'
|
||||
case default
|
||||
! Wrong value
|
||||
info = 8888
|
||||
call psb_errpush(info,name)
|
||||
goto 9999
|
||||
|
||||
end select
|
||||
|
||||
call psb_erractionrestore(err_act)
|
||||
return
|
||||
|
||||
9999 continue
|
||||
call psb_erractionrestore(err_act)
|
||||
if (err_act.eq.psb_act_abort_) then
|
||||
call psb_error()
|
||||
return
|
||||
end if
|
||||
return
|
||||
|
||||
end subroutine coo_dsp_regen
|
||||
|
||||
subroutine jad_dsp_regen(a,info)
|
||||
|
||||
use psb_spmat_type
|
||||
use psb_const_mod
|
||||
use psb_error_mod
|
||||
implicit none
|
||||
|
||||
type(psb_dspmat_type), intent(inout) :: a
|
||||
integer :: info
|
||||
|
||||
integer :: i,j, k, ip1,ip2,nnz,iflag,ichk,nnzt
|
||||
real(kind(1.d0)), allocatable :: work(:)
|
||||
integer :: err_act
|
||||
character(len=20) :: name, ch_err
|
||||
logical, parameter :: debug=.false.
|
||||
|
||||
name='psb_spcnv'
|
||||
info = 0
|
||||
call psb_erractionsave(err_act)
|
||||
|
||||
|
||||
!
|
||||
! dupl_ and upd_ fields should not be changed.
|
||||
!
|
||||
select case(psb_sp_getifld(psb_upd_,a,info))
|
||||
|
||||
case(psb_upd_perm_)
|
||||
|
||||
allocate(work(size(a%aspk)+1000),stat=info)
|
||||
if (info /= 0) then
|
||||
info=2040
|
||||
call psb_errpush(info,name)
|
||||
goto 9999
|
||||
end if
|
||||
|
||||
if (debug) write(0,*) 'Regeneration with psb_upd_perm_'
|
||||
ip1 = psb_sp_getifld(psb_upd_pnt_,a,info)
|
||||
ip2 = a%ia1(ip1+psb_ip2_)
|
||||
nnz = a%ia1(ip1+psb_nnz_)
|
||||
iflag = a%ia1(ip1+psb_iflag_)
|
||||
ichk = a%ia1(ip1+psb_ichk_)
|
||||
nnzt = a%ia1(ip1+psb_nnzt_)
|
||||
if (debug) write(*,*) 'Regeneration start: ',&
|
||||
& a%infoa(psb_upd_),psb_upd_perm_,nnz,nnzt ,iflag,info
|
||||
|
||||
if ((ichk/=nnzt+iflag).or.(nnz/=nnzt)) then
|
||||
info = 8889
|
||||
write(*,*) 'Regeneration start error: ',&
|
||||
& a%infoa(psb_upd_),psb_upd_perm_,nnz,nnzt ,iflag,ichk
|
||||
call psb_errpush(info,name)
|
||||
goto 9999
|
||||
endif
|
||||
do i= 1, nnz
|
||||
work(i) = dzero
|
||||
enddo
|
||||
select case(iflag)
|
||||
case(psb_dupl_ovwrt_,psb_dupl_err_)
|
||||
do i=1, nnz
|
||||
work(a%ia1(ip2+i-1)) = a%aspk(i)
|
||||
enddo
|
||||
case(psb_dupl_add_)
|
||||
do i=1, nnz
|
||||
work(a%ia1(ip2+i-1)) = a%aspk(i) + work(a%ia1(ip2+i-1))
|
||||
enddo
|
||||
case default
|
||||
info = 8887
|
||||
call psb_errpush(info,name)
|
||||
goto 9999
|
||||
end select
|
||||
|
||||
do i=1, nnz
|
||||
a%aspk(i) = work(i)
|
||||
enddo
|
||||
|
||||
|
||||
case(psb_upd_srch_)
|
||||
! Nothing to be done here.
|
||||
if (debug) write(0,*) 'Going through on regeneration with psb_upd_srch_'
|
||||
case default
|
||||
! Wrong value
|
||||
info = 8888
|
||||
call psb_errpush(info,name)
|
||||
goto 9999
|
||||
|
||||
end select
|
||||
|
||||
call psb_erractionrestore(err_act)
|
||||
return
|
||||
|
||||
9999 continue
|
||||
call psb_erractionrestore(err_act)
|
||||
if (err_act.eq.psb_act_abort_) then
|
||||
call psb_error()
|
||||
return
|
||||
end if
|
||||
return
|
||||
|
||||
end subroutine jad_dsp_regen
|
||||
|
||||
|
||||
|
||||
subroutine csr_zsp_regen(a,info)
|
||||
|
||||
use psb_spmat_type
|
||||
use psb_const_mod
|
||||
use psb_error_mod
|
||||
implicit none
|
||||
|
||||
type(psb_zspmat_type), intent(inout) :: a
|
||||
integer :: info
|
||||
|
||||
integer :: i,j, k, ip1,ip2,nnz,iflag,ichk,nnzt
|
||||
complex(kind(1.d0)), allocatable :: work(:)
|
||||
integer :: err_act
|
||||
character(len=20) :: name, ch_err
|
||||
logical, parameter :: debug=.false.
|
||||
|
||||
name='psb_spcnv'
|
||||
info = 0
|
||||
call psb_erractionsave(err_act)
|
||||
|
||||
|
||||
!
|
||||
! dupl_ and upd_ fields should not be changed.
|
||||
!
|
||||
select case(psb_sp_getifld(psb_upd_,a,info))
|
||||
|
||||
case(psb_upd_perm_)
|
||||
|
||||
allocate(work(size(a%aspk)+1000),stat=info)
|
||||
if (info /= 0) then
|
||||
info=2040
|
||||
call psb_errpush(info,name)
|
||||
goto 9999
|
||||
end if
|
||||
|
||||
if (debug) write(0,*) 'Regeneration with psb_upd_perm_'
|
||||
ip1 = psb_sp_getifld(psb_upd_pnt_,a,info)
|
||||
ip2 = a%ia2(ip1+psb_ip2_)
|
||||
nnz = a%ia2(ip1+psb_nnz_)
|
||||
iflag = a%ia2(ip1+psb_iflag_)
|
||||
ichk = a%ia2(ip1+psb_ichk_)
|
||||
nnzt = a%ia2(ip1+psb_nnzt_)
|
||||
if (debug) write(*,*) 'Regeneration start: ',&
|
||||
& a%infoa(psb_upd_),psb_upd_perm_,nnz,nnzt ,iflag,info
|
||||
|
||||
if ((ichk/=nnzt+iflag).or.(nnz/=nnzt)) then
|
||||
info = 8889
|
||||
write(*,*) 'Regeneration start error: ',&
|
||||
& a%infoa(psb_upd_),psb_upd_perm_,nnz,nnzt ,iflag,ichk
|
||||
call psb_errpush(info,name)
|
||||
goto 9999
|
||||
endif
|
||||
do i= 1, nnz
|
||||
work(i) = zzero
|
||||
enddo
|
||||
select case(iflag)
|
||||
case(psb_dupl_ovwrt_,psb_dupl_err_)
|
||||
do i=1, nnz
|
||||
work(a%ia2(ip2+i-1)) = a%aspk(i)
|
||||
enddo
|
||||
case(psb_dupl_add_)
|
||||
do i=1, nnz
|
||||
work(a%ia2(ip2+i-1)) = a%aspk(i) + work(a%ia2(ip2+i-1))
|
||||
enddo
|
||||
case default
|
||||
info = 8887
|
||||
call psb_errpush(info,name)
|
||||
goto 9999
|
||||
end select
|
||||
|
||||
do i=1, nnz
|
||||
a%aspk(i) = work(i)
|
||||
enddo
|
||||
|
||||
|
||||
case(psb_upd_srch_)
|
||||
! Nothing to be done here.
|
||||
if (debug) write(0,*) 'Going through on regeneration with psb_upd_srch_'
|
||||
case default
|
||||
! Wrong value
|
||||
info = 8888
|
||||
call psb_errpush(info,name)
|
||||
goto 9999
|
||||
|
||||
end select
|
||||
|
||||
call psb_erractionrestore(err_act)
|
||||
return
|
||||
|
||||
9999 continue
|
||||
call psb_erractionrestore(err_act)
|
||||
if (err_act.eq.psb_act_abort_) then
|
||||
call psb_error()
|
||||
return
|
||||
end if
|
||||
return
|
||||
|
||||
end subroutine csr_zsp_regen
|
||||
|
||||
subroutine coo_zsp_regen(a,info)
|
||||
|
||||
use psb_spmat_type
|
||||
use psb_const_mod
|
||||
use psb_error_mod
|
||||
implicit none
|
||||
|
||||
type(psb_zspmat_type), intent(inout) :: a
|
||||
integer :: info
|
||||
|
||||
integer :: i,j, k, ip1,ip2,nnz,iflag,ichk,nnzt
|
||||
complex(kind(1.d0)), allocatable :: work(:)
|
||||
integer :: err_act
|
||||
character(len=20) :: name, ch_err
|
||||
logical, parameter :: debug=.false.
|
||||
|
||||
name='psb_spcnv'
|
||||
info = 0
|
||||
call psb_erractionsave(err_act)
|
||||
|
||||
|
||||
!
|
||||
! dupl_ and upd_ fields should not be changed.
|
||||
!
|
||||
select case(psb_sp_getifld(psb_upd_,a,info))
|
||||
|
||||
case(psb_upd_perm_)
|
||||
|
||||
allocate(work(size(a%aspk)+1000),stat=info)
|
||||
if (info /= 0) then
|
||||
info=2040
|
||||
call psb_errpush(info,name)
|
||||
goto 9999
|
||||
end if
|
||||
|
||||
if (debug) write(0,*) 'Regeneration with psb_upd_perm_'
|
||||
ip1 = psb_sp_getifld(psb_upd_pnt_,a,info)
|
||||
ip2 = a%ia2(ip1+psb_ip2_)
|
||||
nnz = a%ia2(ip1+psb_nnz_)
|
||||
iflag = a%ia2(ip1+psb_iflag_)
|
||||
ichk = a%ia2(ip1+psb_ichk_)
|
||||
nnzt = a%ia2(ip1+psb_nnzt_)
|
||||
if (debug) write(*,*) 'Regeneration start: ',&
|
||||
& a%infoa(psb_upd_),psb_upd_perm_,nnz,nnzt ,iflag,info
|
||||
|
||||
if ((ichk/=nnzt+iflag).or.(nnz/=nnzt)) then
|
||||
info = 8889
|
||||
write(*,*) 'Regeneration start error: ',&
|
||||
& a%infoa(psb_upd_),psb_upd_perm_,nnz,nnzt ,iflag,ichk
|
||||
call psb_errpush(info,name)
|
||||
goto 9999
|
||||
endif
|
||||
do i= 1, nnz
|
||||
work(i) = zzero
|
||||
enddo
|
||||
select case(iflag)
|
||||
case(psb_dupl_ovwrt_,psb_dupl_err_)
|
||||
do i=1, nnz
|
||||
work(a%ia2(ip2+i-1)) = a%aspk(i)
|
||||
enddo
|
||||
case(psb_dupl_add_)
|
||||
do i=1, nnz
|
||||
work(a%ia2(ip2+i-1)) = a%aspk(i) + work(a%ia2(ip2+i-1))
|
||||
enddo
|
||||
case default
|
||||
info = 8887
|
||||
call psb_errpush(info,name)
|
||||
goto 9999
|
||||
end select
|
||||
|
||||
do i=1, nnz
|
||||
a%aspk(i) = work(i)
|
||||
enddo
|
||||
|
||||
|
||||
case(psb_upd_srch_)
|
||||
! Nothing to be done here.
|
||||
if (debug) write(0,*) 'Going through on regeneration with psb_upd_srch_'
|
||||
case default
|
||||
! Wrong value
|
||||
info = 8888
|
||||
call psb_errpush(info,name)
|
||||
goto 9999
|
||||
|
||||
end select
|
||||
|
||||
call psb_erractionrestore(err_act)
|
||||
return
|
||||
|
||||
9999 continue
|
||||
call psb_erractionrestore(err_act)
|
||||
if (err_act.eq.psb_act_abort_) then
|
||||
call psb_error()
|
||||
return
|
||||
end if
|
||||
return
|
||||
|
||||
end subroutine coo_zsp_regen
|
||||
|
||||
subroutine jad_zsp_regen(a,info)
|
||||
|
||||
use psb_spmat_type
|
||||
use psb_const_mod
|
||||
use psb_error_mod
|
||||
implicit none
|
||||
|
||||
type(psb_zspmat_type), intent(inout) :: a
|
||||
integer :: info
|
||||
|
||||
integer :: i,j, k, ip1,ip2,nnz,iflag,ichk,nnzt
|
||||
complex(kind(1.d0)), allocatable :: work(:)
|
||||
integer :: err_act
|
||||
character(len=20) :: name, ch_err
|
||||
logical, parameter :: debug=.false.
|
||||
|
||||
name='psb_spcnv'
|
||||
info = 0
|
||||
call psb_erractionsave(err_act)
|
||||
|
||||
|
||||
!
|
||||
! dupl_ and upd_ fields should not be changed.
|
||||
!
|
||||
select case(psb_sp_getifld(psb_upd_,a,info))
|
||||
|
||||
case(psb_upd_perm_)
|
||||
|
||||
allocate(work(size(a%aspk)+1000),stat=info)
|
||||
if (info /= 0) then
|
||||
info=2040
|
||||
call psb_errpush(info,name)
|
||||
goto 9999
|
||||
end if
|
||||
|
||||
if (debug) write(0,*) 'Regeneration with psb_upd_perm_'
|
||||
ip1 = psb_sp_getifld(psb_upd_pnt_,a,info)
|
||||
ip2 = a%ia1(ip1+psb_ip2_)
|
||||
nnz = a%ia1(ip1+psb_nnz_)
|
||||
iflag = a%ia1(ip1+psb_iflag_)
|
||||
ichk = a%ia1(ip1+psb_ichk_)
|
||||
nnzt = a%ia1(ip1+psb_nnzt_)
|
||||
if (debug) write(*,*) 'Regeneration start: ',&
|
||||
& a%infoa(psb_upd_),psb_upd_perm_,nnz,nnzt ,iflag,info
|
||||
|
||||
if ((ichk/=nnzt+iflag).or.(nnz/=nnzt)) then
|
||||
info = 8889
|
||||
write(*,*) 'Regeneration start error: ',&
|
||||
& a%infoa(psb_upd_),psb_upd_perm_,nnz,nnzt ,iflag,ichk
|
||||
call psb_errpush(info,name)
|
||||
goto 9999
|
||||
endif
|
||||
do i= 1, nnz
|
||||
work(i) = zzero
|
||||
enddo
|
||||
select case(iflag)
|
||||
case(psb_dupl_ovwrt_,psb_dupl_err_)
|
||||
do i=1, nnz
|
||||
work(a%ia1(ip2+i-1)) = a%aspk(i)
|
||||
enddo
|
||||
case(psb_dupl_add_)
|
||||
do i=1, nnz
|
||||
work(a%ia1(ip2+i-1)) = a%aspk(i) + work(a%ia1(ip2+i-1))
|
||||
enddo
|
||||
case default
|
||||
info = 8887
|
||||
call psb_errpush(info,name)
|
||||
goto 9999
|
||||
end select
|
||||
|
||||
do i=1, nnz
|
||||
a%aspk(i) = work(i)
|
||||
enddo
|
||||
|
||||
|
||||
case(psb_upd_srch_)
|
||||
! Nothing to be done here.
|
||||
if (debug) write(0,*) 'Going through on regeneration with psb_upd_srch_'
|
||||
case default
|
||||
! Wrong value
|
||||
info = 8888
|
||||
call psb_errpush(info,name)
|
||||
goto 9999
|
||||
|
||||
end select
|
||||
|
||||
call psb_erractionrestore(err_act)
|
||||
return
|
||||
|
||||
9999 continue
|
||||
call psb_erractionrestore(err_act)
|
||||
if (err_act.eq.psb_act_abort_) then
|
||||
call psb_error()
|
||||
return
|
||||
end if
|
||||
return
|
||||
|
||||
end subroutine jad_zsp_regen
|
||||
|
||||
|
||||
|
||||
end module psb_regen_mod
|
||||
@ -1,516 +0,0 @@
|
||||
!!$
|
||||
!!$ Parallel Sparse BLAS v2.0
|
||||
!!$ (C) Copyright 2006 Salvatore Filippone University of Rome Tor Vergata
|
||||
!!$ Alfredo Buttari University of Rome Tor Vergata
|
||||
!!$
|
||||
!!$ Redistribution and use in source and binary forms, with or without
|
||||
!!$ modification, are permitted provided that the following conditions
|
||||
!!$ are met:
|
||||
!!$ 1. Redistributions of source code must retain the above copyright
|
||||
!!$ notice, this list of conditions and the following disclaimer.
|
||||
!!$ 2. Redistributions in binary form must reproduce the above copyright
|
||||
!!$ notice, this list of conditions, and the following disclaimer in the
|
||||
!!$ documentation and/or other materials provided with the distribution.
|
||||
!!$ 3. The name of the PSBLAS group or the names of its contributors may
|
||||
!!$ not be used to endorse or promote products derived from this
|
||||
!!$ software without specific written permission.
|
||||
!!$
|
||||
!!$ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
!!$ ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
!!$ TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
!!$ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PSBLAS GROUP OR ITS CONTRIBUTORS
|
||||
!!$ BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
!!$ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
!!$ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
!!$ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
!!$ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
!!$ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
!!$ POSSIBILITY OF SUCH DAMAGE.
|
||||
!!$
|
||||
!!$
|
||||
! File: psb_zcsdp.f90
|
||||
!
|
||||
! Subroutine: psb_zcsdp
|
||||
! This subroutine performs the assembly of
|
||||
! the local part of a sparse distributed matrix
|
||||
!
|
||||
! Parameters:
|
||||
! a - type(<psb_spmat_type>). The input matrix to be assembled.
|
||||
! b - type(<psb_spmat_type>). The assembled output matrix.
|
||||
! info - integer. Eventually returns an error code.
|
||||
! ifc - integer(optional). ???
|
||||
! check - character(optional). ???
|
||||
! trans - character(optional). ???
|
||||
! unitd - character(optional). ???
|
||||
!
|
||||
subroutine psb_zcsdp(a, b,info,ifc,check,trans,unitd,upd,dupl)
|
||||
use psb_const_mod
|
||||
use psb_error_mod
|
||||
use psb_spmat_type
|
||||
use psb_string_mod
|
||||
use psb_serial_mod, psb_protect_name => psb_zcsdp
|
||||
implicit none
|
||||
!....Parameters...
|
||||
Type(psb_zspmat_type), intent(in) :: A
|
||||
Type(psb_zspmat_type), intent(inout) :: B
|
||||
Integer, intent(out) :: info
|
||||
Integer, intent(in), optional :: ifc,upd,dupl
|
||||
character, intent(in), optional :: check,trans,unitd
|
||||
|
||||
!...Locals...
|
||||
complex(kind(1.d0)) :: d(1)
|
||||
complex(kind(1.d0)), allocatable :: work(:)
|
||||
type(psb_zspmat_type) :: temp_a
|
||||
Integer :: nzr, ntry, ifc_, ia1_size,&
|
||||
& ia2_size, aspk_size,size_req,n_row,n_col,upd_,dupl_
|
||||
integer :: ip1, ip2, nnz, iflag, ichk, nnzt,&
|
||||
& ipc, i, count, err_act, i1, i2, ia
|
||||
character :: check_,trans_,unitd_
|
||||
Integer, Parameter :: maxtry=8
|
||||
logical, parameter :: debug=.false.
|
||||
character(len=20) :: name, ch_err
|
||||
|
||||
name='psb_csdp'
|
||||
info = 0
|
||||
call psb_erractionsave(err_act)
|
||||
|
||||
ntry=0
|
||||
if (present(ifc)) then
|
||||
ifc_ = max(1,ifc)
|
||||
else
|
||||
ifc_ = 1
|
||||
endif
|
||||
if (present(check)) then
|
||||
check_ = toupper(check)
|
||||
else
|
||||
check_ = 'N'
|
||||
endif
|
||||
if (present(trans)) then
|
||||
trans_ = toupper(trans)
|
||||
else
|
||||
trans_ = 'N'
|
||||
endif
|
||||
if (present(unitd)) then
|
||||
unitd_ = toupper(unitd)
|
||||
else
|
||||
unitd_ = 'U'
|
||||
endif
|
||||
|
||||
|
||||
if (check_=='R') then
|
||||
allocate(work(max(size(a%aspk),size(b%aspk))+1000),stat=info)
|
||||
else
|
||||
allocate(work(max(size(a%ia1),size(a%ia2))+max(a%m,b%m)+1000),stat=info)
|
||||
endif
|
||||
|
||||
if (info /= 0) then
|
||||
info=2040
|
||||
call psb_errpush(info,name)
|
||||
goto 9999
|
||||
end if
|
||||
if (ifc_<1) then
|
||||
write(0,*) 'csdp90 Error: invalid ifc ',ifc_
|
||||
info = -4
|
||||
call psb_errpush(info,name)
|
||||
goto 9999
|
||||
endif
|
||||
|
||||
if((check_=='Y').or.(check_=='C')) then
|
||||
if(toupper(a%fida(1:3))=='CSR') then
|
||||
call zcsrck(trans,a%m,a%k,a%descra,a%aspk,a%ia1,a%ia2,work,size(work),info)
|
||||
if(info /= 0) then
|
||||
info=4010
|
||||
ch_err='dcsrck'
|
||||
call psb_errpush(info,name,a_err=ch_err)
|
||||
goto 9999
|
||||
end if
|
||||
|
||||
else
|
||||
write(0,'("Check not yet suported for the ",a3," storage format")')a%fida(1:3)
|
||||
end if
|
||||
|
||||
end if
|
||||
|
||||
if (check_/='R') then
|
||||
|
||||
if (present(upd)) then
|
||||
call psb_sp_setifld(upd,psb_upd_,b,info)
|
||||
end if
|
||||
if (present(dupl)) then
|
||||
call psb_sp_setifld(dupl,psb_dupl_,b,info)
|
||||
end if
|
||||
|
||||
upd_ = psb_sp_getifld(psb_upd_,b,info)
|
||||
select case(upd_)
|
||||
case(psb_upd_dflt_,psb_upd_srch_,psb_upd_perm_)
|
||||
! Legal value, do nothing
|
||||
case default
|
||||
! Fix bad value
|
||||
upd_ = psb_upd_dflt_
|
||||
call psb_sp_setifld(upd_,psb_upd_,b,info)
|
||||
end select
|
||||
dupl_ = psb_sp_getifld(psb_dupl_,b,info)
|
||||
select case(dupl_)
|
||||
case(psb_dupl_ovwrt_,psb_dupl_add_,psb_dupl_err_)
|
||||
! Legal value, do nothing
|
||||
case default
|
||||
! Fix bad value
|
||||
dupl_ = psb_dupl_def_
|
||||
call psb_sp_setifld(dupl_,psb_dupl_,b,info)
|
||||
end select
|
||||
|
||||
! ...matrix conversion...
|
||||
b%m=a%m
|
||||
b%k=a%k
|
||||
size_req = psb_sp_get_nnzeros(a)
|
||||
if (debug) write(0,*) 'DCSDP : size_req 1:',size_req
|
||||
!
|
||||
|
||||
n_row=b%m
|
||||
n_col=b%k
|
||||
call psb_cest(b%fida, n_row,n_col,size_req,&
|
||||
& ia1_size, ia2_size, aspk_size, upd_,info)
|
||||
|
||||
if (info /= psb_no_err_) then
|
||||
info=4010
|
||||
ch_err='psb_cest'
|
||||
call psb_errpush(info,name,a_err=ch_err)
|
||||
goto 9999
|
||||
endif
|
||||
if (.not.allocated(b%aspk).or.&
|
||||
&.not.allocated(b%ia1).or.&
|
||||
&.not.allocated(b%ia2).or.&
|
||||
&.not.allocated(b%pl).or.&
|
||||
&.not.allocated(b%pr)) then
|
||||
call psb_sp_reall(b,ia1_size,ia2_size,aspk_size,info)
|
||||
else if ((size(b%aspk) < aspk_size) .or.&
|
||||
&(size(b%ia1) < ia1_size) .or.&
|
||||
&(size(b%ia2) < ia2_size) .or.&
|
||||
&(size(b%pl) < b%m) .or.&
|
||||
&(size(b%pr) < b%k )) then
|
||||
call psb_sp_reall(b,ia1_size,ia2_size,aspk_size,info)
|
||||
endif
|
||||
|
||||
if (info /= psb_no_err_) then
|
||||
info=4010
|
||||
ch_err='psb_sp_reall'
|
||||
call psb_errpush(info,name,a_err=ch_err)
|
||||
goto 9999
|
||||
endif
|
||||
|
||||
b%pl(:) = 0
|
||||
b%pr(:) = 0
|
||||
|
||||
b%descra = a%descra
|
||||
|
||||
select case (toupper(a%fida(1:3)))
|
||||
|
||||
case ('CSR')
|
||||
|
||||
select case (toupper(b%fida(1:3)))
|
||||
|
||||
case ('CSR')
|
||||
|
||||
|
||||
call zcrcr(trans_, a%m, a%k, unitd_, d, a%descra, a%aspk,&
|
||||
& a%ia1, a%ia2, a%infoa, b%pl, b%descra, b%aspk, b%ia1,&
|
||||
& b%ia2, b%infoa, b%pr, size(b%aspk), size(b%ia1),&
|
||||
& size(b%ia2), work, size(work), info)
|
||||
|
||||
|
||||
if (info/=0) then
|
||||
info=4010
|
||||
ch_err='dcrcr'
|
||||
call psb_errpush(info,name,a_err=ch_err)
|
||||
goto 9999
|
||||
end if
|
||||
|
||||
case ('JAD')
|
||||
|
||||
!...converting to JAD
|
||||
!...output matrix may not be big enough
|
||||
do
|
||||
|
||||
call zcrjd(trans_, a%m, a%k, unitd_, d, a%descra, a%aspk,&
|
||||
& a%ia1, a%ia2, a%infoa, b%pl, b%descra, b%aspk, b%ia1,&
|
||||
& b%ia2, b%infoa, b%pr, size(b%aspk), size(b%ia1),&
|
||||
& size(b%ia2), work, size(work), nzr, info)
|
||||
if (info /= 0) then
|
||||
call psb_errpush(4010,name,a_err='dcrjd')
|
||||
goto 9999
|
||||
endif
|
||||
|
||||
ntry = ntry + 1
|
||||
if (debug) then
|
||||
write(0,*) 'On out from dcrjad ',nzr,info
|
||||
end if
|
||||
if (nzr == 0) exit
|
||||
if (ntry > maxtry ) then
|
||||
write(0,*) 'Tried reallocating for DCRJAD for ',maxtry,': giving up now.'
|
||||
info=2040
|
||||
call psb_errpush(info,name)
|
||||
goto 9999
|
||||
endif
|
||||
|
||||
call psb_sp_reall(b,nzr,info,ifc=ifc_)
|
||||
if (info /= 0) then
|
||||
info=2040
|
||||
call psb_errpush(info,name)
|
||||
goto 9999
|
||||
endif
|
||||
|
||||
end do
|
||||
|
||||
if (info/=0) then
|
||||
call psb_errpush(info,name)
|
||||
goto 9999
|
||||
end if
|
||||
|
||||
case ('COO')
|
||||
|
||||
call zcrco(trans_, a%m, a%k, unitd_, d, a%descra, a%aspk,&
|
||||
& a%ia1, a%ia2, a%infoa, b%pl, b%descra, b%aspk, b%ia1,&
|
||||
& b%ia2, b%infoa, b%pr, size(b%aspk), size(b%ia1),&
|
||||
& size(b%ia2), work, size(work), info)
|
||||
|
||||
if (info/=0) then
|
||||
call psb_errpush(4010,name,a_err='dcrco')
|
||||
goto 9999
|
||||
end if
|
||||
case default
|
||||
info=4010
|
||||
call psb_errpush(info,name)
|
||||
goto 9999
|
||||
|
||||
end select
|
||||
|
||||
case ('COO','COI')
|
||||
|
||||
select case (toupper(b%fida(1:3)))
|
||||
|
||||
case ('CSR')
|
||||
|
||||
call zcocr(trans_, a%m, a%k, unitd_, d, a%descra, a%aspk,&
|
||||
& a%ia2, a%ia1, a%infoa, b%pl, b%descra, b%aspk, b%ia1,&
|
||||
& b%ia2, b%infoa, b%pr, size(b%aspk), size(b%ia1),&
|
||||
& size(b%ia2), work, 2*size(work), info)
|
||||
|
||||
if (info/=0) then
|
||||
call psb_errpush(4010,name,a_err='dcocr')
|
||||
goto 9999
|
||||
end if
|
||||
|
||||
case ('JAD')
|
||||
|
||||
call psb_sp_all(temp_a, size(b%ia1),size(b%ia2),size(b%aspk),info)
|
||||
if (info /= 0) then
|
||||
info=2040
|
||||
call psb_errpush(info,name)
|
||||
goto 9999
|
||||
endif
|
||||
temp_a%m = a%m
|
||||
temp_a%k = a%k
|
||||
|
||||
!...Dirty trick: converting to CSR and then to JAD
|
||||
|
||||
call zcocr(trans_, a%m, a%k, unitd_, d, a%descra, a%aspk,&
|
||||
& a%ia2, a%ia1, a%infoa, temp_a%pl, temp_a%descra, &
|
||||
& temp_a%aspk, temp_a%ia1, temp_a%ia2, temp_a%infoa, temp_a%pr, &
|
||||
& size(temp_a%aspk), size(temp_a%ia1),&
|
||||
& size(temp_a%ia2), work, 2*size(work), info)
|
||||
|
||||
if (info/=0) then
|
||||
call psb_errpush(4010,name,a_err='dcocr')
|
||||
goto 9999
|
||||
end if
|
||||
|
||||
do
|
||||
call zcrjd(trans_, temp_a%m, temp_a%k, unitd_, d, temp_a%descra, &
|
||||
& temp_a%aspk, temp_a%ia1, temp_a%ia2, temp_a%infoa, &
|
||||
& b%pl, b%descra, b%aspk, b%ia1, b%ia2, b%infoa, b%pr, &
|
||||
& size(b%aspk), size(b%ia1),&
|
||||
& size(b%ia2), work, size(work), nzr, info)
|
||||
if (info/=0) then
|
||||
call psb_errpush(4010,name,a_err='dcrjd')
|
||||
goto 9999
|
||||
end if
|
||||
|
||||
ntry = ntry + 1
|
||||
if (debug) then
|
||||
write(0,*) 'On out from dcrjad ',nzr,info
|
||||
end if
|
||||
if (nzr == 0) exit
|
||||
if (ntry > maxtry ) then
|
||||
write(0,*) 'Tried reallocating for DCRJAD for ',maxtry,&
|
||||
& ': giving up now.'
|
||||
info=2040
|
||||
call psb_errpush(info,name)
|
||||
goto 9999
|
||||
endif
|
||||
|
||||
call psb_sp_reall(b,nzr,info,ifc=ifc_)
|
||||
if (info /= 0) then
|
||||
info=2040
|
||||
call psb_errpush(info,name)
|
||||
goto 9999
|
||||
endif
|
||||
|
||||
end do
|
||||
|
||||
case ('COO')
|
||||
|
||||
call zcoco(trans_, a%m, a%k, unitd_, d, a%descra, a%aspk,&
|
||||
& a%ia1, a%ia2, a%infoa, b%pl, b%descra, b%aspk, b%ia1,&
|
||||
& b%ia2, b%infoa, b%pr, size(b%aspk), size(b%ia1),&
|
||||
& size(b%ia2), work, 2*size(work), info)
|
||||
if (info/=0) then
|
||||
call psb_errpush(4010,name,a_err='dcoco')
|
||||
goto 9999
|
||||
end if
|
||||
|
||||
case default
|
||||
info=4010
|
||||
call psb_errpush(info,name)
|
||||
goto 9999
|
||||
end select
|
||||
|
||||
case default
|
||||
info=4010
|
||||
call psb_errpush(info,name)
|
||||
goto 9999
|
||||
|
||||
end select
|
||||
|
||||
|
||||
if (psb_sp_getifld(psb_upd_,b,info) /= psb_upd_perm_) &
|
||||
& call psb_sp_trim(b,info)
|
||||
|
||||
else if (check_=='R') then
|
||||
!...Regenerating matrix
|
||||
|
||||
if (psb_sp_getifld(psb_state_,b,info) /= psb_spmat_upd_) then
|
||||
info = 8888
|
||||
call psb_errpush(info,name)
|
||||
goto 9999
|
||||
endif
|
||||
|
||||
!
|
||||
! dupl_ and upd_ fields should not be changed.
|
||||
!
|
||||
select case(psb_sp_getifld(psb_upd_,b,info))
|
||||
|
||||
case(psb_upd_perm_)
|
||||
if (debug) write(0,*) 'Regeneration with psb_upd_perm_'
|
||||
if (toupper(b%fida(1:3))/='JAD') then
|
||||
ip1 = psb_sp_getifld(psb_upd_pnt_,b,info)
|
||||
ip2 = b%ia2(ip1+psb_ip2_)
|
||||
nnz = b%ia2(ip1+psb_nnz_)
|
||||
iflag = b%ia2(ip1+psb_iflag_)
|
||||
ichk = b%ia2(ip1+psb_ichk_)
|
||||
nnzt = b%ia2(ip1+psb_nnzt_)
|
||||
if (debug) write(*,*) 'Regeneration start: ',&
|
||||
& b%infoa(psb_upd_),psb_upd_perm_,nnz,nnzt ,iflag,info
|
||||
|
||||
if ((ichk/=nnzt+iflag).or.(nnz/=nnzt)) then
|
||||
info = 8889
|
||||
write(*,*) 'Regeneration start error: ',&
|
||||
& b%infoa(psb_upd_),psb_upd_perm_,nnz,nnzt ,iflag,ichk
|
||||
call psb_errpush(info,name)
|
||||
goto 9999
|
||||
endif
|
||||
do i= 1, nnz
|
||||
work(i) = 0.d0
|
||||
enddo
|
||||
select case(iflag)
|
||||
case(psb_dupl_ovwrt_,psb_dupl_err_)
|
||||
do i=1, nnz
|
||||
work(b%ia2(ip2+i-1)) = b%aspk(i)
|
||||
enddo
|
||||
case(psb_dupl_add_)
|
||||
do i=1, nnz
|
||||
work(b%ia2(ip2+i-1)) = b%aspk(i) + work(b%ia2(ip2+i-1))
|
||||
enddo
|
||||
case default
|
||||
info = 8887
|
||||
call psb_errpush(info,name)
|
||||
goto 9999
|
||||
end select
|
||||
|
||||
do i=1, nnz
|
||||
b%aspk(i) = work(i)
|
||||
enddo
|
||||
|
||||
else if (toupper(b%fida(1:3)) == 'JAD') then
|
||||
|
||||
|
||||
ip1 = psb_sp_getifld(psb_upd_pnt_,b,info)
|
||||
ip2 = b%ia1(ip1+psb_ip2_)
|
||||
count = b%ia1(ip1+psb_zero_)
|
||||
ipc = b%ia1(ip1+psb_ipc_)
|
||||
nnz = b%ia1(ip1+psb_nnz_)
|
||||
iflag = b%ia1(ip1+psb_iflag_)
|
||||
ichk = b%ia1(ip1+psb_ichk_)
|
||||
nnzt = b%ia1(ip1+psb_nnzt_)
|
||||
if (debug) write(*,*) 'Regeneration start: ',&
|
||||
& b%infoa(psb_upd_),psb_upd_perm_,nnz,nnzt,count, &
|
||||
& iflag,info
|
||||
|
||||
if ((ichk/=nnzt+iflag).or.(nnz/=nnzt)) then
|
||||
info = 10
|
||||
write(*,*) 'Regeneration start error: ',&
|
||||
& b%infoa(psb_upd_),psb_upd_perm_,nnz,nnzt ,iflag,ichk
|
||||
call psb_errpush(info,name)
|
||||
goto 9999
|
||||
endif
|
||||
|
||||
do i= 1, nnz+count
|
||||
work(i) = 0.d0
|
||||
enddo
|
||||
select case(iflag)
|
||||
case(psb_dupl_ovwrt_,psb_dupl_err_)
|
||||
do i=1, nnz
|
||||
work(b%ia1(ip2+i-1)) = b%aspk(i)
|
||||
enddo
|
||||
case(psb_dupl_add_)
|
||||
do i=1, nnz
|
||||
work(b%ia1(ip2+i-1)) = b%aspk(i) + work(b%ia1(ip2+i-1))
|
||||
enddo
|
||||
case default
|
||||
info = 8887
|
||||
call psb_errpush(info,name)
|
||||
goto 9999
|
||||
end select
|
||||
|
||||
do i=1, nnz+count
|
||||
b%aspk(i) = work(i)
|
||||
enddo
|
||||
do i=1, count
|
||||
b%aspk(b%ia1(ipc+i-1)) = 0.d0
|
||||
end do
|
||||
endif
|
||||
|
||||
case(psb_upd_dflt_,psb_upd_srch_)
|
||||
! Nothing to be done here.
|
||||
if (debug) write(0,*) 'Going through on regeneration with psb_upd_srch_'
|
||||
case default
|
||||
! Wrong value
|
||||
info = 8888
|
||||
call psb_errpush(info,name)
|
||||
goto 9999
|
||||
|
||||
end select
|
||||
end if
|
||||
call psb_sp_setifld(psb_spmat_asb_,psb_state_,b,info)
|
||||
|
||||
call psb_erractionrestore(err_act)
|
||||
return
|
||||
|
||||
9999 continue
|
||||
call psb_erractionrestore(err_act)
|
||||
if (err_act.eq.psb_act_abort_) then
|
||||
call psb_error()
|
||||
return
|
||||
end if
|
||||
return
|
||||
|
||||
end subroutine psb_zcsdp
|
||||
@ -0,0 +1,553 @@
|
||||
!!$
|
||||
!!$ Parallel Sparse BLAS v2.0
|
||||
!!$ (C) Copyright 2006 Salvatore Filippone University of Rome Tor Vergata
|
||||
!!$ Alfredo Buttari University of Rome Tor Vergata
|
||||
!!$
|
||||
!!$ Redistribution and use in source and binary forms, with or without
|
||||
!!$ modification, are permitted provided that the following conditions
|
||||
!!$ are met:
|
||||
!!$ 1. Redistributions of source code must retain the above copyright
|
||||
!!$ notice, this list of conditions and the following disclaimer.
|
||||
!!$ 2. Redistributions in binary form must reproduce the above copyright
|
||||
!!$ notice, this list of conditions, and the following disclaimer in the
|
||||
!!$ documentation and/or other materials provided with the distribution.
|
||||
!!$ 3. The name of the PSBLAS group or the names of its contributors may
|
||||
!!$ not be used to endorse or promote products derived from this
|
||||
!!$ software without specific written permission.
|
||||
!!$
|
||||
!!$ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
!!$ ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
!!$ TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
!!$ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PSBLAS GROUP OR ITS CONTRIBUTORS
|
||||
!!$ BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
!!$ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
!!$ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
!!$ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
!!$ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
!!$ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
!!$ POSSIBILITY OF SUCH DAMAGE.
|
||||
!!$
|
||||
!!$
|
||||
! File: psb_dcsdp.f90
|
||||
!
|
||||
! Subroutine: psb_dcsdp
|
||||
! This subroutine performs the assembly of
|
||||
! the local part of a sparse distributed matrix
|
||||
!
|
||||
! Parameters:
|
||||
! a - type(<psb_spmat_type>). The input matrix to be assembled.
|
||||
! b - type(<psb_spmat_type>). The assembled output matrix.
|
||||
! info - integer. Eventually returns an error code.
|
||||
! ifc - integer(optional). ???
|
||||
! check - character(optional). ???
|
||||
! trans - character(optional). ???
|
||||
! unitd - character(optional). ???
|
||||
!
|
||||
subroutine psb_zspcnv2(a, b,info,afmt,upd,dupl)
|
||||
use psb_const_mod
|
||||
use psb_error_mod
|
||||
use psb_spmat_type
|
||||
use psb_string_mod
|
||||
use psb_serial_mod, psb_protect_name => psb_zspcnv2
|
||||
implicit none
|
||||
!....Parameters...
|
||||
Type(psb_zspmat_type), intent(in) :: A
|
||||
Type(psb_zspmat_type), intent(out) :: B
|
||||
Integer, intent(out) :: info
|
||||
Integer, intent(in), optional :: upd,dupl
|
||||
character(len=*), optional, intent(in) :: afmt
|
||||
|
||||
!...Locals...
|
||||
complex(kind(1.d0)) :: d(1)
|
||||
complex(kind(1.d0)), allocatable :: work(:)
|
||||
type(psb_zspmat_type) :: temp_a
|
||||
Integer :: nzr, ntry, ifc_, ia1_size,&
|
||||
& ia2_size, aspk_size,size_req,n_row,n_col,upd_,dupl_
|
||||
integer :: ip1, ip2, nnz, iflag, ichk, nnzt,&
|
||||
& ipc, i, count, err_act, i1, i2, ia
|
||||
character :: check_,trans_,unitd_
|
||||
character(len=5) :: afmt_
|
||||
Integer, Parameter :: maxtry=8
|
||||
logical, parameter :: debug=.false.
|
||||
character(len=20) :: name, ch_err
|
||||
|
||||
name='psb_spcnv'
|
||||
info = 0
|
||||
call psb_erractionsave(err_act)
|
||||
|
||||
ntry=0
|
||||
|
||||
ifc_ = 2
|
||||
|
||||
|
||||
check_ = 'N'
|
||||
trans_ = 'N'
|
||||
unitd_ = 'U'
|
||||
allocate(work(max(size(a%ia1),size(a%ia2))+max(a%m,b%m)+1000),stat=info)
|
||||
|
||||
if (info /= 0) then
|
||||
info=2040
|
||||
call psb_errpush(info,name)
|
||||
goto 9999
|
||||
end if
|
||||
|
||||
|
||||
if (present(upd)) then
|
||||
call psb_sp_setifld(upd,psb_upd_,b,info)
|
||||
end if
|
||||
if (present(dupl)) then
|
||||
call psb_sp_setifld(dupl,psb_dupl_,b,info)
|
||||
end if
|
||||
if (present(afmt)) then
|
||||
afmt_ = afmt
|
||||
else
|
||||
afmt_ = psb_fidef_
|
||||
end if
|
||||
|
||||
upd_ = psb_sp_getifld(psb_upd_,b,info)
|
||||
select case(upd_)
|
||||
case(psb_upd_srch_,psb_upd_perm_)
|
||||
! Legal value, do nothing
|
||||
case default
|
||||
! Fix bad value
|
||||
upd_ = psb_upd_dflt_
|
||||
call psb_sp_setifld(upd_,psb_upd_,b,info)
|
||||
end select
|
||||
|
||||
dupl_ = psb_sp_getifld(psb_dupl_,b,info)
|
||||
select case(dupl_)
|
||||
case(psb_dupl_ovwrt_,psb_dupl_add_,psb_dupl_err_)
|
||||
! Legal value, do nothing
|
||||
case default
|
||||
! Fix bad value
|
||||
dupl_ = psb_dupl_def_
|
||||
call psb_sp_setifld(dupl_,psb_dupl_,b,info)
|
||||
end select
|
||||
|
||||
! ...matrix conversion...
|
||||
b%m=a%m
|
||||
b%k=a%k
|
||||
b%fida=afmt_
|
||||
size_req = psb_sp_get_nnzeros(a)
|
||||
if (debug) write(0,*) 'DCSDP : size_req 1:',size_req
|
||||
!
|
||||
n_row=b%m
|
||||
n_col=b%k
|
||||
call psb_cest(afmt_,n_row,n_col,size_req,&
|
||||
& ia1_size, ia2_size, aspk_size, upd_,info)
|
||||
b%fida=afmt_
|
||||
|
||||
if (info /= psb_no_err_) then
|
||||
info=4010
|
||||
ch_err='psb_cest'
|
||||
call psb_errpush(info,name,a_err=ch_err)
|
||||
goto 9999
|
||||
endif
|
||||
if (.not.allocated(b%aspk).or.&
|
||||
&.not.allocated(b%ia1).or.&
|
||||
&.not.allocated(b%ia2).or.&
|
||||
&.not.allocated(b%pl).or.&
|
||||
&.not.allocated(b%pr)) then
|
||||
call psb_sp_reall(b,ia1_size,ia2_size,aspk_size,info)
|
||||
else if ((size(b%aspk) < aspk_size) .or.&
|
||||
&(size(b%ia1) < ia1_size) .or.&
|
||||
&(size(b%ia2) < ia2_size) .or.&
|
||||
&(size(b%pl) < b%m) .or.&
|
||||
&(size(b%pr) < b%k )) then
|
||||
call psb_sp_reall(b,ia1_size,ia2_size,aspk_size,info)
|
||||
endif
|
||||
|
||||
if (info /= psb_no_err_) then
|
||||
info=4010
|
||||
ch_err='psb_sp_reall'
|
||||
call psb_errpush(info,name,a_err=ch_err)
|
||||
goto 9999
|
||||
endif
|
||||
|
||||
b%pl(:) = 0
|
||||
b%pr(:) = 0
|
||||
|
||||
b%descra = a%descra
|
||||
|
||||
select case (tolower(a%fida))
|
||||
|
||||
case ('csr')
|
||||
|
||||
select case (tolower(b%fida))
|
||||
|
||||
case ('csr')
|
||||
|
||||
call zcrcr(trans_, a%m, a%k, unitd_, d, a%descra, a%aspk,&
|
||||
& a%ia1, a%ia2, a%infoa, b%pl, b%descra, b%aspk, b%ia1,&
|
||||
& b%ia2, b%infoa, b%pr, size(b%aspk), size(b%ia1),&
|
||||
& size(b%ia2), work, size(work), info)
|
||||
|
||||
|
||||
if (info/=0) then
|
||||
info=4010
|
||||
ch_err='dcrcr'
|
||||
call psb_errpush(info,name,a_err=ch_err)
|
||||
goto 9999
|
||||
end if
|
||||
|
||||
case ('jad')
|
||||
|
||||
!...converting to JAD
|
||||
!...output matrix may not be big enough
|
||||
do
|
||||
|
||||
call zcrjd(trans_, a%m, a%k, unitd_, d, a%descra, a%aspk,&
|
||||
& a%ia1, a%ia2, a%infoa, b%pl, b%descra, b%aspk, b%ia1,&
|
||||
& b%ia2, b%infoa, b%pr, size(b%aspk), size(b%ia1),&
|
||||
& size(b%ia2), work, size(work), nzr, info)
|
||||
if (info /= 0) then
|
||||
call psb_errpush(4010,name,a_err='dcrjd')
|
||||
goto 9999
|
||||
endif
|
||||
|
||||
ntry = ntry + 1
|
||||
if (debug) then
|
||||
write(0,*) 'On out from dcrjad ',nzr,info
|
||||
end if
|
||||
if (nzr == 0) exit
|
||||
if (ntry > maxtry ) then
|
||||
write(0,*) 'Tried reallocating for DCRJAD for ',maxtry,': giving up now.'
|
||||
info=2040
|
||||
call psb_errpush(info,name)
|
||||
goto 9999
|
||||
endif
|
||||
call psb_cest(afmt_,n_row,n_col,nzr,&
|
||||
& ia1_size, ia2_size, aspk_size, upd_,info)
|
||||
call psb_sp_reall(b,ia1_size,ia2_size,aspk_size,info)
|
||||
if (info /= 0) then
|
||||
info=2040
|
||||
call psb_errpush(info,name)
|
||||
goto 9999
|
||||
endif
|
||||
|
||||
end do
|
||||
|
||||
if (info/=0) then
|
||||
call psb_errpush(info,name)
|
||||
goto 9999
|
||||
end if
|
||||
|
||||
case ('coo')
|
||||
if (debug) write(0,*) 'Calling CRCO ',a%descra
|
||||
call zcrco(trans_, a%m, a%k, unitd_, d, a%descra, a%aspk,&
|
||||
& a%ia1, a%ia2, a%infoa, b%pl, b%descra, b%aspk, b%ia1,&
|
||||
& b%ia2, b%infoa, b%pr, size(b%aspk), size(b%ia1),&
|
||||
& size(b%ia2), work, size(work), info)
|
||||
|
||||
if (info/=0) then
|
||||
call psb_errpush(4010,name,a_err='dcrco')
|
||||
goto 9999
|
||||
end if
|
||||
case default
|
||||
info=4010
|
||||
call psb_errpush(info,name)
|
||||
goto 9999
|
||||
|
||||
end select
|
||||
|
||||
case ('coo','coi')
|
||||
|
||||
select case (tolower(b%fida))
|
||||
|
||||
case ('csr')
|
||||
|
||||
call zcocr(trans_, a%m, a%k, unitd_, d, a%descra, a%aspk,&
|
||||
& a%ia2, a%ia1, a%infoa, b%pl, b%descra, b%aspk, b%ia1,&
|
||||
& b%ia2, b%infoa, b%pr, size(b%aspk), size(b%ia1),&
|
||||
& size(b%ia2), work, 2*size(work), info)
|
||||
|
||||
if (info/=0) then
|
||||
call psb_errpush(4010,name,a_err='dcocr')
|
||||
goto 9999
|
||||
end if
|
||||
|
||||
case ('jad')
|
||||
|
||||
call psb_sp_all(temp_a, size(b%ia1),size(b%ia2),size(b%aspk),info)
|
||||
if (info /= 0) then
|
||||
info=2040
|
||||
call psb_errpush(info,name)
|
||||
goto 9999
|
||||
endif
|
||||
temp_a%m = a%m
|
||||
temp_a%k = a%k
|
||||
temp_a%infoa=b%infoa
|
||||
!...Dirty trick: converting to CSR and then to JAD
|
||||
|
||||
call zcocr(trans_, a%m, a%k, unitd_, d, a%descra, a%aspk,&
|
||||
& a%ia2, a%ia1, a%infoa, temp_a%pl, temp_a%descra, &
|
||||
& temp_a%aspk, temp_a%ia1, temp_a%ia2, temp_a%infoa, temp_a%pr, &
|
||||
& size(temp_a%aspk), size(temp_a%ia1),&
|
||||
& size(temp_a%ia2), work, 2*size(work), info)
|
||||
|
||||
if (info/=0) then
|
||||
call psb_errpush(4010,name,a_err='dcocr')
|
||||
goto 9999
|
||||
end if
|
||||
|
||||
do
|
||||
call zcrjd(trans_, temp_a%m, temp_a%k, unitd_, d, temp_a%descra, &
|
||||
& temp_a%aspk, temp_a%ia1, temp_a%ia2, temp_a%infoa, &
|
||||
& b%pl, b%descra, b%aspk, b%ia1, b%ia2, b%infoa, b%pr, &
|
||||
& size(b%aspk), size(b%ia1),&
|
||||
& size(b%ia2), work, size(work), nzr, info)
|
||||
if (info/=0) then
|
||||
call psb_errpush(4010,name,a_err='dcrjd')
|
||||
goto 9999
|
||||
end if
|
||||
|
||||
ntry = ntry + 1
|
||||
if (debug) then
|
||||
write(0,*) 'On out from dcrjad ',nzr,info
|
||||
end if
|
||||
if (nzr == 0) exit
|
||||
if (ntry > maxtry ) then
|
||||
write(0,*) 'Tried reallocating for DCRJAD for ',maxtry,&
|
||||
& ': giving up now.'
|
||||
info=2040
|
||||
call psb_errpush(info,name)
|
||||
goto 9999
|
||||
endif
|
||||
|
||||
call psb_sp_reall(b,nzr,info,ifc=ifc_)
|
||||
if (info /= 0) then
|
||||
info=2040
|
||||
call psb_errpush(info,name)
|
||||
goto 9999
|
||||
endif
|
||||
|
||||
end do
|
||||
|
||||
case ('coo')
|
||||
|
||||
call zcoco(trans_, a%m, a%k, unitd_, d, a%descra, a%aspk,&
|
||||
& a%ia1, a%ia2, a%infoa, b%pl, b%descra, b%aspk, b%ia1,&
|
||||
& b%ia2, b%infoa, b%pr, size(b%aspk), size(b%ia1),&
|
||||
& size(b%ia2), work, 2*size(work), info)
|
||||
if (info/=0) then
|
||||
call psb_errpush(4010,name,a_err='dcoco')
|
||||
goto 9999
|
||||
end if
|
||||
|
||||
case default
|
||||
info=4010
|
||||
call psb_errpush(info,name)
|
||||
goto 9999
|
||||
end select
|
||||
|
||||
case default
|
||||
info=4010
|
||||
call psb_errpush(info,name)
|
||||
goto 9999
|
||||
|
||||
end select
|
||||
|
||||
if (psb_sp_getifld(psb_upd_,b,info) /= psb_upd_perm_) &
|
||||
& call psb_sp_trim(b,info)
|
||||
|
||||
|
||||
call psb_sp_setifld(psb_spmat_asb_,psb_state_,b,info)
|
||||
|
||||
call psb_erractionrestore(err_act)
|
||||
return
|
||||
|
||||
9999 continue
|
||||
call psb_erractionrestore(err_act)
|
||||
if (err_act.eq.psb_act_abort_) then
|
||||
call psb_error()
|
||||
return
|
||||
end if
|
||||
return
|
||||
|
||||
end subroutine psb_zspcnv2
|
||||
|
||||
|
||||
subroutine psb_zspcnv1(a, info, afmt, upd, dupl)
|
||||
|
||||
use psb_spmat_type
|
||||
use psb_regen_mod
|
||||
use psb_serial_mod, psb_protect_name => psb_zspcnv1
|
||||
use psb_const_mod
|
||||
use psi_mod
|
||||
use psb_error_mod
|
||||
use psb_string_mod
|
||||
!use psb_penv_mod
|
||||
|
||||
implicit none
|
||||
|
||||
|
||||
!...Parameters....
|
||||
type(psb_zspmat_type), intent (inout) :: a
|
||||
integer, intent(out) :: info
|
||||
integer,optional, intent(in) :: dupl, upd
|
||||
character(len=*), optional, intent(in) :: afmt
|
||||
|
||||
integer :: int_err(5)
|
||||
type(psb_zspmat_type) :: atemp
|
||||
integer :: np,me,n_col,iout, err_act
|
||||
integer :: spstate
|
||||
integer :: upd_, dupl_
|
||||
integer :: ictxt,n_row
|
||||
logical, parameter :: debug=.false., debugwrt=.false.
|
||||
character(len=20) :: name, ch_err
|
||||
|
||||
info = 0
|
||||
int_err(1)=0
|
||||
name = 'psb_spcnv'
|
||||
call psb_erractionsave(err_act)
|
||||
|
||||
if (present(upd)) then
|
||||
call psb_sp_setifld(upd,psb_upd_,a,info)
|
||||
end if
|
||||
if (present(dupl)) then
|
||||
call psb_sp_setifld(dupl,psb_dupl_,a,info)
|
||||
end if
|
||||
|
||||
upd_ = psb_sp_getifld(psb_upd_,a,info)
|
||||
select case(upd_)
|
||||
case(psb_upd_srch_,psb_upd_perm_)
|
||||
! Legal value, do nothing
|
||||
case default
|
||||
! Fix bad value
|
||||
upd_ = psb_upd_dflt_
|
||||
call psb_sp_setifld(upd_,psb_upd_,a,info)
|
||||
end select
|
||||
|
||||
dupl_ = psb_sp_getifld(psb_dupl_,a,info)
|
||||
select case(dupl_)
|
||||
case(psb_dupl_ovwrt_,psb_dupl_add_,psb_dupl_err_)
|
||||
! Legal value, do nothing
|
||||
case default
|
||||
! Fix bad value
|
||||
dupl_ = psb_dupl_def_
|
||||
call psb_sp_setifld(dupl_,psb_dupl_,a,info)
|
||||
end select
|
||||
|
||||
|
||||
spstate = psb_sp_getifld(psb_state_,a,info)
|
||||
if (info /= 0) then
|
||||
goto 9999
|
||||
endif
|
||||
if (debug) write(0,*) 'Sparse matrix state:',spstate,psb_spmat_bld_,psb_spmat_upd_
|
||||
if (spstate /= psb_spmat_upd_) then
|
||||
! Should we first figure out if we can do it in place?
|
||||
if (debug) write(0,*) 'Update:',upd_,psb_upd_srch_,psb_upd_perm_
|
||||
if (upd_ == psb_upd_srch_) then
|
||||
if (present(afmt)) then
|
||||
select case (tolower(a%fida))
|
||||
case('coo')
|
||||
select case(tolower(afmt))
|
||||
case('coo')
|
||||
call psb_fixcoo(a,info)
|
||||
goto 9998
|
||||
case('csr')
|
||||
call psb_ipcoo2csr(a,info)
|
||||
goto 9998
|
||||
case('csc')
|
||||
call psb_ipcoo2csc(a,info)
|
||||
goto 9998
|
||||
end select
|
||||
case('csr')
|
||||
select case(tolower(afmt))
|
||||
case('coo')
|
||||
call psb_ipcsr2coo(a,info)
|
||||
goto 9998
|
||||
end select
|
||||
end select
|
||||
end if
|
||||
end if
|
||||
|
||||
call psb_sp_clone(a,atemp,info)
|
||||
if(info /= psb_no_err_) then
|
||||
info=4010
|
||||
ch_err='psb_sp_clone'
|
||||
call psb_errpush(info,name,a_err=ch_err)
|
||||
goto 9999
|
||||
! convert to user requested format after the temp copy
|
||||
end if
|
||||
|
||||
if (debugwrt) then
|
||||
iout = 30+me
|
||||
open(iout)
|
||||
call psb_csprt(iout,atemp,head='Input mat')
|
||||
close(iout)
|
||||
endif
|
||||
|
||||
! Do the real conversion into the requested storage format
|
||||
! result is put in A
|
||||
call psb_spcnv(atemp,a,info,afmt=afmt,upd=upd,dupl=dupl)
|
||||
|
||||
IF (debug) WRITE (*, *) me,' ASB: From SPCNV',info,' ',A%FIDA
|
||||
if (info /= psb_no_err_) then
|
||||
info=4010
|
||||
ch_err='psb_csdp'
|
||||
call psb_errpush(info,name,a_err=ch_err)
|
||||
goto 9999
|
||||
endif
|
||||
|
||||
if (debugwrt) then
|
||||
iout = 60+me
|
||||
open(iout)
|
||||
call psb_csprt(iout,a,head='Output mat')
|
||||
close(iout)
|
||||
endif
|
||||
|
||||
call psb_sp_free(atemp,info)
|
||||
|
||||
else if (spstate == psb_spmat_upd_) then
|
||||
!
|
||||
! Second case: we come from an update loop.
|
||||
!
|
||||
select case(tolower(a%fida))
|
||||
case('csr')
|
||||
call csr_regen(a,info)
|
||||
case ('coo','coi')
|
||||
call coo_regen(a,info)
|
||||
case('jad')
|
||||
call jad_regen(a,info)
|
||||
case default
|
||||
info=136
|
||||
ch_err=a%fida
|
||||
call psb_errpush(info,name,a_err=ch_err)
|
||||
goto 9999
|
||||
end select
|
||||
|
||||
|
||||
! check on error retuned by dcsdp
|
||||
if (info /= psb_no_err_) then
|
||||
info = 4010
|
||||
ch_err='xx_regen'
|
||||
call psb_errpush(info,name,a_err=ch_err)
|
||||
goto 9999
|
||||
end if
|
||||
|
||||
else
|
||||
|
||||
info = 600
|
||||
call psb_errpush(info,name)
|
||||
goto 9999
|
||||
if (debug) write(0,*) 'Sparse matrix state:',spstate,psb_spmat_bld_,psb_spmat_upd_
|
||||
|
||||
endif
|
||||
|
||||
9998 continue
|
||||
|
||||
call psb_sp_setifld(psb_spmat_asb_,psb_state_,a,info)
|
||||
|
||||
call psb_erractionrestore(err_act)
|
||||
return
|
||||
|
||||
9999 continue
|
||||
call psb_erractionrestore(err_act)
|
||||
if (err_act.eq.psb_act_abort_) then
|
||||
call psb_error()
|
||||
return
|
||||
end if
|
||||
return
|
||||
|
||||
end subroutine psb_zspcnv1
|
||||
@ -1,242 +0,0 @@
|
||||
!!$
|
||||
!!$ Parallel Sparse BLAS v2.0
|
||||
!!$ (C) Copyright 2006 Salvatore Filippone University of Rome Tor Vergata
|
||||
!!$ Alfredo Buttari University of Rome Tor Vergata
|
||||
!!$
|
||||
!!$ Redistribution and use in source and binary forms, with or without
|
||||
!!$ modification, are permitted provided that the following conditions
|
||||
!!$ are met:
|
||||
!!$ 1. Redistributions of source code must retain the above copyright
|
||||
!!$ notice, this list of conditions and the following disclaimer.
|
||||
!!$ 2. Redistributions in binary form must reproduce the above copyright
|
||||
!!$ notice, this list of conditions, and the following disclaimer in the
|
||||
!!$ documentation and/or other materials provided with the distribution.
|
||||
!!$ 3. The name of the PSBLAS group or the names of its contributors may
|
||||
!!$ not be used to endorse or promote products derived from this
|
||||
!!$ software without specific written permission.
|
||||
!!$
|
||||
!!$ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
!!$ ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
!!$ TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
!!$ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PSBLAS GROUP OR ITS CONTRIBUTORS
|
||||
!!$ BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
!!$ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
!!$ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
!!$ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
!!$ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
!!$ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
!!$ POSSIBILITY OF SUCH DAMAGE.
|
||||
!!$
|
||||
!!$
|
||||
! File: psb_dspcnv.f90
|
||||
!
|
||||
! Subroutine: psb_dspcnv
|
||||
! converts sparse matrix a into b
|
||||
!
|
||||
! Parameters:
|
||||
! a - type(<psb_dspmat_type>). The sparse input matrix.
|
||||
! b - type(<psb_dspmat_type>). The sparse output matrix.
|
||||
! desc_a - type(<psb_desc_type>). The communication descriptor.
|
||||
! info - integer. Eventually returns an error code.
|
||||
!
|
||||
subroutine psb_dspcnv(a,b,desc_a,info)
|
||||
|
||||
use psb_descriptor_type
|
||||
use psb_spmat_type
|
||||
use psb_realloc_mod
|
||||
use psb_serial_mod
|
||||
use psb_const_mod
|
||||
use psb_error_mod
|
||||
use psb_penv_mod
|
||||
implicit none
|
||||
interface dcsdp
|
||||
|
||||
subroutine dcsdp(check,trans,m,n,unitd,d,&
|
||||
& fida,descra,a,ia1,ia2,infoa,&
|
||||
& pl,fidh,descrh,h,ih1,ih2,infoh,pr,lh,lh1,lh2,&
|
||||
& work,lwork,ierror)
|
||||
integer, intent(in) :: lh, lwork, lh1, lh2, m, n
|
||||
integer, intent(out) :: ierror
|
||||
character, intent(in) :: check, trans, unitd
|
||||
real(kind(1.d0)), intent(in) :: d(*), a(*)
|
||||
real(kind(1.d0)), intent(out) :: h(*)
|
||||
real(kind(1.d0)), intent(inout) :: work(*)
|
||||
integer, intent(in) :: ia1(*), ia2(*), infoa(*)
|
||||
integer, intent(out) :: ih1(*), ih2(*), pl(*),pr(*), infoh(*)
|
||||
character, intent(in) :: fida*5, descra*11
|
||||
character, intent(out) :: fidh*5, descrh*11
|
||||
end subroutine dcsdp
|
||||
end interface
|
||||
|
||||
|
||||
interface dcsrp
|
||||
|
||||
subroutine dcsrp(trans,m,n,fida,descra,ia1,ia2,&
|
||||
& infoa,p,work,lwork,ierror)
|
||||
integer, intent(in) :: m, n, lwork
|
||||
integer, intent(out) :: ierror
|
||||
character, intent(in) :: trans
|
||||
real(kind(1.d0)), intent(inout) :: work(*)
|
||||
integer, intent(in) :: p(*)
|
||||
integer, intent(inout) :: ia1(*), ia2(*), infoa(*)
|
||||
character, intent(in) :: fida*5, descra*11
|
||||
end subroutine dcsrp
|
||||
end interface
|
||||
|
||||
interface dcsprt
|
||||
subroutine dcsprt(m,n,fida,descra,a,ia1,ia2,infoa ,iout,ierror)
|
||||
integer, intent(in) :: iout,m, n
|
||||
integer, intent(out) :: ierror
|
||||
real(kind(1.d0)), intent(in) :: a(*)
|
||||
integer, intent(in) :: ia1(*), ia2(*), infoa(*)
|
||||
character, intent(in) :: fida*5, descra*11
|
||||
end subroutine dcsprt
|
||||
end interface
|
||||
|
||||
!...parameters....
|
||||
type(psb_dspmat_type), intent(in) :: a
|
||||
type(psb_dspmat_type), intent(out) :: b
|
||||
type(psb_desc_type), intent(in) :: desc_a
|
||||
integer, intent(out) :: info
|
||||
!....locals....
|
||||
integer :: int_err(5)
|
||||
real(kind(1.d0)) :: d(1)
|
||||
integer,allocatable :: i_temp(:)
|
||||
real(kind(1.d0)),allocatable :: work_dcsdp(:)
|
||||
integer :: ia1_size,ia2_size,aspk_size,&
|
||||
& err_act,i,np,me,n_col,l_dcsdp
|
||||
integer :: lwork_dcsdp,dectype
|
||||
integer :: ictxt,n_row
|
||||
character :: check*1, trans*1, unitd*1
|
||||
|
||||
logical, parameter :: debug=.false.
|
||||
character(len=20) :: name, ch_err
|
||||
|
||||
if(psb_get_errstatus() /= 0) return
|
||||
info=0
|
||||
name = 'psb_dspcnv'
|
||||
call psb_erractionsave(err_act)
|
||||
|
||||
|
||||
ictxt = psb_cd_get_context(desc_a)
|
||||
dectype = psb_cd_get_dectype(desc_a)
|
||||
n_row = psb_cd_get_local_rows(desc_a)
|
||||
n_col = psb_cd_get_local_cols(desc_a)
|
||||
|
||||
! check on blacs grid
|
||||
call psb_info(ictxt, me, np)
|
||||
if (np == -1) then
|
||||
info = 2010
|
||||
call psb_errpush(info,name)
|
||||
goto 9999
|
||||
endif
|
||||
|
||||
if (.not.psb_is_ok_dec((dectype))) then
|
||||
info = 600
|
||||
int_err(1) = dectype
|
||||
call psb_errpush(info,name,i_err=int_err)
|
||||
goto 9999
|
||||
endif
|
||||
|
||||
if (debug) write (0, *) name,' begin matrix assembly...'
|
||||
|
||||
ia1_size = size(a%ia1)
|
||||
ia2_size = size(a%ia2)
|
||||
aspk_size = size(a%aspk)
|
||||
|
||||
if (debug) write (0, *) name,' sizes',ia1_size,ia2_size,aspk_size
|
||||
|
||||
! convert only without check
|
||||
check='N'
|
||||
trans='N'
|
||||
unitd='U'
|
||||
|
||||
! l_dcsdp is the size requested for dcsdp procedure
|
||||
l_dcsdp=(ia1_size+100)
|
||||
|
||||
b%m=n_row
|
||||
b%k=n_col
|
||||
call psb_sp_all(b,ia1_size,ia2_size,aspk_size,info)
|
||||
allocate(work_dcsdp(l_dcsdp),stat=info)
|
||||
if (info /= 0) then
|
||||
info=4025
|
||||
int_err(1)=l_dcsdp
|
||||
call psb_errpush(info, name, i_err=int_err,a_err='real(kind(1.d0))')
|
||||
goto 9999
|
||||
endif
|
||||
|
||||
lwork_dcsdp=size(work_dcsdp)
|
||||
! set infoa(1) to nnzero
|
||||
b%pl(:) = 0
|
||||
b%pr(:) = 0
|
||||
|
||||
if (debug) write (0, *) name,' calling dcsdp',lwork_dcsdp,&
|
||||
&size(work_dcsdp)
|
||||
! convert aspk,ia1,ia2 in requested representation mode
|
||||
if (debug) then
|
||||
|
||||
endif
|
||||
! result is put in b
|
||||
call dcsdp(check,trans,n_row,n_col,unitd,d,a%fida,a%descra,&
|
||||
& a%aspk,a%ia1,a%ia2,a%infoa,&
|
||||
& b%pl,b%fida,b%descra,b%aspk,b%ia1,b%ia2,b%infoa,b%pr,&
|
||||
& size(b%aspk),size(b%ia1),size(b%ia2),&
|
||||
& work_dcsdp,size(work_dcsdp),info)
|
||||
|
||||
if(info /= psb_no_err_) then
|
||||
info=4010
|
||||
ch_err='dcsdp'
|
||||
call psb_errpush(info, name, a_err=ch_err)
|
||||
goto 9999
|
||||
end if
|
||||
|
||||
!
|
||||
! hmmm, have to fix b%pl and b%pr according to a%pl and a%pr!!!
|
||||
! should work (crossed fingers :-)
|
||||
if (a%pr(1) /= 0) then
|
||||
if (b%pr(1) /= 0) then
|
||||
allocate(i_temp(n_col))
|
||||
do i=1, n_col
|
||||
i_temp(i) = b%pr(a%pr(i))
|
||||
enddo
|
||||
call psb_transfer(i_temp,b%pr,info)
|
||||
else
|
||||
allocate(i_temp(n_col))
|
||||
do i=1, n_col
|
||||
i_temp(i) = a%pr(i)
|
||||
enddo
|
||||
call psb_transfer(i_temp,b%pr,info)
|
||||
endif
|
||||
endif
|
||||
if (a%pl(1) /= 0) then
|
||||
if (b%pr(1) /= 0) then
|
||||
allocate(i_temp(n_row))
|
||||
do i=1, n_row
|
||||
i_temp(i) = a%pl(b%pl(i))
|
||||
enddo
|
||||
call psb_transfer(i_temp,b%pl,info)
|
||||
else
|
||||
allocate(i_temp(n_row))
|
||||
do i=1, n_row
|
||||
i_temp(i) = a%pl(i)
|
||||
enddo
|
||||
call psb_transfer(i_temp,b%pl,info)
|
||||
endif
|
||||
endif
|
||||
|
||||
|
||||
if (debug) write (0, *) me,name,' from dcsdp ',&
|
||||
&b%fida,' pl ', b%pl(:),'pr',b%pr(:)
|
||||
|
||||
call psb_erractionrestore(err_act)
|
||||
return
|
||||
|
||||
9999 continue
|
||||
call psb_erractionrestore(err_act)
|
||||
if (err_act == psb_act_abort_) then
|
||||
call psb_error(ictxt)
|
||||
return
|
||||
end if
|
||||
return
|
||||
|
||||
end subroutine psb_dspcnv
|
||||
@ -1,243 +0,0 @@
|
||||
!!$
|
||||
!!$ Parallel Sparse BLAS v2.0
|
||||
!!$ (C) Copyright 2006 Salvatore Filippone University of Rome Tor Vergata
|
||||
!!$ Alfredo Buttari University of Rome Tor Vergata
|
||||
!!$
|
||||
!!$ Redistribution and use in source and binary forms, with or without
|
||||
!!$ modification, are permitted provided that the following conditions
|
||||
!!$ are met:
|
||||
!!$ 1. Redistributions of source code must retain the above copyright
|
||||
!!$ notice, this list of conditions and the following disclaimer.
|
||||
!!$ 2. Redistributions in binary form must reproduce the above copyright
|
||||
!!$ notice, this list of conditions, and the following disclaimer in the
|
||||
!!$ documentation and/or other materials provided with the distribution.
|
||||
!!$ 3. The name of the PSBLAS group or the names of its contributors may
|
||||
!!$ not be used to endorse or promote products derived from this
|
||||
!!$ software without specific written permission.
|
||||
!!$
|
||||
!!$ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
!!$ ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
!!$ TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
!!$ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PSBLAS GROUP OR ITS CONTRIBUTORS
|
||||
!!$ BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
!!$ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
!!$ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
!!$ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
!!$ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
!!$ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
!!$ POSSIBILITY OF SUCH DAMAGE.
|
||||
!!$
|
||||
!!$
|
||||
! File: psb_zspcnv.f90
|
||||
!
|
||||
! Subroutine: psb_zspcnv
|
||||
! converts sparse matrix a into b
|
||||
!
|
||||
! Parameters:
|
||||
! a - type(<psb_zspmat_type>). The sparse input matrix.
|
||||
! b - type(<psb_zspmat_type>). The sparse output matrix.
|
||||
! desc_a - type(<psb_desc_type>). The communication descriptor.
|
||||
! info - integer. Eventually returns an error code.
|
||||
!
|
||||
subroutine psb_zspcnv(a,b,desc_a,info)
|
||||
|
||||
use psb_descriptor_type
|
||||
use psb_spmat_type
|
||||
use psb_realloc_mod
|
||||
use psb_serial_mod
|
||||
use psb_const_mod
|
||||
use psb_error_mod
|
||||
use psb_penv_mod
|
||||
implicit none
|
||||
|
||||
interface zcsdp
|
||||
|
||||
subroutine zcsdp(check,trans,m,n,unitd,d,&
|
||||
& fida,descra,a,ia1,ia2,infoa,&
|
||||
& pl,fidh,descrh,h,ih1,ih2,infoh,pr,lh,lh1,lh2,&
|
||||
& work,lwork,ierror)
|
||||
integer, intent(in) :: lh, lwork, lh1, lh2, m, n
|
||||
integer, intent(out) :: ierror
|
||||
character, intent(in) :: check, trans, unitd
|
||||
complex(kind(1.d0)), intent(in) :: d(*), a(*)
|
||||
complex(kind(1.d0)), intent(out) :: h(*)
|
||||
complex(kind(1.d0)), intent(inout) :: work(*)
|
||||
integer, intent(in) :: ia1(*), ia2(*), infoa(*)
|
||||
integer, intent(out) :: ih1(*), ih2(*), pl(*),pr(*), infoh(*)
|
||||
character, intent(in) :: fida*5, descra*11
|
||||
character, intent(out) :: fidh*5, descrh*11
|
||||
end subroutine zcsdp
|
||||
end interface
|
||||
|
||||
|
||||
interface zcsrp
|
||||
|
||||
subroutine zcsrp(trans,m,n,fida,descra,ia1,ia2,&
|
||||
& infoa,p,work,lwork,ierror)
|
||||
integer, intent(in) :: m, n, lwork
|
||||
integer, intent(out) :: ierror
|
||||
character, intent(in) :: trans
|
||||
complex(kind(1.d0)), intent(inout) :: work(*)
|
||||
integer, intent(in) :: p(*)
|
||||
integer, intent(inout) :: ia1(*), ia2(*), infoa(*)
|
||||
character, intent(in) :: fida*5, descra*11
|
||||
end subroutine zcsrp
|
||||
end interface
|
||||
|
||||
interface zcsprt
|
||||
subroutine zcsprt(m,n,fida,descra,a,ia1,ia2,infoa ,iout,ierror)
|
||||
integer, intent(in) :: iout,m, n
|
||||
integer, intent(out) :: ierror
|
||||
complex(kind(1.d0)), intent(in) :: a(*)
|
||||
integer, intent(in) :: ia1(*), ia2(*), infoa(*)
|
||||
character, intent(in) :: fida*5, descra*11
|
||||
end subroutine zcsprt
|
||||
end interface
|
||||
|
||||
!...parameters....
|
||||
type(psb_zspmat_type), intent(in) :: a
|
||||
type(psb_zspmat_type), intent(out) :: b
|
||||
type(psb_desc_type), intent(in) :: desc_a
|
||||
integer, intent(out) :: info
|
||||
!....locals....
|
||||
integer :: int_err(5)
|
||||
complex(kind(1.d0)) :: d(1)
|
||||
integer,allocatable :: i_temp(:)
|
||||
complex(kind(1.d0)),allocatable :: work_dcsdp(:)
|
||||
integer :: ia1_size,ia2_size,aspk_size,err_act&
|
||||
& ,i,err,np,me,n_col,l_dcsdp
|
||||
integer :: lwork_dcsdp,dectype
|
||||
integer :: ictxt,n_row
|
||||
character :: check*1, trans*1, unitd*1
|
||||
|
||||
logical, parameter :: debug=.false.
|
||||
character(len=20) :: name, ch_err
|
||||
|
||||
if(psb_get_errstatus() /= 0) return
|
||||
info=0
|
||||
name = 'psb_zspcnv'
|
||||
call psb_erractionsave(err_act)
|
||||
|
||||
|
||||
ictxt = psb_cd_get_context(desc_a)
|
||||
dectype = psb_cd_get_dectype(desc_a)
|
||||
n_row = psb_cd_get_local_rows(desc_a)
|
||||
n_col = psb_cd_get_local_cols(desc_a)
|
||||
|
||||
! check on blacs grid
|
||||
call psb_info(ictxt, me, np)
|
||||
if (np == -1) then
|
||||
info = 2010
|
||||
call psb_errpush(info,name)
|
||||
goto 9999
|
||||
endif
|
||||
|
||||
if (.not.psb_is_ok_dec((dectype))) then
|
||||
info = 600
|
||||
int_err(1) = dectype
|
||||
call psb_errpush(info,name,i_err=int_err)
|
||||
goto 9999
|
||||
endif
|
||||
|
||||
if (debug) write (0, *) name,' begin matrix assembly...'
|
||||
|
||||
ia1_size = size(a%ia1)
|
||||
ia2_size = size(a%ia2)
|
||||
aspk_size = size(a%aspk)
|
||||
|
||||
if (debug) write (0, *) name,' sizes',ia1_size,ia2_size,aspk_size
|
||||
|
||||
! convert only without check
|
||||
check='N'
|
||||
trans='N'
|
||||
unitd='U'
|
||||
|
||||
! l_dcsdp is the size requested for dcsdp procedure
|
||||
l_dcsdp=(ia1_size+100)
|
||||
|
||||
b%m=n_row
|
||||
b%k=n_col
|
||||
call psb_sp_all(b,ia1_size,ia2_size,aspk_size,info)
|
||||
allocate(work_dcsdp(l_dcsdp),stat=info)
|
||||
if (info /= 0) then
|
||||
info=4025
|
||||
int_err(1)=l_dcsdp
|
||||
call psb_errpush(info, name, i_err=int_err,a_err='real(kind(1.d0))')
|
||||
goto 9999
|
||||
endif
|
||||
|
||||
lwork_dcsdp=size(work_dcsdp)
|
||||
! set infoa(1) to nnzero
|
||||
b%pl(:) = 0
|
||||
b%pr(:) = 0
|
||||
|
||||
if (debug) write (0, *) name,' calling dcsdp',lwork_dcsdp,&
|
||||
&size(work_dcsdp)
|
||||
! convert aspk,ia1,ia2 in requested representation mode
|
||||
if (debug) then
|
||||
|
||||
endif
|
||||
! result is put in b
|
||||
call zcsdp(check,trans,n_row,n_col,unitd,d,a%fida,a%descra,&
|
||||
& a%aspk,a%ia1,a%ia2,a%infoa,&
|
||||
& b%pl,b%fida,b%descra,b%aspk,b%ia1,b%ia2,b%infoa,b%pr,&
|
||||
& size(b%aspk),size(b%ia1),size(b%ia2),&
|
||||
& work_dcsdp,size(work_dcsdp),info)
|
||||
|
||||
if(info /= psb_no_err_) then
|
||||
info=4010
|
||||
ch_err='zcsdp'
|
||||
call psb_errpush(info, name, a_err=ch_err)
|
||||
goto 9999
|
||||
end if
|
||||
|
||||
!
|
||||
! hmmm, have to fix b%pl and b%pr according to a%pl and a%pr!!!
|
||||
! should work (crossed fingers :-)
|
||||
if (a%pr(1) /= 0) then
|
||||
if (b%pr(1) /= 0) then
|
||||
allocate(i_temp(n_col))
|
||||
do i=1, n_col
|
||||
i_temp(i) = b%pr(a%pr(i))
|
||||
enddo
|
||||
call psb_transfer(i_temp,b%pr,info)
|
||||
else
|
||||
allocate(i_temp(n_col))
|
||||
do i=1, n_col
|
||||
i_temp(i) = a%pr(i)
|
||||
enddo
|
||||
call psb_transfer(i_temp,b%pr,info)
|
||||
endif
|
||||
endif
|
||||
if (a%pl(1) /= 0) then
|
||||
if (b%pr(1) /= 0) then
|
||||
allocate(i_temp(n_row))
|
||||
do i=1, n_row
|
||||
i_temp(i) = a%pl(b%pl(i))
|
||||
enddo
|
||||
call psb_transfer(i_temp,b%pl,info)
|
||||
else
|
||||
allocate(i_temp(n_row))
|
||||
do i=1, n_row
|
||||
i_temp(i) = a%pl(i)
|
||||
enddo
|
||||
call psb_transfer(i_temp,b%pl,info)
|
||||
endif
|
||||
endif
|
||||
|
||||
|
||||
if (debug) write (0, *) me,name,' from zcsdp ',&
|
||||
&b%fida,' pl ', b%pl(:),'pr',b%pr(:)
|
||||
|
||||
call psb_erractionrestore(err_act)
|
||||
return
|
||||
|
||||
9999 continue
|
||||
call psb_erractionrestore(err_act)
|
||||
if (err_act == psb_act_abort_) then
|
||||
call psb_error(ictxt)
|
||||
return
|
||||
end if
|
||||
return
|
||||
|
||||
end subroutine psb_zspcnv
|
||||
Loading…
Reference in New Issue