<div dir="ltr">Hi:<div><br></div><div>It only gives the error when the : is included after Hits_1(i_day), as in :=.</div><div><br></div><div>The : was needed before I subscripted the variable with i_day.</div><div><br></div><div>Barry</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Oct 19, 2017 at 5:31 PM, Marston Johnston <span dir="ltr"><<a href="mailto:shejo284@gmail.com" target="_blank">shejo284@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div bgcolor="white" lang="EN-GB" link="blue" vlink="purple"><div class="m_4610713367109821699WordSection1"><p class="MsoNormal"><span>Hi Barry,<u></u><u></u></span></p><p class="MsoNormal"><span><u></u> <u></u></span></p><p class="MsoNormal"><span>A couple things, not to be nit-picky but just my experience. I rewrote the script a bit. But I’m confused, your arrays are always empty so Hits_1 will always be 0.<u></u><u></u></span></p><p class="MsoNormal"><span>This version of the script doesn’t give the error:<u></u><u></u></span></p><span class=""><p class="MsoNormal"><span><u></u> <u></u></span></p><p class="MsoNormal"><span>begin<u></u><u></u></span></p><p class="MsoNormal"><span>  n_days  = 3<u></u><u></u></span></p><p class="MsoNormal"><span>  dims = 9<u></u><u></u></span></p><p class="MsoNormal"><span>  Hits_1 = new(n_days,"float")<u></u><u></u></span></p></span><p class="MsoNormal"><span>  Hits_4km = new(n_days,"float")<u></u><u></u></span></p><p class="MsoNormal"><span>  Hits_1 = 0.0<u></u><u></u></span></p><p class="MsoNormal"><span>  Hits_4km = 0.0<u></u><u></u></span></p><p class="MsoNormal"><span>  do ii_day = 0,dims-1<u></u><u></u></span></p><p class="MsoNormal"><span>    if (ii_day .eq.0)then<u></u><u></u></span></p><p class="MsoNormal"><span>      i_day = 0<u></u><u></u></span></p><span class=""><p class="MsoNormal"><span>    else<u></u><u></u></span></p><p class="MsoNormal"><span>      i_day = (mod(ii_day,3))<u></u><u></u></span></p><p class="MsoNormal"><span>    end if<u></u><u></u></span></p><p class="MsoNormal"><span>    ;printVarSummary(i_day)<u></u><u></u></span></p><p class="MsoNormal"><span>    ;print("i_day = "+ i_day)<u></u><u></u></span></p><p class="MsoNormal"><span>    Hits_1(i_day) = Hits_4km(i_day) + Hits_1(i_day)<u></u><u></u></span></p></span><p class="MsoNormal"><span>    print(Hits_1(i_day))<u></u><u></u></span></p><p class="MsoNormal"><span>  end do<u></u><u></u></span></p><p class="MsoNormal"><span>end<u></u><u></u></span></p><p class="MsoNormal"><span><u></u> <u></u></span></p><p class="MsoNormal"><span>/M<u></u><u></u></span></p><p class="MsoNormal"><span><u></u> <u></u></span></p><div><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif;color:#0070c0">~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif;color:#0070c0">Marston S. Ward, PhD<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif;color:#0070c0">Department of Earth Sciences<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif;color:#0070c0">University of Gothenburg, Sweden<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif;color:#0070c0">Email: <a href="mailto:marston.johnston@gu.se" target="_blank"><span style="color:#0070c0">marston.johnston@gu.se</span></a><u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif;color:#0070c0">SkypeID: marston.johnston <u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif;color:#0070c0">Phone: <a href="tel:+46%2031%20786%2049%2001" value="+46317864901" target="_blank">+46-31-7864901</a> <u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif;color:#0070c0">Only the fruitful thing is true!<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif;color:#0070c0">~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<u></u><u></u></span></p></div><p class="MsoNormal"><span><u></u> <u></u></span></p><p class="MsoNormal"><span><u></u> <u></u></span></p><div style="border:none;border-top:solid #b5c4df 1.0pt;padding:3.0pt 0cm 0cm 0cm"><p class="MsoNormal"><b><span style="font-size:12.0pt;color:black">From: </span></b><span style="font-size:12.0pt;color:black">ncl-talk <<a href="mailto:ncl-talk-bounces@ucar.edu" target="_blank">ncl-talk-bounces@ucar.edu</a>> on behalf of Barry Lynn <<a href="mailto:barry.h.lynn@gmail.com" target="_blank">barry.h.lynn@gmail.com</a>><br><b>Date: </b>Thursday, 19 October 2017 at 16:18<br><b>To: </b>ncl-talk <<a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a>><br><b>Subject: </b>[ncl-talk] A NCL Mystery Solved<u></u><u></u></span></p></div><div><div class="h5"><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal">Hi:<u></u><u></u></p><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal">I have this error (it didn't obviously show up with a Google search).<u></u><u></u></p></div><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="m_4610713367109821699gmail-p1"><span class="m_4610713367109821699gmail-s1">fatal:Assign: Hits_1 is undefined, can not subscript an undefined variable</span><u></u><u></u></p><p class="m_4610713367109821699gmail-p1"><span class="m_4610713367109821699gmail-s1">fatal:["Execute.c":8575]:<wbr>Execute: Error occurred at or near line 17 in file ./test.ncl</span><u></u><u></u></p><p class="m_4610713367109821699gmail-p1"><span class="m_4610713367109821699gmail-s1">Before defining Hits_1 as an array of size n_days, I needed the : to do the sum.  </span><u></u><u></u></p><p class="m_4610713367109821699gmail-p1">However, it is the : that causes the error when the variable is defined as an array.<u></u><u></u></p><p class="m_4610713367109821699gmail-p1">I am not sure why, but I thought I would make a note of it for those who encounter the same error message.<u></u><u></u></p><p class="m_4610713367109821699gmail-p1"><u></u> <u></u></p><p class="m_4610713367109821699gmail-p1"><span class="m_4610713367109821699gmail-s1">begin</span><u></u><u></u></p><p class="m_4610713367109821699gmail-p1"><span class="m_4610713367109821699gmail-apple-converted-space">  </span><span class="m_4610713367109821699gmail-s2">n_days</span><span class="m_4610713367109821699gmail-apple-converted-space">  </span><span class="m_4610713367109821699gmail-s1">= 3</span><u></u><u></u></p><p class="m_4610713367109821699gmail-p1"><span class="m_4610713367109821699gmail-apple-converted-space">  </span><span class="m_4610713367109821699gmail-s1">dims = 9</span><u></u><u></u></p><p class="m_4610713367109821699gmail-p1"><span class="m_4610713367109821699gmail-apple-converted-space">  </span><span class="m_4610713367109821699gmail-s1">Hits_1 = new(</span><span class="m_4610713367109821699gmail-s2">n_days</span><span class="m_4610713367109821699gmail-s1">,float)</span><u></u><u></u></p><p class="m_4610713367109821699gmail-p1"><span class="m_4610713367109821699gmail-apple-converted-space">  </span><span class="m_4610713367109821699gmail-s1">printVarSummary(Hits_1)</span><u></u><u></u></p><p class="m_4610713367109821699gmail-p1"><span class="m_4610713367109821699gmail-apple-converted-space">  </span><span class="m_4610713367109821699gmail-s1">Hits_4km = new(</span><span class="m_4610713367109821699gmail-s2">n_days</span><span class="m_4610713367109821699gmail-s1">,float)</span><u></u><u></u></p><p class="m_4610713367109821699gmail-p1"><span class="m_4610713367109821699gmail-apple-converted-space">  </span><span class="m_4610713367109821699gmail-s1">Hits_1 = 0</span><u></u><u></u></p><p class="m_4610713367109821699gmail-p1"><span class="m_4610713367109821699gmail-apple-converted-space">  </span><span class="m_4610713367109821699gmail-s1">Hits_4km = 0</span><u></u><u></u></p><p class="m_4610713367109821699gmail-p1"><span class="m_4610713367109821699gmail-apple-converted-space">  </span><span class="m_4610713367109821699gmail-s1">do ii_day = 0,dims,1</span><u></u><u></u></p><p class="m_4610713367109821699gmail-p1"><span class="m_4610713367109821699gmail-apple-converted-space">   </span><span class="m_4610713367109821699gmail-s1">if (ii_day .eq.0)then</span><u></u><u></u></p><p class="m_4610713367109821699gmail-p1"><span class="m_4610713367109821699gmail-apple-converted-space">   </span><span class="m_4610713367109821699gmail-s1">i_day = tointeger(0)</span><u></u><u></u></p><p class="m_4610713367109821699gmail-p1"><span class="m_4610713367109821699gmail-apple-converted-space">   </span><span class="m_4610713367109821699gmail-s1">else</span><u></u><u></u></p><p class="m_4610713367109821699gmail-p1"><span class="m_4610713367109821699gmail-apple-converted-space">   </span><span class="m_4610713367109821699gmail-s1">i_day = (mod(ii_day,3))</span><u></u><u></u></p><p class="m_4610713367109821699gmail-p1"><span class="m_4610713367109821699gmail-apple-converted-space">   </span><span class="m_4610713367109821699gmail-s1">end if</span><u></u><u></u></p><p class="m_4610713367109821699gmail-p1"><span class="m_4610713367109821699gmail-apple-converted-space">   </span><span class="m_4610713367109821699gmail-s1">printVarSummary(i_day)</span><u></u><u></u></p><p class="m_4610713367109821699gmail-p1"><span class="m_4610713367109821699gmail-apple-converted-space">   </span><span class="m_4610713367109821699gmail-s1">print("i_day = " + i_day)</span><u></u><u></u></p><p class="m_4610713367109821699gmail-p1"><span class="m_4610713367109821699gmail-apple-converted-space">   <b> </b></span><span class="m_4610713367109821699gmail-s1"><b>Hits_1(i_day) := Hits_4km(i_day) + Hits_1(i_day) ; </b></span><span class="m_4610713367109821699gmail-s1"><i>remove colon if Hits_1 is defined as an array.</i></span><u></u><u></u></p><p class="m_4610713367109821699gmail-p1"><span class="m_4610713367109821699gmail-apple-converted-space">  </span><span class="m_4610713367109821699gmail-s1">end do</span><u></u><u></u></p><p class="m_4610713367109821699gmail-p1"><span class="m_4610713367109821699gmail-s1">end</span><u></u><u></u></p><p class="m_4610713367109821699gmail-p1"><u></u> <u></u></p><div><p class="MsoNormal"><u></u> <u></u></p></div><p class="MsoNormal">-- <u></u><u></u></p><div><div><p class="MsoNormal">Barry H. Lynn, Ph.D<u></u><u></u></p><div><div><p class="MsoNormal">Senior Lecturer,<u></u><u></u></p></div><div><div><p class="MsoNormal"><span style="color:#888888">The Institute of the Earth Science, <br>The Hebrew University of Jerusalem, <br>Givat Ram, Jerusalem 91904, Israel </span><u></u><u></u></p></div><p class="MsoNormal"><span style="color:#888888">Tel: 972 547 231 170<br>Fax: (972)-25662581</span><u></u><u></u></p></div></div><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal">C.E.O, Weather It Is, LTD<br>Weather and Climate Focus<br><a href="http://weather-it-is.com" target="_blank">http://weather-it-is.com</a><br>Jerusalem, Israel<br>Local: 02 930 9525<br>Cell: 054 7 231 170<br>Int-IS: x972 2 930 9525<br>US <a href="tel:(914)%20432-3108" value="+19144323108" target="_blank">914 432 3108</a><u></u><u></u></p></div></div></div></div></div></div></div><p class="MsoNormal">______________________________<wbr>_________________ ncl-talk mailing list <a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a> List instructions, subscriber options, unsubscribe: <a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" target="_blank">http://mailman.ucar.edu/<wbr>mailman/listinfo/ncl-talk</a> <u></u><u></u></p></div></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">Barry H. Lynn, Ph.D<div><div>Senior Lecturer,</div><div><div><span style="color:rgb(136,136,136)">The Institute of the Earth Science, </span><br style="color:rgb(136,136,136)"><span style="color:rgb(136,136,136)">The Hebrew University of Jerusalem, </span><br style="color:rgb(136,136,136)"><span style="color:rgb(136,136,136)">Givat Ram, Jerusalem 91904, Israel </span><br style="color:rgb(136,136,136)"></div><span style="color:rgb(136,136,136)">Tel: 972 547 231 170</span><br style="color:rgb(136,136,136)"><span style="color:rgb(136,136,136)">Fax: (972)-25662581</span></div></div><div><span style="color:rgb(136,136,136)"><br></span></div><div>C.E.O, Weather It Is, LTD<br>Weather and Climate Focus<br><a href="http://weather-it-is.com" target="_blank">http://weather-it-is.com</a><br>Jerusalem, Israel<br>Local: 02 930 9525<br>Cell: 054 7 231 170<br>Int-IS: x972 2 930 9525<br>US 914 432 3108<br></div></div></div>
</div>