From abf486077ce97fa060bf2482818e7c964a998ff6 Mon Sep 17 00:00:00 2001 From: Salvatore Filippone Date: Tue, 16 Mar 2021 16:40:33 +0100 Subject: [PATCH] New global argument in sizeof() --- prec/psb_c_prec_type.f90 | 27 ++++++++++++++++++++++----- prec/psb_d_prec_type.f90 | 27 ++++++++++++++++++++++----- prec/psb_s_prec_type.f90 | 27 ++++++++++++++++++++++----- prec/psb_z_prec_type.f90 | 27 ++++++++++++++++++++++----- 4 files changed, 88 insertions(+), 20 deletions(-) diff --git a/prec/psb_c_prec_type.f90 b/prec/psb_c_prec_type.f90 index ec7c84f3..32225d31 100644 --- a/prec/psb_c_prec_type.f90 +++ b/prec/psb_c_prec_type.f90 @@ -385,14 +385,31 @@ contains end subroutine psb_c_prec_free - function psb_cprec_sizeof(prec) result(val) + function psb_cprec_sizeof(prec, global) result(val) + implicit none class(psb_cprec_type), intent(in) :: prec - integer(psb_epk_) :: val - integer(psb_ipk_) :: i + 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 - if (allocated(prec%prec)) then - val = val + prec%prec%sizeof() + val = val + psb_sizeof_int + if (allocated(prec%precv)) then + do i=1, size(prec%precv) + 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 psb_cprec_sizeof diff --git a/prec/psb_d_prec_type.f90 b/prec/psb_d_prec_type.f90 index 32d17b4a..1c697570 100644 --- a/prec/psb_d_prec_type.f90 +++ b/prec/psb_d_prec_type.f90 @@ -385,14 +385,31 @@ contains end subroutine psb_d_prec_free - function psb_dprec_sizeof(prec) result(val) + function psb_dprec_sizeof(prec, global) result(val) + implicit none class(psb_dprec_type), intent(in) :: prec - integer(psb_epk_) :: val - integer(psb_ipk_) :: i + 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 - if (allocated(prec%prec)) then - val = val + prec%prec%sizeof() + val = val + psb_sizeof_int + if (allocated(prec%precv)) then + do i=1, size(prec%precv) + 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 psb_dprec_sizeof diff --git a/prec/psb_s_prec_type.f90 b/prec/psb_s_prec_type.f90 index 07f78cca..1785572a 100644 --- a/prec/psb_s_prec_type.f90 +++ b/prec/psb_s_prec_type.f90 @@ -385,14 +385,31 @@ contains end subroutine psb_s_prec_free - function psb_sprec_sizeof(prec) result(val) + function psb_sprec_sizeof(prec, global) result(val) + implicit none class(psb_sprec_type), intent(in) :: prec - integer(psb_epk_) :: val - integer(psb_ipk_) :: i + 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 - if (allocated(prec%prec)) then - val = val + prec%prec%sizeof() + val = val + psb_sizeof_int + if (allocated(prec%precv)) then + do i=1, size(prec%precv) + 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 psb_sprec_sizeof diff --git a/prec/psb_z_prec_type.f90 b/prec/psb_z_prec_type.f90 index a5f8d0d9..805a93e4 100644 --- a/prec/psb_z_prec_type.f90 +++ b/prec/psb_z_prec_type.f90 @@ -385,14 +385,31 @@ contains end subroutine psb_z_prec_free - function psb_zprec_sizeof(prec) result(val) + function psb_zprec_sizeof(prec, global) result(val) + implicit none class(psb_zprec_type), intent(in) :: prec - integer(psb_epk_) :: val - integer(psb_ipk_) :: i + 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 - if (allocated(prec%prec)) then - val = val + prec%prec%sizeof() + val = val + psb_sizeof_int + if (allocated(prec%precv)) then + do i=1, size(prec%precv) + 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 psb_zprec_sizeof