READF: End of file encountered. Unit: 100

File contents:

20.2 22.93

22.23 26.1

19.92 23.55

19.33 24.7

20.68 24.25

24.83 29.47

23.88 29.53

24.55 29.1

22.48 27.17

22.32 27.28

25.62 30.08

23.3 28.75

20.98 24.55

22.68 28.08

23.92 26.52

19.73 24.37

24.88 29.03

27.12 32.48

20.92 26.25

27.55 33.52

27.58 35.18

27.4 31.47

25.87 30.52

25 29.5

 

 

example code:

 

IDL> print, file_lines('sample1.txt')

24

IDL> openr, lun, 'sample1.txt', /get_lun

IDL> readf, lun, data1

IDL> print, data1

20.2000

IDL> readf, lun, data2

IDL> print, data2

22.2300

IDL> data = fltarr(2,24)

IDL> readf,lun,data

% READF: End of file encountered. Unit: 100, File: sample1.txt

% Execution halted at: $MAIN$

What happened? Read beyond the end of the file(because we had already read in the first 2 lines)

IDL> point_lun, lun, 0

IDL> readf,lun,data

IDL> print, min(data), max(data)

 

;PRO file

 

 

pro readfile

file='sample1.txt'

openr,lun,file, /get_lun

lines=file_lines(file)

 

thislat=fltarr(lines)

thislon=fltarr(lines)

 

temp1=0.0

temp2=0.0

 

point_lun, lun, 0

;header=''

;readf, lun, header

 

FOR j=0, lines-1 DO BEGIN

readf,lun, temp1, temp2

thislat[j]=temp1

thislon[j]=temp2

ENDFOR

close,lun

free_lun, lun

print, thislat, thislon

print, 'done!'

 

end

我碰到的这个问题原因是我没有free_lun,lun

转载于:https://www.cnblogs.com/RSmountain/archive/2013/02/05/2893267.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值