1)报错信息
DO WHILE (.NOT.EOF(IUNAG))
Error:Operand of .not. operator at(1)is REAL(4)
2)问题分析
fortran标准里没有eof函数
eof确实识别成了real
3)问题解决
采用类似这个方式来进行:
read(unit, *, iostat = io_status) number
program read_file
implicit none
integer :: unit, i, io_status
real :: number
unit = 10 ! 文件单元号
open(unit, file = 'data.txt', status = 'old')
do
read(unit, *, iostat = io_status) number
if (io_status < 0) then
print *, 'End of file reached.'
exit
end if
print *, number
end do
close(unit)
end program read_file
4)