<div dir="ltr"><div><div>The := syntax was introduced in NCL 6.1.1 (Feb 4, 2013)<br><br><p>
<b>New reassignment operator</b></p><p>

There&#39;s a new operator, &quot;:=&quot;, that allows you to reassign variables
without having to delete them first.</p><p>
For example:
</p><p>

</p><pre>   x = fspan(-10.5,20.8,0.1)    ; array of floats
;  x = &quot;This is a string&quot;       ; this won&#39;t work
   x <b>:=</b> &quot;This is a string&quot;      ; single string
</pre>=====<br>I like the := syntax. <br><br>Not only does it negate the need to explicitly delete a variable before redefining the variable, it informs a person looking at the code that the variable on the left could change shape, sizes, type ....<br><br><br></div></div>  Cheers        <br></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Oct 31, 2016 at 9:32 PM, Luke Osburn <span dir="ltr">&lt;<a href="mailto:luke.osburn@monash.edu" target="_blank">luke.osburn@monash.edu</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Sounds like the variable &quot;lines&quot; has already been predefined with specific dimension sizes. And this does not match the assignment that you are trying to make, so you get a fatal error.<div><br></div><div>Direclty before: <span style="font-size:13px;font-family:&#39;lucida grande&#39;,verdana,&#39;microsoft yahei&#39;;line-height:23px">&#39;  lines  = asciiread(filename1(i),-1,&quot;</span><span style="font-size:13px;font-family:&#39;lucida grande&#39;,verdana,&#39;microsoft yahei&#39;;line-height:23px">str<wbr>ing&quot;)&#39; </span></div><div><span style="font-size:13px;font-family:&#39;lucida grande&#39;,verdana,&#39;microsoft yahei&#39;;line-height:23px">put in: delete(lines) ;This removes the condition that the dimension sizes of left and right have to match as, lines is no longer defined. </span></div></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">On 1 November 2016 at 14:17, Yuqiang Zhang <span dir="ltr">&lt;<a href="mailto:yuqiangzhang.thu@gmail.com" target="_blank">yuqiangzhang.thu@gmail.com</a>&gt;</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 link="#0563C1" vlink="#954F72" lang="EN-US"><div class="m_8745908924922340546m_1286360134496254004WordSection1"><p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1f497d">Try this “</span><span style="font-family:&quot;Verdana&quot;,sans-serif">lines  := asciiread(filename1(i),-1,&quot;str<wbr>ing&quot;)&#39;  </span><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1f497d">”<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1f497d">That happens when you read different files, and they have different length for each file. <u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif">From:</span></b><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif"> <a href="mailto:ncl-talk-bounces@ucar.edu" target="_blank">ncl-talk-bounces@ucar.edu</a> [mailto:<a href="mailto:ncl-talk-bounces@ucar.edu" target="_blank">ncl-talk-bounces@ucar.<wbr>edu</a>] <b>On Behalf Of </b>grace<br><b>Sent:</b> Monday, October 31, 2016 11:06 PM<br><b>To:</b> ncl-talk &lt;<a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a>&gt;<br><b>Subject:</b> [ncl-talk] fatal:Dimension sizes of left hand side and right hand side of assignment do not match . Finding a better way to read csv data in different files for further calculation.<u></u><u></u></span></p><div><div class="m_8745908924922340546h5"><p class="MsoNormal"><u></u> <u></u></p><div><p class="MsoNormal" style="line-height:17.25pt"><span style="font-family:&quot;Verdana&quot;,sans-serif">Hi:<u></u><u></u></span></p></div><div><p class="MsoNormal" style="line-height:17.25pt"><span style="font-family:&quot;Verdana&quot;,sans-serif">  All,I have write a script to read and calculate .csv data according to the &quot;Reading csv&quot;example on the NCL website,but it appears fatal :<u></u><u></u></span></p></div><div><p class="MsoNormal" style="line-height:17.25pt"><span style="font-family:&quot;Verdana&quot;,sans-serif"><u></u> <u></u></span></p></div><div><div><p class="MsoNormal" style="line-height:17.25pt"><span style="font-family:&quot;Verdana&quot;,sans-serif">fatal:Dimension sizes of left hand side and right hand side of assignment do not match<br>fatal:[&quot;Execute.c&quot;:8567]:Execu<wbr>te: Error occurred at or near line 45 in file csv_read.ncl<u></u><u></u></span></p></div><div><p class="MsoNormal" style="line-height:17.25pt"><span style="font-family:&quot;Verdana&quot;,sans-serif"><u></u> <u></u></span></p></div></div><div><p class="MsoNormal" style="line-height:17.25pt"><span style="font-family:&quot;Verdana&quot;,sans-serif">The line 45 is   &#39;  lines  = asciiread(filename1(i),-1,&quot;str<wbr>ing&quot;)&#39;   ........<u></u><u></u></span></p></div><div><p class="MsoNormal" style="line-height:17.25pt"><span style="font-family:&quot;Verdana&quot;,sans-serif">.........<u></u><u></u></span></p></div><div><p class="MsoNormal" style="line-height:17.25pt"><span style="font-family:&quot;Verdana&quot;,sans-serif">........<u></u><u></u></span></p></div><div><p class="MsoNormal" style="line-height:17.25pt"><span style="font-family:&quot;Verdana&quot;,sans-serif">But when I try to read only one csv data,the script can work out.<u></u><u></u></span></p></div><div><p class="MsoNormal" style="line-height:17.25pt"><span style="font-family:&quot;Verdana&quot;,sans-serif">I don&#39;t know how to fix this,can you guys help me?<u></u><u></u></span></p></div><div><p class="MsoNormal" style="line-height:17.25pt"><span style="font-family:&quot;Verdana&quot;,sans-serif">My csv date stored like this:<u></u><u></u></span></p></div><div><div><p class="MsoNormal" style="line-height:17.25pt"><span style="font-family:&quot;Verdana&quot;,sans-serif"><img id="m_8745908924922340546m_1286360134496254004_x0000_i1025" src="cid:image001.png@01D233CC.E69CB3E0" height="544" width="532"><u></u><u></u></span></p></div><div><p class="MsoNormal" style="line-height:17.25pt"><span style="font-family:&quot;Verdana&quot;,sans-serif">Each file include some same named  csv data:<u></u><u></u></span></p></div><div><div><p class="MsoNormal" style="line-height:17.25pt"><span style="font-family:&quot;Verdana&quot;,sans-serif"><img id="m_8745908924922340546m_1286360134496254004_x0000_i1026" src="cid:image002.png@01D233CC.E69CB3E0" height="391" width="521"><img id="m_8745908924922340546m_1286360134496254004_x0000_i1027" src="cid:image003.png@01D233CC.E69CB3E0" height="387" width="539"><u></u><u></u></span></p></div></div><div><p class="MsoNormal" style="line-height:17.25pt"><span style="font-family:&quot;Verdana&quot;,sans-serif"><u></u> <u></u></span></p></div><div><p class="MsoNormal" style="line-height:17.25pt"><span style="font-family:&quot;Verdana&quot;,sans-serif">Can you  help me or give me some good idea?<u></u><u></u></span></p></div></div><div><p class="MsoNormal" style="line-height:17.25pt"><span style="font-family:&quot;Verdana&quot;,sans-serif"><u></u> <u></u></span></p></div><div><p class="MsoNormal" style="line-height:17.25pt"><span style="font-family:&quot;Verdana&quot;,sans-serif">This is my script:<u></u><u></u></span></p></div><div><p class="MsoNormal" style="line-height:17.25pt"><span style="font-family:&quot;Verdana&quot;,sans-serif"> <u></u><u></u></span></p></div><div><p class="MsoNormal" style="line-height:17.25pt"><span style="font-family:&quot;Verdana&quot;,sans-serif">;<br>load &quot;$NCARG_ROOT/lib/ncarg/nclscri<wbr>pts/csm/contributed.ncl&quot;<br>begin<br> filename1=systemfunc(&quot;ls /public/home/huanglei/cmaqdata<wbr>/2016*/Zhouzhi.csv&quot;)<br>  ;   fin1=addfiles(filename1,&quot;r&quot;)<br>    ; printVarSummary(filename1)<br>     print(filename1)<br> <br> ; exit<br>     filenumber =38<br>     time_al= new((/filenumber/),string,&quot;No_<wbr>FillValue&quot;)<br>     oth_al = new((/filenumber/),float,&quot;No_F<wbr>illValue&quot;)<br>     xa_al  = new((/filenumber/),float,&quot;No_F<wbr>illValue&quot;)<br>     tc_al  = new((/filenumber/),float,&quot;No_F<wbr>illValue&quot;)<br>     bj_al  = new((/filenumber/),float,&quot;No_F<wbr>illValue&quot;)<br>     xy_al  = new((/filenumber/),float,&quot;No_F<wbr>illValue&quot;)<br>     wn_al  = new((/filenumber/),float,&quot;No_F<wbr>illValue&quot;)<br>     ya_al  = new((/filenumber/),float,&quot;No_F<wbr>illValue&quot;)<br>     hz_al  = new((/filenumber/),float,&quot;No_F<wbr>illValue&quot;)<br>     yl_al  = new((/filenumber/),float,&quot;No_F<wbr>illValue&quot;)<br>     ak_al  = new((/filenumber/),float,&quot;No_F<wbr>illValue&quot;)<br>     sl_al  = new((/filenumber/),float,&quot;No_F<wbr>illValue&quot;)<br>    <br>  do i=0,filenumber-1<br>            <br>          ;---Read in file as array of strings so we can parse each line.<br>     ; printVarSummary(filename1(2))<br>       lines  = asciiread(filename1(i),-1,&quot;str<wbr>ing&quot;)<br>       nlines = dimsizes(lines)-1   ; First line is a header<u></u><u></u></span></p></div><div><p class="MsoNormal" style="line-height:17.25pt"><span style="font-family:&quot;Verdana&quot;,sans-serif">    ;<br>    ; Start reading in the fields we care about:<br>    ; The first line is a header, so skip this.<br>    ;<br>      delim     = &quot;,&quot;<br>      time = str_get_field(lines(13:36),1,d<wbr>elim)  <br>      oth  = str_get_field(lines(13:36),2,d<wbr>elim)  <br>      xa   = str_get_field(lines(13:36),3,d<wbr>elim)  <br>      tc   = str_get_field(lines(13:36),4,d<wbr>elim)  <br>      bj   = str_get_field(lines(13:36),5,d<wbr>elim)  <br>      xy   = str_get_field(lines(13:36),6,d<wbr>elim)  <br>      wn   = str_get_field(lines(13:36),7,d<wbr>elim)  <br>      ya   = str_get_field(lines(13:36),8,d<wbr>elim)<br>      hz   = str_get_field(lines(13:36),9,d<wbr>elim)  <br>      yl   = str_get_field(lines(13:36),10,<wbr>delim)  <br>      ak   = str_get_field(lines(13:36),11,<wbr>delim)  <br>      sl   = str_get_field(lines(13:36),12,<wbr>delim)<br>            ;  print(time)<br>            ;   exit<br>                         ; time_al(i,:)= time  <br>      ;     print(time_al(i,:))<br>                         oth_al(i) =sum(stringtofloat(oth))  <br>                         xa_al(i)  = sum(stringtofloat(xa))  <br>                         tc_al(i)  = sum(stringtofloat(tc))  <br>                         bj_al(i)  = sum(stringtofloat(bj))  <br>                         xy_al(i)  = sum(stringtofloat(xy))  <br>                         wn_al(i)  = sum(stringtofloat(wn))  <br>                         ya_al(i)  = sum(stringtofloat(ya))  <br>                         hz_al(i)  = sum(stringtofloat(hz))  <br>                         yl_al(i)  = sum(stringtofloat(yl))  <br>                         ak_al(i)  = sum(stringtofloat(ak))  <br>                         sl_al(i)  = sum(stringtofloat(sl)) <br>        ;  print(oth_al(i))     <br>        ;exit<br>         end do<u></u><u></u></span></p></div><div><p class="MsoNormal" style="line-height:17.25pt"><span style="font-family:&quot;Verdana&quot;,sans-serif">                        ;  time_all=ndtooned(time_al)<br>                          oth_all=ndtooned(oth_al)<br>                          xa_all=ndtooned(xa_al)<br>                          tc_all=ndtooned(tc_al)<br>                          bj_all=ndtooned(bj_al)<br>                          xy_all=ndtooned(xy_al)<br>                          wn_all=ndtooned(wn_al)<br>                          ya_all=ndtooned(ya_al)<br>                          hz_all=ndtooned(hz_al)<br>                          yl_all=ndtooned(yl_al)  <br>                          ak_all=ndtooned(ak_al)<br>                          sl_all=ndtooned(sl_al) <u></u><u></u></span></p></div><div><p class="MsoNormal" style="line-height:17.25pt"><span style="font-family:&quot;Verdana&quot;,sans-serif"><br>         print(oth_all)<br> ;   exit<br>  ; calculate the avg<u></u><u></u></span></p></div><div><p class="MsoNormal" style="line-height:17.25pt"><span style="font-family:&quot;Verdana&quot;,sans-serif">                          oth_avg=avg(oth_all)<br>                          xa_avg=avg(xa_all)<br>                          tc_avg=avg(tc_all)<br>                          bj_avg=avg(bj_all)<br>                          xy_avg=avg(xy_all)<br>                          wn_avg=avg(wn_all)<br>                          ya_avg=avg(ya_all)<br>                          hz_avg=avg(hz_all)<br>                          yl_avg=avg(yl_all)  <br>                          ak_avg=avg(ak_all)<br>                          sl_avg=avg(sl_all)<u></u><u></u></span></p></div><div><p class="MsoNormal" style="line-height:17.25pt"><span style="font-family:&quot;Verdana&quot;,sans-serif">                          ssx = hz_avg + ak_avg + sl_avg<br>                          nsx = ya_avg + yl_avg<u></u><u></u></span></p></div><div><p class="MsoNormal" style="line-height:17.25pt"><span style="font-family:&quot;Verdana&quot;,sans-serif">                         print(&quot;oth=&quot;+oth_avg)<br>                         print(&quot;xa=&quot;+xa_avg)<br>                         print(&quot;tc=&quot;+tc_avg)<br>                         print(&quot;bj=&quot;+bj_avg)<br>                         print(&quot;xy=&quot;+xy_avg)<br>                         print(&quot;wn=&quot;+wn_avg)<br>                         print(&quot;ssx=&quot;+ssx)<br>                         print(&quot;nsx=&quot;+nsx)<br>                  title  = new((/8/),string,&quot;No_FillValue<wbr>&quot;)<br>                  title =(/&quot;xa&quot;,&quot;xy&quot;,&quot;wn&quot;,&quot;bj&quot;,&quot;tc&quot;,&quot;n<wbr>sx&quot;,&quot;ssx&quot;,&quot;oth&quot;/)<br>                  data = new((/8/),float,&quot;No_FillValue&quot;<wbr>)<br>                  data =(/xa_avg,xy_avg,wn_avg,bj_avg<wbr>,tc_avg,nsx,ssx,oth_avg/)  <br>                  print(data)<br>                  ;staname=&quot;changan&quot;<br>                  output_file=&quot;/public/home/huan<wbr>glei/cmaqdata/final_data/zhouz<wbr>hi.txt&quot;<br>                 write_table(output_file,&quot;w&quot;,[/<wbr>title,data/],&quot;%s%9.5f&quot;)<br>end<u></u><u></u></span></p></div><div><p class="MsoNormal" style="line-height:17.25pt"><span style="font-family:&quot;Verdana&quot;,sans-serif"> <u></u><u></u></span></p></div><div><p class="MsoNormal" style="line-height:17.25pt"><span style="font-family:&quot;Verdana&quot;,sans-serif"><u></u> <u></u></span></p></div><div><div><p class="MsoNormal" style="line-height:17.25pt"><span style="font-family:&quot;Verdana&quot;,sans-serif">My NCL version is 6.2.0.<u></u><u></u></span></p></div><div><p class="MsoNormal" style="line-height:17.25pt"><span style="font-family:&quot;Verdana&quot;,sans-serif"> How can I slove the problem?<u></u><u></u></span></p></div></div></div></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>