本帖最后由 vvt 于 2017-1-31 23:48 编辑
[Fortran] 纯文本查看 复制代码 PROGRAM MAIN
USE typedef
implicit none
real::rain
type(tdd),allocatable::t(:)! 保存气温值
type(tdd):: total !日均温累加
integer i , m , dy , start , end
character(len=3) :: line
open(7,file="CN019067")
I=0
do
READ(7,*,end=100) line
i=i+1
end do
100 m = i - 1 !//你这个前面只多了一行
rewind(7)
allocate( t(m))
read(7,*)
write(*,*)"start:"
read(*,*) start
write(*,*)"end:"
read(*,*) end
do i=1,m
read(7,*)dy , t(i)%tmax , t(i)%tmin , rain
t(i)%average=(t(i)%tmax+t(i)%tmin)/2 !日均温
end do
total%average = 0
do i=start,end
total%average=total%average+t(i)%average !日均温累加=积温
enddo
print *, dy,total%average !
end PROGRAM |