<div dir="ltr"><div>Hi Barry,</div><div>I did not mean that "where" function should change 2d into 1d, that would not make sense for this function. "where" function would maintain the shape of it's first argument, in your case qs(k,:,:), which is why you get 2d result. <br></div><div><br></div><div>Anyway, I do not have any further comments on this...</div><div><br></div><div>Cheers,</div><div>Rashed<br></div><div><br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Nov 27, 2019 at 7:20 PM Barry Lynn via ncl-talk <<a href="mailto:ncl-talk@ucar.edu">ncl-talk@ucar.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi Rashed:<div><br></div><div>I thought that you should be correct as well.  However, when I printed out sum_q, NCL said that it was a 2 dimensional variable!  I was quite surprised to see this.  </div><div><br></div><div>So, sum_q is changed from a 1 dimensional variable to a 2 dimensional variables (rather than the other way around, where the 1 dimensional variable forces the where statement operating on 2 dimensions to become a 1 dimensional statement.</div><div><br></div><div>





<p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:19px;line-height:normal;font-family:"Courier New";color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures"><span>       </span></span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(224,228,9)">sum_q</span><span style="font-variant-ligatures:no-common-ligatures"> = 0.</span></p>
<p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:19px;line-height:normal;font-family:"Courier New";color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures">;<span>      </span></span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(224,228,9)">sum_q</span><span style="font-variant-ligatures:no-common-ligatures">(0,0) = 1</span></p>
<p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:19px;line-height:normal;font-family:"Courier New";color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures"><span>       </span></span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(224,228,9)">sum_q</span><span style="font-variant-ligatures:no-common-ligatures"> :=<span>  </span>where(qs(k,:,:).ge.0.1,</span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(224,228,9)">sum_q</span><span style="font-variant-ligatures:no-common-ligatures">+1,</span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(224,228,9)">sum_q</span><span style="font-variant-ligatures:no-common-ligatures">)</span></p></div><div><br></div><div>





<p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:19px;line-height:normal;font-family:"Courier New";color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures">Variable: sum_q</span></p>
<p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:19px;line-height:normal;font-family:"Courier New";color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures">Type: float</span></p>
<p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:19px;line-height:normal;font-family:"Courier New";color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures">Total Size: 357604 bytes</span></p>
<p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:19px;line-height:normal;font-family:"Courier New";color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures"><span>            </span>89401 values</span></p>
<p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:19px;line-height:normal;font-family:"Courier New";color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures">Number of Dimensions: 2</span></p>
<p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:19px;line-height:normal;font-family:"Courier New";color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures">Dimensions and sizes:<span style="white-space:pre-wrap">   </span>[299] x [299]</span></p>
<p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:19px;line-height:normal;font-family:"Courier New";color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures">Coordinates:<span> </span></span></p>
<p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:19px;line-height:normal;font-family:"Courier New";color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures">Number Of Attributes: 1</span></p>
<p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:19px;line-height:normal;font-family:"Courier New";color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures"><span>  </span>_FillValue :<span style="white-space:pre-wrap">        </span>9.96921e+36</span></p></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Nov 27, 2019 at 8:18 PM Dennis Shea <<a href="mailto:shea@ucar.edu" target="_blank">shea@ucar.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>re:   := </div><div>Yes.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Nov 27, 2019 at 10:49 AM Barry Lynn via ncl-talk <<a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi Dave:<div><br></div><div>Thank you for your suggestions.</div><div><br></div><div>I actually need to sum_q for all elements of the remaining (:,:) 2d array to obtain a single number.</div><div><br></div><div>I am dividing one number by it. </div><div><br></div><div>I assume that it is okay to put the := and that I will get the sum over all 2d elements?</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Nov 27, 2019 at 7:40 PM Dave Allured - NOAA Affiliate <<a href="mailto:dave.allured@noaa.gov" target="_blank">dave.allured@noaa.gov</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>"sum_q = 1." defines this variable as scalar.  Then the where statement attempts to write a 2-D array onto a scalar.  The assignment statement is not allowed to change dimensions.</div><div><br></div><div>One way to fix this would be to use the reassignment operator ":=", which IS allowed to change dimensions on assignment.</div><div><br></div><div>Another way to fix this would be to define sum_q as a 2-D array before the start of the loop.  I suspect that is what you really intended.</div><div><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Nov 27, 2019 at 10:22 AM Barry Lynn via ncl-talk <<a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi:<div><br></div><div>I have some simple code.</div><div><br></div><div>





<p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:18px;line-height:normal;font-family:"Courier New";color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures"><span>      </span>do k = 0,dims3d(0)-1</span></p>
<p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:18px;line-height:normal;font-family:"Courier New";color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures"><span>       </span>qs(k,:,:) = </span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(224,228,9)">where</span><span style="font-variant-ligatures:no-common-ligatures">(qs(k,:,:).lt.0.1,q_null(k,:,:),qs(k,:,:))</span></p>
<p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:18px;line-height:normal;font-family:"Courier New";color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures"><span>       </span>sum_q = 1.</span></p>
<p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:18px;line-height:normal;font-family:"Courier New";color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures"><span>       </span>sum_q =<span>  </span></span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(224,228,9)">where</span><span style="font-variant-ligatures:no-common-ligatures">(qs(k,:,:).ge.0.1,sum_q+1,sum_q)</span></p>
<p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:18px;line-height:normal;font-family:"Courier New";color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures"><span>       </span>qs_1(k) = sum(qs(k,:,:))/sum_q+qs_1(k)</span></p>
<p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:18px;line-height:normal;font-family:"Courier New";color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures"><span>      </span>end do</span></p><p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:18px;line-height:normal;font-family:"Courier New";color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures"><br></span></p><p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:18px;line-height:normal;font-family:"Courier New";color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures">Why can't I do the "where" sum?</span></p><p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:18px;line-height:normal;font-family:"Courier New";color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures"><br></span></p><p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:18px;line-height:normal;font-family:"Courier New";color:rgb(0,0,0)">





</p><p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:18px;line-height:normal;font-family:"Courier New";color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures">fatal:Number of dimensions on right hand side do not match number of dimension in left hand side</span></p><div><br></div>-- <br><div dir="ltr"><div dir="ltr"><div><div dir="ltr">Barry H. Lynn, Ph.D<div><div>Senior Associate Scientist, 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</div></div></div></div></div></div></div></blockquote></div></div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr"><div dir="ltr"><div><div dir="ltr">Barry H. Lynn, Ph.D<div><div>Senior Associate Scientist, 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><br></div></div></div></div></div>
_______________________________________________<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/mailman/listinfo/ncl-talk</a></blockquote></div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr"><div dir="ltr"><div><div dir="ltr">Barry H. Lynn, Ph.D<div><div>Senior Associate Scientist, 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><br></div></div></div></div></div>
_______________________________________________<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/mailman/listinfo/ncl-talk</a></blockquote></div>