- 积分
- 2473
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2015-3-27
- 最后登录
- 1970-1-1
|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
本帖最后由 东风急流 于 2015-10-5 19:18 编辑
针对上一个帖子给我的提示,我对我的fortran文件和ncl文件做出了修改,用加粗标注了,但还是有问题,说数组维数超出,希望大家能再帮我看看啊,谢谢~
想用ncl读取一个二进制数组,300*400的实型数组(soilana.dat),然后去替换wrfinput里面的土壤湿度第一个时间第一层的值SMOIS(1,1,i, j)(是300*400的)
我的ncl脚本是这么写的:
;======================================================
; This script is used to read a binary file and write the var to the netCDF file.
;======================================================
begin
nx=299
ny=399
a=addfile("./wrfinput.nc","w")
soil=new((/nx,ny/),"float")
soil=fbindirread("/home/lw/soil/soilana.dat",1,(/nx,ny/),"float")
;-----------------------
; change the field
;-----------------------
s=a->SMOIS
do i=1,300,1
do j=1,400,1
s(1,1,i,j)=soil(i-1,j-1)
end do
end do
;-----------------------
;write the field
;-----------------------
a->SMOIS=s
end
运行ncl时总提示我数组设置的太大,比读取记录的数据大。现在的提示如下:
warning:fbinrecread: the size impliede by the dimension array and record number is greater than record size of the file
fatal:["Execute.c":8128]:Execute: Error occurred at or near line 17 in file wrf_var_replace.ncl
再附上我写这个二进制文件的fortran程序:program rw
implicit none
character(len=30):: filename10="2012060306-ass_vsm_result.dat"
integer,parameter::m=400,n=300
real:: temp2(m,n),temp3(m,n)
integer:: error,i,j
!big endian表示数据在大型机上生成,现在不在这类机器上使用
open(10,file=filename10,access="direct",form="unformatted",recl=m*n,convert="big_endian",status="old")
open(30,file="soilsim.dat",access="direct",form="unformatted",recl=m*n)
open(40,file="soilana.dat",access="direct",form="unformatted",recl=m*n)
read(10,rec=2,iostat=error) ((temp2(i,j),i=1,m),j=1,n)
read(10,rec=3,iostat=error) ((temp3(i,j),i=1,m),j=1,n)
!用作测试是否正常读完数据
print*,error
write(30,rec=1) ((temp2(i,j),i=1,m),j=1,n)
write(40,rec=1) ((temp3(i,j),i=1,m),j=1,n)
我用grads检查过我的ana.dat,写300*400的ctl画图没问题,说明是120000个数据啊,怎么到了ncl里面就不是的呢?求到底改写多少啊。。。。。
!养成关闭文件的好习惯
close(10)
|
|