<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto">Hi Sakib,<div><br></div><div>try using the reassignment operator := for the lines defining p. </div><div><br></div><div>p := p_b1</div><div>and</div><div>p := p_b2</div><div><br></div><div>-Karin<div dir="ltr"><br>Am 11.08.2019 um 14:00 schrieb Sakib Ahmed via ncl-talk <<a href="mailto:ncl-talk@ucar.edu">ncl-talk@ucar.edu</a>>:<br><br></div><blockquote type="cite"><div dir="ltr"><div dir="ltr">Dear NCL Community,<div><br></div><div>I'm stuck with a dimension size error issue. Following is what the code looks like:</div><div><br></div><div>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;</div><div><br></div><div>begin<br><br> ustar=new(1,float)<br><br> z0=new((/1,4001/),float)<br><br> ust=fspan(0,4,4001)<br><br><br>ust_array=((/ust^8, ust^7, ust^6, ust^5, ust^4, ust^3, ust^2, ust^1, ust^0/))<br><br><br>printVarSummary(ust_array)<br><br>;polynomial<br><br>p_b1= (/-0.000098701949811, 0.001486209983407, -0.007584567778927, 0.019487056157620, -0.029314498154105, 0.024309735869547, -0.006997554677642, 0.001258400989803, -0.000043976208055/)<br><br>p_b2=(/-0.002182648458354, 0.046387047659009, -0.428830523588356, 2.251251262348664, -7.334368361013868, 15.163848944684784, -19.388290305787166,13.970227275905133, -4.319572176336596/)<br><br>g=9.806650</div><div><br></div><div>do i=0,4000<br> ustar=ust(i)</div><div><br> if (ustar.lt.0.3) then<br> z0(:,i)=0.0185/g * ustar^2<br><br> else if (<a href="http://ustar.lt/" target="_blank">ustar.lt</a>. 2.35) then ; this is the loop where I'm having the issue; not sure how to properly write this in NCL<br><br> p=p_b1<br> z0(:,i)=p*(ust_array(:,i))<br><br> else if (ustar.lt.3) then<br><br> p=p_b2<br> z0(:,i)=p*ust_array(:,i)<br><br><br> else<br> z0(:,i)=0.001305<br><br> end if<br> end if<br> end if<br>end do<br>end</div><div><br></div><div>fatal:Dimension sizes on right hand side of assignment do not match dimension sizes of left hand side<br>fatal:["Execute.c":8635]:Execute: Error occurred at or near line 32<br></div><div><br></div><div><br></div><div>printVarSummary(ust_array)<br><br>Variable: ust_array<br>Type: float<br>Total Size: 144036 bytes<br> 36009 values<br>Number of Dimensions: 2<br>Dimensions and sizes: [9] x [4001]<br>Coordinates:<br></div><div><br></div><div>printVarSummary(z0)<br><br>Variable: z0<br>Type: float<br>Total Size: 16004 bytes<br> 4001 values<br>Number of Dimensions: 2<br>Dimensions and sizes: [1] x [4001]<br>Coordinates:<br>Number Of Attributes: 1<br> _FillValue : 9.96921e+36<br></div><div><br></div><div><br></div><div>I'm still new in NCL but I able to solve this same problem in Matlab and putting this below as a reference. But I'm really interested to do this in NCL.</div><div><br></div><div>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Matlab version;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;</div><div><br></div><div>z0=[]; ust_array=[];<br>ustar=[];<br><br>ust=[0:001:4];</div><div><br>ust_array=[ust.^8; ust.^7; ust.^6; ust.^5; ust.^4; ust.^3; ust.^2; ust.^1; ust.^0;];<br><br>% polynomial:<br>p_b1= [-0.000098701949811, 0.001486209983407, ...<br> -0.007584567778927, 0.019487056157620, ...<br> -0.029314498154105, 0.024309735869547, ...<br> -0.006997554677642, 0.001258400989803, ...<br> -0.000043976208055];<br>p_b2=[-0.002182648458354, 0.046387047659009, ...<br> -0.428830523588356, 2.251251262348664, ...<br> -7.334368361013868, 15.163848944684784, ...<br> -19.388290305787166,13.970227275905133, ...<br> -4.319572176336596];<br>g=9.806650;<br><br><br>for i=1:length(ust)<br> <br> ustar=ust(i);<br> if ustar < 0.3<br> z0(i)=0.0185/g * ustar^2;<br> elseif ustar < 2.35<br> p=p_b1;<br> z0(i)=p*ust_array(:,i);<br> elseif ustar < 3<br> p=p_b2;<br> z0(i)=p*ust_array(:,i);<br> else<br> z0(i)=0.001305;<br> end <br>end<br></div><div><br></div><div>Thank you in advance for the help. </div><div>Sakib</div><div><br></div><div><div style=""><font face="arial, sans-serif" style="" color="#000000">Sakib Ahmed</font></div><div style=""><font face="arial, sans-serif" color="#000000">Connecticut College</font></div><div style=""><font face="arial, sans-serif" color="#000000">Environmental Studies Major,</font></div><div style=""><font face="arial, sans-serif" color="#000000">New London, CT 06320</font></div><div style="color:rgb(136,136,136)"><br class="gmail-Apple-interchange-newline"></div></div><div class="gmail-yj6qo gmail-ajU" style="outline:none;padding:10px 0px;width:22px;margin:2px 0px 0px"><br class="gmail-Apple-interchange-newline"></div></div>
</div></blockquote><blockquote type="cite"><div dir="ltr"><span>_______________________________________________</span><br><span>ncl-talk mailing list</span><br><span><a href="mailto:ncl-talk@ucar.edu">ncl-talk@ucar.edu</a></span><br><span>List instructions, subscriber options, unsubscribe:</span><br><span><a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a></span></div></blockquote></div></body></html>