- 积分
- 6162
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2012-9-22
- 最后登录
- 1970-1-1
|
GrADS
系统平台: |
|
问题截图: |
|
问题概况: |
fortran+grads,想提取矩形区域,画出来的图很诡异! |
我看过提问的智慧: |
看过 |
自己思考时长(天): |
2 |
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
各位大虾,先谢谢了!
我现在想从一个280*200的中国及其周边地形格点数据topo.txt中提取出一个矩形区域,所以限定了i和j的范围,见以下程序:
program read_topo
implicit none
integer(kind=4),parameter::nx=280,ny=200
integer(kind=4) :: i,j
real topo(nx,ny),xgrid(ny),ygrid(nx)
!
!***open file
!
open(unit=12,file='topo.txt',form='formatted')
do i=1,nx
read(12,*) (topo(i,j),j=1,ny)
end do
close(12)
!
!***select topo
!
do i=1,nx
do j=1,ny
if(((i.ge.89).and.(i.le.198)) .and. ((j.ge.5).and.(j.le.98)))then
topo(i,j)=-99
end if
end do
end do
open(unit=44,file='after.txt',form='formatted')
do i=1,nx
write(44,'(200F10.4)') (topo(i,j),j=1,ny)
end do
close(44)
!
!***write files
!
open(unit=13,file="topo_tp_new.dat",form='unformatted',access='direct',&
status='replace',recl=4*nx*ny)
write(13,rec=1)((topo(i,j),j=1,ny),i=1,nx)
print*,topo(1,1)
close(13)
print*,topo(1,1),topo(200,200),topo(161,3)
end program read_topo
然后,我又写了ctl文件,如下:
dset topo_tp_new.dat
undef -99
options little_endian
xdef 280 linear 75.3785 0.25
ydef 200 linear 5.41628 0.25
zdef 1 levels 1
tdef 1 linear jan2008 1mon
vars 1
topo 0 99 topography
endvars
但画出来的图很诡异,见附图,不知道怎么回事,请大家帮忙看看,多谢了!
|
|