From dbdbea9c6f5161d8fb1b0f077c1d15424012f14d Mon Sep 17 00:00:00 2001 From: Cirdans-Home Date: Mon, 4 May 2020 21:54:30 +0200 Subject: [PATCH] C Interfaces for ijk2idx idx2ijk redefined --- cbind/util/psb_util_cbind.h | 6 ++- cbind/util/psb_util_cbind_mod.f90 | 80 +++++++++++++++++++++++++------ 2 files changed, 70 insertions(+), 16 deletions(-) diff --git a/cbind/util/psb_util_cbind.h b/cbind/util/psb_util_cbind.h index 347d53b4..b844cd08 100644 --- a/cbind/util/psb_util_cbind.h +++ b/cbind/util/psb_util_cbind.h @@ -6,8 +6,10 @@ #include "psb_c_cutil.h" #include "psb_c_zutil.h" -psb_i_t psb_c_idx2ijk(psb_i_t *i, psb_i_t *j, psb_i_t idx, psb_i_t nx, psb_i_t ny, psb_i_t base ); -psb_i_t psb_c_lidx2ijk(psb_i_t *i, psb_i_t *j, psb_l_t idx, psb_i_t nx, psb_i_t ny, psb_i_t base ); +psb_i_t psb_c_i_idx2ijk(psb_i_t ijk[],psb_i_t idx,psb_i_t sizes[],psb_i_t modes,psb_i_t base); +psb_i_t psb_c_l_idx2ijk(psb_i_t ijk[],psb_l_t idx,psb_i_t sizes[],psb_i_t modes,psb_i_t base); +psb_i_t psb_c_i_ijk2idx(psb_i_t ijk[],psb_i_t sizes[],psb_i_t modes,psb_i_t base); +psb_l_t psb_c_l_ijk2idx(psb_i_t ijk[],psb_i_t sizes[],psb_i_t modes,psb_i_t base); #endif diff --git a/cbind/util/psb_util_cbind_mod.f90 b/cbind/util/psb_util_cbind_mod.f90 index ec2c9678..20e124bd 100644 --- a/cbind/util/psb_util_cbind_mod.f90 +++ b/cbind/util/psb_util_cbind_mod.f90 @@ -1,5 +1,6 @@ module psb_base_util_cbind_mod use iso_c_binding + use psb_util_mod use psb_cutil_cbind_mod use psb_dutil_cbind_mod use psb_sutil_cbind_mod @@ -9,39 +10,90 @@ contains ! Routines for managing indexes are type independent ! so we have them defined only in the common module - ! for all the types + ! for all the index lengths: - function psb_c_idx2ijk(i,j,idx,nx,ny,base) bind(c) result(res) + function psb_c_i_ijk2idx(ijk,sizes,modes,base) bind(c) result(idx) use psb_base_mod, only : psb_ipk_, psb_lpk_, psb_mpk_, psb_epk_ + use psb_util_mod implicit none - integer(psb_c_ipk_) :: res - integer(psb_c_ipk_), value :: idx,nx,ny,base - integer(psb_c_ipk_) :: i,j + integer(psb_c_ipk_) :: idx + integer(psb_c_ipk_), value :: modes, base + integer(psb_c_ipk_) :: ijk(modes) + integer(psb_c_ipk_) :: sizes(modes) + + integer(psb_ipk_) :: fijk(modes), fsizes(modes) + + fijk(1:modes) = ijk(1:modes) + fsizes(1:modes) = sizes(1:modes) + + call ijk2idx(idx,fijk,fsizes,base) + + end function psb_c_i_ijk2idx + + function psb_c_l_ijk2idx(ijk,sizes,modes,base) bind(c) result(idx) + use psb_base_mod, only : psb_ipk_, psb_lpk_, psb_mpk_, psb_epk_ + use psb_util_mod + implicit none + + integer(psb_c_lpk_) :: idx + integer(psb_c_ipk_), value :: modes, base + integer(psb_c_ipk_) :: ijk(modes) + integer(psb_c_ipk_) :: sizes(modes) + + integer(psb_ipk_) :: fijk(modes), fsizes(modes) + + fijk(1:modes) = ijk(1:modes) + fsizes(1:modes) = sizes(1:modes) + + call ijk2idx(idx,fijk,fsizes,base) + + end function psb_c_l_ijk2idx + + function psb_c_i_idx2ijk(ijk,idx,sizes,modes,base) bind(c) result(res) + use psb_base_mod, only : psb_ipk_, psb_lpk_, psb_mpk_, psb_epk_ + implicit none + + integer(psb_c_ipk_) :: res + integer(psb_c_ipk_), value :: idx + integer(psb_c_ipk_), value :: modes, base + integer(psb_c_ipk_) :: ijk(modes) + integer(psb_c_ipk_) :: sizes(modes) + + integer(psb_ipk_) :: fijk(modes), fsizes(modes) res = -1 - call idx2ijk(i,j,idx,nx,ny,base=base) + fsizes(1:modes) = sizes(1:modes) + call idx2ijk(fijk,idx,fsizes,base=base) + + ijk(1:modes) = fijk(1:modes) res = 0 - end function psb_c_idx2ijk + end function - function psb_c_lidx2ijk(i,j,idx,nx,ny,base) bind(c) result(res) + function psb_c_l_idx2ijk(ijk,idx,sizes,modes,base) bind(c) result(res) use psb_base_mod, only : psb_ipk_, psb_lpk_, psb_mpk_, psb_epk_ implicit none - integer(psb_c_ipk_) :: res - integer(psb_c_lpk_), value :: idx - integer(psb_c_ipk_), value :: nx,ny,base - integer(psb_c_ipk_) :: i,j + integer(psb_c_ipk_) :: res + integer(psb_c_lpk_), value :: idx + integer(psb_c_ipk_), value :: modes, base + integer(psb_c_ipk_) :: ijk(modes) + integer(psb_c_ipk_) :: sizes(modes) + + integer(psb_ipk_) :: fijk(modes), fsizes(modes) res = -1 - call idx2ijk(i,j,idx,nx,ny,base=base) + fsizes(1:modes) = sizes(1:modes) + call idx2ijk(fijk,idx,fsizes,base=base) + + ijk(1:modes) = fijk(1:modes) res = 0 - end function psb_c_lidx2ijk + end function end module psb_base_util_cbind_mod