|
|
|
@ -1,9 +1,9 @@
|
|
|
|
|
!
|
|
|
|
|
!
|
|
|
|
|
! Parallel Sparse BLAS version 3.5
|
|
|
|
|
! (C) Copyright 2006-2018
|
|
|
|
|
! Salvatore Filippone
|
|
|
|
|
! Alfredo Buttari
|
|
|
|
|
!
|
|
|
|
|
! Salvatore Filippone
|
|
|
|
|
! Alfredo Buttari
|
|
|
|
|
!
|
|
|
|
|
! Redistribution and use in source and binary forms, with or without
|
|
|
|
|
! modification, are permitted provided that the following conditions
|
|
|
|
|
! are met:
|
|
|
|
@ -15,7 +15,7 @@
|
|
|
|
|
! 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
|
|
|
|
@ -27,23 +27,23 @@
|
|
|
|
|
! 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_d_pde2d.f90
|
|
|
|
|
!
|
|
|
|
|
! Program: psb_d_pde2d
|
|
|
|
|
! This sample program solves a linear system obtained by discretizing a
|
|
|
|
|
! PDE with Dirichlet BCs.
|
|
|
|
|
!
|
|
|
|
|
! PDE with Dirichlet BCs.
|
|
|
|
|
!
|
|
|
|
|
!
|
|
|
|
|
! The PDE is a general second order equation in 2d
|
|
|
|
|
!
|
|
|
|
|
! a1 dd(u) a2 dd(u) b1 d(u) b2 d(u)
|
|
|
|
|
! a1 dd(u) a2 dd(u) b1 d(u) b2 d(u)
|
|
|
|
|
! - ------ - ------ ----- + ------ + c u = f
|
|
|
|
|
! dxdx dydy dx dy
|
|
|
|
|
! dxdx dydy dx dy
|
|
|
|
|
!
|
|
|
|
|
! with Dirichlet boundary conditions
|
|
|
|
|
! u = g
|
|
|
|
|
! u = g
|
|
|
|
|
!
|
|
|
|
|
! on the unit square 0<=x,y<=1.
|
|
|
|
|
!
|
|
|
|
@ -63,31 +63,31 @@ module psb_d_pde2d_mod
|
|
|
|
|
& psb_dspmat_type, psb_d_vect_type, dzero,&
|
|
|
|
|
& psb_d_base_sparse_mat, psb_d_base_vect_type, psb_i_base_vect_type
|
|
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
interface
|
|
|
|
|
function d_func_2d(x,y) result(val)
|
|
|
|
|
import :: psb_dpk_
|
|
|
|
|
real(psb_dpk_), intent(in) :: x,y
|
|
|
|
|
real(psb_dpk_) :: val
|
|
|
|
|
end function d_func_2d
|
|
|
|
|
end interface
|
|
|
|
|
end interface
|
|
|
|
|
|
|
|
|
|
interface psb_gen_pde2d
|
|
|
|
|
module procedure psb_d_gen_pde2d
|
|
|
|
|
end interface psb_gen_pde2d
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
contains
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function d_null_func_2d(x,y) result(val)
|
|
|
|
|
|
|
|
|
|
real(psb_dpk_), intent(in) :: x,y
|
|
|
|
|
real(psb_dpk_) :: val
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val = dzero
|
|
|
|
|
|
|
|
|
|
end function d_null_func_2d
|
|
|
|
|
|
|
|
|
|
!
|
|
|
|
|
! functions parametrizing the differential equation
|
|
|
|
|
! functions parametrizing the differential equation
|
|
|
|
|
!
|
|
|
|
|
|
|
|
|
|
!
|
|
|
|
@ -101,48 +101,48 @@ contains
|
|
|
|
|
!
|
|
|
|
|
function b1(x,y)
|
|
|
|
|
use psb_base_mod, only : psb_dpk_, done, dzero
|
|
|
|
|
implicit none
|
|
|
|
|
implicit none
|
|
|
|
|
real(psb_dpk_) :: b1
|
|
|
|
|
real(psb_dpk_), intent(in) :: x,y
|
|
|
|
|
b1=dzero
|
|
|
|
|
end function b1
|
|
|
|
|
function b2(x,y)
|
|
|
|
|
use psb_base_mod, only : psb_dpk_, done, dzero
|
|
|
|
|
implicit none
|
|
|
|
|
implicit none
|
|
|
|
|
real(psb_dpk_) :: b2
|
|
|
|
|
real(psb_dpk_), intent(in) :: x,y
|
|
|
|
|
b2=dzero
|
|
|
|
|
end function b2
|
|
|
|
|
function c(x,y)
|
|
|
|
|
use psb_base_mod, only : psb_dpk_, done, dzero
|
|
|
|
|
implicit none
|
|
|
|
|
implicit none
|
|
|
|
|
real(psb_dpk_) :: c
|
|
|
|
|
real(psb_dpk_), intent(in) :: x,y
|
|
|
|
|
c=0.d0
|
|
|
|
|
end function c
|
|
|
|
|
function a1(x,y)
|
|
|
|
|
use psb_base_mod, only : psb_dpk_, done, dzero
|
|
|
|
|
implicit none
|
|
|
|
|
real(psb_dpk_) :: a1
|
|
|
|
|
implicit none
|
|
|
|
|
real(psb_dpk_) :: a1
|
|
|
|
|
real(psb_dpk_), intent(in) :: x,y
|
|
|
|
|
a1=done/80
|
|
|
|
|
end function a1
|
|
|
|
|
function a2(x,y)
|
|
|
|
|
use psb_base_mod, only : psb_dpk_, done, dzero
|
|
|
|
|
implicit none
|
|
|
|
|
implicit none
|
|
|
|
|
real(psb_dpk_) :: a2
|
|
|
|
|
real(psb_dpk_), intent(in) :: x,y
|
|
|
|
|
a2=done/80
|
|
|
|
|
end function a2
|
|
|
|
|
function g(x,y)
|
|
|
|
|
use psb_base_mod, only : psb_dpk_, done, dzero
|
|
|
|
|
implicit none
|
|
|
|
|
implicit none
|
|
|
|
|
real(psb_dpk_) :: g
|
|
|
|
|
real(psb_dpk_), intent(in) :: x,y
|
|
|
|
|
g = dzero
|
|
|
|
|
if (x == done) then
|
|
|
|
|
g = done
|
|
|
|
|
else if (x == dzero) then
|
|
|
|
|
else if (x == dzero) then
|
|
|
|
|
g = exp(-y**2)
|
|
|
|
|
end if
|
|
|
|
|
end function g
|
|
|
|
@ -150,7 +150,7 @@ contains
|
|
|
|
|
|
|
|
|
|
!
|
|
|
|
|
! subroutine to allocate and fill in the coefficient matrix and
|
|
|
|
|
! the rhs.
|
|
|
|
|
! the rhs.
|
|
|
|
|
!
|
|
|
|
|
subroutine psb_d_gen_pde2d(ictxt,idim,a,bv,xv,desc_a,afmt,info,&
|
|
|
|
|
& f,amold,vmold,imold,partition,nrl,iv)
|
|
|
|
@ -158,13 +158,13 @@ contains
|
|
|
|
|
use psb_util_mod
|
|
|
|
|
!
|
|
|
|
|
! Discretizes the partial differential equation
|
|
|
|
|
!
|
|
|
|
|
! a1 dd(u) a2 dd(u) b1 d(u) b2 d(u)
|
|
|
|
|
!
|
|
|
|
|
! a1 dd(u) a2 dd(u) b1 d(u) b2 d(u)
|
|
|
|
|
! - ------ - ------ + ----- + ------ + c u = f
|
|
|
|
|
! dxdx dydy dx dy
|
|
|
|
|
! dxdx dydy dx dy
|
|
|
|
|
!
|
|
|
|
|
! with Dirichlet boundary conditions
|
|
|
|
|
! u = g
|
|
|
|
|
! u = g
|
|
|
|
|
!
|
|
|
|
|
! on the unit square 0<=x,y<=1.
|
|
|
|
|
!
|
|
|
|
@ -221,7 +221,7 @@ contains
|
|
|
|
|
call psb_info(ictxt, iam, np)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (present(f)) then
|
|
|
|
|
if (present(f)) then
|
|
|
|
|
f_ => f
|
|
|
|
|
else
|
|
|
|
|
f_ => d_null_func_2d
|
|
|
|
@ -241,9 +241,9 @@ contains
|
|
|
|
|
else
|
|
|
|
|
partition_ = 3
|
|
|
|
|
end if
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
! initialize array descriptor and sparse matrix storage. provide an
|
|
|
|
|
! estimate of the number of non zeroes
|
|
|
|
|
! estimate of the number of non zeroes
|
|
|
|
|
|
|
|
|
|
m = (1_psb_lpk_)*idim*idim
|
|
|
|
|
n = m
|
|
|
|
@ -252,8 +252,8 @@ contains
|
|
|
|
|
t0 = psb_wtime()
|
|
|
|
|
select case(partition_)
|
|
|
|
|
case(1)
|
|
|
|
|
! A BLOCK partition
|
|
|
|
|
if (present(nrl)) then
|
|
|
|
|
! A BLOCK partition
|
|
|
|
|
if (present(nrl)) then
|
|
|
|
|
nr = nrl
|
|
|
|
|
else
|
|
|
|
|
!
|
|
|
|
@ -264,46 +264,46 @@ contains
|
|
|
|
|
end if
|
|
|
|
|
|
|
|
|
|
nt = nr
|
|
|
|
|
call psb_sum(ictxt,nt)
|
|
|
|
|
if (nt /= m) then
|
|
|
|
|
call psb_sum(ictxt,nt)
|
|
|
|
|
if (nt /= m) then
|
|
|
|
|
write(psb_err_unit,*) iam, 'Initialization error ',nr,nt,m
|
|
|
|
|
info = -1
|
|
|
|
|
call psb_barrier(ictxt)
|
|
|
|
|
call psb_abort(ictxt)
|
|
|
|
|
return
|
|
|
|
|
return
|
|
|
|
|
end if
|
|
|
|
|
|
|
|
|
|
!
|
|
|
|
|
! First example of use of CDALL: specify for each process a number of
|
|
|
|
|
! contiguous rows
|
|
|
|
|
!
|
|
|
|
|
!
|
|
|
|
|
call psb_cdall(ictxt,desc_a,info,nl=nr)
|
|
|
|
|
myidx = desc_a%get_global_indices()
|
|
|
|
|
nlr = size(myidx)
|
|
|
|
|
|
|
|
|
|
case(2)
|
|
|
|
|
! A partition defined by the user through IV
|
|
|
|
|
|
|
|
|
|
if (present(iv)) then
|
|
|
|
|
|
|
|
|
|
if (present(iv)) then
|
|
|
|
|
if (size(iv) /= m) then
|
|
|
|
|
write(psb_err_unit,*) iam, 'Initialization error: wrong IV size',size(iv),m
|
|
|
|
|
info = -1
|
|
|
|
|
call psb_barrier(ictxt)
|
|
|
|
|
call psb_abort(ictxt)
|
|
|
|
|
return
|
|
|
|
|
return
|
|
|
|
|
end if
|
|
|
|
|
else
|
|
|
|
|
write(psb_err_unit,*) iam, 'Initialization error: IV not present'
|
|
|
|
|
info = -1
|
|
|
|
|
call psb_barrier(ictxt)
|
|
|
|
|
call psb_abort(ictxt)
|
|
|
|
|
return
|
|
|
|
|
return
|
|
|
|
|
end if
|
|
|
|
|
|
|
|
|
|
!
|
|
|
|
|
! Second example of use of CDALL: specify for each row the
|
|
|
|
|
! process that owns it
|
|
|
|
|
!
|
|
|
|
|
! process that owns it
|
|
|
|
|
!
|
|
|
|
|
call psb_cdall(ictxt,desc_a,info,vg=iv)
|
|
|
|
|
myidx = desc_a%get_global_indices()
|
|
|
|
|
nlr = size(myidx)
|
|
|
|
@ -318,7 +318,7 @@ contains
|
|
|
|
|
npy = npdims(2)
|
|
|
|
|
|
|
|
|
|
allocate(bndx(0:npx),bndy(0:npy))
|
|
|
|
|
! We can reuse idx2ijk for process indices as well.
|
|
|
|
|
! We can reuse idx2ijk for process indices as well.
|
|
|
|
|
call idx2ijk(iamx,iamy,iam,npx,npy,base=0)
|
|
|
|
|
! Now let's split the 2D square in rectangles
|
|
|
|
|
call dist1Didx(bndx,idim,npx)
|
|
|
|
@ -326,7 +326,7 @@ contains
|
|
|
|
|
call dist1Didx(bndy,idim,npy)
|
|
|
|
|
myny = bndy(iamy+1)-bndy(iamy)
|
|
|
|
|
|
|
|
|
|
! How many indices do I own?
|
|
|
|
|
! How many indices do I own?
|
|
|
|
|
nlr = mynx*myny
|
|
|
|
|
allocate(myidx(nlr))
|
|
|
|
|
! Now, let's generate the list of indices I own
|
|
|
|
@ -348,9 +348,9 @@ contains
|
|
|
|
|
!
|
|
|
|
|
! Third example of use of CDALL: specify for each process
|
|
|
|
|
! the set of global indices it owns.
|
|
|
|
|
!
|
|
|
|
|
!
|
|
|
|
|
call psb_cdall(ictxt,desc_a,info,vl=myidx)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case default
|
|
|
|
|
write(psb_err_unit,*) iam, 'Initialization error: should not get here'
|
|
|
|
|
info = -1
|
|
|
|
@ -359,9 +359,9 @@ contains
|
|
|
|
|
return
|
|
|
|
|
end select
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (info == psb_success_) call psb_spall(a,desc_a,info,nnz=nnz)
|
|
|
|
|
! define rhs from boundary conditions; also build initial guess
|
|
|
|
|
! define rhs from boundary conditions; also build initial guess
|
|
|
|
|
if (info == psb_success_) call psb_geall(xv,desc_a,info)
|
|
|
|
|
if (info == psb_success_) call psb_geall(bv,desc_a,info)
|
|
|
|
|
|
|
|
|
@ -376,12 +376,12 @@ contains
|
|
|
|
|
end if
|
|
|
|
|
|
|
|
|
|
! we build an auxiliary matrix consisting of one row at a
|
|
|
|
|
! time; just a small matrix. might be extended to generate
|
|
|
|
|
! a bunch of rows per call.
|
|
|
|
|
!
|
|
|
|
|
! time; just a small matrix. might be extended to generate
|
|
|
|
|
! a bunch of rows per call.
|
|
|
|
|
!
|
|
|
|
|
allocate(val(20*nb),irow(20*nb),&
|
|
|
|
|
&icol(20*nb),stat=info)
|
|
|
|
|
if (info /= psb_success_ ) then
|
|
|
|
|
if (info /= psb_success_ ) then
|
|
|
|
|
info=psb_err_alloc_dealloc_
|
|
|
|
|
call psb_errpush(info,name)
|
|
|
|
|
goto 9999
|
|
|
|
@ -394,11 +394,11 @@ contains
|
|
|
|
|
call psb_barrier(ictxt)
|
|
|
|
|
t1 = psb_wtime()
|
|
|
|
|
do ii=1, nlr,nb
|
|
|
|
|
ib = min(nb,nlr-ii+1)
|
|
|
|
|
ib = min(nb,nlr-ii+1)
|
|
|
|
|
icoeff = 1
|
|
|
|
|
do k=1,ib
|
|
|
|
|
i=ii+k-1
|
|
|
|
|
! local matrix pointer
|
|
|
|
|
! local matrix pointer
|
|
|
|
|
glob_row=myidx(i)
|
|
|
|
|
! compute gridpoint coordinates
|
|
|
|
|
call idx2ijk(ix,iy,glob_row,idim,idim)
|
|
|
|
@ -408,11 +408,11 @@ contains
|
|
|
|
|
|
|
|
|
|
zt(k) = f_(x,y)
|
|
|
|
|
! internal point: build discretization
|
|
|
|
|
!
|
|
|
|
|
!
|
|
|
|
|
! term depending on (x-1,y)
|
|
|
|
|
!
|
|
|
|
|
val(icoeff) = -a1(x,y)/sqdeltah-b1(x,y)/deltah2
|
|
|
|
|
if (ix == 1) then
|
|
|
|
|
if (ix == 1) then
|
|
|
|
|
zt(k) = g(dzero,y)*(-val(icoeff)) + zt(k)
|
|
|
|
|
else
|
|
|
|
|
call ijk2idx(icol(icoeff),ix-1,iy,idim,idim)
|
|
|
|
@ -421,7 +421,7 @@ contains
|
|
|
|
|
endif
|
|
|
|
|
! term depending on (x,y-1)
|
|
|
|
|
val(icoeff) = -a2(x,y)/sqdeltah-b2(x,y)/deltah2
|
|
|
|
|
if (iy == 1) then
|
|
|
|
|
if (iy == 1) then
|
|
|
|
|
zt(k) = g(x,dzero)*(-val(icoeff)) + zt(k)
|
|
|
|
|
else
|
|
|
|
|
call ijk2idx(icol(icoeff),ix,iy-1,idim,idim)
|
|
|
|
@ -433,10 +433,10 @@ contains
|
|
|
|
|
val(icoeff)=(2*done)*(a1(x,y) + a2(x,y))/sqdeltah + c(x,y)
|
|
|
|
|
call ijk2idx(icol(icoeff),ix,iy,idim,idim)
|
|
|
|
|
irow(icoeff) = glob_row
|
|
|
|
|
icoeff = icoeff+1
|
|
|
|
|
icoeff = icoeff+1
|
|
|
|
|
! term depending on (x,y+1)
|
|
|
|
|
val(icoeff)=-a2(x,y)/sqdeltah+b2(x,y)/deltah2
|
|
|
|
|
if (iy == idim) then
|
|
|
|
|
if (iy == idim) then
|
|
|
|
|
zt(k) = g(x,done)*(-val(icoeff)) + zt(k)
|
|
|
|
|
else
|
|
|
|
|
call ijk2idx(icol(icoeff),ix,iy+1,idim,idim)
|
|
|
|
@ -445,7 +445,7 @@ contains
|
|
|
|
|
endif
|
|
|
|
|
! term depending on (x+1,y)
|
|
|
|
|
val(icoeff)=-a1(x,y)/sqdeltah+b1(x,y)/deltah2
|
|
|
|
|
if (ix==idim) then
|
|
|
|
|
if (ix==idim) then
|
|
|
|
|
zt(k) = g(done,y)*(-val(icoeff)) + zt(k)
|
|
|
|
|
else
|
|
|
|
|
call ijk2idx(icol(icoeff),ix+1,iy,idim,idim)
|
|
|
|
@ -479,8 +479,8 @@ contains
|
|
|
|
|
tcdasb = psb_wtime()-t1
|
|
|
|
|
call psb_barrier(ictxt)
|
|
|
|
|
t1 = psb_wtime()
|
|
|
|
|
if (info == psb_success_) then
|
|
|
|
|
if (present(amold)) then
|
|
|
|
|
if (info == psb_success_) then
|
|
|
|
|
if (present(amold)) then
|
|
|
|
|
call psb_spasb(a,desc_a,info,dupl=psb_dupl_err_,mold=amold)
|
|
|
|
|
else
|
|
|
|
|
call psb_spasb(a,desc_a,info,dupl=psb_dupl_err_,afmt=afmt)
|
|
|
|
@ -503,7 +503,7 @@ contains
|
|
|
|
|
end if
|
|
|
|
|
tasb = psb_wtime()-t1
|
|
|
|
|
call psb_barrier(ictxt)
|
|
|
|
|
ttot = psb_wtime() - t0
|
|
|
|
|
ttot = psb_wtime() - t0
|
|
|
|
|
|
|
|
|
|
call psb_amx(ictxt,talc)
|
|
|
|
|
call psb_amx(ictxt,tgen)
|
|
|
|
@ -544,9 +544,9 @@ program psb_d_pde2d
|
|
|
|
|
integer(psb_ipk_) :: idim
|
|
|
|
|
integer(psb_epk_) :: system_size
|
|
|
|
|
|
|
|
|
|
! miscellaneous
|
|
|
|
|
! miscellaneous
|
|
|
|
|
real(psb_dpk_), parameter :: one = done
|
|
|
|
|
real(psb_dpk_) :: t1, t2, tprec
|
|
|
|
|
real(psb_dpk_) :: t1, t2, tprec
|
|
|
|
|
|
|
|
|
|
! sparse matrix and preconditioner
|
|
|
|
|
type(psb_dspmat_type) :: a
|
|
|
|
@ -563,6 +563,14 @@ program psb_d_pde2d
|
|
|
|
|
integer(psb_epk_) :: amatsize, precsize, descsize, d2size
|
|
|
|
|
real(psb_dpk_) :: err, eps
|
|
|
|
|
|
|
|
|
|
! Parameters for solvers in Block-Jacobi preconditioner
|
|
|
|
|
type ainvparms
|
|
|
|
|
character(len=12) :: alg, orth_alg, ilu_alg, ilut_scale
|
|
|
|
|
integer(psb_ipk_) :: fill, inv_fill
|
|
|
|
|
real(psb_dpk_) :: thresh, inv_thresh
|
|
|
|
|
end type ainvparms
|
|
|
|
|
type(ainvparms) :: parms
|
|
|
|
|
|
|
|
|
|
! other variables
|
|
|
|
|
integer(psb_ipk_) :: info, i
|
|
|
|
|
character(len=20) :: name,ch_err
|
|
|
|
@ -574,7 +582,7 @@ program psb_d_pde2d
|
|
|
|
|
call psb_init(ictxt)
|
|
|
|
|
call psb_info(ictxt,iam,np)
|
|
|
|
|
|
|
|
|
|
if (iam < 0) then
|
|
|
|
|
if (iam < 0) then
|
|
|
|
|
! This should not happen, but just in case
|
|
|
|
|
call psb_exit(ictxt)
|
|
|
|
|
stop
|
|
|
|
@ -585,21 +593,21 @@ program psb_d_pde2d
|
|
|
|
|
!
|
|
|
|
|
! Hello world
|
|
|
|
|
!
|
|
|
|
|
if (iam == psb_root_) then
|
|
|
|
|
if (iam == psb_root_) then
|
|
|
|
|
write(*,*) 'Welcome to PSBLAS version: ',psb_version_string_
|
|
|
|
|
write(*,*) 'This is the ',trim(name),' sample program'
|
|
|
|
|
end if
|
|
|
|
|
!
|
|
|
|
|
! get parameters
|
|
|
|
|
!
|
|
|
|
|
call get_parms(ictxt,kmethd,ptype,afmt,idim,istopc,itmax,itrace,irst,ipart)
|
|
|
|
|
call get_parms(ictxt,kmethd,ptype,afmt,idim,istopc,itmax,itrace,irst,ipart,parms)
|
|
|
|
|
|
|
|
|
|
!
|
|
|
|
|
! allocate and fill in the coefficient matrix, rhs and initial guess
|
|
|
|
|
! allocate and fill in the coefficient matrix, rhs and initial guess
|
|
|
|
|
!
|
|
|
|
|
call psb_barrier(ictxt)
|
|
|
|
|
t1 = psb_wtime()
|
|
|
|
|
call psb_gen_pde2d(ictxt,idim,a,bv,xxv,desc_a,afmt,info,partition=ipart)
|
|
|
|
|
call psb_gen_pde2d(ictxt,idim,a,bv,xxv,desc_a,afmt,info,partition=ipart)
|
|
|
|
|
call psb_barrier(ictxt)
|
|
|
|
|
t2 = psb_wtime() - t1
|
|
|
|
|
if(info /= psb_success_) then
|
|
|
|
@ -612,9 +620,28 @@ program psb_d_pde2d
|
|
|
|
|
if (iam == psb_root_) write(psb_out_unit,'(" ")')
|
|
|
|
|
!
|
|
|
|
|
! prepare the preconditioner.
|
|
|
|
|
!
|
|
|
|
|
!
|
|
|
|
|
if(iam == psb_root_) write(psb_out_unit,'("Setting preconditioner to : ",a)')ptype
|
|
|
|
|
call prec%init(ictxt,ptype,info)
|
|
|
|
|
!
|
|
|
|
|
! Set the options for the BJAC preconditioner
|
|
|
|
|
!
|
|
|
|
|
if (psb_toupper(ptype) == "BJAC") then
|
|
|
|
|
call prec%set('sub_solve', parms%alg, info)
|
|
|
|
|
select case (psb_toupper(parms%alg))
|
|
|
|
|
case ("ILU")
|
|
|
|
|
call prec%set('sub_fillin', parms%fill, info)
|
|
|
|
|
call prec%set('ilu_alg', parms%ilu_alg, info)
|
|
|
|
|
case ("ILUT")
|
|
|
|
|
call prec%set('sub_fillin', parms%fill, info)
|
|
|
|
|
call prec%set('sub_iluthrs', parms%thresh, info)
|
|
|
|
|
call prec%set('ilut_scale', parms%ilut_scale, info)
|
|
|
|
|
case default
|
|
|
|
|
! Do nothing, use default setting in the init routine
|
|
|
|
|
end select
|
|
|
|
|
else
|
|
|
|
|
! nothing to set for NONE or DIAG preconditioner
|
|
|
|
|
end if
|
|
|
|
|
|
|
|
|
|
call psb_barrier(ictxt)
|
|
|
|
|
t1 = psb_wtime()
|
|
|
|
@ -634,14 +661,14 @@ program psb_d_pde2d
|
|
|
|
|
if (iam == psb_root_) write(psb_out_unit,'(" ")')
|
|
|
|
|
call prec%descr()
|
|
|
|
|
!
|
|
|
|
|
! iterative method parameters
|
|
|
|
|
! iterative method parameters
|
|
|
|
|
!
|
|
|
|
|
if(iam == psb_root_) write(psb_out_unit,'("Calling iterative method ",a)')kmethd
|
|
|
|
|
call psb_barrier(ictxt)
|
|
|
|
|
t1 = psb_wtime()
|
|
|
|
|
t1 = psb_wtime()
|
|
|
|
|
eps = 1.d-6
|
|
|
|
|
call psb_krylov(kmethd,a,prec,bv,xxv,eps,desc_a,info,&
|
|
|
|
|
& itmax=itmax,iter=iter,err=err,itrace=itrace,istop=istopc,irst=irst)
|
|
|
|
|
call psb_krylov(kmethd,a,prec,bv,xxv,eps,desc_a,info,&
|
|
|
|
|
& itmax=itmax,iter=iter,err=err,itrace=itrace,istop=istopc,irst=irst)
|
|
|
|
|
|
|
|
|
|
if(info /= psb_success_) then
|
|
|
|
|
info=psb_err_from_subroutine_
|
|
|
|
@ -671,14 +698,14 @@ program psb_d_pde2d
|
|
|
|
|
write(psb_out_unit,'("Convergence indicator on exit : ",es12.5)')err
|
|
|
|
|
write(psb_out_unit,'("Info on exit : ",i12)')info
|
|
|
|
|
write(psb_out_unit,'("Total memory occupation for A: ",i12)')amatsize
|
|
|
|
|
write(psb_out_unit,'("Total memory occupation for PREC: ",i12)')precsize
|
|
|
|
|
write(psb_out_unit,'("Total memory occupation for PREC: ",i12)')precsize
|
|
|
|
|
write(psb_out_unit,'("Total memory occupation for DESC_A: ",i12)')descsize
|
|
|
|
|
write(psb_out_unit,'("Storage format for A: ",a)') a%get_fmt()
|
|
|
|
|
write(psb_out_unit,'("Storage format for DESC_A: ",a)') desc_a%get_fmt()
|
|
|
|
|
end if
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
!
|
|
|
|
|
!
|
|
|
|
|
! cleanup storage and exit
|
|
|
|
|
!
|
|
|
|
|
call psb_gefree(bv,desc_a,info)
|
|
|
|
@ -704,13 +731,14 @@ contains
|
|
|
|
|
!
|
|
|
|
|
! get iteration parameters from standard input
|
|
|
|
|
!
|
|
|
|
|
subroutine get_parms(ictxt,kmethd,ptype,afmt,idim,istopc,itmax,itrace,irst,ipart)
|
|
|
|
|
subroutine get_parms(ictxt,kmethd,ptype,afmt,idim,istopc,itmax,itrace,irst,ipart,parms)
|
|
|
|
|
integer(psb_ipk_) :: ictxt
|
|
|
|
|
character(len=*) :: kmethd, ptype, afmt
|
|
|
|
|
integer(psb_ipk_) :: idim, istopc,itmax,itrace,irst,ipart
|
|
|
|
|
integer(psb_ipk_) :: np, iam
|
|
|
|
|
integer(psb_ipk_) :: ip, inp_unit
|
|
|
|
|
character(len=1024) :: filename
|
|
|
|
|
type(ainvparms) :: parms
|
|
|
|
|
|
|
|
|
|
call psb_info(ictxt, iam, np)
|
|
|
|
|
|
|
|
|
@ -739,12 +767,12 @@ contains
|
|
|
|
|
if (ip >= 4) then
|
|
|
|
|
read(inp_unit,*) ipart
|
|
|
|
|
else
|
|
|
|
|
ipart = 3
|
|
|
|
|
ipart = 3
|
|
|
|
|
endif
|
|
|
|
|
if (ip >= 5) then
|
|
|
|
|
read(inp_unit,*) istopc
|
|
|
|
|
else
|
|
|
|
|
istopc=1
|
|
|
|
|
istopc=1
|
|
|
|
|
endif
|
|
|
|
|
if (ip >= 6) then
|
|
|
|
|
read(inp_unit,*) itmax
|
|
|
|
@ -761,8 +789,27 @@ contains
|
|
|
|
|
else
|
|
|
|
|
irst=1
|
|
|
|
|
endif
|
|
|
|
|
if (ip >= 9) then
|
|
|
|
|
read(inp_unit,*) parms%alg
|
|
|
|
|
read(inp_unit,*) parms%ilu_alg
|
|
|
|
|
read(inp_unit,*) parms%ilut_scale
|
|
|
|
|
read(inp_unit,*) parms%fill
|
|
|
|
|
read(inp_unit,*) parms%inv_fill
|
|
|
|
|
read(inp_unit,*) parms%thresh
|
|
|
|
|
read(inp_unit,*) parms%inv_thresh
|
|
|
|
|
read(inp_unit,*) parms%orth_alg
|
|
|
|
|
else
|
|
|
|
|
parms%alg = 'ILU' ! Block Solver ILU,ILUT,INVK,AINVT,AORTH
|
|
|
|
|
parms%ilu_alg = 'NONE' ! If ILU : MILU or NONE othewise ignored
|
|
|
|
|
parms%ilut_scale = 'NONE' ! If ILUT: NONE, MAXVAL, DIAG, ARWSUM, ACLSUM, ARCSUM
|
|
|
|
|
parms%fill = 0 ! Level of fill for forward factorization
|
|
|
|
|
parms%inv_fill = 1 ! Level of fill for inverse factorization (only INVK)
|
|
|
|
|
parms%thresh = 1E-1_psb_dpk_ ! Threshold for forward factorization
|
|
|
|
|
parms%inv_thresh = 1E-1_psb_dpk_ ! Threshold for inverse factorization
|
|
|
|
|
parms%orth_alg = 'LLK' ! What orthogonalization algorithm?
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
write(psb_out_unit,'("Solving matrix : ell1")')
|
|
|
|
|
write(psb_out_unit,'("Solving matrix : ell1")')
|
|
|
|
|
write(psb_out_unit,'("Grid dimensions : ",i5," x ",i5)')idim,idim
|
|
|
|
|
write(psb_out_unit,'("Number of processors : ",i0)') np
|
|
|
|
|
select case(ipart)
|
|
|
|
@ -775,11 +822,32 @@ contains
|
|
|
|
|
write(psb_out_unit,'("Unknown data distrbution, defaulting to 2D")')
|
|
|
|
|
end select
|
|
|
|
|
write(psb_out_unit,'("Preconditioner : ",a)') ptype
|
|
|
|
|
if( psb_toupper(ptype) == "BJAC" ) then
|
|
|
|
|
write(psb_out_unit,'("Block subsolver : ",a)') parms%alg
|
|
|
|
|
select case (psb_toupper(parms%alg))
|
|
|
|
|
case ('ILU')
|
|
|
|
|
write(psb_out_unit,'("Fill in : ",i0)') parms%fill
|
|
|
|
|
write(psb_out_unit,'("MILU : ",a)') parms%ilu_alg
|
|
|
|
|
case ('ILUT')
|
|
|
|
|
write(psb_out_unit,'("Fill in : ",i0)') parms%fill
|
|
|
|
|
write(psb_out_unit,'("Threshold : ",es12.5)') parms%thresh
|
|
|
|
|
write(psb_out_unit,'("Scaling : ",a)') parms%ilut_scale
|
|
|
|
|
case ('INVK')
|
|
|
|
|
write(psb_out_unit,'("Fill in : ",i0)') parms%fill
|
|
|
|
|
write(psb_out_unit,'("Threshold : ",es12.5)') parms%thresh
|
|
|
|
|
write(psb_out_unit,'("Invese Fill in : ",i0)') parms%inv_fill
|
|
|
|
|
write(psb_out_unit,'("Inverse Threshold : ",es12.5)') parms%inv_thresh
|
|
|
|
|
case ('AINVT','AORTH')
|
|
|
|
|
write(psb_out_unit,'("Inverse Threshold : ",es12.5)') parms%inv_thresh
|
|
|
|
|
case default
|
|
|
|
|
write(psb_out_unit,'("Unknown diagonal solver")')
|
|
|
|
|
end select
|
|
|
|
|
end if
|
|
|
|
|
write(psb_out_unit,'("Iterative method : ",a)') kmethd
|
|
|
|
|
write(psb_out_unit,'(" ")')
|
|
|
|
|
else
|
|
|
|
|
! wrong number of parameter, print an error message and exit
|
|
|
|
|
call pr_usage(izero)
|
|
|
|
|
call pr_usage(izero)
|
|
|
|
|
call psb_abort(ictxt)
|
|
|
|
|
stop 1
|
|
|
|
|
endif
|
|
|
|
@ -803,15 +871,15 @@ contains
|
|
|
|
|
|
|
|
|
|
end subroutine get_parms
|
|
|
|
|
!
|
|
|
|
|
! print an error message
|
|
|
|
|
!
|
|
|
|
|
! print an error message
|
|
|
|
|
!
|
|
|
|
|
subroutine pr_usage(iout)
|
|
|
|
|
integer(psb_ipk_) :: iout
|
|
|
|
|
write(iout,*)'incorrect parameter(s) found'
|
|
|
|
|
write(iout,*)' usage: pde2d90 methd prec dim &
|
|
|
|
|
&[ipart istop itmax itrace]'
|
|
|
|
|
&[ipart istop itmax itrace]'
|
|
|
|
|
write(iout,*)' where:'
|
|
|
|
|
write(iout,*)' methd: cgstab cgs rgmres bicgstabl'
|
|
|
|
|
write(iout,*)' methd: cgstab cgs rgmres bicgstabl'
|
|
|
|
|
write(iout,*)' prec : bjac diag none'
|
|
|
|
|
write(iout,*)' dim number of points along each axis'
|
|
|
|
|
write(iout,*)' the size of the resulting linear '
|
|
|
|
@ -819,11 +887,9 @@ contains
|
|
|
|
|
write(iout,*)' ipart data partition 1 3 '
|
|
|
|
|
write(iout,*)' istop stopping criterion 1, 2 '
|
|
|
|
|
write(iout,*)' itmax maximum number of iterations [500] '
|
|
|
|
|
write(iout,*)' itrace <=0 (no tracing, default) or '
|
|
|
|
|
write(iout,*)' itrace <=0 (no tracing, default) or '
|
|
|
|
|
write(iout,*)' >= 1 do tracing every itrace'
|
|
|
|
|
write(iout,*)' iterations '
|
|
|
|
|
write(iout,*)' iterations '
|
|
|
|
|
end subroutine pr_usage
|
|
|
|
|
|
|
|
|
|
end program psb_d_pde2d
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|