if statement in grads
Stephen R McMillan
smcmillan at PLANALYTICS.COM
Thu Mar 12 11:39:31 EDT 2009
John,
The if statement you quoted--the one that Jennifer suggested--is valid, as
is the nested method that Pablo suggested. However, your unexpected
results appear to indicate the "if..else" conditions (in particular are
not changing during the second time loop iteration. Since your variable
'aa' would be the same at each timestep, then I suppose 'iwc' may be the
culprit. Have you tried echo-displaying the conditional results at each
timestep to confirm their values?
Stephen Mc
John Guhin <johnguhin at GMAIL.COM>
Sent by: GRADSUSR at LIST.CINECA.IT
03/11/2009 08:03 PM
Please respond to
GRADSUSR at LIST.CINECA.IT
To
GRADSUSR at LIST.CINECA.IT
cc
Subject
Re: if statement in grads
Thanks Stephen.
I simplified the script by considering only one time (t). The problem is
indeed if statement.
It seems if statement like this if (rainlow <=aa & aa<rainhigh)
does not work in grads. Is it true? or there is another way to solve my
problem?
thanks in advance.
On Wed, Mar 11, 2009 at 5:07 PM, Stephen R McMillan <
smcmillan at planalytics.com>wrote:
John,
Check the position of your "t1=1" line. As it is, it would appear to
repeat the 20 days once. Did you intend to put "t1=1" before the
outermost while loop?
Stephen Mc
John Guhin <johnguhin at GMAIL.COM>
Sent by: GRADSUSR at LIST.CINECA.IT
03/11/2009 03:48 PM
Please respond to
GRADSUSR at LIST.CINECA.IT
To
GRADSUSR at LIST.CINECA.IT
cc
Subject
Re: if statement in grads
Hi,
I tried with
if (rainlow <=aa & aa<rainhigh)
but didn't work. Am I mising something?
thanks in advance.
On Wed, Mar 11, 2009 at 1:28 PM, Jennifer Adams <jma at cola.iges.org>wrote:
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
--
John Guhin
***************************************************
The information contained in this e-mail message is intended only for the
use of the recipient(s) named above and may contain information that is
privileged, confidential, and/or proprietary. If you are not the intended
recipient, you may not review, copy or distribute this message. If you
have received this communication in error, please notify the sender
immediately by e-mail, and delete the original message.
***************************************************
--
John Guhin
***************************************************
The information contained in this e-mail message is intended only for the use of the recipient(s) named above and may contain information that is privileged, confidential, and/or proprietary. If you are not the intended recipient, you may not review, copy or distribute this message. If you have received this communication in error, please notify the sender immediately by e-mail, and delete the original message.
***************************************************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20090312/c9d30ccc/attachment.html
More information about the gradsusr
mailing list