From 1159659b4f795be951a8b4c23153174af3f3bc3c Mon Sep 17 00:00:00 2001 From: Salvatore Filippone Date: Mon, 15 Mar 2021 15:24:22 +0100 Subject: [PATCH] New global option for sizeof() --- amgprec/amg_c_prec_type.f90 | 20 ++++++++++++++++++-- amgprec/amg_d_prec_type.f90 | 20 ++++++++++++++++++-- amgprec/amg_s_prec_type.f90 | 20 ++++++++++++++++++-- amgprec/amg_z_prec_type.f90 | 20 ++++++++++++++++++-- 4 files changed, 72 insertions(+), 8 deletions(-) diff --git a/amgprec/amg_c_prec_type.f90 b/amgprec/amg_c_prec_type.f90 index 8899c2ac..4b28f65f 100644 --- a/amgprec/amg_c_prec_type.f90 +++ b/amgprec/amg_c_prec_type.f90 @@ -425,11 +425,22 @@ contains end if end function amg_c_get_nzeros - function amg_cprec_sizeof(prec) result(val) + function amg_cprec_sizeof(prec, global) result(val) implicit none class(amg_cprec_type), intent(in) :: prec - integer(psb_epk_) :: val + logical, intent(in), optional :: global + integer(psb_epk_) :: val integer(psb_ipk_) :: i + type(psb_ctxt_type) :: ctxt + + logical :: global_ + + if (present(global)) then + global_ = global + else + global_ = .false. + end if + val = 0 val = val + psb_sizeof_ip if (allocated(prec%precv)) then @@ -437,6 +448,11 @@ contains val = val + prec%precv(i)%sizeof() end do end if + if (global_) then + ctxt = prec%ctxt + call psb_sum(ctxt,val) + end if + end function amg_cprec_sizeof ! diff --git a/amgprec/amg_d_prec_type.f90 b/amgprec/amg_d_prec_type.f90 index ee2533b6..81fb404e 100644 --- a/amgprec/amg_d_prec_type.f90 +++ b/amgprec/amg_d_prec_type.f90 @@ -425,11 +425,22 @@ contains end if end function amg_d_get_nzeros - function amg_dprec_sizeof(prec) result(val) + function amg_dprec_sizeof(prec, global) result(val) implicit none class(amg_dprec_type), intent(in) :: prec - integer(psb_epk_) :: val + logical, intent(in), optional :: global + integer(psb_epk_) :: val integer(psb_ipk_) :: i + type(psb_ctxt_type) :: ctxt + + logical :: global_ + + if (present(global)) then + global_ = global + else + global_ = .false. + end if + val = 0 val = val + psb_sizeof_ip if (allocated(prec%precv)) then @@ -437,6 +448,11 @@ contains val = val + prec%precv(i)%sizeof() end do end if + if (global_) then + ctxt = prec%ctxt + call psb_sum(ctxt,val) + end if + end function amg_dprec_sizeof ! diff --git a/amgprec/amg_s_prec_type.f90 b/amgprec/amg_s_prec_type.f90 index d41a9395..6bef9f9e 100644 --- a/amgprec/amg_s_prec_type.f90 +++ b/amgprec/amg_s_prec_type.f90 @@ -425,11 +425,22 @@ contains end if end function amg_s_get_nzeros - function amg_sprec_sizeof(prec) result(val) + function amg_sprec_sizeof(prec, global) result(val) implicit none class(amg_sprec_type), intent(in) :: prec - integer(psb_epk_) :: val + logical, intent(in), optional :: global + integer(psb_epk_) :: val integer(psb_ipk_) :: i + type(psb_ctxt_type) :: ctxt + + logical :: global_ + + if (present(global)) then + global_ = global + else + global_ = .false. + end if + val = 0 val = val + psb_sizeof_ip if (allocated(prec%precv)) then @@ -437,6 +448,11 @@ contains val = val + prec%precv(i)%sizeof() end do end if + if (global_) then + ctxt = prec%ctxt + call psb_sum(ctxt,val) + end if + end function amg_sprec_sizeof ! diff --git a/amgprec/amg_z_prec_type.f90 b/amgprec/amg_z_prec_type.f90 index c74b51e7..da8f1631 100644 --- a/amgprec/amg_z_prec_type.f90 +++ b/amgprec/amg_z_prec_type.f90 @@ -425,11 +425,22 @@ contains end if end function amg_z_get_nzeros - function amg_zprec_sizeof(prec) result(val) + function amg_zprec_sizeof(prec, global) result(val) implicit none class(amg_zprec_type), intent(in) :: prec - integer(psb_epk_) :: val + logical, intent(in), optional :: global + integer(psb_epk_) :: val integer(psb_ipk_) :: i + type(psb_ctxt_type) :: ctxt + + logical :: global_ + + if (present(global)) then + global_ = global + else + global_ = .false. + end if + val = 0 val = val + psb_sizeof_ip if (allocated(prec%precv)) then @@ -437,6 +448,11 @@ contains val = val + prec%precv(i)%sizeof() end do end if + if (global_) then + ctxt = prec%ctxt + call psb_sum(ctxt,val) + end if + end function amg_zprec_sizeof !