爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 10030|回复: 6

[其他] NCL脚本运行时出现下标越界问题怎么办??

[复制链接]
发表于 2015-4-25 11:49:30 | 显示全部楼层 |阅读模式

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

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

x
fatal:Subscript out of range, error in subscript #0
fatal:An error occurred reading lat
fatal:Execute: Error occurred at or near line 101 in file read_arwpost_60X60.ncl

how to 解决这些问题??拜谢各位大神

                               
登录/注册后可看大图



——————————————————————————————————————————————————
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"
;load "/home/wangxy/wrf_ncl_examples/website/WRFUserARW_add.ncl"
;load "/raid5e2/wangxy/BJClimate/post/WRFwxy11.ncl"
begin
  
  a = "/home/Administrator/basic_res.dat"
  b = addfile("/home/Administrator/geo_em.d01.nc","r")
  type = "ps"
  wks = gsn_open_wks(type,"nox_ave")
  gsn_define_colormap(wks,"gui_default")
;****************************************************
; get data
  lat = wrf_user_getvar(b,"XLAT_M",0)
  lon = wrf_user_getvar(b,"XLONG_M",0)
  hgt = wrf_user_getvar(b,"HGT_M",0)
  setfileoption ("bin", "ReadByteOrder", "BigEndian")
  dim0=80
  dim1=80
  dim2D = (/dim0,dim1/)
  so2=new((/dim0,dim1/),"float")
    so2!0="west_east"
    so2!1="south_north"
  no2=new((/dim0,dim1/),"float")
    no2!0="west_east"
    no2!1="south_north"
  no=new((/dim0,dim1/),"float")
    no!0="west_east"
    no!1="south_north"
  nox=new((/dim0,dim1/),"float")
    nox!0="west_east"
    nox!1="south_north"
  so4=new((/dim0,dim1/),"float")
    so4!0="west_east"
    so4!1="south_north"
  nh4=new((/dim0,dim1/),"float")
    nh4!0="west_east"
    nh4!1="south_north"
  no3=new((/dim0,dim1/),"float")
    no3!0="west_east"
    no3!1="south_north"
  ec=new((/dim0,dim1/),"float")
    ec!0="west_east"
    ec!1="south_north"
  pm25=new((/dim0,dim1/),"float")
    pm25!0="west_east"
    pm25!1="south_north"
  pm10=new((/dim0,dim1/),"float")
    pm10!0="west_east"
    pm10!1="south_north"
  vis=new((/dim0,dim1/),"float")
    vis!0="west_east"
    vis!1="south_north"
  so2  = fbindirread(a, 0 ,dim2D,"float")
  no2  = fbindirread(a, 1 ,dim2D,"float")
  no   = fbindirread(a, 2 ,dim2D,"float")
  so4  = fbindirread(a, 3 ,dim2D,"float")
  nh4  = fbindirread(a, 4 ,dim2D,"float")
  no3  = fbindirread(a, 5 ,dim2D,"float")
  ec   = fbindirread(a, 6 ,dim2D,"float")
  pm25 = fbindirread(a, 7 ,dim2D,"float")
  pm10 = fbindirread(a, 8 ,dim2D,"float")
  vis  = fbindirread(a, 9 ,dim2D,"float")
  nox=no2+no
;********************************************************
; creat plot
  res = True
  res@cnFillOn          = True  ; turn on color
  res@cnLinesOn         = False ; no contour lines
  res@cnInfoLabelOn     = False
  res@gsnAddCyclic      = False ; regional data
;  res@cnLevelSelectionMode = "ExplicitLevels"
;  res@cnLevels = (/0., 250., 500., 750., 1000., 2500., 5000., 10000., \
;                   200000., 300000. /)
  res@cnLevelSelectionMode = "ManualLevels"
; vis 1 15 1; so2/no2/no/nox 0 120 10; pm10/25 0 220 20; ec 0 10 1;  so4 0 15 1; nh4 0 4 0.5; no3 0 0.4 0.05
  res@cnMinLevelValF    =  0.
  res@cnMaxLevelValF    =  120.
  res@cnLevelSpacingF   = 10.
;  res@cnFillColors     = (/4,7,8,9,10,11,13,16,22,23/)
;  res@cnFillColors      = (/4,6,9,12,14,16,20,23/)
; The following resources are Required to plot this projection correctly
  res@mpLimitMode         = "Corners"           ; method to zoom
  res@mpLeftCornerLatF    = lat(10,10)
  res@mpLeftCornerLonF    = lon(10,10)
  res@mpRightCornerLatF   = lat(dim1-11,dim1-11)
  res@mpRightCornerLonF   = lon(dim0-11,dim0-11)
  res@mpProjection        = "LambertConformal"     ; projection
  res@mpLambertParallel1F =  31.88961
  res@mpLambertParallel2F =  31.88961
  res@mpLambertMeridianF  =  120.5875
  res@tfDoNDCOverlay        = True  ; only it is False can use @lat2d @lon2d
  res@pmTickMarkDisplayMode = "Always"
  res@pmLabelBarDisplayMode = "Always" ; turn on color bar
  res@pmLabelBarSide        = "Bottom" ; put it on the bottom of plot
  res@pmLabelBarWidthF      = 0.6      ; control size of colorbar
  res@pmLabelBarHeightF     = 0.1      ;
  res@pmLabelBarOrthogonalPosF = -0.02   ; position wrt plot
;  res@lbLabelAutoStride  = True  ; every other label
  res@lbLabelFontHeightF = 0.016 ; label bar font
  res@lbOrientation      = "Horizontal" ; label bar orientation
  res@lbPerimOn          = False ; no box around label bar
  res@lbAutoManage       = False ; we control how drawn not plot
  plot = gsn_csm_contour_map (wks,nox(10:69,10:69),res)
end
密码修改失败请联系微信:mofangbao
发表于 2015-4-25 12:01:54 | 显示全部楼层
下标超出单位,检查你的数组大小
密码修改失败请联系微信:mofangbao
发表于 2015-4-25 12:01:57 | 显示全部楼层
下标超出单位,检查你的数组大小
密码修改失败请联系微信:mofangbao
 楼主| 发表于 2015-4-25 15:28:31 | 显示全部楼层
又是那隻貓 发表于 2015-4-25 12:01
下标超出单位,检查你的数组大小

那是数组太大还是太小??
密码修改失败请联系微信:mofangbao
发表于 2015-4-25 21:26:58 | 显示全部楼层
好歹也标注一下出错的101行在什么地方啊!
密码修改失败请联系微信:mofangbao
发表于 2015-10-10 18:24:30 | 显示全部楼层
问题解决了吗
密码修改失败请联系微信:mofangbao
发表于 2019-10-31 16:56:05 | 显示全部楼层
请问大神如何解决?
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

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