if/or statement in GrADS script
Eric Altshuler
ela at COLA.IGES.ORG
Wed Oct 17 15:55:17 EDT 2007
Dan,
This should work:
if (subwrd(hh,1)='12' | subwrd(hh,1)='24' | subwrd(hh,1)='36')
...
...
endif
Put the "or" (|) constructs inside the "if" statement. You can do this with "and" (&) also.
Best regards,
Eric L. Altshuler
Assistant Research Scientist
Center for Ocean-Land-Atmosphere Studies
4041 Powder Mill Road, Suite 302
Calverton, MD 20705-3106
USA
E-mail: ela at cola.iges.org
Phone: (301) 902-1257
Fax: (301) 595-9793
----- Original Message -----
From: "Dan Leins" <theedge981 at GMAIL.COM>
To: GRADSUSR at LIST.CINECA.IT
Sent: Wednesday, October 17, 2007 3:46:16 PM (GMT-0500) America/New_York
Subject: if/or statement in GrADS script
All,
I'm working on a GrADS script in which I will pass a forecast hour as an argument. I have a small section of the script that I would only like to execute when I pass forecast hours 12,24,or 36. So far I've constructed the statement to read as follows:
if (subwrd(hh,1)='12')
blah blah blah
endif
This is all fine and good, but I'd like to re-use this same section of code when I pass 24 or 36 as an argument. I was wondering if the if/or functionality existed in GrADS? I was thinking something along the lines of
if (subwrd(hh,1)='12') || if (subwrd(hh,1)='24') || if (subwrd(hh,1)='36')
but that didn't work. I really don't want to copy and paste the code elsewhere in the script as it's a pretty lengthy section.
Is there any way I can accomplish this?
Thanks!
Dan
More information about the gradsusr
mailing list