<div><div dir="auto">This is great, thank you so much for the help. </div></div><div dir="auto"><br></div><div dir="auto"><br></div><div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Aug 11, 2019 at 10:13 AM Dennis Shea <<a href="mailto:shea@ucar.edu">shea@ucar.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Matlab <===> NCL</div><div><br></div><div><div>[1] You do not need a '<b>begin'</b>/'<b>end</b>' for an NCL main script. They are optional.</div><div>[2] I am not Matlab literate but I believe <br></div><div> [a] Matlab uses column-major storage (like: Fortran, R, ...) <br></div><div> [b] Matlab uses 1-based subscripting like Fortran, R</div><div>[3] NCL is like C/C++/Python <br></div><div><div> [a] NCL uses row-major storage <br></div><div> [b] NCL uses 0-based subscripts <br></div><div><br></div><div>Each language has syntax that is unique for certain purposes. <br></div><div>However, in general, there is no one-to-one equivalence.<br></div><div><br></div></div></div><div><br></div><div><div>[snip]<br></div><div>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</div><div> ; not sure how to properly write this in NCL<br> p=p_b1<br> z0(:,i)=p*(ust_array(:,i)) <b> ; array of size [9] * array of size ?4000?</b></div><div> <b> ; in NCL, arrays must conform [same size/shape]</b></div><div><b> ; exception: a scalar is always conformant</b><br></div><div>[snip]</div><div><br></div><div>The <b>ust_array</b> is one-dimensional and is of size <b>[9]</b>.</div><div>ust_array=((/ust^8, ust^7, ust^6, ust^5, ust^4, ust^3, ust^2, ust^1, ust^0/))</div><div>n_ust_array = dimsizes(ust_array)</div><div>print("n_ust_array="+n_ust_array) ; 9</div><div><br></div><div>===</div><div>I've attached a quick-and-dirty code for testing. Rather that 4000, I used 40 because there are many print statements to help you.</div><div><br></div><div>Play around a bit. This is a good way to learn a language.</div><div><br></div><div>Good Luck<br></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Aug 11, 2019 at 8:01 AM Sakib Ahmed 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 Karin, <div><br></div><div>Thank you for the suggestion. I tried the reassignment operator but it didn't work. I'm still getting the error message "fatal:Dimension sizes on right hand side of assignment do not match dimension sizes of left hand side"</div><div><br></div><div>I also tried to convert p_b1 & p_b2 from 1D to 2D just to be consistent with the other variables (z0 and ust_array) dimension but that didn't work either. </div><div><br></div><div> -Sakib</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Aug 11, 2019 at 9:21 AM Karin Meier-Fleischer <<a href="mailto:meier-fleischer@dkrz.de" target="_blank">meier-fleischer@dkrz.de</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="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" target="_blank">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><font face="arial, sans-serif" color="#000000">Sakib Ahmed</font></div><div><font face="arial, sans-serif" color="#000000">Connecticut College</font></div><div><font face="arial, sans-serif" color="#000000">Environmental Studies Major,</font></div><div><font face="arial, sans-serif" color="#000000">New London, CT 06320</font></div><div style="color:rgb(136,136,136)"><br class="m_4595920839484751790gmail-m_-2265329559229858080gmail-m_-8498516794968912003gmail-Apple-interchange-newline"></div></div><div class="m_4595920839484751790gmail-m_-2265329559229858080gmail-m_-8498516794968912003gmail-yj6qo m_4595920839484751790gmail-m_-2265329559229858080gmail-m_-8498516794968912003gmail-ajU" style="outline:medium none currentcolor;padding:10px 0px;width:22px;margin:2px 0px 0px"><br class="m_4595920839484751790gmail-m_-2265329559229858080gmail-m_-8498516794968912003gmail-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" target="_blank">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" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a></span></div></blockquote></div></div></blockquote></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></div>