<div dir="ltr"><div><div><div>Dear GrADS Users,<br><br></div>I am trying to use if and while loop. I am interested in counting the number of times the difference variable (DF) is not equal to zero. I wrote following script, there is no error but it seems it is not working fine. Please suggest what could be wrong?<br><br></div><div><br></div><div>After opening my GrADS readable file, I calculated the value of a difference variable DF for 15 times. I need to see how many times this variable is giving value other than zero. I am using following while and if loop.<br><br></div><div>



















<p class="MsoNormal">&#39;define MV=(DT(t=1)+DT(t=2)+DT(t=3)+DT(t=4))/4&#39;</p>

<p class="MsoNormal"> </p>

<p class="MsoNormal">&#39;define DF1=MV-(DT(t=5)+DT(t=6)+DT(t=7)+DT(t=8))/4&#39;</p>

<p class="MsoNormal">&#39;define DF2=MV-(DT(t=1)+DT(t=3)+DT(t=5)+DT(t=7))/4&#39;</p>

<p class="MsoNormal">&#39;define DF3=MV-(DT(t=2)+DT(t=3)+DT(t=4)+DT(t=5))/4&#39;</p>

<p class="MsoNormal">&#39;define DF4=MV-(DT(t=1)+DT(t=4)+DT(t=5)+DT(t=7))/4&#39;</p>

<p class="MsoNormal">&#39;define DF6=MV-(DT(t=5)+DT(t=6)+DT(t=7)+DT(t=8))/4&#39;</p>

<p class="MsoNormal">&#39;define DF7=MV-(DT(t=1)+DT(t=3)+DT(t=5)+DT(t=7))/4&#39;</p>

<p class="MsoNormal">&#39;define DF8=MV-(DT(t=2)+DT(t=3)+DT(t=4)+DT(t=5))/4&#39;</p>

<p class="MsoNormal">&#39;define DF9=MV-(DT(t=1)+DT(t=4)+DT(t=5)+DT(t=7))/4&#39;</p>

<p class="MsoNormal"> </p>

<p class="MsoNormal">&#39;define DF10=MV-(DT(t=2)+DT(t=5)+DT(t=7)+DT(t=9))/4&#39;</p>

<p class="MsoNormal">&#39;define DF11=MV-(DT(t=1)+DT(t=5)+DT(t=6)+DT(t=7))/4&#39;</p>

<p class="MsoNormal">&#39;define DF12=MV-(DT(t=3)+DT(t=4)+DT(t=6)+DT(t=7))/4&#39;</p>

<p class="MsoNormal">&#39;define DF13=MV-(DT(t=4)+DT(t=6)+DT(t=8)+DT(t=9))/4&#39;</p>

<p class="MsoNormal">&#39;define DF14=MV-(DT(t=1)+DT(t=4)+DT(t=8)+DT(t=9))/4&#39;</p>

<p class="MsoNormal">&#39;define DF15=MV-(DT(t=1)+DT(t=2)+DT(t=8)+DT(t=9))/4&#39;</p>

<p class="MsoNormal"> </p>

<p class="MsoNormal"> </p>

<p class="MsoNormal">count= 0</p>

<p class="MsoNormal">i=1; while (i&lt;=15)</p>

<p class="MsoNormal">if (DF&#39;i&#39; !=0)</p>

<p class="MsoNormal">count=count+1</p>

<p class="MsoNormal">endif</p>

<p class="MsoNormal">i=i+1</p>

<p class="MsoNormal">endwhile</p>

<p class="MsoNormal">p=count/15</p>





</div>*******************************************************<br><br>Thanks,<br><br></div>Mubashar<br></div>