<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">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" class="gmail_signature"><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>