From d92b6c02cf6e6546d6d15a7fad353eb41ce6f070 Mon Sep 17 00:00:00 2001 From: Cirdans-Home Date: Mon, 6 Apr 2020 14:00:21 +0200 Subject: [PATCH] Added interface (and C interface) to is_asb() for sparse matrices --- base/modules/psblas/psb_c_psblas_mod.F90 | 11 +++++ base/modules/psblas/psb_d_psblas_mod.F90 | 11 +++++ base/modules/psblas/psb_s_psblas_mod.F90 | 11 +++++ base/modules/psblas/psb_z_psblas_mod.F90 | 11 +++++ base/psblas/psb_cgetmatinfo.f90 | 54 ++++++++++++++++++++++++ base/psblas/psb_dgetmatinfo.f90 | 54 ++++++++++++++++++++++++ base/psblas/psb_sgetmatinfo.f90 | 54 ++++++++++++++++++++++++ base/psblas/psb_zgetmatinfo.f90 | 54 ++++++++++++++++++++++++ cbind/base/psb_c_cbase.h | 1 + cbind/base/psb_c_dbase.h | 1 + cbind/base/psb_c_psblas_cbind_mod.f90 | 25 +++++++++++ cbind/base/psb_c_sbase.h | 1 + cbind/base/psb_c_zbase.h | 1 + cbind/base/psb_d_psblas_cbind_mod.f90 | 25 +++++++++++ cbind/base/psb_s_psblas_cbind_mod.f90 | 25 +++++++++++ cbind/base/psb_z_psblas_cbind_mod.f90 | 25 +++++++++++ 16 files changed, 364 insertions(+) diff --git a/base/modules/psblas/psb_c_psblas_mod.F90 b/base/modules/psblas/psb_c_psblas_mod.F90 index 05c0b895..9bf20758 100644 --- a/base/modules/psblas/psb_c_psblas_mod.F90 +++ b/base/modules/psblas/psb_c_psblas_mod.F90 @@ -610,4 +610,15 @@ module psb_c_psblas_mod end function end interface + interface psb_is_matasb + function psb_c_is_matasb(a,desc_a,info) result(res) + import :: psb_desc_type, psb_cspmat_type, & + & psb_spk_, psb_ipk_ + logical :: res + type(psb_cspmat_type), intent(in) :: a + type(psb_desc_type), intent (in) :: desc_a + integer(psb_ipk_), intent(out) :: info + end function + end interface + end module psb_c_psblas_mod diff --git a/base/modules/psblas/psb_d_psblas_mod.F90 b/base/modules/psblas/psb_d_psblas_mod.F90 index 165ee4c1..ac4be69e 100644 --- a/base/modules/psblas/psb_d_psblas_mod.F90 +++ b/base/modules/psblas/psb_d_psblas_mod.F90 @@ -645,4 +645,15 @@ module psb_d_psblas_mod end function end interface + interface psb_is_matasb + function psb_d_is_matasb(a,desc_a,info) result(res) + import :: psb_desc_type, psb_dspmat_type, & + & psb_dpk_, psb_ipk_ + logical :: res + type(psb_dspmat_type), intent(in) :: a + type(psb_desc_type), intent (in) :: desc_a + integer(psb_ipk_), intent(out) :: info + end function + end interface + end module psb_d_psblas_mod diff --git a/base/modules/psblas/psb_s_psblas_mod.F90 b/base/modules/psblas/psb_s_psblas_mod.F90 index d1b04e75..547b5e6e 100644 --- a/base/modules/psblas/psb_s_psblas_mod.F90 +++ b/base/modules/psblas/psb_s_psblas_mod.F90 @@ -645,4 +645,15 @@ module psb_s_psblas_mod end function end interface + interface psb_is_matasb + function psb_s_is_matasb(a,desc_a,info) result(res) + import :: psb_desc_type, psb_sspmat_type, & + & psb_spk_, psb_ipk_ + logical :: res + type(psb_sspmat_type), intent(in) :: a + type(psb_desc_type), intent (in) :: desc_a + integer(psb_ipk_), intent(out) :: info + end function + end interface + end module psb_s_psblas_mod diff --git a/base/modules/psblas/psb_z_psblas_mod.F90 b/base/modules/psblas/psb_z_psblas_mod.F90 index e16a4060..93940a16 100644 --- a/base/modules/psblas/psb_z_psblas_mod.F90 +++ b/base/modules/psblas/psb_z_psblas_mod.F90 @@ -610,4 +610,15 @@ module psb_z_psblas_mod end function end interface + interface psb_is_matasb + function psb_z_is_matasb(a,desc_a,info) result(res) + import :: psb_desc_type, psb_zspmat_type, & + & psb_dpk_, psb_ipk_ + logical :: res + type(psb_zspmat_type), intent(in) :: a + type(psb_desc_type), intent (in) :: desc_a + integer(psb_ipk_), intent(out) :: info + end function + end interface + end module psb_z_psblas_mod diff --git a/base/psblas/psb_cgetmatinfo.f90 b/base/psblas/psb_cgetmatinfo.f90 index e2516d04..70cadcea 100644 --- a/base/psblas/psb_cgetmatinfo.f90 +++ b/base/psblas/psb_cgetmatinfo.f90 @@ -144,3 +144,57 @@ function psb_c_is_matupd(a,desc_a,info) result(res) return end function + +function psb_c_is_matasb(a,desc_a,info) result(res) + use psb_base_mod, psb_protect_name => psb_c_is_matasb + use psi_mod + + implicit none + + logical :: res + type(psb_cspmat_type), intent(in) :: a + type(psb_desc_type), intent (in) :: desc_a + integer(psb_ipk_), intent(out) :: info + + ! locals + integer(psb_ipk_) :: ictxt, np, me,& + & err_act, iia, jja + integer(psb_lpk_) :: m,n,ia,ja,localnnz + character(len=20) :: name, ch_err + ! + name='psb_cis_matasb' + info=psb_success_ + call psb_erractionsave(err_act) + if (psb_errstatus_fatal()) then + info = psb_err_internal_error_ ; goto 9999 + end if + + ictxt=desc_a%get_context() + call psb_info(ictxt, me, np) + if (np == -1) then + info = psb_err_context_error_ + call psb_errpush(info,name) + goto 9999 + endif + + m = desc_a%get_global_rows() + n = desc_a%get_global_cols() + + ! Check for matrix correctness + call psb_chkmat(m,n,ia,ja,desc_a,info,iia,jja) + if(info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='psb_chkmat' + call psb_errpush(info,name,a_err=ch_err) + goto 9999 + end if + + res = a%is_asb() + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(ictxt,err_act) + + return +end function diff --git a/base/psblas/psb_dgetmatinfo.f90 b/base/psblas/psb_dgetmatinfo.f90 index 031ad63c..59b38bd0 100644 --- a/base/psblas/psb_dgetmatinfo.f90 +++ b/base/psblas/psb_dgetmatinfo.f90 @@ -144,3 +144,57 @@ function psb_d_is_matupd(a,desc_a,info) result(res) return end function + +function psb_d_is_matasb(a,desc_a,info) result(res) + use psb_base_mod, psb_protect_name => psb_d_is_matasb + use psi_mod + + implicit none + + logical :: res + type(psb_dspmat_type), intent(in) :: a + type(psb_desc_type), intent (in) :: desc_a + integer(psb_ipk_), intent(out) :: info + + ! locals + integer(psb_ipk_) :: ictxt, np, me,& + & err_act, iia, jja + integer(psb_lpk_) :: m,n,ia,ja,localnnz + character(len=20) :: name, ch_err + ! + name='psb_dis_matasb' + info=psb_success_ + call psb_erractionsave(err_act) + if (psb_errstatus_fatal()) then + info = psb_err_internal_error_ ; goto 9999 + end if + + ictxt=desc_a%get_context() + call psb_info(ictxt, me, np) + if (np == -1) then + info = psb_err_context_error_ + call psb_errpush(info,name) + goto 9999 + endif + + m = desc_a%get_global_rows() + n = desc_a%get_global_cols() + + ! Check for matrix correctness + call psb_chkmat(m,n,ia,ja,desc_a,info,iia,jja) + if(info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='psb_chkmat' + call psb_errpush(info,name,a_err=ch_err) + goto 9999 + end if + + res = a%is_asb() + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(ictxt,err_act) + + return +end function diff --git a/base/psblas/psb_sgetmatinfo.f90 b/base/psblas/psb_sgetmatinfo.f90 index a9a4d132..f544a272 100644 --- a/base/psblas/psb_sgetmatinfo.f90 +++ b/base/psblas/psb_sgetmatinfo.f90 @@ -144,3 +144,57 @@ function psb_s_is_matupd(a,desc_a,info) result(res) return end function + +function psb_s_is_matasb(a,desc_a,info) result(res) + use psb_base_mod, psb_protect_name => psb_s_is_matasb + use psi_mod + + implicit none + + logical :: res + type(psb_sspmat_type), intent(in) :: a + type(psb_desc_type), intent (in) :: desc_a + integer(psb_ipk_), intent(out) :: info + + ! locals + integer(psb_ipk_) :: ictxt, np, me,& + & err_act, iia, jja + integer(psb_lpk_) :: m,n,ia,ja,localnnz + character(len=20) :: name, ch_err + ! + name='psb_sis_matasb' + info=psb_success_ + call psb_erractionsave(err_act) + if (psb_errstatus_fatal()) then + info = psb_err_internal_error_ ; goto 9999 + end if + + ictxt=desc_a%get_context() + call psb_info(ictxt, me, np) + if (np == -1) then + info = psb_err_context_error_ + call psb_errpush(info,name) + goto 9999 + endif + + m = desc_a%get_global_rows() + n = desc_a%get_global_cols() + + ! Check for matrix correctness + call psb_chkmat(m,n,ia,ja,desc_a,info,iia,jja) + if(info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='psb_chkmat' + call psb_errpush(info,name,a_err=ch_err) + goto 9999 + end if + + res = a%is_asb() + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(ictxt,err_act) + + return +end function diff --git a/base/psblas/psb_zgetmatinfo.f90 b/base/psblas/psb_zgetmatinfo.f90 index 6d1ec857..8bbb5bcc 100644 --- a/base/psblas/psb_zgetmatinfo.f90 +++ b/base/psblas/psb_zgetmatinfo.f90 @@ -144,3 +144,57 @@ function psb_z_is_matupd(a,desc_a,info) result(res) return end function + +function psb_z_is_matasb(a,desc_a,info) result(res) + use psb_base_mod, psb_protect_name => psb_z_is_matasb + use psi_mod + + implicit none + + logical :: res + type(psb_zspmat_type), intent(in) :: a + type(psb_desc_type), intent (in) :: desc_a + integer(psb_ipk_), intent(out) :: info + + ! locals + integer(psb_ipk_) :: ictxt, np, me,& + & err_act, iia, jja + integer(psb_lpk_) :: m,n,ia,ja,localnnz + character(len=20) :: name, ch_err + ! + name='psb_zis_matasb' + info=psb_success_ + call psb_erractionsave(err_act) + if (psb_errstatus_fatal()) then + info = psb_err_internal_error_ ; goto 9999 + end if + + ictxt=desc_a%get_context() + call psb_info(ictxt, me, np) + if (np == -1) then + info = psb_err_context_error_ + call psb_errpush(info,name) + goto 9999 + endif + + m = desc_a%get_global_rows() + n = desc_a%get_global_cols() + + ! Check for matrix correctness + call psb_chkmat(m,n,ia,ja,desc_a,info,iia,jja) + if(info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='psb_chkmat' + call psb_errpush(info,name,a_err=ch_err) + goto 9999 + end if + + res = a%is_asb() + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(ictxt,err_act) + + return +end function diff --git a/cbind/base/psb_c_cbase.h b/cbind/base/psb_c_cbase.h index 0c76df49..1c212366 100644 --- a/cbind/base/psb_c_cbase.h +++ b/cbind/base/psb_c_cbase.h @@ -42,6 +42,7 @@ psb_i_t psb_c_cmat_get_nrows(psb_c_cspmat *mh); psb_i_t psb_c_cmat_get_ncols(psb_c_cspmat *mh); psb_l_t psb_c_cnnz(psb_c_cspmat *mh,psb_c_descriptor *cdh); bool psb_c_cis_matupd(psb_c_cspmat *mh,psb_c_descriptor *cdh); +bool psb_c_cis_matasb(psb_c_cspmat *mh,psb_c_descriptor *cdh); /* psb_i_t psb_c_cspasb_opt(psb_c_cspmat *mh, psb_c_descriptor *cdh, */ /* const char *afmt, psb_i_t upd, psb_i_t dupl); */ diff --git a/cbind/base/psb_c_dbase.h b/cbind/base/psb_c_dbase.h index 3c3ac712..94dd92be 100644 --- a/cbind/base/psb_c_dbase.h +++ b/cbind/base/psb_c_dbase.h @@ -42,6 +42,7 @@ psb_i_t psb_c_dmat_get_nrows(psb_c_dspmat *mh); psb_i_t psb_c_dmat_get_ncols(psb_c_dspmat *mh); psb_l_t psb_c_dnnz(psb_c_dspmat *mh,psb_c_descriptor *cdh); bool psb_c_dis_matupd(psb_c_dspmat *mh,psb_c_descriptor *cdh); +bool psb_c_dis_matasb(psb_c_dspmat *mh,psb_c_descriptor *cdh); /* psb_i_t psb_c_dspasb_opt(psb_c_dspmat *mh, psb_c_descriptor *cdh, */ /* const char *afmt, psb_i_t upd, psb_i_t dupl); */ diff --git a/cbind/base/psb_c_psblas_cbind_mod.f90 b/cbind/base/psb_c_psblas_cbind_mod.f90 index dfd9dde1..5171d0ab 100644 --- a/cbind/base/psb_c_psblas_cbind_mod.f90 +++ b/cbind/base/psb_c_psblas_cbind_mod.f90 @@ -922,4 +922,29 @@ contains res = psb_is_matupd(ap,descp,info) end function + function psb_c_cis_matasb(ah,cdh) bind(c) result(res) + implicit none + logical :: res + + type(psb_c_cspmat) :: ah + type(psb_c_descriptor) :: cdh + + type(psb_desc_type), pointer :: descp + type(psb_cspmat_type), pointer :: ap + integer(psb_c_ipk_) :: info + + if (c_associated(cdh%item)) then + call c_f_pointer(cdh%item,descp) + else + return + end if + if (c_associated(ah%item)) then + call c_f_pointer(ah%item,ap) + else + return + end if + + res = psb_is_matasb(ap,descp,info) + end function + end module psb_c_psblas_cbind_mod diff --git a/cbind/base/psb_c_sbase.h b/cbind/base/psb_c_sbase.h index 2bd285b2..961766cd 100644 --- a/cbind/base/psb_c_sbase.h +++ b/cbind/base/psb_c_sbase.h @@ -42,6 +42,7 @@ psb_i_t psb_c_smat_get_nrows(psb_c_sspmat *mh); psb_i_t psb_c_smat_get_ncols(psb_c_sspmat *mh); psb_l_t psb_c_snnz(psb_c_sspmat *mh,psb_c_descriptor *cdh); bool psb_c_sis_matupd(psb_c_sspmat *mh,psb_c_descriptor *cdh); +bool psb_c_sis_matasb(psb_c_sspmat *mh,psb_c_descriptor *cdh); /* psb_i_t psb_c_sspasb_opt(psb_c_sspmat *mh, psb_c_descriptor *cdh, */ /* const char *afmt, psb_i_t upd, psb_i_t dupl); */ diff --git a/cbind/base/psb_c_zbase.h b/cbind/base/psb_c_zbase.h index 94cf0209..f5ca30f3 100644 --- a/cbind/base/psb_c_zbase.h +++ b/cbind/base/psb_c_zbase.h @@ -42,6 +42,7 @@ psb_i_t psb_c_zmat_get_nrows(psb_c_zspmat *mh); psb_i_t psb_c_zmat_get_ncols(psb_c_zspmat *mh); psb_l_t psb_c_znnz(psb_c_zspmat *mh,psb_c_descriptor *cdh); bool psb_c_zis_matupd(psb_c_zspmat *mh,psb_c_descriptor *cdh); +bool psb_c_zis_matasb(psb_c_zspmat *mh,psb_c_descriptor *cdh); /* psb_i_t psb_c_zspasb_opt(psb_c_zspmat *mh, psb_c_descriptor *cdh, */ /* const char *afmt, psb_i_t upd, psb_i_t dupl); */ diff --git a/cbind/base/psb_d_psblas_cbind_mod.f90 b/cbind/base/psb_d_psblas_cbind_mod.f90 index 09f7e595..152d5f55 100644 --- a/cbind/base/psb_d_psblas_cbind_mod.f90 +++ b/cbind/base/psb_d_psblas_cbind_mod.f90 @@ -1023,4 +1023,29 @@ contains res = psb_is_matupd(ap,descp,info) end function + function psb_c_dis_matasb(ah,cdh) bind(c) result(res) + implicit none + logical :: res + + type(psb_c_dspmat) :: ah + type(psb_c_descriptor) :: cdh + + type(psb_desc_type), pointer :: descp + type(psb_dspmat_type), pointer :: ap + integer(psb_c_ipk_) :: info + + if (c_associated(cdh%item)) then + call c_f_pointer(cdh%item,descp) + else + return + end if + if (c_associated(ah%item)) then + call c_f_pointer(ah%item,ap) + else + return + end if + + res = psb_is_matasb(ap,descp,info) + end function + end module psb_d_psblas_cbind_mod diff --git a/cbind/base/psb_s_psblas_cbind_mod.f90 b/cbind/base/psb_s_psblas_cbind_mod.f90 index 92b76b2f..c5a3e686 100644 --- a/cbind/base/psb_s_psblas_cbind_mod.f90 +++ b/cbind/base/psb_s_psblas_cbind_mod.f90 @@ -1023,4 +1023,29 @@ contains res = psb_is_matupd(ap,descp,info) end function + function psb_c_sis_matasb(ah,cdh) bind(c) result(res) + implicit none + logical :: res + + type(psb_c_sspmat) :: ah + type(psb_c_descriptor) :: cdh + + type(psb_desc_type), pointer :: descp + type(psb_sspmat_type), pointer :: ap + integer(psb_c_ipk_) :: info + + if (c_associated(cdh%item)) then + call c_f_pointer(cdh%item,descp) + else + return + end if + if (c_associated(ah%item)) then + call c_f_pointer(ah%item,ap) + else + return + end if + + res = psb_is_matasb(ap,descp,info) + end function + end module psb_s_psblas_cbind_mod diff --git a/cbind/base/psb_z_psblas_cbind_mod.f90 b/cbind/base/psb_z_psblas_cbind_mod.f90 index d9cc0e50..d6f853b8 100644 --- a/cbind/base/psb_z_psblas_cbind_mod.f90 +++ b/cbind/base/psb_z_psblas_cbind_mod.f90 @@ -922,4 +922,29 @@ contains res = psb_is_matupd(ap,descp,info) end function + function psb_c_zis_matasb(ah,cdh) bind(c) result(res) + implicit none + logical :: res + + type(psb_c_zspmat) :: ah + type(psb_c_descriptor) :: cdh + + type(psb_desc_type), pointer :: descp + type(psb_zspmat_type), pointer :: ap + integer(psb_c_ipk_) :: info + + if (c_associated(cdh%item)) then + call c_f_pointer(cdh%item,descp) + else + return + end if + if (c_associated(ah%item)) then + call c_f_pointer(ah%item,ap) + else + return + end if + + res = psb_is_matasb(ap,descp,info) + end function + end module psb_z_psblas_cbind_mod