<Example Program>
Program is_iostat_eor_example
Character c
Integer ios, nchars, nlines, nvowels
nchars = 0
nlines = 0
nvowels = 0
Do
Read (*,'(A)',Advance='No',Iostat=ios) c
If (Is_Iostat_End(ios)) Exit
If (ios==0) Then
nchars = nchars + 1
If (Verify(c,'aeiouAEIOU')>0) nvowels = nvowels + 1
Else If (Is_Iostat_Eor(ios)) Then
nlines = nlines + 1
Else
Print *, 'Unexpected i/o error', ios
Stop
End If
End Do
Print *, 'The input contained', nchars, 'characters in', nlines, 'lines.'
Print *, nvowels, 'of the characters were vowels.'
End Program
Execution Results
Now is the time◊ for all good men◊ to come to the aid◊ of the party.◊where ◊ indicates the end of each record, the output is
The input contained 62 characters in 4 lines. 42 of the characters were vowels.