<div dir="ltr">
<div>Sorry for chipping in here, and may be I am wrong but I do not follow the logic:</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">If you do: 
<span style="font-variant-ligatures:no-common-ligatures">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>

</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></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">The variable "sum_q" would be a 2d array containing <b>2s</b> and <b>1s</b>. Do you want a sum of 2s and 1s or you want a sum of qs(k,:,:) where it is greater than 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"><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"></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><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"><br></span></p></div><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Nov 27, 2019 at 10:50 AM 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:<div><br></div><div>The problem with the previous suggestion was that the sum_q became a 2 dimensional variable..  I needed it to be a 1D variables. I found this out by using the "function" printVarSummary</div><div><br></div><div>Here is the correct solution for my needs, based on the very helpful comments up to now.</div><div><br></div><div>Thanks</div><div><br></div><div>(sum_q was defined as a 2d variable -- note: sum_q is not really a sum, as used here, but defined as 1 whereever qs > 0.1).</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 ; just so I don't divide by 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"> =<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>
<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>add_q = sum(</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">); a 1d variable</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>printVarSummary(qs_1(k))</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>printVarSummary(</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>
<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>printVarSummary(add_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"><span>       </span>qs_1(k)<span>  </span>= sum(qs(k,:,:))/add_q+qs_1(k)</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>