[Fortran] 纯文本查看 复制代码
Program www_fcode_cn
Implicit None
integer, parameter :: nDIR = 17 !// 17 种风向
character(len=5) , parameter :: cDir(nDIR) = &
(/'N','NNE','NE','ENE','E','ESE','SE','SSE','S','SSW','SW','WSW','W','WNW','NW','NNW','C'/)
integer :: iDirNum( nDIR ) = 0
character(len=79) :: filename="MH_58230_20131.txt"
integer, parameter :: fileid = 10
integer :: status = 0
logical alive
integer i , a , d , k
character(len=5) :: cDirRead
!open(12,file='newdata.txt')
inquire( file=filename, exist=alive)
if ( .not.alive ) then
write(*,*) TRIM(filename)," doesn't exist."
else
open(fileid,file=filename,status="old")
Do
read(fileid,*,iostat=k) a , a , a , d , cDirRead
if ( k /= 0 ) exit
if ( d == 8 ) then
Do k = 1 , nDIR
if ( cDir(k) == cDirRead ) exit
End Do
iDirNum(k) = iDirNum(k) + 1
end if
End Do
Do i = 1 , nDIR
if( iDirNum(i) > 0 ) write(*,*) Trim(cDir(i)) , ' 出现' , iDirNum(i) , '次'
End Do
close(fileid)
end if
End Program www_fcode_cn