<div dir="ltr">Hello,<br><div><br></div><div> I have do loop as follow. The b12^log(L(j,k)) is very small about exp(-80). What is a suitable way to make NCL handle this calculation, rather than return 0?</div><div><br></div><div><div> do k= 0,dt(2)-1</div><div> do j= 256,511</div><div> if (th(9,j,k).gt.357.5 .and. th(9,j,k).le.362.5) then</div><div> qt(j,k) = b10*b11^log(C(j,k))*b12^log(L(j,k))*b13^log(ht(j,k))*b14^log(ht(j,k))*b15^log(N(j,k))</div></div><div> ....................</div><div><br></div><div> Thanks,</div><div><br></div><div> Yi-Chih</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Apr 27, 2017 at 12:08 PM, Rick Brownrigg <span dir="ltr"><<a href="mailto:brownrig@ucar.edu" target="_blank">brownrig@ucar.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div><div><div><div><div><div><div><div><div><div>Hi Yi-Chih,<br><br></div>I am not sure what you mean by "...<span style="font-size:12.8px">But </span>b12^log(L(j,k))d in the do loop is not working...".<br><br></div>But hopefully to clarify, NCL is a typed language, so that:<br><br></div>1 ; is an integer<br></div>1. ; is a float<br></div>1d ; is a double<br></div>1.d ; is a double<br><br></div>and in general, unless the documentation states otherwise, many functions in NCL are integer-in/integer-out, float-in/float-out, etc.<br><br></div>So if in your example, "L(j,k)" is a float value, "log(L(j,k))" will be a float value, and subject to the valid range of floats. Going back to your original example:<br><br> b10 = todouble(exp(230.84))<br><br></div>230.84 is a float value, and exp(230.84) will be a float value that happens to exceed the valid range of floats. To coerce the result to double, you'll want:<br><br></div> b10 = exp(todouble(230.84)) ;; which is equivalent to "exp(230.84d)"<br><br></div>Hope that helps...<span class="HOEnZb"><font color="#888888"><br></font></span></div><span class="HOEnZb"><font color="#888888">Rick<br><div><div><div><br><br><br><br></div></div></div></font></span></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Apr 26, 2017 at 8:27 PM, Yi-Chih Huang <span dir="ltr"><<a href="mailto:dscpln@gmail.com" target="_blank">dscpln@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hello,<div><br></div><div> The <span style="font-size:12.8px">exp(230.84d) is working. But </span>b12^log(L(j,k))d in the do loop is not working. What would be the command to handle extreme large or extreme small numbers in do loop?</div><div><br></div><div> Thanks,</div><div><br></div><div> Yi-Chih</div><div> </div></div><div class="m_4653977248881174122HOEnZb"><div class="m_4653977248881174122h5"><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Apr 27, 2017 at 1:34 AM, Rick Brownrigg <span dir="ltr"><<a href="mailto:brownrig@ucar.edu" target="_blank">brownrig@ucar.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">This yields a float result, which is out of range for floats:<br><br><div>b10 = exp(230.84)<br></div>b20 = exp(203.22)<br><br><div>Try explicitly making the constants double:<br><br><div>b10 = exp(230.84d)<br></div><div>b20 = exp(203.22d)<br><br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="m_4653977248881174122m_-535711301357359297h5">On Wed, Apr 26, 2017 at 5:27 AM, Yi-Chih Huang <span dir="ltr"><<a href="mailto:dscpln@gmail.com" target="_blank">dscpln@gmail.com</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="m_4653977248881174122m_-535711301357359297h5"><div dir="ltr">Hello,<div><br></div><div> I work on NCL Version 6.1.2. It said the range of double type is e-308 - e+307 on <a href="https://www.ncl.ucar.edu/Document/Manuals/Ref_Manual/NclDataTypes.shtml" target="_blank">https://www.ncl.ucar.edu/Do<wbr>cument/Manuals/Ref_Manual/NclD<wbr>ataTypes.shtml</a>. Although I have tried several ways, I only got infinity and 8 bits in return. Could you show me the command to handle exponential calculation</div><div><div><br></div><div><br></div><div>b10 = todouble(exp(230.84))<br></div><div>b20 = todouble(exp(203.22))<br></div><div>b30 = new(1,double,0)<br></div><div>print(b10+" "+b20+" "+b30)<br></div><div><br></div><div><div>Variable: b30</div><div>Type: double</div><div>Total Size: 8 bytes</div><div> 1 values</div><div>Number of Dimensions: 1</div><div>Dimensions and sizes: [1]</div><div>Coordinates:</div></div><div><br></div><div>(0) inf inf inf<br></div></div><div><br></div><div><div>$ ncl -v</div><div>Unknown option `-v'</div><div> Copyright (C) 1995-2013 - All Rights Reserved</div><div> University Corporation for Atmospheric Research</div><div> NCAR Command Language Version 6.1.2</div><div> The use of this software is governed by a License Agreement.</div><div> See <a href="http://www.ncl.ucar.edu/" target="_blank">http://www.ncl.ucar.edu/</a> for more details.</div></div><div><br></div><div> Thanks much,</div><div><br></div><div> Yi-Chih</div></div>
<br></div></div>______________________________<wbr>_________________<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/mailma<wbr>n/listinfo/ncl-talk</a><br>
<br></blockquote></div><br></div>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>