<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="">fatal:Dimension sizes of left hand side and right hand side of assignment do not match<br class=""><div dir="ltr" class=""><div class="">fatal:["Execute.c":8575]:Execute: Error occurred at or near line 51 in file reaadworkcsv.ncl</div></div><div class=""><br class=""></div><div class="">This usually means you’re trying to set say 15 values to an array that previously only held 10.&nbsp;</div><div class="">NCL is not flexible with array sizes once they are defined. &nbsp;</div><div class="">At the bottom of loops either delete() or use the := notation to redefine where needed.&nbsp;</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Check what ever is happening on line 51. &nbsp;Should the return value always be the same length (through each loop) or do you expect them to vary?</div><div class="">You can redefine the return variable each time easily by using := &nbsp;instead of = &nbsp;</div><div class="">I think the first edit would be</div><div class="">seldata1 := str_match_ic_regex(seldata, strkey)</div><div class=""><br class=""></div><div class="">The print(dimsizes()) suggests you expect the size to vary. &nbsp; You’ll likely need to do the same thing on the lines that also use seldata1 later in the script.&nbsp;</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><br class=""><div><blockquote type="cite" class=""><div class="">On 4 Nov 2015, at 13:56, Adv &lt;<a href="mailto:advita6@gmail.com" class="">advita6@gmail.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="">Hi,<br class=""><br class=""></div><div class="">Thanks for your reply. Sorry for the misrepresentation. <br class=""></div><div class="">I printed below the error output.&nbsp; <br class=""></div><div class="">While the loop starting for the second time I get this error. I am sure that the representation to calculate average of all the jan months are right.<br class=""><br class=""></div><div class="">I tried to create two domensional array which is commented in the code to write output. But that is not a problem.&nbsp; <br class=""></div><div class="">why particularly error in this specific line for the second time loop is what i don't understand. There is no dimension error for the first time. But for the second one. <br class="">​<div class="gmail_chip gmail_drive_chip" style="width:396px;height:18px;max-height:18px;background-color:rgb(245,245,245);padding:5px;color:rgb(34,34,34);font-family:arial;font-style:normal;font-weight:bold;font-size:13px;border:1px solid rgb(221,221,221);line-height:1"><a href="https://drive.google.com/file/d/0B5aDji6ggKPARHlEUW9Ta0tMZG8/view?usp=drive_web" target="_blank" style="display:inline-block;max-width:366px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;text-decoration:none;padding:1px 0;border:none" class=""><img style="vertical-align: bottom; border: none;" src="https://ssl.gstatic.com/docs/doclist/images/icon_10_generic_list.png" class="">&nbsp;<span dir="ltr" style="color:rgb(17,85,204);text-decoration:none;vertical-align:bottom" class="">minnesota50.csv</span></a><img src="x-msg://ssl.gstatic.com/ui/v1/icons/common/x_8px.png" style="opacity: 0.55; cursor: pointer; float: right; position: relative; top: -1px; display: none;" class=""></div>​<br class=""><br class=""><br class=""></div><div class="">Thank you, <br class=""></div><div class=""><br class="">fatal:Dimension sizes of left hand side and right hand side of assignment do not match<br class="">fatal:["Execute.c":8575]:Execute: Error occurred at or near line 51 in file reaadworkcsv.ncl<br class=""><br class=""><br class=""></div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Wed, Nov 4, 2015 at 12:30 PM, Alan Brammer <span dir="ltr" class="">&lt;<a href="mailto:abrammer@albany.edu" target="_blank" class="">abrammer@albany.edu</a>&gt;</span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Had this folder open so I’ll give you a quick reply.<br class="">
<br class="">
There’s a lot of code here and no explanation of why you need help?<br class="">
Although it sometimes resembles it I believe this list isn’t really intended as a place to just quickly outsource your scripting desires.<br class="">
<br class="">
What have you tried?<br class="">
What specific issue did you run into?<br class="">
How is anyone on here supposed to know your data layout?<br class="">
Have you looked at the numerous climatology examples and previous ncl-talk questions?<br class="">
Where did the answers to the above questions fall short and thus what specifically is the problem?<br class="">
<br class="">
Good luck. As always direct replies to the list.&nbsp; Hopefully a more specific question lends it self to a more specific answer.<br class="">
<br class="">
<br class="">
Alan.<br class="">
<div class=""><div class="h5"><br class="">
<br class="">
&gt; On 4 Nov 2015, at 13:23, Adv &lt;<a href="mailto:advita6@gmail.com" class="">advita6@gmail.com</a>&gt; wrote:<br class="">
&gt;<br class="">
&gt; Hi NCL user,<br class="">
&gt;<br class="">
&gt; I would like to write final average corresponding to each station, monthly average of 42 years to a two dimensionl array.<br class="">
&gt; Could someone help me to accomplish this?<br class="">
&gt;<br class="">
&gt; Thank you,<br class="">
&gt; Adv<br class="">
&gt;<br class="">
&gt; begin<br class="">
&gt; ;&nbsp; diri&nbsp; &nbsp;= "./"<br class="">
&gt;&nbsp; &nbsp;fkey&nbsp; &nbsp;= "minnesota"<br class="">
&gt; strs=asciiread("minnesota50.csv" , -1, "string")<br class="">
&gt; n1=(/"197301","197401","197501","197601","197701","197801"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\<br class="">
&gt; ,"197901","198001","198101","198201","198301","198401"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \<br class="">
&gt; ,"198501","198601","198701","198801","198901","199001"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\<br class="">
&gt; ,"199101","199201","199301","199401","199501","199601"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \<br class="">
&gt; ,"199701","199801","199901","200001","200101","200201","200301"&nbsp; &nbsp; &nbsp; &nbsp;\<br class="">
&gt; ,"200401","200501","200601","200701","200801","200901"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \<br class="">
&gt; ,"201001","201101","201201","201301","201401"/)<br class="">
&gt; print(n1)<br class="">
&gt; ns1 = dimsizes(n1)<br class="">
&gt; print(ns1)<br class="">
&gt; do j =0, dimsizes(n1)-1<br class="">
&gt;<br class="">
&gt; ;&nbsp; yyyymm = 197301<br class="">
&gt;&nbsp; &nbsp;yyyymm = n1(j)<br class="">
&gt;&nbsp; &nbsp;fldstr = "PRCP"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;; case sensitive<br class="">
&gt;&nbsp; &nbsp;con&nbsp; &nbsp; = 1.00<br class="">
&gt; print(yyyymm)<br class="">
&gt; ;return<br class="">
&gt; ;***********************************************<br class="">
&gt; ; match all data lines with specified YYYYYY<br class="">
&gt; ;***********************************************<br class="">
&gt;<br class="">
&gt; ;&nbsp; seldata = str_match_ic_regex(strs, tostring(yyyymm))&nbsp; &nbsp; ; 6.3.0<br class="">
&gt;&nbsp; &nbsp;seldata = str_match_ic_regex(strs, tostring(yyyymm))&nbsp; &nbsp; ; 6.3.0<br class="">
&gt; ;&nbsp; print(seldata)<br class="">
&gt;&nbsp; &nbsp;print("=====")<br class="">
&gt; n=(/"THIEF","PARK"/)<br class="">
&gt; print(n)<br class="">
&gt; ns = dimsizes(n)<br class="">
&gt; print(ns)<br class="">
&gt; tim = new((/ns1,ns/),"float")<br class="">
&gt; printVarSummary(tim)<br class="">
&gt; ;tavg = new((/ns1,ns/),"float")<br class="">
&gt; tavg = new(ns,float)<br class="">
&gt; print(tavg)<br class="">
&gt; do i =0, dimsizes(n)-1<br class="">
&gt; strkey = n(i)<br class="">
&gt; print(strkey)<br class="">
&gt; ;strkey= "THIEF"<br class="">
&gt; ;print(strkey)<br class="">
&gt; ;return<br class="">
&gt; ; find all lines (rows) which contain the key string<br class="">
&gt;<br class="">
&gt;&nbsp; &nbsp;seldata1 = str_match_ic_regex(seldata, strkey)&nbsp; &nbsp; &nbsp;; 6.3.0&nbsp; onward<br class="">
&gt; print(seldata1)<br class="">
&gt; print(dimsizes(seldata1))<br class="">
&gt; ;***********************************************<br class="">
&gt; ; write selected data to ascii file<br class="">
&gt; ;***********************************************<br class="">
&gt;&nbsp; seldir&nbsp; = "./"<br class="">
&gt;&nbsp; &nbsp;selfil&nbsp; = fkey+"."+yyyymm+".csv"<br class="">
&gt;&nbsp; &nbsp;system("/bin/rm -f "+seldir+selfil)<br class="">
&gt;&nbsp; &nbsp;asciiwrite(seldir+selfil, seldata1)&nbsp; &nbsp;; all data for selected yyyymm<br class="">
&gt; ;***********************************************<br class="">
&gt; ; Which field matches<br class="">
&gt; ;***********************************************<br class="">
&gt; FIELDS = (/"STATION","STATION_NAME","ELEVATION","LATITUDE","LONGITUDE"&nbsp; &nbsp; \<br class="">
&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;,"DATE","MDPR","MDSF","DAPR","DASF","PRCP","SNWD","SNOW"&nbsp; &nbsp; &nbsp; &nbsp; \<br class="">
&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;,"TMAX","TMIN","TOBS"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;/)<br class="">
&gt;<br class="">
&gt;<br class="">
&gt;&nbsp; &nbsp;nfield = ind(FIELDS.eq.fldstr) + 1&nbsp; &nbsp; &nbsp; ; field to be extracted<br class="">
&gt;&nbsp; &nbsp;print("fldstr="+fldstr+" corresponds to field number "+nfield)<br class="">
&gt;&nbsp; &nbsp;print("=====")<br class="">
&gt; ;***********************************************<br class="">
&gt; ; extract the values<br class="">
&gt; ;***********************************************<br class="">
&gt;<br class="">
&gt;&nbsp; &nbsp;sdat&nbsp; &nbsp;= str_get_field(seldata1 , 2, ",")<br class="">
&gt; ;*********Monthly average********************************<br class="">
&gt;&nbsp; data&nbsp; &nbsp;= tofloat( str_get_field(seldata1 , nfield, ",") )*con<br class="">
&gt;&nbsp; &nbsp;data@_FillValue = -9999*con<br class="">
&gt;&nbsp; &nbsp;print(sdat+" : "+data)<br class="">
&gt;&nbsp; &nbsp;print("=====")<br class="">
&gt; ;print(data)<br class="">
&gt; ;return<br class="">
&gt; tavg(i)=avg(data)<br class="">
&gt; end do<br class="">
&gt; print(tavg)<br class="">
&gt; ;tim(j,i)=tavg<br class="">
&gt; end do<br class="">
&gt;<br class="">
&gt;<br class="">
&gt;<br class="">
</div></div>&gt; _______________________________________________<br class="">
&gt; ncl-talk mailing list<br class="">
&gt; <a href="mailto:ncl-talk@ucar.edu" class="">ncl-talk@ucar.edu</a><br class="">
&gt; List instructions, subscriber options, unsubscribe:<br class="">
&gt; <a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank" class="">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br class="">
<br class="">
</blockquote></div><br class=""></div>
</div></blockquote></div><br class=""></body></html>