- 积分
- 3345
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2014-12-5
- 最后登录
- 1970-1-1
|
发表于 2015-10-18 16:26:17
|
显示全部楼层
program main
implicit none
parameter n=348
real x(n),y(n),c(n),d(n),t(n)
real a,b,sx,sxy,sum2,ave2,sum1,ave1
integer i
!open(1,file='d:/interannual/q/nino3.txt')
!open(2,file='d:/interannual/q/tloop79.txt')
!open(3,file='d:/interannual/q/3.txt')
!open(4,file='d:/interannual/q/4.grd',form='binary')
!open(5,file='d:/interannual/q/5.grd',form='binary')
open(1,file='f:/wwt/lr/nino1+2.txt')
open(2,file='f:/wwt/lr/ssta.grd',form='unformatted',status='old',access='direct',recl=1)
open(3,file='f:/wwt/lr/y1.grd',form='unformatted',status='replace',access='direct',recl=1)
open(4,file='f:/wwt/lr/y2.grd',form='unformatted',status='replace',access='direct',recl=1)
open(5,file='f:/wwt/lr/t.grd',form='unformatted',status='replace',access='direct',recl=1)
do i=1,n
read(1,*) x(i)
read(2,rec=i) y(i)
enddo
do i=1,n
write(3,rec=i) y(i)
enddo
sum1=0.0
sum2=0.0
sx=0.0
sxy=0.0
do i=1,n
sum1=sum1+x(i)
sum2=sum2+y(i)
enddo
ave1=sum1/n
ave2=sum2/n
do i=1,n
c(i)=x(i)-ave1
d(i)=y(i)-ave2
enddo
do i=1,n
sx=sx+c(i)**2
sxy=sxy+c(i)*d(i)
enddo
sx=sx/n
sxy=sxy/n
b=sxy/sx
a=ave2-ave1*b
do i=1,n
t(i)=a+b*x(i)
y(i)=y(i)-t(i)
enddo
do i=1,n
write(4,rec=i) y(i)
write(5,rec=i) t(i)
enddo
end
为什么这样算出来的数据在画图的时候老是出错呢
类似这种
Low Level I/O Error: Read error on data file Data file name = 20091012_RCWF.dat Error reading 141 bytes at location 79524 Data Request Error: Error for variable 'dbz' Error ocurred at column 1 DISPLAY error: Invalid expression Expression = dbz
ctl:dset f:/wwt/lr/y1.grd
title y1
undef -9.99e+08
xdef 1 linear 80.0 1.0
ydef 1 linear -15.0 1.0
zdef 1 linear 0 1.0
TDEF 348 LINEAR jan1979 1mo
vars 3
y1 0 99 yuanshi
y2 0 99 huigui
t 0 99 huigui
endvars
gs:'reinit'
'open f:\wwt\lr\y1.ctl'
'set lon 80'
'set lat -15'
'set lev 0'
'set t 1 348'
'set gxout line'
'set ccolor 4'
'd y1'
'printim f:/wwt/lr/y.png white'
; |
|