请选择 进入手机版 | 继续访问电脑版
爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 2280|回复: 2

[求助]NCL编译报错,syntax error: line 1 in file xxx.ncl before or near fatal

[复制链接]

新浪微博达人勋

发表于 2022-11-5 13:07:23 | 显示全部楼层 |阅读模式
5金钱
NCL新手,在服务器里面安装了ncl,版本是6.4.0
我要编译的脚本是气象家园之前的大神发布过的脚本 我只是进行了一些修改
原代码的网址是:提取wrfout_10米高度(气压、露点、温度、风向、风速),大佬们帮忙检查下脚本对不对-编程作图-气象家园_气象人自己的家园 (06climate.com)

我修改了其中的路径和经纬度后脚本为:

; --------------  LOAD FUNCTIONS AND PROCEDURES ----------------
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/wrf/WRFUserARW.ncl"
begin
; ------------------read wrfout file-------------------

dir   = "/public/lapc/Tgq/environment/WRF/data/wrfout/20180101/"
files = systemfunc("ls " + dir + "wrfout_d03_2018-01-01_00:00:00")
a     = addfiles(files,"r")
;a = addfiles("/home/jina/Build_WRF/WRF输出文档/(2021-09-15)2006-04-01~31号/wrfout_d03_2006-04-01_00:00:00" ,"r")

; Process all the time steps
times = wrf_user_list_times(a)             ; get all times in the file
ntimes = dimsizes(times)            ; number of times in the file
; -----------read Wind\temperature\dew point temperature\pressure\Height
u_ph  = wrf_user_getvar(a,"U10",-1)        ; u averaged to mass points
v_ph  = wrf_user_getvar(a,"V10",-1)        ; v averaged to mass points
tch=wrf_user_getvar(a, "tc",-1)
tdh=wrf_user_getvar(a, "td",-1); td(ntim,nlvl,nlat,nlon)

ph=wrf_user_getvar(a, "pressure",-1)
pbh=wrf_user_getvar(a, "PB",-1)
height  = wrf_user_getvar(a, "z",-1)
ter = wrf_user_getvar(a, "ter",-1) ; ter=HGT(HGT_M, HGT_U, HGT_V)

;---------------- Select set station lon,lat,fixed height(from surface(m))[CHANGE HERE]-----------------------------
Latitude = 36.67
Longitude = 117

;------------------------------------------------------------------
res = True
res@returnInt = True                       ; False : return real values, True: return interger values
point = wrf_user_ll_to_ij(a,Longitude,Latitude,res)       ; wrf_user_ll_to_ij(nc_file,lon,lat,opt)
point =point -1
x = point(0)
y = point(1)

print("X location is: " + x)            ; print the value of X at the screen
print("Y location is: " + y)            ; print the value of Y at the screen
nheight = conform(height,ter,(/0,2,3/)) ; assuming height is a 3d array and ter is a 2d array
height = height - nheight

;-------------------------------------------------------------
spdh=sqrt(u_ph^2+v_ph^2)
windspdh=spdh(:,x,y)
dirh=wind_direction(u_ph,v_ph,0)
winddirh=dirh(:,x,y)
tcc=tch(:,0,x,y)
tdc=tdh(:,0,x,y)
phc=ph(:,0,x,y)+pbh(:,0,x,y)  ;units:pa

;  ------ WRITE IN FILE ---------------                    *
npts=ntimes
fName = "结果_提取10米高度(气压、露点、温度、风向、风速).txt"   ;FILENAME
data  = new( npts, "string")  ;OUTPUTDATE
print("       时间                气压      露点温度      温度         风向        风速 ")
print ( times+sprintf("%12.1f",phc/100)+sprintf("%12.1f",tdc)+ sprintf("%12.1f",tcc)+sprintf("%12.0f",winddirh)+sprintf("%12.1f", windspdh) )
data = times +sprintf("%12.1f",phc/100)+sprintf("%12.1f",tdc)+ sprintf("%12.1f",tcc)+sprintf("%12.0f",winddirh)+sprintf("%12.1f", windspdh)
asciiwrite (fName,data)
end


报错信息为:
[Tgq@mgmt02 20180101]$ ncl newextract10m.ncl
Copyright (C) 1995-2017 - All Rights Reserved
University Corporation for Atmospheric Research
NCAR Command Language Version 6.4.0
The use of this software is governed by a License Agreement.
See http://www.ncl.ucar.edu/ for more details.
fatal:syntax error: line 1 in file newextract10m.ncl before or near

^

fatal:error in statement


我没有发现这个脚本里有什么问题,辛苦大神帮忙解答,万分感谢!

密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2022-11-25 11:42:36 | 显示全部楼层
运行了下你的代码,我这边没有你这样的报错。代码应该是没问题,你可以试试文件转换一下:
dos2unix newextract10m.ncl
看看是不是格式编码的问题
密码修改失败请联系微信:mofangbao
回复

使用道具 举报

新浪微博达人勋

发表于 2022-12-15 21:49:25 | 显示全部楼层
666666666666666666666
密码修改失败请联系微信:mofangbao
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

Copyright ©2011-2014 bbs.06climate.com All Rights Reserved.  Powered by Discuz! (京ICP-10201084)

本站信息均由会员发表,不代表气象家园立场,禁止在本站发表与国家法律相抵触言论

快速回复 返回顶部 返回列表