read(1,'(i4)', iostat = irc) integer_value

if(irc /= 0) then backspace(1) read(1,'(a)') string write(*,*)'error number',irc,'reading ',string,' Bye!' call abort() endif