program ch1103 implicit none integer, dimension (10) :: a = (/ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 /) integer :: io_stat_number = 0 integer :: i open (unit=1,file='data.txt',status='old') do i = 1, 10 read (unit=1,fmt=10,iostat=io_stat_number) a(i) 10 format (i3) if (io_stat_number==0) then cycle else if (io_stat_number==-1) then print *, ' end of file detected at line ', i print *, ' please check data file' exit else if (io_stat_number>0) then print *, ' non numeric data at line ', i print *, ' please correct data file' exit end if end do do i = 1, 10 print *, ' I = ', i, ' a(i) = ', a(i) end do end program ch1103