NCL 脚本错误:setvalues 函数语法错误
NCL 脚本错误:setvalues 函数语法错误
在使用 NCL 脚本时,您可能会遇到以下错误:
fatal:syntax error: line 14 in file a.ncl before or near ,
setvalues plot,
------------------^
fatal:Syntax Error in block, block not executed
fatal:error at line 15 in file a.ncl
这个错误通常是由于 setvalues 函数的语法错误导致的。
错误原因
错误的原因是在 NCL 脚本的最后一行中,setvalues 函数的语法不正确。
解决方案
要解决此问题,您需要将该行更改为:
setvalues plot, (/'wkOutputFilePath': '/share/home/gaoyf/gaoyf_hec/wrf/abc.png'/)
注意,需要将括号中的单引号更改为双引号。
修改后的完整脚本
load '$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl'
begin
a = addfile('geo_em.d01.nc','r') ; Open a file
type = 'png'
wks = gsn_open_wks(type,'plt_geo_1')
ter = a->HGT_M(0,:,:)
res = True ; Create plot resource variable
res@cnFillOn = True ; Enable filled contours
res@gsnSpreadColors = True ; Use color spread across the entire color map
plot = gsn_contour(wks,ter,res) ; Create plot
setvalues plot, (/'wkOutputFilePath': '/share/home/gaoyf/gaoyf_hec/wrf/abc.png'/)
end
通过对 setvalues 函数的语法进行调整,您就可以成功运行 NCL 脚本了。
原文地址: https://www.cveoy.top/t/topic/o8b5 著作权归作者所有。请勿转载和采集!