<div dir="ltr"><div>Attached is a script that uses your do loop approach to calculating the annual and monthly decadal means. A key is<br><br>ndecade = nyrs/10 ; 133/10= 13<br><br></div>and then use <br>
<br>do nyr=0,(10*ndecade)-1,10 ; 10*13= 130 .... 130-1=129<br><br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Jul 29, 2014 at 4:49 PM, Ipshita Majhi <span dir="ltr"><<a href="mailto:ipmajhi@alaska.edu" target="_blank">ipmajhi@alaska.edu</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div><div><div><div><div><div>Here are the details of my code:-<br></div>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<br>
</div><br></div>***********************************************************<br>The errors are as follows:-<br><br></div>fatal:Subscript out of range/error in subscript #0<br></div>fatal:["Excute.c":8128]:Execute :Error occurred at or near line 39 in file decadal_mean_air.ncl<br>
<br>*************************************************************<br><br></div>Here is the program:-<br><br>;Calculating decadal mean<br><br>;This is to read in the all india rainfall and to plot them<br><br><br>load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"<br>
<br>ncol = 12<br>nrows=133<br><br>air=readAsciiTable("~/Documents/PhD_June_2015/Data_AIR/air.txt", ncol, "integer",2)<br>y=dimsizes(air)<br>print(y)<br><br>;ya = dim_avg_n(air,1) ;yearly average <br>
<br><br>;This is for yearly decadal mean<br><br>yearly_decadal = new( dimsizes(ya)/10, float) ;;; assumes ya%10 is 0. if not end indices will be ignored.<br><br><br>ct = 0<br>do i=0, dimsizes(ya)-10, 10 ; loop from 0 to max length of array and step by 10<br>
yearly_decadal(ct) = avg( ya(i:i+9) )<br>ct = ct+1<br>end do<br>print(yearly_decadal)<br><br>;This is for monthly decadal mean<br>;This is a two dimensional matrix<br><br>mda=new((/13,12/),"float"); mda=monthly decadal average<br>
<br>do i=0, 133-10,10 <br><br>do j=0,11<br><br>re(i,j)=dim_avg_n(air(i:i+9,j),0)<br><br>end do<br>end do<br>********************************************************************<br><br></div>Can you help me with this<br><br>
Thanking you in advance<br></div>Best Regards<span class="HOEnZb"><font color="#888888"><br>Ipshita<br><div><div><br><br><div><br></div></div></div></font></span></div>
<br>_______________________________________________<br>
ncl-talk mailing list<br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br>
<br></blockquote></div><br></div>