我正在尝试使用Ubuntu-13中的“gfortran”读取制表符分隔的文本文件。我得到以下错误 “Fortran运行时错误:浮点读取期间的值不正确”
计划如下;
CHARACTER*8 STID
OPEN (8,FILE='station.txt', STATUS='OLD',FORM='FORMATTED')
OPEN (10,FILE='stn.dat',FORM='UNFORMATTED')
IFLAG = 0
C Read and Write
10 READ (8,9000,END=90) IYEAR,IMONTH,STID,RLAT,RLON,RVAL
9000 FORMAT (I4,T1,I2,T1,A8,3F5.1)
IF (IFLAG.EQ.0) THEN
IFLAG = 1
IYROLD = IYEAR
IMNOLD = IMONTH
ENDIF
C If new time group, write time group terminator.
C Assuming no empty time groups.
IF (IYROLD.NE.IYEAR.OR.IMNOLD.NE.IMONTH) THEN
NLEV = 0
WRITE (10) STID,RLAT,RLON,TIM,NLEV,NFLAG
ENDIF
IYROLD = IYEAR
IMNOLD = IMONTH
C Write this report
TIM = 0.0
NLEV = 1
NFLAG = 1
WRITE (10) STID,RLAT,RLON,TIM,NLEV,NFLAG
WRITE (10) RVAL
GO TO 10
C On end of file write last time group terminator.
90 CONTINUE
NLEV = 0
WRITE (10) STID,RLAT,RLON,TIM,NLEV,NFLAG
PRINT *, STID,RLAT,RLON,TIM,NLEV,NFLAG
STOP
END
输入文本文件类似于
1985 11 AAAA 18.2 42.7 9.2
1985 11 BBBB 25.3 49.5 0.0
1985 11 cccc 21.5 41.6 22.6
1985 11 ddddd 29.8 40.1 3.6
.... .. ..... .... .... ...