From 51c0935493c2d1a0f61a157615e4d94eb8c9505b Mon Sep 17 00:00:00 2001 From: Salvatore Filippone Date: Mon, 27 Jan 2014 11:18:20 +0000 Subject: [PATCH] psblas3: psb_c_mmio_impl.f90 psb_d_mmio_impl.f90 psb_s_mmio_impl.f90 psb_z_mmio_impl.f90 Added proper error condition on read. --- util/psb_c_mmio_impl.f90 | 7 +++++-- util/psb_d_mmio_impl.f90 | 2 +- util/psb_s_mmio_impl.f90 | 7 +++++-- util/psb_z_mmio_impl.f90 | 7 +++++-- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/util/psb_c_mmio_impl.f90 b/util/psb_c_mmio_impl.f90 index 39c546ce..316e5545 100644 --- a/util/psb_c_mmio_impl.f90 +++ b/util/psb_c_mmio_impl.f90 @@ -285,7 +285,7 @@ subroutine cmm_mat_read(a, info, iunit, filename) ! we de-symmetrize what we are about to read call acoo%allocate(nrow,ncol,2*nnzero) do i=1,nnzero - read(infile,fmt=*,end=902) acoo%ia(i),acoo%ja(i),are,aim + read(infile,fmt=*,end=902,err=905) acoo%ia(i),acoo%ja(i),are,aim acoo%val(i) = cmplx(are,aim,kind=psb_spk_) end do nzr = nnzero @@ -308,7 +308,7 @@ subroutine cmm_mat_read(a, info, iunit, filename) ! we de-symmetrize what we are about to read call acoo%allocate(nrow,ncol,2*nnzero) do i=1,nnzero - read(infile,fmt=*,end=902) acoo%ia(i),acoo%ja(i),are,aim + read(infile,fmt=*,end=902,err=905) acoo%ia(i),acoo%ja(i),are,aim acoo%val(i) = cmplx(are,aim,kind=psb_spk_) end do nzr = nnzero @@ -340,6 +340,9 @@ subroutine cmm_mat_read(a, info, iunit, filename) 902 info=902 write(psb_err_unit,*) 'READ_MATRIX: Unexpected end of file ' return +905 info=905 + write(psb_err_unit,*) 'READ_MATRIX: Error at line',i + return 993 info=993 write(psb_err_unit,*) 'READ_MATRIX: Memory allocation failure' return diff --git a/util/psb_d_mmio_impl.f90 b/util/psb_d_mmio_impl.f90 index 5848bb16..e81e3c8e 100644 --- a/util/psb_d_mmio_impl.f90 +++ b/util/psb_d_mmio_impl.f90 @@ -276,7 +276,7 @@ subroutine dmm_mat_read(a, info, iunit, filename) ! we de-symmetrize what we are about to read call acoo%allocate(nrow,ncol,2*nnzero) do i=1,nnzero - read(infile,fmt=*,end=902) acoo%ia(i),acoo%ja(i),acoo%val(i) + read(infile,fmt=*,end=902,err=905) acoo%ia(i),acoo%ja(i),acoo%val(i) end do nzr = nnzero do i=1,nnzero diff --git a/util/psb_s_mmio_impl.f90 b/util/psb_s_mmio_impl.f90 index b915fcc1..38429ae6 100644 --- a/util/psb_s_mmio_impl.f90 +++ b/util/psb_s_mmio_impl.f90 @@ -266,7 +266,7 @@ subroutine smm_mat_read(a, info, iunit, filename) if ((psb_tolower(type) == 'real').and.(psb_tolower(sym) == 'general')) then call acoo%allocate(nrow,ncol,nnzero) do i=1,nnzero - read(infile,fmt=*,end=902) acoo%ia(i),acoo%ja(i),acoo%val(i) + read(infile,fmt=*,end=902,err=905) acoo%ia(i),acoo%ja(i),acoo%val(i) end do call acoo%set_nzeros(nnzero) call acoo%fix(info) @@ -279,7 +279,7 @@ subroutine smm_mat_read(a, info, iunit, filename) ! we de-symmetrize what we are about to read call acoo%allocate(nrow,ncol,2*nnzero) do i=1,nnzero - read(infile,fmt=*,end=902) acoo%ia(i),acoo%ja(i),acoo%val(i) + read(infile,fmt=*,end=902,err=905) acoo%ia(i),acoo%ja(i),acoo%val(i) end do nzr = nnzero do i=1,nnzero @@ -312,6 +312,9 @@ subroutine smm_mat_read(a, info, iunit, filename) 902 info=902 write(psb_err_unit,*) 'READ_MATRIX: Unexpected end of file ' return +905 info=905 + write(psb_err_unit,*) 'READ_MATRIX: Error at line',i + return 993 info=993 write(psb_err_unit,*) 'READ_MATRIX: Memory allocation failure' return diff --git a/util/psb_z_mmio_impl.f90 b/util/psb_z_mmio_impl.f90 index 27da9617..b9a72d2e 100644 --- a/util/psb_z_mmio_impl.f90 +++ b/util/psb_z_mmio_impl.f90 @@ -270,7 +270,7 @@ subroutine zmm_mat_read(a, info, iunit, filename) if ((psb_tolower(type) == 'complex').and.(psb_tolower(sym) == 'general')) then call acoo%allocate(nrow,ncol,nnzero) do i=1,nnzero - read(infile,fmt=*,end=902) acoo%ia(i),acoo%ja(i),are,aim + read(infile,fmt=*,end=902,err=905) acoo%ia(i),acoo%ja(i),are,aim acoo%val(i) = cmplx(are,aim,kind=psb_dpk_) end do call acoo%set_nzeros(nnzero) @@ -284,7 +284,7 @@ subroutine zmm_mat_read(a, info, iunit, filename) ! we de-symmetrize what we are about to read call acoo%allocate(nrow,ncol,2*nnzero) do i=1,nnzero - read(infile,fmt=*,end=902) acoo%ia(i),acoo%ja(i),are,aim + read(infile,fmt=*,end=902,err=905) acoo%ia(i),acoo%ja(i),are,aim acoo%val(i) = cmplx(are,aim,kind=psb_dpk_) end do nzr = nnzero @@ -339,6 +339,9 @@ subroutine zmm_mat_read(a, info, iunit, filename) 902 info=902 write(psb_err_unit,*) 'READ_MATRIX: Unexpected end of file ' return +905 info=905 + write(psb_err_unit,*) 'READ_MATRIX: Error at line',i + return 993 info=993 write(psb_err_unit,*) 'READ_MATRIX: Memory allocation failure' return