From c38660c76c0bf1271efe9cb4d1830bf77dd286be Mon Sep 17 00:00:00 2001 From: Cirdans-Home Date: Tue, 6 Jul 2021 16:54:05 +0200 Subject: [PATCH] Added function psb_c_g2l --- cbind/base/psb_c_base.h | 2 ++ cbind/base/psb_c_serial_cbind_mod.F90 | 33 +++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/cbind/base/psb_c_base.h b/cbind/base/psb_c_base.h index e054daf6..0e5a09f9 100644 --- a/cbind/base/psb_c_base.h +++ b/cbind/base/psb_c_base.h @@ -102,6 +102,8 @@ extern "C" { psb_i_t psb_c_cd_get_local_cols(psb_c_descriptor *cd); psb_l_t psb_c_cd_get_global_rows(psb_c_descriptor *cd); psb_i_t psb_c_cd_get_global_indices(psb_l_t idx[], psb_i_t nidx, bool owned, psb_c_descriptor *cd); + psb_i_t psb_c_g2l(psb_c_descriptor *cdh,psb_l_t gindex,bool cowned); + /* legal values for upd argument */ #define psb_upd_srch_ 98764 diff --git a/cbind/base/psb_c_serial_cbind_mod.F90 b/cbind/base/psb_c_serial_cbind_mod.F90 index b298d84a..dba41b67 100644 --- a/cbind/base/psb_c_serial_cbind_mod.F90 +++ b/cbind/base/psb_c_serial_cbind_mod.F90 @@ -204,5 +204,38 @@ contains end function psb_c_cvect_set_vect + function psb_c_g2l(cdh,gindex,cowned) bind(c) result(lindex) + use psb_base_mod + implicit none + + integer(psb_c_lpk_), value :: gindex + logical(c_bool), value :: cowned + type(psb_c_descriptor) :: cdh + integer(psb_c_ipk_) :: lindex + + type(psb_desc_type), pointer :: descp + integer(psb_ipk_) :: info, localindex, ixb, iam, np + logical :: owned + + ixb = psb_c_get_index_base() + owned = cowned + lindex = -1 + if (c_associated(cdh%item)) then + call c_f_pointer(cdh%item,descp) + else + return + end if + + call psb_info(descp%get_context(),iam,np) + if (ixb == 1) then + call descp%indxmap%g2l(gindex,localindex,info,owned=owned) + lindex = localindex + else + call descp%indxmap%g2l(gindex+(1-ixb),localindex,info,owned=owned) + lindex = localindex-(1-ixb) + endif + + end function psb_c_g2l + end module psb_c_serial_cbind_mod