[Fortran] 纯文本查看 复制代码
Program fengxiang
Implicit None
integer, parameter :: nDIR = 18
character(len=5) , parameter :: cDir(nDIR) = &
(/'N','NNE','NE','ENE','E','ESE','SE','SSE','S','SSW','SW','WSW','W','WNW','NW','NNW','C','-99'/)
integer:: hour08(18 ) = 0
integer:: hour14(18 ) = 0
integer:: hour20(18 ) = 0
real:: total(18) =0
integer::x(18)=0
character(len=79) :: filename="D:\各地风向资料\230.txt"
integer, parameter :: fileid = 10
logical alive
integer i ,station,month,day, hour , k
character(len=6) :: cDirRead
real l,year
inquire( file=filename, exist=alive)
if ( .not.alive ) then
write(*,*) TRIM(filename)," doesn't exist."
else
open(fileid,file=filename,status="old")
open(unit=12,file='D:\各地风向资料\处理后数据\230_04.txt')
Do
read(fileid,*,iostat=k) station ,year ,month,day,hour,cDirRead
if ( k /= 0 ) exit
if(month==1.or.month==3.or.month==5.or.month==7.or.month==8.or.month==10.&
or.month==12))then
l=558.0
else if(month==4.or.month==6.or.month==9.or.month==11) then
l=540.0
else if(month==2) then
l=29*2*3.0+28*4*3.0
end if
if (month==4)then
if ( hour == 8 ) then
Do k = 1 , nDIR
if ( cDir(k) == cDirRead ) exit
End Do
hour08(k) = hour08(k) + 1
else if(hour==14) then
Do k = 1 , nDIR
if ( cDir(k) == cDirRead ) exit
End Do
hour14(k) = hour14(k) + 1
else if(hour==20) then
Do k = 1 , nDIR
if ( cDir(k) == cDirRead ) exit
End Do
hour20(k) = hour20(k) + 1
end if
end if
End Do
Do i = 1 , nDIR
x(i)=hour08(i)+hour14(i)+hour20(i)
total(i)=(hour08(i)+hour14(i)+hour20(i))/l
write(12,"(a3,3xf6.1,3xi3,3xf10.8)")Trim(cDir(i)),l ,x(i),total(i)
End Do
close(fileid)
end if
stop
End
[Fortran] 纯文本查看 复制代码
Select Case ( Month )
case ( 1 , 3 , 5 , 7 , 8 , 10 , 12 )
L = 558.0
case ( 4 , 6 , 9 , 11 )
L = 540.0
case ( 2 )
L = 29*2*3.0 + 28*4*3.0
End Select