mld2p4-2:
mlprec/Makefile mlprec/mld_c_base_smoother_impl.f90 mlprec/mld_c_base_smoother_mod.f90 mlprec/mld_c_base_solver_impl.f90 mlprec/mld_c_base_solver_mod.f90 mlprec/mld_c_onelev_impl.f90 mlprec/mld_c_onelev_mod.f90 mlprec/mld_d_base_smoother_impl.f90 mlprec/mld_d_base_smoother_mod.f90 mlprec/mld_d_base_solver_impl.f90 mlprec/mld_d_base_solver_mod.f90 mlprec/mld_d_onelev_impl.f90 mlprec/mld_d_onelev_mod.f90 mlprec/mld_s_base_smoother_impl.f90 mlprec/mld_s_base_smoother_mod.f90 mlprec/mld_s_base_solver_impl.f90 mlprec/mld_s_base_solver_mod.f90 mlprec/mld_s_ilu_impl.f90 mlprec/mld_s_onelev_impl.f90 mlprec/mld_s_onelev_mod.f90 mlprec/mld_z_base_smoother_impl.f90 mlprec/mld_z_base_smoother_mod.f90 mlprec/mld_z_base_solver_impl.f90 mlprec/mld_z_base_solver_mod.f90 mlprec/mld_z_onelev_impl.f90 mlprec/mld_z_onelev_mod.f90 Split module/interface vs. implementation: reduce memory pressure on build phase.stopcriterion
parent
852102c4f8
commit
c7d71019f2
@ -0,0 +1,481 @@
|
|||||||
|
!!$
|
||||||
|
!!$
|
||||||
|
!!$ MLD2P4 version 2.0
|
||||||
|
!!$ MultiLevel Domain Decomposition Parallel Preconditioners Package
|
||||||
|
!!$ based on PSBLAS (Parallel Sparse BLAS version 3.0)
|
||||||
|
!!$
|
||||||
|
!!$ (C) Copyright 2008,2009,2010
|
||||||
|
!!$
|
||||||
|
!!$ Salvatore Filippone University of Rome Tor Vergata
|
||||||
|
!!$ Alfredo Buttari CNRS-IRIT, Toulouse
|
||||||
|
!!$ Pasqua D'Ambra ICAR-CNR, Naples
|
||||||
|
!!$ Daniela di Serafino Second University of Naples
|
||||||
|
!!$
|
||||||
|
!!$ 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 MLD2P4 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 MLD2P4 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.
|
||||||
|
!!$
|
||||||
|
!!$
|
||||||
|
|
||||||
|
!
|
||||||
|
! Apply: comes in two versions, on plain arrays or on encapsulated
|
||||||
|
! vectors.
|
||||||
|
! This basic version just applies the local solver, whatever that
|
||||||
|
! is.
|
||||||
|
!
|
||||||
|
|
||||||
|
subroutine mld_c_base_smoother_apply(alpha,sm,x,beta,y,desc_data,trans,sweeps,work,info)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_c_base_smoother_mod, mld_protect_name => mld_c_base_smoother_apply
|
||||||
|
implicit none
|
||||||
|
type(psb_desc_type), intent(in) :: desc_data
|
||||||
|
class(mld_c_base_smoother_type), intent(in) :: sm
|
||||||
|
complex(psb_spk_),intent(inout) :: x(:)
|
||||||
|
complex(psb_spk_),intent(inout) :: y(:)
|
||||||
|
complex(psb_spk_),intent(in) :: alpha,beta
|
||||||
|
character(len=1),intent(in) :: trans
|
||||||
|
integer, intent(in) :: sweeps
|
||||||
|
complex(psb_spk_),target, intent(inout) :: work(:)
|
||||||
|
integer, intent(out) :: info
|
||||||
|
|
||||||
|
Integer :: err_act
|
||||||
|
character(len=20) :: name='c_base_smoother_apply'
|
||||||
|
|
||||||
|
call psb_erractionsave(err_act)
|
||||||
|
info = psb_success_
|
||||||
|
if (allocated(sm%sv)) then
|
||||||
|
call sm%sv%apply(alpha,x,beta,y,desc_data,trans,work,info)
|
||||||
|
else
|
||||||
|
info = 1121
|
||||||
|
endif
|
||||||
|
if (info /= psb_success_) then
|
||||||
|
call psb_errpush(info,name)
|
||||||
|
goto 9999
|
||||||
|
end if
|
||||||
|
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
return
|
||||||
|
|
||||||
|
9999 continue
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
if (err_act == psb_act_abort_) then
|
||||||
|
call psb_error()
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
return
|
||||||
|
|
||||||
|
end subroutine mld_c_base_smoother_apply
|
||||||
|
|
||||||
|
subroutine mld_c_base_smoother_apply_vect(alpha,sm,x,beta,y,desc_data,&
|
||||||
|
& trans,sweeps,work,info)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_c_base_smoother_mod, mld_protect_name => mld_c_base_smoother_apply_vect
|
||||||
|
implicit none
|
||||||
|
type(psb_desc_type), intent(in) :: desc_data
|
||||||
|
class(mld_c_base_smoother_type), intent(inout) :: sm
|
||||||
|
type(psb_c_vect_type),intent(inout) :: x
|
||||||
|
type(psb_c_vect_type),intent(inout) :: y
|
||||||
|
complex(psb_spk_),intent(in) :: alpha,beta
|
||||||
|
character(len=1),intent(in) :: trans
|
||||||
|
integer, intent(in) :: sweeps
|
||||||
|
complex(psb_spk_),target, intent(inout) :: work(:)
|
||||||
|
integer, intent(out) :: info
|
||||||
|
|
||||||
|
Integer :: err_act
|
||||||
|
character(len=20) :: name='c_base_smoother_apply'
|
||||||
|
|
||||||
|
call psb_erractionsave(err_act)
|
||||||
|
info = psb_success_
|
||||||
|
if (allocated(sm%sv)) then
|
||||||
|
call sm%sv%apply(alpha,x,beta,y,desc_data,trans,work,info)
|
||||||
|
else
|
||||||
|
info = 1121
|
||||||
|
endif
|
||||||
|
if (info /= psb_success_) then
|
||||||
|
call psb_errpush(info,name)
|
||||||
|
goto 9999
|
||||||
|
end if
|
||||||
|
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
return
|
||||||
|
|
||||||
|
9999 continue
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
if (err_act == psb_act_abort_) then
|
||||||
|
call psb_error()
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
return
|
||||||
|
|
||||||
|
end subroutine mld_c_base_smoother_apply_vect
|
||||||
|
|
||||||
|
!
|
||||||
|
! Check:
|
||||||
|
! 1. Check that we do have a solver object
|
||||||
|
! 2. Call its check method
|
||||||
|
!
|
||||||
|
|
||||||
|
subroutine mld_c_base_smoother_check(sm,info)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_c_base_smoother_mod, mld_protect_name => mld_c_base_smoother_check
|
||||||
|
Implicit None
|
||||||
|
|
||||||
|
! Arguments
|
||||||
|
class(mld_c_base_smoother_type), intent(inout) :: sm
|
||||||
|
integer, intent(out) :: info
|
||||||
|
Integer :: err_act
|
||||||
|
character(len=20) :: name='c_base_smoother_check'
|
||||||
|
|
||||||
|
call psb_erractionsave(err_act)
|
||||||
|
info = psb_success_
|
||||||
|
|
||||||
|
if (allocated(sm%sv)) then
|
||||||
|
call sm%sv%check(info)
|
||||||
|
else
|
||||||
|
info=3111
|
||||||
|
call psb_errpush(info,name)
|
||||||
|
goto 9999
|
||||||
|
end if
|
||||||
|
|
||||||
|
if (info /= psb_success_) goto 9999
|
||||||
|
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
return
|
||||||
|
|
||||||
|
9999 continue
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
if (err_act == psb_act_abort_) then
|
||||||
|
call psb_error()
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
return
|
||||||
|
end subroutine mld_c_base_smoother_check
|
||||||
|
|
||||||
|
!
|
||||||
|
! Set methods: the come in multiple versions according
|
||||||
|
! to whether we are setting with integer, real or character
|
||||||
|
! input.
|
||||||
|
! The basic rule is: if the input refers to a parameter
|
||||||
|
! of the smoother, use it, otherwise pass it to the
|
||||||
|
! solver object for further processing.
|
||||||
|
! Since there are no parameters in the base smoother
|
||||||
|
! we just pass everything to the solver object.
|
||||||
|
!
|
||||||
|
subroutine mld_c_base_smoother_seti(sm,what,val,info)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_c_base_smoother_mod, mld_protect_name => mld_c_base_smoother_seti
|
||||||
|
Implicit None
|
||||||
|
! Arguments
|
||||||
|
class(mld_c_base_smoother_type), intent(inout) :: sm
|
||||||
|
integer, intent(in) :: what
|
||||||
|
integer, intent(in) :: val
|
||||||
|
integer, intent(out) :: info
|
||||||
|
Integer :: err_act
|
||||||
|
character(len=20) :: name='c_base_smoother_seti'
|
||||||
|
|
||||||
|
call psb_erractionsave(err_act)
|
||||||
|
info = psb_success_
|
||||||
|
|
||||||
|
if (allocated(sm%sv)) then
|
||||||
|
call sm%sv%set(what,val,info)
|
||||||
|
end if
|
||||||
|
if (info /= psb_success_) goto 9999
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
return
|
||||||
|
|
||||||
|
9999 continue
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
if (err_act == psb_act_abort_) then
|
||||||
|
call psb_error()
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
return
|
||||||
|
end subroutine mld_c_base_smoother_seti
|
||||||
|
|
||||||
|
subroutine mld_c_base_smoother_setc(sm,what,val,info)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_c_base_smoother_mod, mld_protect_name => mld_c_base_smoother_setc
|
||||||
|
Implicit None
|
||||||
|
|
||||||
|
! Arguments
|
||||||
|
class(mld_c_base_smoother_type), intent(inout) :: sm
|
||||||
|
integer, intent(in) :: what
|
||||||
|
character(len=*), intent(in) :: val
|
||||||
|
integer, intent(out) :: info
|
||||||
|
Integer :: err_act
|
||||||
|
character(len=20) :: name='c_base_smoother_setc'
|
||||||
|
|
||||||
|
call psb_erractionsave(err_act)
|
||||||
|
|
||||||
|
info = psb_success_
|
||||||
|
|
||||||
|
if (allocated(sm%sv)) then
|
||||||
|
call sm%sv%set(what,val,info)
|
||||||
|
end if
|
||||||
|
if (info /= psb_success_) goto 9999
|
||||||
|
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
return
|
||||||
|
|
||||||
|
9999 continue
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
if (err_act == psb_act_abort_) then
|
||||||
|
call psb_error()
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
return
|
||||||
|
end subroutine mld_c_base_smoother_setc
|
||||||
|
|
||||||
|
subroutine mld_c_base_smoother_setr(sm,what,val,info)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_c_base_smoother_mod, mld_protect_name => mld_c_base_smoother_setr
|
||||||
|
Implicit None
|
||||||
|
|
||||||
|
! Arguments
|
||||||
|
class(mld_c_base_smoother_type), intent(inout) :: sm
|
||||||
|
integer, intent(in) :: what
|
||||||
|
real(psb_spk_), intent(in) :: val
|
||||||
|
integer, intent(out) :: info
|
||||||
|
Integer :: err_act
|
||||||
|
character(len=20) :: name='c_base_smoother_setr'
|
||||||
|
|
||||||
|
call psb_erractionsave(err_act)
|
||||||
|
|
||||||
|
|
||||||
|
info = psb_success_
|
||||||
|
|
||||||
|
if (allocated(sm%sv)) then
|
||||||
|
call sm%sv%set(what,val,info)
|
||||||
|
end if
|
||||||
|
if (info /= psb_success_) goto 9999
|
||||||
|
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
return
|
||||||
|
|
||||||
|
9999 continue
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
if (err_act == psb_act_abort_) then
|
||||||
|
call psb_error()
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
return
|
||||||
|
end subroutine mld_c_base_smoother_setr
|
||||||
|
|
||||||
|
|
||||||
|
!
|
||||||
|
! Build method.
|
||||||
|
! At base level we only have to pass data to the inner solver.
|
||||||
|
! AMOLD/VMOLD allow to have any relevant sparse matrix or vector
|
||||||
|
! to be stored in a given format. This is essential e.g.
|
||||||
|
! when dealing with GPUs.
|
||||||
|
!
|
||||||
|
subroutine mld_c_base_smoother_bld(a,desc_a,sm,upd,info,amold,vmold)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_c_base_smoother_mod, mld_protect_name => mld_c_base_smoother_bld
|
||||||
|
Implicit None
|
||||||
|
|
||||||
|
! Arguments
|
||||||
|
type(psb_cspmat_type), intent(in), target :: a
|
||||||
|
Type(psb_desc_type), Intent(in) :: desc_a
|
||||||
|
class(mld_c_base_smoother_type), intent(inout) :: sm
|
||||||
|
character, intent(in) :: upd
|
||||||
|
integer, intent(out) :: info
|
||||||
|
class(psb_c_base_sparse_mat), intent(in), optional :: amold
|
||||||
|
class(psb_c_base_vect_type), intent(in), optional :: vmold
|
||||||
|
Integer :: err_act
|
||||||
|
character(len=20) :: name='c_base_smoother_bld'
|
||||||
|
|
||||||
|
call psb_erractionsave(err_act)
|
||||||
|
|
||||||
|
info = psb_success_
|
||||||
|
if (allocated(sm%sv)) then
|
||||||
|
call sm%sv%build(a,desc_a,upd,info,amold=amold,vmold=vmold)
|
||||||
|
else
|
||||||
|
info = 1121
|
||||||
|
call psb_errpush(info,name)
|
||||||
|
endif
|
||||||
|
if (info /= psb_success_) goto 9999
|
||||||
|
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
return
|
||||||
|
|
||||||
|
9999 continue
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
if (err_act == psb_act_abort_) then
|
||||||
|
call psb_error()
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
return
|
||||||
|
end subroutine mld_c_base_smoother_bld
|
||||||
|
|
||||||
|
!
|
||||||
|
! Free method (aka destructor).
|
||||||
|
! In most cases we could do without; however
|
||||||
|
! for cases where there are data objects allocated outside
|
||||||
|
! of the Fortran RTE we need to free them explicitly.
|
||||||
|
!
|
||||||
|
! Even in that case, we could do without this if FINAL
|
||||||
|
! subroutines were supported, which is not the case
|
||||||
|
|
||||||
|
! in GNU Fortran up to 4.7.
|
||||||
|
!
|
||||||
|
subroutine mld_c_base_smoother_free(sm,info)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_c_base_smoother_mod, mld_protect_name => s
|
||||||
|
Implicit None
|
||||||
|
|
||||||
|
! Arguments
|
||||||
|
class(mld_c_base_smoother_type), intent(inout) :: sm
|
||||||
|
integer, intent(out) :: info
|
||||||
|
Integer :: err_act
|
||||||
|
character(len=20) :: name='c_base_smoother_free'
|
||||||
|
|
||||||
|
call psb_erractionsave(err_act)
|
||||||
|
info = psb_success_
|
||||||
|
|
||||||
|
if (allocated(sm%sv)) then
|
||||||
|
call sm%sv%free(info)
|
||||||
|
end if
|
||||||
|
if (info == psb_success_) deallocate(sm%sv,stat=info)
|
||||||
|
if (info /= psb_success_) then
|
||||||
|
info = psb_err_alloc_dealloc_
|
||||||
|
call psb_errpush(info,name)
|
||||||
|
goto 9999
|
||||||
|
end if
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
return
|
||||||
|
|
||||||
|
9999 continue
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
if (err_act == psb_act_abort_) then
|
||||||
|
call psb_error()
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
return
|
||||||
|
end subroutine mld_c_base_smoother_free
|
||||||
|
|
||||||
|
!
|
||||||
|
! Print a description
|
||||||
|
!
|
||||||
|
|
||||||
|
subroutine mld_c_base_smoother_descr(sm,info,iout,coarse)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_c_base_smoother_mod, mld_protect_name => mld_c_base_smoother_descr
|
||||||
|
Implicit None
|
||||||
|
|
||||||
|
! Arguments
|
||||||
|
class(mld_c_base_smoother_type), intent(in) :: sm
|
||||||
|
integer, intent(out) :: info
|
||||||
|
integer, intent(in), optional :: iout
|
||||||
|
logical, intent(in), optional :: coarse
|
||||||
|
|
||||||
|
! Local variables
|
||||||
|
integer :: err_act
|
||||||
|
integer :: ictxt, me, np
|
||||||
|
character(len=20), parameter :: name='mld_c_base_smoother_descr'
|
||||||
|
integer :: iout_
|
||||||
|
logical :: coarse_
|
||||||
|
|
||||||
|
|
||||||
|
call psb_erractionsave(err_act)
|
||||||
|
info = psb_success_
|
||||||
|
|
||||||
|
if (present(coarse)) then
|
||||||
|
coarse_ = coarse
|
||||||
|
else
|
||||||
|
coarse_ = .false.
|
||||||
|
end if
|
||||||
|
if (present(iout)) then
|
||||||
|
iout_ = iout
|
||||||
|
else
|
||||||
|
iout_ = 6
|
||||||
|
end if
|
||||||
|
|
||||||
|
if (.not.coarse_) &
|
||||||
|
& write(iout_,*) 'Base smoother with local solver'
|
||||||
|
if (allocated(sm%sv)) then
|
||||||
|
call sm%sv%descr(info,iout,coarse)
|
||||||
|
if (info /= psb_success_) then
|
||||||
|
info = psb_err_from_subroutine_
|
||||||
|
call psb_errpush(info,name,a_err='Local solver')
|
||||||
|
goto 9999
|
||||||
|
end if
|
||||||
|
end if
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
return
|
||||||
|
|
||||||
|
9999 continue
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
if (err_act == psb_act_abort_) then
|
||||||
|
call psb_error()
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
return
|
||||||
|
end subroutine mld_c_base_smoother_descr
|
||||||
|
|
||||||
|
!
|
||||||
|
! Dump
|
||||||
|
! to file, for debugging purposes.
|
||||||
|
!
|
||||||
|
subroutine mld_c_base_smoother_dmp(sm,ictxt,level,info,prefix,head,smoother,solver)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_c_base_smoother_mod, mld_protect_name => mld_c_base_smoother_dmp
|
||||||
|
implicit none
|
||||||
|
class(mld_c_base_smoother_type), intent(in) :: sm
|
||||||
|
integer, intent(in) :: ictxt,level
|
||||||
|
integer, intent(out) :: info
|
||||||
|
character(len=*), intent(in), optional :: prefix, head
|
||||||
|
logical, optional, intent(in) :: smoother, solver
|
||||||
|
integer :: i, j, il1, iln, lname, lev
|
||||||
|
integer :: icontxt,iam, np
|
||||||
|
character(len=80) :: prefix_
|
||||||
|
character(len=120) :: fname ! len should be at least 20 more than
|
||||||
|
logical :: smoother_
|
||||||
|
! len of prefix_
|
||||||
|
|
||||||
|
info = 0
|
||||||
|
|
||||||
|
if (present(prefix)) then
|
||||||
|
prefix_ = trim(prefix(1:min(len(prefix),len(prefix_))))
|
||||||
|
else
|
||||||
|
prefix_ = "dump_smth_c"
|
||||||
|
end if
|
||||||
|
|
||||||
|
call psb_info(ictxt,iam,np)
|
||||||
|
|
||||||
|
if (present(smoother)) then
|
||||||
|
smoother_ = smoother
|
||||||
|
else
|
||||||
|
smoother_ = .false.
|
||||||
|
end if
|
||||||
|
lname = len_trim(prefix_)
|
||||||
|
fname = trim(prefix_)
|
||||||
|
write(fname(lname+1:lname+5),'(a,i3.3)') '_p',iam
|
||||||
|
lname = lname + 5
|
||||||
|
|
||||||
|
! At base level do nothing for the smoother
|
||||||
|
if (allocated(sm%sv)) &
|
||||||
|
& call sm%sv%dump(ictxt,level,info,solver=solver)
|
||||||
|
|
||||||
|
end subroutine mld_c_base_smoother_dmp
|
||||||
|
|
@ -0,0 +1,338 @@
|
|||||||
|
!
|
||||||
|
! Apply: comes in two versions, on plain arrays or on encapsulated
|
||||||
|
! vectors.
|
||||||
|
! The base version throws an error, since it means that no explicit
|
||||||
|
! choice was made.
|
||||||
|
! Question: would it make sense to transform the base version into
|
||||||
|
! the ID version, i.e. "base_solver" is the identity operator?
|
||||||
|
!
|
||||||
|
|
||||||
|
subroutine mld_c_base_solver_apply(alpha,sv,x,beta,y,desc_data,trans,work,info)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_c_base_solver_mod, mld_protect_name => mld_c_base_solver_apply
|
||||||
|
implicit none
|
||||||
|
type(psb_desc_type), intent(in) :: desc_data
|
||||||
|
class(mld_c_base_solver_type), intent(in) :: sv
|
||||||
|
complex(psb_spk_),intent(inout) :: x(:)
|
||||||
|
complex(psb_spk_),intent(inout) :: y(:)
|
||||||
|
complex(psb_spk_),intent(in) :: alpha,beta
|
||||||
|
character(len=1),intent(in) :: trans
|
||||||
|
complex(psb_spk_),target, intent(inout) :: work(:)
|
||||||
|
integer, intent(out) :: info
|
||||||
|
|
||||||
|
Integer :: err_act
|
||||||
|
character(len=20) :: name='d_base_solver_apply'
|
||||||
|
|
||||||
|
call psb_erractionsave(err_act)
|
||||||
|
|
||||||
|
info = psb_err_missing_override_method_
|
||||||
|
call psb_errpush(info,name)
|
||||||
|
goto 9999
|
||||||
|
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
return
|
||||||
|
|
||||||
|
9999 continue
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
if (err_act == psb_act_abort_) then
|
||||||
|
call psb_error()
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
return
|
||||||
|
|
||||||
|
end subroutine mld_c_base_solver_apply
|
||||||
|
|
||||||
|
subroutine mld_c_base_solver_apply_vect(alpha,sv,x,beta,y,desc_data,trans,work,info)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_c_base_solver_mod, mld_protect_name => mld_c_base_solver_apply_vect
|
||||||
|
implicit none
|
||||||
|
type(psb_desc_type), intent(in) :: desc_data
|
||||||
|
class(mld_c_base_solver_type), intent(inout) :: sv
|
||||||
|
type(psb_c_vect_type),intent(inout) :: x
|
||||||
|
type(psb_c_vect_type),intent(inout) :: y
|
||||||
|
complex(psb_spk_),intent(in) :: alpha,beta
|
||||||
|
character(len=1),intent(in) :: trans
|
||||||
|
complex(psb_spk_),target, intent(inout) :: work(:)
|
||||||
|
integer, intent(out) :: info
|
||||||
|
|
||||||
|
Integer :: err_act
|
||||||
|
character(len=20) :: name='d_base_solver_apply'
|
||||||
|
|
||||||
|
call psb_erractionsave(err_act)
|
||||||
|
|
||||||
|
info = psb_err_missing_override_method_
|
||||||
|
call psb_errpush(info,name)
|
||||||
|
goto 9999
|
||||||
|
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
return
|
||||||
|
|
||||||
|
9999 continue
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
if (err_act == psb_act_abort_) then
|
||||||
|
call psb_error()
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
return
|
||||||
|
|
||||||
|
end subroutine mld_c_base_solver_apply_vect
|
||||||
|
|
||||||
|
|
||||||
|
!
|
||||||
|
! Build
|
||||||
|
! The base version throws an error, since it means that no explicit
|
||||||
|
! choice was made.
|
||||||
|
!
|
||||||
|
subroutine mld_c_base_solver_bld(a,desc_a,sv,upd,info,b,amold,vmold)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_c_base_solver_mod, mld_protect_name => mld_c_base_solver_bld
|
||||||
|
Implicit None
|
||||||
|
! Arguments
|
||||||
|
type(psb_cspmat_type), intent(in), target :: a
|
||||||
|
Type(psb_desc_type), Intent(in) :: desc_a
|
||||||
|
class(mld_c_base_solver_type), intent(inout) :: sv
|
||||||
|
character, intent(in) :: upd
|
||||||
|
integer, intent(out) :: info
|
||||||
|
type(psb_cspmat_type), intent(in), target, optional :: b
|
||||||
|
class(psb_c_base_sparse_mat), intent(in), optional :: amold
|
||||||
|
class(psb_c_base_vect_type), intent(in), optional :: vmold
|
||||||
|
|
||||||
|
Integer :: err_act
|
||||||
|
character(len=20) :: name='d_base_solver_bld'
|
||||||
|
|
||||||
|
call psb_erractionsave(err_act)
|
||||||
|
|
||||||
|
info = psb_err_missing_override_method_
|
||||||
|
call psb_errpush(info,name)
|
||||||
|
goto 9999
|
||||||
|
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
return
|
||||||
|
|
||||||
|
9999 continue
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
if (err_act == psb_act_abort_) then
|
||||||
|
call psb_error()
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
return
|
||||||
|
end subroutine mld_c_base_solver_bld
|
||||||
|
|
||||||
|
subroutine mld_c_base_solver_check(sv,info)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_c_base_solver_mod, mld_protect_name => mld_c_base_solver_check
|
||||||
|
Implicit None
|
||||||
|
! Arguments
|
||||||
|
class(mld_c_base_solver_type), intent(inout) :: sv
|
||||||
|
integer, intent(out) :: info
|
||||||
|
Integer :: err_act
|
||||||
|
character(len=20) :: name='d_base_solver_check'
|
||||||
|
|
||||||
|
call psb_erractionsave(err_act)
|
||||||
|
info = psb_success_
|
||||||
|
|
||||||
|
|
||||||
|
if (info /= psb_success_) goto 9999
|
||||||
|
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
return
|
||||||
|
|
||||||
|
9999 continue
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
if (err_act == psb_act_abort_) then
|
||||||
|
call psb_error()
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
return
|
||||||
|
end subroutine mld_c_base_solver_check
|
||||||
|
|
||||||
|
!
|
||||||
|
! Set.
|
||||||
|
! The base version does nothing; the principle is that
|
||||||
|
! SET acts on what is known, and delegates what is unknown.
|
||||||
|
! Since we are at the bottom of the hierarchy, there's no one
|
||||||
|
! to delegate, so we do nothing.
|
||||||
|
!
|
||||||
|
subroutine mld_c_base_solver_seti(sv,what,val,info)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_c_base_solver_mod, mld_protect_name => mld_c_base_solver_seti
|
||||||
|
Implicit None
|
||||||
|
! Arguments
|
||||||
|
class(mld_c_base_solver_type), intent(inout) :: sv
|
||||||
|
integer, intent(in) :: what
|
||||||
|
integer, intent(in) :: val
|
||||||
|
integer, intent(out) :: info
|
||||||
|
Integer :: err_act
|
||||||
|
character(len=20) :: name='d_base_solver_seti'
|
||||||
|
|
||||||
|
! Correct action here is doing nothing.
|
||||||
|
info = 0
|
||||||
|
|
||||||
|
return
|
||||||
|
end subroutine mld_c_base_solver_seti
|
||||||
|
|
||||||
|
subroutine mld_c_base_solver_setc(sv,what,val,info)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_c_base_solver_mod, mld_protect_name => mld_c_base_solver_setc
|
||||||
|
Implicit None
|
||||||
|
! Arguments
|
||||||
|
class(mld_c_base_solver_type), intent(inout) :: sv
|
||||||
|
integer, intent(in) :: what
|
||||||
|
character(len=*), intent(in) :: val
|
||||||
|
integer, intent(out) :: info
|
||||||
|
Integer :: err_act, ival
|
||||||
|
character(len=20) :: name='d_base_solver_setc'
|
||||||
|
|
||||||
|
call psb_erractionsave(err_act)
|
||||||
|
|
||||||
|
info = psb_success_
|
||||||
|
|
||||||
|
call mld_stringval(val,ival,info)
|
||||||
|
if (info == psb_success_) call sv%set(what,ival,info)
|
||||||
|
|
||||||
|
if (info /= psb_success_) goto 9999
|
||||||
|
|
||||||
|
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
return
|
||||||
|
|
||||||
|
9999 continue
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
if (err_act == psb_act_abort_) then
|
||||||
|
call psb_error()
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
return
|
||||||
|
end subroutine mld_c_base_solver_setc
|
||||||
|
|
||||||
|
subroutine mld_c_base_solver_setr(sv,what,val,info)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_c_base_solver_mod, mld_protect_name => mld_c_base_solver_setr
|
||||||
|
Implicit None
|
||||||
|
! Arguments
|
||||||
|
class(mld_c_base_solver_type), intent(inout) :: sv
|
||||||
|
integer, intent(in) :: what
|
||||||
|
real(psb_spk_), intent(in) :: val
|
||||||
|
integer, intent(out) :: info
|
||||||
|
Integer :: err_act
|
||||||
|
character(len=20) :: name='d_base_solver_setr'
|
||||||
|
|
||||||
|
|
||||||
|
! Correct action here is doing nothing.
|
||||||
|
info = 0
|
||||||
|
|
||||||
|
return
|
||||||
|
end subroutine mld_c_base_solver_setr
|
||||||
|
|
||||||
|
!
|
||||||
|
! Free
|
||||||
|
! The base version throws an error, since it means that no explicit
|
||||||
|
! choice was made. IS THIS CORRECT? I suspect it would be better
|
||||||
|
! to be silent here, to cover reallocation.
|
||||||
|
!
|
||||||
|
subroutine mld_c_base_solver_free(sv,info)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_c_base_solver_mod, mld_protect_name => mld_c_base_solver_free
|
||||||
|
Implicit None
|
||||||
|
! Arguments
|
||||||
|
class(mld_c_base_solver_type), intent(inout) :: sv
|
||||||
|
integer, intent(out) :: info
|
||||||
|
Integer :: err_act
|
||||||
|
character(len=20) :: name='d_base_solver_free'
|
||||||
|
|
||||||
|
call psb_erractionsave(err_act)
|
||||||
|
|
||||||
|
info = psb_err_missing_override_method_
|
||||||
|
call psb_errpush(info,name)
|
||||||
|
goto 9999
|
||||||
|
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
return
|
||||||
|
|
||||||
|
9999 continue
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
if (err_act == psb_act_abort_) then
|
||||||
|
call psb_error()
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
return
|
||||||
|
end subroutine mld_c_base_solver_free
|
||||||
|
|
||||||
|
subroutine mld_c_base_solver_descr(sv,info,iout,coarse)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_c_base_solver_mod, mld_protect_name => mld_c_base_solver_descr
|
||||||
|
Implicit None
|
||||||
|
! Arguments
|
||||||
|
class(mld_c_base_solver_type), intent(in) :: sv
|
||||||
|
integer, intent(out) :: info
|
||||||
|
integer, intent(in), optional :: iout
|
||||||
|
logical, intent(in), optional :: coarse
|
||||||
|
|
||||||
|
! Local variables
|
||||||
|
integer :: err_act
|
||||||
|
integer :: ictxt, me, np
|
||||||
|
character(len=20), parameter :: name='mld_c_base_solver_descr'
|
||||||
|
integer :: iout_
|
||||||
|
|
||||||
|
|
||||||
|
call psb_erractionsave(err_act)
|
||||||
|
|
||||||
|
info = psb_err_missing_override_method_
|
||||||
|
call psb_errpush(info,name)
|
||||||
|
goto 9999
|
||||||
|
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
return
|
||||||
|
|
||||||
|
9999 continue
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
if (err_act == psb_act_abort_) then
|
||||||
|
call psb_error()
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
return
|
||||||
|
end subroutine mld_c_base_solver_descr
|
||||||
|
|
||||||
|
!
|
||||||
|
! Dump. For debugging purposes.
|
||||||
|
!
|
||||||
|
subroutine mld_c_base_solver_dmp(sv,ictxt,level,info,prefix,head,solver)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_c_base_solver_mod, mld_protect_name => mld_c_base_solver_dmp
|
||||||
|
implicit none
|
||||||
|
class(mld_c_base_solver_type), intent(in) :: sv
|
||||||
|
integer, intent(in) :: ictxt,level
|
||||||
|
integer, intent(out) :: info
|
||||||
|
character(len=*), intent(in), optional :: prefix, head
|
||||||
|
logical, optional, intent(in) :: solver
|
||||||
|
integer :: i, j, il1, iln, lname, lev
|
||||||
|
integer :: icontxt,iam, np
|
||||||
|
character(len=80) :: prefix_
|
||||||
|
character(len=120) :: fname ! len should be at least 20 more than
|
||||||
|
logical :: solver_
|
||||||
|
! len of prefix_
|
||||||
|
|
||||||
|
info = 0
|
||||||
|
|
||||||
|
if (present(prefix)) then
|
||||||
|
prefix_ = trim(prefix(1:min(len(prefix),len(prefix_))))
|
||||||
|
else
|
||||||
|
prefix_ = "dump_slv_c"
|
||||||
|
end if
|
||||||
|
|
||||||
|
call psb_info(ictxt,iam,np)
|
||||||
|
|
||||||
|
if (present(solver)) then
|
||||||
|
solver_ = solver
|
||||||
|
else
|
||||||
|
solver_ = .false.
|
||||||
|
end if
|
||||||
|
lname = len_trim(prefix_)
|
||||||
|
fname = trim(prefix_)
|
||||||
|
write(fname(lname+1:lname+5),'(a,i3.3)') '_p',iam
|
||||||
|
lname = lname + 5
|
||||||
|
|
||||||
|
! At base level do nothing for the solver
|
||||||
|
|
||||||
|
end subroutine mld_c_base_solver_dmp
|
||||||
|
|
@ -0,0 +1,459 @@
|
|||||||
|
!!$
|
||||||
|
!!$
|
||||||
|
!!$ MLD2P4 version 2.0
|
||||||
|
!!$ MultiLevel Domain Decomposition Parallel Preconditioners Package
|
||||||
|
!!$ based on PSBLAS (Parallel Sparse BLAS version 3.0)
|
||||||
|
!!$
|
||||||
|
!!$ (C) Copyright 2008,2009,2010
|
||||||
|
!!$
|
||||||
|
!!$ Salvatore Filippone University of Rome Tor Vergata
|
||||||
|
!!$ Alfredo Buttari CNRS-IRIT, Toulouse
|
||||||
|
!!$ Pasqua D'Ambra ICAR-CNR, Naples
|
||||||
|
!!$ Daniela di Serafino Second University of Naples
|
||||||
|
!!$
|
||||||
|
!!$ 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 MLD2P4 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 MLD2P4 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: mld_file_onelev_descr
|
||||||
|
! Version: complex
|
||||||
|
!
|
||||||
|
! This routine prints a description of the preconditioner to the standard
|
||||||
|
! output or to a file. It must be called after the preconditioner has been
|
||||||
|
! built by mld_precbld.
|
||||||
|
!
|
||||||
|
! Arguments:
|
||||||
|
! p - type(mld_Tprec_type), input.
|
||||||
|
! The preconditioner data structure to be printed out.
|
||||||
|
! info - integer, output.
|
||||||
|
! error code.
|
||||||
|
! iout - integer, input, optional.
|
||||||
|
! The id of the file where the preconditioner description
|
||||||
|
! will be printed. If iout is not present, then the standard
|
||||||
|
! output is condidered.
|
||||||
|
!
|
||||||
|
subroutine mld_c_base_onelev_descr(lv,il,nl,info,iout)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_conelev_mod, mld_protect_name => mld_c_base_onelev_descr
|
||||||
|
Implicit None
|
||||||
|
! Arguments
|
||||||
|
class(mld_conelev_type), intent(in) :: lv
|
||||||
|
integer, intent(in) :: il,nl
|
||||||
|
integer, intent(out) :: info
|
||||||
|
integer, intent(in), optional :: iout
|
||||||
|
|
||||||
|
! Local variables
|
||||||
|
integer :: err_act
|
||||||
|
integer :: ictxt, me, np
|
||||||
|
character(len=20), parameter :: name='mld_c_base_onelev_descr'
|
||||||
|
integer :: iout_
|
||||||
|
logical :: coarse
|
||||||
|
|
||||||
|
|
||||||
|
call psb_erractionsave(err_act)
|
||||||
|
|
||||||
|
|
||||||
|
coarse = (il==nl)
|
||||||
|
|
||||||
|
if (present(iout)) then
|
||||||
|
iout_ = iout
|
||||||
|
else
|
||||||
|
iout_ = 6
|
||||||
|
end if
|
||||||
|
|
||||||
|
write(iout_,*)
|
||||||
|
if (il == 2) then
|
||||||
|
call lv%parms%mldescr(iout_,info)
|
||||||
|
write(iout_,*)
|
||||||
|
end if
|
||||||
|
|
||||||
|
if (coarse) then
|
||||||
|
write(iout_,*) ' Level ',il,' (coarsest)'
|
||||||
|
else
|
||||||
|
write(iout_,*) ' Level ',il
|
||||||
|
end if
|
||||||
|
|
||||||
|
call lv%parms%descr(iout_,info,coarse=coarse)
|
||||||
|
|
||||||
|
if (nl > 1) then
|
||||||
|
if (allocated(lv%map%naggr)) then
|
||||||
|
write(iout_,*) ' Size of coarse matrix: ', &
|
||||||
|
& sum(lv%map%naggr(:))
|
||||||
|
write(iout_,*) ' Sizes of aggregates: ', &
|
||||||
|
& lv%map%naggr(:)
|
||||||
|
end if
|
||||||
|
end if
|
||||||
|
|
||||||
|
if (coarse.and.allocated(lv%sm)) &
|
||||||
|
& call lv%sm%descr(info,iout=iout_,coarse=coarse)
|
||||||
|
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
return
|
||||||
|
|
||||||
|
9999 continue
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
if (err_act == psb_act_abort_) then
|
||||||
|
call psb_error()
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
return
|
||||||
|
end subroutine mld_c_base_onelev_descr
|
||||||
|
|
||||||
|
|
||||||
|
!
|
||||||
|
! Subroutines: mld_T_onelev_precfree
|
||||||
|
! Version: complex
|
||||||
|
!
|
||||||
|
! These routines deallocate the mld_Tonelev_type
|
||||||
|
!
|
||||||
|
! Arguments:
|
||||||
|
! p - type(mld_Tonelev_type), input.
|
||||||
|
! The data structure to be deallocated.
|
||||||
|
! info - integer, output.
|
||||||
|
! error code.
|
||||||
|
!
|
||||||
|
subroutine mld_c_base_onelev_free(lv,info)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_conelev_mod, mld_protect_name =>: mld_T_onelev_precfree
|
||||||
|
implicit none
|
||||||
|
|
||||||
|
class(mld_conelev_type), intent(inout) :: lv
|
||||||
|
integer, intent(out) :: info
|
||||||
|
integer :: i
|
||||||
|
|
||||||
|
info = psb_success_
|
||||||
|
|
||||||
|
! We might just deallocate the top level array, except
|
||||||
|
! that there may be inner objects containing C pointers,
|
||||||
|
! e.g. UMFPACK, SLU or CUDA stuff.
|
||||||
|
! We really need FINALs.
|
||||||
|
call lv%sm%free(info)
|
||||||
|
|
||||||
|
call lv%ac%free()
|
||||||
|
if (psb_is_ok_desc(lv%desc_ac)) &
|
||||||
|
& call psb_cdfree(lv%desc_ac,info)
|
||||||
|
call lv%map%free(info)
|
||||||
|
|
||||||
|
! This is a pointer to something else, must not free it here.
|
||||||
|
nullify(lv%base_a)
|
||||||
|
! This is a pointer to something else, must not free it here.
|
||||||
|
nullify(lv%base_desc)
|
||||||
|
|
||||||
|
call lv%nullify()
|
||||||
|
|
||||||
|
end subroutine mld_c_base_onelev_free
|
||||||
|
|
||||||
|
!
|
||||||
|
! Onelevel checks.
|
||||||
|
! The number of Jacobi sweeps to be applied is not
|
||||||
|
! tied to the Jacobi smoother: logically, you have
|
||||||
|
! a smoother and you can choose to apply it any number
|
||||||
|
! of times you like.
|
||||||
|
!
|
||||||
|
subroutine mld_c_base_onelev_check(lv,info)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_conelev_mod, mld_protect_name => mld_c_base_onelev_check
|
||||||
|
|
||||||
|
Implicit None
|
||||||
|
|
||||||
|
! Arguments
|
||||||
|
class(mld_conelev_type), intent(inout) :: lv
|
||||||
|
integer, intent(out) :: info
|
||||||
|
Integer :: err_act
|
||||||
|
character(len=20) :: name='c_base_onelev_check'
|
||||||
|
|
||||||
|
call psb_erractionsave(err_act)
|
||||||
|
info = psb_success_
|
||||||
|
|
||||||
|
call mld_check_def(lv%parms%sweeps,&
|
||||||
|
& 'Jacobi sweeps',1,is_legal_jac_sweeps)
|
||||||
|
call mld_check_def(lv%parms%sweeps_pre,&
|
||||||
|
& 'Jacobi sweeps',1,is_legal_jac_sweeps)
|
||||||
|
call mld_check_def(lv%parms%sweeps_post,&
|
||||||
|
& 'Jacobi sweeps',1,is_legal_jac_sweeps)
|
||||||
|
|
||||||
|
|
||||||
|
if (allocated(lv%sm)) then
|
||||||
|
call lv%sm%check(info)
|
||||||
|
else
|
||||||
|
info=3111
|
||||||
|
call psb_errpush(info,name)
|
||||||
|
goto 9999
|
||||||
|
end if
|
||||||
|
|
||||||
|
if (info /= psb_success_) goto 9999
|
||||||
|
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
return
|
||||||
|
|
||||||
|
9999 continue
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
if (err_act == psb_act_abort_) then
|
||||||
|
call psb_error()
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
return
|
||||||
|
end subroutine mld_c_base_onelev_check
|
||||||
|
|
||||||
|
|
||||||
|
!
|
||||||
|
! Set routines:
|
||||||
|
! Parameters belonging here are:
|
||||||
|
! Number of smoothing sweeps;
|
||||||
|
! Smoother position;
|
||||||
|
! Aggregation related parameters
|
||||||
|
! Record request on coarse level solver,
|
||||||
|
! for checks on solver vs. smoother nomenclature
|
||||||
|
! reconciliation.
|
||||||
|
!
|
||||||
|
subroutine mld_c_base_onelev_seti(lv,what,val,info)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_conelev_mod, mld_protect_name => mld_c_base_onelev_seti
|
||||||
|
|
||||||
|
Implicit None
|
||||||
|
|
||||||
|
! Arguments
|
||||||
|
class(mld_conelev_type), intent(inout) :: lv
|
||||||
|
integer, intent(in) :: what
|
||||||
|
integer, intent(in) :: val
|
||||||
|
integer, intent(out) :: info
|
||||||
|
Integer :: err_act
|
||||||
|
character(len=20) :: name='c_base_onelev_seti'
|
||||||
|
|
||||||
|
call psb_erractionsave(err_act)
|
||||||
|
info = psb_success_
|
||||||
|
|
||||||
|
select case (what)
|
||||||
|
|
||||||
|
case (mld_smoother_sweeps_)
|
||||||
|
lv%parms%sweeps = val
|
||||||
|
lv%parms%sweeps_pre = val
|
||||||
|
lv%parms%sweeps_post = val
|
||||||
|
|
||||||
|
case (mld_smoother_sweeps_pre_)
|
||||||
|
lv%parms%sweeps_pre = val
|
||||||
|
|
||||||
|
case (mld_smoother_sweeps_post_)
|
||||||
|
lv%parms%sweeps_post = val
|
||||||
|
|
||||||
|
case (mld_ml_type_)
|
||||||
|
lv%parms%ml_type = val
|
||||||
|
|
||||||
|
case (mld_aggr_alg_)
|
||||||
|
lv%parms%aggr_alg = val
|
||||||
|
|
||||||
|
case (mld_aggr_kind_)
|
||||||
|
lv%parms%aggr_kind = val
|
||||||
|
|
||||||
|
case (mld_coarse_mat_)
|
||||||
|
lv%parms%coarse_mat = val
|
||||||
|
|
||||||
|
case (mld_smoother_pos_)
|
||||||
|
lv%parms%smoother_pos = val
|
||||||
|
|
||||||
|
case (mld_aggr_omega_alg_)
|
||||||
|
lv%parms%aggr_omega_alg= val
|
||||||
|
|
||||||
|
case (mld_aggr_eig_)
|
||||||
|
lv%parms%aggr_eig = val
|
||||||
|
|
||||||
|
case (mld_aggr_filter_)
|
||||||
|
lv%parms%aggr_filter = val
|
||||||
|
|
||||||
|
case (mld_coarse_solve_)
|
||||||
|
lv%parms%coarse_solve = val
|
||||||
|
|
||||||
|
case default
|
||||||
|
if (allocated(lv%sm)) then
|
||||||
|
call lv%sm%set(what,val,info)
|
||||||
|
end if
|
||||||
|
if (info /= psb_success_) goto 9999
|
||||||
|
end select
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
return
|
||||||
|
|
||||||
|
9999 continue
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
if (err_act == psb_act_abort_) then
|
||||||
|
call psb_error()
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
return
|
||||||
|
end subroutine mld_c_base_onelev_seti
|
||||||
|
|
||||||
|
subroutine mld_c_base_onelev_setc(lv,what,val,info)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_conelev_mod, mld_protect_name => mld_c_base_onelev_setc
|
||||||
|
|
||||||
|
Implicit None
|
||||||
|
|
||||||
|
! Arguments
|
||||||
|
class(mld_conelev_type), intent(inout) :: lv
|
||||||
|
integer, intent(in) :: what
|
||||||
|
character(len=*), intent(in) :: val
|
||||||
|
integer, intent(out) :: info
|
||||||
|
Integer :: err_act
|
||||||
|
character(len=20) :: name='c_base_onelev_setc'
|
||||||
|
integer :: ival
|
||||||
|
|
||||||
|
call psb_erractionsave(err_act)
|
||||||
|
|
||||||
|
info = psb_success_
|
||||||
|
|
||||||
|
call mld_stringval(val,ival,info)
|
||||||
|
if (info == psb_success_) call lv%set(what,ival,info)
|
||||||
|
|
||||||
|
if (info /= psb_success_) goto 9999
|
||||||
|
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
return
|
||||||
|
|
||||||
|
9999 continue
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
if (err_act == psb_act_abort_) then
|
||||||
|
call psb_error()
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
return
|
||||||
|
end subroutine mld_c_base_onelev_setc
|
||||||
|
|
||||||
|
subroutine mld_c_base_onelev_setr(lv,what,val,info)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_conelev_mod, mld_protect_name => mld_c_base_onelev_setr
|
||||||
|
|
||||||
|
Implicit None
|
||||||
|
|
||||||
|
! Arguments
|
||||||
|
class(mld_conelev_type), intent(inout) :: lv
|
||||||
|
integer, intent(in) :: what
|
||||||
|
real(psb_spk_), intent(in) :: val
|
||||||
|
integer, intent(out) :: info
|
||||||
|
Integer :: err_act
|
||||||
|
character(len=20) :: name='c_base_onelev_setr'
|
||||||
|
|
||||||
|
call psb_erractionsave(err_act)
|
||||||
|
|
||||||
|
|
||||||
|
info = psb_success_
|
||||||
|
|
||||||
|
select case (what)
|
||||||
|
|
||||||
|
case (mld_aggr_omega_val_)
|
||||||
|
lv%parms%aggr_omega_val= val
|
||||||
|
|
||||||
|
case (mld_aggr_thresh_)
|
||||||
|
lv%parms%aggr_thresh = val
|
||||||
|
|
||||||
|
case default
|
||||||
|
if (allocated(lv%sm)) then
|
||||||
|
call lv%sm%set(what,val,info)
|
||||||
|
end if
|
||||||
|
if (info /= psb_success_) goto 9999
|
||||||
|
end select
|
||||||
|
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
return
|
||||||
|
|
||||||
|
9999 continue
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
if (err_act == psb_act_abort_) then
|
||||||
|
call psb_error()
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
return
|
||||||
|
end subroutine mld_c_base_onelev_setr
|
||||||
|
|
||||||
|
!
|
||||||
|
! Dump on file: can be fine-tuned to include the (aggregated) matrix
|
||||||
|
! as well as smoother and solver.
|
||||||
|
!
|
||||||
|
subroutine mld_c_base_onelev_dump(lv,level,info,prefix,head,ac,rp,smoother,solver)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_conelev_mod, mld_protect_name => mld_c_base_onelev_dump
|
||||||
|
implicit none
|
||||||
|
class(mld_conelev_type), intent(in) :: lv
|
||||||
|
integer, intent(in) :: level
|
||||||
|
integer, intent(out) :: info
|
||||||
|
character(len=*), intent(in), optional :: prefix, head
|
||||||
|
logical, optional, intent(in) :: ac, rp, smoother, solver
|
||||||
|
integer :: i, j, il1, iln, lname, lev
|
||||||
|
integer :: icontxt,iam, np
|
||||||
|
character(len=80) :: prefix_
|
||||||
|
character(len=120) :: fname ! len should be at least 20 more than
|
||||||
|
logical :: ac_, rp_
|
||||||
|
! len of prefix_
|
||||||
|
|
||||||
|
info = 0
|
||||||
|
|
||||||
|
if (present(prefix)) then
|
||||||
|
prefix_ = trim(prefix(1:min(len(prefix),len(prefix_))))
|
||||||
|
else
|
||||||
|
prefix_ = "dump_lev_c"
|
||||||
|
end if
|
||||||
|
|
||||||
|
if (associated(lv%base_desc)) then
|
||||||
|
icontxt = lv%base_desc%get_context()
|
||||||
|
call psb_info(icontxt,iam,np)
|
||||||
|
else
|
||||||
|
icontxt = -1
|
||||||
|
iam = -1
|
||||||
|
end if
|
||||||
|
if (present(ac)) then
|
||||||
|
ac_ = ac
|
||||||
|
else
|
||||||
|
ac_ = .false.
|
||||||
|
end if
|
||||||
|
if (present(rp)) then
|
||||||
|
rp_ = rp
|
||||||
|
else
|
||||||
|
rp_ = .false.
|
||||||
|
end if
|
||||||
|
lname = len_trim(prefix_)
|
||||||
|
fname = trim(prefix_)
|
||||||
|
write(fname(lname+1:lname+5),'(a,i3.3)') '_p',iam
|
||||||
|
lname = lname + 5
|
||||||
|
|
||||||
|
if (level >= 2) then
|
||||||
|
if (ac_) then
|
||||||
|
write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_ac.mtx'
|
||||||
|
write(0,*) 'Filename ',fname
|
||||||
|
call lv%ac%print(fname,head=head)
|
||||||
|
end if
|
||||||
|
if (rp_) then
|
||||||
|
write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_r.mtx'
|
||||||
|
write(0,*) 'Filename ',fname
|
||||||
|
call lv%map%map_X2Y%print(fname,head=head)
|
||||||
|
write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_p.mtx'
|
||||||
|
write(0,*) 'Filename ',fname
|
||||||
|
call lv%map%map_Y2X%print(fname,head=head)
|
||||||
|
end if
|
||||||
|
end if
|
||||||
|
if (allocated(lv%sm)) &
|
||||||
|
& call lv%sm%dump(icontxt,level,info,smoother=smoother,solver=solver)
|
||||||
|
|
||||||
|
end subroutine mld_c_base_onelev_dump
|
||||||
|
|
||||||
|
|
@ -0,0 +1,481 @@
|
|||||||
|
!!$
|
||||||
|
!!$
|
||||||
|
!!$ MLD2P4 version 2.0
|
||||||
|
!!$ MultiLevel Domain Decomposition Parallel Preconditioners Package
|
||||||
|
!!$ based on PSBLAS (Parallel Sparse BLAS version 3.0)
|
||||||
|
!!$
|
||||||
|
!!$ (C) Copyright 2008,2009,2010
|
||||||
|
!!$
|
||||||
|
!!$ Salvatore Filippone University of Rome Tor Vergata
|
||||||
|
!!$ Alfredo Buttari CNRS-IRIT, Toulouse
|
||||||
|
!!$ Pasqua D'Ambra ICAR-CNR, Naples
|
||||||
|
!!$ Daniela di Serafino Second University of Naples
|
||||||
|
!!$
|
||||||
|
!!$ 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 MLD2P4 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 MLD2P4 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.
|
||||||
|
!!$
|
||||||
|
!!$
|
||||||
|
|
||||||
|
!
|
||||||
|
! Apply: comes in two versions, on plain arrays or on encapsulated
|
||||||
|
! vectors.
|
||||||
|
! This basic version just applies the local solver, whatever that
|
||||||
|
! is.
|
||||||
|
!
|
||||||
|
|
||||||
|
subroutine mld_d_base_smoother_apply(alpha,sm,x,beta,y,desc_data,trans,sweeps,work,info)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_d_base_smoother_mod, mld_protect_name => mld_d_base_smoother_apply
|
||||||
|
implicit none
|
||||||
|
type(psb_desc_type), intent(in) :: desc_data
|
||||||
|
class(mld_d_base_smoother_type), intent(in) :: sm
|
||||||
|
real(psb_dpk_),intent(inout) :: x(:)
|
||||||
|
real(psb_dpk_),intent(inout) :: y(:)
|
||||||
|
real(psb_dpk_),intent(in) :: alpha,beta
|
||||||
|
character(len=1),intent(in) :: trans
|
||||||
|
integer, intent(in) :: sweeps
|
||||||
|
real(psb_dpk_),target, intent(inout) :: work(:)
|
||||||
|
integer, intent(out) :: info
|
||||||
|
|
||||||
|
Integer :: err_act
|
||||||
|
character(len=20) :: name='d_base_smoother_apply'
|
||||||
|
|
||||||
|
call psb_erractionsave(err_act)
|
||||||
|
info = psb_success_
|
||||||
|
if (allocated(sm%sv)) then
|
||||||
|
call sm%sv%apply(alpha,x,beta,y,desc_data,trans,work,info)
|
||||||
|
else
|
||||||
|
info = 1121
|
||||||
|
endif
|
||||||
|
if (info /= psb_success_) then
|
||||||
|
call psb_errpush(info,name)
|
||||||
|
goto 9999
|
||||||
|
end if
|
||||||
|
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
return
|
||||||
|
|
||||||
|
9999 continue
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
if (err_act == psb_act_abort_) then
|
||||||
|
call psb_error()
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
return
|
||||||
|
|
||||||
|
end subroutine mld_d_base_smoother_apply
|
||||||
|
|
||||||
|
subroutine mld_d_base_smoother_apply_vect(alpha,sm,x,beta,y,desc_data,&
|
||||||
|
& trans,sweeps,work,info)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_d_base_smoother_mod, mld_protect_name => mld_d_base_smoother_apply_vect
|
||||||
|
implicit none
|
||||||
|
type(psb_desc_type), intent(in) :: desc_data
|
||||||
|
class(mld_d_base_smoother_type), intent(inout) :: sm
|
||||||
|
type(psb_d_vect_type),intent(inout) :: x
|
||||||
|
type(psb_d_vect_type),intent(inout) :: y
|
||||||
|
real(psb_dpk_),intent(in) :: alpha,beta
|
||||||
|
character(len=1),intent(in) :: trans
|
||||||
|
integer, intent(in) :: sweeps
|
||||||
|
real(psb_dpk_),target, intent(inout) :: work(:)
|
||||||
|
integer, intent(out) :: info
|
||||||
|
|
||||||
|
Integer :: err_act
|
||||||
|
character(len=20) :: name='d_base_smoother_apply'
|
||||||
|
|
||||||
|
call psb_erractionsave(err_act)
|
||||||
|
info = psb_success_
|
||||||
|
if (allocated(sm%sv)) then
|
||||||
|
call sm%sv%apply(alpha,x,beta,y,desc_data,trans,work,info)
|
||||||
|
else
|
||||||
|
info = 1121
|
||||||
|
endif
|
||||||
|
if (info /= psb_success_) then
|
||||||
|
call psb_errpush(info,name)
|
||||||
|
goto 9999
|
||||||
|
end if
|
||||||
|
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
return
|
||||||
|
|
||||||
|
9999 continue
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
if (err_act == psb_act_abort_) then
|
||||||
|
call psb_error()
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
return
|
||||||
|
|
||||||
|
end subroutine mld_d_base_smoother_apply_vect
|
||||||
|
|
||||||
|
!
|
||||||
|
! Check:
|
||||||
|
! 1. Check that we do have a solver object
|
||||||
|
! 2. Call its check method
|
||||||
|
!
|
||||||
|
|
||||||
|
subroutine mld_d_base_smoother_check(sm,info)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_d_base_smoother_mod, mld_protect_name => mld_d_base_smoother_check
|
||||||
|
Implicit None
|
||||||
|
|
||||||
|
! Arguments
|
||||||
|
class(mld_d_base_smoother_type), intent(inout) :: sm
|
||||||
|
integer, intent(out) :: info
|
||||||
|
Integer :: err_act
|
||||||
|
character(len=20) :: name='d_base_smoother_check'
|
||||||
|
|
||||||
|
call psb_erractionsave(err_act)
|
||||||
|
info = psb_success_
|
||||||
|
|
||||||
|
if (allocated(sm%sv)) then
|
||||||
|
call sm%sv%check(info)
|
||||||
|
else
|
||||||
|
info=3111
|
||||||
|
call psb_errpush(info,name)
|
||||||
|
goto 9999
|
||||||
|
end if
|
||||||
|
|
||||||
|
if (info /= psb_success_) goto 9999
|
||||||
|
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
return
|
||||||
|
|
||||||
|
9999 continue
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
if (err_act == psb_act_abort_) then
|
||||||
|
call psb_error()
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
return
|
||||||
|
end subroutine mld_d_base_smoother_check
|
||||||
|
|
||||||
|
!
|
||||||
|
! Set methods: the come in multiple versions according
|
||||||
|
! to whether we are setting with integer, real or character
|
||||||
|
! input.
|
||||||
|
! The basic rule is: if the input refers to a parameter
|
||||||
|
! of the smoother, use it, otherwise pass it to the
|
||||||
|
! solver object for further processing.
|
||||||
|
! Since there are no parameters in the base smoother
|
||||||
|
! we just pass everything to the solver object.
|
||||||
|
!
|
||||||
|
subroutine mld_d_base_smoother_seti(sm,what,val,info)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_d_base_smoother_mod, mld_protect_name => mld_d_base_smoother_seti
|
||||||
|
Implicit None
|
||||||
|
! Arguments
|
||||||
|
class(mld_d_base_smoother_type), intent(inout) :: sm
|
||||||
|
integer, intent(in) :: what
|
||||||
|
integer, intent(in) :: val
|
||||||
|
integer, intent(out) :: info
|
||||||
|
Integer :: err_act
|
||||||
|
character(len=20) :: name='d_base_smoother_seti'
|
||||||
|
|
||||||
|
call psb_erractionsave(err_act)
|
||||||
|
info = psb_success_
|
||||||
|
|
||||||
|
if (allocated(sm%sv)) then
|
||||||
|
call sm%sv%set(what,val,info)
|
||||||
|
end if
|
||||||
|
if (info /= psb_success_) goto 9999
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
return
|
||||||
|
|
||||||
|
9999 continue
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
if (err_act == psb_act_abort_) then
|
||||||
|
call psb_error()
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
return
|
||||||
|
end subroutine mld_d_base_smoother_seti
|
||||||
|
|
||||||
|
subroutine mld_d_base_smoother_setc(sm,what,val,info)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_d_base_smoother_mod, mld_protect_name => mld_d_base_smoother_setc
|
||||||
|
Implicit None
|
||||||
|
|
||||||
|
! Arguments
|
||||||
|
class(mld_d_base_smoother_type), intent(inout) :: sm
|
||||||
|
integer, intent(in) :: what
|
||||||
|
character(len=*), intent(in) :: val
|
||||||
|
integer, intent(out) :: info
|
||||||
|
Integer :: err_act
|
||||||
|
character(len=20) :: name='d_base_smoother_setc'
|
||||||
|
|
||||||
|
call psb_erractionsave(err_act)
|
||||||
|
|
||||||
|
info = psb_success_
|
||||||
|
|
||||||
|
if (allocated(sm%sv)) then
|
||||||
|
call sm%sv%set(what,val,info)
|
||||||
|
end if
|
||||||
|
if (info /= psb_success_) goto 9999
|
||||||
|
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
return
|
||||||
|
|
||||||
|
9999 continue
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
if (err_act == psb_act_abort_) then
|
||||||
|
call psb_error()
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
return
|
||||||
|
end subroutine mld_d_base_smoother_setc
|
||||||
|
|
||||||
|
subroutine mld_d_base_smoother_setr(sm,what,val,info)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_d_base_smoother_mod, mld_protect_name => mld_d_base_smoother_setr
|
||||||
|
Implicit None
|
||||||
|
|
||||||
|
! Arguments
|
||||||
|
class(mld_d_base_smoother_type), intent(inout) :: sm
|
||||||
|
integer, intent(in) :: what
|
||||||
|
real(psb_dpk_), intent(in) :: val
|
||||||
|
integer, intent(out) :: info
|
||||||
|
Integer :: err_act
|
||||||
|
character(len=20) :: name='d_base_smoother_setr'
|
||||||
|
|
||||||
|
call psb_erractionsave(err_act)
|
||||||
|
|
||||||
|
|
||||||
|
info = psb_success_
|
||||||
|
|
||||||
|
if (allocated(sm%sv)) then
|
||||||
|
call sm%sv%set(what,val,info)
|
||||||
|
end if
|
||||||
|
if (info /= psb_success_) goto 9999
|
||||||
|
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
return
|
||||||
|
|
||||||
|
9999 continue
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
if (err_act == psb_act_abort_) then
|
||||||
|
call psb_error()
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
return
|
||||||
|
end subroutine mld_d_base_smoother_setr
|
||||||
|
|
||||||
|
|
||||||
|
!
|
||||||
|
! Build method.
|
||||||
|
! At base level we only have to pass data to the inner solver.
|
||||||
|
! AMOLD/VMOLD allow to have any relevant sparse matrix or vector
|
||||||
|
! to be stored in a given format. This is essential e.g.
|
||||||
|
! when dealing with GPUs.
|
||||||
|
!
|
||||||
|
subroutine mld_d_base_smoother_bld(a,desc_a,sm,upd,info,amold,vmold)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_d_base_smoother_mod, mld_protect_name => mld_d_base_smoother_bld
|
||||||
|
Implicit None
|
||||||
|
|
||||||
|
! Arguments
|
||||||
|
type(psb_dspmat_type), intent(in), target :: a
|
||||||
|
Type(psb_desc_type), Intent(in) :: desc_a
|
||||||
|
class(mld_d_base_smoother_type), intent(inout) :: sm
|
||||||
|
character, intent(in) :: upd
|
||||||
|
integer, intent(out) :: info
|
||||||
|
class(psb_d_base_sparse_mat), intent(in), optional :: amold
|
||||||
|
class(psb_d_base_vect_type), intent(in), optional :: vmold
|
||||||
|
Integer :: err_act
|
||||||
|
character(len=20) :: name='d_base_smoother_bld'
|
||||||
|
|
||||||
|
call psb_erractionsave(err_act)
|
||||||
|
|
||||||
|
info = psb_success_
|
||||||
|
if (allocated(sm%sv)) then
|
||||||
|
call sm%sv%build(a,desc_a,upd,info,amold=amold,vmold=vmold)
|
||||||
|
else
|
||||||
|
info = 1121
|
||||||
|
call psb_errpush(info,name)
|
||||||
|
endif
|
||||||
|
if (info /= psb_success_) goto 9999
|
||||||
|
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
return
|
||||||
|
|
||||||
|
9999 continue
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
if (err_act == psb_act_abort_) then
|
||||||
|
call psb_error()
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
return
|
||||||
|
end subroutine mld_d_base_smoother_bld
|
||||||
|
|
||||||
|
!
|
||||||
|
! Free method (aka destructor).
|
||||||
|
! In most cases we could do without; however
|
||||||
|
! for cases where there are data objects allocated outside
|
||||||
|
! of the Fortran RTE we need to free them explicitly.
|
||||||
|
!
|
||||||
|
! Even in that case, we could do without this if FINAL
|
||||||
|
! subroutines were supported, which is not the case
|
||||||
|
|
||||||
|
! in GNU Fortran up to 4.7.
|
||||||
|
!
|
||||||
|
subroutine mld_d_base_smoother_free(sm,info)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_d_base_smoother_mod, mld_protect_name => s
|
||||||
|
Implicit None
|
||||||
|
|
||||||
|
! Arguments
|
||||||
|
class(mld_d_base_smoother_type), intent(inout) :: sm
|
||||||
|
integer, intent(out) :: info
|
||||||
|
Integer :: err_act
|
||||||
|
character(len=20) :: name='d_base_smoother_free'
|
||||||
|
|
||||||
|
call psb_erractionsave(err_act)
|
||||||
|
info = psb_success_
|
||||||
|
|
||||||
|
if (allocated(sm%sv)) then
|
||||||
|
call sm%sv%free(info)
|
||||||
|
end if
|
||||||
|
if (info == psb_success_) deallocate(sm%sv,stat=info)
|
||||||
|
if (info /= psb_success_) then
|
||||||
|
info = psb_err_alloc_dealloc_
|
||||||
|
call psb_errpush(info,name)
|
||||||
|
goto 9999
|
||||||
|
end if
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
return
|
||||||
|
|
||||||
|
9999 continue
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
if (err_act == psb_act_abort_) then
|
||||||
|
call psb_error()
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
return
|
||||||
|
end subroutine mld_d_base_smoother_free
|
||||||
|
|
||||||
|
!
|
||||||
|
! Print a description
|
||||||
|
!
|
||||||
|
|
||||||
|
subroutine mld_d_base_smoother_descr(sm,info,iout,coarse)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_d_base_smoother_mod, mld_protect_name => mld_d_base_smoother_descr
|
||||||
|
Implicit None
|
||||||
|
|
||||||
|
! Arguments
|
||||||
|
class(mld_d_base_smoother_type), intent(in) :: sm
|
||||||
|
integer, intent(out) :: info
|
||||||
|
integer, intent(in), optional :: iout
|
||||||
|
logical, intent(in), optional :: coarse
|
||||||
|
|
||||||
|
! Local variables
|
||||||
|
integer :: err_act
|
||||||
|
integer :: ictxt, me, np
|
||||||
|
character(len=20), parameter :: name='mld_d_base_smoother_descr'
|
||||||
|
integer :: iout_
|
||||||
|
logical :: coarse_
|
||||||
|
|
||||||
|
|
||||||
|
call psb_erractionsave(err_act)
|
||||||
|
info = psb_success_
|
||||||
|
|
||||||
|
if (present(coarse)) then
|
||||||
|
coarse_ = coarse
|
||||||
|
else
|
||||||
|
coarse_ = .false.
|
||||||
|
end if
|
||||||
|
if (present(iout)) then
|
||||||
|
iout_ = iout
|
||||||
|
else
|
||||||
|
iout_ = 6
|
||||||
|
end if
|
||||||
|
|
||||||
|
if (.not.coarse_) &
|
||||||
|
& write(iout_,*) 'Base smoother with local solver'
|
||||||
|
if (allocated(sm%sv)) then
|
||||||
|
call sm%sv%descr(info,iout,coarse)
|
||||||
|
if (info /= psb_success_) then
|
||||||
|
info = psb_err_from_subroutine_
|
||||||
|
call psb_errpush(info,name,a_err='Local solver')
|
||||||
|
goto 9999
|
||||||
|
end if
|
||||||
|
end if
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
return
|
||||||
|
|
||||||
|
9999 continue
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
if (err_act == psb_act_abort_) then
|
||||||
|
call psb_error()
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
return
|
||||||
|
end subroutine mld_d_base_smoother_descr
|
||||||
|
|
||||||
|
!
|
||||||
|
! Dump
|
||||||
|
! to file, for debugging purposes.
|
||||||
|
!
|
||||||
|
subroutine mld_d_base_smoother_dmp(sm,ictxt,level,info,prefix,head,smoother,solver)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_d_base_smoother_mod, mld_protect_name => mld_d_base_smoother_dmp
|
||||||
|
implicit none
|
||||||
|
class(mld_d_base_smoother_type), intent(in) :: sm
|
||||||
|
integer, intent(in) :: ictxt,level
|
||||||
|
integer, intent(out) :: info
|
||||||
|
character(len=*), intent(in), optional :: prefix, head
|
||||||
|
logical, optional, intent(in) :: smoother, solver
|
||||||
|
integer :: i, j, il1, iln, lname, lev
|
||||||
|
integer :: icontxt,iam, np
|
||||||
|
character(len=80) :: prefix_
|
||||||
|
character(len=120) :: fname ! len should be at least 20 more than
|
||||||
|
logical :: smoother_
|
||||||
|
! len of prefix_
|
||||||
|
|
||||||
|
info = 0
|
||||||
|
|
||||||
|
if (present(prefix)) then
|
||||||
|
prefix_ = trim(prefix(1:min(len(prefix),len(prefix_))))
|
||||||
|
else
|
||||||
|
prefix_ = "dump_smth_d"
|
||||||
|
end if
|
||||||
|
|
||||||
|
call psb_info(ictxt,iam,np)
|
||||||
|
|
||||||
|
if (present(smoother)) then
|
||||||
|
smoother_ = smoother
|
||||||
|
else
|
||||||
|
smoother_ = .false.
|
||||||
|
end if
|
||||||
|
lname = len_trim(prefix_)
|
||||||
|
fname = trim(prefix_)
|
||||||
|
write(fname(lname+1:lname+5),'(a,i3.3)') '_p',iam
|
||||||
|
lname = lname + 5
|
||||||
|
|
||||||
|
! At base level do nothing for the smoother
|
||||||
|
if (allocated(sm%sv)) &
|
||||||
|
& call sm%sv%dump(ictxt,level,info,solver=solver)
|
||||||
|
|
||||||
|
end subroutine mld_d_base_smoother_dmp
|
||||||
|
|
@ -0,0 +1,338 @@
|
|||||||
|
!
|
||||||
|
! Apply: comes in two versions, on plain arrays or on encapsulated
|
||||||
|
! vectors.
|
||||||
|
! The base version throws an error, since it means that no explicit
|
||||||
|
! choice was made.
|
||||||
|
! Question: would it make sense to transform the base version into
|
||||||
|
! the ID version, i.e. "base_solver" is the identity operator?
|
||||||
|
!
|
||||||
|
|
||||||
|
subroutine mld_d_base_solver_apply(alpha,sv,x,beta,y,desc_data,trans,work,info)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_d_base_solver_mod, mld_protect_name => mld_d_base_solver_apply
|
||||||
|
implicit none
|
||||||
|
type(psb_desc_type), intent(in) :: desc_data
|
||||||
|
class(mld_d_base_solver_type), intent(in) :: sv
|
||||||
|
real(psb_dpk_),intent(inout) :: x(:)
|
||||||
|
real(psb_dpk_),intent(inout) :: y(:)
|
||||||
|
real(psb_dpk_),intent(in) :: alpha,beta
|
||||||
|
character(len=1),intent(in) :: trans
|
||||||
|
real(psb_dpk_),target, intent(inout) :: work(:)
|
||||||
|
integer, intent(out) :: info
|
||||||
|
|
||||||
|
Integer :: err_act
|
||||||
|
character(len=20) :: name='d_base_solver_apply'
|
||||||
|
|
||||||
|
call psb_erractionsave(err_act)
|
||||||
|
|
||||||
|
info = psb_err_missing_override_method_
|
||||||
|
call psb_errpush(info,name)
|
||||||
|
goto 9999
|
||||||
|
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
return
|
||||||
|
|
||||||
|
9999 continue
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
if (err_act == psb_act_abort_) then
|
||||||
|
call psb_error()
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
return
|
||||||
|
|
||||||
|
end subroutine mld_d_base_solver_apply
|
||||||
|
|
||||||
|
subroutine mld_d_base_solver_apply_vect(alpha,sv,x,beta,y,desc_data,trans,work,info)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_d_base_solver_mod, mld_protect_name => mld_d_base_solver_apply_vect
|
||||||
|
implicit none
|
||||||
|
type(psb_desc_type), intent(in) :: desc_data
|
||||||
|
class(mld_d_base_solver_type), intent(inout) :: sv
|
||||||
|
type(psb_d_vect_type),intent(inout) :: x
|
||||||
|
type(psb_d_vect_type),intent(inout) :: y
|
||||||
|
real(psb_dpk_),intent(in) :: alpha,beta
|
||||||
|
character(len=1),intent(in) :: trans
|
||||||
|
real(psb_dpk_),target, intent(inout) :: work(:)
|
||||||
|
integer, intent(out) :: info
|
||||||
|
|
||||||
|
Integer :: err_act
|
||||||
|
character(len=20) :: name='d_base_solver_apply'
|
||||||
|
|
||||||
|
call psb_erractionsave(err_act)
|
||||||
|
|
||||||
|
info = psb_err_missing_override_method_
|
||||||
|
call psb_errpush(info,name)
|
||||||
|
goto 9999
|
||||||
|
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
return
|
||||||
|
|
||||||
|
9999 continue
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
if (err_act == psb_act_abort_) then
|
||||||
|
call psb_error()
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
return
|
||||||
|
|
||||||
|
end subroutine mld_d_base_solver_apply_vect
|
||||||
|
|
||||||
|
|
||||||
|
!
|
||||||
|
! Build
|
||||||
|
! The base version throws an error, since it means that no explicit
|
||||||
|
! choice was made.
|
||||||
|
!
|
||||||
|
subroutine mld_d_base_solver_bld(a,desc_a,sv,upd,info,b,amold,vmold)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_d_base_solver_mod, mld_protect_name => mld_d_base_solver_bld
|
||||||
|
Implicit None
|
||||||
|
! Arguments
|
||||||
|
type(psb_dspmat_type), intent(in), target :: a
|
||||||
|
Type(psb_desc_type), Intent(in) :: desc_a
|
||||||
|
class(mld_d_base_solver_type), intent(inout) :: sv
|
||||||
|
character, intent(in) :: upd
|
||||||
|
integer, intent(out) :: info
|
||||||
|
type(psb_dspmat_type), intent(in), target, optional :: b
|
||||||
|
class(psb_d_base_sparse_mat), intent(in), optional :: amold
|
||||||
|
class(psb_d_base_vect_type), intent(in), optional :: vmold
|
||||||
|
|
||||||
|
Integer :: err_act
|
||||||
|
character(len=20) :: name='d_base_solver_bld'
|
||||||
|
|
||||||
|
call psb_erractionsave(err_act)
|
||||||
|
|
||||||
|
info = psb_err_missing_override_method_
|
||||||
|
call psb_errpush(info,name)
|
||||||
|
goto 9999
|
||||||
|
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
return
|
||||||
|
|
||||||
|
9999 continue
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
if (err_act == psb_act_abort_) then
|
||||||
|
call psb_error()
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
return
|
||||||
|
end subroutine mld_d_base_solver_bld
|
||||||
|
|
||||||
|
subroutine mld_d_base_solver_check(sv,info)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_d_base_solver_mod, mld_protect_name => mld_d_base_solver_check
|
||||||
|
Implicit None
|
||||||
|
! Arguments
|
||||||
|
class(mld_d_base_solver_type), intent(inout) :: sv
|
||||||
|
integer, intent(out) :: info
|
||||||
|
Integer :: err_act
|
||||||
|
character(len=20) :: name='d_base_solver_check'
|
||||||
|
|
||||||
|
call psb_erractionsave(err_act)
|
||||||
|
info = psb_success_
|
||||||
|
|
||||||
|
|
||||||
|
if (info /= psb_success_) goto 9999
|
||||||
|
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
return
|
||||||
|
|
||||||
|
9999 continue
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
if (err_act == psb_act_abort_) then
|
||||||
|
call psb_error()
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
return
|
||||||
|
end subroutine mld_d_base_solver_check
|
||||||
|
|
||||||
|
!
|
||||||
|
! Set.
|
||||||
|
! The base version does nothing; the principle is that
|
||||||
|
! SET acts on what is known, and delegates what is unknown.
|
||||||
|
! Since we are at the bottom of the hierarchy, there's no one
|
||||||
|
! to delegate, so we do nothing.
|
||||||
|
!
|
||||||
|
subroutine mld_d_base_solver_seti(sv,what,val,info)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_d_base_solver_mod, mld_protect_name => mld_d_base_solver_seti
|
||||||
|
Implicit None
|
||||||
|
! Arguments
|
||||||
|
class(mld_d_base_solver_type), intent(inout) :: sv
|
||||||
|
integer, intent(in) :: what
|
||||||
|
integer, intent(in) :: val
|
||||||
|
integer, intent(out) :: info
|
||||||
|
Integer :: err_act
|
||||||
|
character(len=20) :: name='d_base_solver_seti'
|
||||||
|
|
||||||
|
! Correct action here is doing nothing.
|
||||||
|
info = 0
|
||||||
|
|
||||||
|
return
|
||||||
|
end subroutine mld_d_base_solver_seti
|
||||||
|
|
||||||
|
subroutine mld_d_base_solver_setc(sv,what,val,info)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_d_base_solver_mod, mld_protect_name => mld_d_base_solver_setc
|
||||||
|
Implicit None
|
||||||
|
! Arguments
|
||||||
|
class(mld_d_base_solver_type), intent(inout) :: sv
|
||||||
|
integer, intent(in) :: what
|
||||||
|
character(len=*), intent(in) :: val
|
||||||
|
integer, intent(out) :: info
|
||||||
|
Integer :: err_act, ival
|
||||||
|
character(len=20) :: name='d_base_solver_setc'
|
||||||
|
|
||||||
|
call psb_erractionsave(err_act)
|
||||||
|
|
||||||
|
info = psb_success_
|
||||||
|
|
||||||
|
call mld_stringval(val,ival,info)
|
||||||
|
if (info == psb_success_) call sv%set(what,ival,info)
|
||||||
|
|
||||||
|
if (info /= psb_success_) goto 9999
|
||||||
|
|
||||||
|
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
return
|
||||||
|
|
||||||
|
9999 continue
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
if (err_act == psb_act_abort_) then
|
||||||
|
call psb_error()
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
return
|
||||||
|
end subroutine mld_d_base_solver_setc
|
||||||
|
|
||||||
|
subroutine mld_d_base_solver_setr(sv,what,val,info)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_d_base_solver_mod, mld_protect_name => mld_d_base_solver_setr
|
||||||
|
Implicit None
|
||||||
|
! Arguments
|
||||||
|
class(mld_d_base_solver_type), intent(inout) :: sv
|
||||||
|
integer, intent(in) :: what
|
||||||
|
real(psb_dpk_), intent(in) :: val
|
||||||
|
integer, intent(out) :: info
|
||||||
|
Integer :: err_act
|
||||||
|
character(len=20) :: name='d_base_solver_setr'
|
||||||
|
|
||||||
|
|
||||||
|
! Correct action here is doing nothing.
|
||||||
|
info = 0
|
||||||
|
|
||||||
|
return
|
||||||
|
end subroutine mld_d_base_solver_setr
|
||||||
|
|
||||||
|
!
|
||||||
|
! Free
|
||||||
|
! The base version throws an error, since it means that no explicit
|
||||||
|
! choice was made. IS THIS CORRECT? I suspect it would be better
|
||||||
|
! to be silent here, to cover reallocation.
|
||||||
|
!
|
||||||
|
subroutine mld_d_base_solver_free(sv,info)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_d_base_solver_mod, mld_protect_name => mld_d_base_solver_free
|
||||||
|
Implicit None
|
||||||
|
! Arguments
|
||||||
|
class(mld_d_base_solver_type), intent(inout) :: sv
|
||||||
|
integer, intent(out) :: info
|
||||||
|
Integer :: err_act
|
||||||
|
character(len=20) :: name='d_base_solver_free'
|
||||||
|
|
||||||
|
call psb_erractionsave(err_act)
|
||||||
|
|
||||||
|
info = psb_err_missing_override_method_
|
||||||
|
call psb_errpush(info,name)
|
||||||
|
goto 9999
|
||||||
|
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
return
|
||||||
|
|
||||||
|
9999 continue
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
if (err_act == psb_act_abort_) then
|
||||||
|
call psb_error()
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
return
|
||||||
|
end subroutine mld_d_base_solver_free
|
||||||
|
|
||||||
|
subroutine mld_d_base_solver_descr(sv,info,iout,coarse)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_d_base_solver_mod, mld_protect_name => mld_d_base_solver_descr
|
||||||
|
Implicit None
|
||||||
|
! Arguments
|
||||||
|
class(mld_d_base_solver_type), intent(in) :: sv
|
||||||
|
integer, intent(out) :: info
|
||||||
|
integer, intent(in), optional :: iout
|
||||||
|
logical, intent(in), optional :: coarse
|
||||||
|
|
||||||
|
! Local variables
|
||||||
|
integer :: err_act
|
||||||
|
integer :: ictxt, me, np
|
||||||
|
character(len=20), parameter :: name='mld_d_base_solver_descr'
|
||||||
|
integer :: iout_
|
||||||
|
|
||||||
|
|
||||||
|
call psb_erractionsave(err_act)
|
||||||
|
|
||||||
|
info = psb_err_missing_override_method_
|
||||||
|
call psb_errpush(info,name)
|
||||||
|
goto 9999
|
||||||
|
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
return
|
||||||
|
|
||||||
|
9999 continue
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
if (err_act == psb_act_abort_) then
|
||||||
|
call psb_error()
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
return
|
||||||
|
end subroutine mld_d_base_solver_descr
|
||||||
|
|
||||||
|
!
|
||||||
|
! Dump. For debugging purposes.
|
||||||
|
!
|
||||||
|
subroutine mld_d_base_solver_dmp(sv,ictxt,level,info,prefix,head,solver)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_d_base_solver_mod, mld_protect_name => mld_d_base_solver_dmp
|
||||||
|
implicit none
|
||||||
|
class(mld_d_base_solver_type), intent(in) :: sv
|
||||||
|
integer, intent(in) :: ictxt,level
|
||||||
|
integer, intent(out) :: info
|
||||||
|
character(len=*), intent(in), optional :: prefix, head
|
||||||
|
logical, optional, intent(in) :: solver
|
||||||
|
integer :: i, j, il1, iln, lname, lev
|
||||||
|
integer :: icontxt,iam, np
|
||||||
|
character(len=80) :: prefix_
|
||||||
|
character(len=120) :: fname ! len should be at least 20 more than
|
||||||
|
logical :: solver_
|
||||||
|
! len of prefix_
|
||||||
|
|
||||||
|
info = 0
|
||||||
|
|
||||||
|
if (present(prefix)) then
|
||||||
|
prefix_ = trim(prefix(1:min(len(prefix),len(prefix_))))
|
||||||
|
else
|
||||||
|
prefix_ = "dump_slv_d"
|
||||||
|
end if
|
||||||
|
|
||||||
|
call psb_info(ictxt,iam,np)
|
||||||
|
|
||||||
|
if (present(solver)) then
|
||||||
|
solver_ = solver
|
||||||
|
else
|
||||||
|
solver_ = .false.
|
||||||
|
end if
|
||||||
|
lname = len_trim(prefix_)
|
||||||
|
fname = trim(prefix_)
|
||||||
|
write(fname(lname+1:lname+5),'(a,i3.3)') '_p',iam
|
||||||
|
lname = lname + 5
|
||||||
|
|
||||||
|
! At base level do nothing for the solver
|
||||||
|
|
||||||
|
end subroutine mld_d_base_solver_dmp
|
||||||
|
|
@ -0,0 +1,459 @@
|
|||||||
|
!!$
|
||||||
|
!!$
|
||||||
|
!!$ MLD2P4 version 2.0
|
||||||
|
!!$ MultiLevel Domain Decomposition Parallel Preconditioners Package
|
||||||
|
!!$ based on PSBLAS (Parallel Sparse BLAS version 3.0)
|
||||||
|
!!$
|
||||||
|
!!$ (C) Copyright 2008,2009,2010
|
||||||
|
!!$
|
||||||
|
!!$ Salvatore Filippone University of Rome Tor Vergata
|
||||||
|
!!$ Alfredo Buttari CNRS-IRIT, Toulouse
|
||||||
|
!!$ Pasqua D'Ambra ICAR-CNR, Naples
|
||||||
|
!!$ Daniela di Serafino Second University of Naples
|
||||||
|
!!$
|
||||||
|
!!$ 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 MLD2P4 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 MLD2P4 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: mld_file_onelev_descr
|
||||||
|
! Version: real
|
||||||
|
!
|
||||||
|
! This routine prints a description of the preconditioner to the standard
|
||||||
|
! output or to a file. It must be called after the preconditioner has been
|
||||||
|
! built by mld_precbld.
|
||||||
|
!
|
||||||
|
! Arguments:
|
||||||
|
! p - type(mld_Tprec_type), input.
|
||||||
|
! The preconditioner data structure to be printed out.
|
||||||
|
! info - integer, output.
|
||||||
|
! error code.
|
||||||
|
! iout - integer, input, optional.
|
||||||
|
! The id of the file where the preconditioner description
|
||||||
|
! will be printed. If iout is not present, then the standard
|
||||||
|
! output is condidered.
|
||||||
|
!
|
||||||
|
subroutine mld_d_base_onelev_descr(lv,il,nl,info,iout)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_donelev_mod, mld_protect_name => mld_d_base_onelev_descr
|
||||||
|
Implicit None
|
||||||
|
! Arguments
|
||||||
|
class(mld_donelev_type), intent(in) :: lv
|
||||||
|
integer, intent(in) :: il,nl
|
||||||
|
integer, intent(out) :: info
|
||||||
|
integer, intent(in), optional :: iout
|
||||||
|
|
||||||
|
! Local variables
|
||||||
|
integer :: err_act
|
||||||
|
integer :: ictxt, me, np
|
||||||
|
character(len=20), parameter :: name='mld_d_base_onelev_descr'
|
||||||
|
integer :: iout_
|
||||||
|
logical :: coarse
|
||||||
|
|
||||||
|
|
||||||
|
call psb_erractionsave(err_act)
|
||||||
|
|
||||||
|
|
||||||
|
coarse = (il==nl)
|
||||||
|
|
||||||
|
if (present(iout)) then
|
||||||
|
iout_ = iout
|
||||||
|
else
|
||||||
|
iout_ = 6
|
||||||
|
end if
|
||||||
|
|
||||||
|
write(iout_,*)
|
||||||
|
if (il == 2) then
|
||||||
|
call lv%parms%mldescr(iout_,info)
|
||||||
|
write(iout_,*)
|
||||||
|
end if
|
||||||
|
|
||||||
|
if (coarse) then
|
||||||
|
write(iout_,*) ' Level ',il,' (coarsest)'
|
||||||
|
else
|
||||||
|
write(iout_,*) ' Level ',il
|
||||||
|
end if
|
||||||
|
|
||||||
|
call lv%parms%descr(iout_,info,coarse=coarse)
|
||||||
|
|
||||||
|
if (nl > 1) then
|
||||||
|
if (allocated(lv%map%naggr)) then
|
||||||
|
write(iout_,*) ' Size of coarse matrix: ', &
|
||||||
|
& sum(lv%map%naggr(:))
|
||||||
|
write(iout_,*) ' Sizes of aggregates: ', &
|
||||||
|
& lv%map%naggr(:)
|
||||||
|
end if
|
||||||
|
end if
|
||||||
|
|
||||||
|
if (coarse.and.allocated(lv%sm)) &
|
||||||
|
& call lv%sm%descr(info,iout=iout_,coarse=coarse)
|
||||||
|
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
return
|
||||||
|
|
||||||
|
9999 continue
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
if (err_act == psb_act_abort_) then
|
||||||
|
call psb_error()
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
return
|
||||||
|
end subroutine mld_d_base_onelev_descr
|
||||||
|
|
||||||
|
|
||||||
|
!
|
||||||
|
! Subroutines: mld_T_onelev_precfree
|
||||||
|
! Version: real
|
||||||
|
!
|
||||||
|
! These routines deallocate the mld_Tonelev_type
|
||||||
|
!
|
||||||
|
! Arguments:
|
||||||
|
! p - type(mld_Tonelev_type), input.
|
||||||
|
! The data structure to be deallocated.
|
||||||
|
! info - integer, output.
|
||||||
|
! error code.
|
||||||
|
!
|
||||||
|
subroutine mld_d_base_onelev_free(lv,info)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_donelev_mod, mld_protect_name =>: mld_T_onelev_precfree
|
||||||
|
implicit none
|
||||||
|
|
||||||
|
class(mld_donelev_type), intent(inout) :: lv
|
||||||
|
integer, intent(out) :: info
|
||||||
|
integer :: i
|
||||||
|
|
||||||
|
info = psb_success_
|
||||||
|
|
||||||
|
! We might just deallocate the top level array, except
|
||||||
|
! that there may be inner objects containing C pointers,
|
||||||
|
! e.g. UMFPACK, SLU or CUDA stuff.
|
||||||
|
! We really need FINALs.
|
||||||
|
call lv%sm%free(info)
|
||||||
|
|
||||||
|
call lv%ac%free()
|
||||||
|
if (psb_is_ok_desc(lv%desc_ac)) &
|
||||||
|
& call psb_cdfree(lv%desc_ac,info)
|
||||||
|
call lv%map%free(info)
|
||||||
|
|
||||||
|
! This is a pointer to something else, must not free it here.
|
||||||
|
nullify(lv%base_a)
|
||||||
|
! This is a pointer to something else, must not free it here.
|
||||||
|
nullify(lv%base_desc)
|
||||||
|
|
||||||
|
call lv%nullify()
|
||||||
|
|
||||||
|
end subroutine mld_d_base_onelev_free
|
||||||
|
|
||||||
|
!
|
||||||
|
! Onelevel checks.
|
||||||
|
! The number of Jacobi sweeps to be applied is not
|
||||||
|
! tied to the Jacobi smoother: logically, you have
|
||||||
|
! a smoother and you can choose to apply it any number
|
||||||
|
! of times you like.
|
||||||
|
!
|
||||||
|
subroutine mld_d_base_onelev_check(lv,info)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_donelev_mod, mld_protect_name => mld_d_base_onelev_check
|
||||||
|
|
||||||
|
Implicit None
|
||||||
|
|
||||||
|
! Arguments
|
||||||
|
class(mld_donelev_type), intent(inout) :: lv
|
||||||
|
integer, intent(out) :: info
|
||||||
|
Integer :: err_act
|
||||||
|
character(len=20) :: name='d_base_onelev_check'
|
||||||
|
|
||||||
|
call psb_erractionsave(err_act)
|
||||||
|
info = psb_success_
|
||||||
|
|
||||||
|
call mld_check_def(lv%parms%sweeps,&
|
||||||
|
& 'Jacobi sweeps',1,is_legal_jac_sweeps)
|
||||||
|
call mld_check_def(lv%parms%sweeps_pre,&
|
||||||
|
& 'Jacobi sweeps',1,is_legal_jac_sweeps)
|
||||||
|
call mld_check_def(lv%parms%sweeps_post,&
|
||||||
|
& 'Jacobi sweeps',1,is_legal_jac_sweeps)
|
||||||
|
|
||||||
|
|
||||||
|
if (allocated(lv%sm)) then
|
||||||
|
call lv%sm%check(info)
|
||||||
|
else
|
||||||
|
info=3111
|
||||||
|
call psb_errpush(info,name)
|
||||||
|
goto 9999
|
||||||
|
end if
|
||||||
|
|
||||||
|
if (info /= psb_success_) goto 9999
|
||||||
|
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
return
|
||||||
|
|
||||||
|
9999 continue
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
if (err_act == psb_act_abort_) then
|
||||||
|
call psb_error()
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
return
|
||||||
|
end subroutine mld_d_base_onelev_check
|
||||||
|
|
||||||
|
|
||||||
|
!
|
||||||
|
! Set routines:
|
||||||
|
! Parameters belonging here are:
|
||||||
|
! Number of smoothing sweeps;
|
||||||
|
! Smoother position;
|
||||||
|
! Aggregation related parameters
|
||||||
|
! Record request on coarse level solver,
|
||||||
|
! for checks on solver vs. smoother nomenclature
|
||||||
|
! reconciliation.
|
||||||
|
!
|
||||||
|
subroutine mld_d_base_onelev_seti(lv,what,val,info)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_donelev_mod, mld_protect_name => mld_d_base_onelev_seti
|
||||||
|
|
||||||
|
Implicit None
|
||||||
|
|
||||||
|
! Arguments
|
||||||
|
class(mld_donelev_type), intent(inout) :: lv
|
||||||
|
integer, intent(in) :: what
|
||||||
|
integer, intent(in) :: val
|
||||||
|
integer, intent(out) :: info
|
||||||
|
Integer :: err_act
|
||||||
|
character(len=20) :: name='d_base_onelev_seti'
|
||||||
|
|
||||||
|
call psb_erractionsave(err_act)
|
||||||
|
info = psb_success_
|
||||||
|
|
||||||
|
select case (what)
|
||||||
|
|
||||||
|
case (mld_smoother_sweeps_)
|
||||||
|
lv%parms%sweeps = val
|
||||||
|
lv%parms%sweeps_pre = val
|
||||||
|
lv%parms%sweeps_post = val
|
||||||
|
|
||||||
|
case (mld_smoother_sweeps_pre_)
|
||||||
|
lv%parms%sweeps_pre = val
|
||||||
|
|
||||||
|
case (mld_smoother_sweeps_post_)
|
||||||
|
lv%parms%sweeps_post = val
|
||||||
|
|
||||||
|
case (mld_ml_type_)
|
||||||
|
lv%parms%ml_type = val
|
||||||
|
|
||||||
|
case (mld_aggr_alg_)
|
||||||
|
lv%parms%aggr_alg = val
|
||||||
|
|
||||||
|
case (mld_aggr_kind_)
|
||||||
|
lv%parms%aggr_kind = val
|
||||||
|
|
||||||
|
case (mld_coarse_mat_)
|
||||||
|
lv%parms%coarse_mat = val
|
||||||
|
|
||||||
|
case (mld_smoother_pos_)
|
||||||
|
lv%parms%smoother_pos = val
|
||||||
|
|
||||||
|
case (mld_aggr_omega_alg_)
|
||||||
|
lv%parms%aggr_omega_alg= val
|
||||||
|
|
||||||
|
case (mld_aggr_eig_)
|
||||||
|
lv%parms%aggr_eig = val
|
||||||
|
|
||||||
|
case (mld_aggr_filter_)
|
||||||
|
lv%parms%aggr_filter = val
|
||||||
|
|
||||||
|
case (mld_coarse_solve_)
|
||||||
|
lv%parms%coarse_solve = val
|
||||||
|
|
||||||
|
case default
|
||||||
|
if (allocated(lv%sm)) then
|
||||||
|
call lv%sm%set(what,val,info)
|
||||||
|
end if
|
||||||
|
if (info /= psb_success_) goto 9999
|
||||||
|
end select
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
return
|
||||||
|
|
||||||
|
9999 continue
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
if (err_act == psb_act_abort_) then
|
||||||
|
call psb_error()
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
return
|
||||||
|
end subroutine mld_d_base_onelev_seti
|
||||||
|
|
||||||
|
subroutine mld_d_base_onelev_setc(lv,what,val,info)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_donelev_mod, mld_protect_name => mld_d_base_onelev_setc
|
||||||
|
|
||||||
|
Implicit None
|
||||||
|
|
||||||
|
! Arguments
|
||||||
|
class(mld_donelev_type), intent(inout) :: lv
|
||||||
|
integer, intent(in) :: what
|
||||||
|
character(len=*), intent(in) :: val
|
||||||
|
integer, intent(out) :: info
|
||||||
|
Integer :: err_act
|
||||||
|
character(len=20) :: name='d_base_onelev_setc'
|
||||||
|
integer :: ival
|
||||||
|
|
||||||
|
call psb_erractionsave(err_act)
|
||||||
|
|
||||||
|
info = psb_success_
|
||||||
|
|
||||||
|
call mld_stringval(val,ival,info)
|
||||||
|
if (info == psb_success_) call lv%set(what,ival,info)
|
||||||
|
|
||||||
|
if (info /= psb_success_) goto 9999
|
||||||
|
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
return
|
||||||
|
|
||||||
|
9999 continue
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
if (err_act == psb_act_abort_) then
|
||||||
|
call psb_error()
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
return
|
||||||
|
end subroutine mld_d_base_onelev_setc
|
||||||
|
|
||||||
|
subroutine mld_d_base_onelev_setr(lv,what,val,info)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_donelev_mod, mld_protect_name => mld_d_base_onelev_setr
|
||||||
|
|
||||||
|
Implicit None
|
||||||
|
|
||||||
|
! Arguments
|
||||||
|
class(mld_donelev_type), intent(inout) :: lv
|
||||||
|
integer, intent(in) :: what
|
||||||
|
real(psb_dpk_), intent(in) :: val
|
||||||
|
integer, intent(out) :: info
|
||||||
|
Integer :: err_act
|
||||||
|
character(len=20) :: name='d_base_onelev_setr'
|
||||||
|
|
||||||
|
call psb_erractionsave(err_act)
|
||||||
|
|
||||||
|
|
||||||
|
info = psb_success_
|
||||||
|
|
||||||
|
select case (what)
|
||||||
|
|
||||||
|
case (mld_aggr_omega_val_)
|
||||||
|
lv%parms%aggr_omega_val= val
|
||||||
|
|
||||||
|
case (mld_aggr_thresh_)
|
||||||
|
lv%parms%aggr_thresh = val
|
||||||
|
|
||||||
|
case default
|
||||||
|
if (allocated(lv%sm)) then
|
||||||
|
call lv%sm%set(what,val,info)
|
||||||
|
end if
|
||||||
|
if (info /= psb_success_) goto 9999
|
||||||
|
end select
|
||||||
|
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
return
|
||||||
|
|
||||||
|
9999 continue
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
if (err_act == psb_act_abort_) then
|
||||||
|
call psb_error()
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
return
|
||||||
|
end subroutine mld_d_base_onelev_setr
|
||||||
|
|
||||||
|
!
|
||||||
|
! Dump on file: can be fine-tuned to include the (aggregated) matrix
|
||||||
|
! as well as smoother and solver.
|
||||||
|
!
|
||||||
|
subroutine mld_d_base_onelev_dump(lv,level,info,prefix,head,ac,rp,smoother,solver)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_donelev_mod, mld_protect_name => mld_d_base_onelev_dump
|
||||||
|
implicit none
|
||||||
|
class(mld_donelev_type), intent(in) :: lv
|
||||||
|
integer, intent(in) :: level
|
||||||
|
integer, intent(out) :: info
|
||||||
|
character(len=*), intent(in), optional :: prefix, head
|
||||||
|
logical, optional, intent(in) :: ac, rp, smoother, solver
|
||||||
|
integer :: i, j, il1, iln, lname, lev
|
||||||
|
integer :: icontxt,iam, np
|
||||||
|
character(len=80) :: prefix_
|
||||||
|
character(len=120) :: fname ! len should be at least 20 more than
|
||||||
|
logical :: ac_, rp_
|
||||||
|
! len of prefix_
|
||||||
|
|
||||||
|
info = 0
|
||||||
|
|
||||||
|
if (present(prefix)) then
|
||||||
|
prefix_ = trim(prefix(1:min(len(prefix),len(prefix_))))
|
||||||
|
else
|
||||||
|
prefix_ = "dump_lev_d"
|
||||||
|
end if
|
||||||
|
|
||||||
|
if (associated(lv%base_desc)) then
|
||||||
|
icontxt = lv%base_desc%get_context()
|
||||||
|
call psb_info(icontxt,iam,np)
|
||||||
|
else
|
||||||
|
icontxt = -1
|
||||||
|
iam = -1
|
||||||
|
end if
|
||||||
|
if (present(ac)) then
|
||||||
|
ac_ = ac
|
||||||
|
else
|
||||||
|
ac_ = .false.
|
||||||
|
end if
|
||||||
|
if (present(rp)) then
|
||||||
|
rp_ = rp
|
||||||
|
else
|
||||||
|
rp_ = .false.
|
||||||
|
end if
|
||||||
|
lname = len_trim(prefix_)
|
||||||
|
fname = trim(prefix_)
|
||||||
|
write(fname(lname+1:lname+5),'(a,i3.3)') '_p',iam
|
||||||
|
lname = lname + 5
|
||||||
|
|
||||||
|
if (level >= 2) then
|
||||||
|
if (ac_) then
|
||||||
|
write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_ac.mtx'
|
||||||
|
write(0,*) 'Filename ',fname
|
||||||
|
call lv%ac%print(fname,head=head)
|
||||||
|
end if
|
||||||
|
if (rp_) then
|
||||||
|
write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_r.mtx'
|
||||||
|
write(0,*) 'Filename ',fname
|
||||||
|
call lv%map%map_X2Y%print(fname,head=head)
|
||||||
|
write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_p.mtx'
|
||||||
|
write(0,*) 'Filename ',fname
|
||||||
|
call lv%map%map_Y2X%print(fname,head=head)
|
||||||
|
end if
|
||||||
|
end if
|
||||||
|
if (allocated(lv%sm)) &
|
||||||
|
& call lv%sm%dump(icontxt,level,info,smoother=smoother,solver=solver)
|
||||||
|
|
||||||
|
end subroutine mld_d_base_onelev_dump
|
||||||
|
|
||||||
|
|
@ -0,0 +1,481 @@
|
|||||||
|
!!$
|
||||||
|
!!$
|
||||||
|
!!$ MLD2P4 version 2.0
|
||||||
|
!!$ MultiLevel Domain Decomposition Parallel Preconditioners Package
|
||||||
|
!!$ based on PSBLAS (Parallel Sparse BLAS version 3.0)
|
||||||
|
!!$
|
||||||
|
!!$ (C) Copyright 2008,2009,2010
|
||||||
|
!!$
|
||||||
|
!!$ Salvatore Filippone University of Rome Tor Vergata
|
||||||
|
!!$ Alfredo Buttari CNRS-IRIT, Toulouse
|
||||||
|
!!$ Pasqua D'Ambra ICAR-CNR, Naples
|
||||||
|
!!$ Daniela di Serafino Second University of Naples
|
||||||
|
!!$
|
||||||
|
!!$ 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 MLD2P4 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 MLD2P4 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.
|
||||||
|
!!$
|
||||||
|
!!$
|
||||||
|
|
||||||
|
!
|
||||||
|
! Apply: comes in two versions, on plain arrays or on encapsulated
|
||||||
|
! vectors.
|
||||||
|
! This basic version just applies the local solver, whatever that
|
||||||
|
! is.
|
||||||
|
!
|
||||||
|
|
||||||
|
subroutine mld_s_base_smoother_apply(alpha,sm,x,beta,y,desc_data,trans,sweeps,work,info)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_s_base_smoother_mod, mld_protect_name => mld_s_base_smoother_apply
|
||||||
|
implicit none
|
||||||
|
type(psb_desc_type), intent(in) :: desc_data
|
||||||
|
class(mld_s_base_smoother_type), intent(in) :: sm
|
||||||
|
real(psb_spk_),intent(inout) :: x(:)
|
||||||
|
real(psb_spk_),intent(inout) :: y(:)
|
||||||
|
real(psb_spk_),intent(in) :: alpha,beta
|
||||||
|
character(len=1),intent(in) :: trans
|
||||||
|
integer, intent(in) :: sweeps
|
||||||
|
real(psb_spk_),target, intent(inout) :: work(:)
|
||||||
|
integer, intent(out) :: info
|
||||||
|
|
||||||
|
Integer :: err_act
|
||||||
|
character(len=20) :: name='s_base_smoother_apply'
|
||||||
|
|
||||||
|
call psb_erractionsave(err_act)
|
||||||
|
info = psb_success_
|
||||||
|
if (allocated(sm%sv)) then
|
||||||
|
call sm%sv%apply(alpha,x,beta,y,desc_data,trans,work,info)
|
||||||
|
else
|
||||||
|
info = 1121
|
||||||
|
endif
|
||||||
|
if (info /= psb_success_) then
|
||||||
|
call psb_errpush(info,name)
|
||||||
|
goto 9999
|
||||||
|
end if
|
||||||
|
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
return
|
||||||
|
|
||||||
|
9999 continue
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
if (err_act == psb_act_abort_) then
|
||||||
|
call psb_error()
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
return
|
||||||
|
|
||||||
|
end subroutine mld_s_base_smoother_apply
|
||||||
|
|
||||||
|
subroutine mld_s_base_smoother_apply_vect(alpha,sm,x,beta,y,desc_data,&
|
||||||
|
& trans,sweeps,work,info)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_s_base_smoother_mod, mld_protect_name => mld_s_base_smoother_apply_vect
|
||||||
|
implicit none
|
||||||
|
type(psb_desc_type), intent(in) :: desc_data
|
||||||
|
class(mld_s_base_smoother_type), intent(inout) :: sm
|
||||||
|
type(psb_s_vect_type),intent(inout) :: x
|
||||||
|
type(psb_s_vect_type),intent(inout) :: y
|
||||||
|
real(psb_spk_),intent(in) :: alpha,beta
|
||||||
|
character(len=1),intent(in) :: trans
|
||||||
|
integer, intent(in) :: sweeps
|
||||||
|
real(psb_spk_),target, intent(inout) :: work(:)
|
||||||
|
integer, intent(out) :: info
|
||||||
|
|
||||||
|
Integer :: err_act
|
||||||
|
character(len=20) :: name='s_base_smoother_apply'
|
||||||
|
|
||||||
|
call psb_erractionsave(err_act)
|
||||||
|
info = psb_success_
|
||||||
|
if (allocated(sm%sv)) then
|
||||||
|
call sm%sv%apply(alpha,x,beta,y,desc_data,trans,work,info)
|
||||||
|
else
|
||||||
|
info = 1121
|
||||||
|
endif
|
||||||
|
if (info /= psb_success_) then
|
||||||
|
call psb_errpush(info,name)
|
||||||
|
goto 9999
|
||||||
|
end if
|
||||||
|
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
return
|
||||||
|
|
||||||
|
9999 continue
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
if (err_act == psb_act_abort_) then
|
||||||
|
call psb_error()
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
return
|
||||||
|
|
||||||
|
end subroutine mld_s_base_smoother_apply_vect
|
||||||
|
|
||||||
|
!
|
||||||
|
! Check:
|
||||||
|
! 1. Check that we do have a solver object
|
||||||
|
! 2. Call its check method
|
||||||
|
!
|
||||||
|
|
||||||
|
subroutine mld_s_base_smoother_check(sm,info)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_s_base_smoother_mod, mld_protect_name => mld_s_base_smoother_check
|
||||||
|
Implicit None
|
||||||
|
|
||||||
|
! Arguments
|
||||||
|
class(mld_s_base_smoother_type), intent(inout) :: sm
|
||||||
|
integer, intent(out) :: info
|
||||||
|
Integer :: err_act
|
||||||
|
character(len=20) :: name='s_base_smoother_check'
|
||||||
|
|
||||||
|
call psb_erractionsave(err_act)
|
||||||
|
info = psb_success_
|
||||||
|
|
||||||
|
if (allocated(sm%sv)) then
|
||||||
|
call sm%sv%check(info)
|
||||||
|
else
|
||||||
|
info=3111
|
||||||
|
call psb_errpush(info,name)
|
||||||
|
goto 9999
|
||||||
|
end if
|
||||||
|
|
||||||
|
if (info /= psb_success_) goto 9999
|
||||||
|
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
return
|
||||||
|
|
||||||
|
9999 continue
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
if (err_act == psb_act_abort_) then
|
||||||
|
call psb_error()
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
return
|
||||||
|
end subroutine mld_s_base_smoother_check
|
||||||
|
|
||||||
|
!
|
||||||
|
! Set methods: the come in multiple versions according
|
||||||
|
! to whether we are setting with integer, real or character
|
||||||
|
! input.
|
||||||
|
! The basic rule is: if the input refers to a parameter
|
||||||
|
! of the smoother, use it, otherwise pass it to the
|
||||||
|
! solver object for further processing.
|
||||||
|
! Since there are no parameters in the base smoother
|
||||||
|
! we just pass everything to the solver object.
|
||||||
|
!
|
||||||
|
subroutine mld_s_base_smoother_seti(sm,what,val,info)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_s_base_smoother_mod, mld_protect_name => mld_s_base_smoother_seti
|
||||||
|
Implicit None
|
||||||
|
! Arguments
|
||||||
|
class(mld_s_base_smoother_type), intent(inout) :: sm
|
||||||
|
integer, intent(in) :: what
|
||||||
|
integer, intent(in) :: val
|
||||||
|
integer, intent(out) :: info
|
||||||
|
Integer :: err_act
|
||||||
|
character(len=20) :: name='s_base_smoother_seti'
|
||||||
|
|
||||||
|
call psb_erractionsave(err_act)
|
||||||
|
info = psb_success_
|
||||||
|
|
||||||
|
if (allocated(sm%sv)) then
|
||||||
|
call sm%sv%set(what,val,info)
|
||||||
|
end if
|
||||||
|
if (info /= psb_success_) goto 9999
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
return
|
||||||
|
|
||||||
|
9999 continue
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
if (err_act == psb_act_abort_) then
|
||||||
|
call psb_error()
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
return
|
||||||
|
end subroutine mld_s_base_smoother_seti
|
||||||
|
|
||||||
|
subroutine mld_s_base_smoother_setc(sm,what,val,info)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_s_base_smoother_mod, mld_protect_name => mld_s_base_smoother_setc
|
||||||
|
Implicit None
|
||||||
|
|
||||||
|
! Arguments
|
||||||
|
class(mld_s_base_smoother_type), intent(inout) :: sm
|
||||||
|
integer, intent(in) :: what
|
||||||
|
character(len=*), intent(in) :: val
|
||||||
|
integer, intent(out) :: info
|
||||||
|
Integer :: err_act
|
||||||
|
character(len=20) :: name='s_base_smoother_setc'
|
||||||
|
|
||||||
|
call psb_erractionsave(err_act)
|
||||||
|
|
||||||
|
info = psb_success_
|
||||||
|
|
||||||
|
if (allocated(sm%sv)) then
|
||||||
|
call sm%sv%set(what,val,info)
|
||||||
|
end if
|
||||||
|
if (info /= psb_success_) goto 9999
|
||||||
|
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
return
|
||||||
|
|
||||||
|
9999 continue
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
if (err_act == psb_act_abort_) then
|
||||||
|
call psb_error()
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
return
|
||||||
|
end subroutine mld_s_base_smoother_setc
|
||||||
|
|
||||||
|
subroutine mld_s_base_smoother_setr(sm,what,val,info)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_s_base_smoother_mod, mld_protect_name => mld_s_base_smoother_setr
|
||||||
|
Implicit None
|
||||||
|
|
||||||
|
! Arguments
|
||||||
|
class(mld_s_base_smoother_type), intent(inout) :: sm
|
||||||
|
integer, intent(in) :: what
|
||||||
|
real(psb_spk_), intent(in) :: val
|
||||||
|
integer, intent(out) :: info
|
||||||
|
Integer :: err_act
|
||||||
|
character(len=20) :: name='s_base_smoother_setr'
|
||||||
|
|
||||||
|
call psb_erractionsave(err_act)
|
||||||
|
|
||||||
|
|
||||||
|
info = psb_success_
|
||||||
|
|
||||||
|
if (allocated(sm%sv)) then
|
||||||
|
call sm%sv%set(what,val,info)
|
||||||
|
end if
|
||||||
|
if (info /= psb_success_) goto 9999
|
||||||
|
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
return
|
||||||
|
|
||||||
|
9999 continue
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
if (err_act == psb_act_abort_) then
|
||||||
|
call psb_error()
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
return
|
||||||
|
end subroutine mld_s_base_smoother_setr
|
||||||
|
|
||||||
|
|
||||||
|
!
|
||||||
|
! Build method.
|
||||||
|
! At base level we only have to pass data to the inner solver.
|
||||||
|
! AMOLD/VMOLD allow to have any relevant sparse matrix or vector
|
||||||
|
! to be stored in a given format. This is essential e.g.
|
||||||
|
! when dealing with GPUs.
|
||||||
|
!
|
||||||
|
subroutine mld_s_base_smoother_bld(a,desc_a,sm,upd,info,amold,vmold)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_s_base_smoother_mod, mld_protect_name => mld_s_base_smoother_bld
|
||||||
|
Implicit None
|
||||||
|
|
||||||
|
! Arguments
|
||||||
|
type(psb_sspmat_type), intent(in), target :: a
|
||||||
|
Type(psb_desc_type), Intent(in) :: desc_a
|
||||||
|
class(mld_s_base_smoother_type), intent(inout) :: sm
|
||||||
|
character, intent(in) :: upd
|
||||||
|
integer, intent(out) :: info
|
||||||
|
class(psb_s_base_sparse_mat), intent(in), optional :: amold
|
||||||
|
class(psb_s_base_vect_type), intent(in), optional :: vmold
|
||||||
|
Integer :: err_act
|
||||||
|
character(len=20) :: name='s_base_smoother_bld'
|
||||||
|
|
||||||
|
call psb_erractionsave(err_act)
|
||||||
|
|
||||||
|
info = psb_success_
|
||||||
|
if (allocated(sm%sv)) then
|
||||||
|
call sm%sv%build(a,desc_a,upd,info,amold=amold,vmold=vmold)
|
||||||
|
else
|
||||||
|
info = 1121
|
||||||
|
call psb_errpush(info,name)
|
||||||
|
endif
|
||||||
|
if (info /= psb_success_) goto 9999
|
||||||
|
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
return
|
||||||
|
|
||||||
|
9999 continue
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
if (err_act == psb_act_abort_) then
|
||||||
|
call psb_error()
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
return
|
||||||
|
end subroutine mld_s_base_smoother_bld
|
||||||
|
|
||||||
|
!
|
||||||
|
! Free method (aka destructor).
|
||||||
|
! In most cases we could do without; however
|
||||||
|
! for cases where there are data objects allocated outside
|
||||||
|
! of the Fortran RTE we need to free them explicitly.
|
||||||
|
!
|
||||||
|
! Even in that case, we could do without this if FINAL
|
||||||
|
! subroutines were supported, which is not the case
|
||||||
|
|
||||||
|
! in GNU Fortran up to 4.7.
|
||||||
|
!
|
||||||
|
subroutine mld_s_base_smoother_free(sm,info)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_s_base_smoother_mod, mld_protect_name => s
|
||||||
|
Implicit None
|
||||||
|
|
||||||
|
! Arguments
|
||||||
|
class(mld_s_base_smoother_type), intent(inout) :: sm
|
||||||
|
integer, intent(out) :: info
|
||||||
|
Integer :: err_act
|
||||||
|
character(len=20) :: name='s_base_smoother_free'
|
||||||
|
|
||||||
|
call psb_erractionsave(err_act)
|
||||||
|
info = psb_success_
|
||||||
|
|
||||||
|
if (allocated(sm%sv)) then
|
||||||
|
call sm%sv%free(info)
|
||||||
|
end if
|
||||||
|
if (info == psb_success_) deallocate(sm%sv,stat=info)
|
||||||
|
if (info /= psb_success_) then
|
||||||
|
info = psb_err_alloc_dealloc_
|
||||||
|
call psb_errpush(info,name)
|
||||||
|
goto 9999
|
||||||
|
end if
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
return
|
||||||
|
|
||||||
|
9999 continue
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
if (err_act == psb_act_abort_) then
|
||||||
|
call psb_error()
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
return
|
||||||
|
end subroutine mld_s_base_smoother_free
|
||||||
|
|
||||||
|
!
|
||||||
|
! Print a description
|
||||||
|
!
|
||||||
|
|
||||||
|
subroutine mld_s_base_smoother_descr(sm,info,iout,coarse)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_s_base_smoother_mod, mld_protect_name => mld_s_base_smoother_descr
|
||||||
|
Implicit None
|
||||||
|
|
||||||
|
! Arguments
|
||||||
|
class(mld_s_base_smoother_type), intent(in) :: sm
|
||||||
|
integer, intent(out) :: info
|
||||||
|
integer, intent(in), optional :: iout
|
||||||
|
logical, intent(in), optional :: coarse
|
||||||
|
|
||||||
|
! Local variables
|
||||||
|
integer :: err_act
|
||||||
|
integer :: ictxt, me, np
|
||||||
|
character(len=20), parameter :: name='mld_s_base_smoother_descr'
|
||||||
|
integer :: iout_
|
||||||
|
logical :: coarse_
|
||||||
|
|
||||||
|
|
||||||
|
call psb_erractionsave(err_act)
|
||||||
|
info = psb_success_
|
||||||
|
|
||||||
|
if (present(coarse)) then
|
||||||
|
coarse_ = coarse
|
||||||
|
else
|
||||||
|
coarse_ = .false.
|
||||||
|
end if
|
||||||
|
if (present(iout)) then
|
||||||
|
iout_ = iout
|
||||||
|
else
|
||||||
|
iout_ = 6
|
||||||
|
end if
|
||||||
|
|
||||||
|
if (.not.coarse_) &
|
||||||
|
& write(iout_,*) 'Base smoother with local solver'
|
||||||
|
if (allocated(sm%sv)) then
|
||||||
|
call sm%sv%descr(info,iout,coarse)
|
||||||
|
if (info /= psb_success_) then
|
||||||
|
info = psb_err_from_subroutine_
|
||||||
|
call psb_errpush(info,name,a_err='Local solver')
|
||||||
|
goto 9999
|
||||||
|
end if
|
||||||
|
end if
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
return
|
||||||
|
|
||||||
|
9999 continue
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
if (err_act == psb_act_abort_) then
|
||||||
|
call psb_error()
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
return
|
||||||
|
end subroutine mld_s_base_smoother_descr
|
||||||
|
|
||||||
|
!
|
||||||
|
! Dump
|
||||||
|
! to file, for debugging purposes.
|
||||||
|
!
|
||||||
|
subroutine mld_s_base_smoother_dmp(sm,ictxt,level,info,prefix,head,smoother,solver)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_s_base_smoother_mod, mld_protect_name => mld_s_base_smoother_dmp
|
||||||
|
implicit none
|
||||||
|
class(mld_s_base_smoother_type), intent(in) :: sm
|
||||||
|
integer, intent(in) :: ictxt,level
|
||||||
|
integer, intent(out) :: info
|
||||||
|
character(len=*), intent(in), optional :: prefix, head
|
||||||
|
logical, optional, intent(in) :: smoother, solver
|
||||||
|
integer :: i, j, il1, iln, lname, lev
|
||||||
|
integer :: icontxt,iam, np
|
||||||
|
character(len=80) :: prefix_
|
||||||
|
character(len=120) :: fname ! len should be at least 20 more than
|
||||||
|
logical :: smoother_
|
||||||
|
! len of prefix_
|
||||||
|
|
||||||
|
info = 0
|
||||||
|
|
||||||
|
if (present(prefix)) then
|
||||||
|
prefix_ = trim(prefix(1:min(len(prefix),len(prefix_))))
|
||||||
|
else
|
||||||
|
prefix_ = "dump_smth_s"
|
||||||
|
end if
|
||||||
|
|
||||||
|
call psb_info(ictxt,iam,np)
|
||||||
|
|
||||||
|
if (present(smoother)) then
|
||||||
|
smoother_ = smoother
|
||||||
|
else
|
||||||
|
smoother_ = .false.
|
||||||
|
end if
|
||||||
|
lname = len_trim(prefix_)
|
||||||
|
fname = trim(prefix_)
|
||||||
|
write(fname(lname+1:lname+5),'(a,i3.3)') '_p',iam
|
||||||
|
lname = lname + 5
|
||||||
|
|
||||||
|
! At base level do nothing for the smoother
|
||||||
|
if (allocated(sm%sv)) &
|
||||||
|
& call sm%sv%dump(ictxt,level,info,solver=solver)
|
||||||
|
|
||||||
|
end subroutine mld_s_base_smoother_dmp
|
||||||
|
|
@ -0,0 +1,338 @@
|
|||||||
|
!
|
||||||
|
! Apply: comes in two versions, on plain arrays or on encapsulated
|
||||||
|
! vectors.
|
||||||
|
! The base version throws an error, since it means that no explicit
|
||||||
|
! choice was made.
|
||||||
|
! Question: would it make sense to transform the base version into
|
||||||
|
! the ID version, i.e. "base_solver" is the identity operator?
|
||||||
|
!
|
||||||
|
|
||||||
|
subroutine mld_s_base_solver_apply(alpha,sv,x,beta,y,desc_data,trans,work,info)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_s_base_solver_mod, mld_protect_name => mld_s_base_solver_apply
|
||||||
|
implicit none
|
||||||
|
type(psb_desc_type), intent(in) :: desc_data
|
||||||
|
class(mld_s_base_solver_type), intent(in) :: sv
|
||||||
|
real(psb_spk_),intent(inout) :: x(:)
|
||||||
|
real(psb_spk_),intent(inout) :: y(:)
|
||||||
|
real(psb_spk_),intent(in) :: alpha,beta
|
||||||
|
character(len=1),intent(in) :: trans
|
||||||
|
real(psb_spk_),target, intent(inout) :: work(:)
|
||||||
|
integer, intent(out) :: info
|
||||||
|
|
||||||
|
Integer :: err_act
|
||||||
|
character(len=20) :: name='d_base_solver_apply'
|
||||||
|
|
||||||
|
call psb_erractionsave(err_act)
|
||||||
|
|
||||||
|
info = psb_err_missing_override_method_
|
||||||
|
call psb_errpush(info,name)
|
||||||
|
goto 9999
|
||||||
|
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
return
|
||||||
|
|
||||||
|
9999 continue
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
if (err_act == psb_act_abort_) then
|
||||||
|
call psb_error()
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
return
|
||||||
|
|
||||||
|
end subroutine mld_s_base_solver_apply
|
||||||
|
|
||||||
|
subroutine mld_s_base_solver_apply_vect(alpha,sv,x,beta,y,desc_data,trans,work,info)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_s_base_solver_mod, mld_protect_name => mld_s_base_solver_apply_vect
|
||||||
|
implicit none
|
||||||
|
type(psb_desc_type), intent(in) :: desc_data
|
||||||
|
class(mld_s_base_solver_type), intent(inout) :: sv
|
||||||
|
type(psb_s_vect_type),intent(inout) :: x
|
||||||
|
type(psb_s_vect_type),intent(inout) :: y
|
||||||
|
real(psb_spk_),intent(in) :: alpha,beta
|
||||||
|
character(len=1),intent(in) :: trans
|
||||||
|
real(psb_spk_),target, intent(inout) :: work(:)
|
||||||
|
integer, intent(out) :: info
|
||||||
|
|
||||||
|
Integer :: err_act
|
||||||
|
character(len=20) :: name='d_base_solver_apply'
|
||||||
|
|
||||||
|
call psb_erractionsave(err_act)
|
||||||
|
|
||||||
|
info = psb_err_missing_override_method_
|
||||||
|
call psb_errpush(info,name)
|
||||||
|
goto 9999
|
||||||
|
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
return
|
||||||
|
|
||||||
|
9999 continue
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
if (err_act == psb_act_abort_) then
|
||||||
|
call psb_error()
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
return
|
||||||
|
|
||||||
|
end subroutine mld_s_base_solver_apply_vect
|
||||||
|
|
||||||
|
|
||||||
|
!
|
||||||
|
! Build
|
||||||
|
! The base version throws an error, since it means that no explicit
|
||||||
|
! choice was made.
|
||||||
|
!
|
||||||
|
subroutine mld_s_base_solver_bld(a,desc_a,sv,upd,info,b,amold,vmold)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_s_base_solver_mod, mld_protect_name => mld_s_base_solver_bld
|
||||||
|
Implicit None
|
||||||
|
! Arguments
|
||||||
|
type(psb_sspmat_type), intent(in), target :: a
|
||||||
|
Type(psb_desc_type), Intent(in) :: desc_a
|
||||||
|
class(mld_s_base_solver_type), intent(inout) :: sv
|
||||||
|
character, intent(in) :: upd
|
||||||
|
integer, intent(out) :: info
|
||||||
|
type(psb_sspmat_type), intent(in), target, optional :: b
|
||||||
|
class(psb_s_base_sparse_mat), intent(in), optional :: amold
|
||||||
|
class(psb_s_base_vect_type), intent(in), optional :: vmold
|
||||||
|
|
||||||
|
Integer :: err_act
|
||||||
|
character(len=20) :: name='d_base_solver_bld'
|
||||||
|
|
||||||
|
call psb_erractionsave(err_act)
|
||||||
|
|
||||||
|
info = psb_err_missing_override_method_
|
||||||
|
call psb_errpush(info,name)
|
||||||
|
goto 9999
|
||||||
|
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
return
|
||||||
|
|
||||||
|
9999 continue
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
if (err_act == psb_act_abort_) then
|
||||||
|
call psb_error()
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
return
|
||||||
|
end subroutine mld_s_base_solver_bld
|
||||||
|
|
||||||
|
subroutine mld_s_base_solver_check(sv,info)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_s_base_solver_mod, mld_protect_name => mld_s_base_solver_check
|
||||||
|
Implicit None
|
||||||
|
! Arguments
|
||||||
|
class(mld_s_base_solver_type), intent(inout) :: sv
|
||||||
|
integer, intent(out) :: info
|
||||||
|
Integer :: err_act
|
||||||
|
character(len=20) :: name='d_base_solver_check'
|
||||||
|
|
||||||
|
call psb_erractionsave(err_act)
|
||||||
|
info = psb_success_
|
||||||
|
|
||||||
|
|
||||||
|
if (info /= psb_success_) goto 9999
|
||||||
|
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
return
|
||||||
|
|
||||||
|
9999 continue
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
if (err_act == psb_act_abort_) then
|
||||||
|
call psb_error()
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
return
|
||||||
|
end subroutine mld_s_base_solver_check
|
||||||
|
|
||||||
|
!
|
||||||
|
! Set.
|
||||||
|
! The base version does nothing; the principle is that
|
||||||
|
! SET acts on what is known, and delegates what is unknown.
|
||||||
|
! Since we are at the bottom of the hierarchy, there's no one
|
||||||
|
! to delegate, so we do nothing.
|
||||||
|
!
|
||||||
|
subroutine mld_s_base_solver_seti(sv,what,val,info)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_s_base_solver_mod, mld_protect_name => mld_s_base_solver_seti
|
||||||
|
Implicit None
|
||||||
|
! Arguments
|
||||||
|
class(mld_s_base_solver_type), intent(inout) :: sv
|
||||||
|
integer, intent(in) :: what
|
||||||
|
integer, intent(in) :: val
|
||||||
|
integer, intent(out) :: info
|
||||||
|
Integer :: err_act
|
||||||
|
character(len=20) :: name='d_base_solver_seti'
|
||||||
|
|
||||||
|
! Correct action here is doing nothing.
|
||||||
|
info = 0
|
||||||
|
|
||||||
|
return
|
||||||
|
end subroutine mld_s_base_solver_seti
|
||||||
|
|
||||||
|
subroutine mld_s_base_solver_setc(sv,what,val,info)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_s_base_solver_mod, mld_protect_name => mld_s_base_solver_setc
|
||||||
|
Implicit None
|
||||||
|
! Arguments
|
||||||
|
class(mld_s_base_solver_type), intent(inout) :: sv
|
||||||
|
integer, intent(in) :: what
|
||||||
|
character(len=*), intent(in) :: val
|
||||||
|
integer, intent(out) :: info
|
||||||
|
Integer :: err_act, ival
|
||||||
|
character(len=20) :: name='d_base_solver_setc'
|
||||||
|
|
||||||
|
call psb_erractionsave(err_act)
|
||||||
|
|
||||||
|
info = psb_success_
|
||||||
|
|
||||||
|
call mld_stringval(val,ival,info)
|
||||||
|
if (info == psb_success_) call sv%set(what,ival,info)
|
||||||
|
|
||||||
|
if (info /= psb_success_) goto 9999
|
||||||
|
|
||||||
|
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
return
|
||||||
|
|
||||||
|
9999 continue
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
if (err_act == psb_act_abort_) then
|
||||||
|
call psb_error()
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
return
|
||||||
|
end subroutine mld_s_base_solver_setc
|
||||||
|
|
||||||
|
subroutine mld_s_base_solver_setr(sv,what,val,info)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_s_base_solver_mod, mld_protect_name => mld_s_base_solver_setr
|
||||||
|
Implicit None
|
||||||
|
! Arguments
|
||||||
|
class(mld_s_base_solver_type), intent(inout) :: sv
|
||||||
|
integer, intent(in) :: what
|
||||||
|
real(psb_spk_), intent(in) :: val
|
||||||
|
integer, intent(out) :: info
|
||||||
|
Integer :: err_act
|
||||||
|
character(len=20) :: name='d_base_solver_setr'
|
||||||
|
|
||||||
|
|
||||||
|
! Correct action here is doing nothing.
|
||||||
|
info = 0
|
||||||
|
|
||||||
|
return
|
||||||
|
end subroutine mld_s_base_solver_setr
|
||||||
|
|
||||||
|
!
|
||||||
|
! Free
|
||||||
|
! The base version throws an error, since it means that no explicit
|
||||||
|
! choice was made. IS THIS CORRECT? I suspect it would be better
|
||||||
|
! to be silent here, to cover reallocation.
|
||||||
|
!
|
||||||
|
subroutine mld_s_base_solver_free(sv,info)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_s_base_solver_mod, mld_protect_name => mld_s_base_solver_free
|
||||||
|
Implicit None
|
||||||
|
! Arguments
|
||||||
|
class(mld_s_base_solver_type), intent(inout) :: sv
|
||||||
|
integer, intent(out) :: info
|
||||||
|
Integer :: err_act
|
||||||
|
character(len=20) :: name='d_base_solver_free'
|
||||||
|
|
||||||
|
call psb_erractionsave(err_act)
|
||||||
|
|
||||||
|
info = psb_err_missing_override_method_
|
||||||
|
call psb_errpush(info,name)
|
||||||
|
goto 9999
|
||||||
|
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
return
|
||||||
|
|
||||||
|
9999 continue
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
if (err_act == psb_act_abort_) then
|
||||||
|
call psb_error()
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
return
|
||||||
|
end subroutine mld_s_base_solver_free
|
||||||
|
|
||||||
|
subroutine mld_s_base_solver_descr(sv,info,iout,coarse)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_s_base_solver_mod, mld_protect_name => mld_s_base_solver_descr
|
||||||
|
Implicit None
|
||||||
|
! Arguments
|
||||||
|
class(mld_s_base_solver_type), intent(in) :: sv
|
||||||
|
integer, intent(out) :: info
|
||||||
|
integer, intent(in), optional :: iout
|
||||||
|
logical, intent(in), optional :: coarse
|
||||||
|
|
||||||
|
! Local variables
|
||||||
|
integer :: err_act
|
||||||
|
integer :: ictxt, me, np
|
||||||
|
character(len=20), parameter :: name='mld_s_base_solver_descr'
|
||||||
|
integer :: iout_
|
||||||
|
|
||||||
|
|
||||||
|
call psb_erractionsave(err_act)
|
||||||
|
|
||||||
|
info = psb_err_missing_override_method_
|
||||||
|
call psb_errpush(info,name)
|
||||||
|
goto 9999
|
||||||
|
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
return
|
||||||
|
|
||||||
|
9999 continue
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
if (err_act == psb_act_abort_) then
|
||||||
|
call psb_error()
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
return
|
||||||
|
end subroutine mld_s_base_solver_descr
|
||||||
|
|
||||||
|
!
|
||||||
|
! Dump. For debugging purposes.
|
||||||
|
!
|
||||||
|
subroutine mld_s_base_solver_dmp(sv,ictxt,level,info,prefix,head,solver)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_s_base_solver_mod, mld_protect_name => mld_s_base_solver_dmp
|
||||||
|
implicit none
|
||||||
|
class(mld_s_base_solver_type), intent(in) :: sv
|
||||||
|
integer, intent(in) :: ictxt,level
|
||||||
|
integer, intent(out) :: info
|
||||||
|
character(len=*), intent(in), optional :: prefix, head
|
||||||
|
logical, optional, intent(in) :: solver
|
||||||
|
integer :: i, j, il1, iln, lname, lev
|
||||||
|
integer :: icontxt,iam, np
|
||||||
|
character(len=80) :: prefix_
|
||||||
|
character(len=120) :: fname ! len should be at least 20 more than
|
||||||
|
logical :: solver_
|
||||||
|
! len of prefix_
|
||||||
|
|
||||||
|
info = 0
|
||||||
|
|
||||||
|
if (present(prefix)) then
|
||||||
|
prefix_ = trim(prefix(1:min(len(prefix),len(prefix_))))
|
||||||
|
else
|
||||||
|
prefix_ = "dump_slv_s"
|
||||||
|
end if
|
||||||
|
|
||||||
|
call psb_info(ictxt,iam,np)
|
||||||
|
|
||||||
|
if (present(solver)) then
|
||||||
|
solver_ = solver
|
||||||
|
else
|
||||||
|
solver_ = .false.
|
||||||
|
end if
|
||||||
|
lname = len_trim(prefix_)
|
||||||
|
fname = trim(prefix_)
|
||||||
|
write(fname(lname+1:lname+5),'(a,i3.3)') '_p',iam
|
||||||
|
lname = lname + 5
|
||||||
|
|
||||||
|
! At base level do nothing for the solver
|
||||||
|
|
||||||
|
end subroutine mld_s_base_solver_dmp
|
||||||
|
|
@ -0,0 +1,472 @@
|
|||||||
|
!!$
|
||||||
|
!!$
|
||||||
|
!!$ MLD2P4 version 2.0
|
||||||
|
!!$ MultiLevel Domain Decomposition Parallel Preconditioners Package
|
||||||
|
!!$ based on PSBLAS (Parallel Sparse BLAS version 3.0)
|
||||||
|
!!$
|
||||||
|
!!$ (C) Copyright 2008,2009,2010, 2010
|
||||||
|
!!$
|
||||||
|
!!$ Salvatore Filippone University of Rome Tor Vergata
|
||||||
|
!!$ Alfredo Buttari CNRS-IRIT, Toulouse
|
||||||
|
!!$ Pasqua D'Ambra ICAR-CNR, Naples
|
||||||
|
!!$ Daniela di Serafino Second University of Naples
|
||||||
|
!!$
|
||||||
|
!!$ 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 MLD2P4 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 MLD2P4 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 mld_s_ilu_solver_apply_vect(alpha,sv,x,beta,y,desc_data,trans,work,info)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_s_ilu_solver, mld_protect_name => mld_s_ilu_solver_apply_vect
|
||||||
|
implicit none
|
||||||
|
type(psb_desc_type), intent(in) :: desc_data
|
||||||
|
class(mld_s_ilu_solver_type), intent(inout) :: sv
|
||||||
|
type(psb_s_vect_type),intent(inout) :: x
|
||||||
|
type(psb_s_vect_type),intent(inout) :: y
|
||||||
|
real(psb_spk_),intent(in) :: alpha,beta
|
||||||
|
character(len=1),intent(in) :: trans
|
||||||
|
real(psb_spk_),target, intent(inout) :: work(:)
|
||||||
|
integer, intent(out) :: info
|
||||||
|
|
||||||
|
integer :: n_row,n_col
|
||||||
|
type(psb_s_vect_type) :: wv
|
||||||
|
real(psb_spk_), pointer :: ww(:), aux(:), tx(:),ty(:)
|
||||||
|
integer :: ictxt,np,me,i, err_act
|
||||||
|
character :: trans_
|
||||||
|
character(len=20) :: name='s_ilu_solver_apply'
|
||||||
|
|
||||||
|
call psb_erractionsave(err_act)
|
||||||
|
|
||||||
|
info = psb_success_
|
||||||
|
|
||||||
|
trans_ = psb_toupper(trans)
|
||||||
|
select case(trans_)
|
||||||
|
case('N')
|
||||||
|
case('T')
|
||||||
|
case('C')
|
||||||
|
case default
|
||||||
|
call psb_errpush(psb_err_iarg_invalid_i_,name)
|
||||||
|
goto 9999
|
||||||
|
end select
|
||||||
|
|
||||||
|
n_row = desc_data%get_local_rows()
|
||||||
|
n_col = desc_data%get_local_cols()
|
||||||
|
|
||||||
|
|
||||||
|
if (x%get_nrows() < n_row) then
|
||||||
|
info = 36
|
||||||
|
call psb_errpush(info,name,i_err=(/2,n_row,0,0,0/))
|
||||||
|
goto 9999
|
||||||
|
end if
|
||||||
|
if (y%get_nrows() < n_row) then
|
||||||
|
info = 36
|
||||||
|
call psb_errpush(info,name,i_err=(/3,n_row,0,0,0/))
|
||||||
|
goto 9999
|
||||||
|
end if
|
||||||
|
if (sv%dv%get_nrows() < n_row) then
|
||||||
|
info = 1124
|
||||||
|
call psb_errpush(info,name,a_err="preconditioner: DV")
|
||||||
|
goto 9999
|
||||||
|
end if
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (n_col <= size(work)) then
|
||||||
|
ww => work(1:n_col)
|
||||||
|
if ((4*n_col+n_col) <= size(work)) then
|
||||||
|
aux => work(n_col+1:)
|
||||||
|
else
|
||||||
|
allocate(aux(4*n_col),stat=info)
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
allocate(ww(n_col),aux(4*n_col),stat=info)
|
||||||
|
endif
|
||||||
|
|
||||||
|
call wv%bld(n_col,mold=x%v)
|
||||||
|
|
||||||
|
if (info /= psb_success_) then
|
||||||
|
info=psb_err_alloc_request_
|
||||||
|
call psb_errpush(info,name,i_err=(/5*n_col,0,0,0,0/),&
|
||||||
|
& a_err='real(psb_spk_)')
|
||||||
|
goto 9999
|
||||||
|
end if
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
select case(trans_)
|
||||||
|
case('N')
|
||||||
|
call psb_spsm(sone,sv%l,x,szero,wv,desc_data,info,&
|
||||||
|
& trans=trans_,scale='L',diag=sv%dv,choice=psb_none_,work=aux)
|
||||||
|
|
||||||
|
if (info == psb_success_) call psb_spsm(alpha,sv%u,wv,beta,y,desc_data,info,&
|
||||||
|
& trans=trans_,scale='U',choice=psb_none_, work=aux)
|
||||||
|
|
||||||
|
case('T')
|
||||||
|
call psb_spsm(sone,sv%u,x,szero,wv,desc_data,info,&
|
||||||
|
& trans=trans_,scale='L',diag=sv%dv,choice=psb_none_,work=aux)
|
||||||
|
if (info == psb_success_) call psb_spsm(alpha,sv%l,wv,beta,y,desc_data,info,&
|
||||||
|
& trans=trans_,scale='U',choice=psb_none_,work=aux)
|
||||||
|
|
||||||
|
case('C')
|
||||||
|
! For real this is the same of T but in the future we will move to
|
||||||
|
! a preprocessed version, so we need a placeholder
|
||||||
|
call psb_spsm(sone,sv%u,x,szero,wv,desc_data,info,&
|
||||||
|
& trans=trans_,scale='L',diag=sv%dv,choice=psb_none_,work=aux)
|
||||||
|
if (info == psb_success_) call psb_spsm(alpha,sv%l,wv,beta,y,desc_data,info,&
|
||||||
|
& trans=trans_,scale='U',choice=psb_none_,work=aux)
|
||||||
|
|
||||||
|
case default
|
||||||
|
call psb_errpush(psb_err_internal_error_,name,a_err='Invalid TRANS in ILU subsolve')
|
||||||
|
goto 9999
|
||||||
|
end select
|
||||||
|
|
||||||
|
|
||||||
|
if (info /= psb_success_) then
|
||||||
|
|
||||||
|
call psb_errpush(psb_err_internal_error_,name,a_err='Error in subsolve')
|
||||||
|
goto 9999
|
||||||
|
endif
|
||||||
|
call wv%free(info)
|
||||||
|
if (n_col <= size(work)) then
|
||||||
|
if ((4*n_col+n_col) <= size(work)) then
|
||||||
|
else
|
||||||
|
deallocate(aux)
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
deallocate(ww,aux)
|
||||||
|
endif
|
||||||
|
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
return
|
||||||
|
|
||||||
|
9999 continue
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
if (err_act == psb_act_abort_) then
|
||||||
|
call psb_error()
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
return
|
||||||
|
|
||||||
|
end subroutine mld_s_ilu_solver_apply_vect
|
||||||
|
|
||||||
|
|
||||||
|
subroutine mld_s_ilu_solver_apply(alpha,sv,x,beta,y,desc_data,trans,work,info)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_s_ilu_solver, mld_protect_name => mld_s_ilu_solver_apply
|
||||||
|
implicit none
|
||||||
|
type(psb_desc_type), intent(in) :: desc_data
|
||||||
|
class(mld_s_ilu_solver_type), intent(in) :: sv
|
||||||
|
real(psb_spk_),intent(inout) :: x(:)
|
||||||
|
real(psb_spk_),intent(inout) :: y(:)
|
||||||
|
real(psb_spk_),intent(in) :: alpha,beta
|
||||||
|
character(len=1),intent(in) :: trans
|
||||||
|
real(psb_spk_),target, intent(inout) :: work(:)
|
||||||
|
integer, intent(out) :: info
|
||||||
|
|
||||||
|
integer :: n_row,n_col
|
||||||
|
real(psb_spk_), pointer :: ww(:), aux(:), tx(:),ty(:)
|
||||||
|
integer :: ictxt,np,me,i, err_act
|
||||||
|
character :: trans_
|
||||||
|
character(len=20) :: name='s_ilu_solver_apply'
|
||||||
|
|
||||||
|
call psb_erractionsave(err_act)
|
||||||
|
|
||||||
|
info = psb_success_
|
||||||
|
|
||||||
|
trans_ = psb_toupper(trans)
|
||||||
|
select case(trans_)
|
||||||
|
case('N')
|
||||||
|
case('T','C')
|
||||||
|
case default
|
||||||
|
call psb_errpush(psb_err_iarg_invalid_i_,name)
|
||||||
|
goto 9999
|
||||||
|
end select
|
||||||
|
|
||||||
|
n_row = desc_data%get_local_rows()
|
||||||
|
n_col = desc_data%get_local_cols()
|
||||||
|
|
||||||
|
if (n_col <= size(work)) then
|
||||||
|
ww => work(1:n_col)
|
||||||
|
if ((4*n_col+n_col) <= size(work)) then
|
||||||
|
aux => work(n_col+1:)
|
||||||
|
else
|
||||||
|
allocate(aux(4*n_col),stat=info)
|
||||||
|
if (info /= psb_success_) then
|
||||||
|
info=psb_err_alloc_request_
|
||||||
|
call psb_errpush(info,name,i_err=(/4*n_col,0,0,0,0/),&
|
||||||
|
& a_err='real(psb_spk_)')
|
||||||
|
goto 9999
|
||||||
|
end if
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
allocate(ww(n_col),aux(4*n_col),stat=info)
|
||||||
|
if (info /= psb_success_) then
|
||||||
|
info=psb_err_alloc_request_
|
||||||
|
call psb_errpush(info,name,i_err=(/5*n_col,0,0,0,0/),&
|
||||||
|
& a_err='real(psb_spk_)')
|
||||||
|
goto 9999
|
||||||
|
end if
|
||||||
|
endif
|
||||||
|
|
||||||
|
select case(trans_)
|
||||||
|
case('N')
|
||||||
|
call psb_spsm(sone,sv%l,x,szero,ww,desc_data,info,&
|
||||||
|
& trans=trans_,scale='L',diag=sv%d,choice=psb_none_,work=aux)
|
||||||
|
|
||||||
|
if (info == psb_success_) call psb_spsm(alpha,sv%u,ww,beta,y,desc_data,info,&
|
||||||
|
& trans=trans_,scale='U',choice=psb_none_, work=aux)
|
||||||
|
|
||||||
|
case('T')
|
||||||
|
call psb_spsm(sone,sv%u,x,szero,ww,desc_data,info,&
|
||||||
|
& trans=trans_,scale='L',diag=sv%d,choice=psb_none_,work=aux)
|
||||||
|
if (info == psb_success_) call psb_spsm(alpha,sv%l,ww,beta,y,desc_data,info,&
|
||||||
|
& trans=trans_,scale='U',choice=psb_none_,work=aux)
|
||||||
|
case('C')
|
||||||
|
! For real this is the same of T but in the future we will move to
|
||||||
|
! a preprocessed version, so we need a placeholder
|
||||||
|
call psb_spsm(sone,sv%u,x,szero,ww,desc_data,info,&
|
||||||
|
& trans=trans_,scale='L',diag=sv%d,choice=psb_none_,work=aux)
|
||||||
|
if (info == psb_success_) call psb_spsm(alpha,sv%l,ww,beta,y,desc_data,info,&
|
||||||
|
& trans=trans_,scale='U',choice=psb_none_,work=aux)
|
||||||
|
case default
|
||||||
|
call psb_errpush(psb_err_internal_error_,name,a_err='Invalid TRANS in ILU subsolve')
|
||||||
|
goto 9999
|
||||||
|
end select
|
||||||
|
|
||||||
|
|
||||||
|
if (info /= psb_success_) then
|
||||||
|
|
||||||
|
call psb_errpush(psb_err_internal_error_,name,a_err='Error in subsolve')
|
||||||
|
goto 9999
|
||||||
|
endif
|
||||||
|
|
||||||
|
if (n_col <= size(work)) then
|
||||||
|
if ((4*n_col+n_col) <= size(work)) then
|
||||||
|
else
|
||||||
|
deallocate(aux)
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
deallocate(ww,aux)
|
||||||
|
endif
|
||||||
|
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
return
|
||||||
|
|
||||||
|
9999 continue
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
if (err_act == psb_act_abort_) then
|
||||||
|
call psb_error()
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
return
|
||||||
|
|
||||||
|
end subroutine mld_s_ilu_solver_apply
|
||||||
|
|
||||||
|
subroutine mld_s_ilu_solver_bld(a,desc_a,sv,upd,info,b,amold,vmold)
|
||||||
|
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_s_ilu_solver, mld_protect_name => mld_s_ilu_solver_bld
|
||||||
|
|
||||||
|
Implicit None
|
||||||
|
|
||||||
|
! Arguments
|
||||||
|
type(psb_sspmat_type), intent(in), target :: a
|
||||||
|
Type(psb_desc_type), Intent(in) :: desc_a
|
||||||
|
class(mld_s_ilu_solver_type), intent(inout) :: sv
|
||||||
|
character, intent(in) :: upd
|
||||||
|
integer, intent(out) :: info
|
||||||
|
type(psb_sspmat_type), intent(in), target, optional :: b
|
||||||
|
class(psb_s_base_sparse_mat), intent(in), optional :: amold
|
||||||
|
class(psb_s_base_vect_type), intent(in), optional :: vmold
|
||||||
|
! Local variables
|
||||||
|
integer :: n_row,n_col, nrow_a, nztota
|
||||||
|
real(psb_spk_), pointer :: ww(:), aux(:), tx(:),ty(:)
|
||||||
|
integer :: ictxt,np,me,i, err_act, debug_unit, debug_level
|
||||||
|
character(len=20) :: name='s_ilu_solver_bld', ch_err
|
||||||
|
|
||||||
|
info=psb_success_
|
||||||
|
call psb_erractionsave(err_act)
|
||||||
|
debug_unit = psb_get_debug_unit()
|
||||||
|
debug_level = psb_get_debug_level()
|
||||||
|
ictxt = desc_a%get_context()
|
||||||
|
call psb_info(ictxt, me, np)
|
||||||
|
if (debug_level >= psb_debug_outer_) &
|
||||||
|
& write(debug_unit,*) me,' ',trim(name),' start'
|
||||||
|
|
||||||
|
|
||||||
|
n_row = desc_a%get_local_rows()
|
||||||
|
|
||||||
|
if (psb_toupper(upd) == 'F') then
|
||||||
|
nrow_a = a%get_nrows()
|
||||||
|
nztota = a%get_nzeros()
|
||||||
|
if (present(b)) then
|
||||||
|
nztota = nztota + b%get_nzeros()
|
||||||
|
end if
|
||||||
|
|
||||||
|
call sv%l%csall(n_row,n_row,info,nztota)
|
||||||
|
if (info == psb_success_) call sv%u%csall(n_row,n_row,info,nztota)
|
||||||
|
if(info /= psb_success_) then
|
||||||
|
info=psb_err_from_subroutine_
|
||||||
|
ch_err='psb_sp_all'
|
||||||
|
call psb_errpush(info,name,a_err=ch_err)
|
||||||
|
goto 9999
|
||||||
|
end if
|
||||||
|
|
||||||
|
if (allocated(sv%d)) then
|
||||||
|
if (size(sv%d) < n_row) then
|
||||||
|
deallocate(sv%d)
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
if (.not.allocated(sv%d)) allocate(sv%d(n_row),stat=info)
|
||||||
|
|
||||||
|
if (info /= psb_success_) then
|
||||||
|
call psb_errpush(psb_err_from_subroutine_,name,a_err='Allocate')
|
||||||
|
goto 9999
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
select case(sv%fact_type)
|
||||||
|
|
||||||
|
case (mld_ilu_t_)
|
||||||
|
!
|
||||||
|
! ILU(k,t)
|
||||||
|
!
|
||||||
|
select case(sv%fill_in)
|
||||||
|
|
||||||
|
case(:-1)
|
||||||
|
! Error: fill-in <= -1
|
||||||
|
call psb_errpush(psb_err_input_value_invalid_i_,&
|
||||||
|
& name,i_err=(/3,sv%fill_in,0,0,0/))
|
||||||
|
goto 9999
|
||||||
|
|
||||||
|
case(0:)
|
||||||
|
! Fill-in >= 0
|
||||||
|
call mld_ilut_fact(sv%fill_in,sv%thresh,&
|
||||||
|
& a, sv%l,sv%u,sv%d,info,blck=b)
|
||||||
|
end select
|
||||||
|
if(info /= psb_success_) then
|
||||||
|
info=psb_err_from_subroutine_
|
||||||
|
ch_err='mld_ilut_fact'
|
||||||
|
call psb_errpush(info,name,a_err=ch_err)
|
||||||
|
goto 9999
|
||||||
|
end if
|
||||||
|
|
||||||
|
case(mld_ilu_n_,mld_milu_n_)
|
||||||
|
!
|
||||||
|
! ILU(k) and MILU(k)
|
||||||
|
!
|
||||||
|
select case(sv%fill_in)
|
||||||
|
case(:-1)
|
||||||
|
! Error: fill-in <= -1
|
||||||
|
call psb_errpush(psb_err_input_value_invalid_i_,&
|
||||||
|
& name,i_err=(/3,sv%fill_in,0,0,0/))
|
||||||
|
goto 9999
|
||||||
|
case(0)
|
||||||
|
! Fill-in 0
|
||||||
|
! Separate implementation of ILU(0) for better performance.
|
||||||
|
! There seems to be a problem with the separate implementation of MILU(0),
|
||||||
|
! contained into mld_ilu0_fact. This must be investigated. For the time being,
|
||||||
|
! resort to the implementation of MILU(k) with k=0.
|
||||||
|
if (sv%fact_type == mld_ilu_n_) then
|
||||||
|
call mld_ilu0_fact(sv%fact_type,a,sv%l,sv%u,&
|
||||||
|
& sv%d,info,blck=b,upd=upd)
|
||||||
|
else
|
||||||
|
call mld_iluk_fact(sv%fill_in,sv%fact_type,&
|
||||||
|
& a,sv%l,sv%u,sv%d,info,blck=b)
|
||||||
|
endif
|
||||||
|
case(1:)
|
||||||
|
! Fill-in >= 1
|
||||||
|
! The same routine implements both ILU(k) and MILU(k)
|
||||||
|
call mld_iluk_fact(sv%fill_in,sv%fact_type,&
|
||||||
|
& a,sv%l,sv%u,sv%d,info,blck=b)
|
||||||
|
end select
|
||||||
|
if (info /= psb_success_) then
|
||||||
|
info=psb_err_from_subroutine_
|
||||||
|
ch_err='mld_iluk_fact'
|
||||||
|
call psb_errpush(info,name,a_err=ch_err)
|
||||||
|
goto 9999
|
||||||
|
end if
|
||||||
|
|
||||||
|
case default
|
||||||
|
! If we end up here, something was wrong up in the call chain.
|
||||||
|
info = psb_err_input_value_invalid_i_
|
||||||
|
call psb_errpush(psb_err_input_value_invalid_i_,name,&
|
||||||
|
& i_err=(/3,sv%fact_type,0,0,0/))
|
||||||
|
goto 9999
|
||||||
|
|
||||||
|
end select
|
||||||
|
else
|
||||||
|
! Here we should add checks for reuse of L and U.
|
||||||
|
! For the time being just throw an error.
|
||||||
|
info = 31
|
||||||
|
call psb_errpush(info, name,&
|
||||||
|
& i_err=(/3,0,0,0,0/),a_err=upd)
|
||||||
|
goto 9999
|
||||||
|
|
||||||
|
!
|
||||||
|
! What is an update of a factorization??
|
||||||
|
! A first attempt could be to reuse EXACTLY the existing indices
|
||||||
|
! as if it was an ILU(0) (since, effectively, the sparsity pattern
|
||||||
|
! should not grow beyond what is already there).
|
||||||
|
!
|
||||||
|
call mld_ilu0_fact(sv%fact_type,a,&
|
||||||
|
& sv%l,sv%u,&
|
||||||
|
& sv%d,info,blck=b,upd=upd)
|
||||||
|
|
||||||
|
end if
|
||||||
|
|
||||||
|
call sv%l%set_asb()
|
||||||
|
call sv%l%trim()
|
||||||
|
call sv%u%set_asb()
|
||||||
|
call sv%u%trim()
|
||||||
|
call sv%dv%bld(sv%d,mold=vmold)
|
||||||
|
|
||||||
|
if (present(amold)) then
|
||||||
|
call sv%l%cscnv(info,mold=amold)
|
||||||
|
call sv%u%cscnv(info,mold=amold)
|
||||||
|
end if
|
||||||
|
|
||||||
|
if (debug_level >= psb_debug_outer_) &
|
||||||
|
& write(debug_unit,*) me,' ',trim(name),' end'
|
||||||
|
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
return
|
||||||
|
|
||||||
|
9999 continue
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
if (err_act == psb_act_abort_) then
|
||||||
|
call psb_error()
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
return
|
||||||
|
end subroutine mld_s_ilu_solver_bld
|
||||||
|
|
@ -0,0 +1,459 @@
|
|||||||
|
!!$
|
||||||
|
!!$
|
||||||
|
!!$ MLD2P4 version 2.0
|
||||||
|
!!$ MultiLevel Domain Decomposition Parallel Preconditioners Package
|
||||||
|
!!$ based on PSBLAS (Parallel Sparse BLAS version 3.0)
|
||||||
|
!!$
|
||||||
|
!!$ (C) Copyright 2008,2009,2010
|
||||||
|
!!$
|
||||||
|
!!$ Salvatore Filippone University of Rome Tor Vergata
|
||||||
|
!!$ Alfredo Buttari CNRS-IRIT, Toulouse
|
||||||
|
!!$ Pasqua D'Ambra ICAR-CNR, Naples
|
||||||
|
!!$ Daniela di Serafino Second University of Naples
|
||||||
|
!!$
|
||||||
|
!!$ 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 MLD2P4 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 MLD2P4 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: mld_file_onelev_descr
|
||||||
|
! Version: real
|
||||||
|
!
|
||||||
|
! This routine prints a description of the preconditioner to the standard
|
||||||
|
! output or to a file. It must be called after the preconditioner has been
|
||||||
|
! built by mld_precbld.
|
||||||
|
!
|
||||||
|
! Arguments:
|
||||||
|
! p - type(mld_Tprec_type), input.
|
||||||
|
! The preconditioner data structure to be printed out.
|
||||||
|
! info - integer, output.
|
||||||
|
! error code.
|
||||||
|
! iout - integer, input, optional.
|
||||||
|
! The id of the file where the preconditioner description
|
||||||
|
! will be printed. If iout is not present, then the standard
|
||||||
|
! output is condidered.
|
||||||
|
!
|
||||||
|
subroutine mld_s_base_onelev_descr(lv,il,nl,info,iout)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_sonelev_mod, mld_protect_name => mld_s_base_onelev_descr
|
||||||
|
Implicit None
|
||||||
|
! Arguments
|
||||||
|
class(mld_sonelev_type), intent(in) :: lv
|
||||||
|
integer, intent(in) :: il,nl
|
||||||
|
integer, intent(out) :: info
|
||||||
|
integer, intent(in), optional :: iout
|
||||||
|
|
||||||
|
! Local variables
|
||||||
|
integer :: err_act
|
||||||
|
integer :: ictxt, me, np
|
||||||
|
character(len=20), parameter :: name='mld_s_base_onelev_descr'
|
||||||
|
integer :: iout_
|
||||||
|
logical :: coarse
|
||||||
|
|
||||||
|
|
||||||
|
call psb_erractionsave(err_act)
|
||||||
|
|
||||||
|
|
||||||
|
coarse = (il==nl)
|
||||||
|
|
||||||
|
if (present(iout)) then
|
||||||
|
iout_ = iout
|
||||||
|
else
|
||||||
|
iout_ = 6
|
||||||
|
end if
|
||||||
|
|
||||||
|
write(iout_,*)
|
||||||
|
if (il == 2) then
|
||||||
|
call lv%parms%mldescr(iout_,info)
|
||||||
|
write(iout_,*)
|
||||||
|
end if
|
||||||
|
|
||||||
|
if (coarse) then
|
||||||
|
write(iout_,*) ' Level ',il,' (coarsest)'
|
||||||
|
else
|
||||||
|
write(iout_,*) ' Level ',il
|
||||||
|
end if
|
||||||
|
|
||||||
|
call lv%parms%descr(iout_,info,coarse=coarse)
|
||||||
|
|
||||||
|
if (nl > 1) then
|
||||||
|
if (allocated(lv%map%naggr)) then
|
||||||
|
write(iout_,*) ' Size of coarse matrix: ', &
|
||||||
|
& sum(lv%map%naggr(:))
|
||||||
|
write(iout_,*) ' Sizes of aggregates: ', &
|
||||||
|
& lv%map%naggr(:)
|
||||||
|
end if
|
||||||
|
end if
|
||||||
|
|
||||||
|
if (coarse.and.allocated(lv%sm)) &
|
||||||
|
& call lv%sm%descr(info,iout=iout_,coarse=coarse)
|
||||||
|
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
return
|
||||||
|
|
||||||
|
9999 continue
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
if (err_act == psb_act_abort_) then
|
||||||
|
call psb_error()
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
return
|
||||||
|
end subroutine mld_s_base_onelev_descr
|
||||||
|
|
||||||
|
|
||||||
|
!
|
||||||
|
! Subroutines: mld_T_onelev_precfree
|
||||||
|
! Version: real
|
||||||
|
!
|
||||||
|
! These routines deallocate the mld_Tonelev_type
|
||||||
|
!
|
||||||
|
! Arguments:
|
||||||
|
! p - type(mld_Tonelev_type), input.
|
||||||
|
! The data structure to be deallocated.
|
||||||
|
! info - integer, output.
|
||||||
|
! error code.
|
||||||
|
!
|
||||||
|
subroutine mld_s_base_onelev_free(lv,info)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_sonelev_mod, mld_protect_name =>: mld_T_onelev_precfree
|
||||||
|
implicit none
|
||||||
|
|
||||||
|
class(mld_sonelev_type), intent(inout) :: lv
|
||||||
|
integer, intent(out) :: info
|
||||||
|
integer :: i
|
||||||
|
|
||||||
|
info = psb_success_
|
||||||
|
|
||||||
|
! We might just deallocate the top level array, except
|
||||||
|
! that there may be inner objects containing C pointers,
|
||||||
|
! e.g. UMFPACK, SLU or CUDA stuff.
|
||||||
|
! We really need FINALs.
|
||||||
|
call lv%sm%free(info)
|
||||||
|
|
||||||
|
call lv%ac%free()
|
||||||
|
if (psb_is_ok_desc(lv%desc_ac)) &
|
||||||
|
& call psb_cdfree(lv%desc_ac,info)
|
||||||
|
call lv%map%free(info)
|
||||||
|
|
||||||
|
! This is a pointer to something else, must not free it here.
|
||||||
|
nullify(lv%base_a)
|
||||||
|
! This is a pointer to something else, must not free it here.
|
||||||
|
nullify(lv%base_desc)
|
||||||
|
|
||||||
|
call lv%nullify()
|
||||||
|
|
||||||
|
end subroutine mld_s_base_onelev_free
|
||||||
|
|
||||||
|
!
|
||||||
|
! Onelevel checks.
|
||||||
|
! The number of Jacobi sweeps to be applied is not
|
||||||
|
! tied to the Jacobi smoother: logically, you have
|
||||||
|
! a smoother and you can choose to apply it any number
|
||||||
|
! of times you like.
|
||||||
|
!
|
||||||
|
subroutine mld_s_base_onelev_check(lv,info)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_sonelev_mod, mld_protect_name => mld_s_base_onelev_check
|
||||||
|
|
||||||
|
Implicit None
|
||||||
|
|
||||||
|
! Arguments
|
||||||
|
class(mld_sonelev_type), intent(inout) :: lv
|
||||||
|
integer, intent(out) :: info
|
||||||
|
Integer :: err_act
|
||||||
|
character(len=20) :: name='s_base_onelev_check'
|
||||||
|
|
||||||
|
call psb_erractionsave(err_act)
|
||||||
|
info = psb_success_
|
||||||
|
|
||||||
|
call mld_check_def(lv%parms%sweeps,&
|
||||||
|
& 'Jacobi sweeps',1,is_legal_jac_sweeps)
|
||||||
|
call mld_check_def(lv%parms%sweeps_pre,&
|
||||||
|
& 'Jacobi sweeps',1,is_legal_jac_sweeps)
|
||||||
|
call mld_check_def(lv%parms%sweeps_post,&
|
||||||
|
& 'Jacobi sweeps',1,is_legal_jac_sweeps)
|
||||||
|
|
||||||
|
|
||||||
|
if (allocated(lv%sm)) then
|
||||||
|
call lv%sm%check(info)
|
||||||
|
else
|
||||||
|
info=3111
|
||||||
|
call psb_errpush(info,name)
|
||||||
|
goto 9999
|
||||||
|
end if
|
||||||
|
|
||||||
|
if (info /= psb_success_) goto 9999
|
||||||
|
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
return
|
||||||
|
|
||||||
|
9999 continue
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
if (err_act == psb_act_abort_) then
|
||||||
|
call psb_error()
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
return
|
||||||
|
end subroutine mld_s_base_onelev_check
|
||||||
|
|
||||||
|
|
||||||
|
!
|
||||||
|
! Set routines:
|
||||||
|
! Parameters belonging here are:
|
||||||
|
! Number of smoothing sweeps;
|
||||||
|
! Smoother position;
|
||||||
|
! Aggregation related parameters
|
||||||
|
! Record request on coarse level solver,
|
||||||
|
! for checks on solver vs. smoother nomenclature
|
||||||
|
! reconciliation.
|
||||||
|
!
|
||||||
|
subroutine mld_s_base_onelev_seti(lv,what,val,info)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_sonelev_mod, mld_protect_name => mld_s_base_onelev_seti
|
||||||
|
|
||||||
|
Implicit None
|
||||||
|
|
||||||
|
! Arguments
|
||||||
|
class(mld_sonelev_type), intent(inout) :: lv
|
||||||
|
integer, intent(in) :: what
|
||||||
|
integer, intent(in) :: val
|
||||||
|
integer, intent(out) :: info
|
||||||
|
Integer :: err_act
|
||||||
|
character(len=20) :: name='s_base_onelev_seti'
|
||||||
|
|
||||||
|
call psb_erractionsave(err_act)
|
||||||
|
info = psb_success_
|
||||||
|
|
||||||
|
select case (what)
|
||||||
|
|
||||||
|
case (mld_smoother_sweeps_)
|
||||||
|
lv%parms%sweeps = val
|
||||||
|
lv%parms%sweeps_pre = val
|
||||||
|
lv%parms%sweeps_post = val
|
||||||
|
|
||||||
|
case (mld_smoother_sweeps_pre_)
|
||||||
|
lv%parms%sweeps_pre = val
|
||||||
|
|
||||||
|
case (mld_smoother_sweeps_post_)
|
||||||
|
lv%parms%sweeps_post = val
|
||||||
|
|
||||||
|
case (mld_ml_type_)
|
||||||
|
lv%parms%ml_type = val
|
||||||
|
|
||||||
|
case (mld_aggr_alg_)
|
||||||
|
lv%parms%aggr_alg = val
|
||||||
|
|
||||||
|
case (mld_aggr_kind_)
|
||||||
|
lv%parms%aggr_kind = val
|
||||||
|
|
||||||
|
case (mld_coarse_mat_)
|
||||||
|
lv%parms%coarse_mat = val
|
||||||
|
|
||||||
|
case (mld_smoother_pos_)
|
||||||
|
lv%parms%smoother_pos = val
|
||||||
|
|
||||||
|
case (mld_aggr_omega_alg_)
|
||||||
|
lv%parms%aggr_omega_alg= val
|
||||||
|
|
||||||
|
case (mld_aggr_eig_)
|
||||||
|
lv%parms%aggr_eig = val
|
||||||
|
|
||||||
|
case (mld_aggr_filter_)
|
||||||
|
lv%parms%aggr_filter = val
|
||||||
|
|
||||||
|
case (mld_coarse_solve_)
|
||||||
|
lv%parms%coarse_solve = val
|
||||||
|
|
||||||
|
case default
|
||||||
|
if (allocated(lv%sm)) then
|
||||||
|
call lv%sm%set(what,val,info)
|
||||||
|
end if
|
||||||
|
if (info /= psb_success_) goto 9999
|
||||||
|
end select
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
return
|
||||||
|
|
||||||
|
9999 continue
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
if (err_act == psb_act_abort_) then
|
||||||
|
call psb_error()
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
return
|
||||||
|
end subroutine mld_s_base_onelev_seti
|
||||||
|
|
||||||
|
subroutine mld_s_base_onelev_setc(lv,what,val,info)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_sonelev_mod, mld_protect_name => mld_s_base_onelev_setc
|
||||||
|
|
||||||
|
Implicit None
|
||||||
|
|
||||||
|
! Arguments
|
||||||
|
class(mld_sonelev_type), intent(inout) :: lv
|
||||||
|
integer, intent(in) :: what
|
||||||
|
character(len=*), intent(in) :: val
|
||||||
|
integer, intent(out) :: info
|
||||||
|
Integer :: err_act
|
||||||
|
character(len=20) :: name='s_base_onelev_setc'
|
||||||
|
integer :: ival
|
||||||
|
|
||||||
|
call psb_erractionsave(err_act)
|
||||||
|
|
||||||
|
info = psb_success_
|
||||||
|
|
||||||
|
call mld_stringval(val,ival,info)
|
||||||
|
if (info == psb_success_) call lv%set(what,ival,info)
|
||||||
|
|
||||||
|
if (info /= psb_success_) goto 9999
|
||||||
|
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
return
|
||||||
|
|
||||||
|
9999 continue
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
if (err_act == psb_act_abort_) then
|
||||||
|
call psb_error()
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
return
|
||||||
|
end subroutine mld_s_base_onelev_setc
|
||||||
|
|
||||||
|
subroutine mld_s_base_onelev_setr(lv,what,val,info)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_sonelev_mod, mld_protect_name => mld_s_base_onelev_setr
|
||||||
|
|
||||||
|
Implicit None
|
||||||
|
|
||||||
|
! Arguments
|
||||||
|
class(mld_sonelev_type), intent(inout) :: lv
|
||||||
|
integer, intent(in) :: what
|
||||||
|
real(psb_spk_), intent(in) :: val
|
||||||
|
integer, intent(out) :: info
|
||||||
|
Integer :: err_act
|
||||||
|
character(len=20) :: name='s_base_onelev_setr'
|
||||||
|
|
||||||
|
call psb_erractionsave(err_act)
|
||||||
|
|
||||||
|
|
||||||
|
info = psb_success_
|
||||||
|
|
||||||
|
select case (what)
|
||||||
|
|
||||||
|
case (mld_aggr_omega_val_)
|
||||||
|
lv%parms%aggr_omega_val= val
|
||||||
|
|
||||||
|
case (mld_aggr_thresh_)
|
||||||
|
lv%parms%aggr_thresh = val
|
||||||
|
|
||||||
|
case default
|
||||||
|
if (allocated(lv%sm)) then
|
||||||
|
call lv%sm%set(what,val,info)
|
||||||
|
end if
|
||||||
|
if (info /= psb_success_) goto 9999
|
||||||
|
end select
|
||||||
|
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
return
|
||||||
|
|
||||||
|
9999 continue
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
if (err_act == psb_act_abort_) then
|
||||||
|
call psb_error()
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
return
|
||||||
|
end subroutine mld_s_base_onelev_setr
|
||||||
|
|
||||||
|
!
|
||||||
|
! Dump on file: can be fine-tuned to include the (aggregated) matrix
|
||||||
|
! as well as smoother and solver.
|
||||||
|
!
|
||||||
|
subroutine mld_s_base_onelev_dump(lv,level,info,prefix,head,ac,rp,smoother,solver)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_sonelev_mod, mld_protect_name => mld_s_base_onelev_dump
|
||||||
|
implicit none
|
||||||
|
class(mld_sonelev_type), intent(in) :: lv
|
||||||
|
integer, intent(in) :: level
|
||||||
|
integer, intent(out) :: info
|
||||||
|
character(len=*), intent(in), optional :: prefix, head
|
||||||
|
logical, optional, intent(in) :: ac, rp, smoother, solver
|
||||||
|
integer :: i, j, il1, iln, lname, lev
|
||||||
|
integer :: icontxt,iam, np
|
||||||
|
character(len=80) :: prefix_
|
||||||
|
character(len=120) :: fname ! len should be at least 20 more than
|
||||||
|
logical :: ac_, rp_
|
||||||
|
! len of prefix_
|
||||||
|
|
||||||
|
info = 0
|
||||||
|
|
||||||
|
if (present(prefix)) then
|
||||||
|
prefix_ = trim(prefix(1:min(len(prefix),len(prefix_))))
|
||||||
|
else
|
||||||
|
prefix_ = "dump_lev_s"
|
||||||
|
end if
|
||||||
|
|
||||||
|
if (associated(lv%base_desc)) then
|
||||||
|
icontxt = lv%base_desc%get_context()
|
||||||
|
call psb_info(icontxt,iam,np)
|
||||||
|
else
|
||||||
|
icontxt = -1
|
||||||
|
iam = -1
|
||||||
|
end if
|
||||||
|
if (present(ac)) then
|
||||||
|
ac_ = ac
|
||||||
|
else
|
||||||
|
ac_ = .false.
|
||||||
|
end if
|
||||||
|
if (present(rp)) then
|
||||||
|
rp_ = rp
|
||||||
|
else
|
||||||
|
rp_ = .false.
|
||||||
|
end if
|
||||||
|
lname = len_trim(prefix_)
|
||||||
|
fname = trim(prefix_)
|
||||||
|
write(fname(lname+1:lname+5),'(a,i3.3)') '_p',iam
|
||||||
|
lname = lname + 5
|
||||||
|
|
||||||
|
if (level >= 2) then
|
||||||
|
if (ac_) then
|
||||||
|
write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_ac.mtx'
|
||||||
|
write(0,*) 'Filename ',fname
|
||||||
|
call lv%ac%print(fname,head=head)
|
||||||
|
end if
|
||||||
|
if (rp_) then
|
||||||
|
write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_r.mtx'
|
||||||
|
write(0,*) 'Filename ',fname
|
||||||
|
call lv%map%map_X2Y%print(fname,head=head)
|
||||||
|
write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_p.mtx'
|
||||||
|
write(0,*) 'Filename ',fname
|
||||||
|
call lv%map%map_Y2X%print(fname,head=head)
|
||||||
|
end if
|
||||||
|
end if
|
||||||
|
if (allocated(lv%sm)) &
|
||||||
|
& call lv%sm%dump(icontxt,level,info,smoother=smoother,solver=solver)
|
||||||
|
|
||||||
|
end subroutine mld_s_base_onelev_dump
|
||||||
|
|
||||||
|
|
@ -0,0 +1,481 @@
|
|||||||
|
!!$
|
||||||
|
!!$
|
||||||
|
!!$ MLD2P4 version 2.0
|
||||||
|
!!$ MultiLevel Domain Decomposition Parallel Preconditioners Package
|
||||||
|
!!$ based on PSBLAS (Parallel Sparse BLAS version 3.0)
|
||||||
|
!!$
|
||||||
|
!!$ (C) Copyright 2008,2009,2010
|
||||||
|
!!$
|
||||||
|
!!$ Salvatore Filippone University of Rome Tor Vergata
|
||||||
|
!!$ Alfredo Buttari CNRS-IRIT, Toulouse
|
||||||
|
!!$ Pasqua D'Ambra ICAR-CNR, Naples
|
||||||
|
!!$ Daniela di Serafino Second University of Naples
|
||||||
|
!!$
|
||||||
|
!!$ 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 MLD2P4 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 MLD2P4 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.
|
||||||
|
!!$
|
||||||
|
!!$
|
||||||
|
|
||||||
|
!
|
||||||
|
! Apply: comes in two versions, on plain arrays or on encapsulated
|
||||||
|
! vectors.
|
||||||
|
! This basic version just applies the local solver, whatever that
|
||||||
|
! is.
|
||||||
|
!
|
||||||
|
|
||||||
|
subroutine mld_z_base_smoother_apply(alpha,sm,x,beta,y,desc_data,trans,sweeps,work,info)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_z_base_smoother_mod, mld_protect_name => mld_z_base_smoother_apply
|
||||||
|
implicit none
|
||||||
|
type(psb_desc_type), intent(in) :: desc_data
|
||||||
|
class(mld_z_base_smoother_type), intent(in) :: sm
|
||||||
|
complex(psb_dpk_),intent(inout) :: x(:)
|
||||||
|
complex(psb_dpk_),intent(inout) :: y(:)
|
||||||
|
complex(psb_dpk_),intent(in) :: alpha,beta
|
||||||
|
character(len=1),intent(in) :: trans
|
||||||
|
integer, intent(in) :: sweeps
|
||||||
|
complex(psb_dpk_),target, intent(inout) :: work(:)
|
||||||
|
integer, intent(out) :: info
|
||||||
|
|
||||||
|
Integer :: err_act
|
||||||
|
character(len=20) :: name='z_base_smoother_apply'
|
||||||
|
|
||||||
|
call psb_erractionsave(err_act)
|
||||||
|
info = psb_success_
|
||||||
|
if (allocated(sm%sv)) then
|
||||||
|
call sm%sv%apply(alpha,x,beta,y,desc_data,trans,work,info)
|
||||||
|
else
|
||||||
|
info = 1121
|
||||||
|
endif
|
||||||
|
if (info /= psb_success_) then
|
||||||
|
call psb_errpush(info,name)
|
||||||
|
goto 9999
|
||||||
|
end if
|
||||||
|
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
return
|
||||||
|
|
||||||
|
9999 continue
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
if (err_act == psb_act_abort_) then
|
||||||
|
call psb_error()
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
return
|
||||||
|
|
||||||
|
end subroutine mld_z_base_smoother_apply
|
||||||
|
|
||||||
|
subroutine mld_z_base_smoother_apply_vect(alpha,sm,x,beta,y,desc_data,&
|
||||||
|
& trans,sweeps,work,info)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_z_base_smoother_mod, mld_protect_name => mld_z_base_smoother_apply_vect
|
||||||
|
implicit none
|
||||||
|
type(psb_desc_type), intent(in) :: desc_data
|
||||||
|
class(mld_z_base_smoother_type), intent(inout) :: sm
|
||||||
|
type(psb_z_vect_type),intent(inout) :: x
|
||||||
|
type(psb_z_vect_type),intent(inout) :: y
|
||||||
|
complex(psb_dpk_),intent(in) :: alpha,beta
|
||||||
|
character(len=1),intent(in) :: trans
|
||||||
|
integer, intent(in) :: sweeps
|
||||||
|
complex(psb_dpk_),target, intent(inout) :: work(:)
|
||||||
|
integer, intent(out) :: info
|
||||||
|
|
||||||
|
Integer :: err_act
|
||||||
|
character(len=20) :: name='z_base_smoother_apply'
|
||||||
|
|
||||||
|
call psb_erractionsave(err_act)
|
||||||
|
info = psb_success_
|
||||||
|
if (allocated(sm%sv)) then
|
||||||
|
call sm%sv%apply(alpha,x,beta,y,desc_data,trans,work,info)
|
||||||
|
else
|
||||||
|
info = 1121
|
||||||
|
endif
|
||||||
|
if (info /= psb_success_) then
|
||||||
|
call psb_errpush(info,name)
|
||||||
|
goto 9999
|
||||||
|
end if
|
||||||
|
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
return
|
||||||
|
|
||||||
|
9999 continue
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
if (err_act == psb_act_abort_) then
|
||||||
|
call psb_error()
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
return
|
||||||
|
|
||||||
|
end subroutine mld_z_base_smoother_apply_vect
|
||||||
|
|
||||||
|
!
|
||||||
|
! Check:
|
||||||
|
! 1. Check that we do have a solver object
|
||||||
|
! 2. Call its check method
|
||||||
|
!
|
||||||
|
|
||||||
|
subroutine mld_z_base_smoother_check(sm,info)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_z_base_smoother_mod, mld_protect_name => mld_z_base_smoother_check
|
||||||
|
Implicit None
|
||||||
|
|
||||||
|
! Arguments
|
||||||
|
class(mld_z_base_smoother_type), intent(inout) :: sm
|
||||||
|
integer, intent(out) :: info
|
||||||
|
Integer :: err_act
|
||||||
|
character(len=20) :: name='z_base_smoother_check'
|
||||||
|
|
||||||
|
call psb_erractionsave(err_act)
|
||||||
|
info = psb_success_
|
||||||
|
|
||||||
|
if (allocated(sm%sv)) then
|
||||||
|
call sm%sv%check(info)
|
||||||
|
else
|
||||||
|
info=3111
|
||||||
|
call psb_errpush(info,name)
|
||||||
|
goto 9999
|
||||||
|
end if
|
||||||
|
|
||||||
|
if (info /= psb_success_) goto 9999
|
||||||
|
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
return
|
||||||
|
|
||||||
|
9999 continue
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
if (err_act == psb_act_abort_) then
|
||||||
|
call psb_error()
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
return
|
||||||
|
end subroutine mld_z_base_smoother_check
|
||||||
|
|
||||||
|
!
|
||||||
|
! Set methods: the come in multiple versions according
|
||||||
|
! to whether we are setting with integer, real or character
|
||||||
|
! input.
|
||||||
|
! The basic rule is: if the input refers to a parameter
|
||||||
|
! of the smoother, use it, otherwise pass it to the
|
||||||
|
! solver object for further processing.
|
||||||
|
! Since there are no parameters in the base smoother
|
||||||
|
! we just pass everything to the solver object.
|
||||||
|
!
|
||||||
|
subroutine mld_z_base_smoother_seti(sm,what,val,info)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_z_base_smoother_mod, mld_protect_name => mld_z_base_smoother_seti
|
||||||
|
Implicit None
|
||||||
|
! Arguments
|
||||||
|
class(mld_z_base_smoother_type), intent(inout) :: sm
|
||||||
|
integer, intent(in) :: what
|
||||||
|
integer, intent(in) :: val
|
||||||
|
integer, intent(out) :: info
|
||||||
|
Integer :: err_act
|
||||||
|
character(len=20) :: name='z_base_smoother_seti'
|
||||||
|
|
||||||
|
call psb_erractionsave(err_act)
|
||||||
|
info = psb_success_
|
||||||
|
|
||||||
|
if (allocated(sm%sv)) then
|
||||||
|
call sm%sv%set(what,val,info)
|
||||||
|
end if
|
||||||
|
if (info /= psb_success_) goto 9999
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
return
|
||||||
|
|
||||||
|
9999 continue
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
if (err_act == psb_act_abort_) then
|
||||||
|
call psb_error()
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
return
|
||||||
|
end subroutine mld_z_base_smoother_seti
|
||||||
|
|
||||||
|
subroutine mld_z_base_smoother_setc(sm,what,val,info)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_z_base_smoother_mod, mld_protect_name => mld_z_base_smoother_setc
|
||||||
|
Implicit None
|
||||||
|
|
||||||
|
! Arguments
|
||||||
|
class(mld_z_base_smoother_type), intent(inout) :: sm
|
||||||
|
integer, intent(in) :: what
|
||||||
|
character(len=*), intent(in) :: val
|
||||||
|
integer, intent(out) :: info
|
||||||
|
Integer :: err_act
|
||||||
|
character(len=20) :: name='z_base_smoother_setc'
|
||||||
|
|
||||||
|
call psb_erractionsave(err_act)
|
||||||
|
|
||||||
|
info = psb_success_
|
||||||
|
|
||||||
|
if (allocated(sm%sv)) then
|
||||||
|
call sm%sv%set(what,val,info)
|
||||||
|
end if
|
||||||
|
if (info /= psb_success_) goto 9999
|
||||||
|
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
return
|
||||||
|
|
||||||
|
9999 continue
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
if (err_act == psb_act_abort_) then
|
||||||
|
call psb_error()
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
return
|
||||||
|
end subroutine mld_z_base_smoother_setc
|
||||||
|
|
||||||
|
subroutine mld_z_base_smoother_setr(sm,what,val,info)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_z_base_smoother_mod, mld_protect_name => mld_z_base_smoother_setr
|
||||||
|
Implicit None
|
||||||
|
|
||||||
|
! Arguments
|
||||||
|
class(mld_z_base_smoother_type), intent(inout) :: sm
|
||||||
|
integer, intent(in) :: what
|
||||||
|
real(psb_dpk_), intent(in) :: val
|
||||||
|
integer, intent(out) :: info
|
||||||
|
Integer :: err_act
|
||||||
|
character(len=20) :: name='z_base_smoother_setr'
|
||||||
|
|
||||||
|
call psb_erractionsave(err_act)
|
||||||
|
|
||||||
|
|
||||||
|
info = psb_success_
|
||||||
|
|
||||||
|
if (allocated(sm%sv)) then
|
||||||
|
call sm%sv%set(what,val,info)
|
||||||
|
end if
|
||||||
|
if (info /= psb_success_) goto 9999
|
||||||
|
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
return
|
||||||
|
|
||||||
|
9999 continue
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
if (err_act == psb_act_abort_) then
|
||||||
|
call psb_error()
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
return
|
||||||
|
end subroutine mld_z_base_smoother_setr
|
||||||
|
|
||||||
|
|
||||||
|
!
|
||||||
|
! Build method.
|
||||||
|
! At base level we only have to pass data to the inner solver.
|
||||||
|
! AMOLD/VMOLD allow to have any relevant sparse matrix or vector
|
||||||
|
! to be stored in a given format. This is essential e.g.
|
||||||
|
! when dealing with GPUs.
|
||||||
|
!
|
||||||
|
subroutine mld_z_base_smoother_bld(a,desc_a,sm,upd,info,amold,vmold)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_z_base_smoother_mod, mld_protect_name => mld_z_base_smoother_bld
|
||||||
|
Implicit None
|
||||||
|
|
||||||
|
! Arguments
|
||||||
|
type(psb_zspmat_type), intent(in), target :: a
|
||||||
|
Type(psb_desc_type), Intent(in) :: desc_a
|
||||||
|
class(mld_z_base_smoother_type), intent(inout) :: sm
|
||||||
|
character, intent(in) :: upd
|
||||||
|
integer, intent(out) :: info
|
||||||
|
class(psb_z_base_sparse_mat), intent(in), optional :: amold
|
||||||
|
class(psb_z_base_vect_type), intent(in), optional :: vmold
|
||||||
|
Integer :: err_act
|
||||||
|
character(len=20) :: name='z_base_smoother_bld'
|
||||||
|
|
||||||
|
call psb_erractionsave(err_act)
|
||||||
|
|
||||||
|
info = psb_success_
|
||||||
|
if (allocated(sm%sv)) then
|
||||||
|
call sm%sv%build(a,desc_a,upd,info,amold=amold,vmold=vmold)
|
||||||
|
else
|
||||||
|
info = 1121
|
||||||
|
call psb_errpush(info,name)
|
||||||
|
endif
|
||||||
|
if (info /= psb_success_) goto 9999
|
||||||
|
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
return
|
||||||
|
|
||||||
|
9999 continue
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
if (err_act == psb_act_abort_) then
|
||||||
|
call psb_error()
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
return
|
||||||
|
end subroutine mld_z_base_smoother_bld
|
||||||
|
|
||||||
|
!
|
||||||
|
! Free method (aka destructor).
|
||||||
|
! In most cases we could do without; however
|
||||||
|
! for cases where there are data objects allocated outside
|
||||||
|
! of the Fortran RTE we need to free them explicitly.
|
||||||
|
!
|
||||||
|
! Even in that case, we could do without this if FINAL
|
||||||
|
! subroutines were supported, which is not the case
|
||||||
|
|
||||||
|
! in GNU Fortran up to 4.7.
|
||||||
|
!
|
||||||
|
subroutine mld_z_base_smoother_free(sm,info)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_z_base_smoother_mod, mld_protect_name => s
|
||||||
|
Implicit None
|
||||||
|
|
||||||
|
! Arguments
|
||||||
|
class(mld_z_base_smoother_type), intent(inout) :: sm
|
||||||
|
integer, intent(out) :: info
|
||||||
|
Integer :: err_act
|
||||||
|
character(len=20) :: name='z_base_smoother_free'
|
||||||
|
|
||||||
|
call psb_erractionsave(err_act)
|
||||||
|
info = psb_success_
|
||||||
|
|
||||||
|
if (allocated(sm%sv)) then
|
||||||
|
call sm%sv%free(info)
|
||||||
|
end if
|
||||||
|
if (info == psb_success_) deallocate(sm%sv,stat=info)
|
||||||
|
if (info /= psb_success_) then
|
||||||
|
info = psb_err_alloc_dealloc_
|
||||||
|
call psb_errpush(info,name)
|
||||||
|
goto 9999
|
||||||
|
end if
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
return
|
||||||
|
|
||||||
|
9999 continue
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
if (err_act == psb_act_abort_) then
|
||||||
|
call psb_error()
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
return
|
||||||
|
end subroutine mld_z_base_smoother_free
|
||||||
|
|
||||||
|
!
|
||||||
|
! Print a description
|
||||||
|
!
|
||||||
|
|
||||||
|
subroutine mld_z_base_smoother_descr(sm,info,iout,coarse)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_z_base_smoother_mod, mld_protect_name => mld_z_base_smoother_descr
|
||||||
|
Implicit None
|
||||||
|
|
||||||
|
! Arguments
|
||||||
|
class(mld_z_base_smoother_type), intent(in) :: sm
|
||||||
|
integer, intent(out) :: info
|
||||||
|
integer, intent(in), optional :: iout
|
||||||
|
logical, intent(in), optional :: coarse
|
||||||
|
|
||||||
|
! Local variables
|
||||||
|
integer :: err_act
|
||||||
|
integer :: ictxt, me, np
|
||||||
|
character(len=20), parameter :: name='mld_z_base_smoother_descr'
|
||||||
|
integer :: iout_
|
||||||
|
logical :: coarse_
|
||||||
|
|
||||||
|
|
||||||
|
call psb_erractionsave(err_act)
|
||||||
|
info = psb_success_
|
||||||
|
|
||||||
|
if (present(coarse)) then
|
||||||
|
coarse_ = coarse
|
||||||
|
else
|
||||||
|
coarse_ = .false.
|
||||||
|
end if
|
||||||
|
if (present(iout)) then
|
||||||
|
iout_ = iout
|
||||||
|
else
|
||||||
|
iout_ = 6
|
||||||
|
end if
|
||||||
|
|
||||||
|
if (.not.coarse_) &
|
||||||
|
& write(iout_,*) 'Base smoother with local solver'
|
||||||
|
if (allocated(sm%sv)) then
|
||||||
|
call sm%sv%descr(info,iout,coarse)
|
||||||
|
if (info /= psb_success_) then
|
||||||
|
info = psb_err_from_subroutine_
|
||||||
|
call psb_errpush(info,name,a_err='Local solver')
|
||||||
|
goto 9999
|
||||||
|
end if
|
||||||
|
end if
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
return
|
||||||
|
|
||||||
|
9999 continue
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
if (err_act == psb_act_abort_) then
|
||||||
|
call psb_error()
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
return
|
||||||
|
end subroutine mld_z_base_smoother_descr
|
||||||
|
|
||||||
|
!
|
||||||
|
! Dump
|
||||||
|
! to file, for debugging purposes.
|
||||||
|
!
|
||||||
|
subroutine mld_z_base_smoother_dmp(sm,ictxt,level,info,prefix,head,smoother,solver)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_z_base_smoother_mod, mld_protect_name => mld_z_base_smoother_dmp
|
||||||
|
implicit none
|
||||||
|
class(mld_z_base_smoother_type), intent(in) :: sm
|
||||||
|
integer, intent(in) :: ictxt,level
|
||||||
|
integer, intent(out) :: info
|
||||||
|
character(len=*), intent(in), optional :: prefix, head
|
||||||
|
logical, optional, intent(in) :: smoother, solver
|
||||||
|
integer :: i, j, il1, iln, lname, lev
|
||||||
|
integer :: icontxt,iam, np
|
||||||
|
character(len=80) :: prefix_
|
||||||
|
character(len=120) :: fname ! len should be at least 20 more than
|
||||||
|
logical :: smoother_
|
||||||
|
! len of prefix_
|
||||||
|
|
||||||
|
info = 0
|
||||||
|
|
||||||
|
if (present(prefix)) then
|
||||||
|
prefix_ = trim(prefix(1:min(len(prefix),len(prefix_))))
|
||||||
|
else
|
||||||
|
prefix_ = "dump_smth_z"
|
||||||
|
end if
|
||||||
|
|
||||||
|
call psb_info(ictxt,iam,np)
|
||||||
|
|
||||||
|
if (present(smoother)) then
|
||||||
|
smoother_ = smoother
|
||||||
|
else
|
||||||
|
smoother_ = .false.
|
||||||
|
end if
|
||||||
|
lname = len_trim(prefix_)
|
||||||
|
fname = trim(prefix_)
|
||||||
|
write(fname(lname+1:lname+5),'(a,i3.3)') '_p',iam
|
||||||
|
lname = lname + 5
|
||||||
|
|
||||||
|
! At base level do nothing for the smoother
|
||||||
|
if (allocated(sm%sv)) &
|
||||||
|
& call sm%sv%dump(ictxt,level,info,solver=solver)
|
||||||
|
|
||||||
|
end subroutine mld_z_base_smoother_dmp
|
||||||
|
|
@ -0,0 +1,338 @@
|
|||||||
|
!
|
||||||
|
! Apply: comes in two versions, on plain arrays or on encapsulated
|
||||||
|
! vectors.
|
||||||
|
! The base version throws an error, since it means that no explicit
|
||||||
|
! choice was made.
|
||||||
|
! Question: would it make sense to transform the base version into
|
||||||
|
! the ID version, i.e. "base_solver" is the identity operator?
|
||||||
|
!
|
||||||
|
|
||||||
|
subroutine mld_z_base_solver_apply(alpha,sv,x,beta,y,desc_data,trans,work,info)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_z_base_solver_mod, mld_protect_name => mld_z_base_solver_apply
|
||||||
|
implicit none
|
||||||
|
type(psb_desc_type), intent(in) :: desc_data
|
||||||
|
class(mld_z_base_solver_type), intent(in) :: sv
|
||||||
|
complex(psb_dpk_),intent(inout) :: x(:)
|
||||||
|
complex(psb_dpk_),intent(inout) :: y(:)
|
||||||
|
complex(psb_dpk_),intent(in) :: alpha,beta
|
||||||
|
character(len=1),intent(in) :: trans
|
||||||
|
complex(psb_dpk_),target, intent(inout) :: work(:)
|
||||||
|
integer, intent(out) :: info
|
||||||
|
|
||||||
|
Integer :: err_act
|
||||||
|
character(len=20) :: name='d_base_solver_apply'
|
||||||
|
|
||||||
|
call psb_erractionsave(err_act)
|
||||||
|
|
||||||
|
info = psb_err_missing_override_method_
|
||||||
|
call psb_errpush(info,name)
|
||||||
|
goto 9999
|
||||||
|
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
return
|
||||||
|
|
||||||
|
9999 continue
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
if (err_act == psb_act_abort_) then
|
||||||
|
call psb_error()
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
return
|
||||||
|
|
||||||
|
end subroutine mld_z_base_solver_apply
|
||||||
|
|
||||||
|
subroutine mld_z_base_solver_apply_vect(alpha,sv,x,beta,y,desc_data,trans,work,info)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_z_base_solver_mod, mld_protect_name => mld_z_base_solver_apply_vect
|
||||||
|
implicit none
|
||||||
|
type(psb_desc_type), intent(in) :: desc_data
|
||||||
|
class(mld_z_base_solver_type), intent(inout) :: sv
|
||||||
|
type(psb_z_vect_type),intent(inout) :: x
|
||||||
|
type(psb_z_vect_type),intent(inout) :: y
|
||||||
|
complex(psb_dpk_),intent(in) :: alpha,beta
|
||||||
|
character(len=1),intent(in) :: trans
|
||||||
|
complex(psb_dpk_),target, intent(inout) :: work(:)
|
||||||
|
integer, intent(out) :: info
|
||||||
|
|
||||||
|
Integer :: err_act
|
||||||
|
character(len=20) :: name='d_base_solver_apply'
|
||||||
|
|
||||||
|
call psb_erractionsave(err_act)
|
||||||
|
|
||||||
|
info = psb_err_missing_override_method_
|
||||||
|
call psb_errpush(info,name)
|
||||||
|
goto 9999
|
||||||
|
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
return
|
||||||
|
|
||||||
|
9999 continue
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
if (err_act == psb_act_abort_) then
|
||||||
|
call psb_error()
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
return
|
||||||
|
|
||||||
|
end subroutine mld_z_base_solver_apply_vect
|
||||||
|
|
||||||
|
|
||||||
|
!
|
||||||
|
! Build
|
||||||
|
! The base version throws an error, since it means that no explicit
|
||||||
|
! choice was made.
|
||||||
|
!
|
||||||
|
subroutine mld_z_base_solver_bld(a,desc_a,sv,upd,info,b,amold,vmold)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_z_base_solver_mod, mld_protect_name => mld_z_base_solver_bld
|
||||||
|
Implicit None
|
||||||
|
! Arguments
|
||||||
|
type(psb_zspmat_type), intent(in), target :: a
|
||||||
|
Type(psb_desc_type), Intent(in) :: desc_a
|
||||||
|
class(mld_z_base_solver_type), intent(inout) :: sv
|
||||||
|
character, intent(in) :: upd
|
||||||
|
integer, intent(out) :: info
|
||||||
|
type(psb_zspmat_type), intent(in), target, optional :: b
|
||||||
|
class(psb_z_base_sparse_mat), intent(in), optional :: amold
|
||||||
|
class(psb_z_base_vect_type), intent(in), optional :: vmold
|
||||||
|
|
||||||
|
Integer :: err_act
|
||||||
|
character(len=20) :: name='d_base_solver_bld'
|
||||||
|
|
||||||
|
call psb_erractionsave(err_act)
|
||||||
|
|
||||||
|
info = psb_err_missing_override_method_
|
||||||
|
call psb_errpush(info,name)
|
||||||
|
goto 9999
|
||||||
|
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
return
|
||||||
|
|
||||||
|
9999 continue
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
if (err_act == psb_act_abort_) then
|
||||||
|
call psb_error()
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
return
|
||||||
|
end subroutine mld_z_base_solver_bld
|
||||||
|
|
||||||
|
subroutine mld_z_base_solver_check(sv,info)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_z_base_solver_mod, mld_protect_name => mld_z_base_solver_check
|
||||||
|
Implicit None
|
||||||
|
! Arguments
|
||||||
|
class(mld_z_base_solver_type), intent(inout) :: sv
|
||||||
|
integer, intent(out) :: info
|
||||||
|
Integer :: err_act
|
||||||
|
character(len=20) :: name='d_base_solver_check'
|
||||||
|
|
||||||
|
call psb_erractionsave(err_act)
|
||||||
|
info = psb_success_
|
||||||
|
|
||||||
|
|
||||||
|
if (info /= psb_success_) goto 9999
|
||||||
|
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
return
|
||||||
|
|
||||||
|
9999 continue
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
if (err_act == psb_act_abort_) then
|
||||||
|
call psb_error()
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
return
|
||||||
|
end subroutine mld_z_base_solver_check
|
||||||
|
|
||||||
|
!
|
||||||
|
! Set.
|
||||||
|
! The base version does nothing; the principle is that
|
||||||
|
! SET acts on what is known, and delegates what is unknown.
|
||||||
|
! Since we are at the bottom of the hierarchy, there's no one
|
||||||
|
! to delegate, so we do nothing.
|
||||||
|
!
|
||||||
|
subroutine mld_z_base_solver_seti(sv,what,val,info)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_z_base_solver_mod, mld_protect_name => mld_z_base_solver_seti
|
||||||
|
Implicit None
|
||||||
|
! Arguments
|
||||||
|
class(mld_z_base_solver_type), intent(inout) :: sv
|
||||||
|
integer, intent(in) :: what
|
||||||
|
integer, intent(in) :: val
|
||||||
|
integer, intent(out) :: info
|
||||||
|
Integer :: err_act
|
||||||
|
character(len=20) :: name='d_base_solver_seti'
|
||||||
|
|
||||||
|
! Correct action here is doing nothing.
|
||||||
|
info = 0
|
||||||
|
|
||||||
|
return
|
||||||
|
end subroutine mld_z_base_solver_seti
|
||||||
|
|
||||||
|
subroutine mld_z_base_solver_setc(sv,what,val,info)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_z_base_solver_mod, mld_protect_name => mld_z_base_solver_setc
|
||||||
|
Implicit None
|
||||||
|
! Arguments
|
||||||
|
class(mld_z_base_solver_type), intent(inout) :: sv
|
||||||
|
integer, intent(in) :: what
|
||||||
|
character(len=*), intent(in) :: val
|
||||||
|
integer, intent(out) :: info
|
||||||
|
Integer :: err_act, ival
|
||||||
|
character(len=20) :: name='d_base_solver_setc'
|
||||||
|
|
||||||
|
call psb_erractionsave(err_act)
|
||||||
|
|
||||||
|
info = psb_success_
|
||||||
|
|
||||||
|
call mld_stringval(val,ival,info)
|
||||||
|
if (info == psb_success_) call sv%set(what,ival,info)
|
||||||
|
|
||||||
|
if (info /= psb_success_) goto 9999
|
||||||
|
|
||||||
|
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
return
|
||||||
|
|
||||||
|
9999 continue
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
if (err_act == psb_act_abort_) then
|
||||||
|
call psb_error()
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
return
|
||||||
|
end subroutine mld_z_base_solver_setc
|
||||||
|
|
||||||
|
subroutine mld_z_base_solver_setr(sv,what,val,info)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_z_base_solver_mod, mld_protect_name => mld_z_base_solver_setr
|
||||||
|
Implicit None
|
||||||
|
! Arguments
|
||||||
|
class(mld_z_base_solver_type), intent(inout) :: sv
|
||||||
|
integer, intent(in) :: what
|
||||||
|
real(psb_dpk_), intent(in) :: val
|
||||||
|
integer, intent(out) :: info
|
||||||
|
Integer :: err_act
|
||||||
|
character(len=20) :: name='d_base_solver_setr'
|
||||||
|
|
||||||
|
|
||||||
|
! Correct action here is doing nothing.
|
||||||
|
info = 0
|
||||||
|
|
||||||
|
return
|
||||||
|
end subroutine mld_z_base_solver_setr
|
||||||
|
|
||||||
|
!
|
||||||
|
! Free
|
||||||
|
! The base version throws an error, since it means that no explicit
|
||||||
|
! choice was made. IS THIS CORRECT? I suspect it would be better
|
||||||
|
! to be silent here, to cover reallocation.
|
||||||
|
!
|
||||||
|
subroutine mld_z_base_solver_free(sv,info)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_z_base_solver_mod, mld_protect_name => mld_z_base_solver_free
|
||||||
|
Implicit None
|
||||||
|
! Arguments
|
||||||
|
class(mld_z_base_solver_type), intent(inout) :: sv
|
||||||
|
integer, intent(out) :: info
|
||||||
|
Integer :: err_act
|
||||||
|
character(len=20) :: name='d_base_solver_free'
|
||||||
|
|
||||||
|
call psb_erractionsave(err_act)
|
||||||
|
|
||||||
|
info = psb_err_missing_override_method_
|
||||||
|
call psb_errpush(info,name)
|
||||||
|
goto 9999
|
||||||
|
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
return
|
||||||
|
|
||||||
|
9999 continue
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
if (err_act == psb_act_abort_) then
|
||||||
|
call psb_error()
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
return
|
||||||
|
end subroutine mld_z_base_solver_free
|
||||||
|
|
||||||
|
subroutine mld_z_base_solver_descr(sv,info,iout,coarse)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_z_base_solver_mod, mld_protect_name => mld_z_base_solver_descr
|
||||||
|
Implicit None
|
||||||
|
! Arguments
|
||||||
|
class(mld_z_base_solver_type), intent(in) :: sv
|
||||||
|
integer, intent(out) :: info
|
||||||
|
integer, intent(in), optional :: iout
|
||||||
|
logical, intent(in), optional :: coarse
|
||||||
|
|
||||||
|
! Local variables
|
||||||
|
integer :: err_act
|
||||||
|
integer :: ictxt, me, np
|
||||||
|
character(len=20), parameter :: name='mld_z_base_solver_descr'
|
||||||
|
integer :: iout_
|
||||||
|
|
||||||
|
|
||||||
|
call psb_erractionsave(err_act)
|
||||||
|
|
||||||
|
info = psb_err_missing_override_method_
|
||||||
|
call psb_errpush(info,name)
|
||||||
|
goto 9999
|
||||||
|
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
return
|
||||||
|
|
||||||
|
9999 continue
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
if (err_act == psb_act_abort_) then
|
||||||
|
call psb_error()
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
return
|
||||||
|
end subroutine mld_z_base_solver_descr
|
||||||
|
|
||||||
|
!
|
||||||
|
! Dump. For debugging purposes.
|
||||||
|
!
|
||||||
|
subroutine mld_z_base_solver_dmp(sv,ictxt,level,info,prefix,head,solver)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_z_base_solver_mod, mld_protect_name => mld_z_base_solver_dmp
|
||||||
|
implicit none
|
||||||
|
class(mld_z_base_solver_type), intent(in) :: sv
|
||||||
|
integer, intent(in) :: ictxt,level
|
||||||
|
integer, intent(out) :: info
|
||||||
|
character(len=*), intent(in), optional :: prefix, head
|
||||||
|
logical, optional, intent(in) :: solver
|
||||||
|
integer :: i, j, il1, iln, lname, lev
|
||||||
|
integer :: icontxt,iam, np
|
||||||
|
character(len=80) :: prefix_
|
||||||
|
character(len=120) :: fname ! len should be at least 20 more than
|
||||||
|
logical :: solver_
|
||||||
|
! len of prefix_
|
||||||
|
|
||||||
|
info = 0
|
||||||
|
|
||||||
|
if (present(prefix)) then
|
||||||
|
prefix_ = trim(prefix(1:min(len(prefix),len(prefix_))))
|
||||||
|
else
|
||||||
|
prefix_ = "dump_slv_z"
|
||||||
|
end if
|
||||||
|
|
||||||
|
call psb_info(ictxt,iam,np)
|
||||||
|
|
||||||
|
if (present(solver)) then
|
||||||
|
solver_ = solver
|
||||||
|
else
|
||||||
|
solver_ = .false.
|
||||||
|
end if
|
||||||
|
lname = len_trim(prefix_)
|
||||||
|
fname = trim(prefix_)
|
||||||
|
write(fname(lname+1:lname+5),'(a,i3.3)') '_p',iam
|
||||||
|
lname = lname + 5
|
||||||
|
|
||||||
|
! At base level do nothing for the solver
|
||||||
|
|
||||||
|
end subroutine mld_z_base_solver_dmp
|
||||||
|
|
@ -0,0 +1,459 @@
|
|||||||
|
!!$
|
||||||
|
!!$
|
||||||
|
!!$ MLD2P4 version 2.0
|
||||||
|
!!$ MultiLevel Domain Decomposition Parallel Preconditioners Package
|
||||||
|
!!$ based on PSBLAS (Parallel Sparse BLAS version 3.0)
|
||||||
|
!!$
|
||||||
|
!!$ (C) Copyright 2008,2009,2010
|
||||||
|
!!$
|
||||||
|
!!$ Salvatore Filippone University of Rome Tor Vergata
|
||||||
|
!!$ Alfredo Buttari CNRS-IRIT, Toulouse
|
||||||
|
!!$ Pasqua D'Ambra ICAR-CNR, Naples
|
||||||
|
!!$ Daniela di Serafino Second University of Naples
|
||||||
|
!!$
|
||||||
|
!!$ 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 MLD2P4 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 MLD2P4 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: mld_file_onelev_descr
|
||||||
|
! Version: complex
|
||||||
|
!
|
||||||
|
! This routine prints a description of the preconditioner to the standard
|
||||||
|
! output or to a file. It must be called after the preconditioner has been
|
||||||
|
! built by mld_precbld.
|
||||||
|
!
|
||||||
|
! Arguments:
|
||||||
|
! p - type(mld_Tprec_type), input.
|
||||||
|
! The preconditioner data structure to be printed out.
|
||||||
|
! info - integer, output.
|
||||||
|
! error code.
|
||||||
|
! iout - integer, input, optional.
|
||||||
|
! The id of the file where the preconditioner description
|
||||||
|
! will be printed. If iout is not present, then the standard
|
||||||
|
! output is condidered.
|
||||||
|
!
|
||||||
|
subroutine mld_z_base_onelev_descr(lv,il,nl,info,iout)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_zonelev_mod, mld_protect_name => mld_z_base_onelev_descr
|
||||||
|
Implicit None
|
||||||
|
! Arguments
|
||||||
|
class(mld_zonelev_type), intent(in) :: lv
|
||||||
|
integer, intent(in) :: il,nl
|
||||||
|
integer, intent(out) :: info
|
||||||
|
integer, intent(in), optional :: iout
|
||||||
|
|
||||||
|
! Local variables
|
||||||
|
integer :: err_act
|
||||||
|
integer :: ictxt, me, np
|
||||||
|
character(len=20), parameter :: name='mld_z_base_onelev_descr'
|
||||||
|
integer :: iout_
|
||||||
|
logical :: coarse
|
||||||
|
|
||||||
|
|
||||||
|
call psb_erractionsave(err_act)
|
||||||
|
|
||||||
|
|
||||||
|
coarse = (il==nl)
|
||||||
|
|
||||||
|
if (present(iout)) then
|
||||||
|
iout_ = iout
|
||||||
|
else
|
||||||
|
iout_ = 6
|
||||||
|
end if
|
||||||
|
|
||||||
|
write(iout_,*)
|
||||||
|
if (il == 2) then
|
||||||
|
call lv%parms%mldescr(iout_,info)
|
||||||
|
write(iout_,*)
|
||||||
|
end if
|
||||||
|
|
||||||
|
if (coarse) then
|
||||||
|
write(iout_,*) ' Level ',il,' (coarsest)'
|
||||||
|
else
|
||||||
|
write(iout_,*) ' Level ',il
|
||||||
|
end if
|
||||||
|
|
||||||
|
call lv%parms%descr(iout_,info,coarse=coarse)
|
||||||
|
|
||||||
|
if (nl > 1) then
|
||||||
|
if (allocated(lv%map%naggr)) then
|
||||||
|
write(iout_,*) ' Size of coarse matrix: ', &
|
||||||
|
& sum(lv%map%naggr(:))
|
||||||
|
write(iout_,*) ' Sizes of aggregates: ', &
|
||||||
|
& lv%map%naggr(:)
|
||||||
|
end if
|
||||||
|
end if
|
||||||
|
|
||||||
|
if (coarse.and.allocated(lv%sm)) &
|
||||||
|
& call lv%sm%descr(info,iout=iout_,coarse=coarse)
|
||||||
|
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
return
|
||||||
|
|
||||||
|
9999 continue
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
if (err_act == psb_act_abort_) then
|
||||||
|
call psb_error()
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
return
|
||||||
|
end subroutine mld_z_base_onelev_descr
|
||||||
|
|
||||||
|
|
||||||
|
!
|
||||||
|
! Subroutines: mld_T_onelev_precfree
|
||||||
|
! Version: complex
|
||||||
|
!
|
||||||
|
! These routines deallocate the mld_Tonelev_type
|
||||||
|
!
|
||||||
|
! Arguments:
|
||||||
|
! p - type(mld_Tonelev_type), input.
|
||||||
|
! The data structure to be deallocated.
|
||||||
|
! info - integer, output.
|
||||||
|
! error code.
|
||||||
|
!
|
||||||
|
subroutine mld_z_base_onelev_free(lv,info)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_zonelev_mod, mld_protect_name =>: mld_T_onelev_precfree
|
||||||
|
implicit none
|
||||||
|
|
||||||
|
class(mld_zonelev_type), intent(inout) :: lv
|
||||||
|
integer, intent(out) :: info
|
||||||
|
integer :: i
|
||||||
|
|
||||||
|
info = psb_success_
|
||||||
|
|
||||||
|
! We might just deallocate the top level array, except
|
||||||
|
! that there may be inner objects containing C pointers,
|
||||||
|
! e.g. UMFPACK, SLU or CUDA stuff.
|
||||||
|
! We really need FINALs.
|
||||||
|
call lv%sm%free(info)
|
||||||
|
|
||||||
|
call lv%ac%free()
|
||||||
|
if (psb_is_ok_desc(lv%desc_ac)) &
|
||||||
|
& call psb_cdfree(lv%desc_ac,info)
|
||||||
|
call lv%map%free(info)
|
||||||
|
|
||||||
|
! This is a pointer to something else, must not free it here.
|
||||||
|
nullify(lv%base_a)
|
||||||
|
! This is a pointer to something else, must not free it here.
|
||||||
|
nullify(lv%base_desc)
|
||||||
|
|
||||||
|
call lv%nullify()
|
||||||
|
|
||||||
|
end subroutine mld_z_base_onelev_free
|
||||||
|
|
||||||
|
!
|
||||||
|
! Onelevel checks.
|
||||||
|
! The number of Jacobi sweeps to be applied is not
|
||||||
|
! tied to the Jacobi smoother: logically, you have
|
||||||
|
! a smoother and you can choose to apply it any number
|
||||||
|
! of times you like.
|
||||||
|
!
|
||||||
|
subroutine mld_z_base_onelev_check(lv,info)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_zonelev_mod, mld_protect_name => mld_z_base_onelev_check
|
||||||
|
|
||||||
|
Implicit None
|
||||||
|
|
||||||
|
! Arguments
|
||||||
|
class(mld_zonelev_type), intent(inout) :: lv
|
||||||
|
integer, intent(out) :: info
|
||||||
|
Integer :: err_act
|
||||||
|
character(len=20) :: name='z_base_onelev_check'
|
||||||
|
|
||||||
|
call psb_erractionsave(err_act)
|
||||||
|
info = psb_success_
|
||||||
|
|
||||||
|
call mld_check_def(lv%parms%sweeps,&
|
||||||
|
& 'Jacobi sweeps',1,is_legal_jac_sweeps)
|
||||||
|
call mld_check_def(lv%parms%sweeps_pre,&
|
||||||
|
& 'Jacobi sweeps',1,is_legal_jac_sweeps)
|
||||||
|
call mld_check_def(lv%parms%sweeps_post,&
|
||||||
|
& 'Jacobi sweeps',1,is_legal_jac_sweeps)
|
||||||
|
|
||||||
|
|
||||||
|
if (allocated(lv%sm)) then
|
||||||
|
call lv%sm%check(info)
|
||||||
|
else
|
||||||
|
info=3111
|
||||||
|
call psb_errpush(info,name)
|
||||||
|
goto 9999
|
||||||
|
end if
|
||||||
|
|
||||||
|
if (info /= psb_success_) goto 9999
|
||||||
|
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
return
|
||||||
|
|
||||||
|
9999 continue
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
if (err_act == psb_act_abort_) then
|
||||||
|
call psb_error()
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
return
|
||||||
|
end subroutine mld_z_base_onelev_check
|
||||||
|
|
||||||
|
|
||||||
|
!
|
||||||
|
! Set routines:
|
||||||
|
! Parameters belonging here are:
|
||||||
|
! Number of smoothing sweeps;
|
||||||
|
! Smoother position;
|
||||||
|
! Aggregation related parameters
|
||||||
|
! Record request on coarse level solver,
|
||||||
|
! for checks on solver vs. smoother nomenclature
|
||||||
|
! reconciliation.
|
||||||
|
!
|
||||||
|
subroutine mld_z_base_onelev_seti(lv,what,val,info)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_zonelev_mod, mld_protect_name => mld_z_base_onelev_seti
|
||||||
|
|
||||||
|
Implicit None
|
||||||
|
|
||||||
|
! Arguments
|
||||||
|
class(mld_zonelev_type), intent(inout) :: lv
|
||||||
|
integer, intent(in) :: what
|
||||||
|
integer, intent(in) :: val
|
||||||
|
integer, intent(out) :: info
|
||||||
|
Integer :: err_act
|
||||||
|
character(len=20) :: name='z_base_onelev_seti'
|
||||||
|
|
||||||
|
call psb_erractionsave(err_act)
|
||||||
|
info = psb_success_
|
||||||
|
|
||||||
|
select case (what)
|
||||||
|
|
||||||
|
case (mld_smoother_sweeps_)
|
||||||
|
lv%parms%sweeps = val
|
||||||
|
lv%parms%sweeps_pre = val
|
||||||
|
lv%parms%sweeps_post = val
|
||||||
|
|
||||||
|
case (mld_smoother_sweeps_pre_)
|
||||||
|
lv%parms%sweeps_pre = val
|
||||||
|
|
||||||
|
case (mld_smoother_sweeps_post_)
|
||||||
|
lv%parms%sweeps_post = val
|
||||||
|
|
||||||
|
case (mld_ml_type_)
|
||||||
|
lv%parms%ml_type = val
|
||||||
|
|
||||||
|
case (mld_aggr_alg_)
|
||||||
|
lv%parms%aggr_alg = val
|
||||||
|
|
||||||
|
case (mld_aggr_kind_)
|
||||||
|
lv%parms%aggr_kind = val
|
||||||
|
|
||||||
|
case (mld_coarse_mat_)
|
||||||
|
lv%parms%coarse_mat = val
|
||||||
|
|
||||||
|
case (mld_smoother_pos_)
|
||||||
|
lv%parms%smoother_pos = val
|
||||||
|
|
||||||
|
case (mld_aggr_omega_alg_)
|
||||||
|
lv%parms%aggr_omega_alg= val
|
||||||
|
|
||||||
|
case (mld_aggr_eig_)
|
||||||
|
lv%parms%aggr_eig = val
|
||||||
|
|
||||||
|
case (mld_aggr_filter_)
|
||||||
|
lv%parms%aggr_filter = val
|
||||||
|
|
||||||
|
case (mld_coarse_solve_)
|
||||||
|
lv%parms%coarse_solve = val
|
||||||
|
|
||||||
|
case default
|
||||||
|
if (allocated(lv%sm)) then
|
||||||
|
call lv%sm%set(what,val,info)
|
||||||
|
end if
|
||||||
|
if (info /= psb_success_) goto 9999
|
||||||
|
end select
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
return
|
||||||
|
|
||||||
|
9999 continue
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
if (err_act == psb_act_abort_) then
|
||||||
|
call psb_error()
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
return
|
||||||
|
end subroutine mld_z_base_onelev_seti
|
||||||
|
|
||||||
|
subroutine mld_z_base_onelev_setc(lv,what,val,info)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_zonelev_mod, mld_protect_name => mld_z_base_onelev_setc
|
||||||
|
|
||||||
|
Implicit None
|
||||||
|
|
||||||
|
! Arguments
|
||||||
|
class(mld_zonelev_type), intent(inout) :: lv
|
||||||
|
integer, intent(in) :: what
|
||||||
|
character(len=*), intent(in) :: val
|
||||||
|
integer, intent(out) :: info
|
||||||
|
Integer :: err_act
|
||||||
|
character(len=20) :: name='z_base_onelev_setc'
|
||||||
|
integer :: ival
|
||||||
|
|
||||||
|
call psb_erractionsave(err_act)
|
||||||
|
|
||||||
|
info = psb_success_
|
||||||
|
|
||||||
|
call mld_stringval(val,ival,info)
|
||||||
|
if (info == psb_success_) call lv%set(what,ival,info)
|
||||||
|
|
||||||
|
if (info /= psb_success_) goto 9999
|
||||||
|
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
return
|
||||||
|
|
||||||
|
9999 continue
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
if (err_act == psb_act_abort_) then
|
||||||
|
call psb_error()
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
return
|
||||||
|
end subroutine mld_z_base_onelev_setc
|
||||||
|
|
||||||
|
subroutine mld_z_base_onelev_setr(lv,what,val,info)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_zonelev_mod, mld_protect_name => mld_z_base_onelev_setr
|
||||||
|
|
||||||
|
Implicit None
|
||||||
|
|
||||||
|
! Arguments
|
||||||
|
class(mld_zonelev_type), intent(inout) :: lv
|
||||||
|
integer, intent(in) :: what
|
||||||
|
real(psb_dpk_), intent(in) :: val
|
||||||
|
integer, intent(out) :: info
|
||||||
|
Integer :: err_act
|
||||||
|
character(len=20) :: name='z_base_onelev_setr'
|
||||||
|
|
||||||
|
call psb_erractionsave(err_act)
|
||||||
|
|
||||||
|
|
||||||
|
info = psb_success_
|
||||||
|
|
||||||
|
select case (what)
|
||||||
|
|
||||||
|
case (mld_aggr_omega_val_)
|
||||||
|
lv%parms%aggr_omega_val= val
|
||||||
|
|
||||||
|
case (mld_aggr_thresh_)
|
||||||
|
lv%parms%aggr_thresh = val
|
||||||
|
|
||||||
|
case default
|
||||||
|
if (allocated(lv%sm)) then
|
||||||
|
call lv%sm%set(what,val,info)
|
||||||
|
end if
|
||||||
|
if (info /= psb_success_) goto 9999
|
||||||
|
end select
|
||||||
|
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
return
|
||||||
|
|
||||||
|
9999 continue
|
||||||
|
call psb_erractionrestore(err_act)
|
||||||
|
if (err_act == psb_act_abort_) then
|
||||||
|
call psb_error()
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
return
|
||||||
|
end subroutine mld_z_base_onelev_setr
|
||||||
|
|
||||||
|
!
|
||||||
|
! Dump on file: can be fine-tuned to include the (aggregated) matrix
|
||||||
|
! as well as smoother and solver.
|
||||||
|
!
|
||||||
|
subroutine mld_z_base_onelev_dump(lv,level,info,prefix,head,ac,rp,smoother,solver)
|
||||||
|
use psb_base_mod
|
||||||
|
use mld_zonelev_mod, mld_protect_name => mld_z_base_onelev_dump
|
||||||
|
implicit none
|
||||||
|
class(mld_zonelev_type), intent(in) :: lv
|
||||||
|
integer, intent(in) :: level
|
||||||
|
integer, intent(out) :: info
|
||||||
|
character(len=*), intent(in), optional :: prefix, head
|
||||||
|
logical, optional, intent(in) :: ac, rp, smoother, solver
|
||||||
|
integer :: i, j, il1, iln, lname, lev
|
||||||
|
integer :: icontxt,iam, np
|
||||||
|
character(len=80) :: prefix_
|
||||||
|
character(len=120) :: fname ! len should be at least 20 more than
|
||||||
|
logical :: ac_, rp_
|
||||||
|
! len of prefix_
|
||||||
|
|
||||||
|
info = 0
|
||||||
|
|
||||||
|
if (present(prefix)) then
|
||||||
|
prefix_ = trim(prefix(1:min(len(prefix),len(prefix_))))
|
||||||
|
else
|
||||||
|
prefix_ = "dump_lev_z"
|
||||||
|
end if
|
||||||
|
|
||||||
|
if (associated(lv%base_desc)) then
|
||||||
|
icontxt = lv%base_desc%get_context()
|
||||||
|
call psb_info(icontxt,iam,np)
|
||||||
|
else
|
||||||
|
icontxt = -1
|
||||||
|
iam = -1
|
||||||
|
end if
|
||||||
|
if (present(ac)) then
|
||||||
|
ac_ = ac
|
||||||
|
else
|
||||||
|
ac_ = .false.
|
||||||
|
end if
|
||||||
|
if (present(rp)) then
|
||||||
|
rp_ = rp
|
||||||
|
else
|
||||||
|
rp_ = .false.
|
||||||
|
end if
|
||||||
|
lname = len_trim(prefix_)
|
||||||
|
fname = trim(prefix_)
|
||||||
|
write(fname(lname+1:lname+5),'(a,i3.3)') '_p',iam
|
||||||
|
lname = lname + 5
|
||||||
|
|
||||||
|
if (level >= 2) then
|
||||||
|
if (ac_) then
|
||||||
|
write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_ac.mtx'
|
||||||
|
write(0,*) 'Filename ',fname
|
||||||
|
call lv%ac%print(fname,head=head)
|
||||||
|
end if
|
||||||
|
if (rp_) then
|
||||||
|
write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_r.mtx'
|
||||||
|
write(0,*) 'Filename ',fname
|
||||||
|
call lv%map%map_X2Y%print(fname,head=head)
|
||||||
|
write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_p.mtx'
|
||||||
|
write(0,*) 'Filename ',fname
|
||||||
|
call lv%map%map_Y2X%print(fname,head=head)
|
||||||
|
end if
|
||||||
|
end if
|
||||||
|
if (allocated(lv%sm)) &
|
||||||
|
& call lv%sm%dump(icontxt,level,info,smoother=smoother,solver=solver)
|
||||||
|
|
||||||
|
end subroutine mld_z_base_onelev_dump
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue