Compare commits

..
40 changed files with 253 additions and 125 deletions
+1
View File
@@ -1,4 +1,5 @@
$Format:%d%n%n$
# Fall back version, probably last release:
1.2.1
# AMG4PSBLAS version file.
+1 -1
View File
@@ -7,7 +7,7 @@
(C) Copyright 2025 Salvatore Filippone
(C) Copyright 2025 Pasqua D'Ambra
(C) Copyright 2025 Fabio Durastante
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
+1
View File
@@ -345,6 +345,7 @@ contains
if (allocated(sm%sv)) then
call sm%sv%free(info)
if (info == psb_success_) deallocate(sm%sv,stat=info)
if (info /= psb_success_) then
info = psb_err_alloc_dealloc_
call psb_errpush(info,name)
-4
View File
@@ -671,10 +671,6 @@ contains
info = psb_err_internal_error_; goto 9999
end if
!
! In the internals, do FREE on components,
! but do not deallocate them
!
if (allocated(prec%precv)) then
do i=1,size(prec%precv)
call prec%precv(i)%free_smoothers(info)
+1
View File
@@ -345,6 +345,7 @@ contains
if (allocated(sm%sv)) then
call sm%sv%free(info)
if (info == psb_success_) deallocate(sm%sv,stat=info)
if (info /= psb_success_) then
info = psb_err_alloc_dealloc_
call psb_errpush(info,name)
+1
View File
@@ -279,6 +279,7 @@ contains
if (allocated(sm%sv)) then
call sm%sv%free(info)
if (info == psb_success_) deallocate(sm%sv,stat=info)
if (info /= psb_success_) then
info = psb_err_alloc_dealloc_
call psb_errpush(info,name)
-4
View File
@@ -671,10 +671,6 @@ contains
info = psb_err_internal_error_; goto 9999
end if
!
! In the internals, do FREE on components,
! but do not deallocate them
!
if (allocated(prec%precv)) then
do i=1,size(prec%precv)
call prec%precv(i)%free_smoothers(info)
+1
View File
@@ -345,6 +345,7 @@ contains
if (allocated(sm%sv)) then
call sm%sv%free(info)
if (info == psb_success_) deallocate(sm%sv,stat=info)
if (info /= psb_success_) then
info = psb_err_alloc_dealloc_
call psb_errpush(info,name)
+1
View File
@@ -279,6 +279,7 @@ contains
if (allocated(sm%sv)) then
call sm%sv%free(info)
if (info == psb_success_) deallocate(sm%sv,stat=info)
if (info /= psb_success_) then
info = psb_err_alloc_dealloc_
call psb_errpush(info,name)
-4
View File
@@ -671,10 +671,6 @@ contains
info = psb_err_internal_error_; goto 9999
end if
!
! In the internals, do FREE on components,
! but do not deallocate them
!
if (allocated(prec%precv)) then
do i=1,size(prec%precv)
call prec%precv(i)%free_smoothers(info)
+1
View File
@@ -345,6 +345,7 @@ contains
if (allocated(sm%sv)) then
call sm%sv%free(info)
if (info == psb_success_) deallocate(sm%sv,stat=info)
if (info /= psb_success_) then
info = psb_err_alloc_dealloc_
call psb_errpush(info,name)
-4
View File
@@ -671,10 +671,6 @@ contains
info = psb_err_internal_error_; goto 9999
end if
!
! In the internals, do FREE on components,
! but do not deallocate them
!
if (allocated(prec%precv)) then
do i=1,size(prec%precv)
call prec%precv(i)%free_smoothers(info)
@@ -53,6 +53,7 @@ subroutine amg_c_as_smoother_free(sm,info)
if (allocated(sm%sv)) then
call sm%sv%free(info)
if (info == psb_success_) deallocate(sm%sv,stat=info)
if (info /= psb_success_) then
info = psb_err_alloc_dealloc_
call psb_errpush(info,name)
@@ -52,6 +52,7 @@ subroutine amg_c_base_smoother_free(sm,info)
if (allocated(sm%sv)) then
call sm%sv%free(info)
if (info == psb_success_) deallocate(sm%sv,stat=info)
end if
if (info /= psb_success_) then
info = psb_err_alloc_dealloc_
@@ -53,6 +53,7 @@ subroutine amg_d_as_smoother_free(sm,info)
if (allocated(sm%sv)) then
call sm%sv%free(info)
if (info == psb_success_) deallocate(sm%sv,stat=info)
if (info /= psb_success_) then
info = psb_err_alloc_dealloc_
call psb_errpush(info,name)
@@ -52,6 +52,7 @@ subroutine amg_d_base_smoother_free(sm,info)
if (allocated(sm%sv)) then
call sm%sv%free(info)
if (info == psb_success_) deallocate(sm%sv,stat=info)
end if
if (info /= psb_success_) then
info = psb_err_alloc_dealloc_
@@ -53,6 +53,7 @@ subroutine amg_s_as_smoother_free(sm,info)
if (allocated(sm%sv)) then
call sm%sv%free(info)
if (info == psb_success_) deallocate(sm%sv,stat=info)
if (info /= psb_success_) then
info = psb_err_alloc_dealloc_
call psb_errpush(info,name)
@@ -52,6 +52,7 @@ subroutine amg_s_base_smoother_free(sm,info)
if (allocated(sm%sv)) then
call sm%sv%free(info)
if (info == psb_success_) deallocate(sm%sv,stat=info)
end if
if (info /= psb_success_) then
info = psb_err_alloc_dealloc_
@@ -53,6 +53,7 @@ subroutine amg_z_as_smoother_free(sm,info)
if (allocated(sm%sv)) then
call sm%sv%free(info)
if (info == psb_success_) deallocate(sm%sv,stat=info)
if (info /= psb_success_) then
info = psb_err_alloc_dealloc_
call psb_errpush(info,name)
@@ -52,6 +52,7 @@ subroutine amg_z_base_smoother_free(sm,info)
if (allocated(sm%sv)) then
call sm%sv%free(info)
if (info == psb_success_) deallocate(sm%sv,stat=info)
end if
if (info /= psb_success_) then
info = psb_err_alloc_dealloc_
+10 -2
View File
@@ -91,7 +91,11 @@ subroutine amg_c_diag_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold)
sv%d(i) = cone/sv%d(i)
end if
end do
if (.not.allocated(sv%dv)) allocate(sv%dv,stat=info)
if (allocated(sv%dv)) then
call sv%dv%free(info)
deallocate(sv%dv)
end if
allocate(sv%dv,stat=info)
if (info == psb_success_) then
call sv%dv%bld(sv%d)
if (present(vmold)) call sv%dv%cnv(vmold)
@@ -172,7 +176,11 @@ subroutine amg_c_l1_diag_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold)
sv%d(i) = cone/sv%d(i)
end if
end do
if (.not.allocated(sv%dv)) allocate(sv%dv,stat=info)
if (allocated(sv%dv)) then
call sv%dv%free(info)
deallocate(sv%dv)
end if
allocate(sv%dv,stat=info)
if (info == psb_success_) then
call sv%dv%bld(sv%d)
if (present(vmold)) call sv%dv%cnv(vmold)
+5 -1
View File
@@ -100,7 +100,11 @@ subroutine amg_c_jac_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold)
sv%d(i) = cone/sv%d(i)
end if
end do
if (.not.allocated(sv%dv)) allocate(sv%dv,stat=info)
if (allocated(sv%dv)) then
call sv%dv%free(info)
deallocate(sv%dv)
end if
allocate(sv%dv,stat=info)
if (info == psb_success_) then
call sv%dv%bld(sv%d)
if (present(vmold)) call sv%dv%cnv(vmold)
@@ -103,7 +103,11 @@ subroutine amg_c_l1_jac_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold)
sv%d(i) = cone/sv%d(i)
end if
end do
if (.not.allocated(sv%dv)) allocate(sv%dv,stat=info)
if (allocated(sv%dv)) then
call sv%dv%free(info)
deallocate(sv%dv)
end if
allocate(sv%dv,stat=info)
if (info == psb_success_) then
call sv%dv%bld(sv%d)
if (present(vmold)) call sv%dv%cnv(vmold)
+10 -2
View File
@@ -91,7 +91,11 @@ subroutine amg_d_diag_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold)
sv%d(i) = done/sv%d(i)
end if
end do
if (.not.allocated(sv%dv)) allocate(sv%dv,stat=info)
if (allocated(sv%dv)) then
call sv%dv%free(info)
deallocate(sv%dv)
end if
allocate(sv%dv,stat=info)
if (info == psb_success_) then
call sv%dv%bld(sv%d)
if (present(vmold)) call sv%dv%cnv(vmold)
@@ -172,7 +176,11 @@ subroutine amg_d_l1_diag_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold)
sv%d(i) = done/sv%d(i)
end if
end do
if (.not.allocated(sv%dv)) allocate(sv%dv,stat=info)
if (allocated(sv%dv)) then
call sv%dv%free(info)
deallocate(sv%dv)
end if
allocate(sv%dv,stat=info)
if (info == psb_success_) then
call sv%dv%bld(sv%d)
if (present(vmold)) call sv%dv%cnv(vmold)
+5 -1
View File
@@ -100,7 +100,11 @@ subroutine amg_d_jac_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold)
sv%d(i) = done/sv%d(i)
end if
end do
if (.not.allocated(sv%dv)) allocate(sv%dv,stat=info)
if (allocated(sv%dv)) then
call sv%dv%free(info)
deallocate(sv%dv)
end if
allocate(sv%dv,stat=info)
if (info == psb_success_) then
call sv%dv%bld(sv%d)
if (present(vmold)) call sv%dv%cnv(vmold)
@@ -103,7 +103,11 @@ subroutine amg_d_l1_jac_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold)
sv%d(i) = done/sv%d(i)
end if
end do
if (.not.allocated(sv%dv)) allocate(sv%dv,stat=info)
if (allocated(sv%dv)) then
call sv%dv%free(info)
deallocate(sv%dv)
end if
allocate(sv%dv,stat=info)
if (info == psb_success_) then
call sv%dv%bld(sv%d)
if (present(vmold)) call sv%dv%cnv(vmold)
+10 -2
View File
@@ -91,7 +91,11 @@ subroutine amg_s_diag_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold)
sv%d(i) = sone/sv%d(i)
end if
end do
if (.not.allocated(sv%dv)) allocate(sv%dv,stat=info)
if (allocated(sv%dv)) then
call sv%dv%free(info)
deallocate(sv%dv)
end if
allocate(sv%dv,stat=info)
if (info == psb_success_) then
call sv%dv%bld(sv%d)
if (present(vmold)) call sv%dv%cnv(vmold)
@@ -172,7 +176,11 @@ subroutine amg_s_l1_diag_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold)
sv%d(i) = sone/sv%d(i)
end if
end do
if (.not.allocated(sv%dv)) allocate(sv%dv,stat=info)
if (allocated(sv%dv)) then
call sv%dv%free(info)
deallocate(sv%dv)
end if
allocate(sv%dv,stat=info)
if (info == psb_success_) then
call sv%dv%bld(sv%d)
if (present(vmold)) call sv%dv%cnv(vmold)
+5 -1
View File
@@ -100,7 +100,11 @@ subroutine amg_s_jac_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold)
sv%d(i) = sone/sv%d(i)
end if
end do
if (.not.allocated(sv%dv)) allocate(sv%dv,stat=info)
if (allocated(sv%dv)) then
call sv%dv%free(info)
deallocate(sv%dv)
end if
allocate(sv%dv,stat=info)
if (info == psb_success_) then
call sv%dv%bld(sv%d)
if (present(vmold)) call sv%dv%cnv(vmold)
@@ -103,7 +103,11 @@ subroutine amg_s_l1_jac_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold)
sv%d(i) = sone/sv%d(i)
end if
end do
if (.not.allocated(sv%dv)) allocate(sv%dv,stat=info)
if (allocated(sv%dv)) then
call sv%dv%free(info)
deallocate(sv%dv)
end if
allocate(sv%dv,stat=info)
if (info == psb_success_) then
call sv%dv%bld(sv%d)
if (present(vmold)) call sv%dv%cnv(vmold)
+10 -2
View File
@@ -91,7 +91,11 @@ subroutine amg_z_diag_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold)
sv%d(i) = zone/sv%d(i)
end if
end do
if (.not.allocated(sv%dv)) allocate(sv%dv,stat=info)
if (allocated(sv%dv)) then
call sv%dv%free(info)
deallocate(sv%dv)
end if
allocate(sv%dv,stat=info)
if (info == psb_success_) then
call sv%dv%bld(sv%d)
if (present(vmold)) call sv%dv%cnv(vmold)
@@ -172,7 +176,11 @@ subroutine amg_z_l1_diag_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold)
sv%d(i) = zone/sv%d(i)
end if
end do
if (.not.allocated(sv%dv)) allocate(sv%dv,stat=info)
if (allocated(sv%dv)) then
call sv%dv%free(info)
deallocate(sv%dv)
end if
allocate(sv%dv,stat=info)
if (info == psb_success_) then
call sv%dv%bld(sv%d)
if (present(vmold)) call sv%dv%cnv(vmold)
+5 -1
View File
@@ -100,7 +100,11 @@ subroutine amg_z_jac_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold)
sv%d(i) = zone/sv%d(i)
end if
end do
if (.not.allocated(sv%dv)) allocate(sv%dv,stat=info)
if (allocated(sv%dv)) then
call sv%dv%free(info)
deallocate(sv%dv)
end if
allocate(sv%dv,stat=info)
if (info == psb_success_) then
call sv%dv%bld(sv%d)
if (present(vmold)) call sv%dv%cnv(vmold)
@@ -103,7 +103,11 @@ subroutine amg_z_l1_jac_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold)
sv%d(i) = zone/sv%d(i)
end if
end do
if (.not.allocated(sv%dv)) allocate(sv%dv,stat=info)
if (allocated(sv%dv)) then
call sv%dv%free(info)
deallocate(sv%dv)
end if
allocate(sv%dv,stat=info)
if (info == psb_success_) then
call sv%dv%bld(sv%d)
if (present(vmold)) call sv%dv%cnv(vmold)
+1 -1
View File
@@ -11,7 +11,7 @@ amg_c_dprec* amg_c_dprec_new()
}
psb_c_i_t amg_c_dprec_delete(amg_c_dprec* p)
psb_i_t amg_c_dprec_delete(amg_c_dprec* p)
{
int iret;
iret=amg_c_dprecfree(p);
+19 -18
View File
@@ -17,27 +17,28 @@ extern "C" {
} amg_c_dprec;
amg_c_dprec* amg_c_dprec_new();
psb_c_i_t amg_c_dprec_delete(amg_c_dprec* p);
psb_i_t amg_c_dprec_delete(amg_c_dprec* p);
psb_c_i_t amg_c_dprecinit(psb_c_ctxt cctxt, amg_c_dprec *ph, const char *ptype);
psb_c_i_t amg_c_dprecseti(amg_c_dprec *ph, const char *what, psb_c_i_t val);
psb_c_i_t amg_c_dprecsetc(amg_c_dprec *ph, const char *what, const char *val);
psb_c_i_t amg_c_dprecsetr(amg_c_dprec *ph, const char *what, double val);
psb_c_i_t amg_c_dprecbld(psb_c_dspmat *ah, psb_c_descriptor *cdh, amg_c_dprec *ph);
psb_c_i_t amg_c_dhierarchy_build(psb_c_dspmat *ah, psb_c_descriptor *cdh, amg_c_dprec *ph);
psb_c_i_t amg_c_dsmoothers_build(psb_c_dspmat *ah, psb_c_descriptor *cdh, amg_c_dprec *ph);
psb_c_i_t amg_c_dsmoothers_build_opt(psb_c_dspmat *ah, psb_c_descriptor *cdh, amg_c_dprec *ph, const char *afmt, const char *chfmt);
psb_c_i_t amg_c_dprecapply(amg_c_dprec *ph, psb_c_dvector *bh, psb_c_dvector *xh, psb_c_descriptor *cdh);
psb_c_i_t amg_c_dprecapply_opt(amg_c_dprec *ph, psb_c_dvector *bh, psb_c_dvector *xh, psb_c_descriptor *cdh, const char *ctrans);
psb_c_i_t amg_c_dprecfree(amg_c_dprec *ph);
psb_c_i_t amg_c_dprecbld_opt(psb_c_dspmat *ah, psb_c_descriptor *cdh,
psb_i_t amg_c_dprecinit(psb_c_ctxt cctxt, amg_c_dprec *ph, const char *ptype);
psb_i_t amg_c_dprecseti(amg_c_dprec *ph, const char *what, psb_i_t val);
psb_i_t amg_c_dprecsetc(amg_c_dprec *ph, const char *what, const char *val);
psb_i_t amg_c_dprecsetr(amg_c_dprec *ph, const char *what, double val);
psb_i_t amg_c_dprecbld(psb_c_dspmat *ah, psb_c_descriptor *cdh, amg_c_dprec *ph);
psb_i_t amg_c_dhierarchy_build(psb_c_dspmat *ah, psb_c_descriptor *cdh, amg_c_dprec *ph);
psb_i_t amg_c_dsmoothers_build(psb_c_dspmat *ah, psb_c_descriptor *cdh, amg_c_dprec *ph);
psb_i_t amg_c_dsmoothers_build_opt(psb_c_dspmat *ah, psb_c_descriptor *cdh, amg_c_dprec *ph, const char *afmt, const char *chfmt);
psb_i_t amg_c_dprecapply(amg_c_dprec *ph, psb_c_dvector *bh, psb_c_dvector *xh, psb_c_descriptor *cdh);
psb_i_t amg_c_dprecapply_opt(amg_c_dprec *ph, psb_c_dvector *bh, psb_c_dvector *xh, psb_c_descriptor *cdh, const char *ctrans);
psb_i_t amg_c_dprecfree(amg_c_dprec *ph);
psb_i_t amg_c_dprecbld_opt(psb_c_dspmat *ah, psb_c_descriptor *cdh,
amg_c_dprec *ph, const char *afmt);
psb_c_i_t amg_c_ddescr(amg_c_dprec *ph);
psb_c_i_t amg_c_dallocate_wrk(amg_c_dprec *ph, const char *chfmt);
psb_i_t amg_c_ddescr(amg_c_dprec *ph);
psb_i_t amg_c_dallocate_wrk(amg_c_dprec *ph, const char *chfmt);
psb_c_i_t amg_c_dkrylov(const char *method, psb_c_dspmat *ah, amg_c_dprec *ph,
psb_c_dvector *bh, psb_c_dvector *xh,
psb_c_descriptor *cdh, psb_c_SolverOptions *opt);
psb_i_t amg_c_dkrylov(const char *method, psb_c_dspmat *ah, amg_c_dprec *ph,
psb_c_dvector *bh, psb_c_dvector *xh,
psb_c_descriptor *cdh, psb_c_dvector *s1,
psb_c_dvector *s2, psb_c_SolverOptions *opt);
#ifdef __cplusplus
+1 -1
View File
@@ -11,7 +11,7 @@ amg_c_zprec* amg_c_new_zprec()
}
psb_c_i_t amg_c_delete_zprec(amg_c_zprec* p)
psb_i_t amg_c_delete_zprec(amg_c_zprec* p)
{
int iret;
iret=amg_c_zprecfree(p);
+18 -17
View File
@@ -19,28 +19,29 @@ extern "C"
} amg_c_zprec;
amg_c_zprec *amg_c_zprec_new();
psb_c_i_t amg_c_zprec_delete(amg_c_zprec *p);
psb_i_t amg_c_zprec_delete(amg_c_zprec *p);
psb_c_i_t amg_c_zprecinit(psb_c_ctxt cctxt, amg_c_zprec *ph, const char *ptype);
psb_c_i_t amg_c_zprecseti(amg_c_zprec *ph, const char *what, psb_c_i_t val);
psb_c_i_t amg_c_zprecsetc(amg_c_zprec *ph, const char *what, const char *val);
psb_c_i_t amg_c_zprecsetr(amg_c_zprec *ph, const char *what, double val);
psb_c_i_t amg_c_zprecbld(psb_c_zspmat *ah, psb_c_descriptor *cdh, amg_c_zprec *ph);
psb_c_i_t amg_c_zhierarchy_build(psb_c_zspmat *ah, psb_c_descriptor *cdh, amg_c_zprec *ph);
psb_c_i_t amg_c_zsmoothers_build(psb_c_zspmat *ah, psb_c_descriptor *cdh, amg_c_zprec *ph);
psb_c_i_t amg_c_zsmoothers_build_opt(psb_c_zspmat *ah, psb_c_descriptor *cdh, amg_c_zprec *ph, const char *afmt, const char *chfmt);
psb_c_i_t amg_c_zprecapply(amg_c_zprec *ph, psb_c_zvector *bh, psb_c_zvector *xh, psb_c_descriptor *cdh);
psb_c_i_t amg_c_zprecapply_opt(amg_c_zprec *ph, psb_c_zvector *bh, psb_c_zvector *xh, psb_c_descriptor *cdh, const char *ctrans);
psb_c_i_t amg_c_zprecfree(amg_c_zprec *ph);
psb_c_i_t amg_c_zprecbld_opt(psb_c_zspmat *ah, psb_c_descriptor *cdh,
psb_i_t amg_c_zprecinit(psb_c_ctxt cctxt, amg_c_zprec *ph, const char *ptype);
psb_i_t amg_c_zprecseti(amg_c_zprec *ph, const char *what, psb_i_t val);
psb_i_t amg_c_zprecsetc(amg_c_zprec *ph, const char *what, const char *val);
psb_i_t amg_c_zprecsetr(amg_c_zprec *ph, const char *what, double val);
psb_i_t amg_c_zprecbld(psb_c_zspmat *ah, psb_c_descriptor *cdh, amg_c_zprec *ph);
psb_i_t amg_c_zhierarchy_build(psb_c_zspmat *ah, psb_c_descriptor *cdh, amg_c_zprec *ph);
psb_i_t amg_c_zsmoothers_build(psb_c_zspmat *ah, psb_c_descriptor *cdh, amg_c_zprec *ph);
psb_i_t amg_c_zsmoothers_build_opt(psb_c_zspmat *ah, psb_c_descriptor *cdh, amg_c_zprec *ph, const char *afmt, const char *chfmt);
psb_i_t amg_c_zprecapply(amg_c_zprec *ph, psb_c_zvector *bh, psb_c_zvector *xh, psb_c_descriptor *cdh);
psb_i_t amg_c_zprecapply_opt(amg_c_zprec *ph, psb_c_zvector *bh, psb_c_zvector *xh, psb_c_descriptor *cdh, const char *ctrans);
psb_i_t amg_c_zprecfree(amg_c_zprec *ph);
psb_i_t amg_c_zprecbld_opt(psb_c_zspmat *ah, psb_c_descriptor *cdh,
amg_c_zprec *ph, const char *afmt);
psb_c_i_t amg_c_zdescr(amg_c_zprec *ph);
psb_c_i_t amg_c_zallocate_wrk(amg_c_zprec *ph, const char *chfmt);
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_c_i_t amg_c_zkrylov(const char *method, psb_c_zspmat *ah, amg_c_zprec *ph,
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_SolverOptions *opt);
psb_c_descriptor *cdh, , psb_c_zvector *s1,
psb_c_zvector *s2, psb_c_SolverOptions *opt);
#ifdef __cplusplus
}
+45 -15
View File
@@ -3,6 +3,7 @@ module amg_dprec_cbind_mod
use iso_c_binding
use amg_prec_mod
use psb_base_cbind_mod
use psb_dlinsolve_cbind_mod
type, bind(c) :: amg_c_dprec
type(c_ptr) :: item = c_null_ptr
@@ -206,11 +207,11 @@ contains
res = AMGC_ERR_FILTER(iret)
AMGC_ERR_HANDLE(res)
if (res /=0) then
act = psb_act_abort_
call psb_error_handler(act)
end if
return
end function amg_c_dhierarchy_build
@@ -252,7 +253,6 @@ 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)
@@ -370,7 +370,7 @@ contains
end function amg_c_dsmoothers_build_opt
function amg_c_dkrylov(methd,&
& ah,ph,bh,xh,cdh,options) bind(c) result(res)
& ah,ph,bh,xh,cdh,s1,s2,options) bind(c) result(res)
use psb_base_mod
use psb_prec_mod
use psb_linsolve_mod
@@ -378,20 +378,21 @@ contains
use psb_dlinsolve_cbind_mod
implicit none
integer(psb_c_ipk_) :: res
type(psb_c_object_type) :: ah,cdh,ph,bh,xh
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,&
& irst=options%irst, err=options%err)
& irst=options%irst, err=options%err, s1=s1,s2=s2)
end function amg_c_dkrylov
function amg_c_dkrylov_opt(methd,&
& ah,ph,bh,xh,eps,cdh,itmax,iter,err,itrace,irst,istop) bind(c) result(res)
& ah,ph,bh,xh,eps,cdh,itmax,iter,err,&
& itrace,irst,istop,s1,s2) bind(c) result(res)
use psb_base_mod
use psb_prec_mod
use psb_linsolve_mod
@@ -399,16 +400,17 @@ contains
use psb_prec_cbind_mod
implicit none
integer(psb_c_ipk_) :: res
type(psb_c_object_type) :: ah,cdh,ph,bh,xh
type(psb_c_object_type) :: ah,cdh,ph,bh,xh,s1, s2
integer(psb_c_ipk_), value :: itmax,itrace,irst,istop
real(c_double), value :: eps
integer(psb_c_ipk_) :: iter
real(c_double) :: err
character(c_char) :: methd(*)
type(psb_desc_type), pointer :: descp
type(psb_dspmat_type), pointer :: ap
type(amg_dprec_type), pointer :: precp
type(psb_d_vect_type), pointer :: xp, bp
type(psb_d_vect_type), pointer :: xp, bp, s1p, s2p
integer(psb_ipk_) :: iret,fitmax,fitrace,first,fistop,fiter
character(len=20) :: fmethd
@@ -441,6 +443,16 @@ contains
return
end if
if (c_associated(s1%item)) then
call c_f_pointer(s1%item,s1p)
else
nullify(s1p)
end if
if (c_associated(s2%item)) then
call c_f_pointer(s2%item,s2p)
else
nullify(s2p)
end if
call psb_stringc2f(methd,fmethd)
feps = eps
@@ -449,10 +461,28 @@ contains
first = irst
fistop = istop
call psb_krylov(fmethd, ap, precp, bp, xp, feps, &
& descp, iret,&
& itmax=fitmax,iter=fiter,itrace=fitrace,istop=fistop,&
& irst=first, err=ferr)
if (associated(s1p).and.associated(s2p)) then
call psb_krylov(fmethd, ap, precp, bp, xp, feps, &
& descp, iret,&
& itmax=fitmax,iter=fiter,itrace=fitrace,istop=fistop,&
& irst=first, err=ferr,s1=s1p,s2=s2p)
else if (associated(s1p)) then
call psb_krylov(fmethd, ap, precp, bp, xp, feps, &
& descp, iret,&
& itmax=fitmax,iter=fiter,itrace=fitrace,istop=fistop,&
& irst=first, err=ferr,s1=s1p)
else if (associated(s2p)) then
call psb_krylov(fmethd, ap, precp, bp, xp, feps, &
& descp, iret,&
& itmax=fitmax,iter=fiter,itrace=fitrace,istop=fistop,&
& irst=first, err=ferr,s2=s2p)
else
call psb_krylov(fmethd, ap, precp, bp, xp, feps, &
& descp, iret,&
& itmax=fitmax,iter=fiter,itrace=fitrace,istop=fistop,&
& irst=first, err=ferr)
end if
iter = fiter
err = ferr
res = min(iret,0)
@@ -507,7 +537,7 @@ contains
res = AMGC_ERR_FILTER(info)
AMGC_ERR_HANDLE(res)
return
end function amg_c_dprecapply
end function amg_c_dprecapply
function amg_c_dprecapply_opt(ph,bc,xc,cdh,ctrans) bind(c,name="amg_c_dprecapply_opt") result(res)
use psb_base_mod
@@ -563,7 +593,7 @@ end function amg_c_dprecapply
res = AMGC_ERR_FILTER(info)
AMGC_ERR_HANDLE(res)
return
end function amg_c_dprecapply_opt
end function amg_c_dprecapply_opt
function amg_c_dprecfree(ph) bind(c) result(res)
implicit none
+47 -14
View File
@@ -207,11 +207,11 @@ contains
res = AMGC_ERR_FILTER(iret)
AMGC_ERR_HANDLE(res)
if (res /=0) then
act = psb_act_abort_
call psb_error_handler(act)
end if
return
end function amg_c_zhierarchy_build
@@ -249,7 +249,6 @@ contains
res = AMGC_ERR_FILTER(iret)
AMGC_ERR_HANDLE(res)
if (res /=0) then
act = psb_act_abort_
call psb_error_handler(act)
@@ -258,7 +257,7 @@ contains
return
end function amg_c_zsmoothers_build
function amg_c_zsmoothers_build_format(ah,cdh,ph,afmt,cdfmt) bind(c) result(res)
function amg_c_zsmoothers_build_opt(ah,cdh,ph,afmt,cdfmt) bind(c) result(res)
#if defined (PSB_HAVE_CUDA)
use psb_cuda_mod
#endif
@@ -364,34 +363,40 @@ contains
AMGC_ERR_HANDLE(res)
return
end function amg_c_zsmoothers_build_format
end function amg_c_zsmoothers_build_opt
function amg_c_zkrylov(methd,&
& ah,ph,bh,xh,cdh,options) bind(c) result(res)
& ah,ph,bh,xh,cdh,s1,s2,options) bind(c) result(res)
use psb_base_mod
use psb_prec_mod
use psb_linsolve_mod
use psb_prec_cbind_mod
use psb_zlinsolve_cbind_mod
implicit none
integer(psb_c_ipk_) :: res
type(psb_c_object_type) :: ah,cdh,ph,bh,xh
type(psb_c_object_type) :: ah,cdh,ph,bh,xh,s1,s2
character(c_char) :: methd(*)
type(solveroptions) :: options
res= amg_c_zkrylov_opt(methd, ah, ph, bh, xh, options%eps,cdh, &
& itmax=options%itmax, iter=options%iter,&
& itrace=options%itrace, istop=options%istop,&
& irst=options%irst, err=options%err)
& irst=options%irst, err=options%err, s1=s1,s2=s2)
end function amg_c_zkrylov
function amg_c_zkrylov_opt(methd,&
& ah,ph,bh,xh,eps,cdh,itmax,iter,err,itrace,irst,istop) bind(c) result(res)
& ah,ph,bh,xh,eps,cdh,itmax,iter,err,&
& itrace,irst,istop,s1,s2) bind(c) result(res)
use psb_base_mod
use psb_prec_mod
use psb_linsolve_mod
use psb_objhandle_mod
use psb_prec_cbind_mod
implicit none
integer(psb_c_ipk_) :: res
type(psb_c_object_type) :: ah,cdh,ph,bh,xh
type(psb_c_object_type) :: ah,cdh,ph,bh,xh,s1, s2
integer(psb_c_ipk_), value :: itmax,itrace,irst,istop
real(c_double), value :: eps
integer(psb_c_ipk_) :: iter
@@ -400,7 +405,7 @@ contains
type(psb_desc_type), pointer :: descp
type(psb_zspmat_type), pointer :: ap
type(amg_zprec_type), pointer :: precp
type(psb_z_vect_type), pointer :: xp, bp
type(psb_z_vect_type), pointer :: xp, bp, s1p, s2p
integer(psb_ipk_) :: iret,fitmax,fitrace,first,fistop,fiter
character(len=20) :: fmethd
@@ -432,6 +437,16 @@ contains
else
return
end if
if (c_associated(s1%item)) then
call c_f_pointer(s1%item,s1p)
else
nullify(s1p)
end if
if (c_associated(s2%item)) then
call c_f_pointer(s2%item,s2p)
else
nullify(s2p)
end if
call psb_stringc2f(methd,fmethd)
@@ -441,10 +456,28 @@ contains
first = irst
fistop = istop
call psb_krylov(fmethd, ap, precp, bp, xp, feps, &
& descp, iret,&
& itmax=fitmax,iter=fiter,itrace=fitrace,istop=fistop,&
& irst=first, err=ferr)
if (associated(s1p).and.associated(s2p)) then
call psb_krylov(fmethd, ap, precp, bp, xp, feps, &
& descp, iret,&
& itmax=fitmax,iter=fiter,itrace=fitrace,istop=fistop,&
& irst=first, err=ferr,s1=s1p,s2=s2p)
else if (associated(s1p)) then
call psb_krylov(fmethd, ap, precp, bp, xp, feps, &
& descp, iret,&
& itmax=fitmax,iter=fiter,itrace=fitrace,istop=fistop,&
& irst=first, err=ferr,s1=s1p)
else if (associated(s2p)) then
call psb_krylov(fmethd, ap, precp, bp, xp, feps, &
& descp, iret,&
& itmax=fitmax,iter=fiter,itrace=fitrace,istop=fistop,&
& irst=first, err=ferr,s2=s2p)
else
call psb_krylov(fmethd, ap, precp, bp, xp, feps, &
& descp, iret,&
& itmax=fitmax,iter=fiter,itrace=fitrace,istop=fistop,&
& irst=first, err=ferr)
end if
iter = fiter
err = ferr
res = min(iret,0)
+13 -13
View File
@@ -123,16 +123,16 @@ double g(double x, double y, double z)
#define NBMAX 20
psb_c_i_t matgen(psb_c_ctxt cctxt, psb_c_i_t nl, psb_c_i_t idim, psb_c_l_t vl[],
psb_i_t matgen(psb_c_ctxt cctxt, psb_i_t nl, psb_i_t idim, psb_l_t vl[],
psb_c_dspmat *ah,psb_c_descriptor *cdh,
psb_c_dvector *xh, psb_c_dvector *bh, psb_c_dvector *rh)
{
psb_c_i_t iam, np;
psb_c_l_t ix, iy, iz, el,glob_row;
psb_c_i_t i, k, info,ret;
psb_i_t iam, np;
psb_l_t ix, iy, iz, el,glob_row;
psb_i_t i, k, info,ret;
double x, y, z, deltah, sqdeltah, deltah2;
double val[10*NBMAX], zt[NBMAX];
psb_c_l_t irow[10*NBMAX], icol[10*NBMAX];
psb_l_t irow[10*NBMAX], icol[10*NBMAX];
info = 0;
psb_c_info(cctxt,&iam,&np);
@@ -254,15 +254,15 @@ void get_hparm(FILE *fp, char *val)
int main(int argc, char *argv[])
{
psb_c_ctxt *cctxt;
psb_c_i_t iam, np;
psb_i_t iam, np;
char methd[40], ptype[40], afmt[8];
psb_c_i_t nparms;
psb_c_i_t idim,info,istop,itmax,itrace,irst,iter,ret;
psb_i_t nparms;
psb_i_t idim,info,istop,itmax,itrace,irst,iter,ret;
amg_c_dprec *ph;
psb_c_dspmat *ah;
psb_c_dvector *bh, *xh, *rh;
psb_c_i_t nb,nlr, nl;
psb_c_l_t i,ng, *vl, k;
psb_i_t nb,nlr, nl;
psb_l_t i,ng, *vl, k;
double t1,t2,eps,err;
double *xv, *bv, *rv;
double one=1.0, zero=0.0, res2;
@@ -305,16 +305,16 @@ int main(int argc, char *argv[])
psb_c_set_index_base(0);
/* Simple minded BLOCK data distribution */
ng = ((psb_c_l_t) idim)*idim*idim;
ng = ((psb_l_t) idim)*idim*idim;
nb = (ng+np-1)/np;
nl = nb;
if ( (ng -iam*nb) < nl) nl = ng -iam*nb;
fprintf(stderr,"%d: Input data %d %ld %d %d\n",iam,idim,ng,nb, nl);
if ((vl=malloc(nb*sizeof(psb_c_l_t)))==NULL) {
if ((vl=malloc(nb*sizeof(psb_l_t)))==NULL) {
fprintf(stderr,"On %d: malloc failure\n",iam);
psb_c_abort(*cctxt);
}
i = ((psb_c_l_t)iam) * nb;
i = ((psb_l_t)iam) * nb;
for (k=0; k<nl; k++)
vl[k] = i+k;
+13 -13
View File
@@ -126,17 +126,17 @@ double g(double x, double y, double z)
#define NBMAX 20
psb_c_i_t matgen(psb_c_ctxt cctxt, psb_c_i_t nl, psb_c_i_t idim, psb_c_l_t vl[],
psb_i_t matgen(psb_c_ctxt cctxt, psb_i_t nl, psb_i_t idim, psb_l_t vl[],
psb_c_dspmat *ah, const char *afmt,
psb_c_descriptor *cdh, const char *cdfmt,
psb_c_dvector *xh, psb_c_dvector *bh, psb_c_dvector *rh)
{
psb_c_i_t iam, np;
psb_c_l_t ix, iy, iz, el, glob_row;
psb_c_i_t i, k, info, ret;
psb_i_t iam, np;
psb_l_t ix, iy, iz, el, glob_row;
psb_i_t i, k, info, ret;
double x, y, z, deltah, sqdeltah, deltah2;
double val[10 * NBMAX], zt[NBMAX];
psb_c_l_t irow[10 * NBMAX], icol[10 * NBMAX];
psb_l_t irow[10 * NBMAX], icol[10 * NBMAX];
info = 0;
psb_c_info(cctxt, &iam, &np);
@@ -360,15 +360,15 @@ void get_hparm(FILE *fp, char *val)
int main(int argc, char *argv[])
{
psb_c_ctxt *cctxt;
psb_c_i_t iam, np;
psb_i_t iam, np;
char methd[40], ptype[40], afmt[8], cdfmt[8];
psb_c_i_t nparms;
psb_c_i_t idim, info, istop, itmax, itrace, irst, iter, ret;
psb_i_t nparms;
psb_i_t idim, info, istop, itmax, itrace, irst, iter, ret;
amg_c_dprec *ph;
psb_c_dspmat *ah;
psb_c_dvector *bh, *xh, *rh;
psb_c_i_t nb, nlr, nl;
psb_c_l_t i, ng, *vl, k;
psb_i_t nb, nlr, nl;
psb_l_t i, ng, *vl, k;
double t1, t2, eps, err;
double *xv, *bv, *rv;
double one = 1.0, zero = 0.0, res2;
@@ -439,18 +439,18 @@ int main(int argc, char *argv[])
psb_c_set_index_base(0);
/* Simple minded BLOCK data distribution */
ng = ((psb_c_l_t)idim) * idim * idim;
ng = ((psb_l_t)idim) * idim * idim;
nb = (ng + np - 1) / np;
nl = nb;
if ((ng - iam * nb) < nl)
nl = ng - iam * nb;
fprintf(stderr, "%d: Input data %d %ld %d %d\n", iam, idim, ng, nb, nl);
if ((vl = malloc(nb * sizeof(psb_c_l_t))) == NULL)
if ((vl = malloc(nb * sizeof(psb_l_t))) == NULL)
{
fprintf(stderr, "On %d: malloc failure\n", iam);
psb_c_abort(*cctxt);
}
i = ((psb_c_l_t)iam) * nb;
i = ((psb_l_t)iam) * nb;
for (k = 0; k < nl; k++)
vl[k] = i + k;