Fortran水平不佳,编程经常遇到灵异事件。下面的数据是我求的数据平均值,但是算完以后生成的dat大小和原始一样,按理说不应该缩小时间的1/604么,望高人指点。
[Fortran] 纯文本查看 复制代码 program mean_spd
implicit none
integer::i, j, k , t, irec, it
integer, parameter::xx=161, yy=81, tt=604
real,dimension(xx, yy)::speed, mean_speed, sum
character(len=80), parameter::filename='wind_speed_weekly.dat'
character(len=80), parameter::outname='mean_spd.dat'
open(11, file=filename, action='read', access='direct', form='unformatted', recl=xx*yy*4)
open(12, file=outname, action='write', access='direct', form='unformatted', recl=xx*yy*4)
!open(123, file='mean_spd.txt')
mean_speed=0.
irec=0
do t=1, 604
read(11, rec=t)((speed(i, j), i=1, xx), j=1, yy)
mean_speed=mean_speed+speed
end do
mean_speed=mean_speed/604.
irec=irec+1
write(12, rec=irec)((mean_speed(i, j), i=1, xx), j=1, yy)
print*, irec
end program |