爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 7686|回复: 5

代码老是提示语法错误怎么办?

[复制链接]
发表于 2016-1-14 15:42:41 | 显示全部楼层 |阅读模式

登录后查看更多精彩内容~

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
这段代码 是用来画台风路径的。但是倒入之后一直显示 屏幕快照 2016-01-14 下午3.41.31.png

我也不知道为什么
下面是我的代码,有没有哪位好心人帮我看看到底是哪里错了?
;*************************************************
; traj.ncl
;*************************************************
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
;**************************************************
begin
;*************************************
; read in data
;************************************
; note this trajectory file contains data in the form of
; 4 variables x 577 timesteps
;   fiTY = “TF_FCST.TXT”
; ntime = numAsciiRow(fiTY)   
  ntime = 577
  lat=new(ntime,"float")
  lon=new(ntime,"float")
  alldata=asciiread("TF_FCST.TXT",-1,"string")
  lat=stringtofloat(str_get_field(alldata,2," "))
  lon=stringtofloat(str_get_field(alldata,3," "))
;********************************************
   wks = gsn_open_wks("X11","HaitangTrack")       ; open workstation
   res            = True                          ; map resources
   res@gsnDraw    = False                         ; don't draw
   res@gsnFrame   = False                         ; don't advance frame
;   res@vpWidthF   = 0.80                         ; make map bigger
;   res@vpHeightF  = 0.80
   res@mpMaxLatF  = 30                            ; select subregion
   res@mpMinLatF  = 15
   res@mpMinLonF  = 115
   res@mpMaxLonF  = 145
   res@mpLandFillColor = "old lace"                         ;160
   res@mpOceanFillColor = "white"
   res@mpGridAndLimbOn = "True"
   res@mpGridMaskMode = "MaskNotOcean"
   res@mpGridLineDashPattern = 15
   res@mpGridSpacingF = 5.0   
   res@mpOutlineOn = True
   res@mpOutlineBoundarySets = "National"   
   res@mpDataBaseVersion = "MediumRes"
   res@mpDataSetName = "Earth..4"
   res@mpOutlineSpecifiers = "China:States"
   res@tiMainString = "Haitang"

   res@tiMainString    = "2005HaitangTrack"                         ; title
   res@gsnCenterString = "markers every 4th time step"           ; center string

   plot = gsn_csm_map_ce(wks,res)                                 ; create map
;*********************************************
; trajectory parameters
;*********************************************
;*********************************************
; some plot parameters
;*********************************************
   pres                  = True               ; polyline resources
   pres@gsLineThicknessF = 2.0                ; line thickness
   colors= (/"red"/) ; line color

   mres  = True                               ; marker resources
   first = True                               ; start of traj resources
;********************************
   resLine = True
   resLine@gsLineThicknessF = 3                                                                                
   resLine@gsLineColor = "magenta"
   mres@gsMarkerIndex  = 16           ; marker style (circle)
   mres@gsMarkerSizeF  = 2.0          ; marker size

   mres@gsMarkerColor  = "red"      ; maker color
   dumLine=new(ntime,graphic)
   dumDot =new(ntime,graphic)
   do j=0,ntime-2
           xx=(/lon(j),lon(j+1)/)
           yy=(/lat(j),lat(j+1)/)
           dumLine(j)=gsn_add_polyline(wks,plot,xx,yy,resLine)
           dumDot(j)=gsn_add_polymarker(wks,plot,lon(j),lat(j),mres)
   end do
   dumDot(ntime-1)=gsn_add_polymarker(wks,plot,lon(ntime-1),lat(ntime-1),mres)

   draw(plot)                                          
   frame(wks)                                         

end


密码修改失败请联系微信:mofangbao
发表于 2016-1-14 16:46:37 | 显示全部楼层
[yinjf@io1 ~]$ ncl 11.ncl
Copyright (C) 1995-2015 - All Rights Reserved
University Corporation for Atmospheric Research
NCAR Command Language Version 6.3.0
The use of this software is governed by a License Agreement.
See http://www.ncl.ucar.edu/ for more details.
fatal:asciiread: Unable to open input file (TF_FCST.TXT)
fatal:["Execute.c":8575]:Execute: Error occurred at or near line 18 in file 11.ncl


运行方式不对
你不要进入ncl命令行,直接在shell中运行  ncl traj.ncl
密码修改失败请联系微信:mofangbao
 楼主| 发表于 2016-1-16 11:16:26 | 显示全部楼层
freekiller 发表于 2016-1-14 16:46
[yinjf@io1 ~]$ ncl 11.ncl
Copyright (C) 1995-2015 - All Rights Reserved
University Corporation  ...

ok 解决啦 谢了 !
刚开始用 对命令行也不熟悉 还需要学习哈
密码修改失败请联系微信:mofangbao
发表于 2019-7-9 23:42:35 | 显示全部楼层
freekiller 发表于 2016-1-14 16:46
[yinjf@io1 ~]$ ncl 11.ncl
Copyright (C) 1995-2015 - All Rights Reserved
University Corporation  ...

你好,我也遇到了同样的问题,老是提示line1错误,
[Administrator@PC-20180406ILZM:~]$ ncl D:/eee/sstcorre.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 D:/eee/sstcorre.ncl before or near ▒
▒
^

fatal:error in statement
请问直接在shell中运行是什么意思,我也是ncl 脚本名.ncl
刚学ncl,感谢
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

发表于 2019-7-9 23:56:01 | 显示全部楼层
请问楼主,不要进入ncl命令行,直接在shell中运行  ncl traj.ncl,难道不加绝对路径吗?在shell中运行是我上面的那种运行方式吗
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

发表于 2019-7-13 23:03:32 | 显示全部楼层
卷毛蓝鼻子 发表于 2019-7-9 23:42
你好,我也遇到了同样的问题,老是提示line1错误,
[Administrator@PC-20180406ILZM:~]$ ncl D:/eee/sst ...

贴出你的脚本
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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