<!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 
style="WORD-WRAP: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space">
<DIV dir=ltr align=left><SPAN class=358373816-08032011><FONT color=#0000ff 
size=2 face=Arial>on a unix box the following&nbsp;should pick the current 
time:</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=358373816-08032011><FONT color=#0000ff 
size=2 face=Arial></FONT></SPAN>&nbsp;</DIV>
<DIV dir=ltr align=left><SPAN class=358373816-08032011><FONT color=#0000ff 
size=2 face=Arial>date +%m'z'%d%b%Y<BR></FONT></SPAN></DIV>
<DIV>&nbsp;</DIV><!-- Converted from text/plain format -->
<P><FONT size=2>--<BR><BR>Bernd Becker&nbsp;&nbsp; Climate Impacts Product 
Development<BR>Met Office Hadley Centre&nbsp;&nbsp;&nbsp; FitzRoy Road&nbsp; 
Exeter&nbsp;&nbsp; Devon EX1 3PB&nbsp; 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>&nbsp;</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>Jennifer 
Adams<BR><B>Sent:</B> 08 March 2011 16:19<BR><B>To:</B> GrADS Users 
Forum<BR><B>Subject:</B> Re: [gradsusr] Automation my (ctl) descriptor 
file<BR></FONT><BR></DIV>
<DIV></DIV>
<DIV>Below is a C program (sdate.c) we use in our operations to print out the 
current date string in GrADS format -- e.g., 08mar2001. We have a descriptor 
file template with "XXX" in place of the date, then in a shell script, we invoke 
sdate, then use 'sed' to change the XXX to the current date. Like 
this:&nbsp;</DIV>
<DIV><BR></DIV>
<DIV>
<DIV>#!/bin/sh</DIV></DIV>
<DIV>
<DIV>gdate=`/your_path_to/sdate`</DIV></DIV>
<DIV>...</DIV>
<DIV>
<DIV>sed s/XXX/$gdate/ /your_path_to/ctl.template &gt; ./tmp</DIV></DIV>
<DIV>...&nbsp;</DIV>
<DIV><BR></DIV>
<DIV>Hope that helps!</DIV>
<DIV>--Jennifer</DIV>
<DIV><BR></DIV>
<DIV><BR></DIV>
<DIV><BR></DIV>
<DIV><BR></DIV>
<DIV><FONT class=Apple-style-span size=3 face=Courier><SPAN 
style="FONT-SIZE: 12px" class=Apple-style-span>#include 
&lt;stdio.h&gt;</SPAN></FONT></DIV>
<DIV><FONT class=Apple-style-span size=3 face=Courier><SPAN 
style="FONT-SIZE: 12px" class=Apple-style-span>#include 
&lt;string.h&gt;</SPAN></FONT></DIV>
<DIV><FONT class=Apple-style-span size=3 face=Courier><SPAN 
style="FONT-SIZE: 12px" class=Apple-style-span>#include 
&lt;time.h&gt;</SPAN></FONT></DIV>
<DIV><FONT class=Apple-style-span size=3 face=Courier><SPAN 
style="FONT-SIZE: 12px" class=Apple-style-span><BR></SPAN></FONT></DIV>
<DIV><FONT class=Apple-style-span size=3 face=Courier><SPAN 
style="FONT-SIZE: 12px" class=Apple-style-span>char *cmons[12] = 
{"jan","feb","mar","apr","may","jun","jul","aug",</SPAN></FONT><SPAN 
style="FONT-FAMILY: Courier; FONT-SIZE: 12px" 
class=Apple-style-span>"sep","oct","nov","dec"};</SPAN></DIV>
<DIV><FONT class=Apple-style-span size=3 face=Courier><SPAN 
style="FONT-SIZE: 12px" class=Apple-style-span><BR></SPAN></FONT></DIV>
<DIV><FONT class=Apple-style-span size=3 face=Courier><SPAN 
style="FONT-SIZE: 12px" class=Apple-style-span>main () {</SPAN></FONT></DIV>
<DIV><FONT class=Apple-style-span size=3 face=Courier><SPAN 
style="FONT-SIZE: 12px" class=Apple-style-span>time_t *tsec;</SPAN></FONT></DIV>
<DIV><FONT class=Apple-style-span size=3 face=Courier><SPAN 
style="FONT-SIZE: 12px" class=Apple-style-span>time_t tt;</SPAN></FONT></DIV>
<DIV><FONT class=Apple-style-span size=3 face=Courier><SPAN 
style="FONT-SIZE: 12px" class=Apple-style-span>struct tm 
*tm;</SPAN></FONT></DIV>
<DIV><FONT class=Apple-style-span size=3 face=Courier><SPAN 
style="FONT-SIZE: 12px" class=Apple-style-span>char 
sname[50];</SPAN></FONT></DIV>
<DIV><FONT class=Apple-style-span size=3 face=Courier><SPAN 
style="FONT-SIZE: 12px" class=Apple-style-span>int rc;</SPAN></FONT></DIV>
<DIV><FONT class=Apple-style-span size=3 face=Courier><SPAN 
style="FONT-SIZE: 12px" class=Apple-style-span></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT class=Apple-style-span size=3 face=Courier><SPAN 
style="FONT-SIZE: 12px" class=Apple-style-span>&nbsp;&nbsp;tt = time((long 
*)0);</SPAN></FONT></DIV>
<DIV><FONT class=Apple-style-span size=3 face=Courier><SPAN 
style="FONT-SIZE: 12px" class=Apple-style-span>&nbsp;&nbsp;tsec = 
&amp;tt;</SPAN></FONT></DIV>
<DIV><FONT class=Apple-style-span size=3 face=Courier><SPAN 
style="FONT-SIZE: 12px" class=Apple-style-span>&nbsp;&nbsp;tm = 
gmtime(tsec);</SPAN></FONT></DIV>
<DIV><FONT class=Apple-style-span size=3 face=Courier><SPAN 
style="FONT-SIZE: 12px" class=Apple-style-span>&nbsp;&nbsp;if 
(tm-&gt;tm_year&gt;99) tm-&gt;tm_year = tm-&gt;tm_year-100;</SPAN></FONT></DIV>
<DIV><FONT class=Apple-style-span size=3 face=Courier><SPAN 
style="FONT-SIZE: 12px" class=Apple-style-span>&nbsp;&nbsp;sprintf 
(sname,"%02i%s%4i",</SPAN></FONT><SPAN 
style="FONT-FAMILY: Courier; FONT-SIZE: 12px" 
class=Apple-style-span>tm-&gt;tm_mday,cmons[tm-&gt;tm_mon],tm-&gt;tm_year+2000);</SPAN></DIV>
<DIV><FONT class=Apple-style-span size=3 face=Courier><SPAN 
style="FONT-SIZE: 12px" class=Apple-style-span>&nbsp;&nbsp;printf 
("%s\n",sname);</SPAN></FONT></DIV>
<DIV><FONT class=Apple-style-span size=3 face=Courier><SPAN 
style="FONT-SIZE: 12px" class=Apple-style-span>}</SPAN></FONT></DIV>
<DIV><BR></DIV>
<DIV><BR></DIV>
<DIV><BR></DIV>
<DIV><BR></DIV>
<DIV>
<DIV>On Mar 8, 2011, at 10:58 AM, Reynaldo Capia wrote:</DIV><BR 
class=Apple-interchange-newline>
<BLOCKQUOTE type="cite">
  <DIV style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt" class=hmmessage>Hi 
  everyone;<BR><BR>I need to automate my tasks of GrADS;<BR><BR>I have 
  everything advanced, and I just want the following:<BR><BR>=&gt; How can I do, 
  to update the date every day of my descriptor 
  file(ctl)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; in this line (31 linear<SPAN 
  class=Apple-converted-space>&nbsp;</SPAN><B>00z08MAR2011</B><SPAN 
  class=Apple-converted-space>&nbsp;</SPAN>TDEF 06hr)?.<BR><BR>I accept 
  suggestions.<BR>Thanks.<BR>_______________________________________________<BR>gradsusr 
  mailing list<BR><A 
  href="mailto:gradsusr@gradsusr.org">gradsusr@gradsusr.org</A><BR><A 
  href="http://gradsusr.org/mailman/listinfo/gradsusr">http://gradsusr.org/mailman/listinfo/gradsusr</A><BR></DIV></BLOCKQUOTE></DIV><BR>
<DIV apple-content-edited="true"><SPAN 
style="WIDOWS: 2; TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-SPACING: 0px 0px; BORDER-COLLAPSE: separate; FONT: 12px Helvetica; WHITE-SPACE: normal; ORPHANS: 2; LETTER-SPACING: normal; COLOR: rgb(0,0,0); WORD-SPACING: 0px; -khtml-text-decorations-in-effect: none; -apple-text-size-adjust: auto" 
class=Apple-style-span>
<DIV 
style="WORD-WRAP: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space"><SPAN 
style="WIDOWS: 2; TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-SPACING: 0px 0px; BORDER-COLLAPSE: separate; FONT: 12px Helvetica; WHITE-SPACE: normal; ORPHANS: 2; LETTER-SPACING: normal; COLOR: rgb(0,0,0); WORD-SPACING: 0px; -khtml-text-decorations-in-effect: none; -apple-text-size-adjust: auto" 
class=Apple-style-span><SPAN 
style="WIDOWS: 2; TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-SPACING: 0px 0px; BORDER-COLLAPSE: separate; FONT: 12px Helvetica; WHITE-SPACE: normal; ORPHANS: 2; LETTER-SPACING: normal; COLOR: rgb(0,0,0); WORD-SPACING: 0px; -khtml-text-decorations-in-effect: none; -apple-text-size-adjust: auto" 
class=Apple-style-span>
<DIV>--</DIV>
<DIV>Jennifer M. Adams</DIV>
<DIV>IGES/COLA</DIV>
<DIV>4041 Powder Mill Road, Suite 302</DIV>
<DIV>Calverton, MD 20705</DIV>
<DIV><A href="mailto:jma@cola.iges.org">jma@cola.iges.org</A></DIV>
<DIV><BR class=khtml-block-placeholder></DIV><BR 
class=Apple-interchange-newline></SPAN></SPAN></DIV></SPAN></DIV><BR></BODY></HTML>