[ncl-talk] ncl fatal:Subscript out of range, error in subscript #0

Mary Haley haley at ucar.edu
Sun Jun 18 11:26:40 MDT 2017


Hi James,

This error message is strange, because as you pointed out, subscript #0
would refer to the leftmost dimension, which is being subsetted with ":".

I'm wondering if there's something fundamentally wrong with the "wave"
variable on the file, or the SwdelQw_waves variable.  It would help to see
a printVarSummary of both of those variables:

printVarSummary(f->SwdelQw_waves)
printVarSummary(f->wave)

The other thing I'm curious about is why SwdelQw_waves has attributes
called "lat" and "lev".

It looks like this variable was originally subscripted by latitude and
level coordinate subscripting in an NCL script, because NCL has an added
feature where if you subscript a variable by a coordinate array, then it
adds an attribute to your subscripted variable with the same name as the
coordinate variable, and assigns the actual value that it ended up
selecting.

If you can provide me with the other printVarSummary output, then I might
be able to tell what's going on.

Thanks,

--Mary



On Wed, Jun 14, 2017 at 10:46 AM, James Russell <jorussel at ncsu.edu> wrote:

> Hi all,
>
> I'm getting the following error message when I run a script to read some
> netcdf files that I wrote from another script:
>
> ncl fatal:Subscript out of range, error in subscript #0
>
> The weird thing happening is that after this error message comes up, the
> script continues running and seems to do the correct things. I'm not sure
> why this error message is coming up either since it's just referencing
> everything in the first dimension when the script reads the file (i.e.
> var(:) ... see below script) so there's no way (I know of) that any
> subscript can be out of range since there aren't actually any subscripts.
>
> The error comes up twice after the following two lines in the script:
> var1  = f->SwdelQw_waves(:,{lagn:lagp},{preL:preH},{com_lat},{com_lon})
> varh1 = f->SwdelQw_waves(:,{lagn:lagp},{com_lev},{latS:latN},{lonE:lonW})
>
> Any help on why this error is appearing would be useful. It doesn't seem
> to be affecting the script but it's worrying since I'm not sure if it's
> changing anything.
>
> Thanks in advance,
> James
>
>
> See below for the script, an ncl_filedump of the file being read, and a
> printVarSummary after the error comes up.
>
> I'm running the script using a shell script:
> ncl clat=\"{$clat}\" clon=\"{$clon}\" clev=\"{$clev}\" tho=\"{$tho}\"
> plot_panelxs_SwQw.ncl
>
> Here's the script:
>
> ;**********************************************************
> ; Script
> ;**********************************************************
>
> com_lat = tofloat(clat)
> com_lon = tofloat(clon)
> com_lev = tofloat(clev)
> thold   = tofloat(tho)
>
> ; Domain and first and last points on cross-section
> preL = 1000.
> preH = 150.
> lagn = -60
> lagp = 60
> latS = com_lat-15
> latN = com_lat+15
> lonW = com_lon-20
> lonE = com_lon+20
>
> ; Data in
> pathin  = "/typhoon/jorussel/pvbud/"
> filein  = "SwQw_"+com_lat+com_lon+com_lev+thold+".nc"
> pathino = "/typhoon/jorussel/basic_vars/"
> fileino = "pvw_"+com_lat+com_lon+com_lev+thold+".nc"
>
> print("Opening file and reading variable data")
> f     = addfile(pathin+filein,"r")
> var1  = f->SwdelQw_waves(:,{lagn:lagp},{preL:preH},{com_lat},{com_lon})
> varh1 = f->SwdelQw_waves(:,{lagn:lagp},{com_lev},{latS:latN},{lonE:lonW})
>
> var1 = var1*(10^6)*6*60*60
> varh1= varh1*(10^6)*6*60*60
>
> ;**********************************************************
> ; End Script
> ;********************************************************
>
> ;**********************************************************
> ; ncl_filedump of file
> ;********************************************************
>
> Variable: f
> Type: file
> filename: SwQw_1133650-1
> path: /typhoon/jorussel/pvbud/SwQw_1133650-1.nc
>    file global attributes:
>       creation_date : Tue Jun 13 11:36:22 EDT 2017
>       Conventions : None
>       source_file : original-file.nc
>       title : NCL Efficient Approach to netCDF Creation
>    dimensions:
>       wave = 411
>       lag = 21
>       lev = 27
>       lat = 57
>       lon = 85
>    variables:
>       integer wave ( wave )
>          _FillValue : -2147483647 <(214)%20748-3647>
>          long_name : time
>          units : YYYYMMDDHH
>
>       integer lag ( lag )
>          units : Hours
>
>       integer lev ( lev )
>          long_name : isobaric level
>          units : hPa
>
>       float lat ( lat )
>          La1 : 89.463
>          Lo1 : 0
>          La2 : -89.463
>          Lo2 : 359.297
>          Di : 0.7031252
>          N : 128
>          units : degrees_north
>          GridType : Gaussian Latitude/Longitude Grid
>          long_name : latitude
>
>       float lon ( lon )
>          La1 : 89.463
>          Lo1 : 0
>          La2 : -89.463
>          Lo2 : 359.297
>          Di : 0.7031252
>          N : 128
>          units : degrees_east
>          GridType : Gaussian Latitude/Longitude Grid
>          long_name : longitude
>
>       float SwdelQw_waves ( wave, lag, lev, lat, lon )
>          waveName : none
>          depth : ( -2147483647 <(214)%20748-3647>, -2147483647
> <(214)%20748-3647> )
>          period : ( 2, 10 )
>          wavenumber : ( -40, -10 )
>          lat : 44.56129
>          lev : 1000
>          description : zetax = -dvdp
>          lonFlip : longitude coordinate variable has been reordered via
> lonFlip
>          initial_time : 10/31/2015 (18:00)
>          forecast_time_units : hours
>          forecast_time : 0
>          parameter_number : 132
>          parameter_table_version : 128
>          gds_grid_type : 4
>          level_indicator : 100
>          units : /s
>          long_name : -grav*(zetaxw*dqw/dx + zetayw*dqw/dy)
>          center : European Center for Medium-Range Weather Forecasts
> (RSMC)
>          _FillValue : 1e+20
>
> ;**********************************************************
> ; End ncl_filedump
> ;********************************************************
>
> ;**********************************************************
> ; printVarSummary of variable after read in and error comes up
> ;********************************************************
>
> Variable: var1
> Type: float
> Total Size: 863100 bytes
>             215775 values
> Number of Dimensions: 3
> Dimensions and sizes: [wave | 411] x [lag | 21] x [lev | 25]
> Coordinates:
>             wave: [1..411]
>             lag: [-60..60]
>             lev: [1000..150]
> Number Of Attributes: 20
>   lon : 33.04689
>   waveName : none
>   depth : ( -2147483647 <(214)%20748-3647>, -2147483647 <(214)%20748-3647>
> )
>   period : ( 2, 10 )
>   wavenumber : ( -40, -10 )
>   lat : 44.56129
>   lev : 1000
>   description : zetax = -dvdp
>   lonFlip : longitude coordinate variable has been reordered via lonFlip
>   initial_time : 10/31/2015 (18:00)
>   forecast_time_units : hours
>   forecast_time : 0
>   parameter_number : 132
>   parameter_table_version : 128
>   gds_grid_type : 4
>   level_indicator : 100
>   units : /s
>   long_name : -grav*(zetaxw*dqw/dx + zetayw*dqw/dy)
>   center : European Center for Medium-Range Weather Forecasts (RSMC)
>   _FillValue : 1e+20
>
> ;**********************************************************
> ; end printVarSummary()
> ;********************************************************
>
>
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170618/e380c6ec/attachment.html 


More information about the ncl-talk mailing list