<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=us-ascii" http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 8.00.6001.19019"></HEAD>
<BODY>
<DIV dir=ltr align=left><SPAN class=281175614-18032011><FONT color=#0000ff
size=2 face=Arial>Thank you , Arlindo!</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=281175614-18032011><FONT color=#0000ff
size=2 face=Arial></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=281175614-18032011><FONT color=#0000ff
size=2 face=Arial>The "@" to expand the shell environment variables is exactly
what cures </FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=281175614-18032011><FONT color=#0000ff
size=2 face=Arial>my problem.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=281175614-18032011><FONT color=#0000ff
size=2 face=Arial></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=281175614-18032011><FONT color=#0000ff
size=2 face=Arial>I needed to tag temporary files to run grads scripts in
parallel. </FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=281175614-18032011><FONT color=#0000ff
size=2 face=Arial>Tagging these files with the current $$ is a viable
solution.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=281175614-18032011><FONT color=#0000ff
size=2 face=Arial></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=281175614-18032011><FONT color=#0000ff
size=2 face=Arial>I want to use the mighty power of shell command date to
reformat </FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=281175614-18032011><FONT color=#0000ff
size=2 face=Arial>current date settings inside grads.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=281175614-18032011><FONT color=#0000ff
size=2 face=Arial></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=281175614-18032011><FONT color=#0000ff
size=2 face=Arial>fxdate is some date in yyyymmdd. To write the tdef flag in a
temporary grads.ctl file,</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=281175614-18032011><FONT color=#0000ff
size=2 face=Arial>the 3 character date is required:</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=281175614-18032011><FONT color=#0000ff
size=2 face=Arial></FONT></SPAN> </DIV>
<DIV><FONT color=#0000ff size=2 face=Arial>* Arlindo's suggestion<BR>'@
!/opt/freeware/bin/date -d 'fxdate' +%b > ./erp2$$'<BR>filename =
subwrd(result,6)</FONT></DIV>
<DIV> </DIV>
<DIV><FONT color=#0000ff size=2
face=Arial>record2=read(filename)<BR>mon=sublin(record2,2)</FONT></DIV>
<DIV> </DIV>
<DIV><FONT color=#0000ff size=2 face=Arial><SPAN class=281175614-18032011>and
hey presto, mon holds the 3 character month from fxdate. </SPAN></FONT></DIV>
<DIV><FONT color=#0000ff size=2 face=Arial><SPAN
class=281175614-18032011></SPAN></FONT> </DIV>
<DIV><FONT color=#0000ff size=2 face=Arial><SPAN class=281175614-18032011>Many
thanks,</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff size=2 face=Arial><SPAN class=281175614-18032011>enjoy
the weekend.</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff size=2 face=Arial><SPAN
class=281175614-18032011></SPAN></FONT> </DIV>
<DIV><FONT color=#0000ff size=2 face=Arial><SPAN
class=281175614-18032011>Bernd.</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff size=2 face=Arial><SPAN
class=281175614-18032011></SPAN></FONT> </DIV><!-- Converted from text/plain format -->
<P><FONT size=2>--<BR>Bernd Becker Climate Impacts Product
Development<BR>Met Office Hadley Centre FitzRoy Road
Exeter Devon EX1 3PB United Kingdom<BR>Tel.: +44 (0) 1392
884511 Fax: +44 (0)870 900 5050<BR>E-mail:bernd.becker@metoffice.gov.uk - <A
href="http://www.metoffice.gov.uk/research/our-scientists/seasonal-to-decadal/bernd-becker">http://www.metoffice.gov.uk/research/our-scientists/seasonal-to-decadal/bernd-becker</A><BR><BR></FONT></P>
<DIV> </DIV><BR>
<DIV dir=ltr lang=en-us class=OutlookMessageHeader align=left>
<HR tabIndex=-1>
<FONT size=2 face=Tahoma><B>From:</B> gradsusr-bounces@gradsusr.org
[mailto:gradsusr-bounces@gradsusr.org] <B>On Behalf Of </B>Arlindo da
Silva<BR><B>Sent:</B> 18 March 2011 00:41<BR><B>To:</B> GrADS Users
Forum<BR><B>Subject:</B> Re: [gradsusr] get output from shell
command<BR></FONT><BR></DIV>
<DIV></DIV>On Thu, Mar 17, 2011 at 5:20 AM, Becker, Bernd <SPAN dir=ltr><<A
href="mailto:bernd.becker@metoffice.gov.uk">bernd.becker@metoffice.gov.uk</A>></SPAN>
wrote:<BR>
<DIV class=gmail_quote>
<BLOCKQUOTE
style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex"
class=gmail_quote><BR><BR>Chuck,<BR>nice solution,<BR>but if you have 17 grads
shells running in parallel, eventually<BR>one of them may overwrite
sysdate.dat and that would be bad.<BR>
<DIV class=im><BR></DIV></BLOCKQUOTE>
<DIV><BR></DIV>
<DIV>If you are using an opengrads release you can use the environment expansion
capability, and the the process ID variable $$, to create unique (per grads
instance) temporay files. For this particular example, try:</DIV>
<DIV><BR></DIV>
<DIV><SPAN
style="BORDER-COLLAPSE: collapse; FONT-FAMILY: arial, sans-serif; FONT-SIZE: 13px"
class=Apple-style-span><BR>'@ !date > sysdate.dat.$$'<BR>filename =
subwrd(result,3)</SPAN></DIV>
<DIV><SPAN
style="BORDER-COLLAPSE: collapse; FONT-FAMILY: arial, sans-serif; FONT-SIZE: 13px"
class=Apple-style-span> d = read(filename)<BR> d1 =
sublin(d,2)<BR> say d1<BR></SPAN></DIV>
<DIV><SPAN
style="BORDER-COLLAPSE: collapse; FONT-FAMILY: arial, sans-serif; FONT-SIZE: 13px"
class=Apple-style-span><BR></SPAN></DIV>
<DIV>The Env extension adds a lot of convenient environment variable
functionality to GrADS. See this for more information:</DIV>
<DIV><BR></DIV>
<DIV> <A
href="http://opengrads.org/doc/udxt/env/">http://opengrads.org/doc/udxt/env/</A></DIV>
<DIV><BR></DIV>
<DIV> Arlindo</DIV>
<DIV><BR></DIV></DIV>-- <BR>Arlindo da Silva<BR><A
href="mailto:dasilva@alum.mit.edu">dasilva@alum.mit.edu</A><BR></BODY></HTML>