[gradsusr] [EXTERNAL] Re: shell command within grads script

Blankenship, Clay B. (MSFC-ST11)[USRA] clay.blankenship at nasa.gov
Tue Oct 20 11:59:56 EDT 2020


Muthu,
The syntax of the linux date command you are looking for is

date -d “now -3 days” +%d%b%Y

You can also do things like
date -d “14:52 3/26/2019 +1 day -3 hours”  (I think I got that right)
or
date -d “$MYTIME -3 days”

I like to also use -u (UTC time).  If not, you can sometimes get unexpected results if there is a daylight saving time shift.

Clay


From: gradsusr <gradsusr-bounces at gradsusr.org> On Behalf Of Muthuvel Chelliah - NOAA Federal
Sent: Monday, October 19, 2020 4:26 PM
To: GrADS Users Forum <gradsusr at gradsusr.org>; Muthuvel Chelliah - NOAA Federal <muthuvel.chelliah at noaa.gov>
Subject: [EXTERNAL] Re: [gradsusr] shell command within grads script

Semyon, Jeff,

Thanks for the replies.

a) I know that the date command with the options I had asked, will give the
result at the grads command line with a ! before that command.

b) I also know the second round about way my manipulating the output
from the q time output (but how to do few days ago?).

I was only curious if there was a way from a) above, of possibly storing
that output in a variable as part of a grads script variable itself.
I guess, it is difficult, and not doable!!

Thanks again
Muthu

------------------------------------------------
Dr. Muthuvel Chelliah, eMail: Muthuvel.Chelliah at noaa.gov<mailto:Muthuvel.Chelliah at noaa.gov>
Rm. 3008, Climate Prediction Center, Ph: (301) 683-3393
NCEP/NWS/NOAA/U.S.Dept.of Commerce,
5830, University Research Court, NCWCP,
College Park, MD 20740


On Mon, Oct 19, 2020 at 4:54 PM Jeff Duda <jeffduda319 at gmail.com<mailto:jeffduda319 at gmail.com>> wrote:
You can try prompting the linux command with "!" and hopefully the script recognizes the result and stores it properly.

I see that you're attempting to do something that would require lots of code in a grads script, but hopefully you know that you can query the valid time of data using 'q time' and parse the data using the 'sublin()', 'subwrd()', and 'substr()' functions internal to GrADS' scripting language.

Jeff Duda

On Mon, Oct 19, 2020 at 1:56 PM Muthuvel Chelliah - NOAA Federal <muthuvel.chelliah at noaa.gov<mailto:muthuvel.chelliah at noaa.gov>> wrote:
Hello folks,

How can I set the result of the following linux shell command
to a variable (time_var) within a Cola grads script? which can be assigned
to set time command, via 'set time 'time_var

date -d "3 days ago" +%d%b%Y

Thanks
Muthu
------------------------------------------------
Dr. Muthuvel Chelliah, eMail: Muthuvel.Chelliah at noaa.gov<mailto:Muthuvel.Chelliah at noaa.gov>
Rm. 3008, Climate Prediction Center, Ph: (301) 683-3393
NCEP/NWS/NOAA/U.S.Dept.of Commerce,
5830, University Research Court, NCWCP,
College Park, MD 20740
_______________________________________________
gradsusr mailing list
gradsusr at gradsusr.org<mailto:gradsusr at gradsusr.org>
http://gradsusr.org/mailman/listinfo/gradsusr<https://urldefense.proofpoint.com/v2/url?u=http-3A__gradsusr.org_mailman_listinfo_gradsusr&d=DwMFaQ&c=ApwzowJNAKKw3xye91w7BE1XMRKi2LN9kiMk5Csz9Zk&r=MCVOJjv6bEVvd32JcHviwqWEO1jfc2ilpIJQx1HJAL8&m=CSXUJVKg7cXRszgP6eeZxH3PPppu4VYEfemzbEdDmzQ&s=ZjS3R7TZ-YNlDQ7tfdIuWhsFdSjSAUb1yUy80lew300&e=>


--
Jeff Duda, Research Scientist
University of Colorado Boulder
Cooperative Institute for Research in Environmental Sciences
NOAA/OAR/ESRL/Global Systems Laboratory
Boulder, CO
_______________________________________________
gradsusr mailing list
gradsusr at gradsusr.org<mailto:gradsusr at gradsusr.org>
http://gradsusr.org/mailman/listinfo/gradsusr<https://urldefense.proofpoint.com/v2/url?u=http-3A__gradsusr.org_mailman_listinfo_gradsusr&d=DwMFaQ&c=ApwzowJNAKKw3xye91w7BE1XMRKi2LN9kiMk5Csz9Zk&r=MCVOJjv6bEVvd32JcHviwqWEO1jfc2ilpIJQx1HJAL8&m=CSXUJVKg7cXRszgP6eeZxH3PPppu4VYEfemzbEdDmzQ&s=ZjS3R7TZ-YNlDQ7tfdIuWhsFdSjSAUb1yUy80lew300&e=>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://gradsusr.org/pipermail/gradsusr/attachments/20201020/01b5aa75/attachment-0001.html>


More information about the gradsusr mailing list