Thanks Stephen. You are correct for more than one time step. But can we read a 2D variable at all inside the if statement? Consider the following:<br><br>'open /raid/pray/processed_data/IWC/iwc.ctl'<br>'open /raid/pray/processed_data/AMSRE/rain-amsre_15jun06-31aug08.ctl'<br>
rainlow=0 ; rainhigh=5;<br>lon1=0 ; lon2=360<br>lat1=-30 ; lat2=30<br>undef=-1e+34<br>z1=1<br>while(z1<19)<br>'set z 'z1<br>'define aa=rain.2*24'<br>if (rainlow <= aa & aa < rainhigh)<br>'d aave(iwc,lon='lon1',lon='lon2',lat='lat1',lat='lat2')'<br>
else<br>'d aave(iwc*0+'undef',lon='lon1',lon='lon2',lat='lat1',lat='lat2')'<br>endif<br>z1=z1+1<br>endwhile<br><br>iwc is 3D. rain.2 is actually a 2D variable, so aa is also 2D. I think thats where the problem is. Anybody has faced similar problem? <br>
thanks.<br><br><br><br><div class="gmail_quote">On Thu, Mar 12, 2009 at 11:39 AM, Stephen R McMillan <span dir="ltr"><<a href="mailto:smcmillan@planalytics.com">smcmillan@planalytics.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br><font face="sans-serif" size="2">John,</font><br><font face="sans-serif" size="2">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?</font><br><font face="sans-serif" size="2">Stephen Mc</font><br><br><br><table width="100%"><tbody><tr valign="top"><td width="40%"><div class="im"><font face="sans-serif" size="1"><b>John Guhin <<a href="mailto:johnguhin@GMAIL.COM" target="_blank">johnguhin@GMAIL.COM</a>></b></font><br>
<font face="sans-serif" size="1">Sent by: <a href="mailto:GRADSUSR@LIST.CINECA.IT" target="_blank">GRADSUSR@LIST.CINECA.IT</a></font></div><p><font face="sans-serif" size="1">03/11/2009 08:03 PM</font></p><div><div></div>
<div class="h5"><table border="1"><tbody><tr valign="top"><td bgcolor="white"><div align="center"><font face="sans-serif" size="1">Please respond to<br><a href="mailto:GRADSUSR@LIST.CINECA.IT" target="_blank">GRADSUSR@LIST.CINECA.IT</a></font></div>
</td></tr></tbody></table><br></div></div></td><td width="59%"><table width="100%"><tbody><tr valign="top"><td><div align="right"><font face="sans-serif" size="1">To</font></div></td><td><font face="sans-serif" size="1"><a href="mailto:GRADSUSR@LIST.CINECA.IT" target="_blank">GRADSUSR@LIST.CINECA.IT</a></font></td>
</tr><tr valign="top"><td><div align="right"><font face="sans-serif" size="1">cc</font></div></td><td></td></tr><tr valign="top"><td><div align="right"><font face="sans-serif" size="1">Subject</font></div></td><td><font face="sans-serif" size="1">Re: if statement in grads</font></td>
</tr></tbody></table><br><table><tbody><tr valign="top"><td></td><td></td></tr></tbody></table><br></td></tr></tbody></table><div><div></div><div class="h5"><br><br><br><font size="3">Thanks Stephen. </font><br><font size="3"> I simplified the script by considering only one
time (t). The problem is indeed if statement.</font><br><font size="3">It seems if statement like this if (rainlow <=aa
& aa<rainhigh)</font><br><font size="3">does not work in grads. Is it true? or there is another
way to solve my problem?</font><br><br><font size="3">thanks in advance.</font><br><br><br><font size="3">On Wed, Mar 11, 2009 at 5:07 PM, Stephen R McMillan <</font><a href="mailto:smcmillan@planalytics.com" target="_blank"><font color="blue" size="3"><u>smcmillan@planalytics.com</u></font></a><font size="3">>wrote:</font><br>
<font size="2">John,</font><br><font size="2">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?</font><br><font size="2">Stephen Mc</font><br><br><br><table width="100%"><tbody><tr valign="top"><td width="40%"><font size="1"><b>John Guhin <</b></font><a href="mailto:johnguhin@GMAIL.COM" target="_blank"><font color="blue" size="1"><b><u>johnguhin@GMAIL.COM</u></b></font></a><font size="1"><b>></b></font><br>
<font size="1">Sent by: </font><a href="mailto:GRADSUSR@LIST.CINECA.IT" target="_blank"><font color="blue" size="1"><u>GRADSUSR@LIST.CINECA.IT</u></font></a><br><br><font size="1">03/11/2009 03:48 PM</font><br><table border="1" width="100%">
<tbody><tr valign="top"><td bgcolor="white" width="100%"><div align="center"><font size="1">Please respond to</font><br><a href="mailto:GRADSUSR@LIST.CINECA.IT" target="_blank"><font color="blue" size="1"><u>GRADSUSR@LIST.CINECA.IT</u></font></a></div>
</td></tr></tbody></table><br><br></td><td width="59%"><table width="100%"><tbody><tr valign="top"><td width="38%"><div align="right"><font size="1">To</font></div></td><td width="61%"><a href="mailto:GRADSUSR@LIST.CINECA.IT" target="_blank"><font color="blue" size="1"><u>GRADSUSR@LIST.CINECA.IT</u></font></a></td>
</tr><tr valign="top"><td><div align="right"><font size="1">cc</font></div></td><td></td></tr><tr valign="top"><td><div align="right"><font size="1">Subject</font></div></td><td><font size="1">Re: if statement in grads</font></td>
</tr></tbody></table><br><table width="100%"><tbody><tr valign="top"><td width="50%"></td><td width="50%"></td></tr></tbody></table><br><br></td></tr></tbody></table><br><br><br><br><font size="3">Hi,</font><br><font size="3"> I tried with</font><br>
<font size="3"> if (rainlow <=aa & aa<rainhigh)</font><br><br><font size="3"> but didn't work. Am I mising something?</font><br><br><font size="3">thanks in advance.</font><br><br><br><font size="3">On Wed, Mar 11, 2009 at 1:28 PM, Jennifer Adams <</font><a href="mailto:jma@cola.iges.org" target="_blank"><font color="blue" size="3"><u>jma@cola.iges.org</u></font></a><font size="3">>wrote:</font><br>
<font size="3">Try changing your if statement to: </font><br><font size="3">if (rainlow <=aa & aa<rainhigh)</font><br><font size="3">--Jennifer</font><br><br><font size="3">On Mar 11, 2009, at 1:19 PM, John Guhin wrote:</font><br>
<br><br><font size="3">Hi,</font><br><font size="3"> I am trying to use if statement in
a grads script... which doesn't seem to work. I am </font><br><font size="3">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. </font><br><br><font size="3"> 'reinit'</font><br><font size="3">'c'</font><br><font size="3">'open iwc.ctl'</font><br><font size="3">'open /rain.ctl'</font><br>
<font size="3">'set gxout fwrite'</font><br><font size="3">'set fwrite iwc_ppt_binned.dat'</font><br><br><font size="3">lon1=40 ; lon2=180</font><br><font size="3">lat1=-20 ; lat2=20</font><br><font size="3">undef=-1e+34</font><br>
<font size="3">rainlow=0 ; rainhigh=5;</font><br><br><font size="3">while(rainhigh<11)</font><br><font size="3">t1=1</font><br><font size="3">while(t1<21)</font><br><font size="3">'set t 't1</font><br><font size="3">z1=1</font><br>
<font size="3">while(z1<19)</font><br><font size="3">'set z 'z1</font><br><font size="3">'define aa=24*rain.2(z=1)'</font><br><font size="3">if (rainlow <= aa < rainhigh)</font><br><font size="3">'d aave(iwc,lon='lon1',lon='lon2',lat='lat1',lat='lat2')'</font><br>
<font size="3">else</font><br><font size="3">'d aave(iwc*0+'undef',lon='lon1',lon='lon2',lat='lat1',lat='lat2')'</font><br><font size="3">endif</font><br><font size="3">z1=z1+1</font><br>
<font size="3">endwhile</font><br><font size="3">t1=t1+1</font><br><font size="3">endwhile</font><br><font size="3">rainlow=rainlow+5</font><br><font size="3">rainhigh=rainhigh+5</font><br><font size="3">endwhile</font><br>
<br><font size="3">'close 2'</font><br><font size="3">'close 1'</font><br><font size="3">'disable fwrite'</font><br><br><font size="3">-- </font><br><font size="3">John Guhin</font><br><font color="#8f8f8f" size="3">--</font><br>
<font color="#8f8f8f" size="3">Jennifer M. Adams</font><br><font color="#8f8f8f" size="3">IGES/COLA</font><br><font color="#8f8f8f" size="3">4041 Powder Mill Road, Suite 302</font><br><font color="#8f8f8f" size="3">Calverton, MD 20705</font><br>
<a href="mailto:jma@cola.iges.org" target="_blank"><font color="blue" size="3"><u>jma@cola.iges.org</u></font></a><br><br><br><br><br><br><br><br><font size="3">-- </font><br><font size="3">John Guhin</font><br><br><br><br>
<font size="3">***************************************************</font><br><font size="3">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.</font><br><font size="3">***************************************************</font><br><br><br><br><font size="3">-- </font><br><font size="3">John Guhin</font><br>
<br><br>
<br>
***************************************************<br>
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.<br>
***************************************************<br></div></div></blockquote></div><br><br clear="all"><br>-- <br>John Guhin<br>