if statement in grads

John Guhin johnguhin at GMAIL.COM
Wed Mar 11 13:19:18 EDT 2009


Hi,
    I am trying to use if statement in a grads script... which doesn't seem
to work. I am
attaching  the gs file. iwc is a 3D variable, and rain is 2D variable
exactly in the same grids. I am trying to extract iwc when rain is within
certain range. The script executes without any error, but the output repeats
itself every 20 days. This means that the " if" statement is not working!!
Any help would be appreciated.

 'reinit'
'c'
'open iwc.ctl'
'open /rain.ctl'
'set gxout fwrite'
'set fwrite iwc_ppt_binned.dat'

lon1=40 ; lon2=180
lat1=-20 ; lat2=20
undef=-1e+34
rainlow=0 ; rainhigh=5;

while(rainhigh<11)
t1=1
while(t1<21)
'set t 't1
z1=1
while(z1<19)
'set z 'z1
'define aa=24*rain.2(z=1)'
if (rainlow <= aa < rainhigh)
'd aave(iwc,lon='lon1',lon='lon2',lat='lat1',lat='lat2')'
else
'd aave(iwc*0+'undef',lon='lon1',lon='lon2',lat='lat1',lat='lat2')'
endif
z1=z1+1
endwhile
t1=t1+1
endwhile
rainlow=rainlow+5
rainhigh=rainhigh+5
endwhile

'close 2'
'close 1'
'disable fwrite'

--
John Guhin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20090311/73a04419/attachment.html 


More information about the gradsusr mailing list