Compare commits

..
Author SHA1 Message Date
sfilippone a27932fe94 Fix CBIND interface 2026-06-16 17:19:50 +02:00
3 changed files with 50 additions and 49 deletions
+5 -4
View File
@@ -38,10 +38,11 @@ extern "C"
psb_i_t amg_c_zdescr(amg_c_zprec *ph);
psb_i_t amg_c_zallocate_wrk(amg_c_zprec *ph, const char *chfmt);
psb_i_t amg_c_zkrylov(const char *method, psb_c_zspmat *ah, amg_c_zprec *ph,
psb_c_zvector *bh, psb_c_zvector *xh,
psb_c_descriptor *cdh, , psb_c_zvector *s1,
psb_c_zvector *s2, psb_c_SolverOptions *opt);
psb_i_t amg_c_zkrylov(const char *method, psb_c_zspmat *ah, amg_c_zprec *ph,
psb_c_zvector *bh, psb_c_zvector *xh,
psb_c_descriptor *cdh, psb_c_zvector *s1,
psb_c_zvector *s2, psb_c_SolverOptions *opt);
#ifdef __cplusplus
}
+5 -6
View File
@@ -211,7 +211,6 @@ contains
act = psb_act_abort_
call psb_error_handler(act)
end if
return
end function amg_c_dhierarchy_build
@@ -253,6 +252,8 @@ contains
act = psb_act_abort_
call psb_error_handler(act)
end if
return
end function amg_c_dsmoothers_build
function amg_c_dsmoothers_build_opt(ah,cdh,ph,afmt,cdfmt) bind(c) result(res)
@@ -381,7 +382,6 @@ contains
type(psb_c_object_type) :: ah,cdh,ph,bh,xh,s1,s2
character(c_char) :: methd(*)
type(solveroptions) :: options
res= amg_c_dkrylov_opt(methd, ah, ph, bh, xh, options%eps,cdh, &
& itmax=options%itmax, iter=options%iter,&
& itrace=options%itrace, istop=options%istop,&
@@ -442,7 +442,6 @@ contains
else
return
end if
if (c_associated(s1%item)) then
call c_f_pointer(s1%item,s1p)
else
@@ -453,7 +452,7 @@ contains
else
nullify(s2p)
end if
!write(0,*) 'krylov: s1 s2 ',associated(s1p),associated(s2p)
call psb_stringc2f(methd,fmethd)
feps = eps
fitmax = itmax
@@ -657,9 +656,9 @@ contains
integer(psb_ipk_) :: iret
type(amg_dprec_type), pointer :: precp
character(len=6) :: fchfmt
! Local variable
! Local variable
integer(psb_ipk_) :: info
! Local mold variables
! Local mold variables
#if defined (PSB_HAVE_CUDA)
type(psb_d_vect_cuda), target :: dvgpu
#endif
+40 -39
View File
@@ -3,6 +3,7 @@ module amg_zprec_cbind_mod
use iso_c_binding
use amg_prec_mod
use psb_base_cbind_mod
use psb_zlinsolve_cbind_mod
type, bind(c) :: amg_c_zprec
type(c_ptr) :: item = c_null_ptr
@@ -257,7 +258,7 @@ contains
return
end function amg_c_zsmoothers_build
function amg_c_zsmoothers_build_opt(ah,cdh,ph,afmt,cdfmt) bind(c) result(res)
function amg_c_zsmoothers_build_format(ah,cdh,ph,afmt,cdfmt) bind(c) result(res)
#if defined (PSB_HAVE_CUDA)
use psb_cuda_mod
#endif
@@ -363,7 +364,7 @@ contains
AMGC_ERR_HANDLE(res)
return
end function amg_c_zsmoothers_build_opt
end function amg_c_zsmoothers_build_format
function amg_c_zkrylov(methd,&
& ah,ph,bh,xh,cdh,s1,s2,options) bind(c) result(res)
@@ -640,55 +641,55 @@ contains
return
end function amg_c_zdescr
function amg_c_zallocate_wrk(ph,chfmt) bind(c, name="amg_c_zallocate_wrk") result(res)
function amg_c_zallocate_wrk(ph,chfmt) bind(c, name="amg_c_zallocate_wrk") result(res)
#if defined (PSB_HAVE_CUDA)
use psb_cuda_mod
use psb_cuda_mod
#endif
implicit none
implicit none
integer(psb_c_ipk_) :: res
type(psb_c_object_type) :: ph
character(c_char) :: chfmt(*)
integer(psb_ipk_) :: iret
type(amg_zprec_type), pointer :: precp
character(len=6) :: fchfmt
! Local variable
integer(psb_ipk_) :: info
! Local mold variables
integer(psb_c_ipk_) :: res
type(psb_c_object_type) :: ph
character(c_char) :: chfmt(*)
integer(psb_ipk_) :: iret
type(amg_zprec_type), pointer :: precp
character(len=6) :: fchfmt
! Local variable
integer(psb_ipk_) :: info
! Local mold variables
#if defined (PSB_HAVE_CUDA)
type(psb_z_vect_cuda), target :: zvgpu
type(psb_z_vect_cuda), target :: zvgpu
#endif
type(psb_z_base_vect_type), target :: zvhost
class(psb_z_base_vect_type), pointer :: vmold
type(psb_z_base_vect_type), target :: zvhost
class(psb_z_base_vect_type), pointer :: vmold
res = -1
if (c_associated(ph%item)) then
call c_f_pointer(ph%item,precp)
else
return
end if
res = -1
if (c_associated(ph%item)) then
call c_f_pointer(ph%item,precp)
else
return
end if
call psb_stringc2f(chfmt,fchfmt)
select case (psb_toupper(fchfmt))
case('HOST','CPU')
vmold => zvhost
call psb_stringc2f(chfmt,fchfmt)
select case (psb_toupper(fchfmt))
case('HOST','CPU')
vmold => zvhost
#if defined (PSB_HAVE_CUDA)
case('GPU','DEVICE')
vmold => zvgpu
case('GPU','DEVICE')
vmold => zvgpu
#endif
case default
write(psb_err_unit,'(A)') 'amg_c_zallocate_wrk: Unknown format ', fchfmt, ' defaulting to HOST/CPU'
vmold => zvhost
end select
case default
write(psb_err_unit,'(A)') 'amg_c_zallocate_wrk: Unknown format ', fchfmt, ' defaulting to HOST/CPU'
vmold => zvhost
end select
call precp%allocate_wrk(info,vmold=vmold)
call precp%allocate_wrk(info,vmold=vmold)
iret = info
iret = info
res = AMGC_ERR_FILTER(iret)
AMGC_ERR_HANDLE(res)
return
res = AMGC_ERR_FILTER(iret)
AMGC_ERR_HANDLE(res)
return
end function amg_c_zallocate_wrk
end function amg_c_zallocate_wrk
end module amg_zprec_cbind_mod