@@ -254,7 +254,8 @@ subroutine read_csv_file(me,filename,header_row,skip_rows,status_ok)
254254 if (any (i== rows_to_skip)) cycle
255255 end if
256256
257- call me% read_line_from_file(iunit,line)
257+ call me% read_line_from_file(iunit,line,status_ok)
258+ if (.not. status_ok) return ! file read error
258259 call me% tokenize(line,row_data)
259260
260261 if (.not. arrays_allocated) then
@@ -1123,13 +1124,14 @@ end function number_of_lines_in_file
11231124! >
11241125! Reads the next line from a file.
11251126
1126- subroutine read_line_from_file (me ,iunit ,line )
1127+ subroutine read_line_from_file (me ,iunit ,line , status_ok )
11271128
11281129 implicit none
11291130
11301131 class(csv_file),intent (in ) :: me
11311132 integer ,intent (in ) :: iunit
11321133 character (len= :),allocatable ,intent (out ) :: line
1134+ logical ,intent (out ) :: status_ok ! ! true if no problems
11331135
11341136 integer :: nread ! ! character count specifier for read statement
11351137 integer :: istat ! ! file read io status flag
@@ -1138,6 +1140,7 @@ subroutine read_line_from_file(me,iunit,line)
11381140 nread = 0
11391141 buffer = ' '
11401142 line = ' '
1143+ status_ok = .true.
11411144
11421145 do
11431146 ! read in the next block of text from the line:
@@ -1149,7 +1152,9 @@ subroutine read_line_from_file(me,iunit,line)
11491152 else if (istat== 0 ) then ! all the characters were read
11501153 line = line// buffer ! add this block of text to the string
11511154 else ! some kind of error
1152- error stop ' Read error.'
1155+ if (me% verbose) write (error_unit,' (A,1X,I5)' ) ' Read error for file unit: ' ,iunit
1156+ status_ok = .false.
1157+ exit
11531158 end if
11541159 end do
11551160
0 commit comments