# Re: fatal:Subscript out of range

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Mon Feb 14 2011 - 08:07:55 MST

Wei,

The error is telling you what the problem is:

> Fatal:Subscript out of range, error in subscript #0
> fatal:An error occurred reading zz
> fatal:Execute: Error occurred at or near line 105 in file

Look at line 105, and look at the leftmost (subscript #0) subscript that you are
using for "zz". You have to make sure "zmax_pos" is not falling outside the
Time range (0-14).

My guess is the problem is with this code:

> b = ind(zz(:,0,0) .gt. zmax*1000. )
> zmax_pos = b(0) - 1

Why are you subtracting 1 from b(0)?

--Mary

On Feb 12, 2011, at 8:11 AM, wei huang wrote:

> Hi,
> Does anyone give me help to fix the problem? Some part of code is attached.
> Thanks , wei
>
>
> = = = = = = =
>
> if ( FirstTime ) then ; get height info for labels
> zmin = 0.
> zmax = 12. ; We are only interested in the first 6km
> nz = floattoint(zmax + 1)
> end if
>
> ; Find the index where 12km is - only need to do this once
> if ( FirstTime ) then
> zz = wrf_user_intrp3d(z,z,"v",plane,angle,opts)
> printVarSummary(zz)
> b = ind(zz(:,0,0) .gt. zmax*1000. )
> zmax_pos = b(0) - 1
> printVarSummary(zmax_pos)
> ; if ( abs(zz(zmax_pos,0)-zmax*1000.) .lt. abs(zz(zmax_pos+1,0)-zmax*1000.) )
> if ( abs(zz(zmax_pos,0,0)-zmax*1000.) .lt. abs(zz(zmax_pos+1,0,0)-zmax*1000.) ) then
> zspan = b(0) - 1
> else
> zspan = b(0)
> end if
> delete(zz)
> delete(b)
> FirstTime = False
> end if
>
> = = = = = = = = =
> res@tmYLMode = "Explicit"
> res@tmYLValues = fspan(0,zspan,nz) ; Create tick marks
> res@tmYLLabels = sprintf("%.1f",fspan(zmin,zmax,nz)) ; Create labels
>
>
> ;= = = = = = = = =
>
> Variable: zz
> Type: float
> Total Size: 1270000 bytes
> 317500 values
> Number of Dimensions: 3
> Dimensions and sizes: [Time | 15] x [Vertical | 100] x [Horizontal | 120]
> Coordinates:
> Number Of Attributes: 4
> _FillValue : -999
> units : m
> description : Height
> Orientation : Cross-Sesion: (87,5) to (82,131)
>
> Variable: zmax_pos
> Type: integer
> Total Size: 4 bytes
> 1 values
> Number of Dimensions: 1
> Dimensions and sizes: [1]
> Coordinates:
> Number Of Attributes: 1
> _FillValue : -999
>
> fatal:Subscript out of range, error in subscript #0
> fatal:An error occurred reading zz
> fatal:Execute: Error occurred at or near line 105 in file
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Mon Feb 14 08:08:02 2011

This archive was generated by hypermail 2.1.8 : Tue Feb 15 2011 - 09:43:19 MST