<div dir="ltr"><div>A preferred approach would be to use the '<a href="https://www.ncl.ucar.edu/Document/Functions/Built-in/where.shtml"><b>where</b></a>' function.There are different ways to implement the [See Description section). Here is a very explicit approach:</div><div><br></div><div>a1= 100*(dim_sum_n(X,0))-(sqrt(dim_sum_n(x,0)))<br>a1= <b>where</b>(a1.eq.0, a1@_FillValue, a1)                     ; avid division by 0.0<br>A1=((dim_sum_n(y,0))*(dim_sum_n(X,0)))-(dim_sum_n(x,0))*(dim_sum_n(x*y,0))/a1<br></div><div>...</div><div>B2B1 = B2-B1<br>B2B1 = <b>where</b>(B2B1.eq.0, B2B1@_FillValue, B2B1)<br>chpOnset = ((A1-A2)/(B2B1))<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Sep 10, 2019 at 10:12 AM Toni Klemm 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 style="overflow-wrap: break-word;">Hi Atul,<br><br>Include an if-loop to only run chpOnset if B2 and B1 are not equal (thus no division by zero). If they are equal you could include an else portion and declare "chpOnset = 9.96921e+36”, making it a missing value.<br><br>Toni<br><div>
<div dir="auto" style="color:rgb(0,0,0);letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><div dir="auto" style="color:rgb(0,0,0);letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><div dir="auto" style="color:rgb(0,0,0);letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><div><br><br><b>Toni Klemm, Ph.D.<br></b>Postdoctoral Research Associate<br>Department of Ecosystem Science and Management<br>College of Agriculture and Life Sciences<br>Texas A&M University, College Station, TX<br><a href="http://www.toni-klemm.de" target="_blank">www.toni-klemm.de</a> | <a href="http://www.twitter.com/toniklemm" target="_blank">@toniklemm</a><br>Editorial Board member, <a href="http://www.eccforum.org" target="_blank">Early Career Climate Forum</a><br><br><br><br><br><br><br><br></div></div></div></div>
</div>
<br><blockquote type="cite">On Sep 10, 2019, at 12:57 AM, Atul Saini via ncl-talk <<a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a>> wrote:<br><br>Hi NCL,<br><br>While running the following code-<br><br>a=addfile("Data_File.nc","r")<br>x=a->tym(0:4,:,:)<br>X=sqrt(x)<br>y=a->rf(0:4,:,:)<br>Y=sqrt(y)<br>v=a->tym(5:9,:,:)<br>V=sqrt(v)<br>w=a->rf(5:9,:,:)<br>W=sqrt(w)<br>A1=((dim_sum_n(y,0))*(dim_sum_n(X,0)))-(dim_sum_n(x,0))*(dim_sum_n(x*y,0))/(100*(dim_sum_n(X,0))-(sqrt(dim_sum_n(x,0))))<br><br>A2=((dim_sum_n(w,0))*(dim_sum_n(V,0)))-(dim_sum_n(v,0))*(dim_sum_n(v*w,0))/(100*(dim_sum_n(V,0))-(sqrt(dim_sum_n(v,0))))<br><br>B1= (100*(dim_sum_n(x*y,0)))-(dim_sum_n(y,0))/(100*(dim_sum_n(X,0))-(sqrt(dim_sum_n(x,0))))<br><br>B2= (100*(dim_sum_n(v*w,0)))-(dim_sum_n(w,0))/(100*(dim_sum_n(V,0))-(sqrt(dim_sum_n(v,0))))<br><br>chpOnset = ((A1-A2)/(B2-B1))<br>print(chpOnset)<br><br>I am receiving the following error-<br>fatal:divide: Division by 0, Can't continue<br>fatal:Div: operator failed, can't continue<br><br>Please help, what should be done here?<br><br>Regards,<br><br><br>                           <br><span id="gmail-m_-5151411799378473126cid:f_k0dezfwf0"><Data_File.nc></span>_______________________________________________<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="https://urldefense.proofpoint.com/v2/url?u=http-3A__mailman.ucar.edu_mailman_listinfo_ncl-2Dtalk&d=DwICAg&c=u6LDEWzohnDQ01ySGnxMzg&r=zmhRVp0i4wZ5_1Ujh0fnRXAExHgKLTQu0rZLW7PxKA4&m=i-1nT_UhpTjL9AKGdDm3lDt4Lby1v-EFWn-4jeJ703Y&s=yB0EgGvVdxmWZT-DJgktgjRkcOMSd0xAadSqj-YayB0&e=" target="_blank">https://urldefense.proofpoint.com/v2/url?u=http-3A__mailman.ucar.edu_mailman_listinfo_ncl-2Dtalk&d=DwICAg&c=u6LDEWzohnDQ01ySGnxMzg&r=zmhRVp0i4wZ5_1Ujh0fnRXAExHgKLTQu0rZLW7PxKA4&m=i-1nT_UhpTjL9AKGdDm3lDt4Lby1v-EFWn-4jeJ703Y&s=yB0EgGvVdxmWZT-DJgktgjRkcOMSd0xAadSqj-YayB0&e=</a><br></blockquote><br></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>