- 积分
- 2794
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2015-1-6
- 最后登录
- 1970-1-1
|
发表于 2016-3-7 16:03:01
|
显示全部楼层
昂好的,那个我后续再加上,刚刚运行了下,感觉有点错。我把程序和结果放上来大大看看~
代码:
program surface
parameter(nt=2126)
integer::n,num,n1,n2,n3,n4
real,allocatable::lon(:),lat(:),ws(:) !动态数组分别用来储存站点的经纬度和风速
real:: temp(9)!?
character*8,allocatable::sta(:) !动态数组,储存站号,站号必须是8个字符,5个的话会stnmap出不出来
!character*8 ss(112) !112为华北112个站点,用于储存站点号
character*12 filename(nt) !用于储存2126个时次的文件名
open(1,file='F:\plot\filename.txt') !这个.txt里边按行储存了青岛站点站号
!read(11,*)
!do i=1,112
!read(11,*) ss(i)
!enddo
!close(11)
do i=1,nt
read(1,*) filename(i) !?read(11,*) ss(i)
print*,'Filename:',filename(i)
end do
close(1)
open(2,file='F:\plot\2015surface\windspeed.grd',form='binary') !储存2126个时次的风速
do k=1,nt
open(3,file=filename(k))
read(3,*)
read(3,*) n1,n2,n2,n4,n !将该时次的站点数赋值于n
allocate(lat(n)) !分配动态数组
allocate(lon(n))
allocate(ws(n))
allocate(sta(n))
close(3)
open(4,file=filename(k)) !获知n后,重新读取数据。
read(4,*)
read(4,*)
do i=1,n !只读风速,别的要素暂略
read(4,*) sta(i),lon(i),lat(i),(temp(j),j=1,9),ws(i)
tim=0.0;nlev=1;nflag=1
write(2) sta(i),lat(i),lon(i),tim,nlev,nflag,ws(i) !一个时次的降水场输入完毕
enddo
nlev=0
write(2) sta(n),lat(n),lon(n),tim,nlev,nflag
!一个时次的降水场输入完毕,告诉Grads 该时次的数据结束。这是一个特殊标记。
deallocate(lat)
deallocate(lon)
deallocate(ws)
deallocate(sta)
!释放动态数组
close(4)
enddo
close(2)
end
|
|