if statement in grads
Jennifer Adams
jma at COLA.IGES.ORG
Wed Mar 11 13:28:01 EDT 2009
Try changing your if statement to:
if (rainlow <=aa & aa<rainhigh)
--Jennifer
On Mar 11, 2009, at 1:19 PM, John Guhin wrote:
>
> 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
--
Jennifer M. Adams
IGES/COLA
4041 Powder Mill Road, Suite 302
Calverton, MD 20705
jma at cola.iges.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20090311/386313f3/attachment.html
More information about the gradsusr
mailing list