- 积分
- 2773
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2011-11-23
- 最后登录
- 1970-1-1
|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
我想用这个插值程序把高斯格点资料(经度是等间距1.875,纬度是不等间距的)插值成0.5*0.5的均匀网格数据。只对中国区域进行插值,并且只是一个时次的。出来的结果是图中有很多空白区域,怎么回事呢?求指点啊!大家帮忙看看,非常感谢!
program inter
implicit none
integer,parameter::ex=37,ey=25,et=1,gx=140,gy=90 !! Input values --------- =*= ----------
real,parameter::undef=-9.96921e+36
real::glat(gx,gy),glon(gx,gy),grid(gx,gy),elat(ex,ey),elon(ex,ey),ease(ex,ey),lat(ey),f(ex,ey),p(gx,gy)
real::t,u,it,m,n
integer::i,j,k,ii,jj,index,irec
!----*-----------------------------------------------------6---------7--
open(10,file='d:\mm\mmm.grd', form='unformatted',access='direct',recl=ex*ey)
read(10,rec=1) ((f(i,j),i=1,ex),j=1,ey)
close(10)
open(20,file='d:\mm\elat.txt',form='formatted')
read(20,*) (lat(j),j=1,ey)
close(20)
!pause
!----*-----------------------------------------------------6---------7--
do j=1,ey
do i=1,ex
elat(i,j)=lat(j)
elon(i,j)=71.25+1.875*(i-1)
enddo
enddo
do n=1,gy
do m=1,gx
glat(m,n)=15.25+0.5*real(n-1)
glon(m,n)=70.25+0.5*real(m-1)
enddo
enddo
do j=1,ey
do i=1,ex
if(f(i,j)==9.96921e+36)then
ease(i,j)=0.0
else
ease(i,j)=f(i,j)
end if
enddo
enddo
call bilinear(elat,elon,ex,ey,ease,glat,glon,gx,gy,grid) ! VIP=Very Important Part
write(*,*)
do n=1,gy
do m=1,gx
p(m,n)=grid(m,n)
enddo
enddo
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
open(2,file='d:\mm\ccout.txt',form='formatted')
! do k=1
write(2,*) ((p(i,j),i=1,gx),j=1,gy)
close(2)
!----*-----------------------------------------------------6---------7--
open(30,file='d:\mm\cm.grd',form='binary')
write(30) ((p(i,j),i=1,gx),j=1,gy)
close(30)
!----*-----------------------------------------------------6---------7--
stop
end
!----*-----------------------------------------------------6---------7--
! --- convert from EASE to GRID using bilinear interpolation ---
! Input ex, ey, gx, gy, ease, elat, elon, glat, glon
! ex
! ey
! gx
! gy
! elat(ex,ey)
! elon(ex,ey)
! elat(ex,ey)
! glat(gx,gy)
! glon(gx,gy)
! Output grid
! grid(gx,gy)
!----*-----------------------------------------------------6---------7--
subroutine bilinear(elat,elon,ex,ey,ease,glat,glon,gx,gy,grid)
! --- convert from EASE to grid using bilinear interpolation ---
integer::ex,ey,gx,gy
dimension elat(ex,ey),elon(ex,ey),ease(ex,ey)
dimension glat(gx,gy),glon(gx,gy),grid(gx,gy)
do 141 i=1,gx
do 142 j=1,gy
do 143 ii=1,ex-1
do 143 jj=1,ey-1
if(glat(i,j).gt.elat(ii,jj) .and. glat(i,j).lt.elat(ii+1,jj+1) & ! i/=ii,j/=jj
& .and. glon(i,j).gt.elon(ii,jj+1) .and. glon(i,j).lt.elon(ii+1,jj))then
i0=ii
j0=jj
t=(glon(i,j)-elon(ii,jj))/(elon(ii+1,jj)-elon(ii,jj))
u=(glat(i,j)-elat(ii,jj))/(elat(ii,jj+1)-elat(ii,jj))
index=1
if(index.eq.1)then
grid(i,j)=(1.-t)*(1.-u)*ease(i0,j0)+ &
& (1.-t)*u*ease(i0,j0+1)+ &
& t*(1.-u)*ease(i0+1,j0)+ &
& t*u*ease(i0+1,j0+1)
endif
elseif(glat(i,j).eq.elat(ii,jj) & ! i==ii,j/=jj
& .and. glon(i,j).gt.elon(ii,jj) .and. glon(i,j).lt.elon(ii,jj+1))then
i0=ii
j0=jj
t=0.
u=(glat(i,j)-elat(ii,jj))/(elat(ii,jj+1)-elat(ii,jj))
index=2
if(index.eq.2)then
grid(i,j)=(1.-t)*(1.-u)*ease(i0,j0)+ &
& (1.-t)*u*ease(i0,j0+1)
endif
elseif(glon(i,j).eq.elon(ii,jj) & ! i/=ii,j==jj
& .and. glat(i,j).gt.elat(ii,jj) .and. glat(i,j).lt.elat(ii+1,jj) )then
i0=ii
j0=jj
t=(glon(i,j)-elon(ii,jj))/(elon(ii+1,jj)-elon(ii,jj))
u=0.
index=3
if(index.eq.3)then
grid(i,j)=(1.-t)*(1.-u)*ease(i0,j0)+ &
& t*(1.-u)*ease(i0+1,j0)
endif
elseif(glat(i,j).eq.elat(ii,jj) & ! i==ii,j==jj
& .and. glon(i,j).eq.elon(ii,jj))then
i0=ii
j0=jj
t=0.
u=0.
index=4
if(index.eq.4)then
grid(i,j)=(1-t)*(1-u)*ease(i0,j0)
endif
! elseif
grid(i,j)=0.
endif
143 continue
142 continue
141 continue
return
end
|
-
-
cc.wmf
446.46 KB, 下载次数: 21, 下载积分: 金钱 -5
|