[ncl-talk] fatal:divide: Division by 0, Can't continue

Toni Klemm toni-klemm at tamu.edu
Tue Sep 10 10:11:25 MDT 2019


Hi Atul,

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.

Toni


Toni Klemm, Ph.D.
Postdoctoral Research Associate
Department of Ecosystem Science and Management
College of Agriculture and Life Sciences
Texas A&M University, College Station, TX
www.toni-klemm.de <http://www.toni-klemm.de/> | @toniklemm <http://www.twitter.com/toniklemm>
Editorial Board member, Early Career Climate Forum <http://www.eccforum.org/>








> On Sep 10, 2019, at 12:57 AM, Atul Saini via ncl-talk <ncl-talk at ucar.edu> wrote:
> 
> Hi NCL,
> 
> While running the following code-
> 
> a=addfile("Data_File.nc","r")
> x=a->tym(0:4,:,:)
> X=sqrt(x)
> y=a->rf(0:4,:,:)
> Y=sqrt(y)
> v=a->tym(5:9,:,:)
> V=sqrt(v)
> w=a->rf(5:9,:,:)
> W=sqrt(w)
> 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))))
> 
> 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))))
> 
> 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))))
> 
> 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))))
> 
> chpOnset = ((A1-A2)/(B2-B1))
> print(chpOnset)
> 
> I am receiving the following error-
> fatal:divide: Division by 0, Can't continue
> fatal:Div: operator failed, can't continue
> 
> Please help, what should be done here?
> 
> Regards,
> 
> 
>                            
> <Data_File.nc>_______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> 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=

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20190910/ea39e31b/attachment.html>


More information about the ncl-talk mailing list