本帖最后由 chuxf 于 2014-3-7 13:34 编辑
[Fortran] 纯文本查看 复制代码 Program www_fcode_cn
Implicit None
integer :: ierr
integer :: i , year , mon , day
integer :: yearlast , monlast , daylast , c
real :: d , a
Open( 12 , File = '57517(4年).txt' )
Open( 13 , File = 'out.txt' )
read(12,*)
yearlast = -1
monlast = -1
daylast = -1
a = 0.0
c = 0
Do
Read( 12 , * , ioStat=ierr ) i , year , mon , day , d
if ( ( ierr== 0 ) .and. (year == yearlast) .and. (mon == monlast) .and. ( (day>15)==(daylast>15) ) ) then !// 同一个半月
if ( ( d > 12.0 ) .and. ( d < 3000.0 ) ) then
a = a + d
c = c + 1
end if
else
if( c> 0 ) then
a = a / c
write(13,*) yearlast , monlast , a , c
end if
a = 0.0
c = 0
if ( ( d > 12.0 ) .and. ( d < 3000.0 ) ) then
c = 1
a = d
end if
end if
yearlast = year
monlast = mon
daylast = day
if ( ierr /= 0 ) Exit
End Do
Close( 12 )
Close( 13 )
End Program www_fcode_cn |