diff --git a/base/tools/psb_cgetelem.f90 b/base/tools/psb_cgetelem.f90 index 2789d1e4..3c4151c9 100644 --- a/base/tools/psb_cgetelem.f90 +++ b/base/tools/psb_cgetelem.f90 @@ -63,7 +63,7 @@ function psb_c_getelem(x,index,desc_a,info) result(res) logical, parameter :: debug = .false. gindex(1) = index - res = -1.0 + res = czero if (psb_errstatus_fatal()) return info=psb_success_ call psb_erractionsave(err_act) @@ -92,7 +92,13 @@ function psb_c_getelem(x,index,desc_a,info) result(res) write(*,*)"My (local+halo) indexes are: ",myidx write(*,*)"My (local) indexes are: ",mylocal end if - res = x%get_entry(localindex(1)) + if ( localindex(1) < 1) then + info = psb_err_internal_error_ + call psb_errpush(info,name,a_err="Index not in the HALO") + goto 9999 + else + res = x%get_entry(localindex(1)) + end if call psb_erractionrestore(err_act) return diff --git a/base/tools/psb_dgetelem.f90 b/base/tools/psb_dgetelem.f90 index 8f5247c7..38d398aa 100644 --- a/base/tools/psb_dgetelem.f90 +++ b/base/tools/psb_dgetelem.f90 @@ -63,7 +63,7 @@ function psb_d_getelem(x,index,desc_a,info) result(res) logical, parameter :: debug = .false. gindex(1) = index - res = -1.0 + res = dzero if (psb_errstatus_fatal()) return info=psb_success_ call psb_erractionsave(err_act) @@ -92,7 +92,13 @@ function psb_d_getelem(x,index,desc_a,info) result(res) write(*,*)"My (local+halo) indexes are: ",myidx write(*,*)"My (local) indexes are: ",mylocal end if - res = x%get_entry(localindex(1)) + if ( localindex(1) < 1) then + info = psb_err_internal_error_ + call psb_errpush(info,name,a_err="Index not in the HALO") + goto 9999 + else + res = x%get_entry(localindex(1)) + end if call psb_erractionrestore(err_act) return diff --git a/base/tools/psb_sgetelem.f90 b/base/tools/psb_sgetelem.f90 index 244947b1..723a2f7d 100644 --- a/base/tools/psb_sgetelem.f90 +++ b/base/tools/psb_sgetelem.f90 @@ -63,7 +63,7 @@ function psb_s_getelem(x,index,desc_a,info) result(res) logical, parameter :: debug = .false. gindex(1) = index - res = -1.0 + res = szero if (psb_errstatus_fatal()) return info=psb_success_ call psb_erractionsave(err_act) @@ -92,7 +92,13 @@ function psb_s_getelem(x,index,desc_a,info) result(res) write(*,*)"My (local+halo) indexes are: ",myidx write(*,*)"My (local) indexes are: ",mylocal end if - res = x%get_entry(localindex(1)) + if ( localindex(1) < 1) then + info = psb_err_internal_error_ + call psb_errpush(info,name,a_err="Index not in the HALO") + goto 9999 + else + res = x%get_entry(localindex(1)) + end if call psb_erractionrestore(err_act) return diff --git a/base/tools/psb_zgetelem.f90 b/base/tools/psb_zgetelem.f90 index 2024f094..ac130e82 100644 --- a/base/tools/psb_zgetelem.f90 +++ b/base/tools/psb_zgetelem.f90 @@ -63,7 +63,7 @@ function psb_z_getelem(x,index,desc_a,info) result(res) logical, parameter :: debug = .false. gindex(1) = index - res = -1.0 + res = zzero if (psb_errstatus_fatal()) return info=psb_success_ call psb_erractionsave(err_act) @@ -92,7 +92,13 @@ function psb_z_getelem(x,index,desc_a,info) result(res) write(*,*)"My (local+halo) indexes are: ",myidx write(*,*)"My (local) indexes are: ",mylocal end if - res = x%get_entry(localindex(1)) + if ( localindex(1) < 1) then + info = psb_err_internal_error_ + call psb_errpush(info,name,a_err="Index not in the HALO") + goto 9999 + else + res = x%get_entry(localindex(1)) + end if call psb_erractionrestore(err_act) return