if statement in grads

Pablo Romero romero619 at HOTMAIL.COM
Wed Mar 11 21:18:33 EDT 2009


nested if should work too...

if (rainlow <=aa)
  if(aa<=rainhigh)
     do_stuff()...
  endif
endif

less elegant, but should achieve the same effect

P.Romero
________________________________
> Date: Wed, 11 Mar 2009 20:03:39 -0400
> From: johnguhin at GMAIL.COM
> Subject: Re: if statement in grads
> To: GRADSUSR at LIST.CINECA.IT
>
>
> 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>
> 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> 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>
>
> 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>
> but didn't work. Am I mising something?
>
> thanks in advance.
>
>
> On Wed, Mar 11, 2009 at 1:28 PM, Jennifer Adams>wrote:
>
> Try changing your if statement to:
> if (rainlow <=aa & aa> --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 t1=1
> while(t1 'set t 't1
> z1=1
>
> while(z1 '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
_________________________________________________________________
Windows Live™: Life without walls.
http://windowslive.com/explore?ocid=TXT_TAGLM_WL_allup_1a_explore_032009



More information about the gradsusr mailing list