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

Dennis Shea shea at ucar.edu
Wed Jul 30 08:44:38 MDT 2014


Attached is a script that uses your do loop approach to calculating the
annual and monthly decadal means. A key is

ndecade = nyrs/10                     ; 133/10= 13

and then use

do nyr=0,(10*ndecade)-1,10      ; 10*13= 130 .... 130-1=129



On Tue, Jul 29, 2014 at 4:49 PM, Ipshita Majhi <ipmajhi at alaska.edu> wrote:

> Here are the details of my code:-
> 1) I am writing a code to calculate decadal monthly mean from the matrix
> called air(all india rainfall) and it is a 133 X 12 matrix
>
> ***********************************************************
> The errors are as follows:-
>
> fatal:Subscript out of range/error in subscript #0
> fatal:["Excute.c":8128]:Execute :Error occurred at or near line 39 in file
> decadal_mean_air.ncl
>
> *************************************************************
>
> Here is the program:-
>
> ;Calculating decadal mean
>
> ;This is to read in the all india rainfall and to plot them
>
>
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
>
> ncol = 12
> nrows=133
>
> air=readAsciiTable("~/Documents/PhD_June_2015/Data_AIR/air.txt", ncol,
> "integer",2)
> y=dimsizes(air)
> print(y)
>
> ;ya = dim_avg_n(air,1)   ;yearly average
>
>
> ;This is for yearly decadal mean
>
> yearly_decadal = new( dimsizes(ya)/10, float)  ;;; assumes ya%10 is 0.  if
> not end indices will be ignored.
>
>
> ct = 0
> do i=0, dimsizes(ya)-10, 10  ;  loop from 0 to max length of array and
> step by 10
> yearly_decadal(ct) = avg( ya(i:i+9) )
> ct = ct+1
> end do
> print(yearly_decadal)
>
> ;This is for monthly decadal mean
> ;This is a two dimensional matrix
>
> mda=new((/13,12/),"float"); mda=monthly decadal average
>
> do i=0, 133-10,10
>
> do j=0,11
>
> re(i,j)=dim_avg_n(air(i:i+9,j),0)
>
> end do
> end do
> ********************************************************************
>
> Can you help me with this
>
> Thanking you in advance
> Best Regards
> Ipshita
>
>
>
>
> _______________________________________________
> ncl-talk mailing list
> 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/20140730/3792bfa1/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ipshita.ncl_post
Type: application/octet-stream
Size: 2574 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20140730/3792bfa1/attachment.obj 


More information about the ncl-talk mailing list