@@ -254,7 +254,8 @@ subroutine read_csv_file(me,filename,header_row,skip_rows,status_ok)
254
254
if (any (i== rows_to_skip)) cycle
255
255
end if
256
256
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
258
259
call me% tokenize(line,row_data)
259
260
260
261
if (.not. arrays_allocated) then
@@ -1123,13 +1124,14 @@ end function number_of_lines_in_file
1123
1124
! >
1124
1125
! Reads the next line from a file.
1125
1126
1126
- subroutine read_line_from_file (me ,iunit ,line )
1127
+ subroutine read_line_from_file (me ,iunit ,line , status_ok )
1127
1128
1128
1129
implicit none
1129
1130
1130
1131
class(csv_file),intent (in ) :: me
1131
1132
integer ,intent (in ) :: iunit
1132
1133
character (len= :),allocatable ,intent (out ) :: line
1134
+ logical ,intent (out ) :: status_ok ! ! true if no problems
1133
1135
1134
1136
integer :: nread ! ! character count specifier for read statement
1135
1137
integer :: istat ! ! file read io status flag
@@ -1138,6 +1140,7 @@ subroutine read_line_from_file(me,iunit,line)
1138
1140
nread = 0
1139
1141
buffer = ' '
1140
1142
line = ' '
1143
+ status_ok = .true.
1141
1144
1142
1145
do
1143
1146
! read in the next block of text from the line:
@@ -1149,7 +1152,9 @@ subroutine read_line_from_file(me,iunit,line)
1149
1152
else if (istat== 0 ) then ! all the characters were read
1150
1153
line = line// buffer ! add this block of text to the string
1151
1154
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
1153
1158
end if
1154
1159
end do
1155
1160
0 commit comments