diff --git a/mlprec/mld_caggrmat_asb.f90 b/mlprec/mld_caggrmat_asb.f90 index 09e2e21a..0f500205 100644 --- a/mlprec/mld_caggrmat_asb.f90 +++ b/mlprec/mld_caggrmat_asb.f90 @@ -52,7 +52,7 @@ ! adjacency graph of A_C has been computed by the mld_aggrmap_bld subroutine. ! The prolongator P_C is built here from this mapping, according to the ! value of p%iprcparm(mld_aggr_kind_), specified by the user through -! mld_dprecinit and mld_dprecset. +! mld_cprecinit and mld_cprecset. ! ! Currently three different prolongators are implemented, corresponding to ! three aggregation algorithms: @@ -76,24 +76,21 @@ ! 1181-1196. ! ! +! ! Arguments: ! a - type(psb_cspmat_type), input. ! The sparse matrix structure containing the local part of ! the fine-level matrix. ! desc_a - type(psb_desc_type), input. ! The communication descriptor of the fine-level matrix. -! ac - type(psb_cspmat_type), output. -! The sparse matrix structure containing the local part of -! the coarse-level matrix. -! desc_ac - type(psb_desc_type), output. -! The communication descriptor of the coarse-level matrix. -! p - type(mld_cbaseprc_type), input/output. -! The base preconditioner data structure containing the local -! part of the base preconditioner to be built. +! p - type(mld_c_onelev_prec_type), input/output. +! The one-level preconditioner data structure containing the local +! part of the base preconditioner to be built as well as the +! aggregate matrices. ! info - integer, output. ! Error code. ! -subroutine mld_caggrmat_asb(a,desc_a,ac,desc_ac,p,info) +subroutine mld_caggrmat_asb(a,desc_a,p,info) use psb_base_mod use mld_inner_mod, mld_protect_name => mld_caggrmat_asb @@ -101,12 +98,10 @@ subroutine mld_caggrmat_asb(a,desc_a,ac,desc_ac,p,info) implicit none ! Arguments - type(psb_cspmat_type), intent(in) :: a - type(psb_desc_type), intent(in) :: desc_a - type(psb_cspmat_type), intent(out) :: ac - type(psb_desc_type), intent(out) :: desc_ac - type(mld_cbaseprc_type), intent(inout), target :: p - integer, intent(out) :: info + type(psb_cspmat_type), intent(in) :: a + type(psb_desc_type), intent(in) :: desc_a + type(mld_c_onelev_prec_type), intent(inout), target :: p + integer, intent(out) :: info ! Local variables integer :: ictxt,np,me, err_act, icomm @@ -125,7 +120,7 @@ subroutine mld_caggrmat_asb(a,desc_a,ac,desc_ac,p,info) select case (p%iprcparm(mld_aggr_kind_)) case (mld_no_smooth_) - call mld_aggrmat_raw_asb(a,desc_a,ac,desc_ac,p,info) + call mld_aggrmat_raw_asb(a,desc_a,p,info) if(info /= 0) then call psb_errpush(4010,name,a_err='mld_aggrmat_raw_asb') goto 9999 @@ -133,7 +128,7 @@ subroutine mld_caggrmat_asb(a,desc_a,ac,desc_ac,p,info) case(mld_smooth_prol_,mld_biz_prol_) - call mld_aggrmat_smth_asb(a,desc_a,ac,desc_ac,p,info) + call mld_aggrmat_smth_asb(a,desc_a,p,info) if(info /= 0) then call psb_errpush(4010,name,a_err='mld_aggrmat_smth_asb') goto 9999 diff --git a/mlprec/mld_caggrmat_raw_asb.F90 b/mlprec/mld_caggrmat_raw_asb.F90 index 8ff8790e..a1799c5f 100644 --- a/mlprec/mld_caggrmat_raw_asb.F90 +++ b/mlprec/mld_caggrmat_raw_asb.F90 @@ -51,7 +51,7 @@ ! ! The coarse-level matrix A_C is distributed among the parallel processes or ! replicated on each of them, according to the value of p%iprcparm(mld_coarse_mat_), -! specified by the user through mld_dprecinit and mld_dprecset. +! specified by the user through mld_cprecinit and mld_cprecset. ! ! For details see ! P. D'Ambra, D. di Serafino and S. Filippone, On the development of @@ -59,24 +59,21 @@ ! 57 (2007), 1181-1196. ! ! +! ! Arguments: ! a - type(psb_cspmat_type), input. ! The sparse matrix structure containing the local part of ! the fine-level matrix. ! desc_a - type(psb_desc_type), input. ! The communication descriptor of the fine-level matrix. -! ac - type(psb_cspmat_type), output. -! The sparse matrix structure containing the local part of -! the coarse-level matrix. -! desc_ac - type(psb_desc_type), output. -! The communication descriptor of the coarse-level matrix. -! p - type(mld_cbaseprc_type), input/output. -! The base preconditioner data structure containing the local -! part of the base preconditioner to be built. +! p - type(mld_c_onelev_prec_type), input/output. +! The one-level preconditioner data structure containing the local +! part of the base preconditioner to be built as well as the +! aggregate matrices. ! info - integer, output. ! Error code. ! -subroutine mld_caggrmat_raw_asb(a,desc_a,ac,desc_ac,p,info) +subroutine mld_caggrmat_raw_asb(a,desc_a,p,info) use psb_base_mod use mld_inner_mod, mld_protect_name => mld_caggrmat_raw_asb @@ -89,19 +86,17 @@ subroutine mld_caggrmat_raw_asb(a,desc_a,ac,desc_ac,p,info) #endif ! Arguments - type(psb_cspmat_type), intent(in) :: a - type(psb_desc_type), intent(in) :: desc_a - type(psb_cspmat_type), intent(out) :: ac - type(psb_desc_type), intent(out) :: desc_ac - type(mld_cbaseprc_type), intent(inout), target :: p - integer, intent(out) :: info + type(psb_cspmat_type), intent(in) :: a + type(psb_desc_type), intent(in) :: desc_a + type(mld_c_onelev_prec_type), intent(inout), target :: p + integer, intent(out) :: info ! Local variables integer ::ictxt,np,me, err_act, icomm character(len=20) :: name type(psb_cspmat_type) :: b - integer, pointer :: nzbr(:), idisp(:) - type(psb_cspmat_type), pointer :: am1,am2 + integer, allocatable :: nzbr(:), idisp(:) + type(psb_cspmat_type) :: am1,am2 integer :: nrow, nglob, ncol, ntaggr, nzac, ip, ndx,& & naggr, nzt,naggrm1, i @@ -119,9 +114,6 @@ subroutine mld_caggrmat_raw_asb(a,desc_a,ac,desc_ac,p,info) nrow = psb_cd_get_local_rows(desc_a) ncol = psb_cd_get_local_cols(desc_a) - - am2 => p%av(mld_sm_pr_t_) - am1 => p%av(mld_sm_pr_) call psb_nullify_sp(am1) call psb_nullify_sp(am2) @@ -195,7 +187,7 @@ subroutine mld_caggrmat_raw_asb(a,desc_a,ac,desc_ac,p,info) if (p%iprcparm(mld_coarse_mat_) == mld_repl_mat_) then - call psb_cdall(ictxt,desc_ac,info,mg=ntaggr,repl=.true.) + call psb_cdall(ictxt,p%desc_ac,info,mg=ntaggr,repl=.true.) if(info /= 0) then call psb_errpush(4010,name,a_err='psb_cdall') goto 9999 @@ -206,7 +198,7 @@ subroutine mld_caggrmat_raw_asb(a,desc_a,ac,desc_ac,p,info) call psb_sum(ictxt,nzbr(1:np)) nzac = sum(nzbr) - call psb_sp_all(ntaggr,ntaggr,ac,nzac,info) + call psb_sp_all(ntaggr,ntaggr,p%ac,nzac,info) if(info /= 0) then call psb_errpush(4010,name,a_err='sp_all') goto 9999 @@ -217,11 +209,11 @@ subroutine mld_caggrmat_raw_asb(a,desc_a,ac,desc_ac,p,info) enddo ndx = nzbr(me+1) - call mpi_allgatherv(b%aspk,ndx,mpi_complex,ac%aspk,nzbr,idisp,& + call mpi_allgatherv(b%aspk,ndx,mpi_complex,p%ac%aspk,nzbr,idisp,& & mpi_complex,icomm,info) - call mpi_allgatherv(b%ia1,ndx,mpi_integer,ac%ia1,nzbr,idisp,& + call mpi_allgatherv(b%ia1,ndx,mpi_integer,p%ac%ia1,nzbr,idisp,& & mpi_integer,icomm,info) - call mpi_allgatherv(b%ia2,ndx,mpi_integer,ac%ia2,nzbr,idisp,& + call mpi_allgatherv(b%ia2,ndx,mpi_integer,p%ac%ia2,nzbr,idisp,& & mpi_integer,icomm,info) if(info /= 0) then info=-1 @@ -229,12 +221,12 @@ subroutine mld_caggrmat_raw_asb(a,desc_a,ac,desc_ac,p,info) goto 9999 end if - ac%m = ntaggr - ac%k = ntaggr - ac%infoa(psb_nnz_) = nzac - ac%fida='COO' - ac%descra='GUN' - call psb_spcnv(ac,info,afmt='coo',dupl=psb_dupl_add_) + p%ac%m = ntaggr + p%ac%k = ntaggr + p%ac%infoa(psb_nnz_) = nzac + p%ac%fida='COO' + p%ac%descra='GUN' + call psb_spcnv(p%ac,info,afmt='coo',dupl=psb_dupl_add_) if(info /= 0) then call psb_errpush(4010,name,a_err='sp_free') goto 9999 @@ -242,9 +234,9 @@ subroutine mld_caggrmat_raw_asb(a,desc_a,ac,desc_ac,p,info) else if (p%iprcparm(mld_coarse_mat_) == mld_distr_mat_) then - call psb_cdall(ictxt,desc_ac,info,nl=naggr) - if (info == 0) call psb_cdasb(desc_ac,info) - if (info == 0) call psb_sp_clone(b,ac,info) + call psb_cdall(ictxt,p%desc_ac,info,nl=naggr) + if (info == 0) call psb_cdasb(p%desc_ac,info) + if (info == 0) call psb_sp_clone(b,p%ac,info) if(info /= 0) then call psb_errpush(4001,name,a_err='Build ac, desc_ac') goto 9999 @@ -263,9 +255,23 @@ subroutine mld_caggrmat_raw_asb(a,desc_a,ac,desc_ac,p,info) deallocate(nzbr,idisp) - call psb_spcnv(ac,info,afmt='csr',dupl=psb_dupl_add_) + call psb_spcnv(p%ac,info,afmt='csr',dupl=psb_dupl_add_) + if(info /= 0) then + call psb_errpush(4010,name,a_err='spcnv') + goto 9999 + end if + + ! + ! Copy the prolongation/restriction matrices into the descriptor map. + ! am2 => PR^T i.e. restriction operator + ! am1 => PR i.e. prolongation operator + ! + p%map_desc = psb_inter_desc(psb_map_aggr_,desc_a,& + & p%desc_ac,am2,am1) + if (info == 0) call psb_sp_free(am1,info) + if (info == 0) call psb_sp_free(am2,info) if(info /= 0) then - call psb_errpush(4010,name,a_err='ipcoo2csr') + call psb_errpush(4010,name,a_err='sp_Free') goto 9999 end if diff --git a/mlprec/mld_caggrmat_smth_asb.F90 b/mlprec/mld_caggrmat_smth_asb.F90 index 32da3daf..8f07a7f1 100644 --- a/mlprec/mld_caggrmat_smth_asb.F90 +++ b/mlprec/mld_caggrmat_smth_asb.F90 @@ -83,18 +83,14 @@ ! the fine-level matrix. ! desc_a - type(psb_desc_type), input. ! The communication descriptor of the fine-level matrix. -! ac - type(psb_cspmat_type), output. -! The sparse matrix structure containing the local part of -! the coarse-level matrix. -! desc_ac - type(psb_desc_type), output. -! The communication descriptor of the coarse-level matrix. -! p - type(mld_cbaseprc_type), input/output. -! The base preconditioner data structure containing the local -! part of the base preconditioner to be built. +! p - type(mld_c_onelev_prec_type), input/output. +! The one-level preconditioner data structure containing the local +! part of the base preconditioner to be built as well as the +! aggregate matrices. ! info - integer, output. ! Error code. ! -subroutine mld_caggrmat_smth_asb(a,desc_a,ac,desc_ac,p,info) +subroutine mld_caggrmat_smth_asb(a,desc_a,p,info) use psb_base_mod use mld_inner_mod, mld_protect_name => mld_caggrmat_smth_asb @@ -109,19 +105,17 @@ subroutine mld_caggrmat_smth_asb(a,desc_a,ac,desc_ac,p,info) ! Arguments type(psb_cspmat_type), intent(in) :: a type(psb_desc_type), intent(in) :: desc_a - type(psb_cspmat_type), intent(out) :: ac - type(psb_desc_type), intent(out) :: desc_ac - type(mld_cbaseprc_type), intent(inout), target :: p + type(mld_c_onelev_prec_type), intent(inout), target :: p integer, intent(out) :: info ! Local variables - type(psb_cspmat_type) :: b - integer, pointer :: nzbr(:), idisp(:) + type(psb_cspmat_type) :: b + integer, allocatable :: nzbr(:), idisp(:) integer :: nrow, nglob, ncol, ntaggr, nzac, ip, ndx,& & naggr, nzl,naggrm1,naggrp1, i, j, k integer ::ictxt,np,me, err_act, icomm character(len=20) :: name - type(psb_cspmat_type), pointer :: am1,am2 + type(psb_cspmat_type) :: am1,am2 type(psb_cspmat_type) :: am3,am4 complex(psb_spk_), allocatable :: adiag(:) logical :: ml_global_nmb @@ -146,9 +140,6 @@ subroutine mld_caggrmat_smth_asb(a,desc_a,ac,desc_ac,p,info) call psb_nullify_sp(b) call psb_nullify_sp(am3) call psb_nullify_sp(am4) - - am2 => p%av(mld_sm_pr_t_) - am1 => p%av(mld_sm_pr_) call psb_nullify_sp(am1) call psb_nullify_sp(am2) @@ -191,7 +182,7 @@ subroutine mld_caggrmat_smth_asb(a,desc_a,ac,desc_ac,p,info) if (info /= 0) then info=4025 call psb_errpush(info,name,i_err=(/nrow,0,0,0,0/),& - & a_err='real(psb_spk_)') + & a_err='complex(psb_spk_)') goto 9999 end if @@ -263,7 +254,6 @@ subroutine mld_caggrmat_smth_asb(a,desc_a,ac,desc_ac,p,info) if (p%iprcparm(mld_aggr_omega_alg_) == mld_eig_est_) then - if (p%iprcparm(mld_aggr_eig_) == mld_max_norm_) then if (p%iprcparm(mld_aggr_kind_) == mld_biz_prol_) then @@ -286,13 +276,13 @@ subroutine mld_caggrmat_smth_asb(a,desc_a,ac,desc_ac,p,info) end do anorm = max(anorm,tmp/dg) enddo + + call psb_amx(ictxt,anorm) else info = 4001 call psb_errpush(info,name,a_err='this section only CSR') goto 9999 endif - - call psb_amx(ictxt,anorm) else anorm = psb_spnrmi(am3,desc_a,info) endif @@ -457,16 +447,16 @@ subroutine mld_caggrmat_smth_asb(a,desc_a,ac,desc_ac,p,info) case(mld_distr_mat_) - call psb_sp_clone(b,ac,info) - nzac = ac%infoa(psb_nnz_) - nzl = ac%infoa(psb_nnz_) - if (info == 0) call psb_cdall(ictxt,desc_ac,info,nl=p%nlaggr(me+1)) - if (info == 0) call psb_cdins(nzl,ac%ia1,ac%ia2,desc_ac,info) - if (info == 0) call psb_cdasb(desc_ac,info) - if (info == 0) call psb_glob_to_loc(ac%ia1(1:nzl),desc_ac,info,iact='I') - if (info == 0) call psb_glob_to_loc(ac%ia2(1:nzl),desc_ac,info,iact='I') + call psb_sp_clone(b,p%ac,info) + nzac = p%ac%infoa(psb_nnz_) + nzl = p%ac%infoa(psb_nnz_) + if (info == 0) call psb_cdall(ictxt,p%desc_ac,info,nl=p%nlaggr(me+1)) + if (info == 0) call psb_cdins(nzl,p%ac%ia1,p%ac%ia2,p%desc_ac,info) + if (info == 0) call psb_cdasb(p%desc_ac,info) + if (info == 0) call psb_glob_to_loc(p%ac%ia1(1:nzl),p%desc_ac,info,iact='I') + if (info == 0) call psb_glob_to_loc(p%ac%ia2(1:nzl),p%desc_ac,info,iact='I') if (info /= 0) then - call psb_errpush(4001,name,a_err='Creating desc_ac and converting ac') + call psb_errpush(4001,name,a_err='Creating p%desc_ac and converting ac') goto 9999 end if if (debug_level >= psb_debug_outer_) & @@ -474,10 +464,10 @@ subroutine mld_caggrmat_smth_asb(a,desc_a,ac,desc_ac,p,info) & 'Assembld aux descr. distr.' - ac%m=desc_ac%matrix_data(psb_n_row_) - ac%k=desc_ac%matrix_data(psb_n_col_) - ac%fida='COO' - ac%descra='GUN' + p%ac%m=psb_cd_get_local_rows(p%desc_ac) + p%ac%k=psb_cd_get_local_cols(p%desc_ac) + p%ac%fida='COO' + p%ac%descra='GUN' call psb_sp_free(b,info) if (info == 0) deallocate(nzbr,idisp,stat=info) @@ -488,25 +478,25 @@ subroutine mld_caggrmat_smth_asb(a,desc_a,ac,desc_ac,p,info) if (np>1) then nzl = psb_sp_get_nnzeros(am1) - call psb_glob_to_loc(am1%ia1(1:nzl),desc_ac,info,'I') + call psb_glob_to_loc(am1%ia1(1:nzl),p%desc_ac,info,'I') if(info /= 0) then call psb_errpush(4010,name,a_err='psb_glob_to_loc') goto 9999 end if endif - am1%k=desc_ac%matrix_data(psb_n_col_) + am1%k=psb_cd_get_local_cols(p%desc_ac) if (np>1) then call psb_spcnv(am2,info,afmt='coo',dupl=psb_dupl_add_) nzl = am2%infoa(psb_nnz_) - if (info == 0) call psb_glob_to_loc(am2%ia1(1:nzl),desc_ac,info,'I') + if (info == 0) call psb_glob_to_loc(am2%ia1(1:nzl),p%desc_ac,info,'I') if (info == 0) call psb_spcnv(am2,info,afmt='csr',dupl=psb_dupl_add_) if(info /= 0) then call psb_errpush(4001,name,a_err='Converting am2 to local') goto 9999 end if end if - am2%m=desc_ac%matrix_data(psb_n_col_) + am2%m=psb_cd_get_local_cols(p%desc_ac) if (debug_level >= psb_debug_outer_) & & write(debug_unit,*) me,' ',trim(name),& @@ -515,13 +505,13 @@ subroutine mld_caggrmat_smth_asb(a,desc_a,ac,desc_ac,p,info) case(mld_repl_mat_) ! ! - call psb_cdall(ictxt,desc_ac,info,mg=ntaggr,repl=.true.) + call psb_cdall(ictxt,p%desc_ac,info,mg=ntaggr,repl=.true.) nzbr(:) = 0 nzbr(me+1) = b%infoa(psb_nnz_) call psb_sum(ictxt,nzbr(1:np)) nzac = sum(nzbr) - if (info == 0) call psb_sp_all(ntaggr,ntaggr,ac,nzac,info) + if (info == 0) call psb_sp_all(ntaggr,ntaggr,p%ac,nzac,info) if (info /= 0) goto 9999 do ip=1,np @@ -529,11 +519,11 @@ subroutine mld_caggrmat_smth_asb(a,desc_a,ac,desc_ac,p,info) enddo ndx = nzbr(me+1) - call mpi_allgatherv(b%aspk,ndx,mpi_complex,ac%aspk,nzbr,idisp,& + call mpi_allgatherv(b%aspk,ndx,mpi_complex,p%ac%aspk,nzbr,idisp,& & mpi_complex,icomm,info) - if (info == 0) call mpi_allgatherv(b%ia1,ndx,mpi_integer,ac%ia1,nzbr,idisp,& + if (info == 0) call mpi_allgatherv(b%ia1,ndx,mpi_integer,p%ac%ia1,nzbr,idisp,& & mpi_integer,icomm,info) - if (info == 0) call mpi_allgatherv(b%ia2,ndx,mpi_integer,ac%ia2,nzbr,idisp,& + if (info == 0) call mpi_allgatherv(b%ia2,ndx,mpi_integer,p%ac%ia2,nzbr,idisp,& & mpi_integer,icomm,info) if (info /= 0) then @@ -541,12 +531,12 @@ subroutine mld_caggrmat_smth_asb(a,desc_a,ac,desc_ac,p,info) goto 9999 end if - ac%m = ntaggr - ac%k = ntaggr - ac%infoa(psb_nnz_) = nzac - ac%fida='COO' - ac%descra='GUN' - call psb_spcnv(ac,info,afmt='coo',dupl=psb_dupl_add_) + p%ac%m = ntaggr + p%ac%k = ntaggr + p%ac%infoa(psb_nnz_) = nzac + p%ac%fida='COO' + p%ac%descra='GUN' + call psb_spcnv(p%ac,info,afmt='coo',dupl=psb_dupl_add_) if(info /= 0) goto 9999 call psb_sp_free(b,info) if(info /= 0) goto 9999 @@ -570,9 +560,9 @@ subroutine mld_caggrmat_smth_asb(a,desc_a,ac,desc_ac,p,info) case(mld_distr_mat_) - call psb_sp_clone(b,ac,info) - if (info == 0) call psb_cdall(ictxt,desc_ac,info,nl=naggr) - if (info == 0) call psb_cdasb(desc_ac,info) + call psb_sp_clone(b,p%ac,info) + if (info == 0) call psb_cdall(ictxt,p%desc_ac,info,nl=naggr) + if (info == 0) call psb_cdasb(p%desc_ac,info) if (info == 0) call psb_sp_free(b,info) if (info /= 0) then call psb_errpush(4010,name,a_err='Build desc_ac, ac') @@ -583,7 +573,7 @@ subroutine mld_caggrmat_smth_asb(a,desc_a,ac,desc_ac,p,info) case(mld_repl_mat_) ! ! - call psb_cdall(ictxt,desc_ac,info,mg=ntaggr,repl=.true.) + call psb_cdall(ictxt,p%desc_ac,info,mg=ntaggr,repl=.true.) if(info /= 0) then call psb_errpush(4010,name,a_err='psb_cdall') goto 9999 @@ -593,7 +583,7 @@ subroutine mld_caggrmat_smth_asb(a,desc_a,ac,desc_ac,p,info) nzbr(me+1) = b%infoa(psb_nnz_) call psb_sum(ictxt,nzbr(1:np)) nzac = sum(nzbr) - call psb_sp_all(ntaggr,ntaggr,ac,nzac,info) + call psb_sp_all(ntaggr,ntaggr,p%ac,nzac,info) if(info /= 0) then call psb_errpush(4010,name,a_err='psb_sp_all') goto 9999 @@ -604,11 +594,11 @@ subroutine mld_caggrmat_smth_asb(a,desc_a,ac,desc_ac,p,info) enddo ndx = nzbr(me+1) - call mpi_allgatherv(b%aspk,ndx,mpi_complex,ac%aspk,nzbr,idisp,& + call mpi_allgatherv(b%aspk,ndx,mpi_complex,p%ac%aspk,nzbr,idisp,& & mpi_complex,icomm,info) - if (info == 0) call mpi_allgatherv(b%ia1,ndx,mpi_integer,ac%ia1,nzbr,idisp,& + if (info == 0) call mpi_allgatherv(b%ia1,ndx,mpi_integer,p%ac%ia1,nzbr,idisp,& & mpi_integer,icomm,info) - if (info == 0) call mpi_allgatherv(b%ia2,ndx,mpi_integer,ac%ia2,nzbr,idisp,& + if (info == 0) call mpi_allgatherv(b%ia2,ndx,mpi_integer,p%ac%ia2,nzbr,idisp,& & mpi_integer,icomm,info) if (info /= 0) then call psb_errpush(4001,name,a_err=' from mpi_allgatherv') @@ -616,12 +606,12 @@ subroutine mld_caggrmat_smth_asb(a,desc_a,ac,desc_ac,p,info) end if - ac%m = ntaggr - ac%k = ntaggr - ac%infoa(psb_nnz_) = nzac - ac%fida='COO' - ac%descra='GUN' - call psb_spcnv(ac,info,afmt='coo',dupl=psb_dupl_add_) + p%ac%m = ntaggr + p%ac%k = ntaggr + p%ac%infoa(psb_nnz_) = nzac + p%ac%fida='COO' + p%ac%descra='GUN' + call psb_spcnv(p%ac,info,afmt='coo',dupl=psb_dupl_add_) if(info /= 0) then call psb_errpush(4010,name,a_err='spcnv') goto 9999 @@ -652,12 +642,27 @@ subroutine mld_caggrmat_smth_asb(a,desc_a,ac,desc_ac,p,info) end select - call psb_spcnv(ac,info,afmt='csr',dupl=psb_dupl_add_) + call psb_spcnv(p%ac,info,afmt='csr',dupl=psb_dupl_add_) if(info /= 0) then call psb_errpush(4010,name,a_err='spcnv') goto 9999 end if + ! + ! Copy the prolongation/restriction matrices into the descriptor map. + ! am2 => PR^T i.e. restriction operator + ! am1 => PR i.e. prolongation operator + ! + p%map_desc = psb_inter_desc(psb_map_aggr_,desc_a,& + & p%desc_ac,am2,am1) + if (info == 0) call psb_sp_free(am1,info) + if (info == 0) call psb_sp_free(am2,info) + if(info /= 0) then + call psb_errpush(4010,name,a_err='sp_Free') + goto 9999 + end if + + if (debug_level >= psb_debug_outer_) & & write(debug_unit,*) me,' ',trim(name),& & 'Done smooth_aggregate ' diff --git a/mlprec/mld_cbaseprec_bld.f90 b/mlprec/mld_cbaseprec_bld.f90 index a7d46ac4..fa69616a 100644 --- a/mlprec/mld_cbaseprec_bld.f90 +++ b/mlprec/mld_cbaseprec_bld.f90 @@ -197,8 +197,6 @@ subroutine mld_cbaseprc_bld(a,desc_a,p,info,upd) end select - p%base_a => a - p%base_desc => desc_a p%iprcparm(mld_prec_status_) = mld_prec_built_ if (debug_level >= psb_debug_outer_) & & write(debug_unit,*) me,' ',trim(name),': Done' diff --git a/mlprec/mld_cmlprec_aply.f90 b/mlprec/mld_cmlprec_aply.f90 index 291b4bf7..57709b06 100644 --- a/mlprec/mld_cmlprec_aply.f90 +++ b/mlprec/mld_cmlprec_aply.f90 @@ -46,7 +46,7 @@ ! Y = beta*Y + alpha*op(M^(-1))*X, ! where ! - M is a multilevel domain decomposition (Schwarz) preconditioner associated -! to a certain matrix A and stored in the array baseprecv, +! to a certain matrix A and stored in the array precv, ! - op(M^(-1)) is M^(-1) or its transpose, according to the value of trans, ! - X and Y are vectors, ! - alpha and beta are scalars. @@ -55,9 +55,9 @@ ! level where we might have a replicated index space) and each process takes care ! of one submatrix. ! -! The multilevel preconditioner M is regarded as an array of 'base preconditioners', +! The multilevel preconditioner M is regarded as an array of 'one-level preconditioners', ! each representing the part of the preconditioner associated to a certain level. -! For each level ilev, the base preconditioner K(ilev) is stored in baseprecv(ilev) +! For each level ilev, the preconditioner K(ilev) is stored in precv(ilev) ! and is associated to a matrix A(ilev), obtained by 'tranferring' the original ! matrix A (i.e. the matrix to be preconditioned) to the level ilev, through smoothed ! aggregation. @@ -78,66 +78,43 @@ ! Arguments: ! alpha - complex(psb_spk_), input. ! The scalar alpha. -! baseprecv - type(mld_cbaseprc_type), dimension(:), input. -! The array of base preconditioner data structures containing the +! precv - type(mld_c_onelev_prec_type), dimension(:), input. +! The array of one-level preconditioner data structures containing the ! local parts of the preconditioners to be applied at each level. -! Note that nlev = size(baseprecv) = number of levels. -! baseprecv(ilev)%av - type(psb_cspmat_type), dimension(:), allocatable(:). -! The sparse matrices needed to apply the preconditioner -! at level ilev. -! baseprecv(ilev)%av(mld_l_pr_) - The L factor of the ILU factorization of the -! local diagonal block of A(ilev). -! baseprecv(ilev)%av(mld_u_pr_) - The U factor of the ILU factorization of the -! local diagonal block of A(ilev), except its -! diagonal entries (stored in baseprecv(ilev)%d). -! baseprecv(ilev)%av(mld_ap_nd_) - The entries of the local part of A(ilev) -! outside the diagonal block, for block-Jacobi -! sweeps. -! baseprecv(ilev)%av(mld_ac_) - The local part of the matrix A(ilev). -! baseprecv(ilev)%av(mld_sm_pr_) - The smoothed prolongator. -! It maps vectors (ilev) ---> (ilev-1). -! baseprecv(ilev)%av(mld_sm_pr_t_) - The smoothed prolongator transpose. -! It maps vectors (ilev-1) ---> (ilev). -! baseprecv(ilev)%d - complex(psb_spk_), dimension(:), allocatable. -! The diagonal entries of the U factor in the ILU -! factorization of A(ilev). -! baseprecv(ilev)%desc_data - type(psb_desc_type). -! The communication descriptor associated to the base -! preconditioner, i.e. to the sparse matrices needed -! to apply the base preconditioner at the current level. -! baseprecv(ilev)%desc_ac - type(psb_desc_type). -! The communication descriptor associated to the sparse -! matrix A(ilev), stored in baseprecv(ilev)%av(mld_ac_). -! baseprecv(ilev)%iprcparm - integer, dimension(:), allocatable. -! The integer parameters defining the base -! preconditioner K(ilev). -! baseprecv(ilev)%rprcparm - complex(psb_spk_), dimension(:), allocatable. -! The real parameters defining the base preconditioner -! K(ilev). -! baseprecv(ilev)%perm - integer, dimension(:), allocatable. -! The row and column permutations applied to the local -! part of A(ilev) (defined only if baseprecv(ilev)% -! iprcparm(mld_sub_ren_)>0). -! baseprecv(ilev)%invperm - integer, dimension(:), allocatable. -! The inverse of the permutation stored in -! baseprecv(ilev)%perm. -! baseprecv(ilev)%mlia - integer, dimension(:), allocatable. -! The aggregation map (ilev-1) --> (ilev). -! In case of non-smoothed aggregation, it is used -! instead of mld_sm_pr_. -! baseprecv(ilev)%nlaggr - integer, dimension(:), allocatable. -! The number of aggregates (rows of A(ilev)) on the -! various processes. -! baseprecv(ilev)%base_a - type(psb_cspmat_type), pointer. -! Pointer (really a pointer!) to the base matrix of -! the current level, i.e. the local part of A(ilev); -! so we have a unified treatment of residuals. We -! need this to avoid passing explicitly the matrix -! A(ilev) to the routine which applies the -! preconditioner. -! baseprecv(ilev)%base_desc - type(psb_desc_type), pointer. -! Pointer to the communication descriptor associated -! to the sparse matrix pointed by base_a. +! Note that nlev = size(precv) = number of levels. +! precv(ilev)%prec - type(psb_cbaseprc_type) +! The "base" preconditioner for the current level +! precv(ilev)%ac - type(psb_cspmat_type) +! The local part of the matrix A(ilev). +! precv(ilev)%desc_ac - type(psb_desc_type). +! The communication descriptor associated to the sparse +! matrix A(ilev) +! precv(ilev)%map_desc - type(psb_inter_desc_type) +! Stores the linear operators mapping between levels +! (ilev-1) and (ilev). These are the restriction and +! prolongation operators described in the sequel. +! precv(ilev)%iprcparm - integer, dimension(:), allocatable. +! The integer parameters defining the multilevel +! strategy +! precv(ilev)%rprcparm - real(psb_spk_), dimension(:), allocatable. +! The real parameters defining the multilevel strategy +! precv(ilev)%mlia - integer, dimension(:), allocatable. +! The aggregation map (ilev-1) --> (ilev). +! In case of non-smoothed aggregation, it is used +! instead of mld_sm_pr_. +! precv(ilev)%nlaggr - integer, dimension(:), allocatable. +! The number of aggregates (rows of A(ilev)) on the +! various processes. +! precv(ilev)%base_a - type(psb_cspmat_type), pointer. +! Pointer (really a pointer!) to the base matrix of +! the current level, i.e. the local part of A(ilev); +! so we have a unified treatment of residuals. We +! need this to avoid passing explicitly the matrix +! A(ilev) to the routine which applies the +! preconditioner. +! precv(ilev)%base_desc - type(psb_desc_type), pointer. +! Pointer to the communication descriptor associated +! to the sparse matrix pointed by base_a. ! ! x - complex(psb_spk_), dimension(:), input. ! The local part of the vector X. @@ -159,10 +136,10 @@ ! Note that when the LU factorization of the matrix A(ilev) is computed instead of ! the ILU one, by using UMFPACK or SuperLU, the corresponding L and U factors ! are stored in data structures provided by UMFPACK or SuperLU and pointed by -! baseprecv(ilev)%iprcparm(mld_umf_ptr) or baseprecv(ilev)%iprcparm(mld_slu_ptr), +! precv(ilev)%prec%iprcparm(mld_umf_ptr) or precv(ilev)%prec%iprcparm(mld_slu_ptr), ! respectively. ! -subroutine mld_cmlprec_aply(alpha,baseprecv,x,beta,y,desc_data,trans,work,info) +subroutine mld_cmlprec_aply(alpha,precv,x,beta,y,desc_data,trans,work,info) use psb_base_mod use mld_inner_mod, mld_protect_name => mld_cmlprec_aply @@ -171,7 +148,7 @@ subroutine mld_cmlprec_aply(alpha,baseprecv,x,beta,y,desc_data,trans,work,info) ! Arguments type(psb_desc_type),intent(in) :: desc_data - type(mld_cbaseprc_type), intent(in) :: baseprecv(:) + type(mld_c_onelev_prec_type), intent(in) :: precv(:) complex(psb_spk_),intent(in) :: alpha,beta complex(psb_spk_),intent(in) :: x(:) complex(psb_spk_),intent(inout) :: y(:) @@ -196,11 +173,11 @@ subroutine mld_cmlprec_aply(alpha,baseprecv,x,beta,y,desc_data,trans,work,info) if (debug_level >= psb_debug_inner_) & & write(debug_unit,*) me,' ',trim(name),& - & ' Entry ', size(baseprecv) + & ' Entry ', size(precv) trans_ = psb_toupper(trans) - select case(baseprecv(2)%iprcparm(mld_ml_type_)) + select case(precv(2)%iprcparm(mld_ml_type_)) case(mld_no_ml_) ! @@ -214,7 +191,7 @@ subroutine mld_cmlprec_aply(alpha,baseprecv,x,beta,y,desc_data,trans,work,info) ! Additive multilevel ! - call add_ml_aply(alpha,baseprecv,x,beta,y,desc_data,trans_,work,info) + call add_ml_aply(alpha,precv,x,beta,y,desc_data,trans_,work,info) case(mld_mult_ml_) ! @@ -225,15 +202,15 @@ subroutine mld_cmlprec_aply(alpha,baseprecv,x,beta,y,desc_data,trans,work,info) ! Note that the transpose switches pre <-> post. ! - select case(baseprecv(2)%iprcparm(mld_smoother_pos_)) + select case(precv(2)%iprcparm(mld_smoother_pos_)) case(mld_post_smooth_) select case (trans_) case('N') - call mlt_post_ml_aply(alpha,baseprecv,x,beta,y,desc_data,trans_,work,info) + call mlt_post_ml_aply(alpha,precv,x,beta,y,desc_data,trans_,work,info) case('T','C') - call mlt_pre_ml_aply(alpha,baseprecv,x,beta,y,desc_data,trans_,work,info) + call mlt_pre_ml_aply(alpha,precv,x,beta,y,desc_data,trans_,work,info) case default info = 4001 call psb_errpush(info,name,a_err='invalid trans') @@ -244,9 +221,9 @@ subroutine mld_cmlprec_aply(alpha,baseprecv,x,beta,y,desc_data,trans,work,info) select case (trans_) case('N') - call mlt_pre_ml_aply(alpha,baseprecv,x,beta,y,desc_data,trans_,work,info) + call mlt_pre_ml_aply(alpha,precv,x,beta,y,desc_data,trans_,work,info) case('T','C') - call mlt_post_ml_aply(alpha,baseprecv,x,beta,y,desc_data,trans_,work,info) + call mlt_post_ml_aply(alpha,precv,x,beta,y,desc_data,trans_,work,info) case default info = 4001 call psb_errpush(info,name,a_err='invalid trans') @@ -255,12 +232,12 @@ subroutine mld_cmlprec_aply(alpha,baseprecv,x,beta,y,desc_data,trans,work,info) case(mld_twoside_smooth_) - call mlt_twoside_ml_aply(alpha,baseprecv,x,beta,y,desc_data,trans_,work,info) + call mlt_twoside_ml_aply(alpha,precv,x,beta,y,desc_data,trans_,work,info) case default info = 4013 call psb_errpush(info,name,a_err='invalid smooth_pos',& - & i_Err=(/baseprecv(2)%iprcparm(mld_smoother_pos_),0,0,0,0/)) + & i_Err=(/precv(2)%iprcparm(mld_smoother_pos_),0,0,0,0/)) goto 9999 end select @@ -268,7 +245,7 @@ subroutine mld_cmlprec_aply(alpha,baseprecv,x,beta,y,desc_data,trans,work,info) case default info = 4013 call psb_errpush(info,name,a_err='invalid mltype',& - & i_Err=(/baseprecv(2)%iprcparm(mld_ml_type_),0,0,0,0/)) + & i_Err=(/precv(2)%iprcparm(mld_ml_type_),0,0,0,0/)) goto 9999 end select @@ -295,7 +272,7 @@ contains ! Y = beta*Y + alpha*op(M^(-1))*X, ! where ! - M is an additive multilevel domain decomposition (Schwarz) preconditioner - ! associated to a certain matrix A and stored in the array baseprecv, + ! associated to a certain matrix A and stored in the array precv, ! - op(M^(-1)) is M^(-1) or its (conjugate) transpose, according to ! the value of trans, ! - X and Y are vectors, @@ -308,9 +285,9 @@ contains ! level where we might have a replicated index space) and each process takes care ! of one submatrix. ! - ! The multilevel preconditioner M is regarded as an array of 'base preconditioners', + ! The multilevel preconditioner M is regarded as an array of 'one-level preconditioners', ! each representing the part of the preconditioner associated to a certain level. - ! For each level ilev, the base preconditioner K(ilev) is stored in baseprecv(ilev) + ! For each level ilev, the base preconditioner K(ilev) is stored in precv(ilev) ! and is associated to a matrix A(ilev), obtained by 'tranferring' the original ! matrix A (i.e. the matrix to be preconditioned) to the level ilev, through smoothed ! aggregation. @@ -324,7 +301,7 @@ contains ! Domain decomposition: parallel multilevel methods for elliptic partial ! differential equations, Cambridge University Press, 1996. ! - ! For a description of the arguments see mld_dmlprec_aply. + ! For a description of the arguments see mld_cmlprec_aply. ! ! A sketch of the algorithm implemented in this routine is provided below ! (AV(ilev; sm_pr_) denotes the smoothed prolongator from level ilev to @@ -358,13 +335,13 @@ contains ! ! 4. Yext = beta*Yext + alpha*Y(1) ! - subroutine add_ml_aply(alpha,baseprecv,x,beta,y,desc_data,trans,work,info) + subroutine add_ml_aply(alpha,precv,x,beta,y,desc_data,trans,work,info) implicit none ! Arguments type(psb_desc_type),intent(in) :: desc_data - type(mld_cbaseprc_type), intent(in) :: baseprecv(:) + type(mld_c_onelev_prec_type), intent(in) :: precv(:) complex(psb_spk_),intent(in) :: alpha,beta complex(psb_spk_),intent(in) :: x(:) complex(psb_spk_),intent(inout) :: y(:) @@ -373,10 +350,9 @@ contains integer, intent(out) :: info ! Local variables - integer :: n_row,n_col integer :: ictxt,np,me,i, nr2l,nc2l,err_act integer :: debug_level, debug_unit - integer :: ismth, nlev, ilev, icm + integer :: nlev, ilev character(len=20) :: name type psb_mlprec_wrk_type @@ -395,9 +371,9 @@ contains if (debug_level >= psb_debug_inner_) & & write(debug_unit,*) me,' ',trim(name),& - & ' Entry ', size(baseprecv) + & ' Entry ', size(precv) - nlev = size(baseprecv) + nlev = size(precv) allocate(mlprec_wrk(nlev),stat=info) if (info /= 0) then call psb_errpush(4010,name,a_err='Allocate') @@ -420,9 +396,8 @@ contains mlprec_wrk(1)%x2l(:) = x(:) mlprec_wrk(1)%y2l(:) = czero - - call mld_baseprec_aply(alpha,baseprecv(1),x,beta,y,& - & baseprecv(1)%base_desc,trans,work,info) + call mld_baseprec_aply(alpha,precv(1)%prec,x,beta,y,& + & precv(1)%base_desc,trans,work,info) if (info /=0) then call psb_errpush(4010,name,a_err='baseprec_aply') goto 9999 @@ -433,40 +408,33 @@ contains ! For each level except the finest one ... ! do ilev = 2, nlev - n_row = psb_cd_get_local_rows(baseprecv(ilev-1)%base_desc) - n_col = psb_cd_get_local_cols(baseprecv(ilev-1)%base_desc) - nc2l = psb_cd_get_local_cols(baseprecv(ilev)%base_desc) - nr2l = psb_cd_get_local_rows(baseprecv(ilev)%base_desc) + nc2l = psb_cd_get_local_cols(precv(ilev)%base_desc) + nr2l = psb_cd_get_local_rows(precv(ilev)%base_desc) allocate(mlprec_wrk(ilev)%x2l(nc2l),mlprec_wrk(ilev)%y2l(nc2l),& & stat=info) if (info /= 0) then info=4025 - call psb_errpush(info,name,i_err=(/2*(nc2l+max(n_row,n_col)),0,0,0,0/),& + call psb_errpush(info,name,i_err=(/2*nc2l,0,0,0,0/),& & a_err='complex(psb_spk_)') goto 9999 end if - - ismth = baseprecv(ilev)%iprcparm(mld_aggr_kind_) - icm = baseprecv(ilev)%iprcparm(mld_coarse_mat_) ! Apply prolongator transpose, i.e. restriction call psb_forward_map(cone,mlprec_wrk(ilev-1)%x2l,& & czero,mlprec_wrk(ilev)%x2l,& - & baseprecv(ilev)%map_desc,info,work=work) - + & precv(ilev)%map_desc,info,work=work) if (info /=0) then call psb_errpush(4001,name,a_err='Error during restriction') goto 9999 end if - ! ! Apply the base preconditioner ! - call mld_baseprec_aply(cone,baseprecv(ilev),& + call mld_baseprec_aply(cone,precv(ilev)%prec,& & mlprec_wrk(ilev)%x2l,czero,mlprec_wrk(ilev)%y2l,& - & baseprecv(ilev)%base_desc,trans,work,info) + & precv(ilev)%base_desc,trans,work,info) enddo @@ -477,19 +445,15 @@ contains ! do ilev =nlev,2,-1 - n_row = psb_cd_get_local_rows(baseprecv(ilev-1)%base_desc) - n_col = psb_cd_get_local_cols(baseprecv(ilev-1)%base_desc) - nc2l = psb_cd_get_local_cols(baseprecv(ilev)%base_desc) - nr2l = psb_cd_get_local_rows(baseprecv(ilev)%base_desc) - ismth = baseprecv(ilev)%iprcparm(mld_aggr_kind_) - icm = baseprecv(ilev)%iprcparm(mld_coarse_mat_) + nc2l = psb_cd_get_local_cols(precv(ilev)%base_desc) + nr2l = psb_cd_get_local_rows(precv(ilev)%base_desc) ! ! Apply prolongator ! call psb_backward_map(cone,mlprec_wrk(ilev)%y2l,& & cone,mlprec_wrk(ilev-1)%y2l,& - & baseprecv(ilev)%map_desc,info,work=work) + & precv(ilev)%map_desc,info,work=work) if (info /=0) then call psb_errpush(4001,name,a_err='Error during prolongation') @@ -502,7 +466,7 @@ contains ! ! Compute the output vector Y ! - call psb_geaxpby(alpha,mlprec_wrk(1)%y2l,cone,y,baseprecv(1)%base_desc,info) + call psb_geaxpby(alpha,mlprec_wrk(1)%y2l,cone,y,precv(1)%base_desc,info) if (info /= 0) then call psb_errpush(4001,name,a_err='Error on final update') goto 9999 @@ -529,14 +493,14 @@ contains ! ! Subroutine: mlt_pre_ml_aply ! Version: complex - ! Note: internal subroutine of mld_dmlprec_aply. + ! Note: internal subroutine of mld_cmlprec_aply. ! ! This routine computes ! ! Y = beta*Y + alpha*op(M^(-1))*X, ! where ! - M is a hybrid multilevel domain decomposition (Schwarz) preconditioner - ! associated to a certain matrix A and stored in the array baseprecv, + ! associated to a certain matrix A and stored in the array precv, ! - op(M^(-1)) is M^(-1) or its (conjugate) transpose, according to ! the value of trans, ! - X and Y are vectors, @@ -549,9 +513,9 @@ contains ! level where we might have a replicated index space) and each process takes care ! of one submatrix. ! - ! The multilevel preconditioner M is regarded as an array of 'base preconditioners', + ! The multilevel preconditioner M is regarded as an array of 'one-level preconditioners', ! each representing the part of the preconditioner associated to a certain level. - ! For each level ilev, the base preconditioner K(ilev) is stored in baseprecv(ilev) + ! For each level ilev, the base preconditioner K(ilev) is stored in precv(ilev) ! and is associated to a matrix A(ilev), obtained by 'tranferring' the original ! matrix A (i.e. the matrix to be preconditioned) to the level ilev, through smoothed ! aggregation. @@ -565,7 +529,7 @@ contains ! Domain decomposition: parallel multilevel methods for elliptic partial ! differential equations, Cambridge University Press, 1996. ! - ! For a description of the arguments see mld_dmlprec_aply. + ! For a description of the arguments see mld_cmlprec_aply. ! ! A sketch of the algorithm implemented in this routine is provided below ! (AV(ilev; sm_pr_) denotes the smoothed prolongator from level ilev to @@ -607,13 +571,13 @@ contains ! 6. Yext = beta*Yext + alpha*Y(1) ! ! - subroutine mlt_pre_ml_aply(alpha,baseprecv,x,beta,y,desc_data,trans,work,info) + subroutine mlt_pre_ml_aply(alpha,precv,x,beta,y,desc_data,trans,work,info) implicit none ! Arguments type(psb_desc_type),intent(in) :: desc_data - type(mld_cbaseprc_type), intent(in) :: baseprecv(:) + type(mld_c_onelev_prec_type), intent(in) :: precv(:) complex(psb_spk_),intent(in) :: alpha,beta complex(psb_spk_),intent(in) :: x(:) complex(psb_spk_),intent(inout) :: y(:) @@ -622,10 +586,9 @@ contains integer, intent(out) :: info ! Local variables - integer :: n_row,n_col integer :: ictxt,np,me,i, nr2l,nc2l,err_act integer :: debug_level, debug_unit - integer :: ismth, nlev, ilev, icm + integer :: nlev, ilev character(len=20) :: name type psb_mlprec_wrk_type @@ -644,9 +607,9 @@ contains if (debug_level >= psb_debug_inner_) & & write(debug_unit,*) me,' ',trim(name),& - & ' Entry ', size(baseprecv) + & ' Entry ', size(precv) - nlev = size(baseprecv) + nlev = size(precv) allocate(mlprec_wrk(nlev),stat=info) if (info /= 0) then call psb_errpush(4010,name,a_err='Allocate') @@ -658,8 +621,7 @@ contains ! ! Copy the input vector X ! - n_col = psb_cd_get_local_cols(desc_data) - nc2l = psb_cd_get_local_cols(baseprecv(1)%base_desc) + nc2l = psb_cd_get_local_cols(precv(1)%base_desc) allocate(mlprec_wrk(1)%x2l(nc2l),mlprec_wrk(1)%y2l(nc2l), & & mlprec_wrk(1)%tx(nc2l), stat=info) @@ -676,8 +638,8 @@ contains ! ! Apply the base preconditioner at the finest level ! - call mld_baseprec_aply(cone,baseprecv(1),mlprec_wrk(1)%x2l,& - & czero,mlprec_wrk(1)%y2l,baseprecv(1)%base_desc,& + call mld_baseprec_aply(cone,precv(1)%prec,mlprec_wrk(1)%x2l,& + & czero,mlprec_wrk(1)%y2l,precv(1)%base_desc,& & trans,work,info) if (info /=0) then call psb_errpush(4010,name,a_err=' baseprec_aply') @@ -691,8 +653,8 @@ contains ! mlprec_wrk(1)%tx = mlprec_wrk(1)%x2l - call psb_spmm(-cone,baseprecv(1)%base_a,mlprec_wrk(1)%y2l,& - & cone,mlprec_wrk(1)%tx,baseprecv(1)%base_desc,info,& + call psb_spmm(-cone,precv(1)%base_a,mlprec_wrk(1)%y2l,& + & cone,mlprec_wrk(1)%tx,precv(1)%base_desc,info,& & work=work,trans=trans) if (info /=0) then call psb_errpush(4001,name,a_err=' fine level residual') @@ -706,12 +668,8 @@ contains ! do ilev = 2, nlev - n_row = psb_cd_get_local_rows(baseprecv(ilev-1)%base_desc) - n_col = psb_cd_get_local_cols(baseprecv(ilev-1)%base_desc) - nc2l = psb_cd_get_local_cols(baseprecv(ilev)%base_desc) - nr2l = psb_cd_get_local_rows(baseprecv(ilev)%base_desc) - ismth = baseprecv(ilev)%iprcparm(mld_aggr_kind_) - icm = baseprecv(ilev)%iprcparm(mld_coarse_mat_) + nc2l = psb_cd_get_local_cols(precv(ilev)%base_desc) + nr2l = psb_cd_get_local_rows(precv(ilev)%base_desc) allocate(mlprec_wrk(ilev)%tx(nc2l),mlprec_wrk(ilev)%y2l(nc2l),& & mlprec_wrk(ilev)%x2l(nc2l), stat=info) @@ -725,28 +683,27 @@ contains ! Apply prolongator transpose, i.e. restriction call psb_forward_map(cone,mlprec_wrk(ilev-1)%tx,& & czero,mlprec_wrk(ilev)%x2l,& - & baseprecv(ilev)%map_desc,info,work=work) + & precv(ilev)%map_desc,info,work=work) if (info /=0) then call psb_errpush(4001,name,a_err='Error during restriction') goto 9999 end if - ! ! Apply the base preconditioner ! - call mld_baseprec_aply(cone,baseprecv(ilev),mlprec_wrk(ilev)%x2l,& - & czero,mlprec_wrk(ilev)%y2l,baseprecv(ilev)%base_desc,trans,work,info) + call mld_baseprec_aply(cone,precv(ilev)%prec,mlprec_wrk(ilev)%x2l,& + & czero,mlprec_wrk(ilev)%y2l,precv(ilev)%base_desc,trans,work,info) ! ! Compute the residual (at all levels but the coarsest one) ! if (ilev < nlev) then mlprec_wrk(ilev)%tx = mlprec_wrk(ilev)%x2l - if (info == 0) call psb_spmm(-cone,baseprecv(ilev)%base_a,& + if (info == 0) call psb_spmm(-cone,precv(ilev)%base_a,& & mlprec_wrk(ilev)%y2l,cone,mlprec_wrk(ilev)%tx,& - & baseprecv(ilev)%base_desc,info,work=work,trans=trans) + & precv(ilev)%base_desc,info,work=work,trans=trans) endif if (info /=0) then call psb_errpush(4001,name,a_err='Error on up sweep residual') @@ -760,16 +717,12 @@ contains ! For each level but the coarsest one ... ! do ilev = nlev-1, 1, -1 - - ismth = baseprecv(ilev+1)%iprcparm(mld_aggr_kind_) - n_row = psb_cd_get_local_rows(baseprecv(ilev)%base_desc) - ! ! Apply prolongator ! call psb_backward_map(cone,mlprec_wrk(ilev+1)%y2l,& & cone,mlprec_wrk(ilev)%y2l,& - & baseprecv(ilev+1)%map_desc,info,work=work) + & precv(ilev+1)%map_desc,info,work=work) if (info /=0) then call psb_errpush(4001,name,a_err='Error during prolongation') @@ -783,7 +736,7 @@ contains ! Compute the output vector Y ! call psb_geaxpby(alpha,mlprec_wrk(1)%y2l,beta,y,& - & baseprecv(1)%base_desc,info) + & precv(1)%base_desc,info) if (info /=0) then call psb_errpush(4001,name,a_err='Error on final update') goto 9999 @@ -809,14 +762,14 @@ contains ! ! Subroutine: mlt_post_ml_aply ! Version: complex - ! Note: internal subroutine of mld_dmlprec_aply. + ! Note: internal subroutine of mld_cmlprec_aply. ! ! This routine computes ! ! Y = beta*Y + alpha*op(M^(-1))*X, ! where ! - M is a hybrid multilevel domain decomposition (Schwarz) preconditioner - ! associated to a certain matrix A and stored in the array baseprecv, + ! associated to a certain matrix A and stored in the array precv, ! - op(M^(-1)) is M^(-1) or its (conjugate) transpose, according to ! the value of trans, ! - X and Y are vectors, @@ -829,9 +782,9 @@ contains ! level where we might have a replicated index space) and each process takes care ! of one submatrix. ! - ! The multilevel preconditioner M is regarded as an array of 'base preconditioners', + ! The multilevel preconditioner M is regarded as an array of 'one-level preconditioners', ! each representing the part of the preconditioner associated to a certain level. - ! For each level ilev, the base preconditioner K(ilev) is stored in baseprecv(ilev) + ! For each level ilev, the base preconditioner K(ilev) is stored in precv(ilev) ! and is associated to a matrix A(ilev), obtained by 'tranferring' the original ! matrix A (i.e. the matrix to be preconditioned) to the level ilev, through smoothed ! aggregation. @@ -844,7 +797,7 @@ contains ! Domain decomposition: parallel multilevel methods for elliptic partial ! differential equations, Cambridge University Press, 1996. ! - ! For a description of the arguments see mld_dmlprec_aply. + ! For a description of the arguments see mld_cmlprec_aply. ! ! A sketch of the algorithm implemented in this routine is provided below. ! (AV(ilev; sm_pr_) denotes the smoothed prolongator from level ilev to @@ -878,13 +831,13 @@ contains ! 5. Yext = beta*Yext + alpha*Y(1) ! ! - subroutine mlt_post_ml_aply(alpha,baseprecv,x,beta,y,desc_data,trans,work,info) + subroutine mlt_post_ml_aply(alpha,precv,x,beta,y,desc_data,trans,work,info) implicit none ! Arguments type(psb_desc_type),intent(in) :: desc_data - type(mld_cbaseprc_type), intent(in) :: baseprecv(:) + type(mld_c_onelev_prec_type), intent(in) :: precv(:) complex(psb_spk_),intent(in) :: alpha,beta complex(psb_spk_),intent(in) :: x(:) complex(psb_spk_),intent(inout) :: y(:) @@ -893,10 +846,9 @@ contains integer, intent(out) :: info ! Local variables - integer :: n_row,n_col integer :: ictxt,np,me,i, nr2l,nc2l,err_act integer :: debug_level, debug_unit - integer :: ismth, nlev, ilev, icm + integer :: nlev, ilev character(len=20) :: name type psb_mlprec_wrk_type @@ -915,9 +867,9 @@ contains if (debug_level >= psb_debug_inner_) & & write(debug_unit,*) me,' ',trim(name),& - & ' Entry ', size(baseprecv) + & ' Entry ', size(precv) - nlev = size(baseprecv) + nlev = size(precv) allocate(mlprec_wrk(nlev),stat=info) if (info /= 0) then call psb_errpush(4010,name,a_err='Allocate') @@ -933,16 +885,21 @@ contains & write(debug_unit,*) me,' ',trim(name),& & ' desc_data status',allocated(desc_data%matrix_data) - n_col = psb_cd_get_local_cols(desc_data) - nc2l = psb_cd_get_local_cols(baseprecv(1)%base_desc) + nc2l = psb_cd_get_local_cols(precv(1)%base_desc) allocate(mlprec_wrk(1)%x2l(nc2l),mlprec_wrk(1)%y2l(nc2l), & & mlprec_wrk(1)%tx(nc2l), stat=info) + if (info /= 0) then + info=4025 + call psb_errpush(info,name,i_err=(/4*nc2l,0,0,0,0/),& + & a_err='complex(psb_spk_)') + goto 9999 + end if call psb_geaxpby(cone,x,czero,mlprec_wrk(1)%tx,& - & baseprecv(1)%base_desc,info) + & precv(1)%base_desc,info) call psb_geaxpby(cone,x,czero,mlprec_wrk(1)%x2l,& - & baseprecv(1)%base_desc,info) + & precv(1)%base_desc,info) ! ! STEP 2 @@ -951,18 +908,13 @@ contains ! do ilev=2, nlev - n_row = psb_cd_get_local_rows(baseprecv(ilev-1)%base_desc) - n_col = psb_cd_get_local_cols(baseprecv(ilev-1)%base_desc) - nc2l = psb_cd_get_local_cols(baseprecv(ilev)%base_desc) - nr2l = psb_cd_get_local_rows(baseprecv(ilev)%base_desc) - ismth = baseprecv(ilev)%iprcparm(mld_aggr_kind_) - icm = baseprecv(ilev)%iprcparm(mld_coarse_mat_) + nc2l = psb_cd_get_local_cols(precv(ilev)%base_desc) + nr2l = psb_cd_get_local_rows(precv(ilev)%base_desc) if (debug_level >= psb_debug_inner_) & & write(debug_unit,*) me,' ',trim(name), & & ' starting up sweep ',& - & ilev,allocated(baseprecv(ilev)%iprcparm),n_row,n_col,& - & nc2l, nr2l,ismth + & ilev,allocated(precv(ilev)%iprcparm),nc2l, nr2l allocate(mlprec_wrk(ilev)%tx(nc2l),mlprec_wrk(ilev)%y2l(nc2l),& & mlprec_wrk(ilev)%x2l(nc2l), stat=info) @@ -977,19 +929,18 @@ contains ! Apply prolongator transpose, i.e. restriction call psb_forward_map(cone,mlprec_wrk(ilev-1)%x2l,& & czero,mlprec_wrk(ilev)%x2l,& - & baseprecv(ilev)%map_desc,info,work=work) + & precv(ilev)%map_desc,info,work=work) if (info /=0) then call psb_errpush(4001,name,a_err='Error during restriction') goto 9999 end if - ! ! update x2l ! call psb_geaxpby(cone,mlprec_wrk(ilev)%x2l,czero,mlprec_wrk(ilev)%tx,& - & baseprecv(ilev)%base_desc,info) + & precv(ilev)%base_desc,info) if (info /= 0) then call psb_errpush(4001,name,a_err='Error in update') goto 9999 @@ -1006,8 +957,8 @@ contains ! ! Apply the base preconditioner at the coarsest level ! - call mld_baseprec_aply(cone,baseprecv(nlev),mlprec_wrk(nlev)%x2l, & - & czero, mlprec_wrk(nlev)%y2l,baseprecv(nlev)%base_desc,trans,work,info) + call mld_baseprec_aply(cone,precv(nlev)%prec,mlprec_wrk(nlev)%x2l, & + & czero, mlprec_wrk(nlev)%y2l,precv(nlev)%base_desc,trans,work,info) if (info /=0) then call psb_errpush(4010,name,a_err='baseprec_aply') goto 9999 @@ -1027,15 +978,12 @@ contains & write(debug_unit,*) me,' ',trim(name),& & ' starting down sweep',ilev - ismth = baseprecv(ilev+1)%iprcparm(mld_aggr_kind_) - n_row = psb_cd_get_local_rows(baseprecv(ilev)%base_desc) - ! ! Apply prolongator ! call psb_backward_map(cone,mlprec_wrk(ilev+1)%y2l,& & czero,mlprec_wrk(ilev)%y2l,& - & baseprecv(ilev+1)%map_desc,info,work=work) + & precv(ilev+1)%map_desc,info,work=work) if (info /=0) then call psb_errpush(4001,name,a_err='Error during prolongation') @@ -1045,15 +993,16 @@ contains ! ! Compute the residual ! - call psb_spmm(-cone,baseprecv(ilev)%base_a,mlprec_wrk(ilev)%y2l,& - & cone,mlprec_wrk(ilev)%tx,baseprecv(ilev)%base_desc,info,& + call psb_spmm(-cone,precv(ilev)%base_a,mlprec_wrk(ilev)%y2l,& + & cone,mlprec_wrk(ilev)%tx,precv(ilev)%base_desc,info,& & work=work,trans=trans) ! ! Apply the base preconditioner ! - if (info == 0) call mld_baseprec_aply(cone,baseprecv(ilev),mlprec_wrk(ilev)%tx,& - & cone,mlprec_wrk(ilev)%y2l,baseprecv(ilev)%base_desc,trans,work,info) + if (info == 0) call mld_baseprec_aply(cone,precv(ilev)%prec,& + & mlprec_wrk(ilev)%tx,cone,mlprec_wrk(ilev)%y2l,precv(ilev)%base_desc,& + & trans,work,info) if (info /=0) then call psb_errpush(4001,name,a_err=' spmm/baseprec_aply') goto 9999 @@ -1069,7 +1018,7 @@ contains ! ! Compute the output vector Y ! - call psb_geaxpby(alpha,mlprec_wrk(1)%y2l,beta,y,baseprecv(1)%base_desc,info) + call psb_geaxpby(alpha,mlprec_wrk(1)%y2l,beta,y,precv(1)%base_desc,info) if (info /=0) then call psb_errpush(4001,name,a_err=' Final update') @@ -1098,7 +1047,7 @@ contains ! ! Subroutine: mlt_twoside_ml_aply ! Version: complex - ! Note: internal subroutine of mld_dmlprec_aply. + ! Note: internal subroutine of mld_cmlprec_aply. ! ! This routine computes ! @@ -1106,7 +1055,7 @@ contains ! where ! - M is a symmetrized hybrid multilevel domain decomposition (Schwarz) ! preconditioner associated to a certain matrix A and stored in the array - ! baseprecv, + ! precv, ! - op(M^(-1)) is M^(-1) or its (conjugate) transpose, according to ! the value of trans, ! - X and Y are vectors, @@ -1120,9 +1069,9 @@ contains ! level where we might have a replicated index space) and each process takes care ! of one submatrix. ! - ! The multilevel preconditioner M is regarded as an array of 'base preconditioners', + ! The multilevel preconditioner M is regarded as an array of 'one-level preconditioners', ! each representing the part of the preconditioner associated to a certain level. - ! For each level ilev, the base preconditioner K(ilev) is stored in baseprecv(ilev) + ! For each level ilev, the base preconditioner K(ilev) is stored in precv(ilev) ! and is associated to a matrix A(ilev), obtained by 'tranferring' the original ! matrix A (i.e. the matrix to be preconditioned) to the level ilev, through smoothed ! aggregation. @@ -1136,7 +1085,7 @@ contains ! Domain decomposition: parallel multilevel methods for elliptic partial ! differential equations, Cambridge University Press, 1996. ! - ! For a description of the arguments see mld_dmlprec_aply. + ! For a description of the arguments see mld_cmlprec_aply. ! ! A sketch of the algorithm implemented in this routine is provided below. ! (AV(ilev; sm_pr_) denotes the smoothed prolongator from level ilev to @@ -1180,13 +1129,13 @@ contains ! ! 6. Yext = beta*Yext + alpha*Y(1) ! - subroutine mlt_twoside_ml_aply(alpha,baseprecv,x,beta,y,desc_data,trans,work,info) + subroutine mlt_twoside_ml_aply(alpha,precv,x,beta,y,desc_data,trans,work,info) implicit none ! Arguments type(psb_desc_type),intent(in) :: desc_data - type(mld_cbaseprc_type), intent(in) :: baseprecv(:) + type(mld_c_onelev_prec_type), intent(in) :: precv(:) complex(psb_spk_),intent(in) :: alpha,beta complex(psb_spk_),intent(in) :: x(:) complex(psb_spk_),intent(inout) :: y(:) @@ -1195,10 +1144,9 @@ contains integer, intent(out) :: info ! Local variables - integer :: n_row,n_col integer :: ictxt,np,me,i, nr2l,nc2l,err_act integer :: debug_level, debug_unit - integer :: ismth, nlev, ilev, icm + integer :: nlev, ilev character(len=20) :: name type psb_mlprec_wrk_type @@ -1217,9 +1165,9 @@ contains if (debug_level >= psb_debug_inner_) & & write(debug_unit,*) me,' ',trim(name),& - & ' Entry ', size(baseprecv) + & ' Entry ', size(precv) - nlev = size(baseprecv) + nlev = size(precv) allocate(mlprec_wrk(nlev),stat=info) if (info /= 0) then call psb_errpush(4010,name,a_err='Allocate') @@ -1230,8 +1178,7 @@ contains ! ! Copy the input vector X ! - n_col = psb_cd_get_local_cols(desc_data) - nc2l = psb_cd_get_local_cols(baseprecv(1)%base_desc) + nc2l = psb_cd_get_local_cols(precv(1)%base_desc) allocate(mlprec_wrk(1)%x2l(nc2l),mlprec_wrk(1)%y2l(nc2l), & & mlprec_wrk(1)%ty(nc2l), mlprec_wrk(1)%tx(nc2l), stat=info) @@ -1244,17 +1191,17 @@ contains end if call psb_geaxpby(cone,x,czero,mlprec_wrk(1)%x2l,& - & baseprecv(1)%base_desc,info) + & precv(1)%base_desc,info) call psb_geaxpby(cone,x,czero,mlprec_wrk(1)%tx,& - & baseprecv(1)%base_desc,info) + & precv(1)%base_desc,info) ! ! STEP 2 ! ! Apply the base preconditioner at the finest level ! - call mld_baseprec_aply(cone,baseprecv(1),mlprec_wrk(1)%x2l,& - & czero,mlprec_wrk(1)%y2l,baseprecv(1)%base_desc,& + call mld_baseprec_aply(cone,precv(1)%prec,mlprec_wrk(1)%x2l,& + & czero,mlprec_wrk(1)%y2l,precv(1)%base_desc,& & trans,work,info) ! ! STEP 3 @@ -1262,8 +1209,8 @@ contains ! Compute the residual at the finest level ! mlprec_wrk(1)%ty = mlprec_wrk(1)%x2l - if (info == 0) call psb_spmm(-cone,baseprecv(1)%base_a,mlprec_wrk(1)%y2l,& - & cone,mlprec_wrk(1)%ty,baseprecv(1)%base_desc,info,& + if (info == 0) call psb_spmm(-cone,precv(1)%base_a,mlprec_wrk(1)%y2l,& + & cone,mlprec_wrk(1)%ty,precv(1)%base_desc,info,& & work=work,trans=trans) if (info /=0) then call psb_errpush(4010,name,a_err='Fine level baseprec/residual') @@ -1277,12 +1224,9 @@ contains ! do ilev = 2, nlev - n_row = psb_cd_get_local_rows(baseprecv(ilev-1)%base_desc) - n_col = psb_cd_get_local_cols(baseprecv(ilev-1)%base_desc) - nc2l = psb_cd_get_local_cols(baseprecv(ilev)%base_desc) - nr2l = psb_cd_get_local_rows(baseprecv(ilev)%base_desc) - ismth = baseprecv(ilev)%iprcparm(mld_aggr_kind_) - icm = baseprecv(ilev)%iprcparm(mld_coarse_mat_) + nc2l = psb_cd_get_local_cols(precv(ilev)%base_desc) + nr2l = psb_cd_get_local_rows(precv(ilev)%base_desc) + allocate(mlprec_wrk(ilev)%tx(nc2l),mlprec_wrk(ilev)%ty(nc2l),& & mlprec_wrk(ilev)%y2l(nc2l),mlprec_wrk(ilev)%x2l(nc2l), stat=info) @@ -1296,30 +1240,29 @@ contains ! Apply prolongator transpose, i.e. restriction call psb_forward_map(cone,mlprec_wrk(ilev-1)%ty,& & czero,mlprec_wrk(ilev)%x2l,& - & baseprecv(ilev)%map_desc,info,work=work) + & precv(ilev)%map_desc,info,work=work) if (info /=0) then call psb_errpush(4001,name,a_err='Error during restriction') goto 9999 end if - call psb_geaxpby(cone,mlprec_wrk(ilev)%x2l,czero,mlprec_wrk(ilev)%tx,& - & baseprecv(ilev)%base_desc,info) + & precv(ilev)%base_desc,info) ! ! Apply the base preconditioner ! - if (info == 0) call mld_baseprec_aply(cone,baseprecv(ilev),& + if (info == 0) call mld_baseprec_aply(cone,precv(ilev)%prec,& & mlprec_wrk(ilev)%x2l,czero,mlprec_wrk(ilev)%y2l,& - &baseprecv(ilev)%base_desc,trans,work,info) + &precv(ilev)%base_desc,trans,work,info) ! ! Compute the residual (at all levels but the coarsest one) ! if(ilev < nlev) then mlprec_wrk(ilev)%ty = mlprec_wrk(ilev)%x2l - if (info == 0) call psb_spmm(-cone,baseprecv(ilev)%base_a,& + if (info == 0) call psb_spmm(-cone,precv(ilev)%base_a,& & mlprec_wrk(ilev)%y2l,cone,mlprec_wrk(ilev)%ty,& - & baseprecv(ilev)%base_desc,info,work=work,trans=trans) + & precv(ilev)%base_desc,info,work=work,trans=trans) endif if (info /=0) then call psb_errpush(4001,name,a_err='baseprec_aply/residual') @@ -1335,15 +1278,12 @@ contains ! do ilev=nlev-1, 1, -1 - ismth = baseprecv(ilev+1)%iprcparm(mld_aggr_kind_) - n_row = psb_cd_get_local_rows(baseprecv(ilev)%base_desc) - ! ! Apply prolongator ! call psb_backward_map(cone,mlprec_wrk(ilev+1)%y2l,& & cone,mlprec_wrk(ilev)%y2l,& - & baseprecv(ilev+1)%map_desc,info,work=work) + & precv(ilev+1)%map_desc,info,work=work) if (info /=0 ) then call psb_errpush(4001,name,a_err='Error during restriction') @@ -1353,14 +1293,14 @@ contains ! ! Compute the residual ! - call psb_spmm(-cone,baseprecv(ilev)%base_a,mlprec_wrk(ilev)%y2l,& - & cone,mlprec_wrk(ilev)%tx,baseprecv(ilev)%base_desc,info,& + call psb_spmm(-cone,precv(ilev)%base_a,mlprec_wrk(ilev)%y2l,& + & cone,mlprec_wrk(ilev)%tx,precv(ilev)%base_desc,info,& & work=work,trans=trans) ! ! Apply the base preconditioner ! - if (info == 0) call mld_baseprec_aply(cone,baseprecv(ilev),mlprec_wrk(ilev)%tx,& - & cone,mlprec_wrk(ilev)%y2l,baseprecv(ilev)%base_desc, trans, work,info) + if (info == 0) call mld_baseprec_aply(cone,precv(ilev)%prec,mlprec_wrk(ilev)%tx,& + & cone,mlprec_wrk(ilev)%y2l,precv(ilev)%base_desc, trans, work,info) if (info /= 0) then call psb_errpush(4001,name,a_err='Error: residual/baseprec_aply') goto 9999 @@ -1373,7 +1313,7 @@ contains ! Compute the output vector Y ! call psb_geaxpby(alpha,mlprec_wrk(1)%y2l,beta,y,& - & baseprecv(1)%base_desc,info) + & precv(1)%base_desc,info) if (info /= 0) then call psb_errpush(4001,name,a_err='Error final update') diff --git a/mlprec/mld_cmlprec_bld.f90 b/mlprec/mld_cmlprec_bld.f90 index 76b1c05d..e2da034b 100644 --- a/mlprec/mld_cmlprec_bld.f90 +++ b/mlprec/mld_cmlprec_bld.f90 @@ -41,7 +41,7 @@ ! Subroutine: mld_cmlprec_bld ! Version: complex ! -! This routine builds the base preconditioner corresponding to the current +! This routine builds the preconditioner corresponding to the current ! level of the multilevel preconditioner. The routine first builds the ! (coarse) matrix associated to the current level from the (fine) matrix ! associated to the previous level, then builds the related base preconditioner. @@ -53,9 +53,9 @@ ! matrix to be preconditioned. ! desc_a - type(psb_desc_type), input. ! The communication descriptor of a. -! p - type(mld_cbaseprc_type), input/output. -! The base preconditioner data structure containing the local -! part of the base preconditioner to be built. +! p - type(mld_c_onelev_type), input/output. +! The preconditioner data structure containing the local +! part of the one-level preconditioner to be built. ! info - integer, output. ! Error code. ! @@ -69,7 +69,7 @@ subroutine mld_cmlprec_bld(a,desc_a,p,info) ! Arguments type(psb_cspmat_type), intent(in), target :: a type(psb_desc_type), intent(in), target :: desc_a - type(mld_cbaseprc_type), intent(inout),target :: p + type(mld_c_onelev_prec_type), intent(inout),target :: p integer, intent(out) :: info ! Local variables @@ -106,16 +106,16 @@ subroutine mld_cmlprec_bld(a,desc_a,p,info) & mld_max_norm_,is_legal_ml_aggr_eig) - select case(p%iprcparm(mld_sub_solve_)) + select case(p%prec%iprcparm(mld_sub_solve_)) case(mld_ilu_n_,mld_milu_n_) - call mld_check_def(p%iprcparm(mld_sub_fillin_),'Level',0,is_legal_ml_lev) + call mld_check_def(p%prec%iprcparm(mld_sub_fillin_),'Level',0,is_legal_ml_lev) case(mld_ilu_t_) - call mld_check_def(p%rprcparm(mld_sub_iluthrs_),'Eps',szero,is_legal_s_fact_thrs) + call mld_check_def(p%prec%rprcparm(mld_sub_iluthrs_),'Eps',szero,is_legal_s_fact_thrs) end select + call mld_check_def(p%prec%iprcparm(mld_smoother_sweeps_),'Jacobi sweeps',& + & 1,is_legal_jac_sweeps) call mld_check_def(p%rprcparm(mld_aggr_omega_val_),'Omega',szero,is_legal_s_omega) call mld_check_def(p%rprcparm(mld_aggr_thresh_),'Aggr_Thresh',szero,is_legal_s_aggr_thrs) - call mld_check_def(p%iprcparm(mld_smoother_sweeps_),'Jacobi sweeps',& - & 1,is_legal_jac_sweeps) ! ! Build a mapping between the row indices of the fine-level matrix @@ -135,7 +135,7 @@ subroutine mld_cmlprec_bld(a,desc_a,p,info) ! the mapping defined by mld_aggrmap_bld and applying the aggregation ! algorithm specified by p%iprcparm(mld_aggr_kind_) ! - call mld_aggrmat_asb(a,desc_a,ac,desc_ac,p,info) + call mld_aggrmat_asb(a,desc_a,p,info) if(info /= 0) then call psb_errpush(4010,name,a_err='mld_aggrmat_asb') goto 9999 @@ -144,34 +144,18 @@ subroutine mld_cmlprec_bld(a,desc_a,p,info) ! ! Build the 'base preconditioner' corresponding to the coarse level ! - call mld_baseprc_bld(ac,desc_ac,p,info) + call mld_baseprc_bld(p%ac,p%desc_ac,p%prec,info) if (info /= 0) then call psb_errpush(4010,name,a_err='mld_baseprc_bld') goto 9999 end if - ! - ! We have used a separate ac because - ! 1. we want to reuse the same routines mld_ilu_bld, etc., - ! 2. we do NOT want to pass an argument twice to them (p%av(mld_ac_) and p), - ! as this would violate the Fortran standard. - ! Hence a separate AC and a TRANSFER function at the end. + ! Fix the base_a and base_desc pointers for handling of residuals. + ! This is correct because this routine is only called at levels >=2. ! - call psb_sp_transfer(ac,p%av(mld_ac_),info) - p%base_a => p%av(mld_ac_) - if (info==0) call psb_cdtransfer(desc_ac,p%desc_ac,info) - - p%map_desc = psb_inter_desc(psb_map_aggr_,desc_a,& - & p%desc_ac,p%av(mld_sm_pr_t_),p%av(mld_sm_pr_)) - ! The two matrices from p%av() have been copied, may free them. - if (info == 0) call psb_sp_free(p%av(mld_sm_pr_t_),info) - if (info == 0) call psb_sp_free(p%av(mld_sm_pr_),info) - if (info /= 0) then - call psb_errpush(4010,name,a_err='psb_cdtransfer') - goto 9999 - end if + p%base_a => p%ac p%base_desc => p%desc_ac - + call psb_erractionrestore(err_act) return diff --git a/mlprec/mld_cprec_aply.f90 b/mlprec/mld_cprec_aply.f90 index 7d85c17d..1fb46463 100644 --- a/mlprec/mld_cprec_aply.f90 +++ b/mlprec/mld_cprec_aply.f90 @@ -120,25 +120,25 @@ subroutine mld_cprec_aply(prec,x,y,desc_data,info,trans,work) end if - if (.not.(allocated(prec%baseprecv))) then + if (.not.(allocated(prec%precv))) then !! Error 1: should call mld_dprecbld info=3112 call psb_errpush(info,name) goto 9999 end if - if (size(prec%baseprecv) >1) then - call mld_mlprec_aply(cone,prec%baseprecv,x,czero,y,desc_data,trans_,work_,info) + if (size(prec%precv) >1) then + call mld_mlprec_aply(cone,prec%precv,x,czero,y,desc_data,trans_,work_,info) if(info /= 0) then call psb_errpush(4010,name,a_err='mld_cmlprec_aply') goto 9999 end if - else if (size(prec%baseprecv) == 1) then - call mld_baseprec_aply(cone,prec%baseprecv(1),x,czero,y,desc_data,trans_, work_,info) + else if (size(prec%precv) == 1) then + call mld_baseprec_aply(cone,prec%precv(1)%prec,x,czero,y,desc_data,trans_, work_,info) else info = 4013 - call psb_errpush(info,name,a_err='Invalid size of baseprecv',& - & i_Err=(/size(prec%baseprecv),0,0,0,0/)) + call psb_errpush(info,name,a_err='Invalid size of precv',& + & i_Err=(/size(prec%precv),0,0,0,0/)) goto 9999 endif diff --git a/mlprec/mld_cprecbld.f90 b/mlprec/mld_cprecbld.f90 index 26f67692..9f73769d 100644 --- a/mlprec/mld_cprecbld.f90 +++ b/mlprec/mld_cprecbld.f90 @@ -119,8 +119,8 @@ subroutine mld_cprecbld(a,desc_a,p,info) !!$ endif upd_ = 'F' - if (.not.allocated(p%baseprecv)) then - !! Error: should have called mld_dprecinit + if (.not.allocated(p%precv)) then + !! Error: should have called mld_cprecinit info=3111 call psb_errpush(info,name) goto 9999 @@ -129,11 +129,11 @@ subroutine mld_cprecbld(a,desc_a,p,info) ! ! Check to ensure all procs have the same ! - iszv = size(p%baseprecv) + iszv = size(p%precv) call psb_bcast(ictxt,iszv) - if (iszv /= size(p%baseprecv)) then + if (iszv /= size(p%precv)) then info=4001 - call psb_errpush(info,name,a_err='Inconsistent size of baseprecv') + call psb_errpush(info,name,a_err='Inconsistent size of precv') goto 9999 end if @@ -142,18 +142,20 @@ subroutine mld_cprecbld(a,desc_a,p,info) ! Check on the iprcparm contents: they should be the same ! on all processes. ! - if (me == psb_root_) ipv(:) = p%baseprecv(1)%iprcparm(:) + if (me == psb_root_) ipv(:) = p%precv(1)%iprcparm(:) call psb_bcast(ictxt,ipv) - if (any(ipv(:) /= p%baseprecv(1)%iprcparm(:) )) then + if (any(ipv(:) /= p%precv(1)%iprcparm(:) )) then write(debug_unit,*) me,name,& &': Inconsistent arguments among processes, forcing a default' - p%baseprecv(1)%iprcparm(:) = ipv(:) + p%precv(1)%iprcparm(:) = ipv(:) end if ! - ! Allocate and build the fine level preconditioner + ! Finest level first; remember to fix base_a and base_desc ! - call init_baseprc_av(p%baseprecv(1),info) - if (info == 0) call mld_baseprc_bld(a,desc_a,p%baseprecv(1),info,upd_) + call init_baseprc_av(p%precv(1)%prec,info) + if (info == 0) call mld_baseprc_bld(a,desc_a,p%precv(1)%prec,info,upd_) + p%precv(1)%base_a => a + p%precv(1)%base_desc => desc_a if (info /= 0) then call psb_errpush(4001,name,a_err='Base level precbuild.') @@ -178,69 +180,69 @@ subroutine mld_cprecbld(a,desc_a,p,info) ! Check on the iprcparm contents: they should be the same ! on all processes. ! - if (me == psb_root_) ipv(:) = p%baseprecv(i)%iprcparm(:) + if (me == psb_root_) ipv(:) = p%precv(i)%iprcparm(:) call psb_bcast(ictxt,ipv) - if (any(ipv(:) /= p%baseprecv(i)%iprcparm(:) )) then + if (any(ipv(:) /= p%precv(i)%iprcparm(:) )) then write(debug_unit,*) me,name,& &': Inconsistent arguments among processes, resetting.' - p%baseprecv(i)%iprcparm(:) = ipv(:) + p%precv(i)%iprcparm(:) = ipv(:) end if ! - ! Allocate the av component of the preconditioner data type - ! at level i + ! Sanity checks on the parameters ! if (i= psb_debug_outer_) & & write(debug_unit,*) me,' ',trim(name),& & 'Calling mlprcbld at level ',i - - ! - ! Build the base preconditioner corresponding to level i ! - if (info == 0) call mld_mlprec_bld(p%baseprecv(i-1)%base_a,& - & p%baseprecv(i-1)%base_desc, p%baseprecv(i),info) + ! Allocate and build the preconditioner at level i. + ! baseprec_bld is called inside mlprec_bld. + ! + call init_baseprc_av(p%precv(i)%prec,info) + if (info == 0) call mld_mlprec_bld(p%precv(i-1)%base_a,& + & p%precv(i-1)%base_desc, p%precv(i),info) + if (info /= 0) then call psb_errpush(4001,name,a_err='Init & build upper level preconditioner') goto 9999 @@ -250,11 +252,14 @@ subroutine mld_cprecbld(a,desc_a,p,info) & write(debug_unit,*) me,' ',trim(name),& & 'Return from ',i,' call to mlprcbld ',info end do + + ! ! Check on sizes from level 2 onwards + ! if (me==0) then k = iszv+1 do i=iszv,3,-1 - if (all(p%baseprecv(i)%nlaggr == p%baseprecv(i-1)%nlaggr)) then + if (all(p%precv(i)%nlaggr == p%precv(i-1)%nlaggr)) then k=i-1 end if end do diff --git a/mlprec/mld_cprecfree.f90 b/mlprec/mld_cprecfree.f90 index b9ee2c15..1fb06335 100644 --- a/mlprec/mld_cprecfree.f90 +++ b/mlprec/mld_cprecfree.f90 @@ -74,11 +74,11 @@ subroutine mld_cprecfree(p,info) me=-1 - if (allocated(p%baseprecv)) then - do i=1,size(p%baseprecv) - call mld_base_precfree(p%baseprecv(i),info) + if (allocated(p%precv)) then + do i=1,size(p%precv) + call mld_onelev_precfree(p%precv(i),info) end do - deallocate(p%baseprecv) + deallocate(p%precv) end if call psb_erractionrestore(err_act) return diff --git a/mlprec/mld_cprecinit.F90 b/mlprec/mld_cprecinit.F90 index 0a7b4e0e..76e7893b 100644 --- a/mlprec/mld_cprecinit.F90 +++ b/mlprec/mld_cprecinit.F90 @@ -104,7 +104,7 @@ subroutine mld_cprecinit(p,ptype,info,nlev) character(len=*), parameter :: name='mld_precinit' info = 0 - if (allocated(p%baseprecv)) then + if (allocated(p%precv)) then call mld_precfree(p,info) if (info /=0) then ! Do we want to do something? @@ -115,68 +115,88 @@ subroutine mld_cprecinit(p,ptype,info,nlev) case ('NOPREC') nlev_ = 1 ilev_ = 1 - allocate(p%baseprecv(nlev_),stat=info) - if (info == 0) call psb_realloc(mld_ifpsz_,p%baseprecv(ilev_)%iprcparm,info) - if (info == 0) call psb_realloc(mld_rfpsz_,p%baseprecv(ilev_)%rprcparm,info) + allocate(p%precv(nlev_),stat=info) + if (info == 0) call psb_realloc(mld_ifpsz_,p%precv(ilev_)%iprcparm,info) + if (info == 0) call psb_realloc(mld_rfpsz_,p%precv(ilev_)%rprcparm,info) + if (info == 0) call psb_realloc(mld_ifpsz_,p%precv(ilev_)%prec%iprcparm,info) + if (info == 0) call psb_realloc(mld_rfpsz_,p%precv(ilev_)%prec%rprcparm,info) if (info /= 0) return - p%baseprecv(ilev_)%iprcparm(:) = 0 - p%baseprecv(ilev_)%iprcparm(mld_smoother_type_) = mld_noprec_ - p%baseprecv(ilev_)%iprcparm(mld_sub_solve_) = mld_f_none_ - p%baseprecv(ilev_)%iprcparm(mld_sub_restr_) = psb_none_ - p%baseprecv(ilev_)%iprcparm(mld_sub_prol_) = psb_none_ - p%baseprecv(ilev_)%iprcparm(mld_sub_ren_) = 0 - p%baseprecv(ilev_)%iprcparm(mld_sub_ovr_) = 0 - p%baseprecv(ilev_)%iprcparm(mld_smoother_sweeps_) = 1 + p%precv(ilev_)%iprcparm(:) = 0 + p%precv(ilev_)%rprcparm(:) = szero + p%precv(ilev_)%prec%iprcparm(:) = 0 + p%precv(ilev_)%prec%rprcparm(:) = szero + p%precv(ilev_)%prec%iprcparm(mld_smoother_type_) = mld_noprec_ + p%precv(ilev_)%prec%iprcparm(mld_sub_solve_) = mld_f_none_ + p%precv(ilev_)%prec%iprcparm(mld_sub_restr_) = psb_none_ + p%precv(ilev_)%prec%iprcparm(mld_sub_prol_) = psb_none_ + p%precv(ilev_)%prec%iprcparm(mld_sub_ren_) = 0 + p%precv(ilev_)%prec%iprcparm(mld_sub_ovr_) = 0 + p%precv(ilev_)%prec%iprcparm(mld_smoother_sweeps_) = 1 case ('DIAG') nlev_ = 1 ilev_ = 1 - allocate(p%baseprecv(nlev_),stat=info) - if (info == 0) call psb_realloc(mld_ifpsz_,p%baseprecv(ilev_)%iprcparm,info) - if (info == 0) call psb_realloc(mld_rfpsz_,p%baseprecv(ilev_)%rprcparm,info) + allocate(p%precv(nlev_),stat=info) + if (info == 0) call psb_realloc(mld_ifpsz_,p%precv(ilev_)%iprcparm,info) + if (info == 0) call psb_realloc(mld_rfpsz_,p%precv(ilev_)%rprcparm,info) + if (info == 0) call psb_realloc(mld_ifpsz_,p%precv(ilev_)%prec%iprcparm,info) + if (info == 0) call psb_realloc(mld_rfpsz_,p%precv(ilev_)%prec%rprcparm,info) if (info /= 0) return - p%baseprecv(ilev_)%iprcparm(:) = 0 - p%baseprecv(ilev_)%iprcparm(mld_smoother_type_) = mld_diag_ - p%baseprecv(ilev_)%iprcparm(mld_sub_solve_) = mld_f_none_ - p%baseprecv(ilev_)%iprcparm(mld_sub_restr_) = psb_none_ - p%baseprecv(ilev_)%iprcparm(mld_sub_prol_) = psb_none_ - p%baseprecv(ilev_)%iprcparm(mld_sub_ren_) = 0 - p%baseprecv(ilev_)%iprcparm(mld_sub_ovr_) = 0 - p%baseprecv(ilev_)%iprcparm(mld_smoother_sweeps_) = 1 + p%precv(ilev_)%iprcparm(:) = 0 + p%precv(ilev_)%rprcparm(:) = szero + p%precv(ilev_)%prec%iprcparm(:) = 0 + p%precv(ilev_)%prec%rprcparm(:) = szero + p%precv(ilev_)%prec%iprcparm(mld_smoother_type_) = mld_diag_ + p%precv(ilev_)%prec%iprcparm(mld_sub_solve_) = mld_f_none_ + p%precv(ilev_)%prec%iprcparm(mld_sub_restr_) = psb_none_ + p%precv(ilev_)%prec%iprcparm(mld_sub_prol_) = psb_none_ + p%precv(ilev_)%prec%iprcparm(mld_sub_ren_) = 0 + p%precv(ilev_)%prec%iprcparm(mld_sub_ovr_) = 0 + p%precv(ilev_)%prec%iprcparm(mld_smoother_sweeps_) = 1 case ('BJAC') nlev_ = 1 ilev_ = 1 - allocate(p%baseprecv(nlev_),stat=info) - if (info == 0) call psb_realloc(mld_ifpsz_,p%baseprecv(ilev_)%iprcparm,info) - if (info == 0) call psb_realloc(mld_rfpsz_,p%baseprecv(ilev_)%rprcparm,info) + allocate(p%precv(nlev_),stat=info) + if (info == 0) call psb_realloc(mld_ifpsz_,p%precv(ilev_)%iprcparm,info) + if (info == 0) call psb_realloc(mld_rfpsz_,p%precv(ilev_)%rprcparm,info) + if (info == 0) call psb_realloc(mld_ifpsz_,p%precv(ilev_)%prec%iprcparm,info) + if (info == 0) call psb_realloc(mld_rfpsz_,p%precv(ilev_)%prec%rprcparm,info) if (info /= 0) return - p%baseprecv(ilev_)%iprcparm(:) = 0 - p%baseprecv(ilev_)%iprcparm(mld_smoother_type_) = mld_bjac_ - p%baseprecv(ilev_)%iprcparm(mld_sub_solve_) = mld_ilu_n_ - p%baseprecv(ilev_)%iprcparm(mld_sub_restr_) = psb_none_ - p%baseprecv(ilev_)%iprcparm(mld_sub_prol_) = psb_none_ - p%baseprecv(ilev_)%iprcparm(mld_sub_ren_) = 0 - p%baseprecv(ilev_)%iprcparm(mld_sub_ovr_) = 0 - p%baseprecv(ilev_)%iprcparm(mld_sub_fillin_) = 0 - p%baseprecv(ilev_)%iprcparm(mld_smoother_sweeps_) = 1 + p%precv(ilev_)%iprcparm(:) = 0 + p%precv(ilev_)%rprcparm(:) = szero + p%precv(ilev_)%prec%iprcparm(:) = 0 + p%precv(ilev_)%prec%rprcparm(:) = szero + p%precv(ilev_)%prec%iprcparm(mld_smoother_type_) = mld_bjac_ + p%precv(ilev_)%prec%iprcparm(mld_sub_solve_) = mld_ilu_n_ + p%precv(ilev_)%prec%iprcparm(mld_sub_restr_) = psb_none_ + p%precv(ilev_)%prec%iprcparm(mld_sub_prol_) = psb_none_ + p%precv(ilev_)%prec%iprcparm(mld_sub_ren_) = 0 + p%precv(ilev_)%prec%iprcparm(mld_sub_ovr_) = 0 + p%precv(ilev_)%prec%iprcparm(mld_sub_fillin_) = 0 + p%precv(ilev_)%prec%iprcparm(mld_smoother_sweeps_) = 1 case ('AS') nlev_ = 1 ilev_ = 1 - allocate(p%baseprecv(nlev_),stat=info) - if (info == 0) call psb_realloc(mld_ifpsz_,p%baseprecv(ilev_)%iprcparm,info) - if (info == 0) call psb_realloc(mld_rfpsz_,p%baseprecv(ilev_)%rprcparm,info) + allocate(p%precv(nlev_),stat=info) + if (info == 0) call psb_realloc(mld_ifpsz_,p%precv(ilev_)%iprcparm,info) + if (info == 0) call psb_realloc(mld_rfpsz_,p%precv(ilev_)%rprcparm,info) + if (info == 0) call psb_realloc(mld_ifpsz_,p%precv(ilev_)%prec%iprcparm,info) + if (info == 0) call psb_realloc(mld_rfpsz_,p%precv(ilev_)%prec%rprcparm,info) if (info /= 0) return - p%baseprecv(ilev_)%iprcparm(:) = 0 - p%baseprecv(ilev_)%iprcparm(mld_smoother_type_) = mld_as_ - p%baseprecv(ilev_)%iprcparm(mld_sub_solve_) = mld_ilu_n_ - p%baseprecv(ilev_)%iprcparm(mld_sub_restr_) = psb_halo_ - p%baseprecv(ilev_)%iprcparm(mld_sub_prol_) = psb_none_ - p%baseprecv(ilev_)%iprcparm(mld_sub_ren_) = 0 - p%baseprecv(ilev_)%iprcparm(mld_sub_ovr_) = 1 - p%baseprecv(ilev_)%iprcparm(mld_sub_fillin_) = 0 - p%baseprecv(ilev_)%iprcparm(mld_smoother_sweeps_) = 1 + p%precv(ilev_)%iprcparm(:) = 0 + p%precv(ilev_)%rprcparm(:) = szero + p%precv(ilev_)%prec%iprcparm(:) = 0 + p%precv(ilev_)%prec%rprcparm(:) = szero + p%precv(ilev_)%prec%iprcparm(mld_smoother_type_) = mld_as_ + p%precv(ilev_)%prec%iprcparm(mld_sub_solve_) = mld_ilu_n_ + p%precv(ilev_)%prec%iprcparm(mld_sub_restr_) = psb_halo_ + p%precv(ilev_)%prec%iprcparm(mld_sub_prol_) = psb_none_ + p%precv(ilev_)%prec%iprcparm(mld_sub_ren_) = 0 + p%precv(ilev_)%prec%iprcparm(mld_sub_ovr_) = 1 + p%precv(ilev_)%prec%iprcparm(mld_sub_fillin_) = 0 + p%precv(ilev_)%prec%iprcparm(mld_smoother_sweeps_) = 1 case ('ML') @@ -187,74 +207,87 @@ subroutine mld_cprecinit(p,ptype,info,nlev) nlev_ = 2 end if ilev_ = 1 - allocate(p%baseprecv(nlev_),stat=info) - if (info == 0) call psb_realloc(mld_ifpsz_,p%baseprecv(ilev_)%iprcparm,info) - if (info == 0) call psb_realloc(mld_rfpsz_,p%baseprecv(ilev_)%rprcparm,info) + allocate(p%precv(nlev_),stat=info) + if (info == 0) call psb_realloc(mld_ifpsz_,p%precv(ilev_)%iprcparm,info) + if (info == 0) call psb_realloc(mld_rfpsz_,p%precv(ilev_)%rprcparm,info) + if (info == 0) call psb_realloc(mld_ifpsz_,p%precv(ilev_)%prec%iprcparm,info) + if (info == 0) call psb_realloc(mld_rfpsz_,p%precv(ilev_)%prec%rprcparm,info) if (info /= 0) return - p%baseprecv(ilev_)%iprcparm(:) = 0 - p%baseprecv(ilev_)%rprcparm(:) = szero - p%baseprecv(ilev_)%iprcparm(mld_smoother_type_) = mld_as_ - p%baseprecv(ilev_)%iprcparm(mld_sub_solve_) = mld_ilu_n_ - p%baseprecv(ilev_)%iprcparm(mld_sub_restr_) = psb_halo_ - p%baseprecv(ilev_)%iprcparm(mld_sub_prol_) = psb_none_ - p%baseprecv(ilev_)%iprcparm(mld_sub_ren_) = 0 - p%baseprecv(ilev_)%iprcparm(mld_sub_ovr_) = 1 - p%baseprecv(ilev_)%iprcparm(mld_sub_fillin_) = 0 - p%baseprecv(ilev_)%iprcparm(mld_smoother_sweeps_) = 1 + p%precv(ilev_)%iprcparm(:) = 0 + p%precv(ilev_)%rprcparm(:) = szero + p%precv(ilev_)%prec%iprcparm(:) = 0 + p%precv(ilev_)%prec%rprcparm(:) = szero + p%precv(ilev_)%prec%iprcparm(mld_smoother_type_) = mld_as_ + p%precv(ilev_)%prec%iprcparm(mld_sub_solve_) = mld_ilu_n_ + p%precv(ilev_)%prec%iprcparm(mld_sub_restr_) = psb_halo_ + p%precv(ilev_)%prec%iprcparm(mld_sub_prol_) = psb_none_ + p%precv(ilev_)%prec%iprcparm(mld_sub_ren_) = 0 + p%precv(ilev_)%prec%iprcparm(mld_sub_ovr_) = 1 + p%precv(ilev_)%prec%iprcparm(mld_sub_fillin_) = 0 + p%precv(ilev_)%prec%iprcparm(mld_smoother_sweeps_) = 1 if (nlev_ == 1) return do ilev_ = 2, nlev_ -1 - if (info == 0) call psb_realloc(mld_ifpsz_,p%baseprecv(ilev_)%iprcparm,info) - if (info == 0) call psb_realloc(mld_rfpsz_,p%baseprecv(ilev_)%rprcparm,info) + if (info == 0) call psb_realloc(mld_ifpsz_,p%precv(ilev_)%iprcparm,info) + if (info == 0) call psb_realloc(mld_rfpsz_,p%precv(ilev_)%rprcparm,info) + if (info == 0) call psb_realloc(mld_ifpsz_,p%precv(ilev_)%prec%iprcparm,info) + if (info == 0) call psb_realloc(mld_rfpsz_,p%precv(ilev_)%prec%rprcparm,info) if (info /= 0) return - p%baseprecv(ilev_)%iprcparm(:) = 0 - p%baseprecv(ilev_)%rprcparm(:) = szero - p%baseprecv(ilev_)%iprcparm(mld_smoother_type_) = mld_as_ - p%baseprecv(ilev_)%iprcparm(mld_sub_restr_) = psb_halo_ - p%baseprecv(ilev_)%iprcparm(mld_sub_prol_) = psb_none_ - p%baseprecv(ilev_)%iprcparm(mld_sub_ren_) = 0 - p%baseprecv(ilev_)%iprcparm(mld_sub_ovr_) = 1 - p%baseprecv(ilev_)%iprcparm(mld_ml_type_) = mld_mult_ml_ - p%baseprecv(ilev_)%iprcparm(mld_aggr_alg_) = mld_dec_aggr_ - p%baseprecv(ilev_)%iprcparm(mld_aggr_kind_) = mld_smooth_prol_ - p%baseprecv(ilev_)%iprcparm(mld_coarse_mat_) = mld_distr_mat_ - p%baseprecv(ilev_)%iprcparm(mld_smoother_pos_) = mld_post_smooth_ - p%baseprecv(ilev_)%iprcparm(mld_aggr_omega_alg_) = mld_eig_est_ - p%baseprecv(ilev_)%iprcparm(mld_aggr_eig_) = mld_max_norm_ - p%baseprecv(ilev_)%iprcparm(mld_sub_solve_) = mld_ilu_n_ - p%baseprecv(ilev_)%iprcparm(mld_sub_fillin_) = 0 - p%baseprecv(ilev_)%iprcparm(mld_smoother_sweeps_) = 1 - p%baseprecv(ilev_)%rprcparm(mld_aggr_omega_val_) = szero - p%baseprecv(ilev_)%rprcparm(mld_aggr_thresh_) = szero + p%precv(ilev_)%iprcparm(:) = 0 + p%precv(ilev_)%rprcparm(:) = szero + p%precv(ilev_)%prec%iprcparm(:) = 0 + p%precv(ilev_)%prec%rprcparm(:) = szero + p%precv(ilev_)%prec%iprcparm(mld_smoother_type_) = mld_as_ + p%precv(ilev_)%prec%iprcparm(mld_sub_restr_) = psb_halo_ + p%precv(ilev_)%prec%iprcparm(mld_sub_prol_) = psb_none_ + p%precv(ilev_)%prec%iprcparm(mld_sub_ren_) = 0 + p%precv(ilev_)%prec%iprcparm(mld_sub_ovr_) = 1 + p%precv(ilev_)%prec%iprcparm(mld_sub_solve_) = mld_ilu_n_ + p%precv(ilev_)%prec%iprcparm(mld_sub_fillin_) = 0 + p%precv(ilev_)%prec%iprcparm(mld_smoother_sweeps_) = 1 + p%precv(ilev_)%iprcparm(mld_ml_type_) = mld_mult_ml_ + p%precv(ilev_)%iprcparm(mld_aggr_alg_) = mld_dec_aggr_ + p%precv(ilev_)%iprcparm(mld_aggr_kind_) = mld_smooth_prol_ + p%precv(ilev_)%iprcparm(mld_coarse_mat_) = mld_distr_mat_ + p%precv(ilev_)%iprcparm(mld_smoother_pos_) = mld_post_smooth_ + p%precv(ilev_)%iprcparm(mld_aggr_omega_alg_) = mld_eig_est_ + p%precv(ilev_)%iprcparm(mld_aggr_eig_) = mld_max_norm_ + p%precv(ilev_)%rprcparm(mld_aggr_omega_val_) = szero + p%precv(ilev_)%rprcparm(mld_aggr_thresh_) = szero end do ilev_ = nlev_ - if (info == 0) call psb_realloc(mld_ifpsz_,p%baseprecv(ilev_)%iprcparm,info) - if (info == 0) call psb_realloc(mld_rfpsz_,p%baseprecv(ilev_)%rprcparm,info) + if (info == 0) call psb_realloc(mld_ifpsz_,p%precv(ilev_)%iprcparm,info) + if (info == 0) call psb_realloc(mld_rfpsz_,p%precv(ilev_)%rprcparm,info) + if (info == 0) call psb_realloc(mld_ifpsz_,p%precv(ilev_)%prec%iprcparm,info) + if (info == 0) call psb_realloc(mld_rfpsz_,p%precv(ilev_)%prec%rprcparm,info) if (info /= 0) return - p%baseprecv(ilev_)%iprcparm(:) = 0 - p%baseprecv(ilev_)%rprcparm(:) = szero - p%baseprecv(ilev_)%iprcparm(mld_coarse_solve_) = mld_bjac_ + p%precv(ilev_)%iprcparm(:) = 0 + p%precv(ilev_)%rprcparm(:) = szero + p%precv(ilev_)%prec%iprcparm(:) = 0 + p%precv(ilev_)%prec%rprcparm(:) = szero + p%precv(ilev_)%prec%iprcparm(mld_coarse_solve_) = mld_bjac_ #if defined(HAVE_SLU_) - p%baseprecv(ilev_)%iprcparm(mld_sub_solve_) = mld_slu_ + p%precv(ilev_)%prec%iprcparm(mld_sub_solve_) = mld_slu_ #else - p%baseprecv(ilev_)%iprcparm(mld_sub_solve_) = mld_ilu_n_ + p%precv(ilev_)%prec%iprcparm(mld_sub_solve_) = mld_ilu_n_ #endif - p%baseprecv(ilev_)%iprcparm(mld_smoother_type_) = mld_bjac_ - p%baseprecv(ilev_)%iprcparm(mld_coarse_mat_) = mld_distr_mat_ - p%baseprecv(ilev_)%iprcparm(mld_sub_restr_) = psb_none_ - p%baseprecv(ilev_)%iprcparm(mld_sub_prol_) = psb_none_ - p%baseprecv(ilev_)%iprcparm(mld_sub_ren_) = 0 - p%baseprecv(ilev_)%iprcparm(mld_sub_ovr_) = 0 - p%baseprecv(ilev_)%iprcparm(mld_ml_type_) = mld_mult_ml_ - p%baseprecv(ilev_)%iprcparm(mld_aggr_alg_) = mld_dec_aggr_ - p%baseprecv(ilev_)%iprcparm(mld_aggr_kind_) = mld_smooth_prol_ - p%baseprecv(ilev_)%iprcparm(mld_smoother_pos_) = mld_post_smooth_ - p%baseprecv(ilev_)%iprcparm(mld_aggr_omega_alg_) = mld_eig_est_ - p%baseprecv(ilev_)%iprcparm(mld_aggr_eig_) = mld_max_norm_ - p%baseprecv(ilev_)%iprcparm(mld_sub_fillin_) = 0 - p%baseprecv(ilev_)%iprcparm(mld_smoother_sweeps_) = 4 - p%baseprecv(ilev_)%rprcparm(mld_aggr_omega_val_) = szero - p%baseprecv(ilev_)%rprcparm(mld_aggr_thresh_) = szero + p%precv(ilev_)%prec%iprcparm(mld_smoother_type_) = mld_bjac_ + p%precv(ilev_)%prec%iprcparm(mld_coarse_mat_) = mld_distr_mat_ + p%precv(ilev_)%prec%iprcparm(mld_sub_restr_) = psb_none_ + p%precv(ilev_)%prec%iprcparm(mld_sub_prol_) = psb_none_ + p%precv(ilev_)%prec%iprcparm(mld_sub_ren_) = 0 + p%precv(ilev_)%prec%iprcparm(mld_sub_ovr_) = 0 + p%precv(ilev_)%prec%iprcparm(mld_sub_fillin_) = 0 + p%precv(ilev_)%prec%iprcparm(mld_smoother_sweeps_) = 4 + p%precv(ilev_)%iprcparm(mld_ml_type_) = mld_mult_ml_ + p%precv(ilev_)%iprcparm(mld_aggr_alg_) = mld_dec_aggr_ + p%precv(ilev_)%iprcparm(mld_aggr_kind_) = mld_smooth_prol_ + p%precv(ilev_)%iprcparm(mld_smoother_pos_) = mld_post_smooth_ + p%precv(ilev_)%iprcparm(mld_aggr_omega_alg_) = mld_eig_est_ + p%precv(ilev_)%iprcparm(mld_aggr_eig_) = mld_max_norm_ + p%precv(ilev_)%rprcparm(mld_aggr_omega_val_) = szero + p%precv(ilev_)%rprcparm(mld_aggr_thresh_) = szero + case default write(0,*) name,': Warning: Unknown preconditioner type request "',ptype,'"' info = 2 diff --git a/mlprec/mld_cprecset.f90 b/mlprec/mld_cprecset.f90 index d7cd13a3..eb2d4d65 100644 --- a/mlprec/mld_cprecset.f90 +++ b/mlprec/mld_cprecset.f90 @@ -68,7 +68,6 @@ ! preconditioner parameter has to be set. ! If nlev is not present, the parameter identified by 'what' ! is set at all the appropriate levels. -! ! ! NOTE: currently, the use of the argument ilev is not "safe" and is reserved to ! MLD2P4 developers. Indeed, by using ilev it is possible to set different values @@ -97,12 +96,12 @@ subroutine mld_cprecseti(p,what,val,info,ilev) info = 0 - if (.not.allocated(p%baseprecv)) then + if (.not.allocated(p%precv)) then info = 3111 write(0,*) name,': Error: uninitialized preconditioner, should call MLD_PRECINIT' return endif - nlev_ = size(p%baseprecv) + nlev_ = size(p%precv) if (present(ilev)) then ilev_ = ilev @@ -115,7 +114,13 @@ subroutine mld_cprecseti(p,what,val,info,ilev) write(0,*) name,': Error: invalid ILEV/NLEV combination',ilev_, nlev_ return endif - if (.not.allocated(p%baseprecv(ilev_)%iprcparm)) then + if (.not.allocated(p%precv(ilev_)%iprcparm)) then + info = 3111 + write(0,*) name,& + &': Error: uninitialized preconditioner component, should call MLD_PRECINIT' + return + endif + if (.not.allocated(p%precv(ilev_)%prec%iprcparm)) then info = 3111 write(0,*) name,& &': Error: uninitialized preconditioner component, should call MLD_PRECINIT' @@ -126,7 +131,7 @@ subroutine mld_cprecseti(p,what,val,info,ilev) ! Set preconditioner parameters at level ilev. ! if (present(ilev)) then - + if (ilev_ == 1) then ! ! Rules for fine level are slightly different. @@ -134,7 +139,7 @@ subroutine mld_cprecseti(p,what,val,info,ilev) select case(what) case(mld_smoother_type_,mld_sub_solve_,mld_sub_restr_,mld_sub_prol_,& & mld_sub_ren_,mld_sub_ovr_,mld_sub_fillin_,mld_smoother_sweeps_) - p%baseprecv(ilev_)%iprcparm(what) = val + p%precv(ilev_)%prec%iprcparm(what) = val case default write(0,*) name,': Error: invalid WHAT' info = -2 @@ -144,23 +149,25 @@ subroutine mld_cprecseti(p,what,val,info,ilev) select case(what) case(mld_smoother_type_,mld_sub_solve_,mld_sub_restr_,mld_sub_prol_,& & mld_sub_ren_,mld_sub_ovr_,mld_sub_fillin_,& - & mld_smoother_sweeps_,mld_ml_type_,mld_aggr_alg_,mld_aggr_kind_,& + & mld_smoother_sweeps_) + p%precv(ilev_)%prec%iprcparm(what) = val + case(mld_ml_type_,mld_aggr_alg_,mld_aggr_kind_,& & mld_smoother_pos_,mld_aggr_omega_alg_,mld_aggr_eig_) - p%baseprecv(ilev_)%iprcparm(what) = val + p%precv(ilev_)%iprcparm(what) = val case(mld_coarse_mat_) if (ilev_ /= nlev_ .and. val /= mld_distr_mat_) then write(0,*) name,': Error: Inconsistent specification of WHAT vs. ILEV' info = -2 return end if - p%baseprecv(ilev_)%iprcparm(mld_coarse_mat_) = val + p%precv(ilev_)%iprcparm(mld_coarse_mat_) = val case(mld_coarse_subsolve_) if (ilev_ /= nlev_) then write(0,*) name,': Error: Inconsistent specification of WHAT vs. ILEV' info = -2 return end if - p%baseprecv(ilev_)%iprcparm(mld_sub_solve_) = val + p%precv(ilev_)%iprcparm(mld_sub_solve_) = val case(mld_coarse_solve_) if (ilev_ /= nlev_) then write(0,*) name,': Error: Inconsistent specification of WHAT vs. ILEV' @@ -169,15 +176,15 @@ subroutine mld_cprecseti(p,what,val,info,ilev) end if if (nlev_ > 1) then - p%baseprecv(nlev_)%iprcparm(mld_coarse_solve_) = val - p%baseprecv(nlev_)%iprcparm(mld_smoother_type_) = mld_bjac_ - p%baseprecv(nlev_)%iprcparm(mld_coarse_mat_) = mld_distr_mat_ + p%precv(nlev_)%iprcparm(mld_coarse_solve_) = val + p%precv(nlev_)%prec%iprcparm(mld_smoother_type_) = mld_bjac_ + p%precv(nlev_)%iprcparm(mld_coarse_mat_) = mld_distr_mat_ select case (val) case(mld_umf_, mld_slu_) - p%baseprecv(nlev_)%iprcparm(mld_coarse_mat_) = mld_repl_mat_ - p%baseprecv(nlev_)%iprcparm(mld_sub_solve_) = val + p%precv(nlev_)%iprcparm(mld_coarse_mat_) = mld_repl_mat_ + p%precv(nlev_)%prec%iprcparm(mld_sub_solve_) = val case(mld_sludist_) - p%baseprecv(nlev_)%iprcparm(mld_sub_solve_) = val + p%precv(nlev_)%prec%iprcparm(mld_sub_solve_) = val end select endif case(mld_coarse_sweeps_) @@ -186,14 +193,14 @@ subroutine mld_cprecseti(p,what,val,info,ilev) info = -2 return end if - p%baseprecv(ilev_)%iprcparm(mld_smoother_sweeps_) = val + p%precv(ilev_)%prec%iprcparm(mld_smoother_sweeps_) = val case(mld_coarse_fillin_) if (ilev_ /= nlev_) then write(0,*) name,': Error: Inconsistent specification of WHAT vs. ILEV' info = -2 return end if - p%baseprecv(ilev_)%iprcparm(mld_sub_fillin_) = val + p%precv(ilev_)%prec%iprcparm(mld_sub_fillin_) = val case default write(0,*) name,': Error: invalid WHAT' info = -2 @@ -211,35 +218,35 @@ subroutine mld_cprecseti(p,what,val,info,ilev) & mld_sub_ren_,mld_sub_ovr_,mld_sub_fillin_,& & mld_smoother_sweeps_) do ilev_=1,max(1,nlev_-1) - if (.not.allocated(p%baseprecv(ilev_)%iprcparm)) then + if (.not.allocated(p%precv(ilev_)%iprcparm)) then write(0,*) name,& &': Error: uninitialized preconditioner component, should call MLD_PRECINIT' info = -1 return endif - p%baseprecv(ilev_)%iprcparm(what) = val + p%precv(ilev_)%prec%iprcparm(what) = val end do case(mld_ml_type_,mld_aggr_alg_,mld_aggr_kind_,& & mld_smoother_pos_,mld_aggr_omega_alg_,mld_aggr_eig_) do ilev_=2,nlev_ - if (.not.allocated(p%baseprecv(ilev_)%iprcparm)) then + if (.not.allocated(p%precv(ilev_)%iprcparm)) then write(0,*) name,& &': Error: uninitialized preconditioner component, should call MLD_PRECINIT' info = -1 return endif - p%baseprecv(ilev_)%iprcparm(what) = val + p%precv(ilev_)%iprcparm(what) = val end do case(mld_coarse_mat_) - if (.not.allocated(p%baseprecv(nlev_)%iprcparm)) then + if (.not.allocated(p%precv(nlev_)%iprcparm)) then write(0,*) name,& & ': Error: uninitialized preconditioner component, should call MLD_PRECINIT' info = -1 return endif - if (nlev_ > 1) p%baseprecv(nlev_)%iprcparm(mld_coarse_mat_) = val + if (nlev_ > 1) p%precv(nlev_)%iprcparm(mld_coarse_mat_) = val case(mld_coarse_solve_) - if (.not.allocated(p%baseprecv(nlev_)%iprcparm)) then + if (.not.allocated(p%precv(nlev_)%iprcparm)) then write(0,*) name,& &': Error: uninitialized preconditioner component, should call MLD_PRECINIT' info = -1 @@ -247,42 +254,42 @@ subroutine mld_cprecseti(p,what,val,info,ilev) endif if (nlev_ > 1) then - p%baseprecv(nlev_)%iprcparm(mld_coarse_solve_) = val - p%baseprecv(nlev_)%iprcparm(mld_smoother_type_) = mld_bjac_ - p%baseprecv(nlev_)%iprcparm(mld_coarse_mat_) = mld_distr_mat_ + p%precv(nlev_)%iprcparm(mld_coarse_solve_) = val + p%precv(nlev_)%prec%iprcparm(mld_smoother_type_) = mld_bjac_ + p%precv(nlev_)%iprcparm(mld_coarse_mat_) = mld_distr_mat_ select case (val) case(mld_umf_, mld_slu_) - p%baseprecv(nlev_)%iprcparm(mld_coarse_mat_) = mld_repl_mat_ - p%baseprecv(nlev_)%iprcparm(mld_sub_solve_) = val + p%precv(nlev_)%iprcparm(mld_coarse_mat_) = mld_repl_mat_ + p%precv(nlev_)%prec%iprcparm(mld_sub_solve_) = val case(mld_sludist_) - p%baseprecv(nlev_)%iprcparm(mld_sub_solve_) = val + p%precv(nlev_)%prec%iprcparm(mld_sub_solve_) = val end select endif case(mld_coarse_subsolve_) - if (.not.allocated(p%baseprecv(nlev_)%iprcparm)) then + if (.not.allocated(p%precv(nlev_)%iprcparm)) then write(0,*) name,& &': Error: uninitialized preconditioner component, should call MLD_PRECINIT' info = -1 return end if - if (nlev_ > 1) p%baseprecv(nlev_)%iprcparm(mld_sub_solve_) = val + if (nlev_ > 1) p%precv(nlev_)%prec%iprcparm(mld_sub_solve_) = val case(mld_coarse_sweeps_) - if (.not.allocated(p%baseprecv(nlev_)%iprcparm)) then + if (.not.allocated(p%precv(nlev_)%iprcparm)) then write(0,*) name,& &': Error: uninitialized preconditioner component, should call MLD_PRECINIT' info = -1 return endif - if (nlev_ > 1) p%baseprecv(nlev_)%iprcparm(mld_smoother_sweeps_) = val + if (nlev_ > 1) p%precv(nlev_)%prec%iprcparm(mld_smoother_sweeps_) = val case(mld_coarse_fillin_) - if (.not.allocated(p%baseprecv(nlev_)%iprcparm)) then + if (.not.allocated(p%precv(nlev_)%iprcparm)) then write(0,*) name,& &': Error: uninitialized preconditioner component, should call MLD_PRECINIT' info = -1 return endif - if (nlev_ > 1) p%baseprecv(nlev_)%iprcparm(mld_sub_fillin_) = val + if (nlev_ > 1) p%precv(nlev_)%prec%iprcparm(mld_sub_fillin_) = val case default write(0,*) name,': Error: invalid WHAT' info = -2 @@ -353,11 +360,11 @@ subroutine mld_cprecsetc(p,what,string,info,ilev) info = 0 - if (.not.allocated(p%baseprecv)) then + if (.not.allocated(p%precv)) then info = 3111 return endif - nlev_ = size(p%baseprecv) + nlev_ = size(p%precv) if (present(ilev)) then ilev_ = ilev @@ -370,7 +377,7 @@ subroutine mld_cprecsetc(p,what,string,info,ilev) info = -1 return endif - if (.not.allocated(p%baseprecv(ilev_)%iprcparm)) then + if (.not.allocated(p%precv(ilev_)%iprcparm)) then write(0,*) name,': Error: uninitialized preconditioner component, should call MLD_PRECINIT' info = 3111 return @@ -450,19 +457,19 @@ subroutine mld_cprecsetr(p,what,val,info,ilev) ilev_ = 1 end if - if (.not.allocated(p%baseprecv)) then + if (.not.allocated(p%precv)) then write(0,*) name,': Error: uninitialized preconditioner, should call MLD_PRECINIT' info = 3111 return endif - nlev_ = size(p%baseprecv) + nlev_ = size(p%precv) if ((ilev_<1).or.(ilev_ > nlev_)) then write(0,*) name,': Error: invalid ILEV/NLEV combination',ilev_, nlev_ info = -1 return endif - if (.not.allocated(p%baseprecv(ilev_)%rprcparm)) then + if (.not.allocated(p%precv(ilev_)%rprcparm)) then write(0,*) name,': Error: uninitialized preconditioner component, should call MLD_PRECINIT' info = 3111 return @@ -479,7 +486,7 @@ subroutine mld_cprecsetr(p,what,val,info,ilev) ! select case(what) case(mld_sub_iluthrs_) - p%baseprecv(ilev_)%rprcparm(what) = val + p%precv(ilev_)%prec%rprcparm(what) = val case default write(0,*) name,': Error: invalid WHAT' info = -2 @@ -487,8 +494,10 @@ subroutine mld_cprecsetr(p,what,val,info,ilev) else if (ilev_ > 1) then select case(what) - case(mld_aggr_omega_val_,mld_aggr_thresh_,mld_sub_iluthrs_) - p%baseprecv(ilev_)%rprcparm(what) = val + case(mld_sub_iluthrs_) + p%precv(ilev_)%prec%rprcparm(what) = val + case(mld_aggr_omega_val_,mld_aggr_thresh_) + p%precv(ilev_)%rprcparm(what) = val case default write(0,*) name,': Error: invalid WHAT' info = -2 @@ -503,38 +512,38 @@ subroutine mld_cprecsetr(p,what,val,info,ilev) select case(what) case(mld_sub_iluthrs_) do ilev_=1,nlev_ - if (.not.allocated(p%baseprecv(ilev_)%rprcparm)) then + if (.not.allocated(p%precv(ilev_)%rprcparm)) then write(0,*) name,': Error: uninitialized preconditioner component, should call MLD_PRECINIT' info = -1 return endif - p%baseprecv(ilev_)%rprcparm(what) = val + p%precv(ilev_)%prec%rprcparm(what) = val end do case(mld_coarse_iluthrs_) ilev_=nlev_ - if (.not.allocated(p%baseprecv(ilev_)%rprcparm)) then + if (.not.allocated(p%precv(ilev_)%rprcparm)) then write(0,*) name,': Error: uninitialized preconditioner component, should call MLD_PRECINIT' info = -1 return endif - p%baseprecv(ilev_)%rprcparm(mld_sub_iluthrs_) = val + p%precv(ilev_)%prec%rprcparm(mld_sub_iluthrs_) = val case(mld_aggr_omega_val_) do ilev_=2,nlev_ - if (.not.allocated(p%baseprecv(ilev_)%rprcparm)) then + if (.not.allocated(p%precv(ilev_)%rprcparm)) then write(0,*) name,': Error: uninitialized preconditioner component, should call MLD_PRECINIT' info = -1 return endif - p%baseprecv(ilev_)%rprcparm(what) = val + p%precv(ilev_)%rprcparm(what) = val end do case(mld_aggr_thresh_) do ilev_=2,nlev_ - if (.not.allocated(p%baseprecv(ilev_)%rprcparm)) then + if (.not.allocated(p%precv(ilev_)%rprcparm)) then write(0,*) name,': Error: uninitialized preconditioner component, should call MLD_PRECINIT' info = -1 return endif - p%baseprecv(ilev_)%rprcparm(what) = val + p%precv(ilev_)%rprcparm(what) = val end do case default write(0,*) name,': Error: invalid WHAT' diff --git a/mlprec/mld_daggrmap_bld.f90 b/mlprec/mld_daggrmap_bld.f90 index 610cd890..48e6ca3b 100644 --- a/mlprec/mld_daggrmap_bld.f90 +++ b/mlprec/mld_daggrmap_bld.f90 @@ -131,7 +131,7 @@ subroutine mld_daggrmap_bld(aggr_type,theta,a,desc_a,nlaggr,ilaggr,info) atmp%m=nr atmp%k=nr if (info == 0) call psb_sp_free(atrans,info) - if (info == 0) call psb_ipcoo2csr(atmp,info) + if (info == 0) call psb_spcnv(atmp,info,afmt='csr') if (info == 0) call mld_dec_map_bld(theta,atmp,desc_a,nlaggr,ilaggr,info) if (info == 0) call psb_sp_free(atmp,info) diff --git a/mlprec/mld_daggrmat_asb.f90 b/mlprec/mld_daggrmat_asb.f90 index 80ed6b30..55df7c27 100644 --- a/mlprec/mld_daggrmat_asb.f90 +++ b/mlprec/mld_daggrmat_asb.f90 @@ -76,24 +76,21 @@ ! 1181-1196. ! ! +! ! Arguments: ! a - type(psb_dspmat_type), input. ! The sparse matrix structure containing the local part of ! the fine-level matrix. ! desc_a - type(psb_desc_type), input. ! The communication descriptor of the fine-level matrix. -! ac - type(psb_dspmat_type), output. -! The sparse matrix structure containing the local part of -! the coarse-level matrix. -! desc_ac - type(psb_desc_type), output. -! The communication descriptor of the coarse-level matrix. -! p - type(mld_dbaseprc_type), input/output. -! The base preconditioner data structure containing the local -! part of the base preconditioner to be built. +! p - type(mld_d_onelev_prec_type), input/output. +! The one-level preconditioner data structure containing the local +! part of the base preconditioner to be built as well as the +! aggregate matrices. ! info - integer, output. ! Error code. ! -subroutine mld_daggrmat_asb(a,desc_a,ac,desc_ac,p,info) +subroutine mld_daggrmat_asb(a,desc_a,p,info) use psb_base_mod use mld_inner_mod, mld_protect_name => mld_daggrmat_asb @@ -103,9 +100,7 @@ subroutine mld_daggrmat_asb(a,desc_a,ac,desc_ac,p,info) ! Arguments type(psb_dspmat_type), intent(in) :: a type(psb_desc_type), intent(in) :: desc_a - type(psb_dspmat_type), intent(out) :: ac - type(psb_desc_type), intent(out) :: desc_ac - type(mld_dbaseprc_type), intent(inout), target :: p + type(mld_d_onelev_prec_type), intent(inout), target :: p integer, intent(out) :: info ! Local variables @@ -125,7 +120,7 @@ subroutine mld_daggrmat_asb(a,desc_a,ac,desc_ac,p,info) select case (p%iprcparm(mld_aggr_kind_)) case (mld_no_smooth_) - call mld_aggrmat_raw_asb(a,desc_a,ac,desc_ac,p,info) + call mld_aggrmat_raw_asb(a,desc_a,p,info) if(info /= 0) then call psb_errpush(4010,name,a_err='mld_aggrmat_raw_asb') goto 9999 @@ -133,7 +128,7 @@ subroutine mld_daggrmat_asb(a,desc_a,ac,desc_ac,p,info) case(mld_smooth_prol_,mld_biz_prol_) - call mld_aggrmat_smth_asb(a,desc_a,ac,desc_ac,p,info) + call mld_aggrmat_smth_asb(a,desc_a,p,info) if(info /= 0) then call psb_errpush(4010,name,a_err='mld_aggrmat_smth_asb') goto 9999 diff --git a/mlprec/mld_daggrmat_raw_asb.F90 b/mlprec/mld_daggrmat_raw_asb.F90 index 53602ed7..c7a54002 100644 --- a/mlprec/mld_daggrmat_raw_asb.F90 +++ b/mlprec/mld_daggrmat_raw_asb.F90 @@ -59,24 +59,21 @@ ! 57 (2007), 1181-1196. ! ! +! ! Arguments: ! a - type(psb_dspmat_type), input. ! The sparse matrix structure containing the local part of ! the fine-level matrix. ! desc_a - type(psb_desc_type), input. ! The communication descriptor of the fine-level matrix. -! ac - type(psb_dspmat_type), output. -! The sparse matrix structure containing the local part of -! the coarse-level matrix. -! desc_ac - type(psb_desc_type), output. -! The communication descriptor of the coarse-level matrix. -! p - type(mld_dbaseprc_type), input/output. -! The base preconditioner data structure containing the local -! part of the base preconditioner to be built. +! p - type(mld_d_onelev_prec_type), input/output. +! The one-level preconditioner data structure containing the local +! part of the base preconditioner to be built as well as the +! aggregate matrices. ! info - integer, output. ! Error code. ! -subroutine mld_daggrmat_raw_asb(a,desc_a,ac,desc_ac,p,info) +subroutine mld_daggrmat_raw_asb(a,desc_a,p,info) use psb_base_mod use mld_inner_mod, mld_protect_name => mld_daggrmat_raw_asb @@ -91,17 +88,15 @@ subroutine mld_daggrmat_raw_asb(a,desc_a,ac,desc_ac,p,info) ! Arguments type(psb_dspmat_type), intent(in) :: a type(psb_desc_type), intent(in) :: desc_a - type(psb_dspmat_type), intent(out) :: ac - type(psb_desc_type), intent(out) :: desc_ac - type(mld_dbaseprc_type), intent(inout), target :: p + type(mld_d_onelev_prec_type), intent(inout), target :: p integer, intent(out) :: info ! Local variables integer ::ictxt,np,me, err_act, icomm character(len=20) :: name type(psb_dspmat_type) :: b - integer, pointer :: nzbr(:), idisp(:) - type(psb_dspmat_type), pointer :: am1,am2 + integer, allocatable :: nzbr(:), idisp(:) + type(psb_dspmat_type) :: am1,am2 integer :: nrow, nglob, ncol, ntaggr, nzac, ip, ndx,& & naggr, nzt, naggrm1, i @@ -119,9 +114,6 @@ subroutine mld_daggrmat_raw_asb(a,desc_a,ac,desc_ac,p,info) nrow = psb_cd_get_local_rows(desc_a) ncol = psb_cd_get_local_cols(desc_a) - - am2 => p%av(mld_sm_pr_t_) - am1 => p%av(mld_sm_pr_) call psb_nullify_sp(am1) call psb_nullify_sp(am2) @@ -195,7 +187,7 @@ subroutine mld_daggrmat_raw_asb(a,desc_a,ac,desc_ac,p,info) if (p%iprcparm(mld_coarse_mat_) == mld_repl_mat_) then - call psb_cdall(ictxt,desc_ac,info,mg=ntaggr,repl=.true.) + call psb_cdall(ictxt,p%desc_ac,info,mg=ntaggr,repl=.true.) if(info /= 0) then call psb_errpush(4010,name,a_err='psb_cdall') goto 9999 @@ -206,7 +198,7 @@ subroutine mld_daggrmat_raw_asb(a,desc_a,ac,desc_ac,p,info) call psb_sum(ictxt,nzbr(1:np)) nzac = sum(nzbr) - call psb_sp_all(ntaggr,ntaggr,ac,nzac,info) + call psb_sp_all(ntaggr,ntaggr,p%ac,nzac,info) if(info /= 0) then call psb_errpush(4010,name,a_err='sp_all') goto 9999 @@ -217,11 +209,11 @@ subroutine mld_daggrmat_raw_asb(a,desc_a,ac,desc_ac,p,info) enddo ndx = nzbr(me+1) - call mpi_allgatherv(b%aspk,ndx,mpi_double_precision,ac%aspk,nzbr,idisp,& + call mpi_allgatherv(b%aspk,ndx,mpi_double_precision,p%ac%aspk,nzbr,idisp,& & mpi_double_precision,icomm,info) - call mpi_allgatherv(b%ia1,ndx,mpi_integer,ac%ia1,nzbr,idisp,& + call mpi_allgatherv(b%ia1,ndx,mpi_integer,p%ac%ia1,nzbr,idisp,& & mpi_integer,icomm,info) - call mpi_allgatherv(b%ia2,ndx,mpi_integer,ac%ia2,nzbr,idisp,& + call mpi_allgatherv(b%ia2,ndx,mpi_integer,p%ac%ia2,nzbr,idisp,& & mpi_integer,icomm,info) if(info /= 0) then info=-1 @@ -229,12 +221,12 @@ subroutine mld_daggrmat_raw_asb(a,desc_a,ac,desc_ac,p,info) goto 9999 end if - ac%m = ntaggr - ac%k = ntaggr - ac%infoa(psb_nnz_) = nzac - ac%fida='COO' - ac%descra='GUN' - call psb_spcnv(ac,info,afmt='coo',dupl=psb_dupl_add_) + p%ac%m = ntaggr + p%ac%k = ntaggr + p%ac%infoa(psb_nnz_) = nzac + p%ac%fida='COO' + p%ac%descra='GUN' + call psb_spcnv(p%ac,info,afmt='coo',dupl=psb_dupl_add_) if(info /= 0) then call psb_errpush(4010,name,a_err='sp_free') goto 9999 @@ -242,9 +234,9 @@ subroutine mld_daggrmat_raw_asb(a,desc_a,ac,desc_ac,p,info) else if (p%iprcparm(mld_coarse_mat_) == mld_distr_mat_) then - call psb_cdall(ictxt,desc_ac,info,nl=naggr) - if (info == 0) call psb_cdasb(desc_ac,info) - if (info == 0) call psb_sp_clone(b,ac,info) + call psb_cdall(ictxt,p%desc_ac,info,nl=naggr) + if (info == 0) call psb_cdasb(p%desc_ac,info) + if (info == 0) call psb_sp_clone(b,p%ac,info) if(info /= 0) then call psb_errpush(4001,name,a_err='Build ac, desc_ac') goto 9999 @@ -263,9 +255,23 @@ subroutine mld_daggrmat_raw_asb(a,desc_a,ac,desc_ac,p,info) deallocate(nzbr,idisp) - call psb_spcnv(ac,info,afmt='csr',dupl=psb_dupl_add_) + call psb_spcnv(p%ac,info,afmt='csr',dupl=psb_dupl_add_) + if(info /= 0) then + call psb_errpush(4010,name,a_err='spcnv') + goto 9999 + end if + + ! + ! Copy the prolongation/restriction matrices into the descriptor map. + ! am2 => PR^T i.e. restriction operator + ! am1 => PR i.e. prolongation operator + ! + p%map_desc = psb_inter_desc(psb_map_aggr_,desc_a,& + & p%desc_ac,am2,am1) + if (info == 0) call psb_sp_free(am1,info) + if (info == 0) call psb_sp_free(am2,info) if(info /= 0) then - call psb_errpush(4010,name,a_err='ipcoo2csr') + call psb_errpush(4010,name,a_err='sp_Free') goto 9999 end if diff --git a/mlprec/mld_daggrmat_smth_asb.F90 b/mlprec/mld_daggrmat_smth_asb.F90 index c8df6c02..3563afe4 100644 --- a/mlprec/mld_daggrmat_smth_asb.F90 +++ b/mlprec/mld_daggrmat_smth_asb.F90 @@ -83,18 +83,14 @@ ! the fine-level matrix. ! desc_a - type(psb_desc_type), input. ! The communication descriptor of the fine-level matrix. -! ac - type(psb_dspmat_type), output. -! The sparse matrix structure containing the local part of -! the coarse-level matrix. -! desc_ac - type(psb_desc_type), output. -! The communication descriptor of the coarse-level matrix. -! p - type(mld_dbaseprc_type), input/output. -! The base preconditioner data structure containing the local -! part of the base preconditioner to be built. +! p - type(mld_d_onelev_prec_type), input/output. +! The one-level preconditioner data structure containing the local +! part of the base preconditioner to be built as well as the +! aggregate matrices. ! info - integer, output. ! Error code. ! -subroutine mld_daggrmat_smth_asb(a,desc_a,ac,desc_ac,p,info) +subroutine mld_daggrmat_smth_asb(a,desc_a,p,info) use psb_base_mod use mld_inner_mod, mld_protect_name => mld_daggrmat_smth_asb @@ -109,19 +105,17 @@ subroutine mld_daggrmat_smth_asb(a,desc_a,ac,desc_ac,p,info) ! Arguments type(psb_dspmat_type), intent(in) :: a type(psb_desc_type), intent(in) :: desc_a - type(psb_dspmat_type), intent(out) :: ac - type(psb_desc_type), intent(out) :: desc_ac - type(mld_dbaseprc_type), intent(inout), target :: p + type(mld_d_onelev_prec_type), intent(inout), target :: p integer, intent(out) :: info ! Local variables type(psb_dspmat_type) :: b - integer, pointer :: nzbr(:), idisp(:) + integer, allocatable :: nzbr(:), idisp(:) integer :: nrow, nglob, ncol, ntaggr, nzac, ip, ndx,& & naggr, nzl,naggrm1,naggrp1, i, j, k integer ::ictxt,np,me, err_act, icomm character(len=20) :: name - type(psb_dspmat_type), pointer :: am1,am2 + type(psb_dspmat_type) :: am1,am2 type(psb_dspmat_type) :: am3,am4 real(psb_dpk_), allocatable :: adiag(:) logical :: ml_global_nmb @@ -146,9 +140,6 @@ subroutine mld_daggrmat_smth_asb(a,desc_a,ac,desc_ac,p,info) call psb_nullify_sp(b) call psb_nullify_sp(am3) call psb_nullify_sp(am4) - - am2 => p%av(mld_sm_pr_t_) - am1 => p%av(mld_sm_pr_) call psb_nullify_sp(am1) call psb_nullify_sp(am2) @@ -456,16 +447,16 @@ subroutine mld_daggrmat_smth_asb(a,desc_a,ac,desc_ac,p,info) case(mld_distr_mat_) - call psb_sp_clone(b,ac,info) - nzac = ac%infoa(psb_nnz_) - nzl = ac%infoa(psb_nnz_) - if (info == 0) call psb_cdall(ictxt,desc_ac,info,nl=p%nlaggr(me+1)) - if (info == 0) call psb_cdins(nzl,ac%ia1,ac%ia2,desc_ac,info) - if (info == 0) call psb_cdasb(desc_ac,info) - if (info == 0) call psb_glob_to_loc(ac%ia1(1:nzl),desc_ac,info,iact='I') - if (info == 0) call psb_glob_to_loc(ac%ia2(1:nzl),desc_ac,info,iact='I') + call psb_sp_clone(b,p%ac,info) + nzac = p%ac%infoa(psb_nnz_) + nzl = p%ac%infoa(psb_nnz_) + if (info == 0) call psb_cdall(ictxt,p%desc_ac,info,nl=p%nlaggr(me+1)) + if (info == 0) call psb_cdins(nzl,p%ac%ia1,p%ac%ia2,p%desc_ac,info) + if (info == 0) call psb_cdasb(p%desc_ac,info) + if (info == 0) call psb_glob_to_loc(p%ac%ia1(1:nzl),p%desc_ac,info,iact='I') + if (info == 0) call psb_glob_to_loc(p%ac%ia2(1:nzl),p%desc_ac,info,iact='I') if (info /= 0) then - call psb_errpush(4001,name,a_err='Creating desc_ac and converting ac') + call psb_errpush(4001,name,a_err='Creating p%desc_ac and converting ac') goto 9999 end if if (debug_level >= psb_debug_outer_) & @@ -473,10 +464,10 @@ subroutine mld_daggrmat_smth_asb(a,desc_a,ac,desc_ac,p,info) & 'Assembld aux descr. distr.' - ac%m=desc_ac%matrix_data(psb_n_row_) - ac%k=desc_ac%matrix_data(psb_n_col_) - ac%fida='COO' - ac%descra='GUN' + p%ac%m=psb_cd_get_local_rows(p%desc_ac) + p%ac%k=psb_cd_get_local_cols(p%desc_ac) + p%ac%fida='COO' + p%ac%descra='GUN' call psb_sp_free(b,info) if (info == 0) deallocate(nzbr,idisp,stat=info) @@ -487,25 +478,25 @@ subroutine mld_daggrmat_smth_asb(a,desc_a,ac,desc_ac,p,info) if (np>1) then nzl = psb_sp_get_nnzeros(am1) - call psb_glob_to_loc(am1%ia1(1:nzl),desc_ac,info,'I') + call psb_glob_to_loc(am1%ia1(1:nzl),p%desc_ac,info,'I') if(info /= 0) then call psb_errpush(4010,name,a_err='psb_glob_to_loc') goto 9999 end if endif - am1%k=desc_ac%matrix_data(psb_n_col_) + am1%k=psb_cd_get_local_cols(p%desc_ac) if (np>1) then call psb_spcnv(am2,info,afmt='coo',dupl=psb_dupl_add_) nzl = am2%infoa(psb_nnz_) - if (info == 0) call psb_glob_to_loc(am2%ia1(1:nzl),desc_ac,info,'I') + if (info == 0) call psb_glob_to_loc(am2%ia1(1:nzl),p%desc_ac,info,'I') if (info == 0) call psb_spcnv(am2,info,afmt='csr',dupl=psb_dupl_add_) if(info /= 0) then call psb_errpush(4001,name,a_err='Converting am2 to local') goto 9999 end if end if - am2%m=desc_ac%matrix_data(psb_n_col_) + am2%m=psb_cd_get_local_cols(p%desc_ac) if (debug_level >= psb_debug_outer_) & & write(debug_unit,*) me,' ',trim(name),& @@ -514,13 +505,13 @@ subroutine mld_daggrmat_smth_asb(a,desc_a,ac,desc_ac,p,info) case(mld_repl_mat_) ! ! - call psb_cdall(ictxt,desc_ac,info,mg=ntaggr,repl=.true.) + call psb_cdall(ictxt,p%desc_ac,info,mg=ntaggr,repl=.true.) nzbr(:) = 0 nzbr(me+1) = b%infoa(psb_nnz_) call psb_sum(ictxt,nzbr(1:np)) nzac = sum(nzbr) - if (info == 0) call psb_sp_all(ntaggr,ntaggr,ac,nzac,info) + if (info == 0) call psb_sp_all(ntaggr,ntaggr,p%ac,nzac,info) if (info /= 0) goto 9999 do ip=1,np @@ -528,11 +519,11 @@ subroutine mld_daggrmat_smth_asb(a,desc_a,ac,desc_ac,p,info) enddo ndx = nzbr(me+1) - call mpi_allgatherv(b%aspk,ndx,mpi_double_precision,ac%aspk,nzbr,idisp,& + call mpi_allgatherv(b%aspk,ndx,mpi_double_precision,p%ac%aspk,nzbr,idisp,& & mpi_double_precision,icomm,info) - if (info == 0) call mpi_allgatherv(b%ia1,ndx,mpi_integer,ac%ia1,nzbr,idisp,& + if (info == 0) call mpi_allgatherv(b%ia1,ndx,mpi_integer,p%ac%ia1,nzbr,idisp,& & mpi_integer,icomm,info) - if (info == 0) call mpi_allgatherv(b%ia2,ndx,mpi_integer,ac%ia2,nzbr,idisp,& + if (info == 0) call mpi_allgatherv(b%ia2,ndx,mpi_integer,p%ac%ia2,nzbr,idisp,& & mpi_integer,icomm,info) if (info /= 0) then @@ -540,12 +531,12 @@ subroutine mld_daggrmat_smth_asb(a,desc_a,ac,desc_ac,p,info) goto 9999 end if - ac%m = ntaggr - ac%k = ntaggr - ac%infoa(psb_nnz_) = nzac - ac%fida='COO' - ac%descra='GUN' - call psb_spcnv(ac,info,afmt='coo',dupl=psb_dupl_add_) + p%ac%m = ntaggr + p%ac%k = ntaggr + p%ac%infoa(psb_nnz_) = nzac + p%ac%fida='COO' + p%ac%descra='GUN' + call psb_spcnv(p%ac,info,afmt='coo',dupl=psb_dupl_add_) if(info /= 0) goto 9999 call psb_sp_free(b,info) if(info /= 0) goto 9999 @@ -569,9 +560,9 @@ subroutine mld_daggrmat_smth_asb(a,desc_a,ac,desc_ac,p,info) case(mld_distr_mat_) - call psb_sp_clone(b,ac,info) - if (info == 0) call psb_cdall(ictxt,desc_ac,info,nl=naggr) - if (info == 0) call psb_cdasb(desc_ac,info) + call psb_sp_clone(b,p%ac,info) + if (info == 0) call psb_cdall(ictxt,p%desc_ac,info,nl=naggr) + if (info == 0) call psb_cdasb(p%desc_ac,info) if (info == 0) call psb_sp_free(b,info) if (info /= 0) then call psb_errpush(4010,name,a_err='Build desc_ac, ac') @@ -582,7 +573,7 @@ subroutine mld_daggrmat_smth_asb(a,desc_a,ac,desc_ac,p,info) case(mld_repl_mat_) ! ! - call psb_cdall(ictxt,desc_ac,info,mg=ntaggr,repl=.true.) + call psb_cdall(ictxt,p%desc_ac,info,mg=ntaggr,repl=.true.) if(info /= 0) then call psb_errpush(4010,name,a_err='psb_cdall') goto 9999 @@ -592,7 +583,7 @@ subroutine mld_daggrmat_smth_asb(a,desc_a,ac,desc_ac,p,info) nzbr(me+1) = b%infoa(psb_nnz_) call psb_sum(ictxt,nzbr(1:np)) nzac = sum(nzbr) - call psb_sp_all(ntaggr,ntaggr,ac,nzac,info) + call psb_sp_all(ntaggr,ntaggr,p%ac,nzac,info) if(info /= 0) then call psb_errpush(4010,name,a_err='psb_sp_all') goto 9999 @@ -603,11 +594,11 @@ subroutine mld_daggrmat_smth_asb(a,desc_a,ac,desc_ac,p,info) enddo ndx = nzbr(me+1) - call mpi_allgatherv(b%aspk,ndx,mpi_double_precision,ac%aspk,nzbr,idisp,& + call mpi_allgatherv(b%aspk,ndx,mpi_double_precision,p%ac%aspk,nzbr,idisp,& & mpi_double_precision,icomm,info) - if (info == 0) call mpi_allgatherv(b%ia1,ndx,mpi_integer,ac%ia1,nzbr,idisp,& + if (info == 0) call mpi_allgatherv(b%ia1,ndx,mpi_integer,p%ac%ia1,nzbr,idisp,& & mpi_integer,icomm,info) - if (info == 0) call mpi_allgatherv(b%ia2,ndx,mpi_integer,ac%ia2,nzbr,idisp,& + if (info == 0) call mpi_allgatherv(b%ia2,ndx,mpi_integer,p%ac%ia2,nzbr,idisp,& & mpi_integer,icomm,info) if (info /= 0) then call psb_errpush(4001,name,a_err=' from mpi_allgatherv') @@ -615,12 +606,12 @@ subroutine mld_daggrmat_smth_asb(a,desc_a,ac,desc_ac,p,info) end if - ac%m = ntaggr - ac%k = ntaggr - ac%infoa(psb_nnz_) = nzac - ac%fida='COO' - ac%descra='GUN' - call psb_spcnv(ac,info,afmt='coo',dupl=psb_dupl_add_) + p%ac%m = ntaggr + p%ac%k = ntaggr + p%ac%infoa(psb_nnz_) = nzac + p%ac%fida='COO' + p%ac%descra='GUN' + call psb_spcnv(p%ac,info,afmt='coo',dupl=psb_dupl_add_) if(info /= 0) then call psb_errpush(4010,name,a_err='spcnv') goto 9999 @@ -651,12 +642,27 @@ subroutine mld_daggrmat_smth_asb(a,desc_a,ac,desc_ac,p,info) end select - call psb_spcnv(ac,info,afmt='csr',dupl=psb_dupl_add_) + call psb_spcnv(p%ac,info,afmt='csr',dupl=psb_dupl_add_) if(info /= 0) then call psb_errpush(4010,name,a_err='spcnv') goto 9999 end if + ! + ! Copy the prolongation/restriction matrices into the descriptor map. + ! am2 => PR^T i.e. restriction operator + ! am1 => PR i.e. prolongation operator + ! + p%map_desc = psb_inter_desc(psb_map_aggr_,desc_a,& + & p%desc_ac,am2,am1) + if (info == 0) call psb_sp_free(am1,info) + if (info == 0) call psb_sp_free(am2,info) + if(info /= 0) then + call psb_errpush(4010,name,a_err='sp_Free') + goto 9999 + end if + + if (debug_level >= psb_debug_outer_) & & write(debug_unit,*) me,' ',trim(name),& & 'Done smooth_aggregate ' diff --git a/mlprec/mld_dbaseprec_bld.f90 b/mlprec/mld_dbaseprec_bld.f90 index b33f194f..0bed4616 100644 --- a/mlprec/mld_dbaseprec_bld.f90 +++ b/mlprec/mld_dbaseprec_bld.f90 @@ -197,8 +197,6 @@ subroutine mld_dbaseprc_bld(a,desc_a,p,info,upd) end select - p%base_a => a - p%base_desc => desc_a p%iprcparm(mld_prec_status_) = mld_prec_built_ if (debug_level >= psb_debug_outer_) & & write(debug_unit,*) me,' ',trim(name),': Done' diff --git a/mlprec/mld_dmlprec_aply.f90 b/mlprec/mld_dmlprec_aply.f90 index 94306d42..c7001e8b 100644 --- a/mlprec/mld_dmlprec_aply.f90 +++ b/mlprec/mld_dmlprec_aply.f90 @@ -46,7 +46,7 @@ ! Y = beta*Y + alpha*op(M^(-1))*X, ! where ! - M is a multilevel domain decomposition (Schwarz) preconditioner associated -! to a certain matrix A and stored in the array baseprecv, +! to a certain matrix A and stored in the array precv, ! - op(M^(-1)) is M^(-1) or its transpose, according to the value of trans, ! - X and Y are vectors, ! - alpha and beta are scalars. @@ -55,9 +55,9 @@ ! level where we might have a replicated index space) and each process takes care ! of one submatrix. ! -! The multilevel preconditioner M is regarded as an array of 'base preconditioners', +! The multilevel preconditioner M is regarded as an array of 'one-level preconditioners', ! each representing the part of the preconditioner associated to a certain level. -! For each level ilev, the base preconditioner K(ilev) is stored in baseprecv(ilev) +! For each level ilev, the preconditioner K(ilev) is stored in precv(ilev) ! and is associated to a matrix A(ilev), obtained by 'tranferring' the original ! matrix A (i.e. the matrix to be preconditioned) to the level ilev, through smoothed ! aggregation. @@ -78,66 +78,43 @@ ! Arguments: ! alpha - real(psb_dpk_), input. ! The scalar alpha. -! baseprecv - type(mld_dbaseprc_type), dimension(:), input. -! The array of base preconditioner data structures containing the +! precv - type(mld_d_onelev_prec_type), dimension(:), input. +! The array of one-level preconditioner data structures containing the ! local parts of the preconditioners to be applied at each level. -! Note that nlev = size(baseprecv) = number of levels. -! baseprecv(ilev)%av - type(psb_dspmat_type), dimension(:), allocatable(:). -! The sparse matrices needed to apply the preconditioner -! at level ilev. -! baseprecv(ilev)%av(mld_l_pr_) - The L factor of the ILU factorization of -! the local diagonal block of A(ilev). -! baseprecv(ilev)%av(mld_u_pr_) - The U factor of the ILU factorization of the -! local diagonal block of A(ilev), except its -! diagonal entries (stored in baseprecv(ilev)%d). -! baseprecv(ilev)%av(mld_ap_nd_) - The entries of the local part of A(ilev) -! outside the diagonal block, for block-Jacobi -! sweeps. -! baseprecv(ilev)%av(mld_ac_) - The local part of the matrix A(ilev). -! baseprecv(ilev)%av(mld_sm_pr_) - The smoothed prolongator. -! It maps vectors (ilev) ---> (ilev-1). -! baseprecv(ilev)%av(mld_sm_pr_t_) - The smoothed prolongator transpose. -! It maps vectors (ilev-1) ---> (ilev). -! baseprecv(ilev)%d - real(psb_dpk_), dimension(:), allocatable. -! The diagonal entries of the U factor in the ILU -! factorization of A(ilev). -! baseprecv(ilev)%desc_data - type(psb_desc_type). -! The communication descriptor associated to the base -! preconditioner, i.e. to the sparse matrices needed -! to apply the base preconditioner at the current level. -! baseprecv(ilev)%desc_ac - type(psb_desc_type). -! The communication descriptor associated to the sparse -! matrix A(ilev), stored in baseprecv(ilev)%av(mld_ac_). -! baseprecv(ilev)%iprcparm - integer, dimension(:), allocatable. -! The integer parameters defining the base -! preconditioner K(ilev). -! baseprecv(ilev)%rprcparm - real(psb_dpk_), dimension(:), allocatable. -! The real parameters defining the base preconditioner -! K(ilev). -! baseprecv(ilev)%perm - integer, dimension(:), allocatable. -! The row and column permutations applied to the local -! part of A(ilev) (defined only if baseprecv(ilev)% -! iprcparm(mld_sub_ren_)>0). -! baseprecv(ilev)%invperm - integer, dimension(:), allocatable. -! The inverse of the permutation stored in -! baseprecv(ilev)%perm. -! baseprecv(ilev)%mlia - integer, dimension(:), allocatable. -! The aggregation map (ilev-1) --> (ilev). -! In case of non-smoothed aggregation, it is used -! instead of mld_sm_pr_. -! baseprecv(ilev)%nlaggr - integer, dimension(:), allocatable. -! The number of aggregates (rows of A(ilev)) on the -! various processes. -! baseprecv(ilev)%base_a - type(psb_dspmat_type), pointer. -! Pointer (really a pointer!) to the base matrix of -! the current level, i.e. the local part of A(ilev); -! so we have a unified treatment of residuals. We -! need this to avoid passing explicitly the matrix -! A(ilev) to the routine which applies the -! preconditioner. -! baseprecv(ilev)%base_desc - type(psb_desc_type), pointer. -! Pointer to the communication descriptor associated -! to the sparse matrix pointed by base_a. +! Note that nlev = size(precv) = number of levels. +! precv(ilev)%prec - type(psb_dbaseprc_type) +! The "base" preconditioner for the current level +! precv(ilev)%ac - type(psb_dspmat_type) +! The local part of the matrix A(ilev). +! precv(ilev)%desc_ac - type(psb_desc_type). +! The communication descriptor associated to the sparse +! matrix A(ilev) +! precv(ilev)%map_desc - type(psb_inter_desc_type) +! Stores the linear operators mapping between levels +! (ilev-1) and (ilev). These are the restriction and +! prolongation operators described in the sequel. +! precv(ilev)%iprcparm - integer, dimension(:), allocatable. +! The integer parameters defining the multilevel +! strategy +! precv(ilev)%rprcparm - real(psb_dpk_), dimension(:), allocatable. +! The real parameters defining the multilevel strategy +! precv(ilev)%mlia - integer, dimension(:), allocatable. +! The aggregation map (ilev-1) --> (ilev). +! In case of non-smoothed aggregation, it is used +! instead of mld_sm_pr_. +! precv(ilev)%nlaggr - integer, dimension(:), allocatable. +! The number of aggregates (rows of A(ilev)) on the +! various processes. +! precv(ilev)%base_a - type(psb_dspmat_type), pointer. +! Pointer (really a pointer!) to the base matrix of +! the current level, i.e. the local part of A(ilev); +! so we have a unified treatment of residuals. We +! need this to avoid passing explicitly the matrix +! A(ilev) to the routine which applies the +! preconditioner. +! precv(ilev)%base_desc - type(psb_desc_type), pointer. +! Pointer to the communication descriptor associated +! to the sparse matrix pointed by base_a. ! ! x - real(psb_dpk_), dimension(:), input. ! The local part of the vector X. @@ -159,10 +136,10 @@ ! Note that when the LU factorization of the matrix A(ilev) is computed instead of ! the ILU one, by using UMFPACK or SuperLU, the corresponding L and U factors ! are stored in data structures provided by UMFPACK or SuperLU and pointed by -! baseprecv(ilev)%iprcparm(mld_umf_ptr) or baseprecv(ilev)%iprcparm(mld_slu_ptr), +! precv(ilev)%prec%iprcparm(mld_umf_ptr) or precv(ilev)%prec%iprcparm(mld_slu_ptr), ! respectively. ! -subroutine mld_dmlprec_aply(alpha,baseprecv,x,beta,y,desc_data,trans,work,info) +subroutine mld_dmlprec_aply(alpha,precv,x,beta,y,desc_data,trans,work,info) use psb_base_mod use mld_inner_mod, mld_protect_name => mld_dmlprec_aply @@ -171,7 +148,7 @@ subroutine mld_dmlprec_aply(alpha,baseprecv,x,beta,y,desc_data,trans,work,info) ! Arguments type(psb_desc_type),intent(in) :: desc_data - type(mld_dbaseprc_type), intent(in) :: baseprecv(:) + type(mld_d_onelev_prec_type), intent(in) :: precv(:) real(psb_dpk_),intent(in) :: alpha,beta real(psb_dpk_),intent(in) :: x(:) real(psb_dpk_),intent(inout) :: y(:) @@ -196,11 +173,11 @@ subroutine mld_dmlprec_aply(alpha,baseprecv,x,beta,y,desc_data,trans,work,info) if (debug_level >= psb_debug_inner_) & & write(debug_unit,*) me,' ',trim(name),& - & ' Entry ', size(baseprecv) + & ' Entry ', size(precv) trans_ = psb_toupper(trans) - select case(baseprecv(2)%iprcparm(mld_ml_type_)) + select case(precv(2)%iprcparm(mld_ml_type_)) case(mld_no_ml_) ! @@ -214,7 +191,7 @@ subroutine mld_dmlprec_aply(alpha,baseprecv,x,beta,y,desc_data,trans,work,info) ! Additive multilevel ! - call add_ml_aply(alpha,baseprecv,x,beta,y,desc_data,trans_,work,info) + call add_ml_aply(alpha,precv,x,beta,y,desc_data,trans_,work,info) case(mld_mult_ml_) ! @@ -225,15 +202,15 @@ subroutine mld_dmlprec_aply(alpha,baseprecv,x,beta,y,desc_data,trans,work,info) ! Note that the transpose switches pre <-> post. ! - select case(baseprecv(2)%iprcparm(mld_smoother_pos_)) + select case(precv(2)%iprcparm(mld_smoother_pos_)) case(mld_post_smooth_) select case (trans_) case('N') - call mlt_post_ml_aply(alpha,baseprecv,x,beta,y,desc_data,trans_,work,info) + call mlt_post_ml_aply(alpha,precv,x,beta,y,desc_data,trans_,work,info) case('T','C') - call mlt_pre_ml_aply(alpha,baseprecv,x,beta,y,desc_data,trans_,work,info) + call mlt_pre_ml_aply(alpha,precv,x,beta,y,desc_data,trans_,work,info) case default info = 4001 call psb_errpush(info,name,a_err='invalid trans') @@ -244,9 +221,9 @@ subroutine mld_dmlprec_aply(alpha,baseprecv,x,beta,y,desc_data,trans,work,info) select case (trans_) case('N') - call mlt_pre_ml_aply(alpha,baseprecv,x,beta,y,desc_data,trans_,work,info) + call mlt_pre_ml_aply(alpha,precv,x,beta,y,desc_data,trans_,work,info) case('T','C') - call mlt_post_ml_aply(alpha,baseprecv,x,beta,y,desc_data,trans_,work,info) + call mlt_post_ml_aply(alpha,precv,x,beta,y,desc_data,trans_,work,info) case default info = 4001 call psb_errpush(info,name,a_err='invalid trans') @@ -255,12 +232,12 @@ subroutine mld_dmlprec_aply(alpha,baseprecv,x,beta,y,desc_data,trans,work,info) case(mld_twoside_smooth_) - call mlt_twoside_ml_aply(alpha,baseprecv,x,beta,y,desc_data,trans_,work,info) + call mlt_twoside_ml_aply(alpha,precv,x,beta,y,desc_data,trans_,work,info) case default info = 4013 call psb_errpush(info,name,a_err='invalid smooth_pos',& - & i_Err=(/baseprecv(2)%iprcparm(mld_smoother_pos_),0,0,0,0/)) + & i_Err=(/precv(2)%iprcparm(mld_smoother_pos_),0,0,0,0/)) goto 9999 end select @@ -268,7 +245,7 @@ subroutine mld_dmlprec_aply(alpha,baseprecv,x,beta,y,desc_data,trans,work,info) case default info = 4013 call psb_errpush(info,name,a_err='invalid mltype',& - & i_Err=(/baseprecv(2)%iprcparm(mld_ml_type_),0,0,0,0/)) + & i_Err=(/precv(2)%iprcparm(mld_ml_type_),0,0,0,0/)) goto 9999 end select @@ -295,7 +272,7 @@ contains ! Y = beta*Y + alpha*op(M^(-1))*X, ! where ! - M is an additive multilevel domain decomposition (Schwarz) preconditioner - ! associated to a certain matrix A and stored in the array baseprecv, + ! associated to a certain matrix A and stored in the array precv, ! - op(M^(-1)) is M^(-1) or its transpose, according to the value of trans, ! - X and Y are vectors, ! - alpha and beta are scalars. @@ -307,9 +284,9 @@ contains ! level where we might have a replicated index space) and each process takes care ! of one submatrix. ! - ! The multilevel preconditioner M is regarded as an array of 'base preconditioners', + ! The multilevel preconditioner M is regarded as an array of 'one-level preconditioners', ! each representing the part of the preconditioner associated to a certain level. - ! For each level ilev, the base preconditioner K(ilev) is stored in baseprecv(ilev) + ! For each level ilev, the base preconditioner K(ilev) is stored in precv(ilev) ! and is associated to a matrix A(ilev), obtained by 'tranferring' the original ! matrix A (i.e. the matrix to be preconditioned) to the level ilev, through smoothed ! aggregation. @@ -357,13 +334,13 @@ contains ! ! 4. Yext = beta*Yext + alpha*Y(1) ! - subroutine add_ml_aply(alpha,baseprecv,x,beta,y,desc_data,trans,work,info) + subroutine add_ml_aply(alpha,precv,x,beta,y,desc_data,trans,work,info) implicit none ! Arguments type(psb_desc_type),intent(in) :: desc_data - type(mld_dbaseprc_type), intent(in) :: baseprecv(:) + type(mld_d_onelev_prec_type), intent(in) :: precv(:) real(psb_dpk_),intent(in) :: alpha,beta real(psb_dpk_),intent(in) :: x(:) real(psb_dpk_),intent(inout) :: y(:) @@ -372,10 +349,9 @@ contains integer, intent(out) :: info ! Local variables - integer :: n_row,n_col integer :: ictxt,np,me,i, nr2l,nc2l,err_act integer :: debug_level, debug_unit - integer :: ismth, nlev, ilev, icm + integer :: nlev, ilev character(len=20) :: name type psb_mlprec_wrk_type @@ -394,9 +370,9 @@ contains if (debug_level >= psb_debug_inner_) & & write(debug_unit,*) me,' ',trim(name),& - & ' Entry ', size(baseprecv) + & ' Entry ', size(precv) - nlev = size(baseprecv) + nlev = size(precv) allocate(mlprec_wrk(nlev),stat=info) if (info /= 0) then call psb_errpush(4010,name,a_err='Allocate') @@ -419,8 +395,8 @@ contains mlprec_wrk(1)%x2l(:) = x(:) mlprec_wrk(1)%y2l(:) = dzero - call mld_baseprec_aply(alpha,baseprecv(1),x,beta,y,& - & baseprecv(1)%base_desc,trans,work,info) + call mld_baseprec_aply(alpha,precv(1)%prec,x,beta,y,& + & precv(1)%base_desc,trans,work,info) if (info /=0) then call psb_errpush(4010,name,a_err='baseprec_aply') goto 9999 @@ -431,40 +407,33 @@ contains ! For each level except the finest one ... ! do ilev = 2, nlev - n_row = psb_cd_get_local_rows(baseprecv(ilev-1)%base_desc) - n_col = psb_cd_get_local_cols(baseprecv(ilev-1)%base_desc) - nc2l = psb_cd_get_local_cols(baseprecv(ilev)%base_desc) - nr2l = psb_cd_get_local_rows(baseprecv(ilev)%base_desc) + nc2l = psb_cd_get_local_cols(precv(ilev)%base_desc) + nr2l = psb_cd_get_local_rows(precv(ilev)%base_desc) allocate(mlprec_wrk(ilev)%x2l(nc2l),mlprec_wrk(ilev)%y2l(nc2l),& & stat=info) if (info /= 0) then info=4025 - call psb_errpush(info,name,i_err=(/2*(nc2l+max(n_row,n_col)),0,0,0,0/),& + call psb_errpush(info,name,i_err=(/2*nc2l,0,0,0,0/),& & a_err='real(psb_dpk_)') goto 9999 end if - - ismth = baseprecv(ilev)%iprcparm(mld_aggr_kind_) - icm = baseprecv(ilev)%iprcparm(mld_coarse_mat_) ! Apply prolongator transpose, i.e. restriction call psb_forward_map(done,mlprec_wrk(ilev-1)%x2l,& & dzero,mlprec_wrk(ilev)%x2l,& - & baseprecv(ilev)%map_desc,info,work=work) - + & precv(ilev)%map_desc,info,work=work) if (info /=0) then call psb_errpush(4001,name,a_err='Error during restriction') goto 9999 end if - ! ! Apply the base preconditioner ! - call mld_baseprec_aply(done,baseprecv(ilev),& + call mld_baseprec_aply(done,precv(ilev)%prec,& & mlprec_wrk(ilev)%x2l,dzero,mlprec_wrk(ilev)%y2l,& - & baseprecv(ilev)%base_desc, trans,work,info) + & precv(ilev)%base_desc, trans,work,info) enddo @@ -475,19 +444,15 @@ contains ! do ilev =nlev,2,-1 - n_row = psb_cd_get_local_rows(baseprecv(ilev-1)%base_desc) - n_col = psb_cd_get_local_cols(baseprecv(ilev-1)%base_desc) - nc2l = psb_cd_get_local_cols(baseprecv(ilev)%base_desc) - nr2l = psb_cd_get_local_rows(baseprecv(ilev)%base_desc) - ismth = baseprecv(ilev)%iprcparm(mld_aggr_kind_) - icm = baseprecv(ilev)%iprcparm(mld_coarse_mat_) + nc2l = psb_cd_get_local_cols(precv(ilev)%base_desc) + nr2l = psb_cd_get_local_rows(precv(ilev)%base_desc) ! ! Apply prolongator ! call psb_backward_map(done,mlprec_wrk(ilev)%y2l,& & done,mlprec_wrk(ilev-1)%y2l,& - & baseprecv(ilev)%map_desc,info,work=work) + & precv(ilev)%map_desc,info,work=work) if (info /=0) then call psb_errpush(4001,name,a_err='Error during prolongation') @@ -500,7 +465,7 @@ contains ! ! Compute the output vector Y ! - call psb_geaxpby(alpha,mlprec_wrk(1)%y2l,done,y,baseprecv(1)%base_desc,info) + call psb_geaxpby(alpha,mlprec_wrk(1)%y2l,done,y,precv(1)%base_desc,info) if (info /= 0) then call psb_errpush(4001,name,a_err='Error on final update') goto 9999 @@ -534,7 +499,7 @@ contains ! Y = beta*Y + alpha*op(M^(-1))*X, ! where ! - M is a hybrid multilevel domain decomposition (Schwarz) preconditioner - ! associated to a certain matrix A and stored in the array baseprecv, + ! associated to a certain matrix A and stored in the array precv, ! - op(M^(-1)) is M^(-1) or its transpose, according to the value of trans, ! - X and Y are vectors, ! - alpha and beta are scalars. @@ -546,9 +511,9 @@ contains ! level where we might have a replicated index space) and each process takes care ! of one submatrix. ! - ! The multilevel preconditioner M is regarded as an array of 'base preconditioners', + ! The multilevel preconditioner M is regarded as an array of 'one-level preconditioners', ! each representing the part of the preconditioner associated to a certain level. - ! For each level ilev, the base preconditioner K(ilev) is stored in baseprecv(ilev) + ! For each level ilev, the base preconditioner K(ilev) is stored in precv(ilev) ! and is associated to a matrix A(ilev), obtained by 'tranferring' the original ! matrix A (i.e. the matrix to be preconditioned) to the level ilev, through smoothed ! aggregation. @@ -604,13 +569,13 @@ contains ! 6. Yext = beta*Yext + alpha*Y(1) ! ! - subroutine mlt_pre_ml_aply(alpha,baseprecv,x,beta,y,desc_data,trans,work,info) + subroutine mlt_pre_ml_aply(alpha,precv,x,beta,y,desc_data,trans,work,info) implicit none ! Arguments type(psb_desc_type),intent(in) :: desc_data - type(mld_dbaseprc_type), intent(in) :: baseprecv(:) + type(mld_d_onelev_prec_type), intent(in) :: precv(:) real(psb_dpk_),intent(in) :: alpha,beta real(psb_dpk_),intent(in) :: x(:) real(psb_dpk_),intent(inout) :: y(:) @@ -619,10 +584,9 @@ contains integer, intent(out) :: info ! Local variables - integer :: n_row,n_col integer :: ictxt,np,me,i, nr2l,nc2l,err_act integer :: debug_level, debug_unit - integer :: ismth, nlev, ilev, icm + integer :: nlev, ilev character(len=20) :: name type psb_mlprec_wrk_type @@ -641,9 +605,9 @@ contains if (debug_level >= psb_debug_inner_) & & write(debug_unit,*) me,' ',trim(name),& - & ' Entry ', size(baseprecv) + & ' Entry ', size(precv) - nlev = size(baseprecv) + nlev = size(precv) allocate(mlprec_wrk(nlev),stat=info) if (info /= 0) then call psb_errpush(4010,name,a_err='Allocate') @@ -655,8 +619,7 @@ contains ! ! Copy the input vector X ! - n_col = psb_cd_get_local_cols(desc_data) - nc2l = psb_cd_get_local_cols(baseprecv(1)%base_desc) + nc2l = psb_cd_get_local_cols(precv(1)%base_desc) allocate(mlprec_wrk(1)%x2l(nc2l),mlprec_wrk(1)%y2l(nc2l), & & mlprec_wrk(1)%tx(nc2l), stat=info) @@ -673,8 +636,8 @@ contains ! ! Apply the base preconditioner at the finest level ! - call mld_baseprec_aply(done,baseprecv(1),mlprec_wrk(1)%x2l,& - & dzero,mlprec_wrk(1)%y2l,baseprecv(1)%base_desc,& + call mld_baseprec_aply(done,precv(1)%prec,mlprec_wrk(1)%x2l,& + & dzero,mlprec_wrk(1)%y2l,precv(1)%base_desc,& & trans,work,info) if (info /=0) then call psb_errpush(4010,name,a_err=' baseprec_aply') @@ -688,8 +651,8 @@ contains ! mlprec_wrk(1)%tx = mlprec_wrk(1)%x2l - call psb_spmm(-done,baseprecv(1)%base_a,mlprec_wrk(1)%y2l,& - & done,mlprec_wrk(1)%tx,baseprecv(1)%base_desc,info,& + call psb_spmm(-done,precv(1)%base_a,mlprec_wrk(1)%y2l,& + & done,mlprec_wrk(1)%tx,precv(1)%base_desc,info,& & work=work,trans=trans) if (info /=0) then call psb_errpush(4001,name,a_err=' fine level residual') @@ -703,12 +666,8 @@ contains ! do ilev = 2, nlev - n_row = psb_cd_get_local_rows(baseprecv(ilev-1)%base_desc) - n_col = psb_cd_get_local_cols(baseprecv(ilev-1)%base_desc) - nc2l = psb_cd_get_local_cols(baseprecv(ilev)%base_desc) - nr2l = psb_cd_get_local_rows(baseprecv(ilev)%base_desc) - ismth = baseprecv(ilev)%iprcparm(mld_aggr_kind_) - icm = baseprecv(ilev)%iprcparm(mld_coarse_mat_) + nc2l = psb_cd_get_local_cols(precv(ilev)%base_desc) + nr2l = psb_cd_get_local_rows(precv(ilev)%base_desc) allocate(mlprec_wrk(ilev)%tx(nc2l),mlprec_wrk(ilev)%y2l(nc2l),& & mlprec_wrk(ilev)%x2l(nc2l), stat=info) @@ -722,7 +681,7 @@ contains ! Apply prolongator transpose, i.e. restriction call psb_forward_map(done,mlprec_wrk(ilev-1)%tx,& & dzero,mlprec_wrk(ilev)%x2l,& - & baseprecv(ilev)%map_desc,info,work=work) + & precv(ilev)%map_desc,info,work=work) if (info /=0) then call psb_errpush(4001,name,a_err='Error during restriction') @@ -732,17 +691,17 @@ contains ! ! Apply the base preconditioner ! - call mld_baseprec_aply(done,baseprecv(ilev),mlprec_wrk(ilev)%x2l,& - & dzero,mlprec_wrk(ilev)%y2l,baseprecv(ilev)%base_desc,trans,work,info) + call mld_baseprec_aply(done,precv(ilev)%prec,mlprec_wrk(ilev)%x2l,& + & dzero,mlprec_wrk(ilev)%y2l,precv(ilev)%base_desc,trans,work,info) ! ! Compute the residual (at all levels but the coarsest one) ! if (ilev < nlev) then mlprec_wrk(ilev)%tx = mlprec_wrk(ilev)%x2l - if (info == 0) call psb_spmm(-done,baseprecv(ilev)%base_a,& + if (info == 0) call psb_spmm(-done,precv(ilev)%base_a,& & mlprec_wrk(ilev)%y2l,done,mlprec_wrk(ilev)%tx,& - & baseprecv(ilev)%base_desc,info,work=work,trans=trans) + & precv(ilev)%base_desc,info,work=work,trans=trans) endif if (info /=0) then call psb_errpush(4001,name,a_err='Error on up sweep residual') @@ -756,16 +715,12 @@ contains ! For each level but the coarsest one ... ! do ilev = nlev-1, 1, -1 - - ismth = baseprecv(ilev+1)%iprcparm(mld_aggr_kind_) - n_row = psb_cd_get_local_rows(baseprecv(ilev)%base_desc) - ! ! Apply prolongator ! call psb_backward_map(done,mlprec_wrk(ilev+1)%y2l,& & done,mlprec_wrk(ilev)%y2l,& - & baseprecv(ilev+1)%map_desc,info,work=work) + & precv(ilev+1)%map_desc,info,work=work) if (info /=0) then call psb_errpush(4001,name,a_err='Error during prolongation') @@ -779,7 +734,7 @@ contains ! Compute the output vector Y ! call psb_geaxpby(alpha,mlprec_wrk(1)%y2l,beta,y,& - & baseprecv(1)%base_desc,info) + & precv(1)%base_desc,info) if (info /=0) then call psb_errpush(4001,name,a_err='Error on final update') goto 9999 @@ -812,7 +767,7 @@ contains ! Y = beta*Y + alpha*op(M^(-1))*X, ! where ! - M is a hybrid multilevel domain decomposition (Schwarz) preconditioner - ! associated to a certain matrix A and stored in the array baseprecv, + ! associated to a certain matrix A and stored in the array precv, ! - op(M^(-1)) is M^(-1) or its transpose, according to the value of trans, ! - X and Y are vectors, ! - alpha and beta are scalars. @@ -824,9 +779,9 @@ contains ! level where we might have a replicated index space) and each process takes care ! of one submatrix. ! - ! The multilevel preconditioner M is regarded as an array of 'base preconditioners', + ! The multilevel preconditioner M is regarded as an array of 'one-level preconditioners', ! each representing the part of the preconditioner associated to a certain level. - ! For each level ilev, the base preconditioner K(ilev) is stored in baseprecv(ilev) + ! For each level ilev, the base preconditioner K(ilev) is stored in precv(ilev) ! and is associated to a matrix A(ilev), obtained by 'tranferring' the original ! matrix A (i.e. the matrix to be preconditioned) to the level ilev, through smoothed ! aggregation. @@ -873,13 +828,13 @@ contains ! 5. Yext = beta*Yext + alpha*Y(1) ! ! - subroutine mlt_post_ml_aply(alpha,baseprecv,x,beta,y,desc_data,trans,work,info) + subroutine mlt_post_ml_aply(alpha,precv,x,beta,y,desc_data,trans,work,info) implicit none ! Arguments type(psb_desc_type),intent(in) :: desc_data - type(mld_dbaseprc_type), intent(in) :: baseprecv(:) + type(mld_d_onelev_prec_type), intent(in) :: precv(:) real(psb_dpk_),intent(in) :: alpha,beta real(psb_dpk_),intent(in) :: x(:) real(psb_dpk_),intent(inout) :: y(:) @@ -888,10 +843,9 @@ contains integer, intent(out) :: info ! Local variables - integer :: n_row,n_col integer :: ictxt,np,me,i, nr2l,nc2l,err_act integer :: debug_level, debug_unit - integer :: ismth, nlev, ilev, icm + integer :: nlev, ilev character(len=20) :: name type psb_mlprec_wrk_type @@ -910,9 +864,9 @@ contains if (debug_level >= psb_debug_inner_) & & write(debug_unit,*) me,' ',trim(name),& - & ' Entry ', size(baseprecv) + & ' Entry ', size(precv) - nlev = size(baseprecv) + nlev = size(precv) allocate(mlprec_wrk(nlev),stat=info) if (info /= 0) then call psb_errpush(4010,name,a_err='Allocate') @@ -928,16 +882,21 @@ contains & write(debug_unit,*) me,' ',trim(name),& & ' desc_data status',allocated(desc_data%matrix_data) - n_col = psb_cd_get_local_cols(desc_data) - nc2l = psb_cd_get_local_cols(baseprecv(1)%base_desc) + nc2l = psb_cd_get_local_cols(precv(1)%base_desc) allocate(mlprec_wrk(1)%x2l(nc2l),mlprec_wrk(1)%y2l(nc2l), & & mlprec_wrk(1)%tx(nc2l), stat=info) + if (info /= 0) then + info=4025 + call psb_errpush(info,name,i_err=(/4*nc2l,0,0,0,0/),& + & a_err='real(psb_dpk_)') + goto 9999 + end if call psb_geaxpby(done,x,dzero,mlprec_wrk(1)%tx,& - & baseprecv(1)%base_desc,info) + & precv(1)%base_desc,info) call psb_geaxpby(done,x,dzero,mlprec_wrk(1)%x2l,& - & baseprecv(1)%base_desc,info) + & precv(1)%base_desc,info) ! ! STEP 2 @@ -946,18 +905,13 @@ contains ! do ilev=2, nlev - n_row = psb_cd_get_local_rows(baseprecv(ilev-1)%base_desc) - n_col = psb_cd_get_local_cols(baseprecv(ilev-1)%base_desc) - nc2l = psb_cd_get_local_cols(baseprecv(ilev)%base_desc) - nr2l = psb_cd_get_local_rows(baseprecv(ilev)%base_desc) - ismth = baseprecv(ilev)%iprcparm(mld_aggr_kind_) - icm = baseprecv(ilev)%iprcparm(mld_coarse_mat_) + nc2l = psb_cd_get_local_cols(precv(ilev)%base_desc) + nr2l = psb_cd_get_local_rows(precv(ilev)%base_desc) if (debug_level >= psb_debug_inner_) & & write(debug_unit,*) me,' ',trim(name), & & ' starting up sweep ',& - & ilev,allocated(baseprecv(ilev)%iprcparm),n_row,n_col,& - & nc2l, nr2l,ismth + & ilev,allocated(precv(ilev)%iprcparm),nc2l, nr2l allocate(mlprec_wrk(ilev)%tx(nc2l),mlprec_wrk(ilev)%y2l(nc2l),& & mlprec_wrk(ilev)%x2l(nc2l), stat=info) @@ -972,7 +926,7 @@ contains ! Apply prolongator transpose, i.e. restriction call psb_forward_map(done,mlprec_wrk(ilev-1)%x2l,& & dzero,mlprec_wrk(ilev)%x2l,& - & baseprecv(ilev)%map_desc,info,work=work) + & precv(ilev)%map_desc,info,work=work) if (info /=0) then call psb_errpush(4001,name,a_err='Error during restriction') @@ -983,7 +937,7 @@ contains ! update x2l ! call psb_geaxpby(done,mlprec_wrk(ilev)%x2l,dzero,mlprec_wrk(ilev)%tx,& - & baseprecv(ilev)%base_desc,info) + & precv(ilev)%base_desc,info) if (info /= 0) then call psb_errpush(4001,name,a_err='Error in update') goto 9999 @@ -1000,9 +954,8 @@ contains ! ! Apply the base preconditioner at the coarsest level ! - call mld_baseprec_aply(done,baseprecv(nlev),mlprec_wrk(nlev)%x2l, & - & dzero, mlprec_wrk(nlev)%y2l,baseprecv(nlev)%base_desc,trans,work,info) - + call mld_baseprec_aply(done,precv(nlev)%prec,mlprec_wrk(nlev)%x2l, & + & dzero, mlprec_wrk(nlev)%y2l,precv(nlev)%base_desc,trans,work,info) if (info /=0) then call psb_errpush(4010,name,a_err='baseprec_aply') goto 9999 @@ -1022,15 +975,12 @@ contains & write(debug_unit,*) me,' ',trim(name),& & ' starting down sweep',ilev - ismth = baseprecv(ilev+1)%iprcparm(mld_aggr_kind_) - n_row = psb_cd_get_local_rows(baseprecv(ilev)%base_desc) - ! ! Apply prolongator ! call psb_backward_map(done,mlprec_wrk(ilev+1)%y2l,& & dzero,mlprec_wrk(ilev)%y2l,& - & baseprecv(ilev+1)%map_desc,info,work=work) + & precv(ilev+1)%map_desc,info,work=work) if (info /=0) then call psb_errpush(4001,name,a_err='Error during prolongation') @@ -1040,15 +990,16 @@ contains ! ! Compute the residual ! - call psb_spmm(-done,baseprecv(ilev)%base_a,mlprec_wrk(ilev)%y2l,& - & done,mlprec_wrk(ilev)%tx,baseprecv(ilev)%base_desc,info,& + call psb_spmm(-done,precv(ilev)%base_a,mlprec_wrk(ilev)%y2l,& + & done,mlprec_wrk(ilev)%tx,precv(ilev)%base_desc,info,& & work=work,trans=trans) ! ! Apply the base preconditioner ! - if (info == 0) call mld_baseprec_aply(done,baseprecv(ilev),mlprec_wrk(ilev)%tx,& - & done,mlprec_wrk(ilev)%y2l,baseprecv(ilev)%base_desc,trans,work,info) + if (info == 0) call mld_baseprec_aply(done,precv(ilev)%prec,& + & mlprec_wrk(ilev)%tx,done,mlprec_wrk(ilev)%y2l,precv(ilev)%base_desc,& + & trans,work,info) if (info /=0) then call psb_errpush(4001,name,a_err=' spmm/baseprec_aply') goto 9999 @@ -1064,7 +1015,7 @@ contains ! ! Compute the output vector Y ! - call psb_geaxpby(alpha,mlprec_wrk(1)%y2l,beta,y,baseprecv(1)%base_desc,info) + call psb_geaxpby(alpha,mlprec_wrk(1)%y2l,beta,y,precv(1)%base_desc,info) if (info /=0) then call psb_errpush(4001,name,a_err=' Final update') @@ -1101,7 +1052,7 @@ contains ! where ! - M is a symmetrized hybrid multilevel domain decomposition (Schwarz) ! preconditioner associated to a certain matrix A and stored in the array - ! baseprecv, + ! precv, ! - op(M^(-1)) is M^(-1) or its transpose, according to the value of trans, ! - X and Y are vectors, ! - alpha and beta are scalars. @@ -1114,9 +1065,9 @@ contains ! level where we might have a replicated index space) and each process takes care ! of one submatrix. ! - ! The multilevel preconditioner M is regarded as an array of 'base preconditioners', + ! The multilevel preconditioner M is regarded as an array of 'one-level preconditioners', ! each representing the part of the preconditioner associated to a certain level. - ! For each level ilev, the base preconditioner K(ilev) is stored in baseprecv(ilev) + ! For each level ilev, the base preconditioner K(ilev) is stored in precv(ilev) ! and is associated to a matrix A(ilev), obtained by 'tranferring' the original ! matrix A (i.e. the matrix to be preconditioned) to the level ilev, through smoothed ! aggregation. @@ -1174,13 +1125,13 @@ contains ! ! 6. Yext = beta*Yext + alpha*Y(1) ! - subroutine mlt_twoside_ml_aply(alpha,baseprecv,x,beta,y,desc_data,trans,work,info) + subroutine mlt_twoside_ml_aply(alpha,precv,x,beta,y,desc_data,trans,work,info) implicit none ! Arguments type(psb_desc_type),intent(in) :: desc_data - type(mld_dbaseprc_type), intent(in) :: baseprecv(:) + type(mld_d_onelev_prec_type), intent(in) :: precv(:) real(psb_dpk_),intent(in) :: alpha,beta real(psb_dpk_),intent(in) :: x(:) real(psb_dpk_),intent(inout) :: y(:) @@ -1189,10 +1140,9 @@ contains integer, intent(out) :: info ! Local variables - integer :: n_row,n_col integer :: ictxt,np,me,i, nr2l,nc2l,err_act integer :: debug_level, debug_unit - integer :: ismth, nlev, ilev, icm + integer :: nlev, ilev character(len=20) :: name type psb_mlprec_wrk_type @@ -1211,9 +1161,9 @@ contains if (debug_level >= psb_debug_inner_) & & write(debug_unit,*) me,' ',trim(name),& - & ' Entry ', size(baseprecv) + & ' Entry ', size(precv) - nlev = size(baseprecv) + nlev = size(precv) allocate(mlprec_wrk(nlev),stat=info) if (info /= 0) then call psb_errpush(4010,name,a_err='Allocate') @@ -1224,8 +1174,7 @@ contains ! ! Copy the input vector X ! - n_col = psb_cd_get_local_cols(desc_data) - nc2l = psb_cd_get_local_cols(baseprecv(1)%base_desc) + nc2l = psb_cd_get_local_cols(precv(1)%base_desc) allocate(mlprec_wrk(1)%x2l(nc2l),mlprec_wrk(1)%y2l(nc2l), & & mlprec_wrk(1)%ty(nc2l), mlprec_wrk(1)%tx(nc2l), stat=info) @@ -1238,17 +1187,17 @@ contains end if call psb_geaxpby(done,x,dzero,mlprec_wrk(1)%x2l,& - & baseprecv(1)%base_desc,info) + & precv(1)%base_desc,info) call psb_geaxpby(done,x,dzero,mlprec_wrk(1)%tx,& - & baseprecv(1)%base_desc,info) + & precv(1)%base_desc,info) ! ! STEP 2 ! ! Apply the base preconditioner at the finest level ! - call mld_baseprec_aply(done,baseprecv(1),mlprec_wrk(1)%x2l,& - & dzero,mlprec_wrk(1)%y2l,baseprecv(1)%base_desc,& + call mld_baseprec_aply(done,precv(1)%prec,mlprec_wrk(1)%x2l,& + & dzero,mlprec_wrk(1)%y2l,precv(1)%base_desc,& & trans,work,info) ! ! STEP 3 @@ -1256,8 +1205,8 @@ contains ! Compute the residual at the finest level ! mlprec_wrk(1)%ty = mlprec_wrk(1)%x2l - if (info == 0) call psb_spmm(-done,baseprecv(1)%base_a,mlprec_wrk(1)%y2l,& - & done,mlprec_wrk(1)%ty,baseprecv(1)%base_desc,info,& + if (info == 0) call psb_spmm(-done,precv(1)%base_a,mlprec_wrk(1)%y2l,& + & done,mlprec_wrk(1)%ty,precv(1)%base_desc,info,& & work=work,trans=trans) if (info /=0) then call psb_errpush(4010,name,a_err='Fine level baseprec/residual') @@ -1271,12 +1220,9 @@ contains ! do ilev = 2, nlev - n_row = psb_cd_get_local_rows(baseprecv(ilev-1)%base_desc) - n_col = psb_cd_get_local_cols(baseprecv(ilev-1)%base_desc) - nc2l = psb_cd_get_local_cols(baseprecv(ilev)%base_desc) - nr2l = psb_cd_get_local_rows(baseprecv(ilev)%base_desc) - ismth = baseprecv(ilev)%iprcparm(mld_aggr_kind_) - icm = baseprecv(ilev)%iprcparm(mld_coarse_mat_) + nc2l = psb_cd_get_local_cols(precv(ilev)%base_desc) + nr2l = psb_cd_get_local_rows(precv(ilev)%base_desc) + allocate(mlprec_wrk(ilev)%tx(nc2l),mlprec_wrk(ilev)%ty(nc2l),& & mlprec_wrk(ilev)%y2l(nc2l),mlprec_wrk(ilev)%x2l(nc2l), stat=info) @@ -1290,7 +1236,7 @@ contains ! Apply prolongator transpose, i.e. restriction call psb_forward_map(done,mlprec_wrk(ilev-1)%ty,& & dzero,mlprec_wrk(ilev)%x2l,& - & baseprecv(ilev)%map_desc,info,work=work) + & precv(ilev)%map_desc,info,work=work) if (info /=0) then call psb_errpush(4001,name,a_err='Error during restriction') @@ -1298,21 +1244,21 @@ contains end if call psb_geaxpby(done,mlprec_wrk(ilev)%x2l,dzero,mlprec_wrk(ilev)%tx,& - & baseprecv(ilev)%base_desc,info) + & precv(ilev)%base_desc,info) ! ! Apply the base preconditioner ! - if (info == 0) call mld_baseprec_aply(done,baseprecv(ilev),& + if (info == 0) call mld_baseprec_aply(done,precv(ilev)%prec,& & mlprec_wrk(ilev)%x2l,dzero,mlprec_wrk(ilev)%y2l,& - & baseprecv(ilev)%base_desc,trans,work,info) + & precv(ilev)%base_desc,trans,work,info) ! ! Compute the residual (at all levels but the coarsest one) ! if(ilev < nlev) then mlprec_wrk(ilev)%ty = mlprec_wrk(ilev)%x2l - if (info == 0) call psb_spmm(-done,baseprecv(ilev)%base_a,& + if (info == 0) call psb_spmm(-done,precv(ilev)%base_a,& & mlprec_wrk(ilev)%y2l,done,mlprec_wrk(ilev)%ty,& - & baseprecv(ilev)%base_desc,info,work=work,trans=trans) + & precv(ilev)%base_desc,info,work=work,trans=trans) endif if (info /=0) then call psb_errpush(4001,name,a_err='baseprec_aply/residual') @@ -1328,15 +1274,12 @@ contains ! do ilev=nlev-1, 1, -1 - ismth = baseprecv(ilev+1)%iprcparm(mld_aggr_kind_) - n_row = psb_cd_get_local_rows(baseprecv(ilev)%base_desc) - ! ! Apply prolongator ! call psb_backward_map(done,mlprec_wrk(ilev+1)%y2l,& & done,mlprec_wrk(ilev)%y2l,& - & baseprecv(ilev+1)%map_desc,info,work=work) + & precv(ilev+1)%map_desc,info,work=work) if (info /=0 ) then call psb_errpush(4001,name,a_err='Error during restriction') @@ -1346,14 +1289,14 @@ contains ! ! Compute the residual ! - call psb_spmm(-done,baseprecv(ilev)%base_a,mlprec_wrk(ilev)%y2l,& - & done,mlprec_wrk(ilev)%tx,baseprecv(ilev)%base_desc,info,& + call psb_spmm(-done,precv(ilev)%base_a,mlprec_wrk(ilev)%y2l,& + & done,mlprec_wrk(ilev)%tx,precv(ilev)%base_desc,info,& & work=work,trans=trans) ! ! Apply the base preconditioner ! - if (info == 0) call mld_baseprec_aply(done,baseprecv(ilev),mlprec_wrk(ilev)%tx,& - & done,mlprec_wrk(ilev)%y2l,baseprecv(ilev)%base_desc, trans, work,info) + if (info == 0) call mld_baseprec_aply(done,precv(ilev)%prec,mlprec_wrk(ilev)%tx,& + & done,mlprec_wrk(ilev)%y2l,precv(ilev)%base_desc, trans, work,info) if (info /= 0) then call psb_errpush(4001,name,a_err='Error: residual/baseprec_aply') goto 9999 @@ -1366,7 +1309,7 @@ contains ! Compute the output vector Y ! call psb_geaxpby(alpha,mlprec_wrk(1)%y2l,beta,y,& - & baseprecv(1)%base_desc,info) + & precv(1)%base_desc,info) if (info /= 0) then call psb_errpush(4001,name,a_err='Error final update') diff --git a/mlprec/mld_dmlprec_bld.f90 b/mlprec/mld_dmlprec_bld.f90 index c66c561f..863101e5 100644 --- a/mlprec/mld_dmlprec_bld.f90 +++ b/mlprec/mld_dmlprec_bld.f90 @@ -41,10 +41,11 @@ ! Subroutine: mld_dmlprec_bld ! Version: real ! -! This routine builds the base preconditioner corresponding to the current +! This routine builds the preconditioner corresponding to the current ! level of the multilevel preconditioner. The routine first builds the ! (coarse) matrix associated to the current level from the (fine) matrix ! associated to the previous level, then builds the related base preconditioner. +! Note that this routine is only ever called on levels >= 2. ! ! ! Arguments: @@ -53,9 +54,9 @@ ! matrix to be preconditioned. ! desc_a - type(psb_desc_type), input. ! The communication descriptor of a. -! p - type(mld_dbaseprc_type), input/output. -! The base preconditioner data structure containing the local -! part of the base preconditioner to be built. +! p - type(mld_d_onelev_type), input/output. +! The preconditioner data structure containing the local +! part of the one-level preconditioner to be built. ! info - integer, output. ! Error code. ! @@ -69,7 +70,7 @@ subroutine mld_dmlprec_bld(a,desc_a,p,info) ! Arguments type(psb_dspmat_type), intent(in), target :: a type(psb_desc_type), intent(in), target :: desc_a - type(mld_dbaseprc_type), intent(inout),target :: p + type(mld_d_onelev_prec_type), intent(inout),target :: p integer, intent(out) :: info ! Local variables @@ -106,16 +107,16 @@ subroutine mld_dmlprec_bld(a,desc_a,p,info) & mld_max_norm_,is_legal_ml_aggr_eig) - select case(p%iprcparm(mld_sub_solve_)) + select case(p%prec%iprcparm(mld_sub_solve_)) case(mld_ilu_n_,mld_milu_n_) - call mld_check_def(p%iprcparm(mld_sub_fillin_),'Level',0,is_legal_ml_lev) + call mld_check_def(p%prec%iprcparm(mld_sub_fillin_),'Level',0,is_legal_ml_lev) case(mld_ilu_t_) - call mld_check_def(p%rprcparm(mld_sub_iluthrs_),'Eps',dzero,is_legal_fact_thrs) + call mld_check_def(p%prec%rprcparm(mld_sub_iluthrs_),'Eps',dzero,is_legal_fact_thrs) end select + call mld_check_def(p%prec%iprcparm(mld_smoother_sweeps_),'Jacobi sweeps',& + & 1,is_legal_jac_sweeps) call mld_check_def(p%rprcparm(mld_aggr_omega_val_),'Omega',dzero,is_legal_omega) call mld_check_def(p%rprcparm(mld_aggr_thresh_),'Aggr_Thresh',dzero,is_legal_aggr_thrs) - call mld_check_def(p%iprcparm(mld_smoother_sweeps_),'Jacobi sweeps',& - & 1,is_legal_jac_sweeps) ! ! Build a mapping between the row indices of the fine-level matrix @@ -135,7 +136,7 @@ subroutine mld_dmlprec_bld(a,desc_a,p,info) ! the mapping defined by mld_aggrmap_bld and applying the aggregation ! algorithm specified by p%iprcparm(mld_aggr_kind_) ! - call mld_aggrmat_asb(a,desc_a,ac,desc_ac,p,info) + call mld_aggrmat_asb(a,desc_a,p,info) if(info /= 0) then call psb_errpush(4010,name,a_err='mld_aggrmat_asb') goto 9999 @@ -144,34 +145,18 @@ subroutine mld_dmlprec_bld(a,desc_a,p,info) ! ! Build the 'base preconditioner' corresponding to the coarse level ! - call mld_baseprc_bld(ac,desc_ac,p,info) + call mld_baseprc_bld(p%ac,p%desc_ac,p%prec,info) if (info /= 0) then call psb_errpush(4010,name,a_err='mld_baseprc_bld') goto 9999 end if - ! - ! We have used a separate ac because - ! 1. we want to reuse the same routines mld_ilu_bld, etc., - ! 2. we do NOT want to pass an argument twice to them (p%av(mld_ac_) and p), - ! as this would violate the Fortran standard. - ! Hence a separate AC and a TRANSFER function at the end. + ! Fix the base_a and base_desc pointers for handling of residuals. + ! This is correct because this routine is only called at levels >=2. ! - call psb_sp_transfer(ac,p%av(mld_ac_),info) - p%base_a => p%av(mld_ac_) - if (info==0) call psb_cdtransfer(desc_ac,p%desc_ac,info) - - p%map_desc = psb_inter_desc(psb_map_aggr_,desc_a,& - & p%desc_ac,p%av(mld_sm_pr_t_),p%av(mld_sm_pr_)) - ! The two matrices from p%av() have been copied, may free them. - if (info == 0) call psb_sp_free(p%av(mld_sm_pr_t_),info) - if (info == 0) call psb_sp_free(p%av(mld_sm_pr_),info) - if (info /= 0) then - call psb_errpush(4010,name,a_err='psb_cdtransfer') - goto 9999 - end if + p%base_a => p%ac p%base_desc => p%desc_ac - + call psb_erractionrestore(err_act) return diff --git a/mlprec/mld_dprec_aply.f90 b/mlprec/mld_dprec_aply.f90 index 7be89f8b..24259709 100644 --- a/mlprec/mld_dprec_aply.f90 +++ b/mlprec/mld_dprec_aply.f90 @@ -120,25 +120,25 @@ subroutine mld_dprec_aply(prec,x,y,desc_data,info,trans,work) end if - if (.not.(allocated(prec%baseprecv))) then + if (.not.(allocated(prec%precv))) then !! Error 1: should call mld_dprecbld info=3112 call psb_errpush(info,name) goto 9999 end if - if (size(prec%baseprecv) >1) then - call mld_mlprec_aply(done,prec%baseprecv,x,dzero,y,desc_data,trans_,work_,info) + if (size(prec%precv) >1) then + call mld_mlprec_aply(done,prec%precv,x,dzero,y,desc_data,trans_,work_,info) if(info /= 0) then call psb_errpush(4010,name,a_err='mld_dmlprec_aply') goto 9999 end if - else if (size(prec%baseprecv) == 1) then - call mld_baseprec_aply(done,prec%baseprecv(1),x,dzero,y,desc_data,trans_, work_,info) + else if (size(prec%precv) == 1) then + call mld_baseprec_aply(done,prec%precv(1)%prec,x,dzero,y,desc_data,trans_, work_,info) else info = 4013 - call psb_errpush(info,name,a_err='Invalid size of baseprecv',& - & i_Err=(/size(prec%baseprecv),0,0,0,0/)) + call psb_errpush(info,name,a_err='Invalid size of precv',& + & i_Err=(/size(prec%precv),0,0,0,0/)) goto 9999 endif diff --git a/mlprec/mld_dprecbld.f90 b/mlprec/mld_dprecbld.f90 index 7c46ed86..1ef662d6 100644 --- a/mlprec/mld_dprecbld.f90 +++ b/mlprec/mld_dprecbld.f90 @@ -119,7 +119,7 @@ subroutine mld_dprecbld(a,desc_a,p,info) !!$ endif upd_ = 'F' - if (.not.allocated(p%baseprecv)) then + if (.not.allocated(p%precv)) then !! Error: should have called mld_dprecinit info=3111 call psb_errpush(info,name) @@ -129,11 +129,11 @@ subroutine mld_dprecbld(a,desc_a,p,info) ! ! Check to ensure all procs have the same ! - iszv = size(p%baseprecv) + iszv = size(p%precv) call psb_bcast(ictxt,iszv) - if (iszv /= size(p%baseprecv)) then + if (iszv /= size(p%precv)) then info=4001 - call psb_errpush(info,name,a_err='Inconsistent size of baseprecv') + call psb_errpush(info,name,a_err='Inconsistent size of precv') goto 9999 end if @@ -142,18 +142,20 @@ subroutine mld_dprecbld(a,desc_a,p,info) ! Check on the iprcparm contents: they should be the same ! on all processes. ! - if (me == psb_root_) ipv(:) = p%baseprecv(1)%iprcparm(:) + if (me == psb_root_) ipv(:) = p%precv(1)%iprcparm(:) call psb_bcast(ictxt,ipv) - if (any(ipv(:) /= p%baseprecv(1)%iprcparm(:) )) then + if (any(ipv(:) /= p%precv(1)%iprcparm(:) )) then write(debug_unit,*) me,name,& &': Inconsistent arguments among processes, forcing a default' - p%baseprecv(1)%iprcparm(:) = ipv(:) + p%precv(1)%iprcparm(:) = ipv(:) end if ! - ! Allocate and build the fine level preconditioner + ! Finest level first; remember to fix base_a and base_desc ! - call init_baseprc_av(p%baseprecv(1),info) - if (info == 0) call mld_baseprc_bld(a,desc_a,p%baseprecv(1),info,upd_) + call init_baseprc_av(p%precv(1)%prec,info) + if (info == 0) call mld_baseprc_bld(a,desc_a,p%precv(1)%prec,info,upd_) + p%precv(1)%base_a => a + p%precv(1)%base_desc => desc_a if (info /= 0) then call psb_errpush(4001,name,a_err='Base level precbuild.') @@ -178,69 +180,69 @@ subroutine mld_dprecbld(a,desc_a,p,info) ! Check on the iprcparm contents: they should be the same ! on all processes. ! - if (me == psb_root_) ipv(:) = p%baseprecv(i)%iprcparm(:) + if (me == psb_root_) ipv(:) = p%precv(i)%iprcparm(:) call psb_bcast(ictxt,ipv) - if (any(ipv(:) /= p%baseprecv(i)%iprcparm(:) )) then + if (any(ipv(:) /= p%precv(i)%iprcparm(:) )) then write(debug_unit,*) me,name,& &': Inconsistent arguments among processes, resetting.' - p%baseprecv(i)%iprcparm(:) = ipv(:) + p%precv(i)%iprcparm(:) = ipv(:) end if ! - ! Allocate the av component of the preconditioner data type - ! at level i + ! Sanity checks on the parameters ! if (i= psb_debug_outer_) & & write(debug_unit,*) me,' ',trim(name),& & 'Calling mlprcbld at level ',i - - ! - ! Build the base preconditioner corresponding to level i ! - if (info == 0) call mld_mlprec_bld(p%baseprecv(i-1)%base_a,& - & p%baseprecv(i-1)%base_desc, p%baseprecv(i),info) + ! Allocate and build the preconditioner at level i. + ! baseprec_bld is called inside mlprec_bld. + ! + call init_baseprc_av(p%precv(i)%prec,info) + if (info == 0) call mld_mlprec_bld(p%precv(i-1)%base_a,& + & p%precv(i-1)%base_desc, p%precv(i),info) + if (info /= 0) then call psb_errpush(4001,name,a_err='Init & build upper level preconditioner') goto 9999 @@ -250,11 +252,14 @@ subroutine mld_dprecbld(a,desc_a,p,info) & write(debug_unit,*) me,' ',trim(name),& & 'Return from ',i,' call to mlprcbld ',info end do + + ! ! Check on sizes from level 2 onwards + ! if (me==0) then k = iszv+1 do i=iszv,3,-1 - if (all(p%baseprecv(i)%nlaggr == p%baseprecv(i-1)%nlaggr)) then + if (all(p%precv(i)%nlaggr == p%precv(i-1)%nlaggr)) then k=i-1 end if end do diff --git a/mlprec/mld_dprecfree.f90 b/mlprec/mld_dprecfree.f90 index c9660082..9e354993 100644 --- a/mlprec/mld_dprecfree.f90 +++ b/mlprec/mld_dprecfree.f90 @@ -74,11 +74,11 @@ subroutine mld_dprecfree(p,info) me=-1 - if (allocated(p%baseprecv)) then - do i=1,size(p%baseprecv) - call mld_base_precfree(p%baseprecv(i),info) + if (allocated(p%precv)) then + do i=1,size(p%precv) + call mld_onelev_precfree(p%precv(i),info) end do - deallocate(p%baseprecv) + deallocate(p%precv) end if call psb_erractionrestore(err_act) return diff --git a/mlprec/mld_dprecinit.F90 b/mlprec/mld_dprecinit.F90 index 4aed84b8..42f3fad1 100644 --- a/mlprec/mld_dprecinit.F90 +++ b/mlprec/mld_dprecinit.F90 @@ -104,7 +104,7 @@ subroutine mld_dprecinit(p,ptype,info,nlev) character(len=*), parameter :: name='mld_precinit' info = 0 - if (allocated(p%baseprecv)) then + if (allocated(p%precv)) then call mld_precfree(p,info) if (info /=0) then ! Do we want to do something? @@ -115,68 +115,88 @@ subroutine mld_dprecinit(p,ptype,info,nlev) case ('NOPREC') nlev_ = 1 ilev_ = 1 - allocate(p%baseprecv(nlev_),stat=info) - if (info == 0) call psb_realloc(mld_ifpsz_,p%baseprecv(ilev_)%iprcparm,info) - if (info == 0) call psb_realloc(mld_rfpsz_,p%baseprecv(ilev_)%rprcparm,info) + allocate(p%precv(nlev_),stat=info) + if (info == 0) call psb_realloc(mld_ifpsz_,p%precv(ilev_)%iprcparm,info) + if (info == 0) call psb_realloc(mld_rfpsz_,p%precv(ilev_)%rprcparm,info) + if (info == 0) call psb_realloc(mld_ifpsz_,p%precv(ilev_)%prec%iprcparm,info) + if (info == 0) call psb_realloc(mld_rfpsz_,p%precv(ilev_)%prec%rprcparm,info) if (info /= 0) return - p%baseprecv(ilev_)%iprcparm(:) = 0 - p%baseprecv(ilev_)%iprcparm(mld_smoother_type_) = mld_noprec_ - p%baseprecv(ilev_)%iprcparm(mld_sub_solve_) = mld_f_none_ - p%baseprecv(ilev_)%iprcparm(mld_sub_restr_) = psb_none_ - p%baseprecv(ilev_)%iprcparm(mld_sub_prol_) = psb_none_ - p%baseprecv(ilev_)%iprcparm(mld_sub_ren_) = 0 - p%baseprecv(ilev_)%iprcparm(mld_sub_ovr_) = 0 - p%baseprecv(ilev_)%iprcparm(mld_smoother_sweeps_) = 1 + p%precv(ilev_)%iprcparm(:) = 0 + p%precv(ilev_)%rprcparm(:) = dzero + p%precv(ilev_)%prec%iprcparm(:) = 0 + p%precv(ilev_)%prec%rprcparm(:) = dzero + p%precv(ilev_)%prec%iprcparm(mld_smoother_type_) = mld_noprec_ + p%precv(ilev_)%prec%iprcparm(mld_sub_solve_) = mld_f_none_ + p%precv(ilev_)%prec%iprcparm(mld_sub_restr_) = psb_none_ + p%precv(ilev_)%prec%iprcparm(mld_sub_prol_) = psb_none_ + p%precv(ilev_)%prec%iprcparm(mld_sub_ren_) = 0 + p%precv(ilev_)%prec%iprcparm(mld_sub_ovr_) = 0 + p%precv(ilev_)%prec%iprcparm(mld_smoother_sweeps_) = 1 case ('DIAG') nlev_ = 1 ilev_ = 1 - allocate(p%baseprecv(nlev_),stat=info) - if (info == 0) call psb_realloc(mld_ifpsz_,p%baseprecv(ilev_)%iprcparm,info) - if (info == 0) call psb_realloc(mld_rfpsz_,p%baseprecv(ilev_)%rprcparm,info) + allocate(p%precv(nlev_),stat=info) + if (info == 0) call psb_realloc(mld_ifpsz_,p%precv(ilev_)%iprcparm,info) + if (info == 0) call psb_realloc(mld_rfpsz_,p%precv(ilev_)%rprcparm,info) + if (info == 0) call psb_realloc(mld_ifpsz_,p%precv(ilev_)%prec%iprcparm,info) + if (info == 0) call psb_realloc(mld_rfpsz_,p%precv(ilev_)%prec%rprcparm,info) if (info /= 0) return - p%baseprecv(ilev_)%iprcparm(:) = 0 - p%baseprecv(ilev_)%iprcparm(mld_smoother_type_) = mld_diag_ - p%baseprecv(ilev_)%iprcparm(mld_sub_solve_) = mld_f_none_ - p%baseprecv(ilev_)%iprcparm(mld_sub_restr_) = psb_none_ - p%baseprecv(ilev_)%iprcparm(mld_sub_prol_) = psb_none_ - p%baseprecv(ilev_)%iprcparm(mld_sub_ren_) = 0 - p%baseprecv(ilev_)%iprcparm(mld_sub_ovr_) = 0 - p%baseprecv(ilev_)%iprcparm(mld_smoother_sweeps_) = 1 + p%precv(ilev_)%iprcparm(:) = 0 + p%precv(ilev_)%rprcparm(:) = dzero + p%precv(ilev_)%prec%iprcparm(:) = 0 + p%precv(ilev_)%prec%rprcparm(:) = dzero + p%precv(ilev_)%prec%iprcparm(mld_smoother_type_) = mld_diag_ + p%precv(ilev_)%prec%iprcparm(mld_sub_solve_) = mld_f_none_ + p%precv(ilev_)%prec%iprcparm(mld_sub_restr_) = psb_none_ + p%precv(ilev_)%prec%iprcparm(mld_sub_prol_) = psb_none_ + p%precv(ilev_)%prec%iprcparm(mld_sub_ren_) = 0 + p%precv(ilev_)%prec%iprcparm(mld_sub_ovr_) = 0 + p%precv(ilev_)%prec%iprcparm(mld_smoother_sweeps_) = 1 case ('BJAC') nlev_ = 1 ilev_ = 1 - allocate(p%baseprecv(nlev_),stat=info) - if (info == 0) call psb_realloc(mld_ifpsz_,p%baseprecv(ilev_)%iprcparm,info) - if (info == 0) call psb_realloc(mld_rfpsz_,p%baseprecv(ilev_)%rprcparm,info) + allocate(p%precv(nlev_),stat=info) + if (info == 0) call psb_realloc(mld_ifpsz_,p%precv(ilev_)%iprcparm,info) + if (info == 0) call psb_realloc(mld_rfpsz_,p%precv(ilev_)%rprcparm,info) + if (info == 0) call psb_realloc(mld_ifpsz_,p%precv(ilev_)%prec%iprcparm,info) + if (info == 0) call psb_realloc(mld_rfpsz_,p%precv(ilev_)%prec%rprcparm,info) if (info /= 0) return - p%baseprecv(ilev_)%iprcparm(:) = 0 - p%baseprecv(ilev_)%iprcparm(mld_smoother_type_) = mld_bjac_ - p%baseprecv(ilev_)%iprcparm(mld_sub_solve_) = mld_ilu_n_ - p%baseprecv(ilev_)%iprcparm(mld_sub_restr_) = psb_none_ - p%baseprecv(ilev_)%iprcparm(mld_sub_prol_) = psb_none_ - p%baseprecv(ilev_)%iprcparm(mld_sub_ren_) = 0 - p%baseprecv(ilev_)%iprcparm(mld_sub_ovr_) = 0 - p%baseprecv(ilev_)%iprcparm(mld_sub_fillin_) = 0 - p%baseprecv(ilev_)%iprcparm(mld_smoother_sweeps_) = 1 + p%precv(ilev_)%iprcparm(:) = 0 + p%precv(ilev_)%rprcparm(:) = dzero + p%precv(ilev_)%prec%iprcparm(:) = 0 + p%precv(ilev_)%prec%rprcparm(:) = dzero + p%precv(ilev_)%prec%iprcparm(mld_smoother_type_) = mld_bjac_ + p%precv(ilev_)%prec%iprcparm(mld_sub_solve_) = mld_ilu_n_ + p%precv(ilev_)%prec%iprcparm(mld_sub_restr_) = psb_none_ + p%precv(ilev_)%prec%iprcparm(mld_sub_prol_) = psb_none_ + p%precv(ilev_)%prec%iprcparm(mld_sub_ren_) = 0 + p%precv(ilev_)%prec%iprcparm(mld_sub_ovr_) = 0 + p%precv(ilev_)%prec%iprcparm(mld_sub_fillin_) = 0 + p%precv(ilev_)%prec%iprcparm(mld_smoother_sweeps_) = 1 case ('AS') nlev_ = 1 ilev_ = 1 - allocate(p%baseprecv(nlev_),stat=info) - if (info == 0) call psb_realloc(mld_ifpsz_,p%baseprecv(ilev_)%iprcparm,info) - if (info == 0) call psb_realloc(mld_rfpsz_,p%baseprecv(ilev_)%rprcparm,info) + allocate(p%precv(nlev_),stat=info) + if (info == 0) call psb_realloc(mld_ifpsz_,p%precv(ilev_)%iprcparm,info) + if (info == 0) call psb_realloc(mld_rfpsz_,p%precv(ilev_)%rprcparm,info) + if (info == 0) call psb_realloc(mld_ifpsz_,p%precv(ilev_)%prec%iprcparm,info) + if (info == 0) call psb_realloc(mld_rfpsz_,p%precv(ilev_)%prec%rprcparm,info) if (info /= 0) return - p%baseprecv(ilev_)%iprcparm(:) = 0 - p%baseprecv(ilev_)%iprcparm(mld_smoother_type_) = mld_as_ - p%baseprecv(ilev_)%iprcparm(mld_sub_solve_) = mld_ilu_n_ - p%baseprecv(ilev_)%iprcparm(mld_sub_restr_) = psb_halo_ - p%baseprecv(ilev_)%iprcparm(mld_sub_prol_) = psb_none_ - p%baseprecv(ilev_)%iprcparm(mld_sub_ren_) = 0 - p%baseprecv(ilev_)%iprcparm(mld_sub_ovr_) = 1 - p%baseprecv(ilev_)%iprcparm(mld_sub_fillin_) = 0 - p%baseprecv(ilev_)%iprcparm(mld_smoother_sweeps_) = 1 + p%precv(ilev_)%iprcparm(:) = 0 + p%precv(ilev_)%rprcparm(:) = dzero + p%precv(ilev_)%prec%iprcparm(:) = 0 + p%precv(ilev_)%prec%rprcparm(:) = dzero + p%precv(ilev_)%prec%iprcparm(mld_smoother_type_) = mld_as_ + p%precv(ilev_)%prec%iprcparm(mld_sub_solve_) = mld_ilu_n_ + p%precv(ilev_)%prec%iprcparm(mld_sub_restr_) = psb_halo_ + p%precv(ilev_)%prec%iprcparm(mld_sub_prol_) = psb_none_ + p%precv(ilev_)%prec%iprcparm(mld_sub_ren_) = 0 + p%precv(ilev_)%prec%iprcparm(mld_sub_ovr_) = 1 + p%precv(ilev_)%prec%iprcparm(mld_sub_fillin_) = 0 + p%precv(ilev_)%prec%iprcparm(mld_smoother_sweeps_) = 1 case ('ML') @@ -187,76 +207,88 @@ subroutine mld_dprecinit(p,ptype,info,nlev) nlev_ = 2 end if ilev_ = 1 - allocate(p%baseprecv(nlev_),stat=info) - if (info == 0) call psb_realloc(mld_ifpsz_,p%baseprecv(ilev_)%iprcparm,info) - if (info == 0) call psb_realloc(mld_rfpsz_,p%baseprecv(ilev_)%rprcparm,info) + allocate(p%precv(nlev_),stat=info) + if (info == 0) call psb_realloc(mld_ifpsz_,p%precv(ilev_)%iprcparm,info) + if (info == 0) call psb_realloc(mld_rfpsz_,p%precv(ilev_)%rprcparm,info) + if (info == 0) call psb_realloc(mld_ifpsz_,p%precv(ilev_)%prec%iprcparm,info) + if (info == 0) call psb_realloc(mld_rfpsz_,p%precv(ilev_)%prec%rprcparm,info) if (info /= 0) return - p%baseprecv(ilev_)%iprcparm(:) = 0 - p%baseprecv(ilev_)%rprcparm(:) = dzero - p%baseprecv(ilev_)%iprcparm(mld_smoother_type_) = mld_as_ - p%baseprecv(ilev_)%iprcparm(mld_sub_solve_) = mld_ilu_n_ - p%baseprecv(ilev_)%iprcparm(mld_sub_restr_) = psb_halo_ - p%baseprecv(ilev_)%iprcparm(mld_sub_prol_) = psb_none_ - p%baseprecv(ilev_)%iprcparm(mld_sub_ren_) = 0 - p%baseprecv(ilev_)%iprcparm(mld_sub_ovr_) = 1 - p%baseprecv(ilev_)%iprcparm(mld_sub_fillin_) = 0 - p%baseprecv(ilev_)%iprcparm(mld_smoother_sweeps_) = 1 + p%precv(ilev_)%iprcparm(:) = 0 + p%precv(ilev_)%rprcparm(:) = dzero + p%precv(ilev_)%prec%iprcparm(:) = 0 + p%precv(ilev_)%prec%rprcparm(:) = dzero + p%precv(ilev_)%prec%iprcparm(mld_smoother_type_) = mld_as_ + p%precv(ilev_)%prec%iprcparm(mld_sub_solve_) = mld_ilu_n_ + p%precv(ilev_)%prec%iprcparm(mld_sub_restr_) = psb_halo_ + p%precv(ilev_)%prec%iprcparm(mld_sub_prol_) = psb_none_ + p%precv(ilev_)%prec%iprcparm(mld_sub_ren_) = 0 + p%precv(ilev_)%prec%iprcparm(mld_sub_ovr_) = 1 + p%precv(ilev_)%prec%iprcparm(mld_sub_fillin_) = 0 + p%precv(ilev_)%prec%iprcparm(mld_smoother_sweeps_) = 1 if (nlev_ == 1) return do ilev_ = 2, nlev_ -1 - if (info == 0) call psb_realloc(mld_ifpsz_,p%baseprecv(ilev_)%iprcparm,info) - if (info == 0) call psb_realloc(mld_rfpsz_,p%baseprecv(ilev_)%rprcparm,info) + if (info == 0) call psb_realloc(mld_ifpsz_,p%precv(ilev_)%iprcparm,info) + if (info == 0) call psb_realloc(mld_rfpsz_,p%precv(ilev_)%rprcparm,info) + if (info == 0) call psb_realloc(mld_ifpsz_,p%precv(ilev_)%prec%iprcparm,info) + if (info == 0) call psb_realloc(mld_rfpsz_,p%precv(ilev_)%prec%rprcparm,info) if (info /= 0) return - p%baseprecv(ilev_)%iprcparm(:) = 0 - p%baseprecv(ilev_)%rprcparm(:) = dzero - p%baseprecv(ilev_)%iprcparm(mld_smoother_type_) = mld_as_ - p%baseprecv(ilev_)%iprcparm(mld_sub_restr_) = psb_halo_ - p%baseprecv(ilev_)%iprcparm(mld_sub_prol_) = psb_none_ - p%baseprecv(ilev_)%iprcparm(mld_sub_ren_) = 0 - p%baseprecv(ilev_)%iprcparm(mld_sub_ovr_) = 1 - p%baseprecv(ilev_)%iprcparm(mld_ml_type_) = mld_mult_ml_ - p%baseprecv(ilev_)%iprcparm(mld_aggr_alg_) = mld_dec_aggr_ - p%baseprecv(ilev_)%iprcparm(mld_aggr_kind_) = mld_smooth_prol_ - p%baseprecv(ilev_)%iprcparm(mld_coarse_mat_) = mld_distr_mat_ - p%baseprecv(ilev_)%iprcparm(mld_smoother_pos_) = mld_post_smooth_ - p%baseprecv(ilev_)%iprcparm(mld_aggr_omega_alg_) = mld_eig_est_ - p%baseprecv(ilev_)%iprcparm(mld_aggr_eig_) = mld_max_norm_ - p%baseprecv(ilev_)%iprcparm(mld_sub_solve_) = mld_ilu_n_ - p%baseprecv(ilev_)%iprcparm(mld_sub_fillin_) = 0 - p%baseprecv(ilev_)%iprcparm(mld_smoother_sweeps_) = 1 - p%baseprecv(ilev_)%rprcparm(mld_aggr_omega_val_) = dzero - p%baseprecv(ilev_)%rprcparm(mld_aggr_thresh_) = dzero + p%precv(ilev_)%iprcparm(:) = 0 + p%precv(ilev_)%rprcparm(:) = dzero + p%precv(ilev_)%prec%iprcparm(:) = 0 + p%precv(ilev_)%prec%rprcparm(:) = dzero + p%precv(ilev_)%prec%iprcparm(mld_smoother_type_) = mld_as_ + p%precv(ilev_)%prec%iprcparm(mld_sub_restr_) = psb_halo_ + p%precv(ilev_)%prec%iprcparm(mld_sub_prol_) = psb_none_ + p%precv(ilev_)%prec%iprcparm(mld_sub_ren_) = 0 + p%precv(ilev_)%prec%iprcparm(mld_sub_ovr_) = 1 + p%precv(ilev_)%prec%iprcparm(mld_sub_solve_) = mld_ilu_n_ + p%precv(ilev_)%prec%iprcparm(mld_sub_fillin_) = 0 + p%precv(ilev_)%prec%iprcparm(mld_smoother_sweeps_) = 1 + p%precv(ilev_)%iprcparm(mld_ml_type_) = mld_mult_ml_ + p%precv(ilev_)%iprcparm(mld_aggr_alg_) = mld_dec_aggr_ + p%precv(ilev_)%iprcparm(mld_aggr_kind_) = mld_smooth_prol_ + p%precv(ilev_)%iprcparm(mld_coarse_mat_) = mld_distr_mat_ + p%precv(ilev_)%iprcparm(mld_smoother_pos_) = mld_post_smooth_ + p%precv(ilev_)%iprcparm(mld_aggr_omega_alg_) = mld_eig_est_ + p%precv(ilev_)%iprcparm(mld_aggr_eig_) = mld_max_norm_ + p%precv(ilev_)%rprcparm(mld_aggr_omega_val_) = dzero + p%precv(ilev_)%rprcparm(mld_aggr_thresh_) = dzero end do ilev_ = nlev_ - if (info == 0) call psb_realloc(mld_ifpsz_,p%baseprecv(ilev_)%iprcparm,info) - if (info == 0) call psb_realloc(mld_rfpsz_,p%baseprecv(ilev_)%rprcparm,info) + if (info == 0) call psb_realloc(mld_ifpsz_,p%precv(ilev_)%iprcparm,info) + if (info == 0) call psb_realloc(mld_rfpsz_,p%precv(ilev_)%rprcparm,info) + if (info == 0) call psb_realloc(mld_ifpsz_,p%precv(ilev_)%prec%iprcparm,info) + if (info == 0) call psb_realloc(mld_rfpsz_,p%precv(ilev_)%prec%rprcparm,info) if (info /= 0) return - p%baseprecv(ilev_)%iprcparm(:) = 0 - p%baseprecv(ilev_)%rprcparm(:) = dzero - p%baseprecv(ilev_)%iprcparm(mld_coarse_solve_) = mld_bjac_ + p%precv(ilev_)%iprcparm(:) = 0 + p%precv(ilev_)%rprcparm(:) = dzero + p%precv(ilev_)%prec%iprcparm(:) = 0 + p%precv(ilev_)%prec%rprcparm(:) = dzero + p%precv(ilev_)%prec%iprcparm(mld_coarse_solve_) = mld_bjac_ #if defined(HAVE_UMF_) - p%baseprecv(ilev_)%iprcparm(mld_sub_solve_) = mld_umf_ + p%precv(ilev_)%prec%iprcparm(mld_sub_solve_) = mld_umf_ #elif defined(HAVE_SLU_) - p%baseprecv(ilev_)%iprcparm(mld_sub_solve_) = mld_slu_ + p%precv(ilev_)%prec%iprcparm(mld_sub_solve_) = mld_slu_ #else - p%baseprecv(ilev_)%iprcparm(mld_sub_solve_) = mld_ilu_n_ + p%precv(ilev_)%prec%iprcparm(mld_sub_solve_) = mld_ilu_n_ #endif - p%baseprecv(ilev_)%iprcparm(mld_smoother_type_) = mld_bjac_ - p%baseprecv(ilev_)%iprcparm(mld_coarse_mat_) = mld_distr_mat_ - p%baseprecv(ilev_)%iprcparm(mld_sub_restr_) = psb_none_ - p%baseprecv(ilev_)%iprcparm(mld_sub_prol_) = psb_none_ - p%baseprecv(ilev_)%iprcparm(mld_sub_ren_) = 0 - p%baseprecv(ilev_)%iprcparm(mld_sub_ovr_) = 0 - p%baseprecv(ilev_)%iprcparm(mld_ml_type_) = mld_mult_ml_ - p%baseprecv(ilev_)%iprcparm(mld_aggr_alg_) = mld_dec_aggr_ - p%baseprecv(ilev_)%iprcparm(mld_aggr_kind_) = mld_smooth_prol_ - p%baseprecv(ilev_)%iprcparm(mld_smoother_pos_) = mld_post_smooth_ - p%baseprecv(ilev_)%iprcparm(mld_aggr_omega_alg_) = mld_eig_est_ - p%baseprecv(ilev_)%iprcparm(mld_aggr_eig_) = mld_max_norm_ - p%baseprecv(ilev_)%iprcparm(mld_sub_fillin_) = 0 - p%baseprecv(ilev_)%iprcparm(mld_smoother_sweeps_) = 4 - p%baseprecv(ilev_)%rprcparm(mld_aggr_omega_val_) = dzero - p%baseprecv(ilev_)%rprcparm(mld_aggr_thresh_) = dzero + p%precv(ilev_)%prec%iprcparm(mld_smoother_type_) = mld_bjac_ + p%precv(ilev_)%prec%iprcparm(mld_coarse_mat_) = mld_distr_mat_ + p%precv(ilev_)%prec%iprcparm(mld_sub_restr_) = psb_none_ + p%precv(ilev_)%prec%iprcparm(mld_sub_prol_) = psb_none_ + p%precv(ilev_)%prec%iprcparm(mld_sub_ren_) = 0 + p%precv(ilev_)%prec%iprcparm(mld_sub_ovr_) = 0 + p%precv(ilev_)%prec%iprcparm(mld_sub_fillin_) = 0 + p%precv(ilev_)%prec%iprcparm(mld_smoother_sweeps_) = 4 + p%precv(ilev_)%iprcparm(mld_ml_type_) = mld_mult_ml_ + p%precv(ilev_)%iprcparm(mld_aggr_alg_) = mld_dec_aggr_ + p%precv(ilev_)%iprcparm(mld_aggr_kind_) = mld_smooth_prol_ + p%precv(ilev_)%iprcparm(mld_smoother_pos_) = mld_post_smooth_ + p%precv(ilev_)%iprcparm(mld_aggr_omega_alg_) = mld_eig_est_ + p%precv(ilev_)%iprcparm(mld_aggr_eig_) = mld_max_norm_ + p%precv(ilev_)%rprcparm(mld_aggr_omega_val_) = dzero + p%precv(ilev_)%rprcparm(mld_aggr_thresh_) = dzero case default write(0,*) name,': Warning: Unknown preconditioner type request "',ptype,'"' diff --git a/mlprec/mld_dprecset.f90 b/mlprec/mld_dprecset.f90 index a7f3aabc..ccd9ad10 100644 --- a/mlprec/mld_dprecset.f90 +++ b/mlprec/mld_dprecset.f90 @@ -96,12 +96,12 @@ subroutine mld_dprecseti(p,what,val,info,ilev) info = 0 - if (.not.allocated(p%baseprecv)) then + if (.not.allocated(p%precv)) then info = 3111 write(0,*) name,': Error: uninitialized preconditioner, should call MLD_PRECINIT' return endif - nlev_ = size(p%baseprecv) + nlev_ = size(p%precv) if (present(ilev)) then ilev_ = ilev @@ -114,7 +114,13 @@ subroutine mld_dprecseti(p,what,val,info,ilev) write(0,*) name,': Error: invalid ILEV/NLEV combination',ilev_, nlev_ return endif - if (.not.allocated(p%baseprecv(ilev_)%iprcparm)) then + if (.not.allocated(p%precv(ilev_)%iprcparm)) then + info = 3111 + write(0,*) name,& + &': Error: uninitialized preconditioner component, should call MLD_PRECINIT' + return + endif + if (.not.allocated(p%precv(ilev_)%prec%iprcparm)) then info = 3111 write(0,*) name,& &': Error: uninitialized preconditioner component, should call MLD_PRECINIT' @@ -133,7 +139,7 @@ subroutine mld_dprecseti(p,what,val,info,ilev) select case(what) case(mld_smoother_type_,mld_sub_solve_,mld_sub_restr_,mld_sub_prol_,& & mld_sub_ren_,mld_sub_ovr_,mld_sub_fillin_,mld_smoother_sweeps_) - p%baseprecv(ilev_)%iprcparm(what) = val + p%precv(ilev_)%prec%iprcparm(what) = val case default write(0,*) name,': Error: invalid WHAT' info = -2 @@ -143,23 +149,25 @@ subroutine mld_dprecseti(p,what,val,info,ilev) select case(what) case(mld_smoother_type_,mld_sub_solve_,mld_sub_restr_,mld_sub_prol_,& & mld_sub_ren_,mld_sub_ovr_,mld_sub_fillin_,& - & mld_smoother_sweeps_,mld_ml_type_,mld_aggr_alg_,mld_aggr_kind_,& + & mld_smoother_sweeps_) + p%precv(ilev_)%prec%iprcparm(what) = val + case(mld_ml_type_,mld_aggr_alg_,mld_aggr_kind_,& & mld_smoother_pos_,mld_aggr_omega_alg_,mld_aggr_eig_) - p%baseprecv(ilev_)%iprcparm(what) = val + p%precv(ilev_)%iprcparm(what) = val case(mld_coarse_mat_) if (ilev_ /= nlev_ .and. val /= mld_distr_mat_) then write(0,*) name,': Error: Inconsistent specification of WHAT vs. ILEV' info = -2 return end if - p%baseprecv(ilev_)%iprcparm(mld_coarse_mat_) = val + p%precv(ilev_)%iprcparm(mld_coarse_mat_) = val case(mld_coarse_subsolve_) if (ilev_ /= nlev_) then write(0,*) name,': Error: Inconsistent specification of WHAT vs. ILEV' info = -2 return end if - p%baseprecv(ilev_)%iprcparm(mld_sub_solve_) = val + p%precv(ilev_)%iprcparm(mld_sub_solve_) = val case(mld_coarse_solve_) if (ilev_ /= nlev_) then write(0,*) name,': Error: Inconsistent specification of WHAT vs. ILEV' @@ -168,15 +176,15 @@ subroutine mld_dprecseti(p,what,val,info,ilev) end if if (nlev_ > 1) then - p%baseprecv(nlev_)%iprcparm(mld_coarse_solve_) = val - p%baseprecv(nlev_)%iprcparm(mld_smoother_type_) = mld_bjac_ - p%baseprecv(nlev_)%iprcparm(mld_coarse_mat_) = mld_distr_mat_ + p%precv(nlev_)%iprcparm(mld_coarse_solve_) = val + p%precv(nlev_)%prec%iprcparm(mld_smoother_type_) = mld_bjac_ + p%precv(nlev_)%iprcparm(mld_coarse_mat_) = mld_distr_mat_ select case (val) case(mld_umf_, mld_slu_) - p%baseprecv(nlev_)%iprcparm(mld_coarse_mat_) = mld_repl_mat_ - p%baseprecv(nlev_)%iprcparm(mld_sub_solve_) = val + p%precv(nlev_)%iprcparm(mld_coarse_mat_) = mld_repl_mat_ + p%precv(nlev_)%prec%iprcparm(mld_sub_solve_) = val case(mld_sludist_) - p%baseprecv(nlev_)%iprcparm(mld_sub_solve_) = val + p%precv(nlev_)%prec%iprcparm(mld_sub_solve_) = val end select endif case(mld_coarse_sweeps_) @@ -185,14 +193,14 @@ subroutine mld_dprecseti(p,what,val,info,ilev) info = -2 return end if - p%baseprecv(ilev_)%iprcparm(mld_smoother_sweeps_) = val + p%precv(ilev_)%prec%iprcparm(mld_smoother_sweeps_) = val case(mld_coarse_fillin_) if (ilev_ /= nlev_) then write(0,*) name,': Error: Inconsistent specification of WHAT vs. ILEV' info = -2 return end if - p%baseprecv(ilev_)%iprcparm(mld_sub_fillin_) = val + p%precv(ilev_)%prec%iprcparm(mld_sub_fillin_) = val case default write(0,*) name,': Error: invalid WHAT' info = -2 @@ -210,35 +218,35 @@ subroutine mld_dprecseti(p,what,val,info,ilev) & mld_sub_ren_,mld_sub_ovr_,mld_sub_fillin_,& & mld_smoother_sweeps_) do ilev_=1,max(1,nlev_-1) - if (.not.allocated(p%baseprecv(ilev_)%iprcparm)) then + if (.not.allocated(p%precv(ilev_)%iprcparm)) then write(0,*) name,& &': Error: uninitialized preconditioner component, should call MLD_PRECINIT' info = -1 return endif - p%baseprecv(ilev_)%iprcparm(what) = val + p%precv(ilev_)%prec%iprcparm(what) = val end do case(mld_ml_type_,mld_aggr_alg_,mld_aggr_kind_,& & mld_smoother_pos_,mld_aggr_omega_alg_,mld_aggr_eig_) do ilev_=2,nlev_ - if (.not.allocated(p%baseprecv(ilev_)%iprcparm)) then + if (.not.allocated(p%precv(ilev_)%iprcparm)) then write(0,*) name,& &': Error: uninitialized preconditioner component, should call MLD_PRECINIT' info = -1 return endif - p%baseprecv(ilev_)%iprcparm(what) = val + p%precv(ilev_)%iprcparm(what) = val end do case(mld_coarse_mat_) - if (.not.allocated(p%baseprecv(nlev_)%iprcparm)) then + if (.not.allocated(p%precv(nlev_)%iprcparm)) then write(0,*) name,& & ': Error: uninitialized preconditioner component, should call MLD_PRECINIT' info = -1 return endif - if (nlev_ > 1) p%baseprecv(nlev_)%iprcparm(mld_coarse_mat_) = val + if (nlev_ > 1) p%precv(nlev_)%iprcparm(mld_coarse_mat_) = val case(mld_coarse_solve_) - if (.not.allocated(p%baseprecv(nlev_)%iprcparm)) then + if (.not.allocated(p%precv(nlev_)%iprcparm)) then write(0,*) name,& &': Error: uninitialized preconditioner component, should call MLD_PRECINIT' info = -1 @@ -246,42 +254,42 @@ subroutine mld_dprecseti(p,what,val,info,ilev) endif if (nlev_ > 1) then - p%baseprecv(nlev_)%iprcparm(mld_coarse_solve_) = val - p%baseprecv(nlev_)%iprcparm(mld_smoother_type_) = mld_bjac_ - p%baseprecv(nlev_)%iprcparm(mld_coarse_mat_) = mld_distr_mat_ + p%precv(nlev_)%iprcparm(mld_coarse_solve_) = val + p%precv(nlev_)%prec%iprcparm(mld_smoother_type_) = mld_bjac_ + p%precv(nlev_)%iprcparm(mld_coarse_mat_) = mld_distr_mat_ select case (val) case(mld_umf_, mld_slu_) - p%baseprecv(nlev_)%iprcparm(mld_coarse_mat_) = mld_repl_mat_ - p%baseprecv(nlev_)%iprcparm(mld_sub_solve_) = val + p%precv(nlev_)%iprcparm(mld_coarse_mat_) = mld_repl_mat_ + p%precv(nlev_)%prec%iprcparm(mld_sub_solve_) = val case(mld_sludist_) - p%baseprecv(nlev_)%iprcparm(mld_sub_solve_) = val + p%precv(nlev_)%prec%iprcparm(mld_sub_solve_) = val end select endif case(mld_coarse_subsolve_) - if (.not.allocated(p%baseprecv(nlev_)%iprcparm)) then + if (.not.allocated(p%precv(nlev_)%iprcparm)) then write(0,*) name,& &': Error: uninitialized preconditioner component, should call MLD_PRECINIT' info = -1 return end if - if (nlev_ > 1) p%baseprecv(nlev_)%iprcparm(mld_sub_solve_) = val + if (nlev_ > 1) p%precv(nlev_)%prec%iprcparm(mld_sub_solve_) = val case(mld_coarse_sweeps_) - if (.not.allocated(p%baseprecv(nlev_)%iprcparm)) then + if (.not.allocated(p%precv(nlev_)%iprcparm)) then write(0,*) name,& &': Error: uninitialized preconditioner component, should call MLD_PRECINIT' info = -1 return endif - if (nlev_ > 1) p%baseprecv(nlev_)%iprcparm(mld_smoother_sweeps_) = val + if (nlev_ > 1) p%precv(nlev_)%prec%iprcparm(mld_smoother_sweeps_) = val case(mld_coarse_fillin_) - if (.not.allocated(p%baseprecv(nlev_)%iprcparm)) then + if (.not.allocated(p%precv(nlev_)%iprcparm)) then write(0,*) name,& &': Error: uninitialized preconditioner component, should call MLD_PRECINIT' info = -1 return endif - if (nlev_ > 1) p%baseprecv(nlev_)%iprcparm(mld_sub_fillin_) = val + if (nlev_ > 1) p%precv(nlev_)%prec%iprcparm(mld_sub_fillin_) = val case default write(0,*) name,': Error: invalid WHAT' info = -2 @@ -351,11 +359,11 @@ subroutine mld_dprecsetc(p,what,string,info,ilev) info = 0 - if (.not.allocated(p%baseprecv)) then + if (.not.allocated(p%precv)) then info = 3111 return endif - nlev_ = size(p%baseprecv) + nlev_ = size(p%precv) if (present(ilev)) then ilev_ = ilev @@ -368,7 +376,7 @@ subroutine mld_dprecsetc(p,what,string,info,ilev) info = -1 return endif - if (.not.allocated(p%baseprecv(ilev_)%iprcparm)) then + if (.not.allocated(p%precv(ilev_)%iprcparm)) then write(0,*) name,': Error: uninitialized preconditioner component, should call MLD_PRECINIT' info = 3111 return @@ -446,19 +454,19 @@ subroutine mld_dprecsetr(p,what,val,info,ilev) ilev_ = 1 end if - if (.not.allocated(p%baseprecv)) then + if (.not.allocated(p%precv)) then write(0,*) name,': Error: uninitialized preconditioner, should call MLD_PRECINIT' info = 3111 return endif - nlev_ = size(p%baseprecv) + nlev_ = size(p%precv) if ((ilev_<1).or.(ilev_ > nlev_)) then write(0,*) name,': Error: invalid ILEV/NLEV combination',ilev_, nlev_ info = -1 return endif - if (.not.allocated(p%baseprecv(ilev_)%rprcparm)) then + if (.not.allocated(p%precv(ilev_)%rprcparm)) then write(0,*) name,': Error: uninitialized preconditioner component, should call MLD_PRECINIT' info = 3111 return @@ -475,7 +483,7 @@ subroutine mld_dprecsetr(p,what,val,info,ilev) ! select case(what) case(mld_sub_iluthrs_) - p%baseprecv(ilev_)%rprcparm(what) = val + p%precv(ilev_)%prec%rprcparm(what) = val case default write(0,*) name,': Error: invalid WHAT' info = -2 @@ -483,8 +491,10 @@ subroutine mld_dprecsetr(p,what,val,info,ilev) else if (ilev_ > 1) then select case(what) - case(mld_aggr_omega_val_,mld_aggr_thresh_,mld_sub_iluthrs_) - p%baseprecv(ilev_)%rprcparm(what) = val + case(mld_sub_iluthrs_) + p%precv(ilev_)%prec%rprcparm(what) = val + case(mld_aggr_omega_val_,mld_aggr_thresh_) + p%precv(ilev_)%rprcparm(what) = val case default write(0,*) name,': Error: invalid WHAT' info = -2 @@ -499,38 +509,38 @@ subroutine mld_dprecsetr(p,what,val,info,ilev) select case(what) case(mld_sub_iluthrs_) do ilev_=1,nlev_ - if (.not.allocated(p%baseprecv(ilev_)%rprcparm)) then + if (.not.allocated(p%precv(ilev_)%rprcparm)) then write(0,*) name,': Error: uninitialized preconditioner component, should call MLD_PRECINIT' info = -1 return endif - p%baseprecv(ilev_)%rprcparm(what) = val + p%precv(ilev_)%prec%rprcparm(what) = val end do case(mld_coarse_iluthrs_) ilev_=nlev_ - if (.not.allocated(p%baseprecv(ilev_)%rprcparm)) then + if (.not.allocated(p%precv(ilev_)%rprcparm)) then write(0,*) name,': Error: uninitialized preconditioner component, should call MLD_PRECINIT' info = -1 return endif - p%baseprecv(ilev_)%rprcparm(mld_sub_iluthrs_) = val + p%precv(ilev_)%prec%rprcparm(mld_sub_iluthrs_) = val case(mld_aggr_omega_val_) do ilev_=2,nlev_ - if (.not.allocated(p%baseprecv(ilev_)%rprcparm)) then + if (.not.allocated(p%precv(ilev_)%rprcparm)) then write(0,*) name,': Error: uninitialized preconditioner component, should call MLD_PRECINIT' info = -1 return endif - p%baseprecv(ilev_)%rprcparm(what) = val + p%precv(ilev_)%rprcparm(what) = val end do case(mld_aggr_thresh_) do ilev_=2,nlev_ - if (.not.allocated(p%baseprecv(ilev_)%rprcparm)) then + if (.not.allocated(p%precv(ilev_)%rprcparm)) then write(0,*) name,': Error: uninitialized preconditioner component, should call MLD_PRECINIT' info = -1 return endif - p%baseprecv(ilev_)%rprcparm(what) = val + p%precv(ilev_)%rprcparm(what) = val end do case default write(0,*) name,': Error: invalid WHAT' diff --git a/mlprec/mld_inner_mod.f90 b/mlprec/mld_inner_mod.f90 index b9728f91..41d76ab2 100644 --- a/mlprec/mld_inner_mod.f90 +++ b/mlprec/mld_inner_mod.f90 @@ -142,11 +142,11 @@ module mld_inner_mod end interface interface mld_mlprec_aply - subroutine mld_smlprec_aply(alpha,baseprecv,x,beta,y,desc_data,trans,work,info) + subroutine mld_smlprec_aply(alpha,precv,x,beta,y,desc_data,trans,work,info) use psb_base_mod, only : psb_sspmat_type, psb_desc_type, psb_spk_ - use mld_prec_type, only : mld_sbaseprc_type + use mld_prec_type, only : mld_sbaseprc_type, mld_s_onelev_prec_type type(psb_desc_type),intent(in) :: desc_data - type(mld_sbaseprc_type), intent(in) :: baseprecv(:) + type(mld_s_onelev_prec_type), intent(in) :: precv(:) real(psb_spk_),intent(in) :: alpha,beta real(psb_spk_),intent(in) :: x(:) real(psb_spk_),intent(inout) :: y(:) @@ -154,23 +154,23 @@ module mld_inner_mod real(psb_spk_),target :: work(:) integer, intent(out) :: info end subroutine mld_smlprec_aply - subroutine mld_dmlprec_aply(alpha,baseprecv,x,beta,y,desc_data,trans,work,info) + subroutine mld_dmlprec_aply(alpha,precv,x,beta,y,desc_data,trans,work,info) use psb_base_mod, only : psb_dspmat_type, psb_desc_type, psb_dpk_ - use mld_prec_type, only : mld_dbaseprc_type + use mld_prec_type, only : mld_dbaseprc_type, mld_d_onelev_prec_type type(psb_desc_type),intent(in) :: desc_data - type(mld_dbaseprc_type), intent(in) :: baseprecv(:) + type(mld_d_onelev_prec_type), intent(in) :: precv(:) real(psb_dpk_),intent(in) :: alpha,beta real(psb_dpk_),intent(in) :: x(:) real(psb_dpk_),intent(inout) :: y(:) - character :: trans + character :: trans real(psb_dpk_),target :: work(:) - integer, intent(out) :: info + integer, intent(out) :: info end subroutine mld_dmlprec_aply subroutine mld_cmlprec_aply(alpha,baseprecv,x,beta,y,desc_data,trans,work,info) use psb_base_mod, only : psb_cspmat_type, psb_desc_type, psb_spk_ - use mld_prec_type, only : mld_cbaseprc_type + use mld_prec_type, only : mld_cbaseprc_type, mld_c_onelev_prec_type type(psb_desc_type),intent(in) :: desc_data - type(mld_cbaseprc_type), intent(in) :: baseprecv(:) + type(mld_c_onelev_prec_type), intent(in) :: baseprecv(:) complex(psb_spk_),intent(in) :: alpha,beta complex(psb_spk_),intent(in) :: x(:) complex(psb_spk_),intent(inout) :: y(:) @@ -180,9 +180,9 @@ module mld_inner_mod end subroutine mld_cmlprec_aply subroutine mld_zmlprec_aply(alpha,baseprecv,x,beta,y,desc_data,trans,work,info) use psb_base_mod, only : psb_zspmat_type, psb_desc_type, psb_dpk_ - use mld_prec_type, only : mld_zbaseprc_type + use mld_prec_type, only : mld_zbaseprc_type, mld_z_onelev_prec_type type(psb_desc_type),intent(in) :: desc_data - type(mld_zbaseprc_type), intent(in) :: baseprecv(:) + type(mld_z_onelev_prec_type), intent(in) :: baseprecv(:) complex(psb_dpk_),intent(in) :: alpha,beta complex(psb_dpk_),intent(in) :: x(:) complex(psb_dpk_),intent(inout) :: y(:) @@ -427,130 +427,106 @@ module mld_inner_mod end interface interface mld_aggrmat_asb - subroutine mld_saggrmat_asb(a,desc_a,ac,desc_ac,p,info) + subroutine mld_saggrmat_asb(a,desc_a,p,info) use psb_base_mod, only : psb_sspmat_type, psb_desc_type, psb_spk_ - use mld_prec_type, only : mld_sbaseprc_type + use mld_prec_type, only : mld_sbaseprc_type, mld_s_onelev_prec_type type(psb_sspmat_type), intent(in) :: a type(psb_desc_type), intent(in) :: desc_a - type(psb_sspmat_type), intent(out) :: ac - type(psb_desc_type), intent(out) :: desc_ac - type(mld_sbaseprc_type), intent(inout), target :: p + type(mld_s_onelev_prec_type), intent(inout), target :: p integer, intent(out) :: info end subroutine mld_saggrmat_asb - subroutine mld_daggrmat_asb(a,desc_a,ac,desc_ac,p,info) + subroutine mld_daggrmat_asb(a,desc_a,p,info) use psb_base_mod, only : psb_dspmat_type, psb_desc_type, psb_dpk_ - use mld_prec_type, only : mld_dbaseprc_type + use mld_prec_type, only : mld_dbaseprc_type, mld_d_onelev_prec_type type(psb_dspmat_type), intent(in) :: a type(psb_desc_type), intent(in) :: desc_a - type(psb_dspmat_type), intent(out) :: ac - type(psb_desc_type), intent(out) :: desc_ac - type(mld_dbaseprc_type), intent(inout), target :: p + type(mld_d_onelev_prec_type), intent(inout), target :: p integer, intent(out) :: info end subroutine mld_daggrmat_asb - subroutine mld_caggrmat_asb(a,desc_a,ac,desc_ac,p,info) + subroutine mld_caggrmat_asb(a,desc_a,p,info) use psb_base_mod, only : psb_cspmat_type, psb_desc_type, psb_spk_ - use mld_prec_type, only : mld_cbaseprc_type + use mld_prec_type, only : mld_cbaseprc_type, mld_c_onelev_prec_type type(psb_cspmat_type), intent(in) :: a type(psb_desc_type), intent(in) :: desc_a - type(psb_cspmat_type), intent(out) :: ac - type(psb_desc_type), intent(out) :: desc_ac - type(mld_cbaseprc_type), intent(inout), target :: p + type(mld_c_onelev_prec_type), intent(inout), target :: p integer, intent(out) :: info end subroutine mld_caggrmat_asb - subroutine mld_zaggrmat_asb(a,desc_a,ac,desc_ac,p,info) + subroutine mld_zaggrmat_asb(a,desc_a,p,info) use psb_base_mod, only : psb_zspmat_type, psb_desc_type, psb_dpk_ - use mld_prec_type, only : mld_zbaseprc_type + use mld_prec_type, only : mld_zbaseprc_type, mld_z_onelev_prec_type type(psb_zspmat_type), intent(in) :: a type(psb_desc_type), intent(in) :: desc_a - type(psb_zspmat_type), intent(out) :: ac - type(psb_desc_type), intent(out) :: desc_ac - type(mld_zbaseprc_type), intent(inout), target :: p + type(mld_z_onelev_prec_type), intent(inout), target :: p integer, intent(out) :: info end subroutine mld_zaggrmat_asb end interface interface mld_aggrmat_raw_asb - subroutine mld_saggrmat_raw_asb(a,desc_a,ac,desc_ac,p,info) + subroutine mld_saggrmat_raw_asb(a,desc_a,p,info) use psb_base_mod, only : psb_sspmat_type, psb_desc_type, psb_spk_ - use mld_prec_type, only : mld_sbaseprc_type + use mld_prec_type, only : mld_sbaseprc_type, mld_s_onelev_prec_type type(psb_sspmat_type), intent(in) :: a type(psb_desc_type), intent(in) :: desc_a - type(psb_sspmat_type), intent(out) :: ac - type(psb_desc_type), intent(out) :: desc_ac - type(mld_sbaseprc_type), intent(inout), target :: p + type(mld_s_onelev_prec_type), intent(inout), target :: p integer, intent(out) :: info end subroutine mld_saggrmat_raw_asb - subroutine mld_daggrmat_raw_asb(a,desc_a,ac,desc_ac,p,info) + subroutine mld_daggrmat_raw_asb(a,desc_a,p,info) use psb_base_mod, only : psb_dspmat_type, psb_desc_type, psb_dpk_ - use mld_prec_type, only : mld_dbaseprc_type + use mld_prec_type, only : mld_dbaseprc_type, mld_d_onelev_prec_type type(psb_dspmat_type), intent(in) :: a type(psb_desc_type), intent(in) :: desc_a - type(psb_dspmat_type), intent(out) :: ac - type(psb_desc_type), intent(out) :: desc_ac - type(mld_dbaseprc_type), intent(inout), target :: p + type(mld_d_onelev_prec_type), intent(inout), target :: p integer, intent(out) :: info end subroutine mld_daggrmat_raw_asb - subroutine mld_caggrmat_raw_asb(a,desc_a,ac,desc_ac,p,info) + subroutine mld_caggrmat_raw_asb(a,desc_a,p,info) use psb_base_mod, only : psb_cspmat_type, psb_desc_type, psb_spk_ - use mld_prec_type, only : mld_cbaseprc_type + use mld_prec_type, only : mld_cbaseprc_type, mld_c_onelev_prec_type type(psb_cspmat_type), intent(in) :: a type(psb_desc_type), intent(in) :: desc_a - type(psb_cspmat_type), intent(out) :: ac - type(psb_desc_type), intent(out) :: desc_ac - type(mld_cbaseprc_type), intent(inout), target :: p + type(mld_c_onelev_prec_type), intent(inout), target :: p integer, intent(out) :: info end subroutine mld_caggrmat_raw_asb - subroutine mld_zaggrmat_raw_asb(a,desc_a,ac,desc_ac,p,info) + subroutine mld_zaggrmat_raw_asb(a,desc_a,p,info) use psb_base_mod, only : psb_zspmat_type, psb_desc_type, psb_dpk_ - use mld_prec_type, only : mld_zbaseprc_type + use mld_prec_type, only : mld_zbaseprc_type, mld_z_onelev_prec_type type(psb_zspmat_type), intent(in) :: a type(psb_desc_type), intent(in) :: desc_a - type(psb_zspmat_type), intent(out) :: ac - type(psb_desc_type), intent(out) :: desc_ac - type(mld_zbaseprc_type), intent(inout), target :: p + type(mld_z_onelev_prec_type), intent(inout), target :: p integer, intent(out) :: info end subroutine mld_zaggrmat_raw_asb end interface interface mld_aggrmat_smth_asb - subroutine mld_saggrmat_smth_asb(a,desc_a,ac,desc_ac,p,info) + subroutine mld_saggrmat_smth_asb(a,desc_a,p,info) use psb_base_mod, only : psb_sspmat_type, psb_desc_type, psb_spk_ - use mld_prec_type, only : mld_sbaseprc_type + use mld_prec_type, only : mld_sbaseprc_type, mld_s_onelev_prec_type type(psb_sspmat_type), intent(in) :: a type(psb_desc_type), intent(in) :: desc_a - type(psb_sspmat_type), intent(out) :: ac - type(psb_desc_type), intent(out) :: desc_ac - type(mld_sbaseprc_type), intent(inout), target :: p + type(mld_s_onelev_prec_type), intent(inout), target :: p integer, intent(out) :: info end subroutine mld_saggrmat_smth_asb - subroutine mld_daggrmat_smth_asb(a,desc_a,ac,desc_ac,p,info) + subroutine mld_daggrmat_smth_asb(a,desc_a,p,info) use psb_base_mod, only : psb_dspmat_type, psb_desc_type, psb_dpk_ - use mld_prec_type, only : mld_dbaseprc_type + use mld_prec_type, only : mld_dbaseprc_type, mld_d_onelev_prec_type type(psb_dspmat_type), intent(in) :: a type(psb_desc_type), intent(in) :: desc_a - type(psb_dspmat_type), intent(out) :: ac - type(psb_desc_type), intent(out) :: desc_ac - type(mld_dbaseprc_type), intent(inout), target :: p + type(mld_d_onelev_prec_type), intent(inout), target :: p integer, intent(out) :: info end subroutine mld_daggrmat_smth_asb - subroutine mld_caggrmat_smth_asb(a,desc_a,ac,desc_ac,p,info) + subroutine mld_caggrmat_smth_asb(a,desc_a,p,info) use psb_base_mod, only : psb_cspmat_type, psb_desc_type, psb_spk_ - use mld_prec_type, only : mld_cbaseprc_type + use mld_prec_type, only : mld_cbaseprc_type, mld_c_onelev_prec_type type(psb_cspmat_type), intent(in) :: a type(psb_desc_type), intent(in) :: desc_a - type(psb_cspmat_type), intent(out) :: ac - type(psb_desc_type), intent(out) :: desc_ac - type(mld_cbaseprc_type), intent(inout), target :: p + type(mld_c_onelev_prec_type), intent(inout), target :: p integer, intent(out) :: info end subroutine mld_caggrmat_smth_asb - subroutine mld_zaggrmat_smth_asb(a,desc_a,ac,desc_ac,p,info) + subroutine mld_zaggrmat_smth_asb(a,desc_a,p,info) use psb_base_mod, only : psb_zspmat_type, psb_desc_type, psb_dpk_ - use mld_prec_type, only : mld_zbaseprc_type + use mld_prec_type, only : mld_zbaseprc_type, mld_z_onelev_prec_type type(psb_zspmat_type), intent(in) :: a type(psb_desc_type), intent(in) :: desc_a - type(psb_zspmat_type), intent(out) :: ac - type(psb_desc_type), intent(out) :: desc_ac - type(mld_zbaseprc_type), intent(inout), target :: p + type(mld_z_onelev_prec_type), intent(inout), target :: p integer, intent(out) :: info end subroutine mld_zaggrmat_smth_asb end interface @@ -636,34 +612,34 @@ module mld_inner_mod interface mld_mlprec_bld subroutine mld_smlprec_bld(a,desc_a,p,info) use psb_base_mod, only : psb_sspmat_type, psb_desc_type, psb_spk_ - use mld_prec_type, only : mld_sbaseprc_type + use mld_prec_type, only : mld_sbaseprc_type, mld_s_onelev_prec_type type(psb_sspmat_type), intent(inout), target :: a type(psb_desc_type), intent(in), target :: desc_a - type(mld_sbaseprc_type), intent(inout), target :: p + type(mld_s_onelev_prec_type), intent(inout), target :: p integer, intent(out) :: info end subroutine mld_smlprec_bld subroutine mld_dmlprec_bld(a,desc_a,p,info) use psb_base_mod, only : psb_dspmat_type, psb_desc_type, psb_dpk_ - use mld_prec_type, only : mld_dbaseprc_type + use mld_prec_type, only : mld_dbaseprc_type, mld_d_onelev_prec_type type(psb_dspmat_type), intent(inout), target :: a type(psb_desc_type), intent(in), target :: desc_a - type(mld_dbaseprc_type), intent(inout), target :: p + type(mld_d_onelev_prec_type), intent(inout), target :: p integer, intent(out) :: info end subroutine mld_dmlprec_bld subroutine mld_cmlprec_bld(a,desc_a,p,info) use psb_base_mod, only : psb_cspmat_type, psb_desc_type, psb_spk_ - use mld_prec_type, only : mld_cbaseprc_type + use mld_prec_type, only : mld_cbaseprc_type, mld_c_onelev_prec_type type(psb_cspmat_type), intent(inout), target :: a type(psb_desc_type), intent(in), target :: desc_a - type(mld_cbaseprc_type), intent(inout),target :: p + type(mld_c_onelev_prec_type), intent(inout),target :: p integer, intent(out) :: info end subroutine mld_cmlprec_bld subroutine mld_zmlprec_bld(a,desc_a,p,info) use psb_base_mod, only : psb_zspmat_type, psb_desc_type, psb_dpk_ - use mld_prec_type, only : mld_zbaseprc_type + use mld_prec_type, only : mld_zbaseprc_type, mld_z_onelev_prec_type type(psb_zspmat_type), intent(inout), target :: a type(psb_desc_type), intent(in), target :: desc_a - type(mld_zbaseprc_type), intent(inout),target :: p + type(mld_z_onelev_prec_type), intent(inout),target :: p integer, intent(out) :: info end subroutine mld_zmlprec_bld end interface diff --git a/mlprec/mld_prec_type.f90 b/mlprec/mld_prec_type.f90 index 12ee7a94..9c895005 100644 --- a/mlprec/mld_prec_type.f90 +++ b/mlprec/mld_prec_type.f90 @@ -73,13 +73,14 @@ module mld_prec_type & psb_cd_get_context, psb_info ! - ! Type: mld_dprec_type, mld_zprec_type + ! Type: mld_dprec_type, mld_zprec_type, mld_sprec_type, mld_cprec_type ! - ! mld_dprec_type and mld_zprec_type are the real and complex preconditioner - ! data structures. In the following description 'd' and 'z' are omitted. + ! mld_dprec_type and friends are the real and complex preconditioner + ! data structures. In the following description 'd', 's', 'c' and 'z' + ! are mostly omitted. ! - ! The multilevel preconditioner data structure, mld_prec_type, consists - ! of an array of 'base preconditioner' data structures, mld_dbaseprc_type, + ! The multilevel preconditioner data structure, mld_Xprec_type, consists + ! of an array of 'one-level preconditioner' data structures, mld_X_onelev_type, ! each containing the local part of the preconditioner associated to a ! certain level. For each level ilev, the base preconditioner K(ilev) is ! built from a matrix A(ilev), which is obtained by 'tranferring' the @@ -89,20 +90,48 @@ module mld_prec_type ! The levels are numbered in increasing order starting from the finest ! one, i.e. level 1 is the finest level and A(1) is the matrix A. ! - !| type mld_dprec_type - !| type(mld_dbaseprc_type), allocatable :: baseprecv(:) - !| end type mld_dprec_type + !| type mld_Xprec_type + !| type(mld_X_onelev_prec_type), allocatable :: precv(:) + !| end type mld_Xprec_type !| - !| type mld_zprec_type - !| type(mld_zbaseprc_type), allocatable :: baseprecv(:) - !| end type mld_zprec_type ! - ! baseprecv(ilev) is the base preconditioner at level ilev. - ! The number of levels is given by size(baseprecv(:)). - ! - ! Type: mld_dbaseprc_type, mld_zbaseprc_type. + ! precv(ilev) is the preconditioner at level ilev. + ! The number of levels is given by size(precv(:)). ! - ! av - type(psb_dspmat_type), dimension(:), allocatable(:). + ! Type: mld_X_onelev_prec_type. + ! The data type containing necessary items for the current level. + ! + ! type(mld_Xbaseprc_type) - prec + ! The current level preconditioner (aka smoother). + ! ac - The local part of the matrix A(ilev). + ! desc_ac - type(psb_desc_type). + ! The communication descriptor associated to the sparse matrix + ! A(ilev), stored in ac. + ! iprcparm - integer, dimension(:), allocatable. + ! The integer parameters defining the multilevel strategy + ! rprcparm - real(psb_Ypk_), dimension(:), allocatable. + ! The real parameters defining the multilevel strategy + ! mlia - integer, dimension(:), allocatable. + ! The aggregation map (ilev-1) --> (ilev). + ! In case of non-smoothed aggregation, it is used instead of + ! mld_sm_pr_. + ! nlaggr - integer, dimension(:), allocatable. + ! The number of aggregates (rows of A(ilev)) on the + ! various processes. + ! map_desc - Stores the mapping between indices from level(ilev-1) to (ilev). + ! Unused at level 1 (finest). + ! base_a - type(psb_zspmat_type), pointer. + ! Pointer (really a pointer!) to the local part of the base matrix + ! of the current level, i.e. A(ilev); so we have a unified treatment + ! of residuals. We need this to avoid passing explicitly the matrix + ! A(ilev) to the routine which applies the preconditioner. + ! base_desc - type(psb_desc_type), pointer. + ! Pointer to the communication descriptor associated to the sparse + ! matrix pointed by base_a. + ! Type: mld_Xbaseprc_type + ! The smoother. + ! + ! av - type(psb_Xspmat_type), dimension(:), allocatable(:). ! The sparse matrices needed to apply the preconditioner at ! the current level ilev. ! av(mld_l_pr_) - The L factor of the ILU factorization of the local @@ -112,28 +141,17 @@ module mld_prec_type ! (stored in d). ! av(mld_ap_nd_) - The entries of the local part of A(ilev) outside ! the diagonal block, for block-Jacobi sweeps. - ! av(mld_ac_) - The local part of the matrix A(ilev). - ! av(mld_sm_pr_) - The smoothed prolongator. - ! It maps vectors (ilev) ---> (ilev-1). - ! av(mld_sm_pr_t_) - The smoothed prolongator transpose. - ! It maps vectors (ilev-1) ---> (ilev). - ! Shouldn't we keep just one of the last two items and handle the transpose - ! in the Sparse BLAS? Maybe. - ! - ! d - real(psb_dpk_), dimension(:), allocatable. + ! d - real/complex(psb_Ypk_), dimension(:), allocatable. ! The diagonal entries of the U factor in the ILU factorization ! of A(ilev). ! desc_data - type(psb_desc_type). ! The communication descriptor associated to the base preconditioner, ! i.e. to the sparse matrices needed to apply the base preconditioner ! at the current level. - ! desc_ac - type(psb_desc_type). - ! The communication descriptor associated to the sparse matrix - ! A(ilev), stored in av(mld_ac_). ! iprcparm - integer, dimension(:), allocatable. ! The integer parameters defining the base preconditioner K(ilev) ! (the iprcparm entries and values are specified below). - ! rprcparm - real(psb_dpk_), dimension(:), allocatable. + ! rprcparm - real(psb_Ypk_), dimension(:), allocatable. ! The real parameters defining the base preconditioner K(ilev) ! (the rprcparm entries and values are specified below). ! perm - integer, dimension(:), allocatable. @@ -141,105 +159,120 @@ module mld_prec_type ! A(ilev) (defined only if iprcparm(mld_sub_ren_)>0). ! invperm - integer, dimension(:), allocatable. ! The inverse of the permutation stored in perm. - ! mlia - integer, dimension(:), allocatable. - ! The aggregation map (ilev-1) --> (ilev). - ! In case of non-smoothed aggregation, it is used instead of - ! mld_sm_pr_. - ! nlaggr - integer, dimension(:), allocatable. - ! The number of aggregates (rows of A(ilev)) on the - ! various processes. - ! map_desc - Stores the mapping between indices from level(ilev-1) to (ilev). - ! Unused at level 1 (finest). - ! base_a - type(psb_zspmat_type), pointer. - ! Pointer (really a pointer!) to the local part of the base matrix - ! of the current level, i.e. A(ilev); so we have a unified treatment - ! of residuals. We need this to avoid passing explicitly the matrix - ! A(ilev) to the routine which applies the preconditioner. - ! base_desc - type(psb_desc_type), pointer. - ! Pointer to the communication descriptor associated to the sparse - ! matrix pointed by base_a. ! ! Note that when the LU factorization of the matrix A(ilev) is computed instead of ! the ILU one, by using UMFPACK or SuperLU_dist, the corresponding L and U factors ! are stored in data structures provided by UMFPACK or SuperLU_dist and pointed by - ! iprcparm(mld_umf_ptr) or iprcparm(mld_slu_ptr), respectively. + ! prec%iprcparm(mld_umf_ptr) or prec%iprcparm(mld_slu_ptr), respectively. ! type mld_sbaseprc_type - type(psb_sspmat_type), allocatable :: av(:) real(psb_spk_), allocatable :: d(:) - type(psb_desc_type) :: desc_data , desc_ac + type(psb_desc_type) :: desc_data integer, allocatable :: iprcparm(:) real(psb_spk_), allocatable :: rprcparm(:) integer, allocatable :: perm(:), invperm(:) + end type mld_sbaseprc_type + + type mld_s_onelev_prec_type + type(mld_sbaseprc_type) :: prec + integer, allocatable :: iprcparm(:) + real(psb_spk_), allocatable :: rprcparm(:) + type(psb_sspmat_type) :: ac + type(psb_desc_type) :: desc_ac integer, allocatable :: mlia(:), nlaggr(:) type(psb_sspmat_type), pointer :: base_a => null() type(psb_desc_type), pointer :: base_desc => null() type(psb_inter_desc_type) :: map_desc - end type mld_sbaseprc_type + end type mld_s_onelev_prec_type type mld_sprec_type - type(mld_sbaseprc_type), allocatable :: baseprecv(:) + type(mld_s_onelev_prec_type), allocatable :: precv(:) end type mld_sprec_type type mld_dbaseprc_type - type(psb_dspmat_type), allocatable :: av(:) real(psb_dpk_), allocatable :: d(:) - type(psb_desc_type) :: desc_data , desc_ac + type(psb_desc_type) :: desc_data integer, allocatable :: iprcparm(:) real(psb_dpk_), allocatable :: rprcparm(:) integer, allocatable :: perm(:), invperm(:) + end type mld_dbaseprc_type + + type mld_d_onelev_prec_type + type(mld_dbaseprc_type) :: prec + integer, allocatable :: iprcparm(:) + real(psb_dpk_), allocatable :: rprcparm(:) + type(psb_dspmat_type) :: ac + type(psb_desc_type) :: desc_ac integer, allocatable :: mlia(:), nlaggr(:) type(psb_dspmat_type), pointer :: base_a => null() type(psb_desc_type), pointer :: base_desc => null() type(psb_inter_desc_type) :: map_desc - end type mld_dbaseprc_type + end type mld_d_onelev_prec_type type mld_dprec_type - type(mld_dbaseprc_type), allocatable :: baseprecv(:) + type(mld_d_onelev_prec_type), allocatable :: precv(:) end type mld_dprec_type - type mld_cbaseprc_type + type mld_cbaseprc_type type(psb_cspmat_type), allocatable :: av(:) complex(psb_spk_), allocatable :: d(:) - type(psb_desc_type) :: desc_data , desc_ac + type(psb_desc_type) :: desc_data integer, allocatable :: iprcparm(:) real(psb_spk_), allocatable :: rprcparm(:) integer, allocatable :: perm(:), invperm(:) + end type mld_cbaseprc_type + + type mld_c_onelev_prec_type + type(mld_cbaseprc_type) :: prec + integer, allocatable :: iprcparm(:) + real(psb_spk_), allocatable :: rprcparm(:) + type(psb_cspmat_type) :: ac + type(psb_desc_type) :: desc_ac integer, allocatable :: mlia(:), nlaggr(:) type(psb_cspmat_type), pointer :: base_a => null() type(psb_desc_type), pointer :: base_desc => null() type(psb_inter_desc_type) :: map_desc - end type mld_cbaseprc_type + end type mld_c_onelev_prec_type type mld_cprec_type - type(mld_cbaseprc_type), allocatable :: baseprecv(:) + type(mld_c_onelev_prec_type), allocatable :: precv(:) end type mld_cprec_type type mld_zbaseprc_type - type(psb_zspmat_type), allocatable :: av(:) complex(psb_dpk_), allocatable :: d(:) - type(psb_desc_type) :: desc_data , desc_ac + type(psb_desc_type) :: desc_data integer, allocatable :: iprcparm(:) real(psb_dpk_), allocatable :: rprcparm(:) integer, allocatable :: perm(:), invperm(:) + end type mld_zbaseprc_type + + type mld_z_onelev_prec_type + type(mld_zbaseprc_type) :: prec + integer, allocatable :: iprcparm(:) + real(psb_dpk_), allocatable :: rprcparm(:) + type(psb_zspmat_type) :: ac + type(psb_desc_type) :: desc_ac integer, allocatable :: mlia(:), nlaggr(:) type(psb_zspmat_type), pointer :: base_a => null() type(psb_desc_type), pointer :: base_desc => null() type(psb_inter_desc_type) :: map_desc - end type mld_zbaseprc_type + end type mld_z_onelev_prec_type type mld_zprec_type - type(mld_zbaseprc_type), allocatable :: baseprecv(:) + type(mld_z_onelev_prec_type), allocatable :: precv(:) end type mld_zprec_type + ! ! Entries in iprcparm ! + ! These are in baseprec + ! integer, parameter :: mld_smoother_type_ = 1 integer, parameter :: mld_sub_solve_ = 2 integer, parameter :: mld_sub_restr_ = 3 @@ -248,23 +281,26 @@ module mld_prec_type integer, parameter :: mld_sub_ovr_ = 6 integer, parameter :: mld_sub_fillin_ = 8 integer, parameter :: mld_smoother_sweeps_ = 9 - integer, parameter :: mld_ml_type_ = 10 - integer, parameter :: mld_smoother_pos_ = 11 - integer, parameter :: mld_aggr_kind_ = 12 - integer, parameter :: mld_aggr_alg_ = 13 - integer, parameter :: mld_aggr_omega_alg_ = 14 - integer, parameter :: mld_aggr_eig_ = 15 - integer, parameter :: mld_coarse_mat_ = 16 !! 2 ints for 64 bit versions - integer, parameter :: mld_slu_ptr_ = 17 - integer, parameter :: mld_umf_symptr_ = 17 - integer, parameter :: mld_umf_numptr_ = 19 - integer, parameter :: mld_slud_ptr_ = 21 - integer, parameter :: mld_prec_status_ = 24 - integer, parameter :: mld_coarse_solve_ = 25 - integer, parameter :: mld_coarse_sweeps_ = 26 - integer, parameter :: mld_coarse_fillin_ = 27 - integer, parameter :: mld_coarse_subsolve_ = 28 + integer, parameter :: mld_slu_ptr_ = 10 + integer, parameter :: mld_umf_symptr_ = 12 + integer, parameter :: mld_umf_numptr_ = 14 + integer, parameter :: mld_slud_ptr_ = 16 + integer, parameter :: mld_prec_status_ = 18 + ! + ! These are in onelev_prec + ! + integer, parameter :: mld_ml_type_ = 20 + integer, parameter :: mld_smoother_pos_ = 21 + integer, parameter :: mld_aggr_kind_ = 22 + integer, parameter :: mld_aggr_alg_ = 23 + integer, parameter :: mld_aggr_omega_alg_ = 24 + integer, parameter :: mld_aggr_eig_ = 25 + integer, parameter :: mld_coarse_mat_ = 26 + integer, parameter :: mld_coarse_solve_ = 27 + integer, parameter :: mld_coarse_sweeps_ = 28 + integer, parameter :: mld_coarse_fillin_ = 29 + integer, parameter :: mld_coarse_subsolve_ = 30 integer, parameter :: mld_ifpsz_ = 32 ! @@ -380,11 +416,21 @@ module mld_prec_type & mld_dbase_precfree, mld_zbase_precfree end interface + interface mld_onelev_precfree + module procedure mld_s_onelev_precfree, mld_d_onelev_precfree, & + & mld_c_onelev_precfree, mld_z_onelev_precfree + end interface + interface mld_nullify_baseprec module procedure mld_nullify_sbaseprec, mld_nullify_cbaseprec,& & mld_nullify_dbaseprec, mld_nullify_zbaseprec end interface + interface mld_nullify_onelevprec + module procedure mld_nullify_s_onelevprec, mld_nullify_d_onelevprec,& + & mld_nullify_c_onelevprec, mld_nullify_z_onelevprec + end interface + interface mld_check_def module procedure mld_icheck_def, mld_scheck_def, mld_dcheck_def end interface @@ -404,7 +450,9 @@ module mld_prec_type module procedure mld_sprec_sizeof, mld_cprec_sizeof, & & mld_dprec_sizeof, mld_zprec_sizeof, & & mld_sbaseprc_sizeof, mld_cbaseprc_sizeof,& - & mld_dbaseprc_sizeof, mld_zbaseprc_sizeof + & mld_dbaseprc_sizeof, mld_zbaseprc_sizeof, & + & mld_s_onelev_prec_sizeof, mld_d_onelev_prec_sizeof,& + & mld_c_onelev_prec_sizeof, mld_z_onelev_prec_sizeof end interface contains @@ -518,9 +566,9 @@ contains integer(psb_long_int_k_) :: val integer :: i val = 0 - if (allocated(prec%baseprecv)) then - do i=1, size(prec%baseprecv) - val = val + mld_sizeof(prec%baseprecv(i)) + if (allocated(prec%precv)) then + do i=1, size(prec%precv) + val = val + mld_sizeof(prec%precv(i)) end do end if end function mld_sprec_sizeof @@ -531,9 +579,9 @@ contains integer(psb_long_int_k_) :: val integer :: i val = 0 - if (allocated(prec%baseprecv)) then - do i=1, size(prec%baseprecv) - val = val + mld_sizeof(prec%baseprecv(i)) + if (allocated(prec%precv)) then + do i=1, size(prec%precv) + val = val + mld_sizeof(prec%precv(i)) end do end if end function mld_dprec_sizeof @@ -544,9 +592,9 @@ contains integer(psb_long_int_k_) :: val integer :: i val = 0 - if (allocated(prec%baseprecv)) then - do i=1, size(prec%baseprecv) - val = val + mld_sizeof(prec%baseprecv(i)) + if (allocated(prec%precv)) then + do i=1, size(prec%precv) + val = val + mld_sizeof(prec%precv(i)) end do end if end function mld_cprec_sizeof @@ -557,9 +605,9 @@ contains integer(psb_long_int_k_) :: val integer :: i val = 0 - if (allocated(prec%baseprecv)) then - do i=1, size(prec%baseprecv) - val = val + mld_sizeof(prec%baseprecv(i)) + if (allocated(prec%precv)) then + do i=1, size(prec%precv) + val = val + mld_sizeof(prec%precv(i)) end do end if end function mld_zprec_sizeof @@ -599,7 +647,6 @@ contains val = val + psb_sizeof(prec%av(i)) end do end if - val = val + psb_sizeof(prec%map_desc) end function mld_sbaseprc_sizeof @@ -634,7 +681,7 @@ contains val = val + psb_sizeof(prec%av(i)) end do end if - val = val + psb_sizeof(prec%map_desc) + end function mld_dbaseprc_sizeof @@ -669,7 +716,6 @@ contains val = val + psb_sizeof(prec%av(i)) end do end if - val = val + psb_sizeof(prec%map_desc) end function mld_cbaseprc_sizeof @@ -704,9 +750,76 @@ contains val = val + psb_sizeof(prec%av(i)) end do end if - val = val + psb_sizeof(prec%map_desc) end function mld_zbaseprc_sizeof + + function mld_s_onelev_prec_sizeof(prec) result(val) + implicit none + type(mld_s_onelev_prec_type), intent(in) :: prec + integer(psb_long_int_k_) :: val + integer :: i + + val = mld_sizeof(prec%prec) + if (allocated(prec%iprcparm)) then + val = val + psb_sizeof_int * size(prec%iprcparm) + end if + if (allocated(prec%rprcparm)) val = val + psb_sizeof_sp * size(prec%rprcparm) + val = val + psb_sizeof(prec%desc_ac) + val = val + psb_sizeof(prec%ac) + val = val + psb_sizeof(prec%map_desc) + + end function mld_s_onelev_prec_sizeof + + function mld_d_onelev_prec_sizeof(prec) result(val) + implicit none + type(mld_d_onelev_prec_type), intent(in) :: prec + integer(psb_long_int_k_) :: val + integer :: i + + val = mld_sizeof(prec%prec) + if (allocated(prec%iprcparm)) then + val = val + psb_sizeof_int * size(prec%iprcparm) + end if + if (allocated(prec%rprcparm)) val = val + psb_sizeof_dp * size(prec%rprcparm) + val = val + psb_sizeof(prec%desc_ac) + val = val + psb_sizeof(prec%ac) + val = val + psb_sizeof(prec%map_desc) + + end function mld_d_onelev_prec_sizeof + + function mld_c_onelev_prec_sizeof(prec) result(val) + implicit none + type(mld_c_onelev_prec_type), intent(in) :: prec + integer(psb_long_int_k_) :: val + integer :: i + + val = mld_sizeof(prec%prec) + if (allocated(prec%iprcparm)) then + val = val + psb_sizeof_int * size(prec%iprcparm) + end if + if (allocated(prec%rprcparm)) val = val + psb_sizeof_sp * size(prec%rprcparm) + val = val + psb_sizeof(prec%desc_ac) + val = val + psb_sizeof(prec%ac) + val = val + psb_sizeof(prec%map_desc) + + end function mld_c_onelev_prec_sizeof + + function mld_z_onelev_prec_sizeof(prec) result(val) + implicit none + type(mld_z_onelev_prec_type), intent(in) :: prec + integer(psb_long_int_k_) :: val + integer :: i + + val = mld_sizeof(prec%prec) + if (allocated(prec%iprcparm)) then + val = val + psb_sizeof_int * size(prec%iprcparm) + end if + if (allocated(prec%rprcparm)) val = val + psb_sizeof_dp * size(prec%rprcparm) + val = val + psb_sizeof(prec%desc_ac) + val = val + psb_sizeof(prec%ac) + val = val + psb_sizeof(prec%map_desc) + + end function mld_z_onelev_prec_sizeof ! ! Routines printing out a description of the preconditioner @@ -859,13 +972,14 @@ contains return end subroutine mld_ml_level_descr - subroutine mld_ml_coarse_descr(iout,ilev,iprcparm,nlaggr, info,rprcparm,dprcparm) + subroutine mld_ml_coarse_descr(iout,ilev,iprcparm,iprcparm2,nlaggr,info,& + & rprcparm,dprcparm, rprcparm2,dprcparm2) implicit none - integer, intent(in) :: iprcparm(:),iout,ilev + integer, intent(in) :: iprcparm(:),iprcparm2(:),iout,ilev integer, intent(in), allocatable :: nlaggr(:) integer, intent(out) :: info - real(psb_spk_), intent(in), optional :: rprcparm(:) - real(psb_dpk_), intent(in), optional :: dprcparm(:) + real(psb_spk_), intent(in), optional :: rprcparm(:), rprcparm2(:) + real(psb_dpk_), intent(in), optional :: dprcparm(:), dprcparm2(:) info = 0 if (count((/ present(rprcparm),present(dprcparm) /)) /= 1) then @@ -873,6 +987,11 @@ contains !!$ call psb_errpush(info,name,a_err=" rprcparm, dprcparm") return endif + if (count((/ present(rprcparm2),present(dprcparm2) /)) /= 1) then + info=581 +!!$ call psb_errpush(info,name,a_err=" rprcparm, dprcparm") + return + endif if (iprcparm(mld_ml_type_)>mld_no_ml_) then @@ -898,28 +1017,27 @@ contains if (iprcparm(mld_coarse_mat_) == mld_distr_mat_ .and. & & iprcparm(mld_sub_solve_) /= mld_sludist_) then write(iout,*) ' Coarsest matrix solver: block Jacobi with ', & - & fact_names(iprcparm(mld_sub_solve_)) + & fact_names(iprcparm2(mld_sub_solve_)) write(iout,*) ' Number of Jacobi sweeps: ', & - & (iprcparm(mld_smoother_sweeps_)) + & (iprcparm2(mld_smoother_sweeps_)) else write(iout,*) ' Coarsest matrix solver: ', & - & fact_names(iprcparm(mld_sub_solve_)) + & fact_names(iprcparm2(mld_sub_solve_)) end if - select case(iprcparm(mld_sub_solve_)) + select case(iprcparm2(mld_sub_solve_)) case(mld_ilu_n_,mld_milu_n_) - write(iout,*) ' Fill level:',iprcparm(mld_sub_fillin_) + write(iout,*) ' Fill level:',iprcparm2(mld_sub_fillin_) case(mld_ilu_t_) - write(iout,*) ' Fill level:',iprcparm(mld_sub_fillin_) - if (present(rprcparm)) then - write(iout,*) ' Fill threshold :',rprcparm(mld_sub_iluthrs_) - else - write(iout,*) ' Fill threshold :',dprcparm(mld_sub_iluthrs_) + write(iout,*) ' Fill level:',iprcparm2(mld_sub_fillin_) + if (present(rprcparm2)) then + write(iout,*) ' Fill threshold :',rprcparm2(mld_sub_iluthrs_) + else if (present(dprcparm2)) then + write(iout,*) ' Fill threshold :',dprcparm2(mld_sub_iluthrs_) end if case(mld_slu_,mld_umf_,mld_sludist_) case default write(iout,*) ' Should never get here!' end select - end if @@ -966,8 +1084,8 @@ contains end if if (iout_ < 0) iout_ = 6 - if (allocated(p%baseprecv)) then - ictxt = psb_cd_get_context(p%baseprecv(1)%desc_data) + if (allocated(p%precv)) then + ictxt = psb_cd_get_context(p%precv(1)%prec%desc_data) call psb_info(ictxt,me,np) @@ -981,7 +1099,7 @@ contains write(iout_,*) write(iout_,'(a)') 'Preconditioner description' - nlev = size(p%baseprecv) + nlev = size(p%precv) if (nlev >= 1) then ! ! Print description of base preconditioner @@ -996,8 +1114,8 @@ contains endif ilev = 1 - call mld_base_prec_descr(iout_,p%baseprecv(ilev)%iprcparm,info,& - & dprcparm=p%baseprecv(ilev)%rprcparm) + call mld_base_prec_descr(iout_,p%precv(ilev)%prec%iprcparm,info,& + & dprcparm=p%precv(ilev)%prec%rprcparm) end if @@ -1010,7 +1128,7 @@ contains write(iout_,*) 'Multilevel details' do ilev = 2, nlev - if (.not.allocated(p%baseprecv(ilev)%iprcparm)) then + if (.not.allocated(p%precv(ilev)%iprcparm)) then info = 3111 write(iout_,*) ' ',name,': error: inconsistent MLPREC part, should call MLD_PRECINIT' return @@ -1025,8 +1143,8 @@ contains ! ilev=2 - call mld_ml_alg_descr(iout_,ilev,p%baseprecv(ilev)%iprcparm, info,& - & dprcparm=p%baseprecv(ilev)%rprcparm) + call mld_ml_alg_descr(iout_,ilev,p%precv(ilev)%iprcparm, info,& + & dprcparm=p%precv(ilev)%rprcparm) ! ! Coarse matrices are different at levels 2,...,nlev-1, hence related @@ -1034,9 +1152,9 @@ contains ! write(iout_,*) do ilev = 2, nlev-1 - call mld_ml_level_descr(iout_,ilev,p%baseprecv(ilev)%iprcparm,& - & p%baseprecv(ilev)%nlaggr,info,& - & dprcparm=p%baseprecv(ilev)%rprcparm) + call mld_ml_level_descr(iout_,ilev,p%precv(ilev)%iprcparm,& + & p%precv(ilev)%nlaggr,info,& + & dprcparm=p%precv(ilev)%rprcparm) end do ! @@ -1045,10 +1163,11 @@ contains ilev = nlev write(iout_,*) - call mld_ml_coarse_descr(iout_,ilev,p%baseprecv(ilev)%iprcparm,& - & p%baseprecv(ilev)%nlaggr,info,& - & dprcparm=p%baseprecv(ilev)%rprcparm) - + call mld_ml_coarse_descr(iout_,ilev,& + & p%precv(ilev)%iprcparm,p%precv(ilev)%prec%iprcparm,& + & p%precv(ilev)%nlaggr,info,& + & dprcparm=p%precv(ilev)%rprcparm,& + & dprcparm2=p%precv(ilev)%prec%rprcparm) end if endif @@ -1085,8 +1204,8 @@ contains end if if (iout_ < 0) iout_ = 6 - if (allocated(p%baseprecv)) then - ictxt = psb_cd_get_context(p%baseprecv(1)%desc_data) + if (allocated(p%precv)) then + ictxt = psb_cd_get_context(p%precv(1)%prec%desc_data) call psb_info(ictxt,me,np) @@ -1100,7 +1219,7 @@ contains write(iout_,*) write(iout_,*) 'Preconditioner description' - nlev = size(p%baseprecv) + nlev = size(p%precv) if (nlev >= 1) then ! ! Print description of base preconditioner @@ -1115,8 +1234,8 @@ contains endif ilev = 1 - call mld_base_prec_descr(iout_,p%baseprecv(ilev)%iprcparm,info,& - & rprcparm=p%baseprecv(ilev)%rprcparm) + call mld_base_prec_descr(iout_,p%precv(ilev)%prec%iprcparm,info,& + & rprcparm=p%precv(ilev)%prec%rprcparm) end if @@ -1129,7 +1248,7 @@ contains write(iout_,*) 'Multilevel details' do ilev = 2, nlev - if (.not.allocated(p%baseprecv(ilev)%iprcparm)) then + if (.not.allocated(p%precv(ilev)%iprcparm)) then info = 3111 write(iout_,*) ' ',name,': error: inconsistent MLPREC part, should call MLD_PRECINIT' return @@ -1144,8 +1263,8 @@ contains ! ilev=2 - call mld_ml_alg_descr(iout_,ilev,p%baseprecv(ilev)%iprcparm, info,& - & rprcparm=p%baseprecv(ilev)%rprcparm) + call mld_ml_alg_descr(iout_,ilev,p%precv(ilev)%iprcparm, info,& + & rprcparm=p%precv(ilev)%rprcparm) ! ! Coarse matrices are different at levels 2,...,nlev-1, hence related @@ -1153,9 +1272,9 @@ contains ! write(iout_,*) do ilev = 2, nlev-1 - call mld_ml_level_descr(iout_,ilev,p%baseprecv(ilev)%iprcparm,& - & p%baseprecv(ilev)%nlaggr,info,& - & rprcparm=p%baseprecv(ilev)%rprcparm) + call mld_ml_level_descr(iout_,ilev,p%precv(ilev)%iprcparm,& + & p%precv(ilev)%nlaggr,info,& + & rprcparm=p%precv(ilev)%rprcparm) end do ! @@ -1164,9 +1283,12 @@ contains ilev = nlev write(iout_,*) - call mld_ml_coarse_descr(iout_,ilev,p%baseprecv(ilev)%iprcparm,& - & p%baseprecv(ilev)%nlaggr,info,& - & rprcparm=p%baseprecv(ilev)%rprcparm) + call mld_ml_coarse_descr(iout_,ilev,& + & p%precv(ilev)%iprcparm,p%precv(ilev)%prec%iprcparm,& + & p%precv(ilev)%nlaggr,info,& + & rprcparm=p%precv(ilev)%rprcparm, & + & rprcparm2=p%precv(ilev)%prec%rprcparm) + end if endif @@ -1226,8 +1348,8 @@ contains end if if (iout_ < 0) iout_ = 6 - if (allocated(p%baseprecv)) then - ictxt = psb_cd_get_context(p%baseprecv(1)%desc_data) + if (allocated(p%precv)) then + ictxt = psb_cd_get_context(p%precv(1)%prec%desc_data) call psb_info(ictxt,me,np) @@ -1241,7 +1363,7 @@ contains write(iout_,*) write(iout_,*) 'Preconditioner description' - nlev = size(p%baseprecv) + nlev = size(p%precv) if (nlev >= 1) then ! ! Print description of base preconditioner @@ -1256,8 +1378,8 @@ contains endif ilev = 1 - call mld_base_prec_descr(iout_,p%baseprecv(ilev)%iprcparm,info,& - & dprcparm=p%baseprecv(ilev)%rprcparm) + call mld_base_prec_descr(iout_,p%precv(ilev)%prec%iprcparm,info,& + & dprcparm=p%precv(ilev)%prec%rprcparm) end if @@ -1270,7 +1392,7 @@ contains write(iout_,*) 'Multilevel details' do ilev = 2, nlev - if (.not.allocated(p%baseprecv(ilev)%iprcparm)) then + if (.not.allocated(p%precv(ilev)%iprcparm)) then info = 3111 write(iout_,*) ' ',name,': error: inconsistent MLPREC part, should call MLD_PRECINIT' return @@ -1285,8 +1407,8 @@ contains ! ilev=2 - call mld_ml_alg_descr(iout_,ilev,p%baseprecv(ilev)%iprcparm, info,& - & dprcparm=p%baseprecv(ilev)%rprcparm) + call mld_ml_alg_descr(iout_,ilev,p%precv(ilev)%iprcparm, info,& + & dprcparm=p%precv(ilev)%rprcparm) ! ! Coarse matrices are different at levels 2,...,nlev-1, hence related @@ -1294,9 +1416,9 @@ contains ! write(iout_,*) do ilev = 2, nlev-1 - call mld_ml_level_descr(iout_,ilev,p%baseprecv(ilev)%iprcparm,& - & p%baseprecv(ilev)%nlaggr,info,& - & dprcparm=p%baseprecv(ilev)%rprcparm) + call mld_ml_level_descr(iout_,ilev,p%precv(ilev)%iprcparm,& + & p%precv(ilev)%nlaggr,info,& + & dprcparm=p%precv(ilev)%rprcparm) end do ! @@ -1305,9 +1427,11 @@ contains ilev = nlev write(iout_,*) - call mld_ml_coarse_descr(iout_,ilev,p%baseprecv(ilev)%iprcparm,& - & p%baseprecv(ilev)%nlaggr,info,& - & dprcparm=p%baseprecv(ilev)%rprcparm) + call mld_ml_coarse_descr(iout_,ilev,& + & p%precv(ilev)%iprcparm,p%precv(ilev)%prec%iprcparm,& + & p%precv(ilev)%nlaggr,info,& + & dprcparm=p%precv(ilev)%rprcparm,& + & dprcparm2=p%precv(ilev)%prec%rprcparm) end if endif @@ -1343,8 +1467,8 @@ contains end if if (iout_ < 0) iout_ = 6 - if (allocated(p%baseprecv)) then - ictxt = psb_cd_get_context(p%baseprecv(1)%desc_data) + if (allocated(p%precv)) then + ictxt = psb_cd_get_context(p%precv(1)%prec%desc_data) call psb_info(ictxt,me,np) @@ -1357,7 +1481,7 @@ contains if (me==psb_root_) then write(iout_,*) write(iout_,*) 'Preconditioner description' - nlev = size(p%baseprecv) + nlev = size(p%precv) if (nlev >= 1) then ! ! Print description of base preconditioner @@ -1372,8 +1496,8 @@ contains endif ilev = 1 - call mld_base_prec_descr(iout_,p%baseprecv(ilev)%iprcparm,info,& - & rprcparm=p%baseprecv(ilev)%rprcparm) + call mld_base_prec_descr(iout_,p%precv(ilev)%prec%iprcparm,info,& + & rprcparm=p%precv(ilev)%prec%rprcparm) end if @@ -1386,7 +1510,7 @@ contains write(iout_,*) 'Multilevel details' do ilev = 2, nlev - if (.not.allocated(p%baseprecv(ilev)%iprcparm)) then + if (.not.allocated(p%precv(ilev)%iprcparm)) then info = 3111 write(iout_,*) ' ',name,': error: inconsistent MLPREC part, should call MLD_PRECINIT' return @@ -1401,8 +1525,8 @@ contains ! ilev=2 - call mld_ml_alg_descr(iout_,ilev,p%baseprecv(ilev)%iprcparm, info,& - & rprcparm=p%baseprecv(ilev)%rprcparm) + call mld_ml_alg_descr(iout_,ilev,p%precv(ilev)%iprcparm, info,& + & rprcparm=p%precv(ilev)%rprcparm) ! ! Coarse matrices are different at levels 2,...,nlev-1, hence related @@ -1411,9 +1535,9 @@ contains write(iout_,*) do ilev = 2, nlev-1 - call mld_ml_level_descr(iout_,ilev,p%baseprecv(ilev)%iprcparm,& - & p%baseprecv(ilev)%nlaggr,info,& - & rprcparm=p%baseprecv(ilev)%rprcparm) + call mld_ml_level_descr(iout_,ilev,p%precv(ilev)%iprcparm,& + & p%precv(ilev)%nlaggr,info,& + & rprcparm=p%precv(ilev)%rprcparm) end do ! @@ -1422,9 +1546,11 @@ contains ilev = nlev write(iout_,*) - call mld_ml_coarse_descr(iout_,ilev,p%baseprecv(ilev)%iprcparm,& - & p%baseprecv(ilev)%nlaggr,info,& - & rprcparm=p%baseprecv(ilev)%rprcparm) + call mld_ml_coarse_descr(iout_,ilev,& + & p%precv(ilev)%iprcparm,p%precv(ilev)%prec%iprcparm,& + & p%precv(ilev)%nlaggr,info,& + & rprcparm=p%precv(ilev)%rprcparm,& + & rprcparm2=p%precv(ilev)%prec%rprcparm) end if endif @@ -1718,26 +1844,12 @@ contains if (allocated(p%desc_data%matrix_data)) & & call psb_cdfree(p%desc_data,info) - if (allocated(p%desc_ac%matrix_data)) & - & call psb_cdfree(p%desc_ac,info) if (allocated(p%rprcparm)) then deallocate(p%rprcparm,stat=info) end if - ! This is a pointer to something else, must not free it here. - nullify(p%base_a) - ! This is a pointer to something else, must not free it here. - nullify(p%base_desc) - if (allocated(p%mlia)) then - deallocate(p%mlia,stat=info) - endif - - if (allocated(p%nlaggr)) then - deallocate(p%nlaggr,stat=info) - endif - if (allocated(p%perm)) then deallocate(p%perm,stat=info) endif @@ -1762,14 +1874,68 @@ contains call mld_nullify_baseprec(p) end subroutine mld_sbase_precfree - subroutine mld_nullify_sbaseprec(p) + + subroutine mld_s_onelev_precfree(p,info) implicit none - type(mld_sbaseprc_type), intent(inout) :: p + type(mld_s_onelev_prec_type), intent(inout) :: p + integer, intent(out) :: info + integer :: i + + info = 0 + ! Actually we might just deallocate the top level array, except + ! for the inner UMFPACK or SLU stuff + call mld_base_precfree(p%prec,info) + + call psb_sp_free(p%ac,info) + if (allocated(p%desc_ac%matrix_data)) & + & call psb_cdfree(p%desc_ac,info) + + if (allocated(p%rprcparm)) then + deallocate(p%rprcparm,stat=info) + end if + ! This is a pointer to something else, must not free it here. nullify(p%base_a) + ! This is a pointer to something else, must not free it here. nullify(p%base_desc) + if (allocated(p%mlia)) then + deallocate(p%mlia,stat=info) + endif + + if (allocated(p%nlaggr)) then + deallocate(p%nlaggr,stat=info) + endif + + ! + ! free explicitly map_desc??? + ! For now thanks to allocatable semantics + ! works anyway. + ! + + call mld_nullify_onelevprec(p) + end subroutine mld_s_onelev_precfree + + + subroutine mld_nullify_s_onelevprec(p) + implicit none + + type(mld_s_onelev_prec_type), intent(inout) :: p + + nullify(p%base_a) + nullify(p%base_desc) + + end subroutine mld_nullify_s_onelevprec + + subroutine mld_nullify_sbaseprec(p) + implicit none + + type(mld_sbaseprc_type), intent(inout) :: p + +!!$ nullify(p%base_a) +!!$ nullify(p%base_desc) + end subroutine mld_nullify_sbaseprec @@ -1803,24 +1969,10 @@ contains if (allocated(p%desc_data%matrix_data)) & & call psb_cdfree(p%desc_data,info) - if (allocated(p%desc_ac%matrix_data)) & - & call psb_cdfree(p%desc_ac,info) if (allocated(p%rprcparm)) then deallocate(p%rprcparm,stat=info) end if - ! This is a pointer to something else, must not free it here. - nullify(p%base_a) - ! This is a pointer to something else, must not free it here. - nullify(p%base_desc) - - if (allocated(p%mlia)) then - deallocate(p%mlia,stat=info) - endif - - if (allocated(p%nlaggr)) then - deallocate(p%nlaggr,stat=info) - endif if (allocated(p%perm)) then deallocate(p%perm,stat=info) @@ -1846,15 +1998,67 @@ contains call mld_nullify_baseprec(p) end subroutine mld_dbase_precfree + subroutine mld_d_onelev_precfree(p,info) + implicit none + + type(mld_d_onelev_prec_type), intent(inout) :: p + integer, intent(out) :: info + integer :: i + + info = 0 + + ! Actually we might just deallocate the top level array, except + ! for the inner UMFPACK or SLU stuff + call mld_base_precfree(p%prec,info) + + call psb_sp_free(p%ac,info) + if (allocated(p%desc_ac%matrix_data)) & + & call psb_cdfree(p%desc_ac,info) + + if (allocated(p%rprcparm)) then + deallocate(p%rprcparm,stat=info) + end if + ! This is a pointer to something else, must not free it here. + nullify(p%base_a) + ! This is a pointer to something else, must not free it here. + nullify(p%base_desc) + + if (allocated(p%mlia)) then + deallocate(p%mlia,stat=info) + endif + + if (allocated(p%nlaggr)) then + deallocate(p%nlaggr,stat=info) + endif + + ! + ! free explicitly map_desc??? + ! For now thanks to allocatable semantics + ! works anyway. + ! + + call mld_nullify_onelevprec(p) + end subroutine mld_d_onelev_precfree + subroutine mld_nullify_dbaseprec(p) implicit none type(mld_dbaseprc_type), intent(inout) :: p +!!$ +!!$ nullify(p%base_a) +!!$ nullify(p%base_desc) + + end subroutine mld_nullify_dbaseprec + + subroutine mld_nullify_d_onelevprec(p) + implicit none + + type(mld_d_onelev_prec_type), intent(inout) :: p nullify(p%base_a) nullify(p%base_desc) - end subroutine mld_nullify_dbaseprec + end subroutine mld_nullify_d_onelevprec subroutine mld_cbase_precfree(p,info) implicit none @@ -1882,24 +2086,10 @@ contains end if if (allocated(p%desc_data%matrix_data)) & & call psb_cdfree(p%desc_data,info) - if (allocated(p%desc_ac%matrix_data)) & - & call psb_cdfree(p%desc_ac,info) if (allocated(p%rprcparm)) then deallocate(p%rprcparm,stat=info) end if - ! This is a pointer to something else, must not free it here. - nullify(p%base_a) - ! This is a pointer to something else, must not free it here. - nullify(p%base_desc) - - if (allocated(p%mlia)) then - deallocate(p%mlia,stat=info) - endif - - if (allocated(p%nlaggr)) then - deallocate(p%nlaggr,stat=info) - endif if (allocated(p%perm)) then deallocate(p%perm,stat=info) @@ -1922,14 +2112,66 @@ contains call mld_nullify_baseprec(p) end subroutine mld_cbase_precfree - subroutine mld_nullify_cbaseprec(p) + subroutine mld_c_onelev_precfree(p,info) implicit none - type(mld_cbaseprc_type), intent(inout) :: p + type(mld_c_onelev_prec_type), intent(inout) :: p + integer, intent(out) :: info + integer :: i + + info = 0 + ! Actually we might just deallocate the top level array, except + ! for the inner UMFPACK or SLU stuff + call mld_base_precfree(p%prec,info) + + call psb_sp_free(p%ac,info) + if (allocated(p%desc_ac%matrix_data)) & + & call psb_cdfree(p%desc_ac,info) + + if (allocated(p%rprcparm)) then + deallocate(p%rprcparm,stat=info) + end if + ! This is a pointer to something else, must not free it here. nullify(p%base_a) + ! This is a pointer to something else, must not free it here. nullify(p%base_desc) + if (allocated(p%mlia)) then + deallocate(p%mlia,stat=info) + endif + + if (allocated(p%nlaggr)) then + deallocate(p%nlaggr,stat=info) + endif + + ! + ! free explicitly map_desc??? + ! For now thanks to allocatable semantics + ! works anyway. + ! + + call mld_nullify_onelevprec(p) + end subroutine mld_c_onelev_precfree + + subroutine mld_nullify_c_onelevprec(p) + implicit none + + type(mld_c_onelev_prec_type), intent(inout) :: p + + nullify(p%base_a) + nullify(p%base_desc) + + end subroutine mld_nullify_c_onelevprec + + subroutine mld_nullify_cbaseprec(p) + implicit none + + type(mld_cbaseprc_type), intent(inout) :: p + +!!$ nullify(p%base_a) +!!$ nullify(p%base_desc) + end subroutine mld_nullify_cbaseprec subroutine mld_zbase_precfree(p,info) @@ -1958,24 +2200,10 @@ contains end if if (allocated(p%desc_data%matrix_data)) & & call psb_cdfree(p%desc_data,info) - if (allocated(p%desc_ac%matrix_data)) & - & call psb_cdfree(p%desc_ac,info) if (allocated(p%rprcparm)) then deallocate(p%rprcparm,stat=info) end if - ! This is a pointer to something else, must not free it here. - nullify(p%base_a) - ! This is a pointer to something else, must not free it here. - nullify(p%base_desc) - - if (allocated(p%mlia)) then - deallocate(p%mlia,stat=info) - endif - - if (allocated(p%nlaggr)) then - deallocate(p%nlaggr,stat=info) - endif if (allocated(p%perm)) then deallocate(p%perm,stat=info) @@ -1998,14 +2226,67 @@ contains call mld_nullify_baseprec(p) end subroutine mld_zbase_precfree - subroutine mld_nullify_zbaseprec(p) + subroutine mld_z_onelev_precfree(p,info) implicit none - type(mld_zbaseprc_type), intent(inout) :: p + type(mld_z_onelev_prec_type), intent(inout) :: p + integer, intent(out) :: info + integer :: i + + info = 0 + + ! Actually we might just deallocate the top level array, except + ! for the inner UMFPACK or SLU stuff + call mld_base_precfree(p%prec,info) + + call psb_sp_free(p%ac,info) + if (allocated(p%desc_ac%matrix_data)) & + & call psb_cdfree(p%desc_ac,info) + + if (allocated(p%rprcparm)) then + deallocate(p%rprcparm,stat=info) + end if + ! This is a pointer to something else, must not free it here. + nullify(p%base_a) + ! This is a pointer to something else, must not free it here. + nullify(p%base_desc) + + if (allocated(p%mlia)) then + deallocate(p%mlia,stat=info) + endif + + if (allocated(p%nlaggr)) then + deallocate(p%nlaggr,stat=info) + endif + + ! + ! free explicitly map_desc??? + ! For now thanks to allocatable semantics + ! works anyway. + ! + + call mld_nullify_onelevprec(p) + end subroutine mld_z_onelev_precfree + + subroutine mld_nullify_z_onelevprec(p) + implicit none + + type(mld_z_onelev_prec_type), intent(inout) :: p nullify(p%base_a) nullify(p%base_desc) + end subroutine mld_nullify_z_onelevprec + + + subroutine mld_nullify_zbaseprec(p) + implicit none + + type(mld_zbaseprc_type), intent(inout) :: p + +!!$ nullify(p%base_a) +!!$ nullify(p%base_desc) + end subroutine mld_nullify_zbaseprec diff --git a/mlprec/mld_saggrmap_bld.f90 b/mlprec/mld_saggrmap_bld.f90 index 2fbbe5e8..61df167c 100644 --- a/mlprec/mld_saggrmap_bld.f90 +++ b/mlprec/mld_saggrmap_bld.f90 @@ -131,7 +131,7 @@ subroutine mld_saggrmap_bld(aggr_type,theta,a,desc_a,nlaggr,ilaggr,info) atmp%m=nr atmp%k=nr if (info == 0) call psb_sp_free(atrans,info) - if (info == 0) call psb_ipcoo2csr(atmp,info) + if (info == 0) call psb_spcnv(atmp,info,afmt='csr') if (info == 0) call mld_dec_map_bld(theta,atmp,desc_a,nlaggr,ilaggr,info) if (info == 0) call psb_sp_free(atmp,info) @@ -161,8 +161,6 @@ subroutine mld_saggrmap_bld(aggr_type,theta,a,desc_a,nlaggr,ilaggr,info) contains - - subroutine mld_dec_map_bld(theta,a,desc_a,nlaggr,ilaggr,info) use psb_base_mod diff --git a/mlprec/mld_saggrmat_asb.f90 b/mlprec/mld_saggrmat_asb.f90 index 61422945..e4f42249 100644 --- a/mlprec/mld_saggrmat_asb.f90 +++ b/mlprec/mld_saggrmat_asb.f90 @@ -76,24 +76,21 @@ ! 1181-1196. ! ! +! ! Arguments: ! a - type(psb_sspmat_type), input. ! The sparse matrix structure containing the local part of ! the fine-level matrix. ! desc_a - type(psb_desc_type), input. ! The communication descriptor of the fine-level matrix. -! ac - type(psb_sspmat_type), output. -! The sparse matrix structure containing the local part of -! the coarse-level matrix. -! desc_ac - type(psb_desc_type), output. -! The communication descriptor of the coarse-level matrix. -! p - type(mld_sbaseprc_type), input/output. -! The base preconditioner data structure containing the local -! part of the base preconditioner to be built. +! p - type(mld_s_onelev_prec_type), input/output. +! The one-level preconditioner data structure containing the local +! part of the base preconditioner to be built as well as the +! aggregate matrices. ! info - integer, output. ! Error code. ! -subroutine mld_saggrmat_asb(a,desc_a,ac,desc_ac,p,info) +subroutine mld_saggrmat_asb(a,desc_a,p,info) use psb_base_mod use mld_inner_mod, mld_protect_name => mld_saggrmat_asb @@ -103,9 +100,7 @@ subroutine mld_saggrmat_asb(a,desc_a,ac,desc_ac,p,info) ! Arguments type(psb_sspmat_type), intent(in) :: a type(psb_desc_type), intent(in) :: desc_a - type(psb_sspmat_type), intent(out) :: ac - type(psb_desc_type), intent(out) :: desc_ac - type(mld_sbaseprc_type), intent(inout), target :: p + type(mld_s_onelev_prec_type), intent(inout), target :: p integer, intent(out) :: info ! Local variables @@ -125,7 +120,7 @@ subroutine mld_saggrmat_asb(a,desc_a,ac,desc_ac,p,info) select case (p%iprcparm(mld_aggr_kind_)) case (mld_no_smooth_) - call mld_aggrmat_raw_asb(a,desc_a,ac,desc_ac,p,info) + call mld_aggrmat_raw_asb(a,desc_a,p,info) if(info /= 0) then call psb_errpush(4010,name,a_err='mld_aggrmat_raw_asb') goto 9999 @@ -133,7 +128,7 @@ subroutine mld_saggrmat_asb(a,desc_a,ac,desc_ac,p,info) case(mld_smooth_prol_,mld_biz_prol_) - call mld_aggrmat_smth_asb(a,desc_a,ac,desc_ac,p,info) + call mld_aggrmat_smth_asb(a,desc_a,p,info) if(info /= 0) then call psb_errpush(4010,name,a_err='mld_aggrmat_smth_asb') goto 9999 diff --git a/mlprec/mld_saggrmat_raw_asb.F90 b/mlprec/mld_saggrmat_raw_asb.F90 index 981d5718..54e3da69 100644 --- a/mlprec/mld_saggrmat_raw_asb.F90 +++ b/mlprec/mld_saggrmat_raw_asb.F90 @@ -59,24 +59,21 @@ ! 57 (2007), 1181-1196. ! ! +! ! Arguments: ! a - type(psb_sspmat_type), input. ! The sparse matrix structure containing the local part of ! the fine-level matrix. ! desc_a - type(psb_desc_type), input. ! The communication descriptor of the fine-level matrix. -! ac - type(psb_sspmat_type), output. -! The sparse matrix structure containing the local part of -! the coarse-level matrix. -! desc_ac - type(psb_desc_type), output. -! The communication descriptor of the coarse-level matrix. -! p - type(mld_sbaseprc_type), input/output. -! The base preconditioner data structure containing the local -! part of the base preconditioner to be built. +! p - type(mld_s_onelev_prec_type), input/output. +! The one-level preconditioner data structure containing the local +! part of the base preconditioner to be built as well as the +! aggregate matrices. ! info - integer, output. ! Error code. ! -subroutine mld_saggrmat_raw_asb(a,desc_a,ac,desc_ac,p,info) +subroutine mld_saggrmat_raw_asb(a,desc_a,p,info) use psb_base_mod use mld_inner_mod, mld_protect_name => mld_saggrmat_raw_asb @@ -91,17 +88,15 @@ subroutine mld_saggrmat_raw_asb(a,desc_a,ac,desc_ac,p,info) ! Arguments type(psb_sspmat_type), intent(in) :: a type(psb_desc_type), intent(in) :: desc_a - type(psb_sspmat_type), intent(out) :: ac - type(psb_desc_type), intent(out) :: desc_ac - type(mld_sbaseprc_type), intent(inout), target :: p + type(mld_s_onelev_prec_type), intent(inout), target :: p integer, intent(out) :: info ! Local variables integer ::ictxt,np,me, err_act, icomm character(len=20) :: name type(psb_sspmat_type) :: b - integer, pointer :: nzbr(:), idisp(:) - type(psb_sspmat_type), pointer :: am1,am2 + integer, allocatable :: nzbr(:), idisp(:) + type(psb_sspmat_type) :: am1,am2 integer :: nrow, nglob, ncol, ntaggr, nzac, ip, ndx,& & naggr, nzt, naggrm1, i @@ -119,9 +114,6 @@ subroutine mld_saggrmat_raw_asb(a,desc_a,ac,desc_ac,p,info) nrow = psb_cd_get_local_rows(desc_a) ncol = psb_cd_get_local_cols(desc_a) - - am2 => p%av(mld_sm_pr_t_) - am1 => p%av(mld_sm_pr_) call psb_nullify_sp(am1) call psb_nullify_sp(am2) @@ -195,7 +187,7 @@ subroutine mld_saggrmat_raw_asb(a,desc_a,ac,desc_ac,p,info) if (p%iprcparm(mld_coarse_mat_) == mld_repl_mat_) then - call psb_cdall(ictxt,desc_ac,info,mg=ntaggr,repl=.true.) + call psb_cdall(ictxt,p%desc_ac,info,mg=ntaggr,repl=.true.) if(info /= 0) then call psb_errpush(4010,name,a_err='psb_cdall') goto 9999 @@ -206,7 +198,7 @@ subroutine mld_saggrmat_raw_asb(a,desc_a,ac,desc_ac,p,info) call psb_sum(ictxt,nzbr(1:np)) nzac = sum(nzbr) - call psb_sp_all(ntaggr,ntaggr,ac,nzac,info) + call psb_sp_all(ntaggr,ntaggr,p%ac,nzac,info) if(info /= 0) then call psb_errpush(4010,name,a_err='sp_all') goto 9999 @@ -217,11 +209,11 @@ subroutine mld_saggrmat_raw_asb(a,desc_a,ac,desc_ac,p,info) enddo ndx = nzbr(me+1) - call mpi_allgatherv(b%aspk,ndx,mpi_real,ac%aspk,nzbr,idisp,& + call mpi_allgatherv(b%aspk,ndx,mpi_real,p%ac%aspk,nzbr,idisp,& & mpi_real,icomm,info) - call mpi_allgatherv(b%ia1,ndx,mpi_integer,ac%ia1,nzbr,idisp,& + call mpi_allgatherv(b%ia1,ndx,mpi_integer,p%ac%ia1,nzbr,idisp,& & mpi_integer,icomm,info) - call mpi_allgatherv(b%ia2,ndx,mpi_integer,ac%ia2,nzbr,idisp,& + call mpi_allgatherv(b%ia2,ndx,mpi_integer,p%ac%ia2,nzbr,idisp,& & mpi_integer,icomm,info) if(info /= 0) then info=-1 @@ -229,12 +221,12 @@ subroutine mld_saggrmat_raw_asb(a,desc_a,ac,desc_ac,p,info) goto 9999 end if - ac%m = ntaggr - ac%k = ntaggr - ac%infoa(psb_nnz_) = nzac - ac%fida='COO' - ac%descra='GUN' - call psb_spcnv(ac,info,afmt='coo',dupl=psb_dupl_add_) + p%ac%m = ntaggr + p%ac%k = ntaggr + p%ac%infoa(psb_nnz_) = nzac + p%ac%fida='COO' + p%ac%descra='GUN' + call psb_spcnv(p%ac,info,afmt='coo',dupl=psb_dupl_add_) if(info /= 0) then call psb_errpush(4010,name,a_err='sp_free') goto 9999 @@ -242,9 +234,9 @@ subroutine mld_saggrmat_raw_asb(a,desc_a,ac,desc_ac,p,info) else if (p%iprcparm(mld_coarse_mat_) == mld_distr_mat_) then - call psb_cdall(ictxt,desc_ac,info,nl=naggr) - if (info == 0) call psb_cdasb(desc_ac,info) - if (info == 0) call psb_sp_clone(b,ac,info) + call psb_cdall(ictxt,p%desc_ac,info,nl=naggr) + if (info == 0) call psb_cdasb(p%desc_ac,info) + if (info == 0) call psb_sp_clone(b,p%ac,info) if(info /= 0) then call psb_errpush(4001,name,a_err='Build ac, desc_ac') goto 9999 @@ -263,9 +255,23 @@ subroutine mld_saggrmat_raw_asb(a,desc_a,ac,desc_ac,p,info) deallocate(nzbr,idisp) - call psb_spcnv(ac,info,afmt='csr',dupl=psb_dupl_add_) + call psb_spcnv(p%ac,info,afmt='csr',dupl=psb_dupl_add_) + if(info /= 0) then + call psb_errpush(4010,name,a_err='spcnv') + goto 9999 + end if + + ! + ! Copy the prolongation/restriction matrices into the descriptor map. + ! am2 => PR^T i.e. restriction operator + ! am1 => PR i.e. prolongation operator + ! + p%map_desc = psb_inter_desc(psb_map_aggr_,desc_a,& + & p%desc_ac,am2,am1) + if (info == 0) call psb_sp_free(am1,info) + if (info == 0) call psb_sp_free(am2,info) if(info /= 0) then - call psb_errpush(4010,name,a_err='ipcoo2csr') + call psb_errpush(4010,name,a_err='sp_Free') goto 9999 end if diff --git a/mlprec/mld_saggrmat_smth_asb.F90 b/mlprec/mld_saggrmat_smth_asb.F90 index dcc107ee..c9d3d5c4 100644 --- a/mlprec/mld_saggrmat_smth_asb.F90 +++ b/mlprec/mld_saggrmat_smth_asb.F90 @@ -83,18 +83,14 @@ ! the fine-level matrix. ! desc_a - type(psb_desc_type), input. ! The communication descriptor of the fine-level matrix. -! ac - type(psb_sspmat_type), output. -! The sparse matrix structure containing the local part of -! the coarse-level matrix. -! desc_ac - type(psb_desc_type), output. -! The communication descriptor of the coarse-level matrix. -! p - type(mld_sbaseprc_type), input/output. -! The base preconditioner data structure containing the local -! part of the base preconditioner to be built. +! p - type(mld_s_onelev_prec_type), input/output. +! The one-level preconditioner data structure containing the local +! part of the base preconditioner to be built as well as the +! aggregate matrices. ! info - integer, output. ! Error code. ! -subroutine mld_saggrmat_smth_asb(a,desc_a,ac,desc_ac,p,info) +subroutine mld_saggrmat_smth_asb(a,desc_a,p,info) use psb_base_mod use mld_inner_mod, mld_protect_name => mld_saggrmat_smth_asb @@ -109,19 +105,17 @@ subroutine mld_saggrmat_smth_asb(a,desc_a,ac,desc_ac,p,info) ! Arguments type(psb_sspmat_type), intent(in) :: a type(psb_desc_type), intent(in) :: desc_a - type(psb_sspmat_type), intent(out) :: ac - type(psb_desc_type), intent(out) :: desc_ac - type(mld_sbaseprc_type), intent(inout), target :: p + type(mld_s_onelev_prec_type), intent(inout), target :: p integer, intent(out) :: info ! Local variables - type(psb_sspmat_type) :: b - integer, pointer :: nzbr(:), idisp(:) + type(psb_sspmat_type) :: b + integer, allocatable :: nzbr(:), idisp(:) integer :: nrow, nglob, ncol, ntaggr, nzac, ip, ndx,& & naggr, nzl,naggrm1,naggrp1, i, j, k integer ::ictxt,np,me, err_act, icomm character(len=20) :: name - type(psb_sspmat_type), pointer :: am1,am2 + type(psb_sspmat_type) :: am1,am2 type(psb_sspmat_type) :: am3,am4 real(psb_spk_), allocatable :: adiag(:) logical :: ml_global_nmb @@ -146,9 +140,6 @@ subroutine mld_saggrmat_smth_asb(a,desc_a,ac,desc_ac,p,info) call psb_nullify_sp(b) call psb_nullify_sp(am3) call psb_nullify_sp(am4) - - am2 => p%av(mld_sm_pr_t_) - am1 => p%av(mld_sm_pr_) call psb_nullify_sp(am1) call psb_nullify_sp(am2) @@ -263,7 +254,6 @@ subroutine mld_saggrmat_smth_asb(a,desc_a,ac,desc_ac,p,info) if (p%iprcparm(mld_aggr_omega_alg_) == mld_eig_est_) then - if (p%iprcparm(mld_aggr_eig_) == mld_max_norm_) then if (p%iprcparm(mld_aggr_kind_) == mld_biz_prol_) then @@ -293,7 +283,6 @@ subroutine mld_saggrmat_smth_asb(a,desc_a,ac,desc_ac,p,info) call psb_errpush(info,name,a_err='this section only CSR') goto 9999 endif - else anorm = psb_spnrmi(am3,desc_a,info) endif @@ -458,16 +447,16 @@ subroutine mld_saggrmat_smth_asb(a,desc_a,ac,desc_ac,p,info) case(mld_distr_mat_) - call psb_sp_clone(b,ac,info) - nzac = ac%infoa(psb_nnz_) - nzl = ac%infoa(psb_nnz_) - if (info == 0) call psb_cdall(ictxt,desc_ac,info,nl=p%nlaggr(me+1)) - if (info == 0) call psb_cdins(nzl,ac%ia1,ac%ia2,desc_ac,info) - if (info == 0) call psb_cdasb(desc_ac,info) - if (info == 0) call psb_glob_to_loc(ac%ia1(1:nzl),desc_ac,info,iact='I') - if (info == 0) call psb_glob_to_loc(ac%ia2(1:nzl),desc_ac,info,iact='I') + call psb_sp_clone(b,p%ac,info) + nzac = p%ac%infoa(psb_nnz_) + nzl = p%ac%infoa(psb_nnz_) + if (info == 0) call psb_cdall(ictxt,p%desc_ac,info,nl=p%nlaggr(me+1)) + if (info == 0) call psb_cdins(nzl,p%ac%ia1,p%ac%ia2,p%desc_ac,info) + if (info == 0) call psb_cdasb(p%desc_ac,info) + if (info == 0) call psb_glob_to_loc(p%ac%ia1(1:nzl),p%desc_ac,info,iact='I') + if (info == 0) call psb_glob_to_loc(p%ac%ia2(1:nzl),p%desc_ac,info,iact='I') if (info /= 0) then - call psb_errpush(4001,name,a_err='Creating desc_ac and converting ac') + call psb_errpush(4001,name,a_err='Creating p%desc_ac and converting ac') goto 9999 end if if (debug_level >= psb_debug_outer_) & @@ -475,10 +464,10 @@ subroutine mld_saggrmat_smth_asb(a,desc_a,ac,desc_ac,p,info) & 'Assembld aux descr. distr.' - ac%m=desc_ac%matrix_data(psb_n_row_) - ac%k=desc_ac%matrix_data(psb_n_col_) - ac%fida='COO' - ac%descra='GUN' + p%ac%m=psb_cd_get_local_rows(p%desc_ac) + p%ac%k=psb_cd_get_local_cols(p%desc_ac) + p%ac%fida='COO' + p%ac%descra='GUN' call psb_sp_free(b,info) if (info == 0) deallocate(nzbr,idisp,stat=info) @@ -489,25 +478,25 @@ subroutine mld_saggrmat_smth_asb(a,desc_a,ac,desc_ac,p,info) if (np>1) then nzl = psb_sp_get_nnzeros(am1) - call psb_glob_to_loc(am1%ia1(1:nzl),desc_ac,info,'I') + call psb_glob_to_loc(am1%ia1(1:nzl),p%desc_ac,info,'I') if(info /= 0) then call psb_errpush(4010,name,a_err='psb_glob_to_loc') goto 9999 end if endif - am1%k=desc_ac%matrix_data(psb_n_col_) + am1%k=psb_cd_get_local_cols(p%desc_ac) if (np>1) then call psb_spcnv(am2,info,afmt='coo',dupl=psb_dupl_add_) nzl = am2%infoa(psb_nnz_) - if (info == 0) call psb_glob_to_loc(am2%ia1(1:nzl),desc_ac,info,'I') + if (info == 0) call psb_glob_to_loc(am2%ia1(1:nzl),p%desc_ac,info,'I') if (info == 0) call psb_spcnv(am2,info,afmt='csr',dupl=psb_dupl_add_) if(info /= 0) then call psb_errpush(4001,name,a_err='Converting am2 to local') goto 9999 end if end if - am2%m=desc_ac%matrix_data(psb_n_col_) + am2%m=psb_cd_get_local_cols(p%desc_ac) if (debug_level >= psb_debug_outer_) & & write(debug_unit,*) me,' ',trim(name),& @@ -516,13 +505,13 @@ subroutine mld_saggrmat_smth_asb(a,desc_a,ac,desc_ac,p,info) case(mld_repl_mat_) ! ! - call psb_cdall(ictxt,desc_ac,info,mg=ntaggr,repl=.true.) + call psb_cdall(ictxt,p%desc_ac,info,mg=ntaggr,repl=.true.) nzbr(:) = 0 nzbr(me+1) = b%infoa(psb_nnz_) call psb_sum(ictxt,nzbr(1:np)) nzac = sum(nzbr) - if (info == 0) call psb_sp_all(ntaggr,ntaggr,ac,nzac,info) + if (info == 0) call psb_sp_all(ntaggr,ntaggr,p%ac,nzac,info) if (info /= 0) goto 9999 do ip=1,np @@ -530,11 +519,11 @@ subroutine mld_saggrmat_smth_asb(a,desc_a,ac,desc_ac,p,info) enddo ndx = nzbr(me+1) - call mpi_allgatherv(b%aspk,ndx,mpi_real,ac%aspk,nzbr,idisp,& + call mpi_allgatherv(b%aspk,ndx,mpi_real,p%ac%aspk,nzbr,idisp,& & mpi_real,icomm,info) - if (info == 0) call mpi_allgatherv(b%ia1,ndx,mpi_integer,ac%ia1,nzbr,idisp,& + if (info == 0) call mpi_allgatherv(b%ia1,ndx,mpi_integer,p%ac%ia1,nzbr,idisp,& & mpi_integer,icomm,info) - if (info == 0) call mpi_allgatherv(b%ia2,ndx,mpi_integer,ac%ia2,nzbr,idisp,& + if (info == 0) call mpi_allgatherv(b%ia2,ndx,mpi_integer,p%ac%ia2,nzbr,idisp,& & mpi_integer,icomm,info) if (info /= 0) then @@ -542,12 +531,12 @@ subroutine mld_saggrmat_smth_asb(a,desc_a,ac,desc_ac,p,info) goto 9999 end if - ac%m = ntaggr - ac%k = ntaggr - ac%infoa(psb_nnz_) = nzac - ac%fida='COO' - ac%descra='GUN' - call psb_spcnv(ac,info,afmt='coo',dupl=psb_dupl_add_) + p%ac%m = ntaggr + p%ac%k = ntaggr + p%ac%infoa(psb_nnz_) = nzac + p%ac%fida='COO' + p%ac%descra='GUN' + call psb_spcnv(p%ac,info,afmt='coo',dupl=psb_dupl_add_) if(info /= 0) goto 9999 call psb_sp_free(b,info) if(info /= 0) goto 9999 @@ -571,9 +560,9 @@ subroutine mld_saggrmat_smth_asb(a,desc_a,ac,desc_ac,p,info) case(mld_distr_mat_) - call psb_sp_clone(b,ac,info) - if (info == 0) call psb_cdall(ictxt,desc_ac,info,nl=naggr) - if (info == 0) call psb_cdasb(desc_ac,info) + call psb_sp_clone(b,p%ac,info) + if (info == 0) call psb_cdall(ictxt,p%desc_ac,info,nl=naggr) + if (info == 0) call psb_cdasb(p%desc_ac,info) if (info == 0) call psb_sp_free(b,info) if (info /= 0) then call psb_errpush(4010,name,a_err='Build desc_ac, ac') @@ -584,7 +573,7 @@ subroutine mld_saggrmat_smth_asb(a,desc_a,ac,desc_ac,p,info) case(mld_repl_mat_) ! ! - call psb_cdall(ictxt,desc_ac,info,mg=ntaggr,repl=.true.) + call psb_cdall(ictxt,p%desc_ac,info,mg=ntaggr,repl=.true.) if(info /= 0) then call psb_errpush(4010,name,a_err='psb_cdall') goto 9999 @@ -594,7 +583,7 @@ subroutine mld_saggrmat_smth_asb(a,desc_a,ac,desc_ac,p,info) nzbr(me+1) = b%infoa(psb_nnz_) call psb_sum(ictxt,nzbr(1:np)) nzac = sum(nzbr) - call psb_sp_all(ntaggr,ntaggr,ac,nzac,info) + call psb_sp_all(ntaggr,ntaggr,p%ac,nzac,info) if(info /= 0) then call psb_errpush(4010,name,a_err='psb_sp_all') goto 9999 @@ -605,11 +594,11 @@ subroutine mld_saggrmat_smth_asb(a,desc_a,ac,desc_ac,p,info) enddo ndx = nzbr(me+1) - call mpi_allgatherv(b%aspk,ndx,mpi_real,ac%aspk,nzbr,idisp,& + call mpi_allgatherv(b%aspk,ndx,mpi_real,p%ac%aspk,nzbr,idisp,& & mpi_real,icomm,info) - if (info == 0) call mpi_allgatherv(b%ia1,ndx,mpi_integer,ac%ia1,nzbr,idisp,& + if (info == 0) call mpi_allgatherv(b%ia1,ndx,mpi_integer,p%ac%ia1,nzbr,idisp,& & mpi_integer,icomm,info) - if (info == 0) call mpi_allgatherv(b%ia2,ndx,mpi_integer,ac%ia2,nzbr,idisp,& + if (info == 0) call mpi_allgatherv(b%ia2,ndx,mpi_integer,p%ac%ia2,nzbr,idisp,& & mpi_integer,icomm,info) if (info /= 0) then call psb_errpush(4001,name,a_err=' from mpi_allgatherv') @@ -617,12 +606,12 @@ subroutine mld_saggrmat_smth_asb(a,desc_a,ac,desc_ac,p,info) end if - ac%m = ntaggr - ac%k = ntaggr - ac%infoa(psb_nnz_) = nzac - ac%fida='COO' - ac%descra='GUN' - call psb_spcnv(ac,info,afmt='coo',dupl=psb_dupl_add_) + p%ac%m = ntaggr + p%ac%k = ntaggr + p%ac%infoa(psb_nnz_) = nzac + p%ac%fida='COO' + p%ac%descra='GUN' + call psb_spcnv(p%ac,info,afmt='coo',dupl=psb_dupl_add_) if(info /= 0) then call psb_errpush(4010,name,a_err='spcnv') goto 9999 @@ -653,12 +642,27 @@ subroutine mld_saggrmat_smth_asb(a,desc_a,ac,desc_ac,p,info) end select - call psb_spcnv(ac,info,afmt='csr',dupl=psb_dupl_add_) + call psb_spcnv(p%ac,info,afmt='csr',dupl=psb_dupl_add_) if(info /= 0) then call psb_errpush(4010,name,a_err='spcnv') goto 9999 end if + ! + ! Copy the prolongation/restriction matrices into the descriptor map. + ! am2 => PR^T i.e. restriction operator + ! am1 => PR i.e. prolongation operator + ! + p%map_desc = psb_inter_desc(psb_map_aggr_,desc_a,& + & p%desc_ac,am2,am1) + if (info == 0) call psb_sp_free(am1,info) + if (info == 0) call psb_sp_free(am2,info) + if(info /= 0) then + call psb_errpush(4010,name,a_err='sp_Free') + goto 9999 + end if + + if (debug_level >= psb_debug_outer_) & & write(debug_unit,*) me,' ',trim(name),& & 'Done smooth_aggregate ' diff --git a/mlprec/mld_sbaseprec_bld.f90 b/mlprec/mld_sbaseprec_bld.f90 index 032a106b..3e47911b 100644 --- a/mlprec/mld_sbaseprec_bld.f90 +++ b/mlprec/mld_sbaseprec_bld.f90 @@ -197,8 +197,6 @@ subroutine mld_sbaseprc_bld(a,desc_a,p,info,upd) end select - p%base_a => a - p%base_desc => desc_a p%iprcparm(mld_prec_status_) = mld_prec_built_ if (debug_level >= psb_debug_outer_) & & write(debug_unit,*) me,' ',trim(name),': Done' diff --git a/mlprec/mld_smlprec_aply.f90 b/mlprec/mld_smlprec_aply.f90 index 14d937bb..13f17fd7 100644 --- a/mlprec/mld_smlprec_aply.f90 +++ b/mlprec/mld_smlprec_aply.f90 @@ -46,7 +46,7 @@ ! Y = beta*Y + alpha*op(M^(-1))*X, ! where ! - M is a multilevel domain decomposition (Schwarz) preconditioner associated -! to a certain matrix A and stored in the array baseprecv, +! to a certain matrix A and stored in the array precv, ! - op(M^(-1)) is M^(-1) or its transpose, according to the value of trans, ! - X and Y are vectors, ! - alpha and beta are scalars. @@ -55,9 +55,9 @@ ! level where we might have a replicated index space) and each process takes care ! of one submatrix. ! -! The multilevel preconditioner M is regarded as an array of 'base preconditioners', +! The multilevel preconditioner M is regarded as an array of 'one-level preconditioners', ! each representing the part of the preconditioner associated to a certain level. -! For each level ilev, the base preconditioner K(ilev) is stored in baseprecv(ilev) +! For each level ilev, the preconditioner K(ilev) is stored in precv(ilev) ! and is associated to a matrix A(ilev), obtained by 'tranferring' the original ! matrix A (i.e. the matrix to be preconditioned) to the level ilev, through smoothed ! aggregation. @@ -78,66 +78,43 @@ ! Arguments: ! alpha - real(psb_spk_), input. ! The scalar alpha. -! baseprecv - type(mld_sbaseprc_type), dimension(:), input. -! The array of base preconditioner data structures containing the +! precv - type(mld_s_onelev_prec_type), dimension(:), input. +! The array of one-level preconditioner data structures containing the ! local parts of the preconditioners to be applied at each level. -! Note that nlev = size(baseprecv) = number of levels. -! baseprecv(ilev)%av - type(psb_sspmat_type), dimension(:), allocatable(:). -! The sparse matrices needed to apply the preconditioner -! at level ilev. -! baseprecv(ilev)%av(mld_l_pr_) - The L factor of the ILU factorization of -! the local diagonal block of A(ilev). -! baseprecv(ilev)%av(mld_u_pr_) - The U factor of the ILU factorization of the -! local diagonal block of A(ilev), except its -! diagonal entries (stored in baseprecv(ilev)%d). -! baseprecv(ilev)%av(mld_ap_nd_) - The entries of the local part of A(ilev) -! outside the diagonal block, for block-Jacobi -! sweeps. -! baseprecv(ilev)%av(mld_ac_) - The local part of the matrix A(ilev). -! baseprecv(ilev)%av(mld_sm_pr_) - The smoothed prolongator. -! It maps vectors (ilev) ---> (ilev-1). -! baseprecv(ilev)%av(mld_sm_pr_t_) - The smoothed prolongator transpose. -! It maps vectors (ilev-1) ---> (ilev). -! baseprecv(ilev)%d - real(psb_spk_), dimension(:), allocatable. -! The diagonal entries of the U factor in the ILU -! factorization of A(ilev). -! baseprecv(ilev)%desc_data - type(psb_desc_type). -! The communication descriptor associated to the base -! preconditioner, i.e. to the sparse matrices needed -! to apply the base preconditioner at the current level. -! baseprecv(ilev)%desc_ac - type(psb_desc_type). -! The communication descriptor associated to the sparse -! matrix A(ilev), stored in baseprecv(ilev)%av(mld_ac_). -! baseprecv(ilev)%iprcparm - integer, dimension(:), allocatable. -! The integer parameters defining the base -! preconditioner K(ilev). -! baseprecv(ilev)%rprcparm - real(psb_spk_), dimension(:), allocatable. -! The real parameters defining the base preconditioner -! K(ilev). -! baseprecv(ilev)%perm - integer, dimension(:), allocatable. -! The row and column permutations applied to the local -! part of A(ilev) (defined only if baseprecv(ilev)% -! iprcparm(mld_sub_ren_)>0). -! baseprecv(ilev)%invperm - integer, dimension(:), allocatable. -! The inverse of the permutation stored in -! baseprecv(ilev)%perm. -! baseprecv(ilev)%mlia - integer, dimension(:), allocatable. -! The aggregation map (ilev-1) --> (ilev). -! In case of non-smoothed aggregation, it is used -! instead of mld_sm_pr_. -! baseprecv(ilev)%nlaggr - integer, dimension(:), allocatable. -! The number of aggregates (rows of A(ilev)) on the -! various processes. -! baseprecv(ilev)%base_a - type(psb_sspmat_type), pointer. -! Pointer (really a pointer!) to the base matrix of -! the current level, i.e. the local part of A(ilev); -! so we have a unified treatment of residuals. We -! need this to avoid passing explicitly the matrix -! A(ilev) to the routine which applies the -! preconditioner. -! baseprecv(ilev)%base_desc - type(psb_desc_type), pointer. -! Pointer to the communication descriptor associated -! to the sparse matrix pointed by base_a. +! Note that nlev = size(precv) = number of levels. +! precv(ilev)%prec - type(psb_sbaseprc_type) +! The "base" preconditioner for the current level +! precv(ilev)%ac - type(psb_sspmat_type) +! The local part of the matrix A(ilev). +! precv(ilev)%desc_ac - type(psb_desc_type). +! The communication descriptor associated to the sparse +! matrix A(ilev) +! precv(ilev)%map_desc - type(psb_inter_desc_type) +! Stores the linear operators mapping between levels +! (ilev-1) and (ilev). These are the restriction and +! prolongation operators described in the sequel. +! precv(ilev)%iprcparm - integer, dimension(:), allocatable. +! The integer parameters defining the multilevel +! strategy +! precv(ilev)%rprcparm - real(psb_spk_), dimension(:), allocatable. +! The real parameters defining the multilevel strategy +! precv(ilev)%mlia - integer, dimension(:), allocatable. +! The aggregation map (ilev-1) --> (ilev). +! In case of non-smoothed aggregation, it is used +! instead of mld_sm_pr_. +! precv(ilev)%nlaggr - integer, dimension(:), allocatable. +! The number of aggregates (rows of A(ilev)) on the +! various processes. +! precv(ilev)%base_a - type(psb_sspmat_type), pointer. +! Pointer (really a pointer!) to the base matrix of +! the current level, i.e. the local part of A(ilev); +! so we have a unified treatment of residuals. We +! need this to avoid passing explicitly the matrix +! A(ilev) to the routine which applies the +! preconditioner. +! precv(ilev)%base_desc - type(psb_desc_type), pointer. +! Pointer to the communication descriptor associated +! to the sparse matrix pointed by base_a. ! ! x - real(psb_spk_), dimension(:), input. ! The local part of the vector X. @@ -159,10 +136,10 @@ ! Note that when the LU factorization of the matrix A(ilev) is computed instead of ! the ILU one, by using UMFPACK or SuperLU, the corresponding L and U factors ! are stored in data structures provided by UMFPACK or SuperLU and pointed by -! baseprecv(ilev)%iprcparm(mld_umf_ptr) or baseprecv(ilev)%iprcparm(mld_slu_ptr), +! precv(ilev)%prec%iprcparm(mld_umf_ptr) or precv(ilev)%prec%iprcparm(mld_slu_ptr), ! respectively. ! -subroutine mld_smlprec_aply(alpha,baseprecv,x,beta,y,desc_data,trans,work,info) +subroutine mld_smlprec_aply(alpha,precv,x,beta,y,desc_data,trans,work,info) use psb_base_mod use mld_inner_mod, mld_protect_name => mld_smlprec_aply @@ -171,7 +148,7 @@ subroutine mld_smlprec_aply(alpha,baseprecv,x,beta,y,desc_data,trans,work,info) ! Arguments type(psb_desc_type),intent(in) :: desc_data - type(mld_sbaseprc_type), intent(in) :: baseprecv(:) + type(mld_s_onelev_prec_type), intent(in) :: precv(:) real(psb_spk_),intent(in) :: alpha,beta real(psb_spk_),intent(in) :: x(:) real(psb_spk_),intent(inout) :: y(:) @@ -196,11 +173,11 @@ subroutine mld_smlprec_aply(alpha,baseprecv,x,beta,y,desc_data,trans,work,info) if (debug_level >= psb_debug_inner_) & & write(debug_unit,*) me,' ',trim(name),& - & ' Entry ', size(baseprecv) + & ' Entry ', size(precv) trans_ = psb_toupper(trans) - select case(baseprecv(2)%iprcparm(mld_ml_type_)) + select case(precv(2)%iprcparm(mld_ml_type_)) case(mld_no_ml_) ! @@ -214,7 +191,7 @@ subroutine mld_smlprec_aply(alpha,baseprecv,x,beta,y,desc_data,trans,work,info) ! Additive multilevel ! - call add_ml_aply(alpha,baseprecv,x,beta,y,desc_data,trans_,work,info) + call add_ml_aply(alpha,precv,x,beta,y,desc_data,trans_,work,info) case(mld_mult_ml_) ! @@ -225,15 +202,15 @@ subroutine mld_smlprec_aply(alpha,baseprecv,x,beta,y,desc_data,trans,work,info) ! Note that the transpose switches pre <-> post. ! - select case(baseprecv(2)%iprcparm(mld_smoother_pos_)) + select case(precv(2)%iprcparm(mld_smoother_pos_)) case(mld_post_smooth_) select case (trans_) case('N') - call mlt_post_ml_aply(alpha,baseprecv,x,beta,y,desc_data,trans_,work,info) + call mlt_post_ml_aply(alpha,precv,x,beta,y,desc_data,trans_,work,info) case('T','C') - call mlt_pre_ml_aply(alpha,baseprecv,x,beta,y,desc_data,trans_,work,info) + call mlt_pre_ml_aply(alpha,precv,x,beta,y,desc_data,trans_,work,info) case default info = 4001 call psb_errpush(info,name,a_err='invalid trans') @@ -244,9 +221,9 @@ subroutine mld_smlprec_aply(alpha,baseprecv,x,beta,y,desc_data,trans,work,info) select case (trans_) case('N') - call mlt_pre_ml_aply(alpha,baseprecv,x,beta,y,desc_data,trans_,work,info) + call mlt_pre_ml_aply(alpha,precv,x,beta,y,desc_data,trans_,work,info) case('T','C') - call mlt_post_ml_aply(alpha,baseprecv,x,beta,y,desc_data,trans_,work,info) + call mlt_post_ml_aply(alpha,precv,x,beta,y,desc_data,trans_,work,info) case default info = 4001 call psb_errpush(info,name,a_err='invalid trans') @@ -255,12 +232,12 @@ subroutine mld_smlprec_aply(alpha,baseprecv,x,beta,y,desc_data,trans,work,info) case(mld_twoside_smooth_) - call mlt_twoside_ml_aply(alpha,baseprecv,x,beta,y,desc_data,trans_,work,info) + call mlt_twoside_ml_aply(alpha,precv,x,beta,y,desc_data,trans_,work,info) case default info = 4013 call psb_errpush(info,name,a_err='invalid smooth_pos',& - & i_Err=(/baseprecv(2)%iprcparm(mld_smoother_pos_),0,0,0,0/)) + & i_Err=(/precv(2)%iprcparm(mld_smoother_pos_),0,0,0,0/)) goto 9999 end select @@ -268,7 +245,7 @@ subroutine mld_smlprec_aply(alpha,baseprecv,x,beta,y,desc_data,trans,work,info) case default info = 4013 call psb_errpush(info,name,a_err='invalid mltype',& - & i_Err=(/baseprecv(2)%iprcparm(mld_ml_type_),0,0,0,0/)) + & i_Err=(/precv(2)%iprcparm(mld_ml_type_),0,0,0,0/)) goto 9999 end select @@ -295,7 +272,7 @@ contains ! Y = beta*Y + alpha*op(M^(-1))*X, ! where ! - M is an additive multilevel domain decomposition (Schwarz) preconditioner - ! associated to a certain matrix A and stored in the array baseprecv, + ! associated to a certain matrix A and stored in the array precv, ! - op(M^(-1)) is M^(-1) or its transpose, according to the value of trans, ! - X and Y are vectors, ! - alpha and beta are scalars. @@ -307,9 +284,9 @@ contains ! level where we might have a replicated index space) and each process takes care ! of one submatrix. ! - ! The multilevel preconditioner M is regarded as an array of 'base preconditioners', + ! The multilevel preconditioner M is regarded as an array of 'one-level preconditioners', ! each representing the part of the preconditioner associated to a certain level. - ! For each level ilev, the base preconditioner K(ilev) is stored in baseprecv(ilev) + ! For each level ilev, the base preconditioner K(ilev) is stored in precv(ilev) ! and is associated to a matrix A(ilev), obtained by 'tranferring' the original ! matrix A (i.e. the matrix to be preconditioned) to the level ilev, through smoothed ! aggregation. @@ -357,13 +334,13 @@ contains ! ! 4. Yext = beta*Yext + alpha*Y(1) ! - subroutine add_ml_aply(alpha,baseprecv,x,beta,y,desc_data,trans,work,info) + subroutine add_ml_aply(alpha,precv,x,beta,y,desc_data,trans,work,info) implicit none ! Arguments type(psb_desc_type),intent(in) :: desc_data - type(mld_sbaseprc_type), intent(in) :: baseprecv(:) + type(mld_s_onelev_prec_type), intent(in) :: precv(:) real(psb_spk_),intent(in) :: alpha,beta real(psb_spk_),intent(in) :: x(:) real(psb_spk_),intent(inout) :: y(:) @@ -372,10 +349,9 @@ contains integer, intent(out) :: info ! Local variables - integer :: n_row,n_col integer :: ictxt,np,me,i, nr2l,nc2l,err_act integer :: debug_level, debug_unit - integer :: ismth, nlev, ilev, icm + integer :: nlev, ilev character(len=20) :: name type psb_mlprec_wrk_type @@ -394,9 +370,9 @@ contains if (debug_level >= psb_debug_inner_) & & write(debug_unit,*) me,' ',trim(name),& - & ' Entry ', size(baseprecv) + & ' Entry ', size(precv) - nlev = size(baseprecv) + nlev = size(precv) allocate(mlprec_wrk(nlev),stat=info) if (info /= 0) then call psb_errpush(4010,name,a_err='Allocate') @@ -419,8 +395,8 @@ contains mlprec_wrk(1)%x2l(:) = x(:) mlprec_wrk(1)%y2l(:) = szero - call mld_baseprec_aply(alpha,baseprecv(1),x,beta,y,& - & baseprecv(1)%base_desc,trans,work,info) + call mld_baseprec_aply(alpha,precv(1)%prec,x,beta,y,& + & precv(1)%base_desc,trans,work,info) if (info /=0) then call psb_errpush(4010,name,a_err='baseprec_aply') goto 9999 @@ -431,27 +407,21 @@ contains ! For each level except the finest one ... ! do ilev = 2, nlev - n_row = psb_cd_get_local_rows(baseprecv(ilev-1)%base_desc) - n_col = psb_cd_get_local_cols(baseprecv(ilev-1)%base_desc) - nc2l = psb_cd_get_local_cols(baseprecv(ilev)%base_desc) - nr2l = psb_cd_get_local_rows(baseprecv(ilev)%base_desc) + nc2l = psb_cd_get_local_cols(precv(ilev)%base_desc) + nr2l = psb_cd_get_local_rows(precv(ilev)%base_desc) allocate(mlprec_wrk(ilev)%x2l(nc2l),mlprec_wrk(ilev)%y2l(nc2l),& & stat=info) if (info /= 0) then info=4025 - call psb_errpush(info,name,i_err=(/2*(nc2l+max(n_row,n_col)),0,0,0,0/),& + call psb_errpush(info,name,i_err=(/2*nc2l,0,0,0,0/),& & a_err='real(psb_spk_)') goto 9999 end if - - ismth = baseprecv(ilev)%iprcparm(mld_aggr_kind_) - icm = baseprecv(ilev)%iprcparm(mld_coarse_mat_) ! Apply prolongator transpose, i.e. restriction call psb_forward_map(sone,mlprec_wrk(ilev-1)%x2l,& & szero,mlprec_wrk(ilev)%x2l,& - & baseprecv(ilev)%map_desc,info,work=work) - + & precv(ilev)%map_desc,info,work=work) if (info /=0) then call psb_errpush(4001,name,a_err='Error during restriction') @@ -461,9 +431,9 @@ contains ! ! Apply the base preconditioner ! - call mld_baseprec_aply(sone,baseprecv(ilev),& + call mld_baseprec_aply(sone,precv(ilev)%prec,& & mlprec_wrk(ilev)%x2l,szero,mlprec_wrk(ilev)%y2l,& - & baseprecv(ilev)%base_desc, trans,work,info) + & precv(ilev)%base_desc, trans,work,info) enddo @@ -474,19 +444,15 @@ contains ! do ilev =nlev,2,-1 - n_row = psb_cd_get_local_rows(baseprecv(ilev-1)%base_desc) - n_col = psb_cd_get_local_cols(baseprecv(ilev-1)%base_desc) - nc2l = psb_cd_get_local_cols(baseprecv(ilev)%base_desc) - nr2l = psb_cd_get_local_rows(baseprecv(ilev)%base_desc) - ismth = baseprecv(ilev)%iprcparm(mld_aggr_kind_) - icm = baseprecv(ilev)%iprcparm(mld_coarse_mat_) + nc2l = psb_cd_get_local_cols(precv(ilev)%base_desc) + nr2l = psb_cd_get_local_rows(precv(ilev)%base_desc) ! ! Apply prolongator ! call psb_backward_map(sone,mlprec_wrk(ilev)%y2l,& & sone,mlprec_wrk(ilev-1)%y2l,& - & baseprecv(ilev)%map_desc,info,work=work) + & precv(ilev)%map_desc,info,work=work) if (info /=0) then call psb_errpush(4001,name,a_err='Error during prolongation') @@ -499,7 +465,7 @@ contains ! ! Compute the output vector Y ! - call psb_geaxpby(alpha,mlprec_wrk(1)%y2l,sone,y,baseprecv(1)%base_desc,info) + call psb_geaxpby(alpha,mlprec_wrk(1)%y2l,sone,y,precv(1)%base_desc,info) if (info /= 0) then call psb_errpush(4001,name,a_err='Error on final update') goto 9999 @@ -533,7 +499,7 @@ contains ! Y = beta*Y + alpha*op(M^(-1))*X, ! where ! - M is a hybrid multilevel domain decomposition (Schwarz) preconditioner - ! associated to a certain matrix A and stored in the array baseprecv, + ! associated to a certain matrix A and stored in the array precv, ! - op(M^(-1)) is M^(-1) or its transpose, according to the value of trans, ! - X and Y are vectors, ! - alpha and beta are scalars. @@ -545,9 +511,9 @@ contains ! level where we might have a replicated index space) and each process takes care ! of one submatrix. ! - ! The multilevel preconditioner M is regarded as an array of 'base preconditioners', + ! The multilevel preconditioner M is regarded as an array of 'one-level preconditioners', ! each representing the part of the preconditioner associated to a certain level. - ! For each level ilev, the base preconditioner K(ilev) is stored in baseprecv(ilev) + ! For each level ilev, the base preconditioner K(ilev) is stored in precv(ilev) ! and is associated to a matrix A(ilev), obtained by 'tranferring' the original ! matrix A (i.e. the matrix to be preconditioned) to the level ilev, through smoothed ! aggregation. @@ -603,13 +569,13 @@ contains ! 6. Yext = beta*Yext + alpha*Y(1) ! ! - subroutine mlt_pre_ml_aply(alpha,baseprecv,x,beta,y,desc_data,trans,work,info) + subroutine mlt_pre_ml_aply(alpha,precv,x,beta,y,desc_data,trans,work,info) implicit none ! Arguments type(psb_desc_type),intent(in) :: desc_data - type(mld_sbaseprc_type), intent(in) :: baseprecv(:) + type(mld_s_onelev_prec_type), intent(in) :: precv(:) real(psb_spk_),intent(in) :: alpha,beta real(psb_spk_),intent(in) :: x(:) real(psb_spk_),intent(inout) :: y(:) @@ -618,10 +584,9 @@ contains integer, intent(out) :: info ! Local variables - integer :: n_row,n_col integer :: ictxt,np,me,i, nr2l,nc2l,err_act integer :: debug_level, debug_unit - integer :: ismth, nlev, ilev, icm + integer :: nlev, ilev character(len=20) :: name type psb_mlprec_wrk_type @@ -640,9 +605,9 @@ contains if (debug_level >= psb_debug_inner_) & & write(debug_unit,*) me,' ',trim(name),& - & ' Entry ', size(baseprecv) + & ' Entry ', size(precv) - nlev = size(baseprecv) + nlev = size(precv) allocate(mlprec_wrk(nlev),stat=info) if (info /= 0) then call psb_errpush(4010,name,a_err='Allocate') @@ -654,8 +619,7 @@ contains ! ! Copy the input vector X ! - n_col = psb_cd_get_local_cols(desc_data) - nc2l = psb_cd_get_local_cols(baseprecv(1)%base_desc) + nc2l = psb_cd_get_local_cols(precv(1)%base_desc) allocate(mlprec_wrk(1)%x2l(nc2l),mlprec_wrk(1)%y2l(nc2l), & & mlprec_wrk(1)%tx(nc2l), stat=info) @@ -672,8 +636,8 @@ contains ! ! Apply the base preconditioner at the finest level ! - call mld_baseprec_aply(sone,baseprecv(1),mlprec_wrk(1)%x2l,& - & szero,mlprec_wrk(1)%y2l,baseprecv(1)%base_desc,& + call mld_baseprec_aply(sone,precv(1)%prec,mlprec_wrk(1)%x2l,& + & szero,mlprec_wrk(1)%y2l,precv(1)%base_desc,& & trans,work,info) if (info /=0) then call psb_errpush(4010,name,a_err=' baseprec_aply') @@ -687,8 +651,8 @@ contains ! mlprec_wrk(1)%tx = mlprec_wrk(1)%x2l - call psb_spmm(-sone,baseprecv(1)%base_a,mlprec_wrk(1)%y2l,& - & sone,mlprec_wrk(1)%tx,baseprecv(1)%base_desc,info,& + call psb_spmm(-sone,precv(1)%base_a,mlprec_wrk(1)%y2l,& + & sone,mlprec_wrk(1)%tx,precv(1)%base_desc,info,& & work=work,trans=trans) if (info /=0) then call psb_errpush(4001,name,a_err=' fine level residual') @@ -702,12 +666,8 @@ contains ! do ilev = 2, nlev - n_row = psb_cd_get_local_rows(baseprecv(ilev-1)%base_desc) - n_col = psb_cd_get_local_cols(baseprecv(ilev-1)%base_desc) - nc2l = psb_cd_get_local_cols(baseprecv(ilev)%base_desc) - nr2l = psb_cd_get_local_rows(baseprecv(ilev)%base_desc) - ismth = baseprecv(ilev)%iprcparm(mld_aggr_kind_) - icm = baseprecv(ilev)%iprcparm(mld_coarse_mat_) + nc2l = psb_cd_get_local_cols(precv(ilev)%base_desc) + nr2l = psb_cd_get_local_rows(precv(ilev)%base_desc) allocate(mlprec_wrk(ilev)%tx(nc2l),mlprec_wrk(ilev)%y2l(nc2l),& & mlprec_wrk(ilev)%x2l(nc2l), stat=info) @@ -721,7 +681,7 @@ contains ! Apply prolongator transpose, i.e. restriction call psb_forward_map(sone,mlprec_wrk(ilev-1)%tx,& & szero,mlprec_wrk(ilev)%x2l,& - & baseprecv(ilev)%map_desc,info,work=work) + & precv(ilev)%map_desc,info,work=work) if (info /=0) then call psb_errpush(4001,name,a_err='Error during restriction') @@ -731,17 +691,17 @@ contains ! ! Apply the base preconditioner ! - call mld_baseprec_aply(sone,baseprecv(ilev),mlprec_wrk(ilev)%x2l,& - & szero,mlprec_wrk(ilev)%y2l,baseprecv(ilev)%base_desc,trans,work,info) + call mld_baseprec_aply(sone,precv(ilev)%prec,mlprec_wrk(ilev)%x2l,& + & szero,mlprec_wrk(ilev)%y2l,precv(ilev)%base_desc,trans,work,info) ! ! Compute the residual (at all levels but the coarsest one) ! if (ilev < nlev) then mlprec_wrk(ilev)%tx = mlprec_wrk(ilev)%x2l - if (info == 0) call psb_spmm(-sone,baseprecv(ilev)%base_a,& + if (info == 0) call psb_spmm(-sone,precv(ilev)%base_a,& & mlprec_wrk(ilev)%y2l,sone,mlprec_wrk(ilev)%tx,& - & baseprecv(ilev)%base_desc,info,work=work,trans=trans) + & precv(ilev)%base_desc,info,work=work,trans=trans) endif if (info /=0) then call psb_errpush(4001,name,a_err='Error on up sweep residual') @@ -755,16 +715,12 @@ contains ! For each level but the coarsest one ... ! do ilev = nlev-1, 1, -1 - - ismth = baseprecv(ilev+1)%iprcparm(mld_aggr_kind_) - n_row = psb_cd_get_local_rows(baseprecv(ilev)%base_desc) - ! ! Apply prolongator ! call psb_backward_map(sone,mlprec_wrk(ilev+1)%y2l,& & sone,mlprec_wrk(ilev)%y2l,& - & baseprecv(ilev+1)%map_desc,info,work=work) + & precv(ilev+1)%map_desc,info,work=work) if (info /=0) then call psb_errpush(4001,name,a_err='Error during prolongation') @@ -778,7 +734,7 @@ contains ! Compute the output vector Y ! call psb_geaxpby(alpha,mlprec_wrk(1)%y2l,beta,y,& - & baseprecv(1)%base_desc,info) + & precv(1)%base_desc,info) if (info /=0) then call psb_errpush(4001,name,a_err='Error on final update') goto 9999 @@ -811,7 +767,7 @@ contains ! Y = beta*Y + alpha*op(M^(-1))*X, ! where ! - M is a hybrid multilevel domain decomposition (Schwarz) preconditioner - ! associated to a certain matrix A and stored in the array baseprecv, + ! associated to a certain matrix A and stored in the array precv, ! - op(M^(-1)) is M^(-1) or its transpose, according to the value of trans, ! - X and Y are vectors, ! - alpha and beta are scalars. @@ -823,9 +779,9 @@ contains ! level where we might have a replicated index space) and each process takes care ! of one submatrix. ! - ! The multilevel preconditioner M is regarded as an array of 'base preconditioners', + ! The multilevel preconditioner M is regarded as an array of 'one-level preconditioners', ! each representing the part of the preconditioner associated to a certain level. - ! For each level ilev, the base preconditioner K(ilev) is stored in baseprecv(ilev) + ! For each level ilev, the base preconditioner K(ilev) is stored in precv(ilev) ! and is associated to a matrix A(ilev), obtained by 'tranferring' the original ! matrix A (i.e. the matrix to be preconditioned) to the level ilev, through smoothed ! aggregation. @@ -872,13 +828,13 @@ contains ! 5. Yext = beta*Yext + alpha*Y(1) ! ! - subroutine mlt_post_ml_aply(alpha,baseprecv,x,beta,y,desc_data,trans,work,info) + subroutine mlt_post_ml_aply(alpha,precv,x,beta,y,desc_data,trans,work,info) implicit none ! Arguments type(psb_desc_type),intent(in) :: desc_data - type(mld_sbaseprc_type), intent(in) :: baseprecv(:) + type(mld_s_onelev_prec_type), intent(in) :: precv(:) real(psb_spk_),intent(in) :: alpha,beta real(psb_spk_),intent(in) :: x(:) real(psb_spk_),intent(inout) :: y(:) @@ -887,10 +843,9 @@ contains integer, intent(out) :: info ! Local variables - integer :: n_row,n_col integer :: ictxt,np,me,i, nr2l,nc2l,err_act integer :: debug_level, debug_unit - integer :: ismth, nlev, ilev, icm + integer :: nlev, ilev character(len=20) :: name type psb_mlprec_wrk_type @@ -909,9 +864,9 @@ contains if (debug_level >= psb_debug_inner_) & & write(debug_unit,*) me,' ',trim(name),& - & ' Entry ', size(baseprecv) + & ' Entry ', size(precv) - nlev = size(baseprecv) + nlev = size(precv) allocate(mlprec_wrk(nlev),stat=info) if (info /= 0) then call psb_errpush(4010,name,a_err='Allocate') @@ -927,16 +882,21 @@ contains & write(debug_unit,*) me,' ',trim(name),& & ' desc_data status',allocated(desc_data%matrix_data) - n_col = psb_cd_get_local_cols(desc_data) - nc2l = psb_cd_get_local_cols(baseprecv(1)%base_desc) + nc2l = psb_cd_get_local_cols(precv(1)%base_desc) allocate(mlprec_wrk(1)%x2l(nc2l),mlprec_wrk(1)%y2l(nc2l), & & mlprec_wrk(1)%tx(nc2l), stat=info) + if (info /= 0) then + info=4025 + call psb_errpush(info,name,i_err=(/4*nc2l,0,0,0,0/),& + & a_err='real(psb_spk_)') + goto 9999 + end if call psb_geaxpby(sone,x,szero,mlprec_wrk(1)%tx,& - & baseprecv(1)%base_desc,info) + & precv(1)%base_desc,info) call psb_geaxpby(sone,x,szero,mlprec_wrk(1)%x2l,& - & baseprecv(1)%base_desc,info) + & precv(1)%base_desc,info) ! ! STEP 2 @@ -945,18 +905,13 @@ contains ! do ilev=2, nlev - n_row = psb_cd_get_local_rows(baseprecv(ilev-1)%base_desc) - n_col = psb_cd_get_local_cols(baseprecv(ilev-1)%base_desc) - nc2l = psb_cd_get_local_cols(baseprecv(ilev)%base_desc) - nr2l = psb_cd_get_local_rows(baseprecv(ilev)%base_desc) - ismth = baseprecv(ilev)%iprcparm(mld_aggr_kind_) - icm = baseprecv(ilev)%iprcparm(mld_coarse_mat_) + nc2l = psb_cd_get_local_cols(precv(ilev)%base_desc) + nr2l = psb_cd_get_local_rows(precv(ilev)%base_desc) if (debug_level >= psb_debug_inner_) & & write(debug_unit,*) me,' ',trim(name), & & ' starting up sweep ',& - & ilev,allocated(baseprecv(ilev)%iprcparm),n_row,n_col,& - & nc2l, nr2l,ismth + & ilev,allocated(precv(ilev)%iprcparm),nc2l, nr2l allocate(mlprec_wrk(ilev)%tx(nc2l),mlprec_wrk(ilev)%y2l(nc2l),& & mlprec_wrk(ilev)%x2l(nc2l), stat=info) @@ -971,7 +926,7 @@ contains ! Apply prolongator transpose, i.e. restriction call psb_forward_map(sone,mlprec_wrk(ilev-1)%x2l,& & szero,mlprec_wrk(ilev)%x2l,& - & baseprecv(ilev)%map_desc,info,work=work) + & precv(ilev)%map_desc,info,work=work) if (info /=0) then call psb_errpush(4001,name,a_err='Error during restriction') @@ -982,7 +937,7 @@ contains ! update x2l ! call psb_geaxpby(sone,mlprec_wrk(ilev)%x2l,szero,mlprec_wrk(ilev)%tx,& - & baseprecv(ilev)%base_desc,info) + & precv(ilev)%base_desc,info) if (info /= 0) then call psb_errpush(4001,name,a_err='Error in update') goto 9999 @@ -999,9 +954,8 @@ contains ! ! Apply the base preconditioner at the coarsest level ! - call mld_baseprec_aply(sone,baseprecv(nlev),mlprec_wrk(nlev)%x2l, & - & szero, mlprec_wrk(nlev)%y2l,baseprecv(nlev)%base_desc,trans,work,info) - + call mld_baseprec_aply(sone,precv(nlev)%prec,mlprec_wrk(nlev)%x2l, & + & szero, mlprec_wrk(nlev)%y2l,precv(nlev)%base_desc,trans,work,info) if (info /=0) then call psb_errpush(4010,name,a_err='baseprec_aply') goto 9999 @@ -1021,15 +975,12 @@ contains & write(debug_unit,*) me,' ',trim(name),& & ' starting down sweep',ilev - ismth = baseprecv(ilev+1)%iprcparm(mld_aggr_kind_) - n_row = psb_cd_get_local_rows(baseprecv(ilev)%base_desc) - ! ! Apply prolongator ! call psb_backward_map(sone,mlprec_wrk(ilev+1)%y2l,& & szero,mlprec_wrk(ilev)%y2l,& - & baseprecv(ilev+1)%map_desc,info,work=work) + & precv(ilev+1)%map_desc,info,work=work) if (info /=0) then call psb_errpush(4001,name,a_err='Error during prolongation') @@ -1039,15 +990,16 @@ contains ! ! Compute the residual ! - call psb_spmm(-sone,baseprecv(ilev)%base_a,mlprec_wrk(ilev)%y2l,& - & sone,mlprec_wrk(ilev)%tx,baseprecv(ilev)%base_desc,info,& + call psb_spmm(-sone,precv(ilev)%base_a,mlprec_wrk(ilev)%y2l,& + & sone,mlprec_wrk(ilev)%tx,precv(ilev)%base_desc,info,& & work=work,trans=trans) ! ! Apply the base preconditioner ! - if (info == 0) call mld_baseprec_aply(sone,baseprecv(ilev),mlprec_wrk(ilev)%tx,& - & sone,mlprec_wrk(ilev)%y2l,baseprecv(ilev)%base_desc,trans,work,info) + if (info == 0) call mld_baseprec_aply(sone,precv(ilev)%prec,& + & mlprec_wrk(ilev)%tx,sone,mlprec_wrk(ilev)%y2l,precv(ilev)%base_desc,& + & trans,work,info) if (info /=0) then call psb_errpush(4001,name,a_err=' spmm/baseprec_aply') goto 9999 @@ -1063,7 +1015,7 @@ contains ! ! Compute the output vector Y ! - call psb_geaxpby(alpha,mlprec_wrk(1)%y2l,beta,y,baseprecv(1)%base_desc,info) + call psb_geaxpby(alpha,mlprec_wrk(1)%y2l,beta,y,precv(1)%base_desc,info) if (info /=0) then call psb_errpush(4001,name,a_err=' Final update') @@ -1100,7 +1052,7 @@ contains ! where ! - M is a symmetrized hybrid multilevel domain decomposition (Schwarz) ! preconditioner associated to a certain matrix A and stored in the array - ! baseprecv, + ! precv, ! - op(M^(-1)) is M^(-1) or its transpose, according to the value of trans, ! - X and Y are vectors, ! - alpha and beta are scalars. @@ -1113,9 +1065,9 @@ contains ! level where we might have a replicated index space) and each process takes care ! of one submatrix. ! - ! The multilevel preconditioner M is regarded as an array of 'base preconditioners', + ! The multilevel preconditioner M is regarded as an array of 'one-level preconditioners', ! each representing the part of the preconditioner associated to a certain level. - ! For each level ilev, the base preconditioner K(ilev) is stored in baseprecv(ilev) + ! For each level ilev, the base preconditioner K(ilev) is stored in precv(ilev) ! and is associated to a matrix A(ilev), obtained by 'tranferring' the original ! matrix A (i.e. the matrix to be preconditioned) to the level ilev, through smoothed ! aggregation. @@ -1173,13 +1125,13 @@ contains ! ! 6. Yext = beta*Yext + alpha*Y(1) ! - subroutine mlt_twoside_ml_aply(alpha,baseprecv,x,beta,y,desc_data,trans,work,info) + subroutine mlt_twoside_ml_aply(alpha,precv,x,beta,y,desc_data,trans,work,info) implicit none ! Arguments type(psb_desc_type),intent(in) :: desc_data - type(mld_sbaseprc_type), intent(in) :: baseprecv(:) + type(mld_s_onelev_prec_type), intent(in) :: precv(:) real(psb_spk_),intent(in) :: alpha,beta real(psb_spk_),intent(in) :: x(:) real(psb_spk_),intent(inout) :: y(:) @@ -1188,10 +1140,9 @@ contains integer, intent(out) :: info ! Local variables - integer :: n_row,n_col integer :: ictxt,np,me,i, nr2l,nc2l,err_act integer :: debug_level, debug_unit - integer :: ismth, nlev, ilev, icm + integer :: nlev, ilev character(len=20) :: name type psb_mlprec_wrk_type @@ -1210,9 +1161,9 @@ contains if (debug_level >= psb_debug_inner_) & & write(debug_unit,*) me,' ',trim(name),& - & ' Entry ', size(baseprecv) + & ' Entry ', size(precv) - nlev = size(baseprecv) + nlev = size(precv) allocate(mlprec_wrk(nlev),stat=info) if (info /= 0) then call psb_errpush(4010,name,a_err='Allocate') @@ -1223,8 +1174,7 @@ contains ! ! Copy the input vector X ! - n_col = psb_cd_get_local_cols(desc_data) - nc2l = psb_cd_get_local_cols(baseprecv(1)%base_desc) + nc2l = psb_cd_get_local_cols(precv(1)%base_desc) allocate(mlprec_wrk(1)%x2l(nc2l),mlprec_wrk(1)%y2l(nc2l), & & mlprec_wrk(1)%ty(nc2l), mlprec_wrk(1)%tx(nc2l), stat=info) @@ -1237,17 +1187,17 @@ contains end if call psb_geaxpby(sone,x,szero,mlprec_wrk(1)%x2l,& - & baseprecv(1)%base_desc,info) + & precv(1)%base_desc,info) call psb_geaxpby(sone,x,szero,mlprec_wrk(1)%tx,& - & baseprecv(1)%base_desc,info) + & precv(1)%base_desc,info) ! ! STEP 2 ! ! Apply the base preconditioner at the finest level ! - call mld_baseprec_aply(sone,baseprecv(1),mlprec_wrk(1)%x2l,& - & szero,mlprec_wrk(1)%y2l,baseprecv(1)%base_desc,& + call mld_baseprec_aply(sone,precv(1)%prec,mlprec_wrk(1)%x2l,& + & szero,mlprec_wrk(1)%y2l,precv(1)%base_desc,& & trans,work,info) ! ! STEP 3 @@ -1255,8 +1205,8 @@ contains ! Compute the residual at the finest level ! mlprec_wrk(1)%ty = mlprec_wrk(1)%x2l - if (info == 0) call psb_spmm(-sone,baseprecv(1)%base_a,mlprec_wrk(1)%y2l,& - & sone,mlprec_wrk(1)%ty,baseprecv(1)%base_desc,info,& + if (info == 0) call psb_spmm(-sone,precv(1)%base_a,mlprec_wrk(1)%y2l,& + & sone,mlprec_wrk(1)%ty,precv(1)%base_desc,info,& & work=work,trans=trans) if (info /=0) then call psb_errpush(4010,name,a_err='Fine level baseprec/residual') @@ -1270,12 +1220,9 @@ contains ! do ilev = 2, nlev - n_row = psb_cd_get_local_rows(baseprecv(ilev-1)%base_desc) - n_col = psb_cd_get_local_cols(baseprecv(ilev-1)%base_desc) - nc2l = psb_cd_get_local_cols(baseprecv(ilev)%base_desc) - nr2l = psb_cd_get_local_rows(baseprecv(ilev)%base_desc) - ismth = baseprecv(ilev)%iprcparm(mld_aggr_kind_) - icm = baseprecv(ilev)%iprcparm(mld_coarse_mat_) + nc2l = psb_cd_get_local_cols(precv(ilev)%base_desc) + nr2l = psb_cd_get_local_rows(precv(ilev)%base_desc) + allocate(mlprec_wrk(ilev)%tx(nc2l),mlprec_wrk(ilev)%ty(nc2l),& & mlprec_wrk(ilev)%y2l(nc2l),mlprec_wrk(ilev)%x2l(nc2l), stat=info) @@ -1289,7 +1236,7 @@ contains ! Apply prolongator transpose, i.e. restriction call psb_forward_map(sone,mlprec_wrk(ilev-1)%ty,& & szero,mlprec_wrk(ilev)%x2l,& - & baseprecv(ilev)%map_desc,info,work=work) + & precv(ilev)%map_desc,info,work=work) if (info /=0) then call psb_errpush(4001,name,a_err='Error during restriction') @@ -1297,21 +1244,21 @@ contains end if call psb_geaxpby(sone,mlprec_wrk(ilev)%x2l,szero,mlprec_wrk(ilev)%tx,& - & baseprecv(ilev)%base_desc,info) + & precv(ilev)%base_desc,info) ! ! Apply the base preconditioner ! - if (info == 0) call mld_baseprec_aply(sone,baseprecv(ilev),& + if (info == 0) call mld_baseprec_aply(sone,precv(ilev)%prec,& & mlprec_wrk(ilev)%x2l,szero,mlprec_wrk(ilev)%y2l,& - & baseprecv(ilev)%base_desc,trans,work,info) + & precv(ilev)%base_desc,trans,work,info) ! ! Compute the residual (at all levels but the coarsest one) ! if(ilev < nlev) then mlprec_wrk(ilev)%ty = mlprec_wrk(ilev)%x2l - if (info == 0) call psb_spmm(-sone,baseprecv(ilev)%base_a,& + if (info == 0) call psb_spmm(-sone,precv(ilev)%base_a,& & mlprec_wrk(ilev)%y2l,sone,mlprec_wrk(ilev)%ty,& - & baseprecv(ilev)%base_desc,info,work=work,trans=trans) + & precv(ilev)%base_desc,info,work=work,trans=trans) endif if (info /=0) then call psb_errpush(4001,name,a_err='baseprec_aply/residual') @@ -1327,15 +1274,12 @@ contains ! do ilev=nlev-1, 1, -1 - ismth = baseprecv(ilev+1)%iprcparm(mld_aggr_kind_) - n_row = psb_cd_get_local_rows(baseprecv(ilev)%base_desc) - ! ! Apply prolongator ! call psb_backward_map(sone,mlprec_wrk(ilev+1)%y2l,& & sone,mlprec_wrk(ilev)%y2l,& - & baseprecv(ilev+1)%map_desc,info,work=work) + & precv(ilev+1)%map_desc,info,work=work) if (info /=0 ) then call psb_errpush(4001,name,a_err='Error during restriction') @@ -1345,14 +1289,14 @@ contains ! ! Compute the residual ! - call psb_spmm(-sone,baseprecv(ilev)%base_a,mlprec_wrk(ilev)%y2l,& - & sone,mlprec_wrk(ilev)%tx,baseprecv(ilev)%base_desc,info,& + call psb_spmm(-sone,precv(ilev)%base_a,mlprec_wrk(ilev)%y2l,& + & sone,mlprec_wrk(ilev)%tx,precv(ilev)%base_desc,info,& & work=work,trans=trans) ! ! Apply the base preconditioner ! - if (info == 0) call mld_baseprec_aply(sone,baseprecv(ilev),mlprec_wrk(ilev)%tx,& - & sone,mlprec_wrk(ilev)%y2l,baseprecv(ilev)%base_desc, trans, work,info) + if (info == 0) call mld_baseprec_aply(sone,precv(ilev)%prec,mlprec_wrk(ilev)%tx,& + & sone,mlprec_wrk(ilev)%y2l,precv(ilev)%base_desc, trans, work,info) if (info /= 0) then call psb_errpush(4001,name,a_err='Error: residual/baseprec_aply') goto 9999 @@ -1365,7 +1309,7 @@ contains ! Compute the output vector Y ! call psb_geaxpby(alpha,mlprec_wrk(1)%y2l,beta,y,& - & baseprecv(1)%base_desc,info) + & precv(1)%base_desc,info) if (info /= 0) then call psb_errpush(4001,name,a_err='Error final update') diff --git a/mlprec/mld_smlprec_bld.f90 b/mlprec/mld_smlprec_bld.f90 index 8b6234d1..b5f1feef 100644 --- a/mlprec/mld_smlprec_bld.f90 +++ b/mlprec/mld_smlprec_bld.f90 @@ -41,10 +41,11 @@ ! Subroutine: mld_smlprec_bld ! Version: real ! -! This routine builds the base preconditioner corresponding to the current +! This routine builds the preconditioner corresponding to the current ! level of the multilevel preconditioner. The routine first builds the ! (coarse) matrix associated to the current level from the (fine) matrix ! associated to the previous level, then builds the related base preconditioner. +! Note that this routine is only ever called on levels >= 2. ! ! ! Arguments: @@ -53,9 +54,9 @@ ! matrix to be preconditioned. ! desc_a - type(psb_desc_type), input. ! The communication descriptor of a. -! p - type(mld_sbaseprc_type), input/output. -! The base preconditioner data structure containing the local -! part of the base preconditioner to be built. +! p - type(mld_s_onelev_type), input/output. +! The preconditioner data structure containing the local +! part of the one-level preconditioner to be built. ! info - integer, output. ! Error code. ! @@ -69,7 +70,7 @@ subroutine mld_smlprec_bld(a,desc_a,p,info) ! Arguments type(psb_sspmat_type), intent(in), target :: a type(psb_desc_type), intent(in), target :: desc_a - type(mld_sbaseprc_type), intent(inout),target :: p + type(mld_s_onelev_prec_type), intent(inout),target :: p integer, intent(out) :: info ! Local variables @@ -106,16 +107,16 @@ subroutine mld_smlprec_bld(a,desc_a,p,info) & mld_max_norm_,is_legal_ml_aggr_eig) - select case(p%iprcparm(mld_sub_solve_)) + select case(p%prec%iprcparm(mld_sub_solve_)) case(mld_ilu_n_,mld_milu_n_) - call mld_check_def(p%iprcparm(mld_sub_fillin_),'Level',0,is_legal_ml_lev) + call mld_check_def(p%prec%iprcparm(mld_sub_fillin_),'Level',0,is_legal_ml_lev) case(mld_ilu_t_) - call mld_check_def(p%rprcparm(mld_sub_iluthrs_),'Eps',szero,is_legal_s_fact_thrs) + call mld_check_def(p%prec%rprcparm(mld_sub_iluthrs_),'Eps',szero,is_legal_s_fact_thrs) end select + call mld_check_def(p%prec%iprcparm(mld_smoother_sweeps_),'Jacobi sweeps',& + & 1,is_legal_jac_sweeps) call mld_check_def(p%rprcparm(mld_aggr_omega_val_),'Omega',szero,is_legal_s_omega) call mld_check_def(p%rprcparm(mld_aggr_thresh_),'Aggr_Thresh',szero,is_legal_s_aggr_thrs) - call mld_check_def(p%iprcparm(mld_smoother_sweeps_),'Jacobi sweeps',& - & 1,is_legal_jac_sweeps) ! ! Build a mapping between the row indices of the fine-level matrix @@ -135,7 +136,7 @@ subroutine mld_smlprec_bld(a,desc_a,p,info) ! the mapping defined by mld_aggrmap_bld and applying the aggregation ! algorithm specified by p%iprcparm(mld_aggr_kind_) ! - call mld_aggrmat_asb(a,desc_a,ac,desc_ac,p,info) + call mld_aggrmat_asb(a,desc_a,p,info) if(info /= 0) then call psb_errpush(4010,name,a_err='mld_aggrmat_asb') goto 9999 @@ -144,34 +145,18 @@ subroutine mld_smlprec_bld(a,desc_a,p,info) ! ! Build the 'base preconditioner' corresponding to the coarse level ! - call mld_baseprc_bld(ac,desc_ac,p,info) + call mld_baseprc_bld(p%ac,p%desc_ac,p%prec,info) if (info /= 0) then call psb_errpush(4010,name,a_err='mld_baseprc_bld') goto 9999 end if - ! - ! We have used a separate ac because - ! 1. we want to reuse the same routines mld_ilu_bld, etc., - ! 2. we do NOT want to pass an argument twice to them (p%av(mld_ac_) and p), - ! as this would violate the Fortran standard. - ! Hence a separate AC and a TRANSFER function at the end. + ! Fix the base_a and base_desc pointers for handling of residuals. + ! This is correct because this routine is only called at levels >=2. ! - call psb_sp_transfer(ac,p%av(mld_ac_),info) - p%base_a => p%av(mld_ac_) - if (info==0) call psb_cdtransfer(desc_ac,p%desc_ac,info) - - p%map_desc = psb_inter_desc(psb_map_aggr_,desc_a,& - & p%desc_ac,p%av(mld_sm_pr_t_),p%av(mld_sm_pr_)) - ! The two matrices from p%av() have been copied, may free them. - if (info == 0) call psb_sp_free(p%av(mld_sm_pr_t_),info) - if (info == 0) call psb_sp_free(p%av(mld_sm_pr_),info) - if (info /= 0) then - call psb_errpush(4010,name,a_err='psb_cdtransfer') - goto 9999 - end if + p%base_a => p%ac p%base_desc => p%desc_ac - + call psb_erractionrestore(err_act) return diff --git a/mlprec/mld_sprec_aply.f90 b/mlprec/mld_sprec_aply.f90 index e7ad914a..2e75b60f 100644 --- a/mlprec/mld_sprec_aply.f90 +++ b/mlprec/mld_sprec_aply.f90 @@ -120,25 +120,25 @@ subroutine mld_sprec_aply(prec,x,y,desc_data,info,trans,work) end if - if (.not.(allocated(prec%baseprecv))) then + if (.not.(allocated(prec%precv))) then !! Error 1: should call mld_sprecbld info=3112 call psb_errpush(info,name) goto 9999 end if - if (size(prec%baseprecv) >1) then - call mld_mlprec_aply(sone,prec%baseprecv,x,szero,y,desc_data,trans_,work_,info) + if (size(prec%precv) >1) then + call mld_mlprec_aply(sone,prec%precv,x,szero,y,desc_data,trans_,work_,info) if(info /= 0) then call psb_errpush(4010,name,a_err='mld_smlprec_aply') goto 9999 end if - else if (size(prec%baseprecv) == 1) then - call mld_baseprec_aply(sone,prec%baseprecv(1),x,szero,y,desc_data,trans_, work_,info) + else if (size(prec%precv) == 1) then + call mld_baseprec_aply(sone,prec%precv(1)%prec,x,szero,y,desc_data,trans_, work_,info) else info = 4013 - call psb_errpush(info,name,a_err='Invalid size of baseprecv',& - & i_Err=(/size(prec%baseprecv),0,0,0,0/)) + call psb_errpush(info,name,a_err='Invalid size of precv',& + & i_Err=(/size(prec%precv),0,0,0,0/)) goto 9999 endif diff --git a/mlprec/mld_sprecbld.f90 b/mlprec/mld_sprecbld.f90 index 91271d26..3f67c589 100644 --- a/mlprec/mld_sprecbld.f90 +++ b/mlprec/mld_sprecbld.f90 @@ -119,7 +119,7 @@ subroutine mld_sprecbld(a,desc_a,p,info) !!$ endif upd_ = 'F' - if (.not.allocated(p%baseprecv)) then + if (.not.allocated(p%precv)) then !! Error: should have called mld_sprecinit info=3111 call psb_errpush(info,name) @@ -129,11 +129,11 @@ subroutine mld_sprecbld(a,desc_a,p,info) ! ! Check to ensure all procs have the same ! - iszv = size(p%baseprecv) + iszv = size(p%precv) call psb_bcast(ictxt,iszv) - if (iszv /= size(p%baseprecv)) then + if (iszv /= size(p%precv)) then info=4001 - call psb_errpush(info,name,a_err='Inconsistent size of baseprecv') + call psb_errpush(info,name,a_err='Inconsistent size of precv') goto 9999 end if @@ -142,18 +142,20 @@ subroutine mld_sprecbld(a,desc_a,p,info) ! Check on the iprcparm contents: they should be the same ! on all processes. ! - if (me == psb_root_) ipv(:) = p%baseprecv(1)%iprcparm(:) + if (me == psb_root_) ipv(:) = p%precv(1)%iprcparm(:) call psb_bcast(ictxt,ipv) - if (any(ipv(:) /= p%baseprecv(1)%iprcparm(:) )) then + if (any(ipv(:) /= p%precv(1)%iprcparm(:) )) then write(debug_unit,*) me,name,& &': Inconsistent arguments among processes, forcing a default' - p%baseprecv(1)%iprcparm(:) = ipv(:) + p%precv(1)%iprcparm(:) = ipv(:) end if ! - ! Allocate and build the fine level preconditioner + ! Finest level first; remember to fix base_a and base_desc ! - call init_baseprc_av(p%baseprecv(1),info) - if (info == 0) call mld_baseprc_bld(a,desc_a,p%baseprecv(1),info,upd_) + call init_baseprc_av(p%precv(1)%prec,info) + if (info == 0) call mld_baseprc_bld(a,desc_a,p%precv(1)%prec,info,upd_) + p%precv(1)%base_a => a + p%precv(1)%base_desc => desc_a if (info /= 0) then call psb_errpush(4001,name,a_err='Base level precbuild.') @@ -178,69 +180,69 @@ subroutine mld_sprecbld(a,desc_a,p,info) ! Check on the iprcparm contents: they should be the same ! on all processes. ! - if (me == psb_root_) ipv(:) = p%baseprecv(i)%iprcparm(:) + if (me == psb_root_) ipv(:) = p%precv(i)%iprcparm(:) call psb_bcast(ictxt,ipv) - if (any(ipv(:) /= p%baseprecv(i)%iprcparm(:) )) then + if (any(ipv(:) /= p%precv(i)%iprcparm(:) )) then write(debug_unit,*) me,name,& &': Inconsistent arguments among processes, resetting.' - p%baseprecv(i)%iprcparm(:) = ipv(:) + p%precv(i)%iprcparm(:) = ipv(:) end if ! - ! Allocate the av component of the preconditioner data type - ! at level i + ! Sanity checks on the parameters ! if (i= psb_debug_outer_) & & write(debug_unit,*) me,' ',trim(name),& & 'Calling mlprcbld at level ',i - - ! - ! Build the base preconditioner corresponding to level i ! - if (info == 0) call mld_mlprec_bld(p%baseprecv(i-1)%base_a,& - & p%baseprecv(i-1)%base_desc, p%baseprecv(i),info) + ! Allocate and build the preconditioner at level i. + ! baseprec_bld is called inside mlprec_bld. + ! + call init_baseprc_av(p%precv(i)%prec,info) + if (info == 0) call mld_mlprec_bld(p%precv(i-1)%base_a,& + & p%precv(i-1)%base_desc, p%precv(i),info) + if (info /= 0) then call psb_errpush(4001,name,a_err='Init & build upper level preconditioner') goto 9999 @@ -250,11 +252,14 @@ subroutine mld_sprecbld(a,desc_a,p,info) & write(debug_unit,*) me,' ',trim(name),& & 'Return from ',i,' call to mlprcbld ',info end do + + ! ! Check on sizes from level 2 onwards + ! if (me==0) then k = iszv+1 do i=iszv,3,-1 - if (all(p%baseprecv(i)%nlaggr == p%baseprecv(i-1)%nlaggr)) then + if (all(p%precv(i)%nlaggr == p%precv(i-1)%nlaggr)) then k=i-1 end if end do diff --git a/mlprec/mld_sprecfree.f90 b/mlprec/mld_sprecfree.f90 index 50f15f18..f03948a7 100644 --- a/mlprec/mld_sprecfree.f90 +++ b/mlprec/mld_sprecfree.f90 @@ -74,11 +74,11 @@ subroutine mld_sprecfree(p,info) me=-1 - if (allocated(p%baseprecv)) then - do i=1,size(p%baseprecv) - call mld_base_precfree(p%baseprecv(i),info) + if (allocated(p%precv)) then + do i=1,size(p%precv) + call mld_onelev_precfree(p%precv(i),info) end do - deallocate(p%baseprecv) + deallocate(p%precv) end if call psb_erractionrestore(err_act) return diff --git a/mlprec/mld_sprecinit.F90 b/mlprec/mld_sprecinit.F90 index 3d75fc59..fa81e99d 100644 --- a/mlprec/mld_sprecinit.F90 +++ b/mlprec/mld_sprecinit.F90 @@ -104,7 +104,7 @@ subroutine mld_sprecinit(p,ptype,info,nlev) character(len=*), parameter :: name='mld_precinit' info = 0 - if (allocated(p%baseprecv)) then + if (allocated(p%precv)) then call mld_precfree(p,info) if (info /=0) then ! Do we want to do something? @@ -115,68 +115,88 @@ subroutine mld_sprecinit(p,ptype,info,nlev) case ('NOPREC') nlev_ = 1 ilev_ = 1 - allocate(p%baseprecv(nlev_),stat=info) - if (info == 0) call psb_realloc(mld_ifpsz_,p%baseprecv(ilev_)%iprcparm,info) - if (info == 0) call psb_realloc(mld_rfpsz_,p%baseprecv(ilev_)%rprcparm,info) + allocate(p%precv(nlev_),stat=info) + if (info == 0) call psb_realloc(mld_ifpsz_,p%precv(ilev_)%iprcparm,info) + if (info == 0) call psb_realloc(mld_rfpsz_,p%precv(ilev_)%rprcparm,info) + if (info == 0) call psb_realloc(mld_ifpsz_,p%precv(ilev_)%prec%iprcparm,info) + if (info == 0) call psb_realloc(mld_rfpsz_,p%precv(ilev_)%prec%rprcparm,info) if (info /= 0) return - p%baseprecv(ilev_)%iprcparm(:) = 0 - p%baseprecv(ilev_)%iprcparm(mld_smoother_type_) = mld_noprec_ - p%baseprecv(ilev_)%iprcparm(mld_sub_solve_) = mld_f_none_ - p%baseprecv(ilev_)%iprcparm(mld_sub_restr_) = psb_none_ - p%baseprecv(ilev_)%iprcparm(mld_sub_prol_) = psb_none_ - p%baseprecv(ilev_)%iprcparm(mld_sub_ren_) = 0 - p%baseprecv(ilev_)%iprcparm(mld_sub_ovr_) = 0 - p%baseprecv(ilev_)%iprcparm(mld_smoother_sweeps_) = 1 + p%precv(ilev_)%iprcparm(:) = 0 + p%precv(ilev_)%rprcparm(:) = szero + p%precv(ilev_)%prec%iprcparm(:) = 0 + p%precv(ilev_)%prec%rprcparm(:) = szero + p%precv(ilev_)%prec%iprcparm(mld_smoother_type_) = mld_noprec_ + p%precv(ilev_)%prec%iprcparm(mld_sub_solve_) = mld_f_none_ + p%precv(ilev_)%prec%iprcparm(mld_sub_restr_) = psb_none_ + p%precv(ilev_)%prec%iprcparm(mld_sub_prol_) = psb_none_ + p%precv(ilev_)%prec%iprcparm(mld_sub_ren_) = 0 + p%precv(ilev_)%prec%iprcparm(mld_sub_ovr_) = 0 + p%precv(ilev_)%prec%iprcparm(mld_smoother_sweeps_) = 1 case ('DIAG') nlev_ = 1 ilev_ = 1 - allocate(p%baseprecv(nlev_),stat=info) - if (info == 0) call psb_realloc(mld_ifpsz_,p%baseprecv(ilev_)%iprcparm,info) - if (info == 0) call psb_realloc(mld_rfpsz_,p%baseprecv(ilev_)%rprcparm,info) + allocate(p%precv(nlev_),stat=info) + if (info == 0) call psb_realloc(mld_ifpsz_,p%precv(ilev_)%iprcparm,info) + if (info == 0) call psb_realloc(mld_rfpsz_,p%precv(ilev_)%rprcparm,info) + if (info == 0) call psb_realloc(mld_ifpsz_,p%precv(ilev_)%prec%iprcparm,info) + if (info == 0) call psb_realloc(mld_rfpsz_,p%precv(ilev_)%prec%rprcparm,info) if (info /= 0) return - p%baseprecv(ilev_)%iprcparm(:) = 0 - p%baseprecv(ilev_)%iprcparm(mld_smoother_type_) = mld_diag_ - p%baseprecv(ilev_)%iprcparm(mld_sub_solve_) = mld_f_none_ - p%baseprecv(ilev_)%iprcparm(mld_sub_restr_) = psb_none_ - p%baseprecv(ilev_)%iprcparm(mld_sub_prol_) = psb_none_ - p%baseprecv(ilev_)%iprcparm(mld_sub_ren_) = 0 - p%baseprecv(ilev_)%iprcparm(mld_sub_ovr_) = 0 - p%baseprecv(ilev_)%iprcparm(mld_smoother_sweeps_) = 1 + p%precv(ilev_)%iprcparm(:) = 0 + p%precv(ilev_)%rprcparm(:) = szero + p%precv(ilev_)%prec%iprcparm(:) = 0 + p%precv(ilev_)%prec%rprcparm(:) = szero + p%precv(ilev_)%prec%iprcparm(mld_smoother_type_) = mld_diag_ + p%precv(ilev_)%prec%iprcparm(mld_sub_solve_) = mld_f_none_ + p%precv(ilev_)%prec%iprcparm(mld_sub_restr_) = psb_none_ + p%precv(ilev_)%prec%iprcparm(mld_sub_prol_) = psb_none_ + p%precv(ilev_)%prec%iprcparm(mld_sub_ren_) = 0 + p%precv(ilev_)%prec%iprcparm(mld_sub_ovr_) = 0 + p%precv(ilev_)%prec%iprcparm(mld_smoother_sweeps_) = 1 case ('BJAC') nlev_ = 1 ilev_ = 1 - allocate(p%baseprecv(nlev_),stat=info) - if (info == 0) call psb_realloc(mld_ifpsz_,p%baseprecv(ilev_)%iprcparm,info) - if (info == 0) call psb_realloc(mld_rfpsz_,p%baseprecv(ilev_)%rprcparm,info) + allocate(p%precv(nlev_),stat=info) + if (info == 0) call psb_realloc(mld_ifpsz_,p%precv(ilev_)%iprcparm,info) + if (info == 0) call psb_realloc(mld_rfpsz_,p%precv(ilev_)%rprcparm,info) + if (info == 0) call psb_realloc(mld_ifpsz_,p%precv(ilev_)%prec%iprcparm,info) + if (info == 0) call psb_realloc(mld_rfpsz_,p%precv(ilev_)%prec%rprcparm,info) if (info /= 0) return - p%baseprecv(ilev_)%iprcparm(:) = 0 - p%baseprecv(ilev_)%iprcparm(mld_smoother_type_) = mld_bjac_ - p%baseprecv(ilev_)%iprcparm(mld_sub_solve_) = mld_ilu_n_ - p%baseprecv(ilev_)%iprcparm(mld_sub_restr_) = psb_none_ - p%baseprecv(ilev_)%iprcparm(mld_sub_prol_) = psb_none_ - p%baseprecv(ilev_)%iprcparm(mld_sub_ren_) = 0 - p%baseprecv(ilev_)%iprcparm(mld_sub_ovr_) = 0 - p%baseprecv(ilev_)%iprcparm(mld_sub_fillin_) = 0 - p%baseprecv(ilev_)%iprcparm(mld_smoother_sweeps_) = 1 + p%precv(ilev_)%iprcparm(:) = 0 + p%precv(ilev_)%rprcparm(:) = szero + p%precv(ilev_)%prec%iprcparm(:) = 0 + p%precv(ilev_)%prec%rprcparm(:) = szero + p%precv(ilev_)%prec%iprcparm(mld_smoother_type_) = mld_bjac_ + p%precv(ilev_)%prec%iprcparm(mld_sub_solve_) = mld_ilu_n_ + p%precv(ilev_)%prec%iprcparm(mld_sub_restr_) = psb_none_ + p%precv(ilev_)%prec%iprcparm(mld_sub_prol_) = psb_none_ + p%precv(ilev_)%prec%iprcparm(mld_sub_ren_) = 0 + p%precv(ilev_)%prec%iprcparm(mld_sub_ovr_) = 0 + p%precv(ilev_)%prec%iprcparm(mld_sub_fillin_) = 0 + p%precv(ilev_)%prec%iprcparm(mld_smoother_sweeps_) = 1 case ('AS') nlev_ = 1 ilev_ = 1 - allocate(p%baseprecv(nlev_),stat=info) - if (info == 0) call psb_realloc(mld_ifpsz_,p%baseprecv(ilev_)%iprcparm,info) - if (info == 0) call psb_realloc(mld_rfpsz_,p%baseprecv(ilev_)%rprcparm,info) + allocate(p%precv(nlev_),stat=info) + if (info == 0) call psb_realloc(mld_ifpsz_,p%precv(ilev_)%iprcparm,info) + if (info == 0) call psb_realloc(mld_rfpsz_,p%precv(ilev_)%rprcparm,info) + if (info == 0) call psb_realloc(mld_ifpsz_,p%precv(ilev_)%prec%iprcparm,info) + if (info == 0) call psb_realloc(mld_rfpsz_,p%precv(ilev_)%prec%rprcparm,info) if (info /= 0) return - p%baseprecv(ilev_)%iprcparm(:) = 0 - p%baseprecv(ilev_)%iprcparm(mld_smoother_type_) = mld_as_ - p%baseprecv(ilev_)%iprcparm(mld_sub_solve_) = mld_ilu_n_ - p%baseprecv(ilev_)%iprcparm(mld_sub_restr_) = psb_halo_ - p%baseprecv(ilev_)%iprcparm(mld_sub_prol_) = psb_none_ - p%baseprecv(ilev_)%iprcparm(mld_sub_ren_) = 0 - p%baseprecv(ilev_)%iprcparm(mld_sub_ovr_) = 1 - p%baseprecv(ilev_)%iprcparm(mld_sub_fillin_) = 0 - p%baseprecv(ilev_)%iprcparm(mld_smoother_sweeps_) = 1 + p%precv(ilev_)%iprcparm(:) = 0 + p%precv(ilev_)%rprcparm(:) = szero + p%precv(ilev_)%prec%iprcparm(:) = 0 + p%precv(ilev_)%prec%rprcparm(:) = szero + p%precv(ilev_)%prec%iprcparm(mld_smoother_type_) = mld_as_ + p%precv(ilev_)%prec%iprcparm(mld_sub_solve_) = mld_ilu_n_ + p%precv(ilev_)%prec%iprcparm(mld_sub_restr_) = psb_halo_ + p%precv(ilev_)%prec%iprcparm(mld_sub_prol_) = psb_none_ + p%precv(ilev_)%prec%iprcparm(mld_sub_ren_) = 0 + p%precv(ilev_)%prec%iprcparm(mld_sub_ovr_) = 1 + p%precv(ilev_)%prec%iprcparm(mld_sub_fillin_) = 0 + p%precv(ilev_)%prec%iprcparm(mld_smoother_sweeps_) = 1 case ('ML') @@ -187,75 +207,87 @@ subroutine mld_sprecinit(p,ptype,info,nlev) nlev_ = 2 end if ilev_ = 1 - allocate(p%baseprecv(nlev_),stat=info) - if (info == 0) call psb_realloc(mld_ifpsz_,p%baseprecv(ilev_)%iprcparm,info) - if (info == 0) call psb_realloc(mld_rfpsz_,p%baseprecv(ilev_)%rprcparm,info) + allocate(p%precv(nlev_),stat=info) + if (info == 0) call psb_realloc(mld_ifpsz_,p%precv(ilev_)%iprcparm,info) + if (info == 0) call psb_realloc(mld_rfpsz_,p%precv(ilev_)%rprcparm,info) + if (info == 0) call psb_realloc(mld_ifpsz_,p%precv(ilev_)%prec%iprcparm,info) + if (info == 0) call psb_realloc(mld_rfpsz_,p%precv(ilev_)%prec%rprcparm,info) if (info /= 0) return - p%baseprecv(ilev_)%iprcparm(:) = 0 - p%baseprecv(ilev_)%rprcparm(:) = szero - p%baseprecv(ilev_)%iprcparm(mld_smoother_type_) = mld_as_ - p%baseprecv(ilev_)%iprcparm(mld_sub_solve_) = mld_ilu_n_ - p%baseprecv(ilev_)%iprcparm(mld_sub_restr_) = psb_halo_ - p%baseprecv(ilev_)%iprcparm(mld_sub_prol_) = psb_none_ - p%baseprecv(ilev_)%iprcparm(mld_sub_ren_) = 0 - p%baseprecv(ilev_)%iprcparm(mld_sub_ovr_) = 1 - p%baseprecv(ilev_)%iprcparm(mld_sub_fillin_) = 0 - p%baseprecv(ilev_)%iprcparm(mld_smoother_sweeps_) = 1 + p%precv(ilev_)%iprcparm(:) = 0 + p%precv(ilev_)%rprcparm(:) = szero + p%precv(ilev_)%prec%iprcparm(:) = 0 + p%precv(ilev_)%prec%rprcparm(:) = szero + p%precv(ilev_)%prec%iprcparm(mld_smoother_type_) = mld_as_ + p%precv(ilev_)%prec%iprcparm(mld_sub_solve_) = mld_ilu_n_ + p%precv(ilev_)%prec%iprcparm(mld_sub_restr_) = psb_halo_ + p%precv(ilev_)%prec%iprcparm(mld_sub_prol_) = psb_none_ + p%precv(ilev_)%prec%iprcparm(mld_sub_ren_) = 0 + p%precv(ilev_)%prec%iprcparm(mld_sub_ovr_) = 1 + p%precv(ilev_)%prec%iprcparm(mld_sub_fillin_) = 0 + p%precv(ilev_)%prec%iprcparm(mld_smoother_sweeps_) = 1 if (nlev_ == 1) return do ilev_ = 2, nlev_ -1 - if (info == 0) call psb_realloc(mld_ifpsz_,p%baseprecv(ilev_)%iprcparm,info) - if (info == 0) call psb_realloc(mld_rfpsz_,p%baseprecv(ilev_)%rprcparm,info) + if (info == 0) call psb_realloc(mld_ifpsz_,p%precv(ilev_)%iprcparm,info) + if (info == 0) call psb_realloc(mld_rfpsz_,p%precv(ilev_)%rprcparm,info) + if (info == 0) call psb_realloc(mld_ifpsz_,p%precv(ilev_)%prec%iprcparm,info) + if (info == 0) call psb_realloc(mld_rfpsz_,p%precv(ilev_)%prec%rprcparm,info) if (info /= 0) return - p%baseprecv(ilev_)%iprcparm(:) = 0 - p%baseprecv(ilev_)%rprcparm(:) = szero - p%baseprecv(ilev_)%iprcparm(mld_smoother_type_) = mld_as_ - p%baseprecv(ilev_)%iprcparm(mld_sub_restr_) = psb_halo_ - p%baseprecv(ilev_)%iprcparm(mld_sub_prol_) = psb_none_ - p%baseprecv(ilev_)%iprcparm(mld_sub_ren_) = 0 - p%baseprecv(ilev_)%iprcparm(mld_sub_ovr_) = 1 - p%baseprecv(ilev_)%iprcparm(mld_ml_type_) = mld_mult_ml_ - p%baseprecv(ilev_)%iprcparm(mld_aggr_alg_) = mld_dec_aggr_ - p%baseprecv(ilev_)%iprcparm(mld_aggr_kind_) = mld_smooth_prol_ - p%baseprecv(ilev_)%iprcparm(mld_coarse_mat_) = mld_distr_mat_ - p%baseprecv(ilev_)%iprcparm(mld_smoother_pos_) = mld_post_smooth_ - p%baseprecv(ilev_)%iprcparm(mld_aggr_omega_alg_) = mld_eig_est_ - p%baseprecv(ilev_)%iprcparm(mld_aggr_eig_) = mld_max_norm_ - p%baseprecv(ilev_)%iprcparm(mld_sub_solve_) = mld_ilu_n_ - p%baseprecv(ilev_)%iprcparm(mld_sub_fillin_) = 0 - p%baseprecv(ilev_)%iprcparm(mld_smoother_sweeps_) = 1 - p%baseprecv(ilev_)%rprcparm(mld_aggr_omega_val_) = szero - p%baseprecv(ilev_)%rprcparm(mld_aggr_thresh_) = szero + p%precv(ilev_)%iprcparm(:) = 0 + p%precv(ilev_)%rprcparm(:) = szero + p%precv(ilev_)%prec%iprcparm(:) = 0 + p%precv(ilev_)%prec%rprcparm(:) = szero + p%precv(ilev_)%prec%iprcparm(mld_smoother_type_) = mld_as_ + p%precv(ilev_)%prec%iprcparm(mld_sub_restr_) = psb_halo_ + p%precv(ilev_)%prec%iprcparm(mld_sub_prol_) = psb_none_ + p%precv(ilev_)%prec%iprcparm(mld_sub_ren_) = 0 + p%precv(ilev_)%prec%iprcparm(mld_sub_ovr_) = 1 + p%precv(ilev_)%prec%iprcparm(mld_sub_solve_) = mld_ilu_n_ + p%precv(ilev_)%prec%iprcparm(mld_sub_fillin_) = 0 + p%precv(ilev_)%prec%iprcparm(mld_smoother_sweeps_) = 1 + p%precv(ilev_)%iprcparm(mld_ml_type_) = mld_mult_ml_ + p%precv(ilev_)%iprcparm(mld_aggr_alg_) = mld_dec_aggr_ + p%precv(ilev_)%iprcparm(mld_aggr_kind_) = mld_smooth_prol_ + p%precv(ilev_)%iprcparm(mld_coarse_mat_) = mld_distr_mat_ + p%precv(ilev_)%iprcparm(mld_smoother_pos_) = mld_post_smooth_ + p%precv(ilev_)%iprcparm(mld_aggr_omega_alg_) = mld_eig_est_ + p%precv(ilev_)%iprcparm(mld_aggr_eig_) = mld_max_norm_ + p%precv(ilev_)%rprcparm(mld_aggr_omega_val_) = szero + p%precv(ilev_)%rprcparm(mld_aggr_thresh_) = szero end do ilev_ = nlev_ - if (info == 0) call psb_realloc(mld_ifpsz_,p%baseprecv(ilev_)%iprcparm,info) - if (info == 0) call psb_realloc(mld_rfpsz_,p%baseprecv(ilev_)%rprcparm,info) + if (info == 0) call psb_realloc(mld_ifpsz_,p%precv(ilev_)%iprcparm,info) + if (info == 0) call psb_realloc(mld_rfpsz_,p%precv(ilev_)%rprcparm,info) + if (info == 0) call psb_realloc(mld_ifpsz_,p%precv(ilev_)%prec%iprcparm,info) + if (info == 0) call psb_realloc(mld_rfpsz_,p%precv(ilev_)%prec%rprcparm,info) if (info /= 0) return - p%baseprecv(ilev_)%iprcparm(:) = 0 - p%baseprecv(ilev_)%rprcparm(:) = szero - p%baseprecv(ilev_)%iprcparm(mld_coarse_solve_) = mld_bjac_ + p%precv(ilev_)%iprcparm(:) = 0 + p%precv(ilev_)%rprcparm(:) = szero + p%precv(ilev_)%prec%iprcparm(:) = 0 + p%precv(ilev_)%prec%rprcparm(:) = szero + p%precv(ilev_)%prec%iprcparm(mld_coarse_solve_) = mld_bjac_ #if defined(HAVE_SLU_) - p%baseprecv(ilev_)%iprcparm(mld_sub_solve_) = mld_slu_ + p%precv(ilev_)%prec%iprcparm(mld_sub_solve_) = mld_slu_ #else - p%baseprecv(ilev_)%iprcparm(mld_sub_solve_) = mld_ilu_n_ + p%precv(ilev_)%prec%iprcparm(mld_sub_solve_) = mld_ilu_n_ #endif - p%baseprecv(ilev_)%iprcparm(mld_smoother_type_) = mld_bjac_ - p%baseprecv(ilev_)%iprcparm(mld_coarse_mat_) = mld_distr_mat_ - p%baseprecv(ilev_)%iprcparm(mld_sub_restr_) = psb_none_ - p%baseprecv(ilev_)%iprcparm(mld_sub_prol_) = psb_none_ - p%baseprecv(ilev_)%iprcparm(mld_sub_ren_) = 0 - p%baseprecv(ilev_)%iprcparm(mld_sub_ovr_) = 0 - p%baseprecv(ilev_)%iprcparm(mld_ml_type_) = mld_mult_ml_ - p%baseprecv(ilev_)%iprcparm(mld_aggr_alg_) = mld_dec_aggr_ - p%baseprecv(ilev_)%iprcparm(mld_aggr_kind_) = mld_smooth_prol_ - p%baseprecv(ilev_)%iprcparm(mld_smoother_pos_) = mld_post_smooth_ - p%baseprecv(ilev_)%iprcparm(mld_aggr_omega_alg_) = mld_eig_est_ - p%baseprecv(ilev_)%iprcparm(mld_aggr_eig_) = mld_max_norm_ - p%baseprecv(ilev_)%iprcparm(mld_sub_fillin_) = 0 - p%baseprecv(ilev_)%iprcparm(mld_smoother_sweeps_) = 4 - p%baseprecv(ilev_)%rprcparm(mld_aggr_omega_val_) = szero - p%baseprecv(ilev_)%rprcparm(mld_aggr_thresh_) = szero - + p%precv(ilev_)%prec%iprcparm(mld_smoother_type_) = mld_bjac_ + p%precv(ilev_)%prec%iprcparm(mld_coarse_mat_) = mld_distr_mat_ + p%precv(ilev_)%prec%iprcparm(mld_sub_restr_) = psb_none_ + p%precv(ilev_)%prec%iprcparm(mld_sub_prol_) = psb_none_ + p%precv(ilev_)%prec%iprcparm(mld_sub_ren_) = 0 + p%precv(ilev_)%prec%iprcparm(mld_sub_ovr_) = 0 + p%precv(ilev_)%prec%iprcparm(mld_sub_fillin_) = 0 + p%precv(ilev_)%prec%iprcparm(mld_smoother_sweeps_) = 4 + p%precv(ilev_)%iprcparm(mld_ml_type_) = mld_mult_ml_ + p%precv(ilev_)%iprcparm(mld_aggr_alg_) = mld_dec_aggr_ + p%precv(ilev_)%iprcparm(mld_aggr_kind_) = mld_smooth_prol_ + p%precv(ilev_)%iprcparm(mld_smoother_pos_) = mld_post_smooth_ + p%precv(ilev_)%iprcparm(mld_aggr_omega_alg_) = mld_eig_est_ + p%precv(ilev_)%iprcparm(mld_aggr_eig_) = mld_max_norm_ + p%precv(ilev_)%rprcparm(mld_aggr_omega_val_) = szero + p%precv(ilev_)%rprcparm(mld_aggr_thresh_) = szero + case default write(0,*) name,': Warning: Unknown preconditioner type request "',ptype,'"' info = 2 diff --git a/mlprec/mld_sprecset.f90 b/mlprec/mld_sprecset.f90 index 981dbaed..f5190d95 100644 --- a/mlprec/mld_sprecset.f90 +++ b/mlprec/mld_sprecset.f90 @@ -68,7 +68,6 @@ ! preconditioner parameter has to be set. ! If nlev is not present, the parameter identified by 'what' ! is set at all the appropriate levels. -! ! ! NOTE: currently, the use of the argument ilev is not "safe" and is reserved to ! MLD2P4 developers. Indeed, by using ilev it is possible to set different values @@ -97,12 +96,12 @@ subroutine mld_sprecseti(p,what,val,info,ilev) info = 0 - if (.not.allocated(p%baseprecv)) then + if (.not.allocated(p%precv)) then info = 3111 write(0,*) name,': Error: uninitialized preconditioner, should call MLD_PRECINIT' return endif - nlev_ = size(p%baseprecv) + nlev_ = size(p%precv) if (present(ilev)) then ilev_ = ilev @@ -115,7 +114,13 @@ subroutine mld_sprecseti(p,what,val,info,ilev) write(0,*) name,': Error: invalid ILEV/NLEV combination',ilev_, nlev_ return endif - if (.not.allocated(p%baseprecv(ilev_)%iprcparm)) then + if (.not.allocated(p%precv(ilev_)%iprcparm)) then + info = 3111 + write(0,*) name,& + &': Error: uninitialized preconditioner component, should call MLD_PRECINIT' + return + endif + if (.not.allocated(p%precv(ilev_)%prec%iprcparm)) then info = 3111 write(0,*) name,& &': Error: uninitialized preconditioner component, should call MLD_PRECINIT' @@ -126,7 +131,7 @@ subroutine mld_sprecseti(p,what,val,info,ilev) ! Set preconditioner parameters at level ilev. ! if (present(ilev)) then - + if (ilev_ == 1) then ! ! Rules for fine level are slightly different. @@ -134,7 +139,7 @@ subroutine mld_sprecseti(p,what,val,info,ilev) select case(what) case(mld_smoother_type_,mld_sub_solve_,mld_sub_restr_,mld_sub_prol_,& & mld_sub_ren_,mld_sub_ovr_,mld_sub_fillin_,mld_smoother_sweeps_) - p%baseprecv(ilev_)%iprcparm(what) = val + p%precv(ilev_)%prec%iprcparm(what) = val case default write(0,*) name,': Error: invalid WHAT' info = -2 @@ -144,23 +149,25 @@ subroutine mld_sprecseti(p,what,val,info,ilev) select case(what) case(mld_smoother_type_,mld_sub_solve_,mld_sub_restr_,mld_sub_prol_,& & mld_sub_ren_,mld_sub_ovr_,mld_sub_fillin_,& - & mld_smoother_sweeps_,mld_ml_type_,mld_aggr_alg_,mld_aggr_kind_,& + & mld_smoother_sweeps_) + p%precv(ilev_)%prec%iprcparm(what) = val + case(mld_ml_type_,mld_aggr_alg_,mld_aggr_kind_,& & mld_smoother_pos_,mld_aggr_omega_alg_,mld_aggr_eig_) - p%baseprecv(ilev_)%iprcparm(what) = val + p%precv(ilev_)%iprcparm(what) = val case(mld_coarse_mat_) if (ilev_ /= nlev_ .and. val /= mld_distr_mat_) then write(0,*) name,': Error: Inconsistent specification of WHAT vs. ILEV' info = -2 return end if - p%baseprecv(ilev_)%iprcparm(mld_coarse_mat_) = val + p%precv(ilev_)%iprcparm(mld_coarse_mat_) = val case(mld_coarse_subsolve_) if (ilev_ /= nlev_) then write(0,*) name,': Error: Inconsistent specification of WHAT vs. ILEV' info = -2 return end if - p%baseprecv(ilev_)%iprcparm(mld_sub_solve_) = val + p%precv(ilev_)%iprcparm(mld_sub_solve_) = val case(mld_coarse_solve_) if (ilev_ /= nlev_) then write(0,*) name,': Error: Inconsistent specification of WHAT vs. ILEV' @@ -169,15 +176,15 @@ subroutine mld_sprecseti(p,what,val,info,ilev) end if if (nlev_ > 1) then - p%baseprecv(nlev_)%iprcparm(mld_coarse_solve_) = val - p%baseprecv(nlev_)%iprcparm(mld_smoother_type_) = mld_bjac_ - p%baseprecv(nlev_)%iprcparm(mld_coarse_mat_) = mld_distr_mat_ + p%precv(nlev_)%iprcparm(mld_coarse_solve_) = val + p%precv(nlev_)%prec%iprcparm(mld_smoother_type_) = mld_bjac_ + p%precv(nlev_)%iprcparm(mld_coarse_mat_) = mld_distr_mat_ select case (val) case(mld_umf_, mld_slu_) - p%baseprecv(nlev_)%iprcparm(mld_coarse_mat_) = mld_repl_mat_ - p%baseprecv(nlev_)%iprcparm(mld_sub_solve_) = val + p%precv(nlev_)%iprcparm(mld_coarse_mat_) = mld_repl_mat_ + p%precv(nlev_)%prec%iprcparm(mld_sub_solve_) = val case(mld_sludist_) - p%baseprecv(nlev_)%iprcparm(mld_sub_solve_) = val + p%precv(nlev_)%prec%iprcparm(mld_sub_solve_) = val end select endif case(mld_coarse_sweeps_) @@ -186,14 +193,14 @@ subroutine mld_sprecseti(p,what,val,info,ilev) info = -2 return end if - p%baseprecv(ilev_)%iprcparm(mld_smoother_sweeps_) = val + p%precv(ilev_)%prec%iprcparm(mld_smoother_sweeps_) = val case(mld_coarse_fillin_) if (ilev_ /= nlev_) then write(0,*) name,': Error: Inconsistent specification of WHAT vs. ILEV' info = -2 return end if - p%baseprecv(ilev_)%iprcparm(mld_sub_fillin_) = val + p%precv(ilev_)%prec%iprcparm(mld_sub_fillin_) = val case default write(0,*) name,': Error: invalid WHAT' info = -2 @@ -211,35 +218,35 @@ subroutine mld_sprecseti(p,what,val,info,ilev) & mld_sub_ren_,mld_sub_ovr_,mld_sub_fillin_,& & mld_smoother_sweeps_) do ilev_=1,max(1,nlev_-1) - if (.not.allocated(p%baseprecv(ilev_)%iprcparm)) then + if (.not.allocated(p%precv(ilev_)%iprcparm)) then write(0,*) name,& &': Error: uninitialized preconditioner component, should call MLD_PRECINIT' info = -1 return endif - p%baseprecv(ilev_)%iprcparm(what) = val + p%precv(ilev_)%prec%iprcparm(what) = val end do case(mld_ml_type_,mld_aggr_alg_,mld_aggr_kind_,& & mld_smoother_pos_,mld_aggr_omega_alg_,mld_aggr_eig_) do ilev_=2,nlev_ - if (.not.allocated(p%baseprecv(ilev_)%iprcparm)) then + if (.not.allocated(p%precv(ilev_)%iprcparm)) then write(0,*) name,& &': Error: uninitialized preconditioner component, should call MLD_PRECINIT' info = -1 return endif - p%baseprecv(ilev_)%iprcparm(what) = val + p%precv(ilev_)%iprcparm(what) = val end do case(mld_coarse_mat_) - if (.not.allocated(p%baseprecv(nlev_)%iprcparm)) then + if (.not.allocated(p%precv(nlev_)%iprcparm)) then write(0,*) name,& & ': Error: uninitialized preconditioner component, should call MLD_PRECINIT' info = -1 return endif - if (nlev_ > 1) p%baseprecv(nlev_)%iprcparm(mld_coarse_mat_) = val + if (nlev_ > 1) p%precv(nlev_)%iprcparm(mld_coarse_mat_) = val case(mld_coarse_solve_) - if (.not.allocated(p%baseprecv(nlev_)%iprcparm)) then + if (.not.allocated(p%precv(nlev_)%iprcparm)) then write(0,*) name,& &': Error: uninitialized preconditioner component, should call MLD_PRECINIT' info = -1 @@ -247,42 +254,42 @@ subroutine mld_sprecseti(p,what,val,info,ilev) endif if (nlev_ > 1) then - p%baseprecv(nlev_)%iprcparm(mld_coarse_solve_) = val - p%baseprecv(nlev_)%iprcparm(mld_smoother_type_) = mld_bjac_ - p%baseprecv(nlev_)%iprcparm(mld_coarse_mat_) = mld_distr_mat_ + p%precv(nlev_)%iprcparm(mld_coarse_solve_) = val + p%precv(nlev_)%prec%iprcparm(mld_smoother_type_) = mld_bjac_ + p%precv(nlev_)%iprcparm(mld_coarse_mat_) = mld_distr_mat_ select case (val) case(mld_umf_, mld_slu_) - p%baseprecv(nlev_)%iprcparm(mld_coarse_mat_) = mld_repl_mat_ - p%baseprecv(nlev_)%iprcparm(mld_sub_solve_) = val + p%precv(nlev_)%iprcparm(mld_coarse_mat_) = mld_repl_mat_ + p%precv(nlev_)%prec%iprcparm(mld_sub_solve_) = val case(mld_sludist_) - p%baseprecv(nlev_)%iprcparm(mld_sub_solve_) = val + p%precv(nlev_)%prec%iprcparm(mld_sub_solve_) = val end select endif case(mld_coarse_subsolve_) - if (.not.allocated(p%baseprecv(nlev_)%iprcparm)) then + if (.not.allocated(p%precv(nlev_)%iprcparm)) then write(0,*) name,& &': Error: uninitialized preconditioner component, should call MLD_PRECINIT' info = -1 return end if - if (nlev_ > 1) p%baseprecv(nlev_)%iprcparm(mld_sub_solve_) = val + if (nlev_ > 1) p%precv(nlev_)%prec%iprcparm(mld_sub_solve_) = val case(mld_coarse_sweeps_) - if (.not.allocated(p%baseprecv(nlev_)%iprcparm)) then + if (.not.allocated(p%precv(nlev_)%iprcparm)) then write(0,*) name,& &': Error: uninitialized preconditioner component, should call MLD_PRECINIT' info = -1 return endif - if (nlev_ > 1) p%baseprecv(nlev_)%iprcparm(mld_smoother_sweeps_) = val + if (nlev_ > 1) p%precv(nlev_)%prec%iprcparm(mld_smoother_sweeps_) = val case(mld_coarse_fillin_) - if (.not.allocated(p%baseprecv(nlev_)%iprcparm)) then + if (.not.allocated(p%precv(nlev_)%iprcparm)) then write(0,*) name,& &': Error: uninitialized preconditioner component, should call MLD_PRECINIT' info = -1 return endif - if (nlev_ > 1) p%baseprecv(nlev_)%iprcparm(mld_sub_fillin_) = val + if (nlev_ > 1) p%precv(nlev_)%prec%iprcparm(mld_sub_fillin_) = val case default write(0,*) name,': Error: invalid WHAT' info = -2 @@ -353,11 +360,11 @@ subroutine mld_sprecsetc(p,what,string,info,ilev) info = 0 - if (.not.allocated(p%baseprecv)) then + if (.not.allocated(p%precv)) then info = 3111 return endif - nlev_ = size(p%baseprecv) + nlev_ = size(p%precv) if (present(ilev)) then ilev_ = ilev @@ -370,7 +377,7 @@ subroutine mld_sprecsetc(p,what,string,info,ilev) info = -1 return endif - if (.not.allocated(p%baseprecv(ilev_)%iprcparm)) then + if (.not.allocated(p%precv(ilev_)%iprcparm)) then write(0,*) name,': Error: uninitialized preconditioner component, should call MLD_PRECINIT' info = 3111 return @@ -449,19 +456,19 @@ subroutine mld_sprecsetr(p,what,val,info,ilev) ilev_ = 1 end if - if (.not.allocated(p%baseprecv)) then + if (.not.allocated(p%precv)) then write(0,*) name,': Error: uninitialized preconditioner, should call MLD_PRECINIT' info = 3111 return endif - nlev_ = size(p%baseprecv) + nlev_ = size(p%precv) if ((ilev_<1).or.(ilev_ > nlev_)) then write(0,*) name,': Error: invalid ILEV/NLEV combination',ilev_, nlev_ info = -1 return endif - if (.not.allocated(p%baseprecv(ilev_)%rprcparm)) then + if (.not.allocated(p%precv(ilev_)%rprcparm)) then write(0,*) name,': Error: uninitialized preconditioner component, should call MLD_PRECINIT' info = 3111 return @@ -478,7 +485,7 @@ subroutine mld_sprecsetr(p,what,val,info,ilev) ! select case(what) case(mld_sub_iluthrs_) - p%baseprecv(ilev_)%rprcparm(what) = val + p%precv(ilev_)%prec%rprcparm(what) = val case default write(0,*) name,': Error: invalid WHAT' info = -2 @@ -486,8 +493,10 @@ subroutine mld_sprecsetr(p,what,val,info,ilev) else if (ilev_ > 1) then select case(what) - case(mld_aggr_omega_val_,mld_aggr_thresh_,mld_sub_iluthrs_) - p%baseprecv(ilev_)%rprcparm(what) = val + case(mld_sub_iluthrs_) + p%precv(ilev_)%prec%rprcparm(what) = val + case(mld_aggr_omega_val_,mld_aggr_thresh_) + p%precv(ilev_)%rprcparm(what) = val case default write(0,*) name,': Error: invalid WHAT' info = -2 @@ -502,38 +511,38 @@ subroutine mld_sprecsetr(p,what,val,info,ilev) select case(what) case(mld_sub_iluthrs_) do ilev_=1,nlev_ - if (.not.allocated(p%baseprecv(ilev_)%rprcparm)) then + if (.not.allocated(p%precv(ilev_)%rprcparm)) then write(0,*) name,': Error: uninitialized preconditioner component, should call MLD_PRECINIT' info = -1 return endif - p%baseprecv(ilev_)%rprcparm(what) = val + p%precv(ilev_)%prec%rprcparm(what) = val end do case(mld_coarse_iluthrs_) ilev_=nlev_ - if (.not.allocated(p%baseprecv(ilev_)%rprcparm)) then + if (.not.allocated(p%precv(ilev_)%rprcparm)) then write(0,*) name,': Error: uninitialized preconditioner component, should call MLD_PRECINIT' info = -1 return endif - p%baseprecv(ilev_)%rprcparm(mld_sub_iluthrs_) = val + p%precv(ilev_)%prec%rprcparm(mld_sub_iluthrs_) = val case(mld_aggr_omega_val_) do ilev_=2,nlev_ - if (.not.allocated(p%baseprecv(ilev_)%rprcparm)) then + if (.not.allocated(p%precv(ilev_)%rprcparm)) then write(0,*) name,': Error: uninitialized preconditioner component, should call MLD_PRECINIT' info = -1 return endif - p%baseprecv(ilev_)%rprcparm(what) = val + p%precv(ilev_)%rprcparm(what) = val end do case(mld_aggr_thresh_) do ilev_=2,nlev_ - if (.not.allocated(p%baseprecv(ilev_)%rprcparm)) then + if (.not.allocated(p%precv(ilev_)%rprcparm)) then write(0,*) name,': Error: uninitialized preconditioner component, should call MLD_PRECINIT' info = -1 return endif - p%baseprecv(ilev_)%rprcparm(what) = val + p%precv(ilev_)%rprcparm(what) = val end do case default write(0,*) name,': Error: invalid WHAT' diff --git a/mlprec/mld_zaggrmat_asb.f90 b/mlprec/mld_zaggrmat_asb.f90 index cc4fea1f..dede101d 100644 --- a/mlprec/mld_zaggrmat_asb.f90 +++ b/mlprec/mld_zaggrmat_asb.f90 @@ -52,7 +52,7 @@ ! adjacency graph of A_C has been computed by the mld_aggrmap_bld subroutine. ! The prolongator P_C is built here from this mapping, according to the ! value of p%iprcparm(mld_aggr_kind_), specified by the user through -! mld_dprecinit and mld_dprecset. +! mld_zprecinit and mld_zprecset. ! ! Currently three different prolongators are implemented, corresponding to ! three aggregation algorithms: @@ -76,24 +76,21 @@ ! 1181-1196. ! ! +! ! Arguments: ! a - type(psb_zspmat_type), input. ! The sparse matrix structure containing the local part of ! the fine-level matrix. ! desc_a - type(psb_desc_type), input. ! The communication descriptor of the fine-level matrix. -! ac - type(psb_zspmat_type), output. -! The sparse matrix structure containing the local part of -! the coarse-level matrix. -! desc_ac - type(psb_desc_type), output. -! The communication descriptor of the coarse-level matrix. -! p - type(mld_zbaseprc_type), input/output. -! The base preconditioner data structure containing the local -! part of the base preconditioner to be built. +! p - type(mld_z_onelev_prec_type), input/output. +! The one-level preconditioner data structure containing the local +! part of the base preconditioner to be built as well as the +! aggregate matrices. ! info - integer, output. ! Error code. ! -subroutine mld_zaggrmat_asb(a,desc_a,ac,desc_ac,p,info) +subroutine mld_zaggrmat_asb(a,desc_a,p,info) use psb_base_mod use mld_inner_mod, mld_protect_name => mld_zaggrmat_asb @@ -101,12 +98,10 @@ subroutine mld_zaggrmat_asb(a,desc_a,ac,desc_ac,p,info) implicit none ! Arguments - type(psb_zspmat_type), intent(in) :: a - type(psb_desc_type), intent(in) :: desc_a - type(psb_zspmat_type), intent(out) :: ac - type(psb_desc_type), intent(out) :: desc_ac - type(mld_zbaseprc_type), intent(inout), target :: p - integer, intent(out) :: info + type(psb_zspmat_type), intent(in) :: a + type(psb_desc_type), intent(in) :: desc_a + type(mld_z_onelev_prec_type), intent(inout), target :: p + integer, intent(out) :: info ! Local variables integer :: ictxt,np,me, err_act, icomm @@ -125,7 +120,7 @@ subroutine mld_zaggrmat_asb(a,desc_a,ac,desc_ac,p,info) select case (p%iprcparm(mld_aggr_kind_)) case (mld_no_smooth_) - call mld_aggrmat_raw_asb(a,desc_a,ac,desc_ac,p,info) + call mld_aggrmat_raw_asb(a,desc_a,p,info) if(info /= 0) then call psb_errpush(4010,name,a_err='mld_aggrmat_raw_asb') goto 9999 @@ -133,7 +128,7 @@ subroutine mld_zaggrmat_asb(a,desc_a,ac,desc_ac,p,info) case(mld_smooth_prol_,mld_biz_prol_) - call mld_aggrmat_smth_asb(a,desc_a,ac,desc_ac,p,info) + call mld_aggrmat_smth_asb(a,desc_a,p,info) if(info /= 0) then call psb_errpush(4010,name,a_err='mld_aggrmat_smth_asb') goto 9999 diff --git a/mlprec/mld_zaggrmat_raw_asb.F90 b/mlprec/mld_zaggrmat_raw_asb.F90 index fcb99318..ce51b4bf 100644 --- a/mlprec/mld_zaggrmat_raw_asb.F90 +++ b/mlprec/mld_zaggrmat_raw_asb.F90 @@ -51,7 +51,7 @@ ! ! The coarse-level matrix A_C is distributed among the parallel processes or ! replicated on each of them, according to the value of p%iprcparm(mld_coarse_mat_), -! specified by the user through mld_dprecinit and mld_dprecset. +! specified by the user through mld_zprecinit and mld_zprecset. ! ! For details see ! P. D'Ambra, D. di Serafino and S. Filippone, On the development of @@ -59,24 +59,21 @@ ! 57 (2007), 1181-1196. ! ! +! ! Arguments: ! a - type(psb_zspmat_type), input. ! The sparse matrix structure containing the local part of ! the fine-level matrix. ! desc_a - type(psb_desc_type), input. ! The communication descriptor of the fine-level matrix. -! ac - type(psb_zspmat_type), output. -! The sparse matrix structure containing the local part of -! the coarse-level matrix. -! desc_ac - type(psb_desc_type), output. -! The communication descriptor of the coarse-level matrix. -! p - type(mld_zbaseprc_type), input/output. -! The base preconditioner data structure containing the local -! part of the base preconditioner to be built. +! p - type(mld_z_onelev_prec_type), input/output. +! The one-level preconditioner data structure containing the local +! part of the base preconditioner to be built as well as the +! aggregate matrices. ! info - integer, output. ! Error code. ! -subroutine mld_zaggrmat_raw_asb(a,desc_a,ac,desc_ac,p,info) +subroutine mld_zaggrmat_raw_asb(a,desc_a,p,info) use psb_base_mod use mld_inner_mod, mld_protect_name => mld_zaggrmat_raw_asb @@ -89,19 +86,17 @@ subroutine mld_zaggrmat_raw_asb(a,desc_a,ac,desc_ac,p,info) #endif ! Arguments - type(psb_zspmat_type), intent(in) :: a - type(psb_desc_type), intent(in) :: desc_a - type(psb_zspmat_type), intent(out) :: ac - type(psb_desc_type), intent(out) :: desc_ac - type(mld_zbaseprc_type), intent(inout), target :: p - integer, intent(out) :: info + type(psb_zspmat_type), intent(in) :: a + type(psb_desc_type), intent(in) :: desc_a + type(mld_z_onelev_prec_type), intent(inout), target :: p + integer, intent(out) :: info ! Local variables integer ::ictxt,np,me, err_act, icomm character(len=20) :: name - type(psb_zspmat_type) :: b - integer, pointer :: nzbr(:), idisp(:) - type(psb_zspmat_type), pointer :: am1,am2 + type(psb_zspmat_type) :: b + integer, allocatable :: nzbr(:), idisp(:) + type(psb_zspmat_type) :: am1,am2 integer :: nrow, nglob, ncol, ntaggr, nzac, ip, ndx,& & naggr, nzt,naggrm1, i @@ -119,9 +114,6 @@ subroutine mld_zaggrmat_raw_asb(a,desc_a,ac,desc_ac,p,info) nrow = psb_cd_get_local_rows(desc_a) ncol = psb_cd_get_local_cols(desc_a) - - am2 => p%av(mld_sm_pr_t_) - am1 => p%av(mld_sm_pr_) call psb_nullify_sp(am1) call psb_nullify_sp(am2) @@ -195,7 +187,7 @@ subroutine mld_zaggrmat_raw_asb(a,desc_a,ac,desc_ac,p,info) if (p%iprcparm(mld_coarse_mat_) == mld_repl_mat_) then - call psb_cdall(ictxt,desc_ac,info,mg=ntaggr,repl=.true.) + call psb_cdall(ictxt,p%desc_ac,info,mg=ntaggr,repl=.true.) if(info /= 0) then call psb_errpush(4010,name,a_err='psb_cdall') goto 9999 @@ -206,7 +198,7 @@ subroutine mld_zaggrmat_raw_asb(a,desc_a,ac,desc_ac,p,info) call psb_sum(ictxt,nzbr(1:np)) nzac = sum(nzbr) - call psb_sp_all(ntaggr,ntaggr,ac,nzac,info) + call psb_sp_all(ntaggr,ntaggr,p%ac,nzac,info) if(info /= 0) then call psb_errpush(4010,name,a_err='sp_all') goto 9999 @@ -217,11 +209,11 @@ subroutine mld_zaggrmat_raw_asb(a,desc_a,ac,desc_ac,p,info) enddo ndx = nzbr(me+1) - call mpi_allgatherv(b%aspk,ndx,mpi_double_complex,ac%aspk,nzbr,idisp,& + call mpi_allgatherv(b%aspk,ndx,mpi_double_complex,p%ac%aspk,nzbr,idisp,& & mpi_double_complex,icomm,info) - call mpi_allgatherv(b%ia1,ndx,mpi_integer,ac%ia1,nzbr,idisp,& + call mpi_allgatherv(b%ia1,ndx,mpi_integer,p%ac%ia1,nzbr,idisp,& & mpi_integer,icomm,info) - call mpi_allgatherv(b%ia2,ndx,mpi_integer,ac%ia2,nzbr,idisp,& + call mpi_allgatherv(b%ia2,ndx,mpi_integer,p%ac%ia2,nzbr,idisp,& & mpi_integer,icomm,info) if(info /= 0) then info=-1 @@ -229,12 +221,12 @@ subroutine mld_zaggrmat_raw_asb(a,desc_a,ac,desc_ac,p,info) goto 9999 end if - ac%m = ntaggr - ac%k = ntaggr - ac%infoa(psb_nnz_) = nzac - ac%fida='COO' - ac%descra='GUN' - call psb_spcnv(ac,info,afmt='coo',dupl=psb_dupl_add_) + p%ac%m = ntaggr + p%ac%k = ntaggr + p%ac%infoa(psb_nnz_) = nzac + p%ac%fida='COO' + p%ac%descra='GUN' + call psb_spcnv(p%ac,info,afmt='coo',dupl=psb_dupl_add_) if(info /= 0) then call psb_errpush(4010,name,a_err='sp_free') goto 9999 @@ -242,9 +234,9 @@ subroutine mld_zaggrmat_raw_asb(a,desc_a,ac,desc_ac,p,info) else if (p%iprcparm(mld_coarse_mat_) == mld_distr_mat_) then - call psb_cdall(ictxt,desc_ac,info,nl=naggr) - if (info == 0) call psb_cdasb(desc_ac,info) - if (info == 0) call psb_sp_clone(b,ac,info) + call psb_cdall(ictxt,p%desc_ac,info,nl=naggr) + if (info == 0) call psb_cdasb(p%desc_ac,info) + if (info == 0) call psb_sp_clone(b,p%ac,info) if(info /= 0) then call psb_errpush(4001,name,a_err='Build ac, desc_ac') goto 9999 @@ -263,9 +255,23 @@ subroutine mld_zaggrmat_raw_asb(a,desc_a,ac,desc_ac,p,info) deallocate(nzbr,idisp) - call psb_spcnv(ac,info,afmt='csr',dupl=psb_dupl_add_) + call psb_spcnv(p%ac,info,afmt='csr',dupl=psb_dupl_add_) + if(info /= 0) then + call psb_errpush(4010,name,a_err='spcnv') + goto 9999 + end if + + ! + ! Copy the prolongation/restriction matrices into the descriptor map. + ! am2 => PR^T i.e. restriction operator + ! am1 => PR i.e. prolongation operator + ! + p%map_desc = psb_inter_desc(psb_map_aggr_,desc_a,& + & p%desc_ac,am2,am1) + if (info == 0) call psb_sp_free(am1,info) + if (info == 0) call psb_sp_free(am2,info) if(info /= 0) then - call psb_errpush(4010,name,a_err='ipcoo2csr') + call psb_errpush(4010,name,a_err='sp_Free') goto 9999 end if diff --git a/mlprec/mld_zaggrmat_smth_asb.F90 b/mlprec/mld_zaggrmat_smth_asb.F90 index ae204928..b56f6592 100644 --- a/mlprec/mld_zaggrmat_smth_asb.F90 +++ b/mlprec/mld_zaggrmat_smth_asb.F90 @@ -83,18 +83,14 @@ ! the fine-level matrix. ! desc_a - type(psb_desc_type), input. ! The communication descriptor of the fine-level matrix. -! ac - type(psb_zspmat_type), output. -! The sparse matrix structure containing the local part of -! the coarse-level matrix. -! desc_ac - type(psb_desc_type), output. -! The communication descriptor of the coarse-level matrix. -! p - type(mld_zbaseprc_type), input/output. -! The base preconditioner data structure containing the local -! part of the base preconditioner to be built. +! p - type(mld_z_onelev_prec_type), input/output. +! The one-level preconditioner data structure containing the local +! part of the base preconditioner to be built as well as the +! aggregate matrices. ! info - integer, output. ! Error code. ! -subroutine mld_zaggrmat_smth_asb(a,desc_a,ac,desc_ac,p,info) +subroutine mld_zaggrmat_smth_asb(a,desc_a,p,info) use psb_base_mod use mld_inner_mod, mld_protect_name => mld_zaggrmat_smth_asb @@ -109,19 +105,17 @@ subroutine mld_zaggrmat_smth_asb(a,desc_a,ac,desc_ac,p,info) ! Arguments type(psb_zspmat_type), intent(in) :: a type(psb_desc_type), intent(in) :: desc_a - type(psb_zspmat_type), intent(out) :: ac - type(psb_desc_type), intent(out) :: desc_ac - type(mld_zbaseprc_type), intent(inout), target :: p + type(mld_z_onelev_prec_type), intent(inout), target :: p integer, intent(out) :: info ! Local variables - type(psb_zspmat_type) :: b - integer, pointer :: nzbr(:), idisp(:) + type(psb_zspmat_type) :: b + integer, allocatable :: nzbr(:), idisp(:) integer :: nrow, nglob, ncol, ntaggr, nzac, ip, ndx,& & naggr, nzl,naggrm1,naggrp1, i, j, k integer ::ictxt,np,me, err_act, icomm character(len=20) :: name - type(psb_zspmat_type), pointer :: am1,am2 + type(psb_zspmat_type) :: am1,am2 type(psb_zspmat_type) :: am3,am4 complex(psb_dpk_), allocatable :: adiag(:) logical :: ml_global_nmb @@ -146,9 +140,6 @@ subroutine mld_zaggrmat_smth_asb(a,desc_a,ac,desc_ac,p,info) call psb_nullify_sp(b) call psb_nullify_sp(am3) call psb_nullify_sp(am4) - - am2 => p%av(mld_sm_pr_t_) - am1 => p%av(mld_sm_pr_) call psb_nullify_sp(am1) call psb_nullify_sp(am2) @@ -191,7 +182,7 @@ subroutine mld_zaggrmat_smth_asb(a,desc_a,ac,desc_ac,p,info) if (info /= 0) then info=4025 call psb_errpush(info,name,i_err=(/nrow,0,0,0,0/),& - & a_err='real(psb_dpk_)') + & a_err='complex(psb_dpk_)') goto 9999 end if @@ -456,16 +447,16 @@ subroutine mld_zaggrmat_smth_asb(a,desc_a,ac,desc_ac,p,info) case(mld_distr_mat_) - call psb_sp_clone(b,ac,info) - nzac = ac%infoa(psb_nnz_) - nzl = ac%infoa(psb_nnz_) - if (info == 0) call psb_cdall(ictxt,desc_ac,info,nl=p%nlaggr(me+1)) - if (info == 0) call psb_cdins(nzl,ac%ia1,ac%ia2,desc_ac,info) - if (info == 0) call psb_cdasb(desc_ac,info) - if (info == 0) call psb_glob_to_loc(ac%ia1(1:nzl),desc_ac,info,iact='I') - if (info == 0) call psb_glob_to_loc(ac%ia2(1:nzl),desc_ac,info,iact='I') + call psb_sp_clone(b,p%ac,info) + nzac = p%ac%infoa(psb_nnz_) + nzl = p%ac%infoa(psb_nnz_) + if (info == 0) call psb_cdall(ictxt,p%desc_ac,info,nl=p%nlaggr(me+1)) + if (info == 0) call psb_cdins(nzl,p%ac%ia1,p%ac%ia2,p%desc_ac,info) + if (info == 0) call psb_cdasb(p%desc_ac,info) + if (info == 0) call psb_glob_to_loc(p%ac%ia1(1:nzl),p%desc_ac,info,iact='I') + if (info == 0) call psb_glob_to_loc(p%ac%ia2(1:nzl),p%desc_ac,info,iact='I') if (info /= 0) then - call psb_errpush(4001,name,a_err='Creating desc_ac and converting ac') + call psb_errpush(4001,name,a_err='Creating p%desc_ac and converting ac') goto 9999 end if if (debug_level >= psb_debug_outer_) & @@ -473,10 +464,10 @@ subroutine mld_zaggrmat_smth_asb(a,desc_a,ac,desc_ac,p,info) & 'Assembld aux descr. distr.' - ac%m=desc_ac%matrix_data(psb_n_row_) - ac%k=desc_ac%matrix_data(psb_n_col_) - ac%fida='COO' - ac%descra='GUN' + p%ac%m=psb_cd_get_local_rows(p%desc_ac) + p%ac%k=psb_cd_get_local_cols(p%desc_ac) + p%ac%fida='COO' + p%ac%descra='GUN' call psb_sp_free(b,info) if (info == 0) deallocate(nzbr,idisp,stat=info) @@ -487,25 +478,25 @@ subroutine mld_zaggrmat_smth_asb(a,desc_a,ac,desc_ac,p,info) if (np>1) then nzl = psb_sp_get_nnzeros(am1) - call psb_glob_to_loc(am1%ia1(1:nzl),desc_ac,info,'I') + call psb_glob_to_loc(am1%ia1(1:nzl),p%desc_ac,info,'I') if(info /= 0) then call psb_errpush(4010,name,a_err='psb_glob_to_loc') goto 9999 end if endif - am1%k=desc_ac%matrix_data(psb_n_col_) + am1%k=psb_cd_get_local_cols(p%desc_ac) if (np>1) then call psb_spcnv(am2,info,afmt='coo',dupl=psb_dupl_add_) nzl = am2%infoa(psb_nnz_) - if (info == 0) call psb_glob_to_loc(am2%ia1(1:nzl),desc_ac,info,'I') + if (info == 0) call psb_glob_to_loc(am2%ia1(1:nzl),p%desc_ac,info,'I') if (info == 0) call psb_spcnv(am2,info,afmt='csr',dupl=psb_dupl_add_) if(info /= 0) then call psb_errpush(4001,name,a_err='Converting am2 to local') goto 9999 end if end if - am2%m=desc_ac%matrix_data(psb_n_col_) + am2%m=psb_cd_get_local_cols(p%desc_ac) if (debug_level >= psb_debug_outer_) & & write(debug_unit,*) me,' ',trim(name),& @@ -514,13 +505,13 @@ subroutine mld_zaggrmat_smth_asb(a,desc_a,ac,desc_ac,p,info) case(mld_repl_mat_) ! ! - call psb_cdall(ictxt,desc_ac,info,mg=ntaggr,repl=.true.) + call psb_cdall(ictxt,p%desc_ac,info,mg=ntaggr,repl=.true.) nzbr(:) = 0 nzbr(me+1) = b%infoa(psb_nnz_) call psb_sum(ictxt,nzbr(1:np)) nzac = sum(nzbr) - if (info == 0) call psb_sp_all(ntaggr,ntaggr,ac,nzac,info) + if (info == 0) call psb_sp_all(ntaggr,ntaggr,p%ac,nzac,info) if (info /= 0) goto 9999 do ip=1,np @@ -528,11 +519,11 @@ subroutine mld_zaggrmat_smth_asb(a,desc_a,ac,desc_ac,p,info) enddo ndx = nzbr(me+1) - call mpi_allgatherv(b%aspk,ndx,mpi_double_complex,ac%aspk,nzbr,idisp,& + call mpi_allgatherv(b%aspk,ndx,mpi_double_complex,p%ac%aspk,nzbr,idisp,& & mpi_double_complex,icomm,info) - if (info == 0) call mpi_allgatherv(b%ia1,ndx,mpi_integer,ac%ia1,nzbr,idisp,& + if (info == 0) call mpi_allgatherv(b%ia1,ndx,mpi_integer,p%ac%ia1,nzbr,idisp,& & mpi_integer,icomm,info) - if (info == 0) call mpi_allgatherv(b%ia2,ndx,mpi_integer,ac%ia2,nzbr,idisp,& + if (info == 0) call mpi_allgatherv(b%ia2,ndx,mpi_integer,p%ac%ia2,nzbr,idisp,& & mpi_integer,icomm,info) if (info /= 0) then @@ -540,12 +531,12 @@ subroutine mld_zaggrmat_smth_asb(a,desc_a,ac,desc_ac,p,info) goto 9999 end if - ac%m = ntaggr - ac%k = ntaggr - ac%infoa(psb_nnz_) = nzac - ac%fida='COO' - ac%descra='GUN' - call psb_spcnv(ac,info,afmt='coo',dupl=psb_dupl_add_) + p%ac%m = ntaggr + p%ac%k = ntaggr + p%ac%infoa(psb_nnz_) = nzac + p%ac%fida='COO' + p%ac%descra='GUN' + call psb_spcnv(p%ac,info,afmt='coo',dupl=psb_dupl_add_) if(info /= 0) goto 9999 call psb_sp_free(b,info) if(info /= 0) goto 9999 @@ -569,9 +560,9 @@ subroutine mld_zaggrmat_smth_asb(a,desc_a,ac,desc_ac,p,info) case(mld_distr_mat_) - call psb_sp_clone(b,ac,info) - if (info == 0) call psb_cdall(ictxt,desc_ac,info,nl=naggr) - if (info == 0) call psb_cdasb(desc_ac,info) + call psb_sp_clone(b,p%ac,info) + if (info == 0) call psb_cdall(ictxt,p%desc_ac,info,nl=naggr) + if (info == 0) call psb_cdasb(p%desc_ac,info) if (info == 0) call psb_sp_free(b,info) if (info /= 0) then call psb_errpush(4010,name,a_err='Build desc_ac, ac') @@ -582,7 +573,7 @@ subroutine mld_zaggrmat_smth_asb(a,desc_a,ac,desc_ac,p,info) case(mld_repl_mat_) ! ! - call psb_cdall(ictxt,desc_ac,info,mg=ntaggr,repl=.true.) + call psb_cdall(ictxt,p%desc_ac,info,mg=ntaggr,repl=.true.) if(info /= 0) then call psb_errpush(4010,name,a_err='psb_cdall') goto 9999 @@ -592,7 +583,7 @@ subroutine mld_zaggrmat_smth_asb(a,desc_a,ac,desc_ac,p,info) nzbr(me+1) = b%infoa(psb_nnz_) call psb_sum(ictxt,nzbr(1:np)) nzac = sum(nzbr) - call psb_sp_all(ntaggr,ntaggr,ac,nzac,info) + call psb_sp_all(ntaggr,ntaggr,p%ac,nzac,info) if(info /= 0) then call psb_errpush(4010,name,a_err='psb_sp_all') goto 9999 @@ -603,11 +594,11 @@ subroutine mld_zaggrmat_smth_asb(a,desc_a,ac,desc_ac,p,info) enddo ndx = nzbr(me+1) - call mpi_allgatherv(b%aspk,ndx,mpi_double_complex,ac%aspk,nzbr,idisp,& + call mpi_allgatherv(b%aspk,ndx,mpi_double_complex,p%ac%aspk,nzbr,idisp,& & mpi_double_complex,icomm,info) - if (info == 0) call mpi_allgatherv(b%ia1,ndx,mpi_integer,ac%ia1,nzbr,idisp,& + if (info == 0) call mpi_allgatherv(b%ia1,ndx,mpi_integer,p%ac%ia1,nzbr,idisp,& & mpi_integer,icomm,info) - if (info == 0) call mpi_allgatherv(b%ia2,ndx,mpi_integer,ac%ia2,nzbr,idisp,& + if (info == 0) call mpi_allgatherv(b%ia2,ndx,mpi_integer,p%ac%ia2,nzbr,idisp,& & mpi_integer,icomm,info) if (info /= 0) then call psb_errpush(4001,name,a_err=' from mpi_allgatherv') @@ -615,12 +606,12 @@ subroutine mld_zaggrmat_smth_asb(a,desc_a,ac,desc_ac,p,info) end if - ac%m = ntaggr - ac%k = ntaggr - ac%infoa(psb_nnz_) = nzac - ac%fida='COO' - ac%descra='GUN' - call psb_spcnv(ac,info,afmt='coo',dupl=psb_dupl_add_) + p%ac%m = ntaggr + p%ac%k = ntaggr + p%ac%infoa(psb_nnz_) = nzac + p%ac%fida='COO' + p%ac%descra='GUN' + call psb_spcnv(p%ac,info,afmt='coo',dupl=psb_dupl_add_) if(info /= 0) then call psb_errpush(4010,name,a_err='spcnv') goto 9999 @@ -651,12 +642,27 @@ subroutine mld_zaggrmat_smth_asb(a,desc_a,ac,desc_ac,p,info) end select - call psb_spcnv(ac,info,afmt='csr',dupl=psb_dupl_add_) + call psb_spcnv(p%ac,info,afmt='csr',dupl=psb_dupl_add_) if(info /= 0) then call psb_errpush(4010,name,a_err='spcnv') goto 9999 end if + ! + ! Copy the prolongation/restriction matrices into the descriptor map. + ! am2 => PR^T i.e. restriction operator + ! am1 => PR i.e. prolongation operator + ! + p%map_desc = psb_inter_desc(psb_map_aggr_,desc_a,& + & p%desc_ac,am2,am1) + if (info == 0) call psb_sp_free(am1,info) + if (info == 0) call psb_sp_free(am2,info) + if(info /= 0) then + call psb_errpush(4010,name,a_err='sp_Free') + goto 9999 + end if + + if (debug_level >= psb_debug_outer_) & & write(debug_unit,*) me,' ',trim(name),& & 'Done smooth_aggregate ' diff --git a/mlprec/mld_zbaseprec_bld.f90 b/mlprec/mld_zbaseprec_bld.f90 index fe04713d..c325babe 100644 --- a/mlprec/mld_zbaseprec_bld.f90 +++ b/mlprec/mld_zbaseprec_bld.f90 @@ -197,8 +197,6 @@ subroutine mld_zbaseprc_bld(a,desc_a,p,info,upd) end select - p%base_a => a - p%base_desc => desc_a p%iprcparm(mld_prec_status_) = mld_prec_built_ if (debug_level >= psb_debug_outer_) & & write(debug_unit,*) me,' ',trim(name),': Done' diff --git a/mlprec/mld_zmlprec_aply.f90 b/mlprec/mld_zmlprec_aply.f90 index fab02659..6e4f9e47 100644 --- a/mlprec/mld_zmlprec_aply.f90 +++ b/mlprec/mld_zmlprec_aply.f90 @@ -46,7 +46,7 @@ ! Y = beta*Y + alpha*op(M^(-1))*X, ! where ! - M is a multilevel domain decomposition (Schwarz) preconditioner associated -! to a certain matrix A and stored in the array baseprecv, +! to a certain matrix A and stored in the array precv, ! - op(M^(-1)) is M^(-1) or its transpose, according to the value of trans, ! - X and Y are vectors, ! - alpha and beta are scalars. @@ -55,9 +55,9 @@ ! level where we might have a replicated index space) and each process takes care ! of one submatrix. ! -! The multilevel preconditioner M is regarded as an array of 'base preconditioners', +! The multilevel preconditioner M is regarded as an array of 'one-level preconditioners', ! each representing the part of the preconditioner associated to a certain level. -! For each level ilev, the base preconditioner K(ilev) is stored in baseprecv(ilev) +! For each level ilev, the preconditioner K(ilev) is stored in precv(ilev) ! and is associated to a matrix A(ilev), obtained by 'tranferring' the original ! matrix A (i.e. the matrix to be preconditioned) to the level ilev, through smoothed ! aggregation. @@ -78,66 +78,43 @@ ! Arguments: ! alpha - complex(psb_dpk_), input. ! The scalar alpha. -! baseprecv - type(mld_zbaseprc_type), dimension(:), input. -! The array of base preconditioner data structures containing the +! precv - type(mld_z_onelev_prec_type), dimension(:), input. +! The array of one-level preconditioner data structures containing the ! local parts of the preconditioners to be applied at each level. -! Note that nlev = size(baseprecv) = number of levels. -! baseprecv(ilev)%av - type(psb_zspmat_type), dimension(:), allocatable(:). -! The sparse matrices needed to apply the preconditioner -! at level ilev. -! baseprecv(ilev)%av(mld_l_pr_) - The L factor of the ILU factorization of the -! local diagonal block of A(ilev). -! baseprecv(ilev)%av(mld_u_pr_) - The U factor of the ILU factorization of the -! local diagonal block of A(ilev), except its -! diagonal entries (stored in baseprecv(ilev)%d). -! baseprecv(ilev)%av(mld_ap_nd_) - The entries of the local part of A(ilev) -! outside the diagonal block, for block-Jacobi -! sweeps. -! baseprecv(ilev)%av(mld_ac_) - The local part of the matrix A(ilev). -! baseprecv(ilev)%av(mld_sm_pr_) - The smoothed prolongator. -! It maps vectors (ilev) ---> (ilev-1). -! baseprecv(ilev)%av(mld_sm_pr_t_) - The smoothed prolongator transpose. -! It maps vectors (ilev-1) ---> (ilev). -! baseprecv(ilev)%d - complex(psb_dpk_), dimension(:), allocatable. -! The diagonal entries of the U factor in the ILU -! factorization of A(ilev). -! baseprecv(ilev)%desc_data - type(psb_desc_type). -! The communication descriptor associated to the base -! preconditioner, i.e. to the sparse matrices needed -! to apply the base preconditioner at the current level. -! baseprecv(ilev)%desc_ac - type(psb_desc_type). -! The communication descriptor associated to the sparse -! matrix A(ilev), stored in baseprecv(ilev)%av(mld_ac_). -! baseprecv(ilev)%iprcparm - integer, dimension(:), allocatable. -! The integer parameters defining the base -! preconditioner K(ilev). -! baseprecv(ilev)%rprcparm - complex(psb_dpk_), dimension(:), allocatable. -! The real parameters defining the base preconditioner -! K(ilev). -! baseprecv(ilev)%perm - integer, dimension(:), allocatable. -! The row and column permutations applied to the local -! part of A(ilev) (defined only if baseprecv(ilev)% -! iprcparm(mld_sub_ren_)>0). -! baseprecv(ilev)%invperm - integer, dimension(:), allocatable. -! The inverse of the permutation stored in -! baseprecv(ilev)%perm. -! baseprecv(ilev)%mlia - integer, dimension(:), allocatable. -! The aggregation map (ilev-1) --> (ilev). -! In case of non-smoothed aggregation, it is used -! instead of mld_sm_pr_. -! baseprecv(ilev)%nlaggr - integer, dimension(:), allocatable. -! The number of aggregates (rows of A(ilev)) on the -! various processes. -! baseprecv(ilev)%base_a - type(psb_zspmat_type), pointer. -! Pointer (really a pointer!) to the base matrix of -! the current level, i.e. the local part of A(ilev); -! so we have a unified treatment of residuals. We -! need this to avoid passing explicitly the matrix -! A(ilev) to the routine which applies the -! preconditioner. -! baseprecv(ilev)%base_desc - type(psb_desc_type), pointer. -! Pointer to the communication descriptor associated -! to the sparse matrix pointed by base_a. +! Note that nlev = size(precv) = number of levels. +! precv(ilev)%prec - type(psb_zbaseprc_type) +! The "base" preconditioner for the current level +! precv(ilev)%ac - type(psb_zspmat_type) +! The local part of the matrix A(ilev). +! precv(ilev)%desc_ac - type(psb_desc_type). +! The communication descriptor associated to the sparse +! matrix A(ilev) +! precv(ilev)%map_desc - type(psb_inter_desc_type) +! Stores the linear operators mapping between levels +! (ilev-1) and (ilev). These are the restriction and +! prolongation operators described in the sequel. +! precv(ilev)%iprcparm - integer, dimension(:), allocatable. +! The integer parameters defining the multilevel +! strategy +! precv(ilev)%rprcparm - real(psb_dpk_), dimension(:), allocatable. +! The real parameters defining the multilevel strategy +! precv(ilev)%mlia - integer, dimension(:), allocatable. +! The aggregation map (ilev-1) --> (ilev). +! In case of non-smoothed aggregation, it is used +! instead of mld_sm_pr_. +! precv(ilev)%nlaggr - integer, dimension(:), allocatable. +! The number of aggregates (rows of A(ilev)) on the +! various processes. +! precv(ilev)%base_a - type(psb_zspmat_type), pointer. +! Pointer (really a pointer!) to the base matrix of +! the current level, i.e. the local part of A(ilev); +! so we have a unified treatment of residuals. We +! need this to avoid passing explicitly the matrix +! A(ilev) to the routine which applies the +! preconditioner. +! precv(ilev)%base_desc - type(psb_desc_type), pointer. +! Pointer to the communication descriptor associated +! to the sparse matrix pointed by base_a. ! ! x - complex(psb_dpk_), dimension(:), input. ! The local part of the vector X. @@ -159,10 +136,10 @@ ! Note that when the LU factorization of the matrix A(ilev) is computed instead of ! the ILU one, by using UMFPACK or SuperLU, the corresponding L and U factors ! are stored in data structures provided by UMFPACK or SuperLU and pointed by -! baseprecv(ilev)%iprcparm(mld_umf_ptr) or baseprecv(ilev)%iprcparm(mld_slu_ptr), +! precv(ilev)%prec%iprcparm(mld_umf_ptr) or precv(ilev)%prec%iprcparm(mld_slu_ptr), ! respectively. ! -subroutine mld_zmlprec_aply(alpha,baseprecv,x,beta,y,desc_data,trans,work,info) +subroutine mld_zmlprec_aply(alpha,precv,x,beta,y,desc_data,trans,work,info) use psb_base_mod use mld_inner_mod, mld_protect_name => mld_zmlprec_aply @@ -171,7 +148,7 @@ subroutine mld_zmlprec_aply(alpha,baseprecv,x,beta,y,desc_data,trans,work,info) ! Arguments type(psb_desc_type),intent(in) :: desc_data - type(mld_zbaseprc_type), intent(in) :: baseprecv(:) + type(mld_z_onelev_prec_type), intent(in) :: precv(:) complex(psb_dpk_),intent(in) :: alpha,beta complex(psb_dpk_),intent(in) :: x(:) complex(psb_dpk_),intent(inout) :: y(:) @@ -196,11 +173,11 @@ subroutine mld_zmlprec_aply(alpha,baseprecv,x,beta,y,desc_data,trans,work,info) if (debug_level >= psb_debug_inner_) & & write(debug_unit,*) me,' ',trim(name),& - & ' Entry ', size(baseprecv) + & ' Entry ', size(precv) trans_ = psb_toupper(trans) - select case(baseprecv(2)%iprcparm(mld_ml_type_)) + select case(precv(2)%iprcparm(mld_ml_type_)) case(mld_no_ml_) ! @@ -214,7 +191,7 @@ subroutine mld_zmlprec_aply(alpha,baseprecv,x,beta,y,desc_data,trans,work,info) ! Additive multilevel ! - call add_ml_aply(alpha,baseprecv,x,beta,y,desc_data,trans_,work,info) + call add_ml_aply(alpha,precv,x,beta,y,desc_data,trans_,work,info) case(mld_mult_ml_) ! @@ -225,15 +202,15 @@ subroutine mld_zmlprec_aply(alpha,baseprecv,x,beta,y,desc_data,trans,work,info) ! Note that the transpose switches pre <-> post. ! - select case(baseprecv(2)%iprcparm(mld_smoother_pos_)) + select case(precv(2)%iprcparm(mld_smoother_pos_)) case(mld_post_smooth_) select case (trans_) case('N') - call mlt_post_ml_aply(alpha,baseprecv,x,beta,y,desc_data,trans_,work,info) + call mlt_post_ml_aply(alpha,precv,x,beta,y,desc_data,trans_,work,info) case('T','C') - call mlt_pre_ml_aply(alpha,baseprecv,x,beta,y,desc_data,trans_,work,info) + call mlt_pre_ml_aply(alpha,precv,x,beta,y,desc_data,trans_,work,info) case default info = 4001 call psb_errpush(info,name,a_err='invalid trans') @@ -244,9 +221,9 @@ subroutine mld_zmlprec_aply(alpha,baseprecv,x,beta,y,desc_data,trans,work,info) select case (trans_) case('N') - call mlt_pre_ml_aply(alpha,baseprecv,x,beta,y,desc_data,trans_,work,info) + call mlt_pre_ml_aply(alpha,precv,x,beta,y,desc_data,trans_,work,info) case('T','C') - call mlt_post_ml_aply(alpha,baseprecv,x,beta,y,desc_data,trans_,work,info) + call mlt_post_ml_aply(alpha,precv,x,beta,y,desc_data,trans_,work,info) case default info = 4001 call psb_errpush(info,name,a_err='invalid trans') @@ -255,12 +232,12 @@ subroutine mld_zmlprec_aply(alpha,baseprecv,x,beta,y,desc_data,trans,work,info) case(mld_twoside_smooth_) - call mlt_twoside_ml_aply(alpha,baseprecv,x,beta,y,desc_data,trans_,work,info) + call mlt_twoside_ml_aply(alpha,precv,x,beta,y,desc_data,trans_,work,info) case default info = 4013 call psb_errpush(info,name,a_err='invalid smooth_pos',& - & i_Err=(/baseprecv(2)%iprcparm(mld_smoother_pos_),0,0,0,0/)) + & i_Err=(/precv(2)%iprcparm(mld_smoother_pos_),0,0,0,0/)) goto 9999 end select @@ -268,7 +245,7 @@ subroutine mld_zmlprec_aply(alpha,baseprecv,x,beta,y,desc_data,trans,work,info) case default info = 4013 call psb_errpush(info,name,a_err='invalid mltype',& - & i_Err=(/baseprecv(2)%iprcparm(mld_ml_type_),0,0,0,0/)) + & i_Err=(/precv(2)%iprcparm(mld_ml_type_),0,0,0,0/)) goto 9999 end select @@ -295,7 +272,7 @@ contains ! Y = beta*Y + alpha*op(M^(-1))*X, ! where ! - M is an additive multilevel domain decomposition (Schwarz) preconditioner - ! associated to a certain matrix A and stored in the array baseprecv, + ! associated to a certain matrix A and stored in the array precv, ! - op(M^(-1)) is M^(-1) or its (conjugate) transpose, according to ! the value of trans, ! - X and Y are vectors, @@ -308,9 +285,9 @@ contains ! level where we might have a replicated index space) and each process takes care ! of one submatrix. ! - ! The multilevel preconditioner M is regarded as an array of 'base preconditioners', + ! The multilevel preconditioner M is regarded as an array of 'one-level preconditioners', ! each representing the part of the preconditioner associated to a certain level. - ! For each level ilev, the base preconditioner K(ilev) is stored in baseprecv(ilev) + ! For each level ilev, the base preconditioner K(ilev) is stored in precv(ilev) ! and is associated to a matrix A(ilev), obtained by 'tranferring' the original ! matrix A (i.e. the matrix to be preconditioned) to the level ilev, through smoothed ! aggregation. @@ -324,7 +301,7 @@ contains ! Domain decomposition: parallel multilevel methods for elliptic partial ! differential equations, Cambridge University Press, 1996. ! - ! For a description of the arguments see mld_dmlprec_aply. + ! For a description of the arguments see mld_zmlprec_aply. ! ! A sketch of the algorithm implemented in this routine is provided below ! (AV(ilev; sm_pr_) denotes the smoothed prolongator from level ilev to @@ -358,13 +335,13 @@ contains ! ! 4. Yext = beta*Yext + alpha*Y(1) ! - subroutine add_ml_aply(alpha,baseprecv,x,beta,y,desc_data,trans,work,info) + subroutine add_ml_aply(alpha,precv,x,beta,y,desc_data,trans,work,info) implicit none ! Arguments type(psb_desc_type),intent(in) :: desc_data - type(mld_zbaseprc_type), intent(in) :: baseprecv(:) + type(mld_z_onelev_prec_type), intent(in) :: precv(:) complex(psb_dpk_),intent(in) :: alpha,beta complex(psb_dpk_),intent(in) :: x(:) complex(psb_dpk_),intent(inout) :: y(:) @@ -373,10 +350,9 @@ contains integer, intent(out) :: info ! Local variables - integer :: n_row,n_col integer :: ictxt,np,me,i, nr2l,nc2l,err_act integer :: debug_level, debug_unit - integer :: ismth, nlev, ilev, icm + integer :: nlev, ilev character(len=20) :: name type psb_mlprec_wrk_type @@ -395,9 +371,9 @@ contains if (debug_level >= psb_debug_inner_) & & write(debug_unit,*) me,' ',trim(name),& - & ' Entry ', size(baseprecv) + & ' Entry ', size(precv) - nlev = size(baseprecv) + nlev = size(precv) allocate(mlprec_wrk(nlev),stat=info) if (info /= 0) then call psb_errpush(4010,name,a_err='Allocate') @@ -420,9 +396,8 @@ contains mlprec_wrk(1)%x2l(:) = x(:) mlprec_wrk(1)%y2l(:) = zzero - - call mld_baseprec_aply(alpha,baseprecv(1),x,beta,y,& - & baseprecv(1)%base_desc,trans,work,info) + call mld_baseprec_aply(alpha,precv(1)%prec,x,beta,y,& + & precv(1)%base_desc,trans,work,info) if (info /=0) then call psb_errpush(4010,name,a_err='baseprec_aply') goto 9999 @@ -433,49 +408,33 @@ contains ! For each level except the finest one ... ! do ilev = 2, nlev - n_row = psb_cd_get_local_rows(baseprecv(ilev-1)%base_desc) - n_col = psb_cd_get_local_cols(baseprecv(ilev-1)%base_desc) - nc2l = psb_cd_get_local_cols(baseprecv(ilev)%base_desc) - nr2l = psb_cd_get_local_rows(baseprecv(ilev)%base_desc) + nc2l = psb_cd_get_local_cols(precv(ilev)%base_desc) + nr2l = psb_cd_get_local_rows(precv(ilev)%base_desc) allocate(mlprec_wrk(ilev)%x2l(nc2l),mlprec_wrk(ilev)%y2l(nc2l),& & stat=info) if (info /= 0) then info=4025 - call psb_errpush(info,name,i_err=(/2*(nc2l+max(n_row,n_col)),0,0,0,0/),& + call psb_errpush(info,name,i_err=(/2*nc2l,0,0,0,0/),& & a_err='complex(psb_dpk_)') goto 9999 end if - - ismth = baseprecv(ilev)%iprcparm(mld_aggr_kind_) - icm = baseprecv(ilev)%iprcparm(mld_coarse_mat_) ! Apply prolongator transpose, i.e. restriction call psb_forward_map(zone,mlprec_wrk(ilev-1)%x2l,& & zzero,mlprec_wrk(ilev)%x2l,& - & baseprecv(ilev)%map_desc,info,work=work) - + & precv(ilev)%map_desc,info,work=work) if (info /=0) then call psb_errpush(4001,name,a_err='Error during restriction') goto 9999 end if - - if (icm == mld_repl_mat_) then - call psb_sum(ictxt,mlprec_wrk(ilev)%x2l(1:nr2l)) - else if (icm /= mld_distr_mat_) then - info = 4013 - call psb_errpush(info,name,a_err='invalid mld_coarse_mat_',& - & i_Err=(/icm,0,0,0,0/)) - goto 9999 - endif - ! ! Apply the base preconditioner ! - call mld_baseprec_aply(zone,baseprecv(ilev),& + call mld_baseprec_aply(zone,precv(ilev)%prec,& & mlprec_wrk(ilev)%x2l,zzero,mlprec_wrk(ilev)%y2l,& - & baseprecv(ilev)%base_desc,trans,work,info) + & precv(ilev)%base_desc,trans,work,info) enddo @@ -486,19 +445,15 @@ contains ! do ilev =nlev,2,-1 - n_row = psb_cd_get_local_rows(baseprecv(ilev-1)%base_desc) - n_col = psb_cd_get_local_cols(baseprecv(ilev-1)%base_desc) - nc2l = psb_cd_get_local_cols(baseprecv(ilev)%base_desc) - nr2l = psb_cd_get_local_rows(baseprecv(ilev)%base_desc) - ismth = baseprecv(ilev)%iprcparm(mld_aggr_kind_) - icm = baseprecv(ilev)%iprcparm(mld_coarse_mat_) + nc2l = psb_cd_get_local_cols(precv(ilev)%base_desc) + nr2l = psb_cd_get_local_rows(precv(ilev)%base_desc) ! ! Apply prolongator ! call psb_backward_map(zone,mlprec_wrk(ilev)%y2l,& & zone,mlprec_wrk(ilev-1)%y2l,& - & baseprecv(ilev)%map_desc,info,work=work) + & precv(ilev)%map_desc,info,work=work) if (info /=0) then call psb_errpush(4001,name,a_err='Error during prolongation') @@ -511,7 +466,7 @@ contains ! ! Compute the output vector Y ! - call psb_geaxpby(alpha,mlprec_wrk(1)%y2l,zone,y,baseprecv(1)%base_desc,info) + call psb_geaxpby(alpha,mlprec_wrk(1)%y2l,zone,y,precv(1)%base_desc,info) if (info /= 0) then call psb_errpush(4001,name,a_err='Error on final update') goto 9999 @@ -538,14 +493,14 @@ contains ! ! Subroutine: mlt_pre_ml_aply ! Version: complex - ! Note: internal subroutine of mld_dmlprec_aply. + ! Note: internal subroutine of mld_zmlprec_aply. ! ! This routine computes ! ! Y = beta*Y + alpha*op(M^(-1))*X, ! where ! - M is a hybrid multilevel domain decomposition (Schwarz) preconditioner - ! associated to a certain matrix A and stored in the array baseprecv, + ! associated to a certain matrix A and stored in the array precv, ! - op(M^(-1)) is M^(-1) or its (conjugate) transpose, according to ! the value of trans, ! - X and Y are vectors, @@ -558,9 +513,9 @@ contains ! level where we might have a replicated index space) and each process takes care ! of one submatrix. ! - ! The multilevel preconditioner M is regarded as an array of 'base preconditioners', + ! The multilevel preconditioner M is regarded as an array of 'one-level preconditioners', ! each representing the part of the preconditioner associated to a certain level. - ! For each level ilev, the base preconditioner K(ilev) is stored in baseprecv(ilev) + ! For each level ilev, the base preconditioner K(ilev) is stored in precv(ilev) ! and is associated to a matrix A(ilev), obtained by 'tranferring' the original ! matrix A (i.e. the matrix to be preconditioned) to the level ilev, through smoothed ! aggregation. @@ -574,7 +529,7 @@ contains ! Domain decomposition: parallel multilevel methods for elliptic partial ! differential equations, Cambridge University Press, 1996. ! - ! For a description of the arguments see mld_dmlprec_aply. + ! For a description of the arguments see mld_zmlprec_aply. ! ! A sketch of the algorithm implemented in this routine is provided below ! (AV(ilev; sm_pr_) denotes the smoothed prolongator from level ilev to @@ -616,13 +571,13 @@ contains ! 6. Yext = beta*Yext + alpha*Y(1) ! ! - subroutine mlt_pre_ml_aply(alpha,baseprecv,x,beta,y,desc_data,trans,work,info) + subroutine mlt_pre_ml_aply(alpha,precv,x,beta,y,desc_data,trans,work,info) implicit none ! Arguments type(psb_desc_type),intent(in) :: desc_data - type(mld_zbaseprc_type), intent(in) :: baseprecv(:) + type(mld_z_onelev_prec_type), intent(in) :: precv(:) complex(psb_dpk_),intent(in) :: alpha,beta complex(psb_dpk_),intent(in) :: x(:) complex(psb_dpk_),intent(inout) :: y(:) @@ -631,10 +586,9 @@ contains integer, intent(out) :: info ! Local variables - integer :: n_row,n_col integer :: ictxt,np,me,i, nr2l,nc2l,err_act integer :: debug_level, debug_unit - integer :: ismth, nlev, ilev, icm + integer :: nlev, ilev character(len=20) :: name type psb_mlprec_wrk_type @@ -653,9 +607,9 @@ contains if (debug_level >= psb_debug_inner_) & & write(debug_unit,*) me,' ',trim(name),& - & ' Entry ', size(baseprecv) + & ' Entry ', size(precv) - nlev = size(baseprecv) + nlev = size(precv) allocate(mlprec_wrk(nlev),stat=info) if (info /= 0) then call psb_errpush(4010,name,a_err='Allocate') @@ -667,8 +621,7 @@ contains ! ! Copy the input vector X ! - n_col = psb_cd_get_local_cols(desc_data) - nc2l = psb_cd_get_local_cols(baseprecv(1)%base_desc) + nc2l = psb_cd_get_local_cols(precv(1)%base_desc) allocate(mlprec_wrk(1)%x2l(nc2l),mlprec_wrk(1)%y2l(nc2l), & & mlprec_wrk(1)%tx(nc2l), stat=info) @@ -685,8 +638,8 @@ contains ! ! Apply the base preconditioner at the finest level ! - call mld_baseprec_aply(zone,baseprecv(1),mlprec_wrk(1)%x2l,& - & zzero,mlprec_wrk(1)%y2l,baseprecv(1)%base_desc,& + call mld_baseprec_aply(zone,precv(1)%prec,mlprec_wrk(1)%x2l,& + & zzero,mlprec_wrk(1)%y2l,precv(1)%base_desc,& & trans,work,info) if (info /=0) then call psb_errpush(4010,name,a_err=' baseprec_aply') @@ -700,8 +653,8 @@ contains ! mlprec_wrk(1)%tx = mlprec_wrk(1)%x2l - call psb_spmm(-zone,baseprecv(1)%base_a,mlprec_wrk(1)%y2l,& - & zone,mlprec_wrk(1)%tx,baseprecv(1)%base_desc,info,& + call psb_spmm(-zone,precv(1)%base_a,mlprec_wrk(1)%y2l,& + & zone,mlprec_wrk(1)%tx,precv(1)%base_desc,info,& & work=work,trans=trans) if (info /=0) then call psb_errpush(4001,name,a_err=' fine level residual') @@ -715,12 +668,8 @@ contains ! do ilev = 2, nlev - n_row = psb_cd_get_local_rows(baseprecv(ilev-1)%base_desc) - n_col = psb_cd_get_local_cols(baseprecv(ilev-1)%base_desc) - nc2l = psb_cd_get_local_cols(baseprecv(ilev)%base_desc) - nr2l = psb_cd_get_local_rows(baseprecv(ilev)%base_desc) - ismth = baseprecv(ilev)%iprcparm(mld_aggr_kind_) - icm = baseprecv(ilev)%iprcparm(mld_coarse_mat_) + nc2l = psb_cd_get_local_cols(precv(ilev)%base_desc) + nr2l = psb_cd_get_local_rows(precv(ilev)%base_desc) allocate(mlprec_wrk(ilev)%tx(nc2l),mlprec_wrk(ilev)%y2l(nc2l),& & mlprec_wrk(ilev)%x2l(nc2l), stat=info) @@ -734,7 +683,7 @@ contains ! Apply prolongator transpose, i.e. restriction call psb_forward_map(zone,mlprec_wrk(ilev-1)%tx,& & zzero,mlprec_wrk(ilev)%x2l,& - & baseprecv(ilev)%map_desc,info,work=work) + & precv(ilev)%map_desc,info,work=work) if (info /=0) then call psb_errpush(4001,name,a_err='Error during restriction') @@ -744,17 +693,17 @@ contains ! ! Apply the base preconditioner ! - call mld_baseprec_aply(zone,baseprecv(ilev),mlprec_wrk(ilev)%x2l,& - & zzero,mlprec_wrk(ilev)%y2l,baseprecv(ilev)%base_desc,trans,work,info) + call mld_baseprec_aply(zone,precv(ilev)%prec,mlprec_wrk(ilev)%x2l,& + & zzero,mlprec_wrk(ilev)%y2l,precv(ilev)%base_desc,trans,work,info) ! ! Compute the residual (at all levels but the coarsest one) ! if (ilev < nlev) then mlprec_wrk(ilev)%tx = mlprec_wrk(ilev)%x2l - if (info == 0) call psb_spmm(-zone,baseprecv(ilev)%base_a,& + if (info == 0) call psb_spmm(-zone,precv(ilev)%base_a,& & mlprec_wrk(ilev)%y2l,zone,mlprec_wrk(ilev)%tx,& - & baseprecv(ilev)%base_desc,info,work=work,trans=trans) + & precv(ilev)%base_desc,info,work=work,trans=trans) endif if (info /=0) then call psb_errpush(4001,name,a_err='Error on up sweep residual') @@ -768,16 +717,12 @@ contains ! For each level but the coarsest one ... ! do ilev = nlev-1, 1, -1 - - ismth = baseprecv(ilev+1)%iprcparm(mld_aggr_kind_) - n_row = psb_cd_get_local_rows(baseprecv(ilev)%base_desc) - ! ! Apply prolongator ! call psb_backward_map(zone,mlprec_wrk(ilev+1)%y2l,& & zone,mlprec_wrk(ilev)%y2l,& - & baseprecv(ilev+1)%map_desc,info,work=work) + & precv(ilev+1)%map_desc,info,work=work) if (info /=0) then call psb_errpush(4001,name,a_err='Error during prolongation') @@ -791,7 +736,7 @@ contains ! Compute the output vector Y ! call psb_geaxpby(alpha,mlprec_wrk(1)%y2l,beta,y,& - & baseprecv(1)%base_desc,info) + & precv(1)%base_desc,info) if (info /=0) then call psb_errpush(4001,name,a_err='Error on final update') goto 9999 @@ -817,14 +762,14 @@ contains ! ! Subroutine: mlt_post_ml_aply ! Version: complex - ! Note: internal subroutine of mld_dmlprec_aply. + ! Note: internal subroutine of mld_zmlprec_aply. ! ! This routine computes ! ! Y = beta*Y + alpha*op(M^(-1))*X, ! where ! - M is a hybrid multilevel domain decomposition (Schwarz) preconditioner - ! associated to a certain matrix A and stored in the array baseprecv, + ! associated to a certain matrix A and stored in the array precv, ! - op(M^(-1)) is M^(-1) or its (conjugate) transpose, according to ! the value of trans, ! - X and Y are vectors, @@ -837,9 +782,9 @@ contains ! level where we might have a replicated index space) and each process takes care ! of one submatrix. ! - ! The multilevel preconditioner M is regarded as an array of 'base preconditioners', + ! The multilevel preconditioner M is regarded as an array of 'one-level preconditioners', ! each representing the part of the preconditioner associated to a certain level. - ! For each level ilev, the base preconditioner K(ilev) is stored in baseprecv(ilev) + ! For each level ilev, the base preconditioner K(ilev) is stored in precv(ilev) ! and is associated to a matrix A(ilev), obtained by 'tranferring' the original ! matrix A (i.e. the matrix to be preconditioned) to the level ilev, through smoothed ! aggregation. @@ -852,7 +797,7 @@ contains ! Domain decomposition: parallel multilevel methods for elliptic partial ! differential equations, Cambridge University Press, 1996. ! - ! For a description of the arguments see mld_dmlprec_aply. + ! For a description of the arguments see mld_zmlprec_aply. ! ! A sketch of the algorithm implemented in this routine is provided below. ! (AV(ilev; sm_pr_) denotes the smoothed prolongator from level ilev to @@ -886,13 +831,13 @@ contains ! 5. Yext = beta*Yext + alpha*Y(1) ! ! - subroutine mlt_post_ml_aply(alpha,baseprecv,x,beta,y,desc_data,trans,work,info) + subroutine mlt_post_ml_aply(alpha,precv,x,beta,y,desc_data,trans,work,info) implicit none ! Arguments type(psb_desc_type),intent(in) :: desc_data - type(mld_zbaseprc_type), intent(in) :: baseprecv(:) + type(mld_z_onelev_prec_type), intent(in) :: precv(:) complex(psb_dpk_),intent(in) :: alpha,beta complex(psb_dpk_),intent(in) :: x(:) complex(psb_dpk_),intent(inout) :: y(:) @@ -901,10 +846,9 @@ contains integer, intent(out) :: info ! Local variables - integer :: n_row,n_col integer :: ictxt,np,me,i, nr2l,nc2l,err_act integer :: debug_level, debug_unit - integer :: ismth, nlev, ilev, icm + integer :: nlev, ilev character(len=20) :: name type psb_mlprec_wrk_type @@ -923,9 +867,9 @@ contains if (debug_level >= psb_debug_inner_) & & write(debug_unit,*) me,' ',trim(name),& - & ' Entry ', size(baseprecv) + & ' Entry ', size(precv) - nlev = size(baseprecv) + nlev = size(precv) allocate(mlprec_wrk(nlev),stat=info) if (info /= 0) then call psb_errpush(4010,name,a_err='Allocate') @@ -941,16 +885,21 @@ contains & write(debug_unit,*) me,' ',trim(name),& & ' desc_data status',allocated(desc_data%matrix_data) - n_col = psb_cd_get_local_cols(desc_data) - nc2l = psb_cd_get_local_cols(baseprecv(1)%base_desc) + nc2l = psb_cd_get_local_cols(precv(1)%base_desc) allocate(mlprec_wrk(1)%x2l(nc2l),mlprec_wrk(1)%y2l(nc2l), & & mlprec_wrk(1)%tx(nc2l), stat=info) + if (info /= 0) then + info=4025 + call psb_errpush(info,name,i_err=(/4*nc2l,0,0,0,0/),& + & a_err='complex(psb_dpk_)') + goto 9999 + end if call psb_geaxpby(zone,x,zzero,mlprec_wrk(1)%tx,& - & baseprecv(1)%base_desc,info) + & precv(1)%base_desc,info) call psb_geaxpby(zone,x,zzero,mlprec_wrk(1)%x2l,& - & baseprecv(1)%base_desc,info) + & precv(1)%base_desc,info) ! ! STEP 2 @@ -959,18 +908,13 @@ contains ! do ilev=2, nlev - n_row = psb_cd_get_local_rows(baseprecv(ilev-1)%base_desc) - n_col = psb_cd_get_local_cols(baseprecv(ilev-1)%base_desc) - nc2l = psb_cd_get_local_cols(baseprecv(ilev)%base_desc) - nr2l = psb_cd_get_local_rows(baseprecv(ilev)%base_desc) - ismth = baseprecv(ilev)%iprcparm(mld_aggr_kind_) - icm = baseprecv(ilev)%iprcparm(mld_coarse_mat_) + nc2l = psb_cd_get_local_cols(precv(ilev)%base_desc) + nr2l = psb_cd_get_local_rows(precv(ilev)%base_desc) if (debug_level >= psb_debug_inner_) & & write(debug_unit,*) me,' ',trim(name), & & ' starting up sweep ',& - & ilev,allocated(baseprecv(ilev)%iprcparm),n_row,n_col,& - & nc2l, nr2l,ismth + & ilev,allocated(precv(ilev)%iprcparm),nc2l, nr2l allocate(mlprec_wrk(ilev)%tx(nc2l),mlprec_wrk(ilev)%y2l(nc2l),& & mlprec_wrk(ilev)%x2l(nc2l), stat=info) @@ -985,7 +929,7 @@ contains ! Apply prolongator transpose, i.e. restriction call psb_forward_map(zone,mlprec_wrk(ilev-1)%x2l,& & zzero,mlprec_wrk(ilev)%x2l,& - & baseprecv(ilev)%map_desc,info,work=work) + & precv(ilev)%map_desc,info,work=work) if (info /=0) then call psb_errpush(4001,name,a_err='Error during restriction') @@ -996,7 +940,7 @@ contains ! update x2l ! call psb_geaxpby(zone,mlprec_wrk(ilev)%x2l,zzero,mlprec_wrk(ilev)%tx,& - & baseprecv(ilev)%base_desc,info) + & precv(ilev)%base_desc,info) if (info /= 0) then call psb_errpush(4001,name,a_err='Error in update') goto 9999 @@ -1013,8 +957,8 @@ contains ! ! Apply the base preconditioner at the coarsest level ! - call mld_baseprec_aply(zone,baseprecv(nlev),mlprec_wrk(nlev)%x2l, & - & zzero, mlprec_wrk(nlev)%y2l,baseprecv(nlev)%base_desc,trans,work,info) + call mld_baseprec_aply(zone,precv(nlev)%prec,mlprec_wrk(nlev)%x2l, & + & zzero, mlprec_wrk(nlev)%y2l,precv(nlev)%base_desc,trans,work,info) if (info /=0) then call psb_errpush(4010,name,a_err='baseprec_aply') goto 9999 @@ -1034,15 +978,12 @@ contains & write(debug_unit,*) me,' ',trim(name),& & ' starting down sweep',ilev - ismth = baseprecv(ilev+1)%iprcparm(mld_aggr_kind_) - n_row = psb_cd_get_local_rows(baseprecv(ilev)%base_desc) - ! ! Apply prolongator ! call psb_backward_map(zone,mlprec_wrk(ilev+1)%y2l,& & zzero,mlprec_wrk(ilev)%y2l,& - & baseprecv(ilev+1)%map_desc,info,work=work) + & precv(ilev+1)%map_desc,info,work=work) if (info /=0) then call psb_errpush(4001,name,a_err='Error during prolongation') @@ -1052,15 +993,16 @@ contains ! ! Compute the residual ! - call psb_spmm(-zone,baseprecv(ilev)%base_a,mlprec_wrk(ilev)%y2l,& - & zone,mlprec_wrk(ilev)%tx,baseprecv(ilev)%base_desc,info,& + call psb_spmm(-zone,precv(ilev)%base_a,mlprec_wrk(ilev)%y2l,& + & zone,mlprec_wrk(ilev)%tx,precv(ilev)%base_desc,info,& & work=work,trans=trans) ! ! Apply the base preconditioner ! - if (info == 0) call mld_baseprec_aply(zone,baseprecv(ilev),mlprec_wrk(ilev)%tx,& - & zone,mlprec_wrk(ilev)%y2l,baseprecv(ilev)%base_desc,trans,work,info) + if (info == 0) call mld_baseprec_aply(zone,precv(ilev)%prec,& + & mlprec_wrk(ilev)%tx,zone,mlprec_wrk(ilev)%y2l,precv(ilev)%base_desc,& + &trans,work,info) if (info /=0) then call psb_errpush(4001,name,a_err=' spmm/baseprec_aply') goto 9999 @@ -1076,7 +1018,7 @@ contains ! ! Compute the output vector Y ! - call psb_geaxpby(alpha,mlprec_wrk(1)%y2l,beta,y,baseprecv(1)%base_desc,info) + call psb_geaxpby(alpha,mlprec_wrk(1)%y2l,beta,y,precv(1)%base_desc,info) if (info /=0) then call psb_errpush(4001,name,a_err=' Final update') @@ -1105,7 +1047,7 @@ contains ! ! Subroutine: mlt_twoside_ml_aply ! Version: complex - ! Note: internal subroutine of mld_dmlprec_aply. + ! Note: internal subroutine of mld_zmlprec_aply. ! ! This routine computes ! @@ -1113,7 +1055,7 @@ contains ! where ! - M is a symmetrized hybrid multilevel domain decomposition (Schwarz) ! preconditioner associated to a certain matrix A and stored in the array - ! baseprecv, + ! precv, ! - op(M^(-1)) is M^(-1) or its (conjugate) transpose, according to ! the value of trans, ! - X and Y are vectors, @@ -1127,9 +1069,9 @@ contains ! level where we might have a replicated index space) and each process takes care ! of one submatrix. ! - ! The multilevel preconditioner M is regarded as an array of 'base preconditioners', + ! The multilevel preconditioner M is regarded as an array of 'one-level preconditioners', ! each representing the part of the preconditioner associated to a certain level. - ! For each level ilev, the base preconditioner K(ilev) is stored in baseprecv(ilev) + ! For each level ilev, the base preconditioner K(ilev) is stored in precv(ilev) ! and is associated to a matrix A(ilev), obtained by 'tranferring' the original ! matrix A (i.e. the matrix to be preconditioned) to the level ilev, through smoothed ! aggregation. @@ -1143,7 +1085,7 @@ contains ! Domain decomposition: parallel multilevel methods for elliptic partial ! differential equations, Cambridge University Press, 1996. ! - ! For a description of the arguments see mld_dmlprec_aply. + ! For a description of the arguments see mld_zmlprec_aply. ! ! A sketch of the algorithm implemented in this routine is provided below. ! (AV(ilev; sm_pr_) denotes the smoothed prolongator from level ilev to @@ -1187,13 +1129,13 @@ contains ! ! 6. Yext = beta*Yext + alpha*Y(1) ! - subroutine mlt_twoside_ml_aply(alpha,baseprecv,x,beta,y,desc_data,trans,work,info) + subroutine mlt_twoside_ml_aply(alpha,precv,x,beta,y,desc_data,trans,work,info) implicit none ! Arguments type(psb_desc_type),intent(in) :: desc_data - type(mld_zbaseprc_type), intent(in) :: baseprecv(:) + type(mld_z_onelev_prec_type), intent(in) :: precv(:) complex(psb_dpk_),intent(in) :: alpha,beta complex(psb_dpk_),intent(in) :: x(:) complex(psb_dpk_),intent(inout) :: y(:) @@ -1202,10 +1144,9 @@ contains integer, intent(out) :: info ! Local variables - integer :: n_row,n_col integer :: ictxt,np,me,i, nr2l,nc2l,err_act integer :: debug_level, debug_unit - integer :: ismth, nlev, ilev, icm + integer :: nlev, ilev character(len=20) :: name type psb_mlprec_wrk_type @@ -1224,9 +1165,9 @@ contains if (debug_level >= psb_debug_inner_) & & write(debug_unit,*) me,' ',trim(name),& - & ' Entry ', size(baseprecv) + & ' Entry ', size(precv) - nlev = size(baseprecv) + nlev = size(precv) allocate(mlprec_wrk(nlev),stat=info) if (info /= 0) then call psb_errpush(4010,name,a_err='Allocate') @@ -1237,8 +1178,7 @@ contains ! ! Copy the input vector X ! - n_col = psb_cd_get_local_cols(desc_data) - nc2l = psb_cd_get_local_cols(baseprecv(1)%base_desc) + nc2l = psb_cd_get_local_cols(precv(1)%base_desc) allocate(mlprec_wrk(1)%x2l(nc2l),mlprec_wrk(1)%y2l(nc2l), & & mlprec_wrk(1)%ty(nc2l), mlprec_wrk(1)%tx(nc2l), stat=info) @@ -1251,17 +1191,17 @@ contains end if call psb_geaxpby(zone,x,zzero,mlprec_wrk(1)%x2l,& - & baseprecv(1)%base_desc,info) + & precv(1)%base_desc,info) call psb_geaxpby(zone,x,zzero,mlprec_wrk(1)%tx,& - & baseprecv(1)%base_desc,info) + & precv(1)%base_desc,info) ! ! STEP 2 ! ! Apply the base preconditioner at the finest level ! - call mld_baseprec_aply(zone,baseprecv(1),mlprec_wrk(1)%x2l,& - & zzero,mlprec_wrk(1)%y2l,baseprecv(1)%base_desc,& + call mld_baseprec_aply(zone,precv(1)%prec,mlprec_wrk(1)%x2l,& + & zzero,mlprec_wrk(1)%y2l,precv(1)%base_desc,& & trans,work,info) ! ! STEP 3 @@ -1269,8 +1209,8 @@ contains ! Compute the residual at the finest level ! mlprec_wrk(1)%ty = mlprec_wrk(1)%x2l - if (info == 0) call psb_spmm(-zone,baseprecv(1)%base_a,mlprec_wrk(1)%y2l,& - & zone,mlprec_wrk(1)%ty,baseprecv(1)%base_desc,info,& + if (info == 0) call psb_spmm(-zone,precv(1)%base_a,mlprec_wrk(1)%y2l,& + & zone,mlprec_wrk(1)%ty,precv(1)%base_desc,info,& & work=work,trans=trans) if (info /=0) then call psb_errpush(4010,name,a_err='Fine level baseprec/residual') @@ -1284,12 +1224,9 @@ contains ! do ilev = 2, nlev - n_row = psb_cd_get_local_rows(baseprecv(ilev-1)%base_desc) - n_col = psb_cd_get_local_cols(baseprecv(ilev-1)%base_desc) - nc2l = psb_cd_get_local_cols(baseprecv(ilev)%base_desc) - nr2l = psb_cd_get_local_rows(baseprecv(ilev)%base_desc) - ismth = baseprecv(ilev)%iprcparm(mld_aggr_kind_) - icm = baseprecv(ilev)%iprcparm(mld_coarse_mat_) + nc2l = psb_cd_get_local_cols(precv(ilev)%base_desc) + nr2l = psb_cd_get_local_rows(precv(ilev)%base_desc) + allocate(mlprec_wrk(ilev)%tx(nc2l),mlprec_wrk(ilev)%ty(nc2l),& & mlprec_wrk(ilev)%y2l(nc2l),mlprec_wrk(ilev)%x2l(nc2l), stat=info) @@ -1303,7 +1240,7 @@ contains ! Apply prolongator transpose, i.e. restriction call psb_forward_map(zone,mlprec_wrk(ilev-1)%ty,& & zzero,mlprec_wrk(ilev)%x2l,& - & baseprecv(ilev)%map_desc,info,work=work) + & precv(ilev)%map_desc,info,work=work) if (info /=0) then call psb_errpush(4001,name,a_err='Error during restriction') @@ -1311,21 +1248,21 @@ contains end if call psb_geaxpby(zone,mlprec_wrk(ilev)%x2l,zzero,mlprec_wrk(ilev)%tx,& - & baseprecv(ilev)%base_desc,info) + & precv(ilev)%base_desc,info) ! ! Apply the base preconditioner ! - if (info == 0) call mld_baseprec_aply(zone,baseprecv(ilev),& + if (info == 0) call mld_baseprec_aply(zone,precv(ilev)%prec,& & mlprec_wrk(ilev)%x2l,zzero,mlprec_wrk(ilev)%y2l,& - &baseprecv(ilev)%base_desc,trans,work,info) + &precv(ilev)%base_desc,trans,work,info) ! ! Compute the residual (at all levels but the coarsest one) ! if(ilev < nlev) then mlprec_wrk(ilev)%ty = mlprec_wrk(ilev)%x2l - if (info == 0) call psb_spmm(-zone,baseprecv(ilev)%base_a,& + if (info == 0) call psb_spmm(-zone,precv(ilev)%base_a,& & mlprec_wrk(ilev)%y2l,zone,mlprec_wrk(ilev)%ty,& - & baseprecv(ilev)%base_desc,info,work=work,trans=trans) + & precv(ilev)%base_desc,info,work=work,trans=trans) endif if (info /=0) then call psb_errpush(4001,name,a_err='baseprec_aply/residual') @@ -1341,15 +1278,12 @@ contains ! do ilev=nlev-1, 1, -1 - ismth = baseprecv(ilev+1)%iprcparm(mld_aggr_kind_) - n_row = psb_cd_get_local_rows(baseprecv(ilev)%base_desc) - ! ! Apply prolongator ! call psb_backward_map(zone,mlprec_wrk(ilev+1)%y2l,& & zone,mlprec_wrk(ilev)%y2l,& - & baseprecv(ilev+1)%map_desc,info,work=work) + & precv(ilev+1)%map_desc,info,work=work) if (info /=0 ) then call psb_errpush(4001,name,a_err='Error during restriction') @@ -1359,14 +1293,14 @@ contains ! ! Compute the residual ! - call psb_spmm(-zone,baseprecv(ilev)%base_a,mlprec_wrk(ilev)%y2l,& - & zone,mlprec_wrk(ilev)%tx,baseprecv(ilev)%base_desc,info,& + call psb_spmm(-zone,precv(ilev)%base_a,mlprec_wrk(ilev)%y2l,& + & zone,mlprec_wrk(ilev)%tx,precv(ilev)%base_desc,info,& & work=work,trans=trans) ! ! Apply the base preconditioner ! - if (info == 0) call mld_baseprec_aply(zone,baseprecv(ilev),mlprec_wrk(ilev)%tx,& - & zone,mlprec_wrk(ilev)%y2l,baseprecv(ilev)%base_desc, trans, work,info) + if (info == 0) call mld_baseprec_aply(zone,precv(ilev)%prec,mlprec_wrk(ilev)%tx,& + & zone,mlprec_wrk(ilev)%y2l,precv(ilev)%base_desc, trans, work,info) if (info /= 0) then call psb_errpush(4001,name,a_err='Error: residual/baseprec_aply') goto 9999 @@ -1379,7 +1313,7 @@ contains ! Compute the output vector Y ! call psb_geaxpby(alpha,mlprec_wrk(1)%y2l,beta,y,& - & baseprecv(1)%base_desc,info) + & precv(1)%base_desc,info) if (info /= 0) then call psb_errpush(4001,name,a_err='Error final update') diff --git a/mlprec/mld_zmlprec_bld.f90 b/mlprec/mld_zmlprec_bld.f90 index 142a132b..4008a766 100644 --- a/mlprec/mld_zmlprec_bld.f90 +++ b/mlprec/mld_zmlprec_bld.f90 @@ -41,7 +41,7 @@ ! Subroutine: mld_zmlprec_bld ! Version: complex ! -! This routine builds the base preconditioner corresponding to the current +! This routine builds the preconditioner corresponding to the current ! level of the multilevel preconditioner. The routine first builds the ! (coarse) matrix associated to the current level from the (fine) matrix ! associated to the previous level, then builds the related base preconditioner. @@ -53,9 +53,9 @@ ! matrix to be preconditioned. ! desc_a - type(psb_desc_type), input. ! The communication descriptor of a. -! p - type(mld_zbaseprc_type), input/output. -! The base preconditioner data structure containing the local -! part of the base preconditioner to be built. +! p - type(mld_z_onelev_type), input/output. +! The preconditioner data structure containing the local +! part of the one-level preconditioner to be built. ! info - integer, output. ! Error code. ! @@ -69,7 +69,7 @@ subroutine mld_zmlprec_bld(a,desc_a,p,info) ! Arguments type(psb_zspmat_type), intent(in), target :: a type(psb_desc_type), intent(in), target :: desc_a - type(mld_zbaseprc_type), intent(inout),target :: p + type(mld_z_onelev_prec_type), intent(inout),target :: p integer, intent(out) :: info ! Local variables @@ -106,16 +106,16 @@ subroutine mld_zmlprec_bld(a,desc_a,p,info) & mld_max_norm_,is_legal_ml_aggr_eig) - select case(p%iprcparm(mld_sub_solve_)) + select case(p%prec%iprcparm(mld_sub_solve_)) case(mld_ilu_n_,mld_milu_n_) - call mld_check_def(p%iprcparm(mld_sub_fillin_),'Level',0,is_legal_ml_lev) + call mld_check_def(p%prec%iprcparm(mld_sub_fillin_),'Level',0,is_legal_ml_lev) case(mld_ilu_t_) - call mld_check_def(p%rprcparm(mld_sub_iluthrs_),'Eps',dzero,is_legal_fact_thrs) + call mld_check_def(p%prec%rprcparm(mld_sub_iluthrs_),'Eps',dzero,is_legal_fact_thrs) end select + call mld_check_def(p%prec%iprcparm(mld_smoother_sweeps_),'Jacobi sweeps',& + & 1,is_legal_jac_sweeps) call mld_check_def(p%rprcparm(mld_aggr_omega_val_),'Omega',dzero,is_legal_omega) call mld_check_def(p%rprcparm(mld_aggr_thresh_),'Aggr_Thresh',dzero,is_legal_aggr_thrs) - call mld_check_def(p%iprcparm(mld_smoother_sweeps_),'Jacobi sweeps',& - & 1,is_legal_jac_sweeps) ! ! Build a mapping between the row indices of the fine-level matrix @@ -135,7 +135,7 @@ subroutine mld_zmlprec_bld(a,desc_a,p,info) ! the mapping defined by mld_aggrmap_bld and applying the aggregation ! algorithm specified by p%iprcparm(mld_aggr_kind_) ! - call mld_aggrmat_asb(a,desc_a,ac,desc_ac,p,info) + call mld_aggrmat_asb(a,desc_a,p,info) if(info /= 0) then call psb_errpush(4010,name,a_err='mld_aggrmat_asb') goto 9999 @@ -144,34 +144,18 @@ subroutine mld_zmlprec_bld(a,desc_a,p,info) ! ! Build the 'base preconditioner' corresponding to the coarse level ! - call mld_baseprc_bld(ac,desc_ac,p,info) + call mld_baseprc_bld(p%ac,p%desc_ac,p%prec,info) if (info /= 0) then call psb_errpush(4010,name,a_err='mld_baseprc_bld') goto 9999 end if - ! - ! We have used a separate ac because - ! 1. we want to reuse the same routines mld_ilu_bld, etc., - ! 2. we do NOT want to pass an argument twice to them (p%av(mld_ac_) and p), - ! as this would violate the Fortran standard. - ! Hence a separate AC and a TRANSFER function at the end. + ! Fix the base_a and base_desc pointers for handling of residuals. + ! This is correct because this routine is only called at levels >=2. ! - call psb_sp_transfer(ac,p%av(mld_ac_),info) - p%base_a => p%av(mld_ac_) - if (info==0) call psb_cdtransfer(desc_ac,p%desc_ac,info) - - p%map_desc = psb_inter_desc(psb_map_aggr_,desc_a,& - & p%desc_ac,p%av(mld_sm_pr_t_),p%av(mld_sm_pr_)) - ! The two matrices from p%av() have been copied, may free them. - if (info == 0) call psb_sp_free(p%av(mld_sm_pr_t_),info) - if (info == 0) call psb_sp_free(p%av(mld_sm_pr_),info) - if (info /= 0) then - call psb_errpush(4010,name,a_err='psb_cdtransfer') - goto 9999 - end if + p%base_a => p%ac p%base_desc => p%desc_ac - + call psb_erractionrestore(err_act) return diff --git a/mlprec/mld_zprec_aply.f90 b/mlprec/mld_zprec_aply.f90 index 8c62a8df..1414bce9 100644 --- a/mlprec/mld_zprec_aply.f90 +++ b/mlprec/mld_zprec_aply.f90 @@ -120,25 +120,25 @@ subroutine mld_zprec_aply(prec,x,y,desc_data,info,trans,work) end if - if (.not.(allocated(prec%baseprecv))) then + if (.not.(allocated(prec%precv))) then !! Error 1: should call mld_dprecbld info=3112 call psb_errpush(info,name) goto 9999 end if - if (size(prec%baseprecv) >1) then - call mld_mlprec_aply(zone,prec%baseprecv,x,zzero,y,desc_data,trans_,work_,info) + if (size(prec%precv) >1) then + call mld_mlprec_aply(zone,prec%precv,x,zzero,y,desc_data,trans_,work_,info) if(info /= 0) then call psb_errpush(4010,name,a_err='mld_zmlprec_aply') goto 9999 end if - else if (size(prec%baseprecv) == 1) then - call mld_baseprec_aply(zone,prec%baseprecv(1),x,zzero,y,desc_data,trans_, work_,info) + else if (size(prec%precv) == 1) then + call mld_baseprec_aply(zone,prec%precv(1)%prec,x,zzero,y,desc_data,trans_, work_,info) else info = 4013 - call psb_errpush(info,name,a_err='Invalid size of baseprecv',& - & i_Err=(/size(prec%baseprecv),0,0,0,0/)) + call psb_errpush(info,name,a_err='Invalid size of precv',& + & i_Err=(/size(prec%precv),0,0,0,0/)) goto 9999 endif diff --git a/mlprec/mld_zprecbld.f90 b/mlprec/mld_zprecbld.f90 index e683a84e..a84cd42b 100644 --- a/mlprec/mld_zprecbld.f90 +++ b/mlprec/mld_zprecbld.f90 @@ -119,8 +119,8 @@ subroutine mld_zprecbld(a,desc_a,p,info) !!$ endif upd_ = 'F' - if (.not.allocated(p%baseprecv)) then - !! Error: should have called mld_dprecinit + if (.not.allocated(p%precv)) then + !! Error: should have called mld_zprecinit info=3111 call psb_errpush(info,name) goto 9999 @@ -129,11 +129,11 @@ subroutine mld_zprecbld(a,desc_a,p,info) ! ! Check to ensure all procs have the same ! - iszv = size(p%baseprecv) + iszv = size(p%precv) call psb_bcast(ictxt,iszv) - if (iszv /= size(p%baseprecv)) then + if (iszv /= size(p%precv)) then info=4001 - call psb_errpush(info,name,a_err='Inconsistent size of baseprecv') + call psb_errpush(info,name,a_err='Inconsistent size of precv') goto 9999 end if @@ -142,18 +142,20 @@ subroutine mld_zprecbld(a,desc_a,p,info) ! Check on the iprcparm contents: they should be the same ! on all processes. ! - if (me == psb_root_) ipv(:) = p%baseprecv(1)%iprcparm(:) + if (me == psb_root_) ipv(:) = p%precv(1)%iprcparm(:) call psb_bcast(ictxt,ipv) - if (any(ipv(:) /= p%baseprecv(1)%iprcparm(:) )) then + if (any(ipv(:) /= p%precv(1)%iprcparm(:) )) then write(debug_unit,*) me,name,& &': Inconsistent arguments among processes, forcing a default' - p%baseprecv(1)%iprcparm(:) = ipv(:) + p%precv(1)%iprcparm(:) = ipv(:) end if ! - ! Allocate and build the fine level preconditioner + ! Finest level first; remember to fix base_a and base_desc ! - call init_baseprc_av(p%baseprecv(1),info) - if (info == 0) call mld_baseprc_bld(a,desc_a,p%baseprecv(1),info,upd_) + call init_baseprc_av(p%precv(1)%prec,info) + if (info == 0) call mld_baseprc_bld(a,desc_a,p%precv(1)%prec,info,upd_) + p%precv(1)%base_a => a + p%precv(1)%base_desc => desc_a if (info /= 0) then call psb_errpush(4001,name,a_err='Base level precbuild.') @@ -178,69 +180,69 @@ subroutine mld_zprecbld(a,desc_a,p,info) ! Check on the iprcparm contents: they should be the same ! on all processes. ! - if (me == psb_root_) ipv(:) = p%baseprecv(i)%iprcparm(:) + if (me == psb_root_) ipv(:) = p%precv(i)%iprcparm(:) call psb_bcast(ictxt,ipv) - if (any(ipv(:) /= p%baseprecv(i)%iprcparm(:) )) then + if (any(ipv(:) /= p%precv(i)%iprcparm(:) )) then write(debug_unit,*) me,name,& &': Inconsistent arguments among processes, resetting.' - p%baseprecv(i)%iprcparm(:) = ipv(:) + p%precv(i)%iprcparm(:) = ipv(:) end if ! - ! Allocate the av component of the preconditioner data type - ! at level i + ! Sanity checks on the parameters ! if (i= psb_debug_outer_) & & write(debug_unit,*) me,' ',trim(name),& & 'Calling mlprcbld at level ',i - - ! - ! Build the base preconditioner corresponding to level i ! - if (info == 0) call mld_mlprec_bld(p%baseprecv(i-1)%base_a,& - & p%baseprecv(i-1)%base_desc, p%baseprecv(i),info) + ! Allocate and build the preconditioner at level i. + ! baseprec_bld is called inside mlprec_bld. + ! + call init_baseprc_av(p%precv(i)%prec,info) + if (info == 0) call mld_mlprec_bld(p%precv(i-1)%base_a,& + & p%precv(i-1)%base_desc, p%precv(i),info) + if (info /= 0) then call psb_errpush(4001,name,a_err='Init & build upper level preconditioner') goto 9999 @@ -250,11 +252,14 @@ subroutine mld_zprecbld(a,desc_a,p,info) & write(debug_unit,*) me,' ',trim(name),& & 'Return from ',i,' call to mlprcbld ',info end do + + ! ! Check on sizes from level 2 onwards + ! if (me==0) then k = iszv+1 do i=iszv,3,-1 - if (all(p%baseprecv(i)%nlaggr == p%baseprecv(i-1)%nlaggr)) then + if (all(p%precv(i)%nlaggr == p%precv(i-1)%nlaggr)) then k=i-1 end if end do diff --git a/mlprec/mld_zprecfree.f90 b/mlprec/mld_zprecfree.f90 index 0f39bd27..61017acf 100644 --- a/mlprec/mld_zprecfree.f90 +++ b/mlprec/mld_zprecfree.f90 @@ -74,11 +74,11 @@ subroutine mld_zprecfree(p,info) me=-1 - if (allocated(p%baseprecv)) then - do i=1,size(p%baseprecv) - call mld_base_precfree(p%baseprecv(i),info) + if (allocated(p%precv)) then + do i=1,size(p%precv) + call mld_onelev_precfree(p%precv(i),info) end do - deallocate(p%baseprecv) + deallocate(p%precv) end if call psb_erractionrestore(err_act) return diff --git a/mlprec/mld_zprecinit.F90 b/mlprec/mld_zprecinit.F90 index 1081d863..c3c3bd02 100644 --- a/mlprec/mld_zprecinit.F90 +++ b/mlprec/mld_zprecinit.F90 @@ -104,7 +104,7 @@ subroutine mld_zprecinit(p,ptype,info,nlev) character(len=*), parameter :: name='mld_precinit' info = 0 - if (allocated(p%baseprecv)) then + if (allocated(p%precv)) then call mld_precfree(p,info) if (info /=0) then ! Do we want to do something? @@ -115,68 +115,88 @@ subroutine mld_zprecinit(p,ptype,info,nlev) case ('NOPREC') nlev_ = 1 ilev_ = 1 - allocate(p%baseprecv(nlev_),stat=info) - if (info == 0) call psb_realloc(mld_ifpsz_,p%baseprecv(ilev_)%iprcparm,info) - if (info == 0) call psb_realloc(mld_rfpsz_,p%baseprecv(ilev_)%rprcparm,info) + allocate(p%precv(nlev_),stat=info) + if (info == 0) call psb_realloc(mld_ifpsz_,p%precv(ilev_)%iprcparm,info) + if (info == 0) call psb_realloc(mld_rfpsz_,p%precv(ilev_)%rprcparm,info) + if (info == 0) call psb_realloc(mld_ifpsz_,p%precv(ilev_)%prec%iprcparm,info) + if (info == 0) call psb_realloc(mld_rfpsz_,p%precv(ilev_)%prec%rprcparm,info) if (info /= 0) return - p%baseprecv(ilev_)%iprcparm(:) = 0 - p%baseprecv(ilev_)%iprcparm(mld_smoother_type_) = mld_noprec_ - p%baseprecv(ilev_)%iprcparm(mld_sub_solve_) = mld_f_none_ - p%baseprecv(ilev_)%iprcparm(mld_sub_restr_) = psb_none_ - p%baseprecv(ilev_)%iprcparm(mld_sub_prol_) = psb_none_ - p%baseprecv(ilev_)%iprcparm(mld_sub_ren_) = 0 - p%baseprecv(ilev_)%iprcparm(mld_sub_ovr_) = 0 - p%baseprecv(ilev_)%iprcparm(mld_smoother_sweeps_) = 1 + p%precv(ilev_)%iprcparm(:) = 0 + p%precv(ilev_)%rprcparm(:) = dzero + p%precv(ilev_)%prec%iprcparm(:) = 0 + p%precv(ilev_)%prec%rprcparm(:) = dzero + p%precv(ilev_)%prec%iprcparm(mld_smoother_type_) = mld_noprec_ + p%precv(ilev_)%prec%iprcparm(mld_sub_solve_) = mld_f_none_ + p%precv(ilev_)%prec%iprcparm(mld_sub_restr_) = psb_none_ + p%precv(ilev_)%prec%iprcparm(mld_sub_prol_) = psb_none_ + p%precv(ilev_)%prec%iprcparm(mld_sub_ren_) = 0 + p%precv(ilev_)%prec%iprcparm(mld_sub_ovr_) = 0 + p%precv(ilev_)%prec%iprcparm(mld_smoother_sweeps_) = 1 case ('DIAG') nlev_ = 1 ilev_ = 1 - allocate(p%baseprecv(nlev_),stat=info) - if (info == 0) call psb_realloc(mld_ifpsz_,p%baseprecv(ilev_)%iprcparm,info) - if (info == 0) call psb_realloc(mld_rfpsz_,p%baseprecv(ilev_)%rprcparm,info) + allocate(p%precv(nlev_),stat=info) + if (info == 0) call psb_realloc(mld_ifpsz_,p%precv(ilev_)%iprcparm,info) + if (info == 0) call psb_realloc(mld_rfpsz_,p%precv(ilev_)%rprcparm,info) + if (info == 0) call psb_realloc(mld_ifpsz_,p%precv(ilev_)%prec%iprcparm,info) + if (info == 0) call psb_realloc(mld_rfpsz_,p%precv(ilev_)%prec%rprcparm,info) if (info /= 0) return - p%baseprecv(ilev_)%iprcparm(:) = 0 - p%baseprecv(ilev_)%iprcparm(mld_smoother_type_) = mld_diag_ - p%baseprecv(ilev_)%iprcparm(mld_sub_solve_) = mld_f_none_ - p%baseprecv(ilev_)%iprcparm(mld_sub_restr_) = psb_none_ - p%baseprecv(ilev_)%iprcparm(mld_sub_prol_) = psb_none_ - p%baseprecv(ilev_)%iprcparm(mld_sub_ren_) = 0 - p%baseprecv(ilev_)%iprcparm(mld_sub_ovr_) = 0 - p%baseprecv(ilev_)%iprcparm(mld_smoother_sweeps_) = 1 + p%precv(ilev_)%iprcparm(:) = 0 + p%precv(ilev_)%rprcparm(:) = dzero + p%precv(ilev_)%prec%iprcparm(:) = 0 + p%precv(ilev_)%prec%rprcparm(:) = dzero + p%precv(ilev_)%prec%iprcparm(mld_smoother_type_) = mld_diag_ + p%precv(ilev_)%prec%iprcparm(mld_sub_solve_) = mld_f_none_ + p%precv(ilev_)%prec%iprcparm(mld_sub_restr_) = psb_none_ + p%precv(ilev_)%prec%iprcparm(mld_sub_prol_) = psb_none_ + p%precv(ilev_)%prec%iprcparm(mld_sub_ren_) = 0 + p%precv(ilev_)%prec%iprcparm(mld_sub_ovr_) = 0 + p%precv(ilev_)%prec%iprcparm(mld_smoother_sweeps_) = 1 case ('BJAC') nlev_ = 1 ilev_ = 1 - allocate(p%baseprecv(nlev_),stat=info) - if (info == 0) call psb_realloc(mld_ifpsz_,p%baseprecv(ilev_)%iprcparm,info) - if (info == 0) call psb_realloc(mld_rfpsz_,p%baseprecv(ilev_)%rprcparm,info) + allocate(p%precv(nlev_),stat=info) + if (info == 0) call psb_realloc(mld_ifpsz_,p%precv(ilev_)%iprcparm,info) + if (info == 0) call psb_realloc(mld_rfpsz_,p%precv(ilev_)%rprcparm,info) + if (info == 0) call psb_realloc(mld_ifpsz_,p%precv(ilev_)%prec%iprcparm,info) + if (info == 0) call psb_realloc(mld_rfpsz_,p%precv(ilev_)%prec%rprcparm,info) if (info /= 0) return - p%baseprecv(ilev_)%iprcparm(:) = 0 - p%baseprecv(ilev_)%iprcparm(mld_smoother_type_) = mld_bjac_ - p%baseprecv(ilev_)%iprcparm(mld_sub_solve_) = mld_ilu_n_ - p%baseprecv(ilev_)%iprcparm(mld_sub_restr_) = psb_none_ - p%baseprecv(ilev_)%iprcparm(mld_sub_prol_) = psb_none_ - p%baseprecv(ilev_)%iprcparm(mld_sub_ren_) = 0 - p%baseprecv(ilev_)%iprcparm(mld_sub_ovr_) = 0 - p%baseprecv(ilev_)%iprcparm(mld_sub_fillin_) = 0 - p%baseprecv(ilev_)%iprcparm(mld_smoother_sweeps_) = 1 + p%precv(ilev_)%iprcparm(:) = 0 + p%precv(ilev_)%rprcparm(:) = dzero + p%precv(ilev_)%prec%iprcparm(:) = 0 + p%precv(ilev_)%prec%rprcparm(:) = dzero + p%precv(ilev_)%prec%iprcparm(mld_smoother_type_) = mld_bjac_ + p%precv(ilev_)%prec%iprcparm(mld_sub_solve_) = mld_ilu_n_ + p%precv(ilev_)%prec%iprcparm(mld_sub_restr_) = psb_none_ + p%precv(ilev_)%prec%iprcparm(mld_sub_prol_) = psb_none_ + p%precv(ilev_)%prec%iprcparm(mld_sub_ren_) = 0 + p%precv(ilev_)%prec%iprcparm(mld_sub_ovr_) = 0 + p%precv(ilev_)%prec%iprcparm(mld_sub_fillin_) = 0 + p%precv(ilev_)%prec%iprcparm(mld_smoother_sweeps_) = 1 case ('AS') nlev_ = 1 ilev_ = 1 - allocate(p%baseprecv(nlev_),stat=info) - if (info == 0) call psb_realloc(mld_ifpsz_,p%baseprecv(ilev_)%iprcparm,info) - if (info == 0) call psb_realloc(mld_rfpsz_,p%baseprecv(ilev_)%rprcparm,info) + allocate(p%precv(nlev_),stat=info) + if (info == 0) call psb_realloc(mld_ifpsz_,p%precv(ilev_)%iprcparm,info) + if (info == 0) call psb_realloc(mld_rfpsz_,p%precv(ilev_)%rprcparm,info) + if (info == 0) call psb_realloc(mld_ifpsz_,p%precv(ilev_)%prec%iprcparm,info) + if (info == 0) call psb_realloc(mld_rfpsz_,p%precv(ilev_)%prec%rprcparm,info) if (info /= 0) return - p%baseprecv(ilev_)%iprcparm(:) = 0 - p%baseprecv(ilev_)%iprcparm(mld_smoother_type_) = mld_as_ - p%baseprecv(ilev_)%iprcparm(mld_sub_solve_) = mld_ilu_n_ - p%baseprecv(ilev_)%iprcparm(mld_sub_restr_) = psb_halo_ - p%baseprecv(ilev_)%iprcparm(mld_sub_prol_) = psb_none_ - p%baseprecv(ilev_)%iprcparm(mld_sub_ren_) = 0 - p%baseprecv(ilev_)%iprcparm(mld_sub_ovr_) = 1 - p%baseprecv(ilev_)%iprcparm(mld_sub_fillin_) = 0 - p%baseprecv(ilev_)%iprcparm(mld_smoother_sweeps_) = 1 + p%precv(ilev_)%iprcparm(:) = 0 + p%precv(ilev_)%rprcparm(:) = dzero + p%precv(ilev_)%prec%iprcparm(:) = 0 + p%precv(ilev_)%prec%rprcparm(:) = dzero + p%precv(ilev_)%prec%iprcparm(mld_smoother_type_) = mld_as_ + p%precv(ilev_)%prec%iprcparm(mld_sub_solve_) = mld_ilu_n_ + p%precv(ilev_)%prec%iprcparm(mld_sub_restr_) = psb_halo_ + p%precv(ilev_)%prec%iprcparm(mld_sub_prol_) = psb_none_ + p%precv(ilev_)%prec%iprcparm(mld_sub_ren_) = 0 + p%precv(ilev_)%prec%iprcparm(mld_sub_ovr_) = 1 + p%precv(ilev_)%prec%iprcparm(mld_sub_fillin_) = 0 + p%precv(ilev_)%prec%iprcparm(mld_smoother_sweeps_) = 1 case ('ML') @@ -187,76 +207,88 @@ subroutine mld_zprecinit(p,ptype,info,nlev) nlev_ = 2 end if ilev_ = 1 - allocate(p%baseprecv(nlev_),stat=info) - if (info == 0) call psb_realloc(mld_ifpsz_,p%baseprecv(ilev_)%iprcparm,info) - if (info == 0) call psb_realloc(mld_rfpsz_,p%baseprecv(ilev_)%rprcparm,info) + allocate(p%precv(nlev_),stat=info) + if (info == 0) call psb_realloc(mld_ifpsz_,p%precv(ilev_)%iprcparm,info) + if (info == 0) call psb_realloc(mld_rfpsz_,p%precv(ilev_)%rprcparm,info) + if (info == 0) call psb_realloc(mld_ifpsz_,p%precv(ilev_)%prec%iprcparm,info) + if (info == 0) call psb_realloc(mld_rfpsz_,p%precv(ilev_)%prec%rprcparm,info) if (info /= 0) return - p%baseprecv(ilev_)%iprcparm(:) = 0 - p%baseprecv(ilev_)%rprcparm(:) = dzero - p%baseprecv(ilev_)%iprcparm(mld_smoother_type_) = mld_as_ - p%baseprecv(ilev_)%iprcparm(mld_sub_solve_) = mld_ilu_n_ - p%baseprecv(ilev_)%iprcparm(mld_sub_restr_) = psb_halo_ - p%baseprecv(ilev_)%iprcparm(mld_sub_prol_) = psb_none_ - p%baseprecv(ilev_)%iprcparm(mld_sub_ren_) = 0 - p%baseprecv(ilev_)%iprcparm(mld_sub_ovr_) = 1 - p%baseprecv(ilev_)%iprcparm(mld_sub_fillin_) = 0 - p%baseprecv(ilev_)%iprcparm(mld_smoother_sweeps_) = 1 + p%precv(ilev_)%iprcparm(:) = 0 + p%precv(ilev_)%rprcparm(:) = dzero + p%precv(ilev_)%prec%iprcparm(:) = 0 + p%precv(ilev_)%prec%rprcparm(:) = dzero + p%precv(ilev_)%prec%iprcparm(mld_smoother_type_) = mld_as_ + p%precv(ilev_)%prec%iprcparm(mld_sub_solve_) = mld_ilu_n_ + p%precv(ilev_)%prec%iprcparm(mld_sub_restr_) = psb_halo_ + p%precv(ilev_)%prec%iprcparm(mld_sub_prol_) = psb_none_ + p%precv(ilev_)%prec%iprcparm(mld_sub_ren_) = 0 + p%precv(ilev_)%prec%iprcparm(mld_sub_ovr_) = 1 + p%precv(ilev_)%prec%iprcparm(mld_sub_fillin_) = 0 + p%precv(ilev_)%prec%iprcparm(mld_smoother_sweeps_) = 1 if (nlev_ == 1) return do ilev_ = 2, nlev_ -1 - if (info == 0) call psb_realloc(mld_ifpsz_,p%baseprecv(ilev_)%iprcparm,info) - if (info == 0) call psb_realloc(mld_rfpsz_,p%baseprecv(ilev_)%rprcparm,info) + if (info == 0) call psb_realloc(mld_ifpsz_,p%precv(ilev_)%iprcparm,info) + if (info == 0) call psb_realloc(mld_rfpsz_,p%precv(ilev_)%rprcparm,info) + if (info == 0) call psb_realloc(mld_ifpsz_,p%precv(ilev_)%prec%iprcparm,info) + if (info == 0) call psb_realloc(mld_rfpsz_,p%precv(ilev_)%prec%rprcparm,info) if (info /= 0) return - p%baseprecv(ilev_)%iprcparm(:) = 0 - p%baseprecv(ilev_)%rprcparm(:) = dzero - p%baseprecv(ilev_)%iprcparm(mld_smoother_type_) = mld_as_ - p%baseprecv(ilev_)%iprcparm(mld_sub_restr_) = psb_halo_ - p%baseprecv(ilev_)%iprcparm(mld_sub_prol_) = psb_none_ - p%baseprecv(ilev_)%iprcparm(mld_sub_ren_) = 0 - p%baseprecv(ilev_)%iprcparm(mld_sub_ovr_) = 1 - p%baseprecv(ilev_)%iprcparm(mld_ml_type_) = mld_mult_ml_ - p%baseprecv(ilev_)%iprcparm(mld_aggr_alg_) = mld_dec_aggr_ - p%baseprecv(ilev_)%iprcparm(mld_aggr_kind_) = mld_smooth_prol_ - p%baseprecv(ilev_)%iprcparm(mld_coarse_mat_) = mld_distr_mat_ - p%baseprecv(ilev_)%iprcparm(mld_smoother_pos_) = mld_post_smooth_ - p%baseprecv(ilev_)%iprcparm(mld_aggr_omega_alg_) = mld_eig_est_ - p%baseprecv(ilev_)%iprcparm(mld_aggr_eig_) = mld_max_norm_ - p%baseprecv(ilev_)%iprcparm(mld_sub_solve_) = mld_ilu_n_ - p%baseprecv(ilev_)%iprcparm(mld_sub_fillin_) = 0 - p%baseprecv(ilev_)%iprcparm(mld_smoother_sweeps_) = 1 - p%baseprecv(ilev_)%rprcparm(mld_aggr_omega_val_) = dzero - p%baseprecv(ilev_)%rprcparm(mld_aggr_thresh_) = dzero + p%precv(ilev_)%iprcparm(:) = 0 + p%precv(ilev_)%rprcparm(:) = dzero + p%precv(ilev_)%prec%iprcparm(:) = 0 + p%precv(ilev_)%prec%rprcparm(:) = dzero + p%precv(ilev_)%prec%iprcparm(mld_smoother_type_) = mld_as_ + p%precv(ilev_)%prec%iprcparm(mld_sub_restr_) = psb_halo_ + p%precv(ilev_)%prec%iprcparm(mld_sub_prol_) = psb_none_ + p%precv(ilev_)%prec%iprcparm(mld_sub_ren_) = 0 + p%precv(ilev_)%prec%iprcparm(mld_sub_ovr_) = 1 + p%precv(ilev_)%prec%iprcparm(mld_sub_solve_) = mld_ilu_n_ + p%precv(ilev_)%prec%iprcparm(mld_sub_fillin_) = 0 + p%precv(ilev_)%prec%iprcparm(mld_smoother_sweeps_) = 1 + p%precv(ilev_)%iprcparm(mld_ml_type_) = mld_mult_ml_ + p%precv(ilev_)%iprcparm(mld_aggr_alg_) = mld_dec_aggr_ + p%precv(ilev_)%iprcparm(mld_aggr_kind_) = mld_smooth_prol_ + p%precv(ilev_)%iprcparm(mld_coarse_mat_) = mld_distr_mat_ + p%precv(ilev_)%iprcparm(mld_smoother_pos_) = mld_post_smooth_ + p%precv(ilev_)%iprcparm(mld_aggr_omega_alg_) = mld_eig_est_ + p%precv(ilev_)%iprcparm(mld_aggr_eig_) = mld_max_norm_ + p%precv(ilev_)%rprcparm(mld_aggr_omega_val_) = dzero + p%precv(ilev_)%rprcparm(mld_aggr_thresh_) = dzero end do ilev_ = nlev_ - if (info == 0) call psb_realloc(mld_ifpsz_,p%baseprecv(ilev_)%iprcparm,info) - if (info == 0) call psb_realloc(mld_rfpsz_,p%baseprecv(ilev_)%rprcparm,info) + if (info == 0) call psb_realloc(mld_ifpsz_,p%precv(ilev_)%iprcparm,info) + if (info == 0) call psb_realloc(mld_rfpsz_,p%precv(ilev_)%rprcparm,info) + if (info == 0) call psb_realloc(mld_ifpsz_,p%precv(ilev_)%prec%iprcparm,info) + if (info == 0) call psb_realloc(mld_rfpsz_,p%precv(ilev_)%prec%rprcparm,info) if (info /= 0) return - p%baseprecv(ilev_)%iprcparm(:) = 0 - p%baseprecv(ilev_)%rprcparm(:) = dzero - p%baseprecv(ilev_)%iprcparm(mld_coarse_solve_) = mld_bjac_ + p%precv(ilev_)%iprcparm(:) = 0 + p%precv(ilev_)%rprcparm(:) = dzero + p%precv(ilev_)%prec%iprcparm(:) = 0 + p%precv(ilev_)%prec%rprcparm(:) = dzero + p%precv(ilev_)%prec%iprcparm(mld_coarse_solve_) = mld_bjac_ #if defined(HAVE_UMF_) - p%baseprecv(ilev_)%iprcparm(mld_sub_solve_) = mld_umf_ + p%precv(ilev_)%prec%iprcparm(mld_sub_solve_) = mld_umf_ #elif defined(HAVE_SLU_) - p%baseprecv(ilev_)%iprcparm(mld_sub_solve_) = mld_slu_ + p%precv(ilev_)%prec%iprcparm(mld_sub_solve_) = mld_slu_ #else - p%baseprecv(ilev_)%iprcparm(mld_sub_solve_) = mld_ilu_n_ + p%precv(ilev_)%prec%iprcparm(mld_sub_solve_) = mld_ilu_n_ #endif - p%baseprecv(ilev_)%iprcparm(mld_smoother_type_) = mld_bjac_ - p%baseprecv(ilev_)%iprcparm(mld_coarse_mat_) = mld_distr_mat_ - p%baseprecv(ilev_)%iprcparm(mld_sub_restr_) = psb_none_ - p%baseprecv(ilev_)%iprcparm(mld_sub_prol_) = psb_none_ - p%baseprecv(ilev_)%iprcparm(mld_sub_ren_) = 0 - p%baseprecv(ilev_)%iprcparm(mld_sub_ovr_) = 0 - p%baseprecv(ilev_)%iprcparm(mld_ml_type_) = mld_mult_ml_ - p%baseprecv(ilev_)%iprcparm(mld_aggr_alg_) = mld_dec_aggr_ - p%baseprecv(ilev_)%iprcparm(mld_aggr_kind_) = mld_smooth_prol_ - p%baseprecv(ilev_)%iprcparm(mld_smoother_pos_) = mld_post_smooth_ - p%baseprecv(ilev_)%iprcparm(mld_aggr_omega_alg_) = mld_eig_est_ - p%baseprecv(ilev_)%iprcparm(mld_aggr_eig_) = mld_max_norm_ - p%baseprecv(ilev_)%iprcparm(mld_sub_fillin_) = 0 - p%baseprecv(ilev_)%iprcparm(mld_smoother_sweeps_) = 4 - p%baseprecv(ilev_)%rprcparm(mld_aggr_omega_val_) = dzero - p%baseprecv(ilev_)%rprcparm(mld_aggr_thresh_) = dzero + p%precv(ilev_)%prec%iprcparm(mld_smoother_type_) = mld_bjac_ + p%precv(ilev_)%prec%iprcparm(mld_coarse_mat_) = mld_distr_mat_ + p%precv(ilev_)%prec%iprcparm(mld_sub_restr_) = psb_none_ + p%precv(ilev_)%prec%iprcparm(mld_sub_prol_) = psb_none_ + p%precv(ilev_)%prec%iprcparm(mld_sub_ren_) = 0 + p%precv(ilev_)%prec%iprcparm(mld_sub_ovr_) = 0 + p%precv(ilev_)%prec%iprcparm(mld_sub_fillin_) = 0 + p%precv(ilev_)%prec%iprcparm(mld_smoother_sweeps_) = 4 + p%precv(ilev_)%iprcparm(mld_ml_type_) = mld_mult_ml_ + p%precv(ilev_)%iprcparm(mld_aggr_alg_) = mld_dec_aggr_ + p%precv(ilev_)%iprcparm(mld_aggr_kind_) = mld_smooth_prol_ + p%precv(ilev_)%iprcparm(mld_smoother_pos_) = mld_post_smooth_ + p%precv(ilev_)%iprcparm(mld_aggr_omega_alg_) = mld_eig_est_ + p%precv(ilev_)%iprcparm(mld_aggr_eig_) = mld_max_norm_ + p%precv(ilev_)%rprcparm(mld_aggr_omega_val_) = dzero + p%precv(ilev_)%rprcparm(mld_aggr_thresh_) = dzero case default write(0,*) name,': Warning: Unknown preconditioner type request "',ptype,'"' diff --git a/mlprec/mld_zprecset.f90 b/mlprec/mld_zprecset.f90 index de7e6c0f..957a8216 100644 --- a/mlprec/mld_zprecset.f90 +++ b/mlprec/mld_zprecset.f90 @@ -97,12 +97,12 @@ subroutine mld_zprecseti(p,what,val,info,ilev) info = 0 - if (.not.allocated(p%baseprecv)) then + if (.not.allocated(p%precv)) then info = 3111 write(0,*) name,': Error: uninitialized preconditioner, should call MLD_PRECINIT' return endif - nlev_ = size(p%baseprecv) + nlev_ = size(p%precv) if (present(ilev)) then ilev_ = ilev @@ -115,7 +115,13 @@ subroutine mld_zprecseti(p,what,val,info,ilev) write(0,*) name,': Error: invalid ILEV/NLEV combination',ilev_, nlev_ return endif - if (.not.allocated(p%baseprecv(ilev_)%iprcparm)) then + if (.not.allocated(p%precv(ilev_)%iprcparm)) then + info = 3111 + write(0,*) name,& + &': Error: uninitialized preconditioner component, should call MLD_PRECINIT' + return + endif + if (.not.allocated(p%precv(ilev_)%prec%iprcparm)) then info = 3111 write(0,*) name,& &': Error: uninitialized preconditioner component, should call MLD_PRECINIT' @@ -126,7 +132,7 @@ subroutine mld_zprecseti(p,what,val,info,ilev) ! Set preconditioner parameters at level ilev. ! if (present(ilev)) then - + if (ilev_ == 1) then ! ! Rules for fine level are slightly different. @@ -134,7 +140,7 @@ subroutine mld_zprecseti(p,what,val,info,ilev) select case(what) case(mld_smoother_type_,mld_sub_solve_,mld_sub_restr_,mld_sub_prol_,& & mld_sub_ren_,mld_sub_ovr_,mld_sub_fillin_,mld_smoother_sweeps_) - p%baseprecv(ilev_)%iprcparm(what) = val + p%precv(ilev_)%prec%iprcparm(what) = val case default write(0,*) name,': Error: invalid WHAT' info = -2 @@ -144,23 +150,25 @@ subroutine mld_zprecseti(p,what,val,info,ilev) select case(what) case(mld_smoother_type_,mld_sub_solve_,mld_sub_restr_,mld_sub_prol_,& & mld_sub_ren_,mld_sub_ovr_,mld_sub_fillin_,& - & mld_smoother_sweeps_,mld_ml_type_,mld_aggr_alg_,mld_aggr_kind_,& + & mld_smoother_sweeps_) + p%precv(ilev_)%prec%iprcparm(what) = val + case(mld_ml_type_,mld_aggr_alg_,mld_aggr_kind_,& & mld_smoother_pos_,mld_aggr_omega_alg_,mld_aggr_eig_) - p%baseprecv(ilev_)%iprcparm(what) = val + p%precv(ilev_)%iprcparm(what) = val case(mld_coarse_mat_) if (ilev_ /= nlev_ .and. val /= mld_distr_mat_) then write(0,*) name,': Error: Inconsistent specification of WHAT vs. ILEV' info = -2 return end if - p%baseprecv(ilev_)%iprcparm(mld_coarse_mat_) = val + p%precv(ilev_)%iprcparm(mld_coarse_mat_) = val case(mld_coarse_subsolve_) if (ilev_ /= nlev_) then write(0,*) name,': Error: Inconsistent specification of WHAT vs. ILEV' info = -2 return end if - p%baseprecv(ilev_)%iprcparm(mld_sub_solve_) = val + p%precv(ilev_)%iprcparm(mld_sub_solve_) = val case(mld_coarse_solve_) if (ilev_ /= nlev_) then write(0,*) name,': Error: Inconsistent specification of WHAT vs. ILEV' @@ -169,15 +177,15 @@ subroutine mld_zprecseti(p,what,val,info,ilev) end if if (nlev_ > 1) then - p%baseprecv(nlev_)%iprcparm(mld_coarse_solve_) = val - p%baseprecv(nlev_)%iprcparm(mld_smoother_type_) = mld_bjac_ - p%baseprecv(nlev_)%iprcparm(mld_coarse_mat_) = mld_distr_mat_ + p%precv(nlev_)%iprcparm(mld_coarse_solve_) = val + p%precv(nlev_)%prec%iprcparm(mld_smoother_type_) = mld_bjac_ + p%precv(nlev_)%iprcparm(mld_coarse_mat_) = mld_distr_mat_ select case (val) case(mld_umf_, mld_slu_) - p%baseprecv(nlev_)%iprcparm(mld_coarse_mat_) = mld_repl_mat_ - p%baseprecv(nlev_)%iprcparm(mld_sub_solve_) = val + p%precv(nlev_)%iprcparm(mld_coarse_mat_) = mld_repl_mat_ + p%precv(nlev_)%prec%iprcparm(mld_sub_solve_) = val case(mld_sludist_) - p%baseprecv(nlev_)%iprcparm(mld_sub_solve_) = val + p%precv(nlev_)%prec%iprcparm(mld_sub_solve_) = val end select endif case(mld_coarse_sweeps_) @@ -186,14 +194,14 @@ subroutine mld_zprecseti(p,what,val,info,ilev) info = -2 return end if - p%baseprecv(ilev_)%iprcparm(mld_smoother_sweeps_) = val + p%precv(ilev_)%prec%iprcparm(mld_smoother_sweeps_) = val case(mld_coarse_fillin_) if (ilev_ /= nlev_) then write(0,*) name,': Error: Inconsistent specification of WHAT vs. ILEV' info = -2 return end if - p%baseprecv(ilev_)%iprcparm(mld_sub_fillin_) = val + p%precv(ilev_)%prec%iprcparm(mld_sub_fillin_) = val case default write(0,*) name,': Error: invalid WHAT' info = -2 @@ -211,35 +219,35 @@ subroutine mld_zprecseti(p,what,val,info,ilev) & mld_sub_ren_,mld_sub_ovr_,mld_sub_fillin_,& & mld_smoother_sweeps_) do ilev_=1,max(1,nlev_-1) - if (.not.allocated(p%baseprecv(ilev_)%iprcparm)) then + if (.not.allocated(p%precv(ilev_)%iprcparm)) then write(0,*) name,& &': Error: uninitialized preconditioner component, should call MLD_PRECINIT' info = -1 return endif - p%baseprecv(ilev_)%iprcparm(what) = val + p%precv(ilev_)%prec%iprcparm(what) = val end do case(mld_ml_type_,mld_aggr_alg_,mld_aggr_kind_,& & mld_smoother_pos_,mld_aggr_omega_alg_,mld_aggr_eig_) do ilev_=2,nlev_ - if (.not.allocated(p%baseprecv(ilev_)%iprcparm)) then + if (.not.allocated(p%precv(ilev_)%iprcparm)) then write(0,*) name,& &': Error: uninitialized preconditioner component, should call MLD_PRECINIT' info = -1 return endif - p%baseprecv(ilev_)%iprcparm(what) = val + p%precv(ilev_)%iprcparm(what) = val end do case(mld_coarse_mat_) - if (.not.allocated(p%baseprecv(nlev_)%iprcparm)) then + if (.not.allocated(p%precv(nlev_)%iprcparm)) then write(0,*) name,& & ': Error: uninitialized preconditioner component, should call MLD_PRECINIT' info = -1 return endif - if (nlev_ > 1) p%baseprecv(nlev_)%iprcparm(mld_coarse_mat_) = val + if (nlev_ > 1) p%precv(nlev_)%iprcparm(mld_coarse_mat_) = val case(mld_coarse_solve_) - if (.not.allocated(p%baseprecv(nlev_)%iprcparm)) then + if (.not.allocated(p%precv(nlev_)%iprcparm)) then write(0,*) name,& &': Error: uninitialized preconditioner component, should call MLD_PRECINIT' info = -1 @@ -247,42 +255,42 @@ subroutine mld_zprecseti(p,what,val,info,ilev) endif if (nlev_ > 1) then - p%baseprecv(nlev_)%iprcparm(mld_coarse_solve_) = val - p%baseprecv(nlev_)%iprcparm(mld_smoother_type_) = mld_bjac_ - p%baseprecv(nlev_)%iprcparm(mld_coarse_mat_) = mld_distr_mat_ + p%precv(nlev_)%iprcparm(mld_coarse_solve_) = val + p%precv(nlev_)%prec%iprcparm(mld_smoother_type_) = mld_bjac_ + p%precv(nlev_)%iprcparm(mld_coarse_mat_) = mld_distr_mat_ select case (val) case(mld_umf_, mld_slu_) - p%baseprecv(nlev_)%iprcparm(mld_coarse_mat_) = mld_repl_mat_ - p%baseprecv(nlev_)%iprcparm(mld_sub_solve_) = val + p%precv(nlev_)%iprcparm(mld_coarse_mat_) = mld_repl_mat_ + p%precv(nlev_)%prec%iprcparm(mld_sub_solve_) = val case(mld_sludist_) - p%baseprecv(nlev_)%iprcparm(mld_sub_solve_) = val + p%precv(nlev_)%prec%iprcparm(mld_sub_solve_) = val end select endif case(mld_coarse_subsolve_) - if (.not.allocated(p%baseprecv(nlev_)%iprcparm)) then + if (.not.allocated(p%precv(nlev_)%iprcparm)) then write(0,*) name,& &': Error: uninitialized preconditioner component, should call MLD_PRECINIT' info = -1 return end if - if (nlev_ > 1) p%baseprecv(nlev_)%iprcparm(mld_sub_solve_) = val + if (nlev_ > 1) p%precv(nlev_)%prec%iprcparm(mld_sub_solve_) = val case(mld_coarse_sweeps_) - if (.not.allocated(p%baseprecv(nlev_)%iprcparm)) then + if (.not.allocated(p%precv(nlev_)%iprcparm)) then write(0,*) name,& &': Error: uninitialized preconditioner component, should call MLD_PRECINIT' info = -1 return endif - if (nlev_ > 1) p%baseprecv(nlev_)%iprcparm(mld_smoother_sweeps_) = val + if (nlev_ > 1) p%precv(nlev_)%prec%iprcparm(mld_smoother_sweeps_) = val case(mld_coarse_fillin_) - if (.not.allocated(p%baseprecv(nlev_)%iprcparm)) then + if (.not.allocated(p%precv(nlev_)%iprcparm)) then write(0,*) name,& &': Error: uninitialized preconditioner component, should call MLD_PRECINIT' info = -1 return endif - if (nlev_ > 1) p%baseprecv(nlev_)%iprcparm(mld_sub_fillin_) = val + if (nlev_ > 1) p%precv(nlev_)%prec%iprcparm(mld_sub_fillin_) = val case default write(0,*) name,': Error: invalid WHAT' info = -2 @@ -353,11 +361,11 @@ subroutine mld_zprecsetc(p,what,string,info,ilev) info = 0 - if (.not.allocated(p%baseprecv)) then + if (.not.allocated(p%precv)) then info = 3111 return endif - nlev_ = size(p%baseprecv) + nlev_ = size(p%precv) if (present(ilev)) then ilev_ = ilev @@ -370,7 +378,7 @@ subroutine mld_zprecsetc(p,what,string,info,ilev) info = -1 return endif - if (.not.allocated(p%baseprecv(ilev_)%iprcparm)) then + if (.not.allocated(p%precv(ilev_)%iprcparm)) then write(0,*) name,': Error: uninitialized preconditioner component, should call MLD_PRECINIT' info = 3111 return @@ -450,19 +458,19 @@ subroutine mld_zprecsetr(p,what,val,info,ilev) ilev_ = 1 end if - if (.not.allocated(p%baseprecv)) then + if (.not.allocated(p%precv)) then write(0,*) name,': Error: uninitialized preconditioner, should call MLD_PRECINIT' info = 3111 return endif - nlev_ = size(p%baseprecv) + nlev_ = size(p%precv) if ((ilev_<1).or.(ilev_ > nlev_)) then write(0,*) name,': Error: invalid ILEV/NLEV combination',ilev_, nlev_ info = -1 return endif - if (.not.allocated(p%baseprecv(ilev_)%rprcparm)) then + if (.not.allocated(p%precv(ilev_)%rprcparm)) then write(0,*) name,': Error: uninitialized preconditioner component, should call MLD_PRECINIT' info = 3111 return @@ -479,7 +487,7 @@ subroutine mld_zprecsetr(p,what,val,info,ilev) ! select case(what) case(mld_sub_iluthrs_) - p%baseprecv(ilev_)%rprcparm(what) = val + p%precv(ilev_)%prec%rprcparm(what) = val case default write(0,*) name,': Error: invalid WHAT' info = -2 @@ -487,8 +495,10 @@ subroutine mld_zprecsetr(p,what,val,info,ilev) else if (ilev_ > 1) then select case(what) - case(mld_aggr_omega_val_,mld_aggr_thresh_,mld_sub_iluthrs_) - p%baseprecv(ilev_)%rprcparm(what) = val + case(mld_sub_iluthrs_) + p%precv(ilev_)%prec%rprcparm(what) = val + case(mld_aggr_omega_val_,mld_aggr_thresh_) + p%precv(ilev_)%rprcparm(what) = val case default write(0,*) name,': Error: invalid WHAT' info = -2 @@ -503,38 +513,38 @@ subroutine mld_zprecsetr(p,what,val,info,ilev) select case(what) case(mld_sub_iluthrs_) do ilev_=1,nlev_ - if (.not.allocated(p%baseprecv(ilev_)%rprcparm)) then + if (.not.allocated(p%precv(ilev_)%rprcparm)) then write(0,*) name,': Error: uninitialized preconditioner component, should call MLD_PRECINIT' info = -1 return endif - p%baseprecv(ilev_)%rprcparm(what) = val + p%precv(ilev_)%prec%rprcparm(what) = val end do case(mld_coarse_iluthrs_) ilev_=nlev_ - if (.not.allocated(p%baseprecv(ilev_)%rprcparm)) then + if (.not.allocated(p%precv(ilev_)%rprcparm)) then write(0,*) name,': Error: uninitialized preconditioner component, should call MLD_PRECINIT' info = -1 return endif - p%baseprecv(ilev_)%rprcparm(mld_sub_iluthrs_) = val + p%precv(ilev_)%prec%rprcparm(mld_sub_iluthrs_) = val case(mld_aggr_omega_val_) do ilev_=2,nlev_ - if (.not.allocated(p%baseprecv(ilev_)%rprcparm)) then + if (.not.allocated(p%precv(ilev_)%rprcparm)) then write(0,*) name,': Error: uninitialized preconditioner component, should call MLD_PRECINIT' info = -1 return endif - p%baseprecv(ilev_)%rprcparm(what) = val + p%precv(ilev_)%rprcparm(what) = val end do case(mld_aggr_thresh_) do ilev_=2,nlev_ - if (.not.allocated(p%baseprecv(ilev_)%rprcparm)) then + if (.not.allocated(p%precv(ilev_)%rprcparm)) then write(0,*) name,': Error: uninitialized preconditioner component, should call MLD_PRECINIT' info = -1 return endif - p%baseprecv(ilev_)%rprcparm(what) = val + p%precv(ilev_)%rprcparm(what) = val end do case default write(0,*) name,': Error: invalid WHAT'