If/else statements dependent upon time

Charles Seman Charles.Seman at NOAA.GOV
Thu Dec 6 16:25:54 EST 2007


Jack,

Please find attached script "month.gs" and script function
"get_month.gsf" (called by "month.gs", enabled by "month.gs" statement:
rc = gsfallow("on"); see http://grads.iges.org/grads/gadoc/gsf.html
Running "month.gs" gives following output (some error checks were also
run, not shown here):
ga-> month
Time values set: 2005:1:1:0 2005:1:1:0
2005:1:1:0
month is Jan

"get_month.gsf" returns a character month name, given a "date" which has
been assigned after doing a 'set t ...' (in above example, 'set t 1')
You could modify function "get_month.gsf" to return the numerical month
value if desired; to do this, remove statements that assign character
string names to "month" in "get_month.gsf" (in this case, you could also
consolidate the "if" checks like: if( month = 1 | month = 2 | ... |
month = 12 )...)

I hope this helps,
Chuck

Jack wrote:
> Hi all,
>
> I am new to GrADS, so maybe that's why I haven't found this on my own yet,
> but here's what I'm trying to do:
>
> I want to do a calculation based on an 850 temp map, to forecast surface
> temps, that is dependent on the month of the year. Each month has a slightly
> different formula than the prior month. Instead of changing the formula in
> the script every month, I wanted to use "if/else" statements, where the "if"
> is dependent on the month.
>
> I guess my biggest issue now, is getting time identified and used so that it
> can be executed by the proper formula (of which there should be 12 in there).
>
> Any help would be greatly appreciated.
>
> Thanks!
>
> Jack
>

--

Please note that Charles.Seman at noaa.gov should be considered my NOAA
email address, not cjs at gfdl.noaa.gov.

********************************************************************
 Charles Seman                                Charles.Seman at noaa.gov
 U.S. Department of Commerce / NOAA / OAR
 Geophysical Fluid Dynamics Laboratory         voice: (609) 452-6547
 201 Forrestal Road                              fax: (609) 987-5063
 Princeton, NJ  08540-6649            http://www.gfdl.noaa.gov/~cjs/
********************************************************************

"The contents of this message are mine personally and do not reflect
any position of the Government or NOAA."

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: month.gs
Url: http://gradsusr.org/pipermail/gradsusr/attachments/20071206/94c56e8d/attachment.pl 
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: get_month.gsf
Url: http://gradsusr.org/pipermail/gradsusr/attachments/20071206/94c56e8d/attachment-0001.pl 


More information about the gradsusr mailing list