登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
最近想把以前的程序改写下,所以想到了ncl自带的function功能,做了一个简单的测试程序。开始放置于主程序的路径下,但怕找不到这个函数,就在$NCARG_ROOT/lib/ncarg/nclscripts/csm路径下又放置了一份子程序的代码。但从运行结果看,似乎还是没能找到这个函数,我参考了一下调用contributed的函数调用方式,调用方式应该是没有问题的。所以请教该如何修改程序。
子程序myfunc.ncl的内容为
undef ("foo")
function my_func(x:numeric,opt:logical)
local dimx,rankx,xx
begin
dimx = dimsizes(x)
rankx = dimsizes(dimx)
if(typeof(x).eq."float")then
if(opt.and.isatt(opt,"scale"))then
xx = x*opt@scale
else
xx = x
end if
else
return(x)
end if
end
主程序main.ncl的内容为:
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/myfunc.ncl"
begin
opt = True
opt@scale = 10
opt@add = 1000
opt@wgts = (/0.25,0.50,0.25/)
;opt@a3d = array_3D
data=(/1.0,2.0,3.0/)
var=data
print(var)
;printVarSummary(opt)
scale_var= my_func(var,opt) ;调用子程序,但这一行出问题了,为第20行
print(scale_var)
end
错误提示为:
fatal:Illegal right-hand side type for assignment fatal:["Execute.c":8578]:Execute: Error occurred at or near line 20 in file main.ncl
|