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

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 26743|回复: 20

[其他] ncl求助 :line-1 报错

[复制链接]

新浪微博达人勋

发表于 2014-10-20 17:01:44 | 显示全部楼层 |阅读模式

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

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

x
我是在UE里编辑好了之后导入的,格式也用dosunix转过,但一直是这样的报错:
fatal:syntax error: line 136 in file vaper_flux.ncl before or near \n
end
---^

fatal:error in statement
fatal:syntax error: line -1 before or near  

^

fatal:error in statement

错误中的line136是指的最后一行。这几天我一直遇到这种情况,之前一个脚本同样也是。请教了很多师兄,除了认为是格式的问题,其他的也不知道问题出现在哪里。请问怎样有效的避免这种情况呢?由于这个问题解决不了,整个脚本也没有开始读取。
谢谢各位大神,帮我分析一下呢。
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2014-10-20 21:38:59 | 显示全部楼层
避免这种错误的有效办法就是,写入do后立刻将end do补全,然后再去添加两者之间的代码!其它结构也一样,比如if和end if。
密码修改失败请联系微信:mofangbao
回复 支持 1 反对 0

使用道具 举报

新浪微博达人勋

发表于 2014-10-20 17:25:15 | 显示全部楼层
代码贴出来呗,肯定还是有语法错误!
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2014-10-20 17:36:01 | 显示全部楼层
是参考了之前一位同学发布的水汽通量图调用fortran的脚本:
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"
external  MY "/mnt/hgfs/E/term/20110723/vaporflux.so"
begin                                                
  ;========================
  ; get list of all files and open as "one big file"
  ;========================                             
    fall0302 = addfile("wrfout_d01_2011-07-23_00_00_00.nc","r")                        ; note the "s" of addfile
  ;========================
  ; choose how files are combined and read in variable across files
  ;========================  
  ; We generate plots, but what kind do we prefer?
; type = "x11"
; type = "pdf"
  type = "ps"
; type = "ncgm"
  wks = gsn_open_wks(type,"vaporflux")

;===============================================================
; What times and how many time steps are in the data set?
  times = wrf_user_getvar(a,"times",-1)  ; get all times in the file
  ntimes = dimsizes(times)         ; number of times in the file
  print(ntimes)
; The specific pressure levels that we want the data interpolated to.
  pressure_levels = (/850./)   ; pressure levels to plot
  nlevels         = dimsizes(pressure_levels)     ; number of pressure levels

;==========================================================

  do it = 0,ntimes-1,1             ; TIME LOOP

    print("Working on time: " + times(it) )
    res@TimeLabel = times(it)   ; Set Valid time to use on plots

;=================================================================
; First get the variables we will need        

    tc = wrf_user_getvar(fall0302,"tc",it)        ; T in C
    u  = wrf_user_getvar(fall0302,"ua",it)        ; u averaged to mass points
    v  = wrf_user_getvar(fall0302,"va",it)        ; v averaged to mass points
    p  = wrf_user_getvar(fall0302, "pressure",it) ; pressure is our vertical coordinate
    z  = wrf_user_getvar(fall0302, "z",it)        ; grid point height
    rh = wrf_user_getvar(fall0302,"rh",it)        ; relative humidity
      
;##########################################################################################   
   radius   =  20
   g        =  9.8

  ;*******************************************************************************************************
qu     =new((/12,41,41/),float)
qv     =new((/12,41,41/),float)
mm     =new((/12,41,41/),float)

;*******************************************************************************************
xx=41
yy=41
zz=1
tt=12
  
   MY::vaporflux(p,t,rh,u,v,qu,qv,mm,xx,yy,zz,tt,g)
   
    printVarSummary(qu)
   
    copy_VarMeta(u,qu)
    copy_VarMeta(v,qv)
    copy_VarMeta(rh,mm)

   printVarSummary(qu)

;=====================================================================================================
;plot
;=====================================================================================================


    res = True
    res@gsnAddCyclic  = False
    res@gsnDraw      = False                        ; don't draw yet
    res@gsnFrame     = False                        ; don't advance frame yet

                                       
    res@vcLineArrowThicknessF  = 2.0
    res@vcRefAnnoOrthogonalPosF  = 0            ;ref的位置
    res@vcRefAnnoString1On      = True
    res@vcRefAnnoString2On      = False
    res@vcRefMagnitudeF         = 20                 ; make vectors larger
    res@vcRefLengthF            = 0.1               ; ref vec length
    res@vcGlyphStyle            = "CurlyVector"     ; turn on curly vectors
    res@vcMinDistanceF          =0.02                ;箭头疏密
   
   
    res@vcVectorDrawOrder= "PostDraw"
    res@gsnLeftString =""
    res@gsnRightString =""
    res@tiMainString =""

   
    cnres                 = True                    ; plot mods desired
    cnres@gsnDraw         = False                   ; don't draw yet
    cnres@gsnFrame        = False                   ; don't advance frame yet
    cnres@cnFillOn        = True                    ; turn on color
    cnres@gsnSpreadColors = True                    ; use full colormap
    cnres@gsnSpreadColorStart = 0
    cnres@gsnSpreadColorEnd   = 201
    cnres@cnLinesOn       = False                   ; turn off contour lines
    cnres@cnLineLabelsOn  = False                   ; tuen off line labels
    cnres@cnInfoLabelOn =False
       
       
    cnres@cnLevelSelectionMode = "AutomaticLevels"
    ;cnres@cnMinLevelValF    = 4
    ;cnres@cnMaxLevelValF   = 42
    ;cnres@cnLevelSpacingF   =2
       
    cnres@gsnLeftString =""
    cnres@gsnRightString =" g s~S~ -1~N~cm~S~ -1~N~hPa~S~ -1"
    cnres@tiMainString =""
    cnres@lbLabelBarOn           = False   

   
        mm=smth9(mm,0.5,-0.25,False)

    printMinMax (mm*1000, True)
; dir = "/cma/u/Twangdh/hxe/example/"
   gsn_define_colormap(wks,"BlAqGrYeOrReVi200")       
   
   print("====plot..........===========")       
   plots = new((/2,12/),graphic)
     plots(0,5) =wrf_vector(fall0302,wks,qu(5,:,:)*1000,qv(5,:,:)*1000,res)  ; create plot
     plots(1,5) = wrf_contour(fall0302,wks,mm(5,:,:)*1000,cnres)
     overlay(plots(0,5),plots(1,5))
     draw(plots)
   
  frame(wks)
;#########################################################################
end
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2014-10-20 21:27:50 | 显示全部楼层
甜果果 发表于 2014-10-20 17:36
是参考了之前一位同学发布的水汽通量图调用fortran的脚本:
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/ ...

do没有end do
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2014-10-21 10:23:56 | 显示全部楼层
谢谢了 原来是这么低级的错误  
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2015-5-17 16:14:17 | 显示全部楼层
师姐!??
密码修改失败请联系微信:mofangbao
回复

使用道具 举报

新浪微博达人勋

 楼主| 发表于 2015-5-18 14:35:03 | 显示全部楼层

````你是???
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2015-5-19 13:27:24 | 显示全部楼层

这是我的小号,哈哈哈哈
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2015-9-22 09:24:36 | 显示全部楼层
太好了谢谢楼主
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

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

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

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