<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#333333;background-color:#FFFFFF;font-family:'Times New Roman', Times, serif;">
<p><span style="font-size: 12pt; font-family: Calibri, Arial, Helvetica, sans-serif;"><span style="font-family: Calibri, Arial, Helvetica, sans-serif;">Thank you so much</span></span></p>
<p><span style="font-size: 12pt;"><span style="font-family: Calibri, Arial, Helvetica, sans-serif;">I tried with following syntax.</span><span style="font-family: Calibri, Arial, Helvetica, sans-serif;"><span style="font-family: Calibri, Arial, Helvetica, sans-serif;">If&nbsp;</span></span><span style="font-family: Calibri, Arial, Helvetica, sans-serif;"><span style="font-family: Calibri, Arial, Helvetica, sans-serif;">it
 has properly considered first condition expression, the error</span></span><span style="font-family: Calibri, Arial, Helvetica, sans-serif;"><span style="font-family: Calibri, Arial, Helvetica, sans-serif;">&nbsp;&quot;fatal:divide: Division by 0&quot; would not have been
 appeared.</span></span></span></p>
<p><span style="font-family: Menlo; font-size: 11px;"><br>
</span></p>
<p style="margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">
ncl 49&gt; output = where((b(:,:,:).eq.0 .or. d(:,:,:).eq.0), (d-b), (d/b))</p>
<p style="margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">
fatal:divide: Division by 0, Can't continue</p>
<p style="margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">
fatal:Div: operator failed, can't continue</p>
<p></p>
<p style="margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">
fatal:[&quot;Execute.c&quot;:8573]:Execute: Error occurred at or near line 49</p>
<p style="margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">
<br>
</p>
<p style="margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">
<br>
</p>
<p style="margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">
<span style="font-size: 12pt;">Regards,</span><br>
</p>
<div id="Signature">
<div id="divtagdefaultwrapper" style="font-size:12pt; color:#333333; background-color:#FFFFFF; font-family:'Times New Roman',Times,serif">
<p><b><font color="#4ba524">Amit Prasad Timilsina</font></b></p>
<p><font color="#006fc9">School of Natural Resources,UNL</font></p>
<p><font color="#006fc9"><br>
</font></p>
<p><font color="#006fc9"></font></p>
</div>
</div>
<br>
<br>
<div style="color: rgb(0, 0, 0);">
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Rick Brownrigg &lt;brownrig@ucar.edu&gt;<br>
<b>Sent:</b> Tuesday, January 5, 2016 7:41 PM<br>
<b>To:</b> amit timilsina<br>
<b>Cc:</b> ncl-talk@ucar.edu<br>
<b>Subject:</b> Re: [ncl-talk] Taking ratio of precipitation dataset</font>
<div>&nbsp;</div>
</div>
<div>
<div dir="ltr">
<div>
<div>Hi Amit,<br>
<br>
</div>
As was pointed out to me by one of my colleagues, you want to remove the calls to &quot;any()&quot; in the where statement I gave previously; otherwise, you'll still get differences everywhere.<br>
<br>
</div>
Rick<br>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Tue, Jan 5, 2016 at 4:20 PM, Rick Brownrigg <span dir="ltr">
&lt;<a href="mailto:brownrig@ucar.edu" target="_blank">brownrig@ucar.edu</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
<div dir="ltr">Offhand, it seems like you want to use the where() function, rather than an if/else coupled with any():<br>
<br>
<a href="http://ncl.ucar.edu/Document/Functions/Built-in/where.shtml" target="_blank">http://ncl.ucar.edu/Document/Functions/Built-in/where.shtml</a><br>
<br>
<div class="gmail_extra"><br>
</div>
<div class="gmail_extra">Something like (untested):<br>
&nbsp;<br>
</div>
<div class="gmail_extra">output = where((any(b(:,:,:).eq.0)) .or. (any(d(:,:,:).eq.0)), d-b, d/b)<br>
</div>
<div class="gmail_extra"><br>
<br>
</div>
<div class="gmail_extra">
<div class="gmail_quote">
<div>
<div class="h5">On Tue, Jan 5, 2016 at 4:10 PM, amit timilsina <span dir="ltr">&lt;<a href="mailto:timilsinaamit87@huskers.unl.edu" target="_blank">timilsinaamit87@huskers.unl.edu</a>&gt;</span> wrote:<br>
</div>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex; border-left:1px solid rgb(204,204,204); padding-left:1ex">
<div>
<div class="h5">Respected all,<br>
<br>
I would like to take ratio and differences of variable precipitation(pr) in such way that if both the values for particular day is positive or greater than zero, I want to take ratio. If one of the values, either denominator or numerator, is zero, then I would
 like to take differences. Here is my code:<br>
ncl 0&gt; a=addfile(&quot;pr_day_MRI-CGCM3_decadal2005_r1i1p1_20060101-20351231.nc&quot;,&quot;r&quot;)<br>
ncl 1&gt; b=a-&gt;pr<br>
ncl 2&gt; c=addfile(&quot;pr_day_MRI-CGCM3_rcp45_r1i1p1_20060101-20351231.nc&quot;,&quot;r&quot;)<br>
ncl 3&gt; d=a-&gt;pr<br>
ncl 4&gt; if (any(b(:,:,:).eq.0)) .or. (any(d(:,:,:).eq.0)) then<br>
ncl 5&gt; output = (d-b)<br>
ncl 6&gt; else<br>
ncl 7&gt; ouput = d/b<br>
ncl 8&gt; end if<br>
<br>
This output gives me only differences, not a combination of both. Is it possible to put any flag to know whether we have considered differences or ratio at each grid level? I have attached printVarSummary for further information.<br>
<br>
Thank you in advance<br>
<br>
<br>
<br>
Amit Prasad Timilsina<br>
PhD student<br>
School of Natural Resources,UNL<br>
<br>
</div>
</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><br>
<br>
</blockquote>
</div>
<br>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</div>
</div>
</div>
</body>
</html>