# [ncl-talk] how can I avoid dividing by zero?

Sri Nandini snandini at marum.de
Wed Aug 22 02:39:14 MDT 2018

```Hello

how can I remove the zero values to avoid dividing by zero the error I got is as the following:

fatal:divide: Division by 0, Can't continue
fatal:Div: operator failed, can't continue

I have tried using   yinv = 1. / where(y.ne.0, y, y at _FillValue) but now it gives me all nan values

Heres the bit of my code

T41    = f->Z3(:,{850},:,:)

printVarSummary(T41)
T41 at _FillValue = -9.96921e+36

aveX    = dim_avg_n_Wrap(T41,0)
printVarSummary(aveX)                      ; (lat,lon)
T41 at _FillValue = -9.96921e+36

aveX = 1. / where(aveX.ne.0, aveX, aveX at _FillValue)

aveX1 and aveX2 below are of same type as aveX.
XLAT = conform ( aveX2 , xlat , 0 )
printVarSummary(XLAT)

egr = eady_growth_rate(aveX2, aveX1, aveX, XLAT, 0,  1)

Output
===========================
Variable: egr
Type: double
Total Size: 110592 bytes
13824 values
Number of Dimensions: 2
Dimensions and sizes:	[lat | 96] x [lon | 144]
Coordinates:
lat: [ -90..  90]
lon: [   0..357.5]
Number Of Attributes: 3
_FillValue :	-9.969209968386869e+36
long_name :	maximum eady growth rate
units :
(0)	maximum eady growth rate : min=nan   max=nan