[gradsusr] if and while loop
Mubashar Ahmad
mubashardogar at gmail.com
Fri May 5 15:35:54 EDT 2017
Dear GrADS Users,
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?
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.
'define MV=(DT(t=1)+DT(t=2)+DT(t=3)+DT(t=4))/4'
'define DF1=MV-(DT(t=5)+DT(t=6)+DT(t=7)+DT(t=8))/4'
'define DF2=MV-(DT(t=1)+DT(t=3)+DT(t=5)+DT(t=7))/4'
'define DF3=MV-(DT(t=2)+DT(t=3)+DT(t=4)+DT(t=5))/4'
'define DF4=MV-(DT(t=1)+DT(t=4)+DT(t=5)+DT(t=7))/4'
'define DF6=MV-(DT(t=5)+DT(t=6)+DT(t=7)+DT(t=8))/4'
'define DF7=MV-(DT(t=1)+DT(t=3)+DT(t=5)+DT(t=7))/4'
'define DF8=MV-(DT(t=2)+DT(t=3)+DT(t=4)+DT(t=5))/4'
'define DF9=MV-(DT(t=1)+DT(t=4)+DT(t=5)+DT(t=7))/4'
'define DF10=MV-(DT(t=2)+DT(t=5)+DT(t=7)+DT(t=9))/4'
'define DF11=MV-(DT(t=1)+DT(t=5)+DT(t=6)+DT(t=7))/4'
'define DF12=MV-(DT(t=3)+DT(t=4)+DT(t=6)+DT(t=7))/4'
'define DF13=MV-(DT(t=4)+DT(t=6)+DT(t=8)+DT(t=9))/4'
'define DF14=MV-(DT(t=1)+DT(t=4)+DT(t=8)+DT(t=9))/4'
'define DF15=MV-(DT(t=1)+DT(t=2)+DT(t=8)+DT(t=9))/4'
count= 0
i=1; while (i<=15)
if (DF'i' !=0)
count=count+1
endif
i=i+1
endwhile
p=count/15
*******************************************************
Thanks,
Mubashar
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20170505/54aea5f5/attachment.html
More information about the gradsusr
mailing list