<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Benita,&nbsp;<div class=""><br class=""></div><div class="">I see now that basically all these points apply to whoever wrote the examples and not to you. &nbsp;</div><div class=""><br class=""></div><div class="">All examples on that page need to be edited. &nbsp;I’m guessing someone did a find/replace on an older version of this function and didn’t check thoroughly. &nbsp;</div><div class=""><br class=""></div><div class="">Also mistake on my part mixed up the order of these. &nbsp;</div><div class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class=""><div class="">&nbsp;spei(prc, t, lat,len(k), False, 0)</div></div></div><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Alan.&nbsp;</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On 22 Feb 2016, at 11:31, Alan Brammer &lt;<a href="mailto:abrammer@albany.edu" class="">abrammer@albany.edu</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><br class=""></div><div class="">Hi Benita,&nbsp;</div><div class=""><br class=""></div><div class="">Multiple things.</div><div class="">&nbsp;<a href="https://www.ncl.ucar.edu/Document/Functions/Built-in/spei.shtml" class="">https://www.ncl.ucar.edu/Document/Functions/Built-in/spei.shtml</a></div><div class="">At the top of the page. &nbsp;"<span style="color: rgb(51, 51, 51); font-family: verdana, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255);" class="">&nbsp;</span><i style="margin: 0px; padding: 0px; color: rgb(51, 51, 51); font-family: verdana, sans-serif; font-size: 13px;" class="">Available in&nbsp;<a href="https://www.ncl.ucar.edu/prev_releases.shtml#6.3.1" style="margin: 0px; padding: 0px; text-decoration: none; color: rgb(133, 45, 133);" class="">version 6.3.1</a>&nbsp;and later. "</i></div><div class="">&nbsp;So you can’t use the function yet, latest released version is 6.3.0. &nbsp;Which you’re using.&nbsp;</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Secondly,&nbsp;</div><div class="">You can’t have variables and functions named the same thing. &nbsp; When the function spei() is included, trying to define an array named spei is going to create problems. &nbsp;</div><div class=""><br class=""></div><div class="">Line 16 won’t work in any language I know of. &nbsp;Rename your variable so it doesn’t clash with the function name.&nbsp;</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Third.&nbsp;</div><div class="">Again from the top link, spei() will expect 6 arguments and you only passed 4. &nbsp;</div><div class=""><br class=""></div><div class="">Fourth.</div><div class="">The specific error you’re getting is because NCL is trying to subscript the spei variable using False as you passed on line 16. &nbsp;False isn’t a valid subscript.&nbsp;</div><div class=""><br class=""></div><div class="">Fifth.</div><div class="">Included edited lines below which should work once 6.3.1 is released. &nbsp; Though you will need to read in some temperature data as well. Read the functions documentation.&nbsp;</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">;;;; &nbsp; Will need 6.3.1 &nbsp;</div><div class=""><br class=""></div><div class=""><div class="">&nbsp; &nbsp;f= addfile("pr_Amon_ensemble_historical_190001-200512.nc", "r")</div><div class="">&nbsp; &nbsp;prc &nbsp; &nbsp;= f-&gt;pr &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ; pr(time,lat,lon)</div><div class="">&nbsp; &nbsp;printVarSummary(prc)</div><div class=""><br class=""></div><div class="">&nbsp; &nbsp;prc_dimnames = getvardims(prc)</div><div class="">&nbsp;time = lat= prc&amp;$prc_dimnames(0)$<span class="Apple-tab-span" style="white-space:pre">                </span>;; get dimension coordinates without knowing dimension names</div><div class="">&nbsp; lat= prc&amp;$prc_dimnames(1)$</div><div class="">&nbsp; lon= prc&amp;$prc_dimnames(2)$</div><div class="">&nbsp;</div><div class="">&nbsp;&nbsp;dimp &nbsp; = dimsizes(prc) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;; # monthly precipitation values</div><div class="">&nbsp; &nbsp;ntim &nbsp; = dimp(0)</div><div class="">&nbsp; &nbsp;nlat &nbsp; = dimp(1)</div><div class="">&nbsp; &nbsp;mlon &nbsp; = dimp(2)</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">&nbsp; &nbsp;len &nbsp; &nbsp;= (/ 6, 12, 24 /)</div><div class="">&nbsp; &nbsp;klen &nbsp; = &nbsp;dimsizes(len)</div><div class="">&nbsp; &nbsp;spei_data &nbsp; &nbsp;= &nbsp;new((/klen,ntim,nlat,mlon/) ,float,prc@_FillValue)</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">&nbsp; t = &nbsp;…. &nbsp;; spei needs a temperature variable same size as prc</div><div class=""><br class=""></div><div class="">&nbsp;do k=0,klen-1</div><div class="">&nbsp; &nbsp; &nbsp;&nbsp;spei_data(k,:,:,:) = spei(prc, t, len(k),lat, False, 0)</div><div class="">&nbsp; end do</div></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Good luck,&nbsp;</div><div class="">Alan</div><div class=""><br class=""></div><div class=""><br class=""></div><br class=""><div class=""><blockquote type="cite" class=""><div class="">On 22 Feb 2016, at 11:11, Tam, Benita (EC/EC) &lt;<a href="mailto:benita.tam@canada.ca" class="">benita.tam@canada.ca</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="WordSection1" style="page: WordSection1; font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-CA" style="font-size: 10pt; font-family: Verdana, sans-serif;" class="">Hi,<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-CA" style="font-size: 10pt; font-family: Verdana, sans-serif;" class=""><o:p class="">&nbsp;</o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-CA" style="font-size: 10pt; font-family: Verdana, sans-serif;" class="">I am trying to calculate SPEI using the SPEI function in NCL with gridded data, but when I run the script, I get an error message saying that the subscripts must be one dimensional. This is expected for data for one location, but not for gridded data. My sample script is attached (it’s basically the same as the example provided with the function).<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-CA" style="font-size: 10pt; font-family: Verdana, sans-serif;" class=""><o:p class="">&nbsp;</o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-CA" style="font-size: 10pt; font-family: Verdana, sans-serif;" class="">NCL version: 6.3.0<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-CA" style="font-size: 10pt; font-family: Verdana, sans-serif;" class="">Script (see attached)<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-CA" style="font-size: 10pt; font-family: Verdana, sans-serif;" class="">Error message: fatal:Illegal subscript. Subscripts must be scalar or one dimensional vectors<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-CA" style="font-size: 10pt; font-family: Verdana, sans-serif;" class="">Url for netcdf data:<span class="Apple-converted-space">&nbsp;</span></span><a href="http://ccds-dscc.ec.gc.ca/files/cmip5/pr/pr_Amon_ensemble_historical_190001-200512.nc" style="color: purple; text-decoration: underline;" class=""><span lang="EN-CA" style="font-size: 10pt; font-family: Verdana, sans-serif;" class="">http://ccds-dscc.ec.gc.ca/files/cmip5/pr/pr_Amon_ensemble_historical_190001-200512.nc</span></a><span lang="EN-CA" style="font-size: 10pt; font-family: Verdana, sans-serif;" class=""><o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-CA" style="font-size: 10pt; font-family: Verdana, sans-serif;" class=""><o:p class="">&nbsp;</o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-CA" style="font-size: 10pt; font-family: Verdana, sans-serif;" class="">Thanks,<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-CA" style="font-size: 10pt; font-family: Verdana, sans-serif;" class="">Benita<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-CA" style="font-size: 10pt; font-family: Verdana, sans-serif;" class=""><o:p class="">&nbsp;</o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-CA" style="font-size: 10pt; font-family: Verdana, sans-serif;" class=""><o:p class="">&nbsp;</o:p></span></div></div><span id="cid:7C2B85FD-11EC-4284-A606-2A722C188503@eas.albany.edu" class="">&lt;test_prc.ncl&gt;</span><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">_______________________________________________</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">ncl-talk mailing list</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><a href="mailto:ncl-talk@ucar.edu" style="color: purple; text-decoration: underline; font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">ncl-talk@ucar.edu</a><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">List instructions, subscriber options, unsubscribe:</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" style="color: purple; text-decoration: underline; font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a></div></blockquote></div><br class=""></div></div></blockquote></div><br class=""></div></body></html>