Subscript out of range, error in subscript #0

From: 朱学明 <557xiaozhu_at_nyahnyahspammersnyahnyah>
Date: Wed Sep 04 2013 - 18:37:28 MDT

When I tried to plot the vector fields from ROMS results. My code is as follow. I have many years monthly data since 1993-2000, so the variable v's dimension size should be 96*22*633*1545. But when it run to nb=13, I have got an error message as follow,

fatal:Subscript out of range, error in subscript #0
fatal:["Execute.c":8128]:Execute: Error occurred at or near line 250 in file $NCARG_ROOT/lib/ncarg/nclscripts/roms/ROMS_utils.ncl

fatal:["Execute.c":8128]:Execute: Error occurred at or near line 188 in file ROMS_vector_plot_rectangle.ncl

My ncl code is as follow,

;----------------------------------------------------------------------
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/roms/ROMS_utils.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
;************************************************
begin
;************************************************
; read in netCDF file
;************************************************
  data_file = "np8_monthly_*.nc"
; data_file = "np8_clm_mon*.nc"
  nb = 12
  ne = -1
  depth = -20.0

  lat_min = 0
  lat_max = 25
  lon_min = 99
  lon_max = 125
  resol = 1

  infile = systemfunc("ls ./"+data_file)
  in = addfiles(infile,"r") ;
;************************************************
; read in netCDF file
;************************************************
  grd_file = "/cygdrive/f/np8/np8_grd.nc"
; grd_file = "F:/np8/np8_grd.nc"
  grd = addfile(grd_file,"r")
  lon = grd->lon_rho(1,:)
  lat = grd->lat_rho(:,1)
; lon_u = grd->lon_u(1,:)
; lat_u = grd->lat_u(:,1)
; lon_v = grd->lon_v(1,:)
; lat_v = grd->lat_v(:,1)
; lon = fspan(lon_min,lon_max,10*(lon_max-lon_min)/resol+1)
; lat = fspan(lat_min,lat_max,10*(lat_max-lat_min)/resol+1)
; lon@units = "degree_east"
; lat@units = "degree_north"
  h = doubletofloat(grd->h)
......................

nn = dimsizes(in[:]->ocean_time)
do nt=nb,nn
     time=in[:] ->ocean_time(nt-1)
     utc_date = cd_calendar(time, -3)
     print(""+utc_date)
     
;************************************************
; read in zonal [u] and meridional [v] winds
;************************************************
     u = roms_3d_interp(in,"u",nt-1,h,depth) ; Line 188
     v = roms_3d_interp(in,"v",nt-1,h,depth)
; tmp = in[:]->v(nt-1,21,:,:)
; v = linint2(lon_v,lat_v,tmp,False,lon,lat,0)
; delete(tmp)
     speed = sqrt(u^2 + v^2)
; if(nt .eq. nb) then
        u!0 = "lat"
        u!1 = "lon"
        u&lat = lat
        u&lon = lon
        v!0 = "lat"
        v!1 = "lon"
        v&lat = lat
        v&lon = lon
        speed!0 = "lat"
        speed!1 = "lon"
        speed&lat = lat
        speed&lon = lon
; end if
        printVarSummary(u)
     vcres@tiMainString = "Surface currents distribution"
     vcres@gsnLeftString = utc_date
     vcres@gsnRightString = "m/s"

     wks = gsn_open_wks(wks_type ,"velocity_"+flt2string(depth)+"-"+utc_date) ; open a ps file
     gsn_define_colormap(wks,"rainbow") ;"BlAqGrYeOrRe") ; choose colormap
; plot = gsn_csm_contour_map_ce(wks,speed, res)

     plot = gsn_csm_vector_scalar_map_ce(wks,u,v,speed,vcres) ; create plot
; plot = gsn_csm_vector_map_ce(wks,u,v,vcres)
  end do
2013-09-05



朱学明

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Sep 4 18:37:53 2013

This archive was generated by hypermail 2.1.8 : Mon Sep 16 2013 - 13:43:52 MDT