You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
154 lines
5.3 KiB
Fortran
154 lines
5.3 KiB
Fortran
8 years ago
|
!
|
||
|
!
|
||
4 years ago
|
! AMG4PSBLAS version 1.0
|
||
|
! Algebraic Multigrid Package
|
||
8 years ago
|
! based on PSBLAS (Parallel Sparse BLAS version 3.5)
|
||
8 years ago
|
!
|
||
4 years ago
|
! (C) Copyright 2020
|
||
8 years ago
|
!
|
||
7 years ago
|
! Salvatore Filippone
|
||
|
! Pasqua D'Ambra
|
||
4 years ago
|
! Fabio Durastante
|
||
8 years ago
|
!
|
||
|
! 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.
|
||
4 years ago
|
! 3. The name of the AMG4PSBLAS group or the names of its contributors may
|
||
8 years ago
|
! 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
|
||
4 years ago
|
! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AMG4PSBLAS GROUP OR ITS CONTRIBUTORS
|
||
8 years ago
|
! 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.
|
||
|
!
|
||
|
!
|
||
4 years ago
|
subroutine amg_s_base_onelev_build(lv,info,amold,vmold,imold,ilv)
|
||
9 years ago
|
use psb_base_mod
|
||
4 years ago
|
use amg_s_onelev_mod, amg_protect_name => amg_s_base_onelev_build
|
||
9 years ago
|
implicit none
|
||
4 years ago
|
class(amg_s_onelev_type), target, intent(inout) :: lv
|
||
9 years ago
|
integer(psb_ipk_), intent(out) :: info
|
||
|
class(psb_s_base_sparse_mat), intent(in), optional :: amold
|
||
|
class(psb_s_base_vect_type), intent(in), optional :: vmold
|
||
|
class(psb_i_base_vect_type), intent(in), optional :: imold
|
||
5 years ago
|
integer(psb_ipk_), intent(in), optional :: ilv
|
||
9 years ago
|
! Local
|
||
5 years ago
|
integer(psb_ipk_) :: err,i,k, err_act
|
||
9 years ago
|
integer(psb_ipk_) :: ictxt, me, np
|
||
|
integer(psb_ipk_) :: debug_level, debug_unit
|
||
|
character(len=20) :: name, ch_err
|
||
|
|
||
4 years ago
|
name = 'amg_onelev_build'
|
||
9 years ago
|
info=psb_success_
|
||
|
err=0
|
||
|
call psb_erractionsave(err_act)
|
||
7 years ago
|
if (psb_errstatus_fatal()) then
|
||
|
info = psb_err_internal_error_; goto 9999
|
||
|
end if
|
||
9 years ago
|
debug_unit = psb_get_debug_unit()
|
||
|
debug_level = psb_get_debug_level()
|
||
|
if (.not.associated(lv%base_desc)) then
|
||
|
info = psb_err_internal_error_
|
||
|
call psb_errpush(info,name,&
|
||
|
& a_err='Unassociated base DESC')
|
||
|
goto 9999
|
||
|
end if
|
||
|
info = psb_success_
|
||
|
ictxt = lv%base_desc%get_ctxt()
|
||
|
call psb_info(ictxt,me,np)
|
||
|
|
||
|
if (.not.allocated(lv%sm)) then
|
||
4 years ago
|
!! Error: should have called amg_dprecinit
|
||
9 years ago
|
info=3111
|
||
|
call psb_errpush(info,name)
|
||
|
goto 9999
|
||
|
end if
|
||
|
if (.not.allocated(lv%sm%sv)) then
|
||
4 years ago
|
!! Error: should have called amg_dprecinit
|
||
9 years ago
|
info=3111
|
||
|
call psb_errpush(info,name)
|
||
|
goto 9999
|
||
|
end if
|
||
|
lv%ac_nz_loc = lv%ac%get_nzeros()
|
||
|
lv%ac_nz_tot = lv%ac_nz_loc
|
||
5 years ago
|
select case(lv%parms%coarse_mat)
|
||
4 years ago
|
case(amg_distr_mat_)
|
||
5 years ago
|
call psb_sum(ictxt,lv%ac_nz_tot)
|
||
4 years ago
|
case(amg_repl_mat_)
|
||
5 years ago
|
! Do nothing
|
||
|
case default
|
||
|
! Should never get here
|
||
|
info = psb_err_internal_error_
|
||
|
call psb_errpush(info,name,a_err='Wrong lv%parms')
|
||
|
goto 9999
|
||
|
end select
|
||
|
|
||
|
|
||
9 years ago
|
if (debug_level >= psb_debug_outer_) &
|
||
|
& write(debug_unit,*) me,' ',trim(name),&
|
||
|
& 'Calling mlprcbld at level ',i
|
||
4 years ago
|
call amg_check_def(lv%parms%sweeps_pre,&
|
||
9 years ago
|
& 'Jacobi sweeps',izero,is_int_non_negative)
|
||
4 years ago
|
call amg_check_def(lv%parms%sweeps_post,&
|
||
9 years ago
|
& 'Jacobi sweeps',izero,is_int_non_negative)
|
||
9 years ago
|
|
||
5 years ago
|
call lv%sm%build(lv%base_a,lv%base_desc,info)
|
||
|
if (info == 0) then
|
||
|
if (allocated(lv%sm2a)) then
|
||
|
call lv%sm2a%build(lv%base_a,lv%base_desc,info)
|
||
|
lv%sm2 => lv%sm2a
|
||
|
else
|
||
|
lv%sm2 => lv%sm
|
||
|
end if
|
||
|
end if
|
||
|
if (info /=0 ) then
|
||
|
info = psb_err_internal_error_
|
||
|
call psb_errpush(info,name,&
|
||
|
& a_err='Smoother bld error')
|
||
|
goto 9999
|
||
7 years ago
|
end if
|
||
5 years ago
|
|
||
5 years ago
|
if (lv%sm%sv%is_global()) then
|
||
|
if ((lv%parms%sweeps_pre>1).or.(lv%parms%sweeps_post>1)) then
|
||
|
lv%parms%sweeps_pre = 1
|
||
|
lv%parms%sweeps_post = 1
|
||
|
if (me == 0) then
|
||
5 years ago
|
write(debug_unit,*)
|
||
5 years ago
|
if (present(ilv)) then
|
||
|
write(debug_unit,*) 'Warning: the solver "',trim(lv%sm%sv%get_fmt()),&
|
||
|
& '" at level ',ilv
|
||
|
write(debug_unit,*) ' is configured as a global solver '
|
||
|
else
|
||
|
write(debug_unit,*) 'Warning: the solver "',trim(lv%sm%sv%get_fmt()),&
|
||
|
& '" is configured as a global solver '
|
||
|
end if
|
||
|
write(debug_unit,*) ' Pre and post sweeps at this level reset to 1'
|
||
|
end if
|
||
|
end if
|
||
|
end if
|
||
|
|
||
5 years ago
|
if (any((/present(amold),present(vmold),present(imold)/))) &
|
||
|
& call lv%cnv(info,amold=amold,vmold=vmold,imold=imold)
|
||
|
|
||
9 years ago
|
call psb_erractionrestore(err_act)
|
||
|
return
|
||
5 years ago
|
|
||
9 years ago
|
9999 call psb_error_handler(err_act)
|
||
5 years ago
|
|
||
9 years ago
|
return
|
||
5 years ago
|
|
||
4 years ago
|
end subroutine amg_s_base_onelev_build
|