<div dir="ltr"><div><div><div><div><div><div><div>Hi,<br><br></div>I ran the script with the file that was sent to Dennis. I got the same error message:<br><br>fatal:["NclFile.c":2100]:Subscript out of range, error in subscript #0<br>fatal:["Execute.c":8640]:Execute: Error occurred at or near line 17 in file ERI95.ncl<br><br></div>Line 17 is this:<br><br>precpi = fin->precip(iTim,{4:8},{34:39})<br><br></div>A simple print of the value of iTim shows it to be a large negative number, indeed it is the default value for "missing_value" for an integer. The function ind() returns missing_value if nothing meets the condition.<br><br></div>Again, some simple prints ultimately revealed that the variable time in the file contains all zeros(!), which in turn is why ind() found nothing that meets the condition.<br><br></div>So that is ultimately the cause of the error. But I hope that gives a sense for how to debug and track down problems.<br><br></div>Good luck<br></div>Rick<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Oct 26, 2017 at 12:58 PM, Mary Haley <span dir="ltr"><<a href="mailto:haley@ucar.edu" target="_blank">haley@ucar.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 class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">I can't tell from your script which is line 22, because I don't know how many lines you have before the "begin" statement.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">However, the error message is telling you exactly what the issue is:</div><span class=""><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small"><span style="font-size:12.8px">Subscript out of range, error in subscript #0</span></div><div class="gmail_default" style="font-size:small"><br></div></span><div class="gmail_default" style="font-size:small"><span style="font-size:12.8px"></span>Subscript #0 in NCL means the leftmost subscript, and it's saying that you are using a subscript that is out-of-range.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">My guess is this line might be the problem:</div><div class="gmail_default"><span class="">
<p class="m_-4905615617953501309gmail-p1" style="font-size:small"><span class="m_-4905615617953501309gmail-s1">arr_jjas1= </span><span class="m_-4905615617953501309gmail-s2">(/</span><span class="m_-4905615617953501309gmail-s1">rf1(time|2::12,lat|:,lon|:)</span><span class="m_-4905615617953501309gmail-s2">/<wbr>)</span></p></span><p class="m_-4905615617953501309gmail-p1" style="font-size:small">The "time | 2::12" is subscript #0 in this case, and it is going start at the 3rd index of time (because indexing starts at 0, so '2' refers to index 3), and grab every 12th time step. Do you have at least 3 time steps in this variable? If not, then that would cause the error.</p><p class="m_-4905615617953501309gmail-p1" style="font-size:small">As we tell new users of NCL, if you are getting an error message about subscripting or dimension sizes from a variable, use printVarSummary to look at the variable:</p><p class="m_-4905615617953501309gmail-p1" style="font-size:small">printVarSummary(rf1)<br></p><p class="m_-4905615617953501309gmail-p1" style="font-size:small">This should tell you what the dimension size is of the time dimension and might help point to the source of the error.</p><p class="m_-4905615617953501309gmail-p1" style="font-size:small">If the above line is *not* line 22, then find line 22 in your script and do a printVarSummary on whatever variable it is complaining about.</p><p class="m_-4905615617953501309gmail-p1" style="font-size:small">For future reference, if you get an error you don't understand, then look it up on our error page:</p><p class="m_-4905615617953501309gmail-p1"><a href="http://www.ncl.ucar.edu/Document/Language/error_messages.shtml" target="_blank">http://www.ncl.ucar.edu/<wbr>Document/Language/error_<wbr>messages.shtml</a></p><p class="m_-4905615617953501309gmail-p1">--Mary</p><p class="m_-4905615617953501309gmail-p1"><br></p></div></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">On Wed, Oct 25, 2017 at 11:23 PM, yohanan sweet <span dir="ltr"><<a href="mailto:marsilas23@gmail.com" target="_blank">marsilas23@gmail.com</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div dir="ltr"><br><div>dear ncl talk</div><div><br></div><div>I need help if there is anyone can help me.</div><div><br></div><div>I was using grid data of my country with NetCDF format. but I cannot understand what the error is if anyone can help me.this is my code and the error it gives me is.</div><div><br></div><div><div><div>begin</div><div>;-----------------------------<wbr>------------------------------<wbr>---------------</div><div>f = "Sweetheart.nc"</div><div>;f = "<a href="http://mon.precip.nc" target="_blank">mon.precip.nc</a>"</div><div>fin = addfile(f, "r")</div><div>timet = fin->time</div><div>ymd = round(timet, 3)</div><div><br></div><div>;ymd = cd_calendar(timet,2)</div><div>iTim = ind (<a href="http://ymd.ge.19830101.and.ymd.lt" target="_blank">ymd.ge.19830101.and.ymd.lt</a>.20<wbr>100101)</div><div>precpi = fin->precip(iTim,{4:8},{34:39}<wbr>)</div><div>;=============================<wbr>==============================<wbr>===================</div><div>timem =precpi&time</div><div>rain = rmMonAnnCycTLL(precpi)</div><div>prec_jjas1 = rain(2::12,:,:)</div><div>rf1= runave_Wrap(rain(lat|:,lon|:,t<wbr>ime|:),4,0)</div><div>arr_jjas1= (/rf1(time|2::12,lat|:,lon|:)/<wbr>)</div><div><br></div><div>arr_jjas1!0 = "time"</div><div>arr_jjas1!1 = "lat"</div><div>arr_jjas1!2 = "lon"</div><div>arr_jjas1&time = prec_jjas1&time</div><div>arr_jjas1&lat = prec_jjas1&lat</div><div>arr_jjas1&lon = prec_jjas1&lon</div><div>printVarSummary(arr_jjas1)</div><div><br></div><div>yene = dim_avg_Wrap (arr_jjas1(time|:,lat|:,lon|:)<wbr>)</div><div> yene2 = dim_avg_Wrap(yene)</div><div> stand = dim_standardize_Wrap(yene2,1)</div><div>;printVarSummary(stand)</div><div>;*****************************<wbr>******************************<wbr>**************</div><div> fil = "Sweetheart.nc"</div><div> ;fil = "<a href="http://mon.precip.nc" target="_blank">mon.precip.nc</a>"</div><div> fin1 =addfile(fil,"r")</div><div> timep = fin1->time</div><div>ymd1 = round(timet, 3)</div><div><br></div><div> ;ymd1 = cd_calendar(timep,2)</div><div> iTim = ind(ymd1.ge.19830101.and.ymd1.<wbr>lt.20100101)</div><div> precip = fin1->precip(iTim,:,:)</div><div>;*****************************<wbr>******************************<wbr>****************</div><div>mare =rmMonAnnCycTLL(precip)</div><div>time = mare&time</div><div>prec_jjas = mare(3::12,:,:)</div><div>rf= runave_Wrap(mare(lat|:,lon|:,t<wbr>ime|:),3,0)</div><div>arr_jjas= (/rf(time|3::12,lat|:,lon|:)/)</div><div><br></div><div>arr_jjas!0 = "time"</div><div>arr_jjas!1 = "lat"</div><div>arr_jjas!2 = "lon"</div><div>arr_jjas&time = prec_jjas&time</div><div>arr_jjas&lat = prec_jjas&lat</div><div>arr_jjas&lon = prec_jjas&lon</div><div>printVarSummary(arr_jjas)</div><div>;===========calculate corelation====================<wbr>======================</div><div>ccr = escorc(stand,arr_jjas(lat|:,lo<wbr>n|:,time|:))</div><div>copy_VarCoords(prec_jjas(0,:,:<wbr>),ccr)</div><div>printVarSummary(ccr)</div><div>printMinMax(ccr,0)</div><div>;=============================<wbr>==============================<wbr>=============</div><div>siglvl =0.05</div><div>test = rtest(ccr(lat|:,lon|:),34,0)</div><div>test = where(ismissing(ccr),test@_Fil<wbr>lValue,test)</div><div><br></div><div>test!0 = "lat"</div><div>test!1 ="lon"</div><div>test&lat = ccr&lat</div><div>test&lon =ccr&lon</div><div>printVarSummary(test)</div><div>;=============================<wbr>==============================<wbr>===================</div><div>wks = gsn_open_wks("x11","Correlatio<wbr>n")</div><div>gsn_define_colormap(wks,"preci<wbr>p_diff_12lev")</div><div>res = True</div><div>res@cnFillOn = True</div><div>;res@cnLineOn = True</div><div>res@cnLevelSelectionMode = "ManualLevels"</div><div>res@mpCenterLonF =180</div><div>res@cnMinLevelValF = -0.6 </div></div></div><div><div>res@cnMaxLevelValF = 0.6</div><div>res@cnLineLabelsOn = False</div><div><br></div><div>res@cnLevelSpacingF = 0.1</div><div>;res@gsnSpreedColors = True</div><div>res@mpPerimOn =False</div><div>res@tiMainString = " (a) Corr (SERI ,MAM precipitation and 850-hpa winds) "</div><div>res@mpFillOn = False</div><div>res@gsnDraw =False</div><div>res@cnLinesOn = False</div><div>res1 =True</div><div>res1@gsnDraw =False</div><div>res1@gsnFrame = False</div><div><br></div><div>res1@cnLevelSelectionMode = "ManualLevels"</div><div>res1@cnMinLevelValF = 0.00 ; min level</div><div>res1@cnMaxLevelValF = 1.05</div><div>res1@cnLevelSpacingF = 0.05</div><div>res1@cnInfoLabelOn = False</div><div>res1@cnLinesOn = False</div><div>res1@cnLineLabelsOn = False</div><div> ;res@mpMinLatF = 3 ; range to zoom in on</div><div><br></div><div> ;res@mpMaxLatF = 15</div><div> ;res@mpMinLonF = 33</div><div> ;res@mpMaxLonF = 48</div><div> ;res@mpOutlineBoundarySets = "National"</div><div> ;res@mpAreaMaskingOn =True</div><div><br></div><div>res1@cnLineLabelOn = False</div><div>res1@cnFillScaleF = 0.6 ;add extra density</div><div>res1@gsnDraw = False ; do not draw the plot</div><div>res1@gsnFrame = False ; do not advance the frame</div><div>;res@tiMainString = "Correlation between NIO and rainfall 9month led "</div><div>plot0 = gsn_csm_contour_map(wks,ccr,re<wbr>s)</div><div><br></div><div>opt =True</div><div>opt@gsnShadeFillType = "pattern"</div><div>opt@gsnShadeLow = 17</div><div>opt@gsnShadeDotSizeF = 0.6</div><div>plot1 = gsn_csm_contour(wks,test,res1)</div><div>plot1 = gsn_contour_shade(plot1,0.05,0<wbr>.75,opt)</div><div>;=============================<wbr>==============================<wbr>==============================</div><div>ECMWF = "/home/cyoo/scratch/reanl/ecmw<wbr>f/monthly/"</div><div>fileU = systemfunc ("ls "+ECMWF+"uwnd/u.mon.*.nc")</div><div>F = addfiles (fileU, "r")</div><div>timeu = F[:]->time</div><div>ymds = cd_calendar(timeu,2)</div><div>iTim1 = ind (<a href="http://ymds.ge.19790101.and.ymds.lt" target="_blank">ymds.ge.19790101.and.ymds.lt</a>.<wbr>20120101)</div><div>uwind = F[:]->u (iTim1,{850},:,:)</div><div>;=============================<wbr>==============================<wbr>===========</div><div>Uanom =rmMonAnnCycTLL(uwind)</div><div>;T = Uanom&time</div><div> T = uwind&time</div><div><br></div><div>;ym1 =cd_calendar(T,0)</div><div> ;month1 = tointeger(ym1(:,1))</div><div> ;imon1 = ind(month1.ge.02.and.month1.le<wbr>.05)</div><div><br></div><div>U1 = Uanom(2::12,:,:)</div><div>ub1= runave_Wrap(Uanom(lat|:,lon|:,<wbr>time|:),4,0)</div><div>uu21= (/ub1(time|2::12,lat|:,lon|:)/<wbr>)</div><div>uu21!0 = "time"</div><div>uu21!1 = "lat"</div><div>uu21!2 = "lon"</div><div>uu21&time = U1&time</div><div>uu21&lat = U1&lat</div><div>uu21&lon = U1&lon</div><div>;printVarSummary(uu21)</div><div><br></div><div>U = dim_avg_Wrap(uu21(lat|:,lon|:,<wbr>time|:))</div><div><br></div><div>;=============================<wbr>==============================<wbr>==========</div><div>fileV = systemfunc ("ls "+ECMWF+"vwnd/v.mon.*.nc")</div><div>fv = addfiles (fileV, "r")</div><div>time2 = fv[:]->time</div><div>ymd2 = cd_calendar(time2,2)</div><div>iTim2 = ind (<a href="http://ymd2.ge.19790101.and.ymd2.lt" target="_blank">ymd2.ge.19790101.and.ymd2.lt</a>.<wbr>20120101)</div><div>vwind = fv[:]->v (iTim2,{850},:,:)</div></div><div><div>Vanom =rmMonAnnCycTLL(vwind)</div><div>;T1 = Vanom&time</div><div>;T1 = vwind&time</div><div>V1 = Vanom(2::12,:,:)</div><div>vb1= runave_Wrap(Vanom(lat|:,lon|:,<wbr>time|:),4,0)</div><div>vu21= (/vb1(time|2::12,lat|:,lon|:)/<wbr>)</div><div>vu21!0 = "time"</div><div>vu21!1 = "lat"</div><div>vu21!2 = "lon"</div><div>vu21&time = V1&time</div><div>vu21&lat = V1&lat</div><div>vu21&lon = V1&lon</div><div>V = dim_avg_Wrap(vu21(lat|:,lon|:,<wbr>time|:))</div><div><br></div><div><br></div><div> res2 = True</div><div> res2@vcMinFracLengthF = 0.3</div><div> res2@vcRefMagnitudeF = 20 ; define vector ref mag</div><div> res2@vcRefLengthF = 0.04 ; define length of vec ref</div><div>res2@vcGlyphStyle = "LineArrow"</div><div>res2@vcMinDistanceF = 0.02 ; thin out vectors</div><div> ;res2@vcGlyphStyle = "CurlyVector" ; turn on curley vectors</div><div> res2@gsnDraw = False ; don't draw yet</div><div> res2@gsnFrame = False ; don't advance frame yet</div><div> res2@vcLineArrowThicknessF = 1.5</div><div> res2@gsnLeftString = "" ; turn off strings</div><div> res2@gsnRightString = ""</div><div><br></div><div>plotV = gsn_csm_vector(wks,U,V,res2)</div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div>overlay(plot0,plot1) ; overlay the U-wind plot on the rainfall plot</div><div>overlay(plot0,plotV)</div><div>draw(plot0) ; draw the rainfall plot (with the U-wind plot overlaid)</div><div>frame(wks)</div><div>end</div><div><br></div><div><div>fatal:["NclFile.c":2099]:Subsc<wbr>ript out of range, error in subscript #0</div><div>fatal:["Execute.c":8575]:Execu<wbr>te: Error occurred at or near line 22 in file stan</div><div>dardizerain.ncl</div></div><div><br></div><div><br></div></div></div>
<br></div></div>______________________________<wbr>_________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">http://mailman.ucar.edu/mailma<wbr>n/listinfo/ncl-talk</a><br>
<br></blockquote></div><br></div>
<br>______________________________<wbr>_________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu">ncl-talk@ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">http://mailman.ucar.edu/<wbr>mailman/listinfo/ncl-talk</a><br>
<br></blockquote></div><br></div>