<div dir="ltr">Aaron,<div>I had a look through your script.  Here are my observations and suggestions.</div><div><br></div><div>-Grads does not have an intrinsic fprintf function.  There are user-defined scripts that use that function, but what you should use for string formatting in a grads script is math_format.  See <a href="http://www.iges.org/grads/gadoc/mathfunctions.html">this page on grads script math functions</a> for a list of more and how to use them.</div>
<div>-You have some seemingly superfluous single quotes running around in your code.  Perhaps this is related to different versions of Grads (for example, if you are running OpenGrads instead of the regular version), but you might want to check that.  For example (including a snippet of your code)</div>
<div><br></div><div><div>(line 1) init = &#39;&#39;runhr&#39;&#39;Z26DEC2013</div><div>fhr = 0</div><div>path = &#39;graphix/gem/25km/&#39;</div><div>sysdate2 = 20131226</div><div><br></div><div>&#39;reinit&#39;</div><div>
<br></div><div>incr=3</div><div>START=0</div><div>END=80</div><div>(line 2) i=&#39;&#39;START&#39;&#39;</div><div><br></div><div>(line 3) while(&#39;i&#39; &lt;= &#39;END&#39;)</div></div><div><br></div><div>In (what I&#39;ve marked as) line 1, I&#39;m not sure why you have quotes surrounding runhr.  All that seems to be doing is surrounding the string runhr with empty strings.  Also, I think you need to include the Z26DEC2013 part in quotes to define it as a string.  I&#39;m not sure how Grads will interpret it if you attempt to set init as a number of some kind.  As a check, you can include the line &quot;say init&quot; after you define init to have grads spit out the value of the variable to the window.  In line 2, it seems you&#39;re setting the variable i as the string &quot;START&quot;.  Since you have previously set START to the number 0, I think you will want to remove those quotes so that i is properly set.  In line 3, you have placed quotes around i and END in your while statement.  Remove those.  You would only use quotes to set off lines that you would input to the command prompt.  If it belongs internally to the Grads script code (like the while loop is) you don&#39;t need to set it off with quotes.</div>
<div><br></div><div>As far as setting your forecast hour goes, I would imagine the range of possible forecast hours follows a regular pattern that you could either set in an array or set using math.  For example, if your model output is every three hours, then you could just do</div>
<div><br></div><div>while (i &lt; END)</div><div> fcsthr = (i-1)*3</div><div><br></div><div>....</div><div><br></div><div> i = i + 1</div><div>endwhile</div><div><br></div><div>Jeff Duda</div></div><div class="gmail_extra">
<br><br><div class="gmail_quote">On Thu, Dec 26, 2013 at 10:57 PM, Perry, Aaron @ LSC <span dir="ltr">&lt;<a href="mailto:Aaron.Perry@lsc.vsc.edu" target="_blank">Aaron.Perry@lsc.vsc.edu</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">





<div>
<div style="direction:ltr;font-size:10pt;font-family:Tahoma">Good Evening All,<br>
<br>
I am trying to implement a while loop that will automatically insert each forecast hour (ex. 000, 003, 006, etc) of many control files for a weather model directly into the &#39;open .ctl&#39; line.<br>
<div><br>
The reason for this is because I have 10+ control files that I&#39;d like to run sequentially without having to create 10 different GrADS scripts to process each individual control file.<br>
<br>
What I have in place now does not return any errors within GrADS but, it doesn&#39;t process anything and the screen stays black. Clearly, I&#39;m doing something wrong...<br>
<br>
In UNIX, you can simply use printf &quot;%0*d\n&quot; to accomplish three leading zeros. I&#39;ve tried modifying this process by putting a &quot;!&quot; in front of printf to run the process outside of GrADS but, this doesn&#39;t seem to be working...<br>

<br>
I&#39;ve attached the &quot;working&quot; script to this email in hopes that someone who is more GrADS-savy than me can take a look at the coding and potentially figure out this issue for me.<br>
<br>
<br>
<div style="font-family:Tahoma;font-size:13px">
<div style="font-family:Tahoma;font-size:13px">
<div style="font-family:Tahoma;font-size:13px">
<div style="font-family:Tahoma;font-size:13px">
<div style="font-family:Tahoma;font-size:13px">
<div style="font-family:Tahoma;font-size:13px"><font size="3"><font face="Arial"><font face="Tahoma"><font>Onward and Upward,<br>
<br>
</font>Aaron Perry<br>
</font><font size="3"><font size="3"><font face="Tahoma">Boston, MA<br>
Mobile: 617-780-4312</font><br>
</font></font></font></font></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>

<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" target="_blank">http://gradsusr.org/mailman/listinfo/gradsusr</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br>Jeff Duda<br>Graduate research assistant<br>University of Oklahoma School of Meteorology<br>Center for Analysis and Prediction of Storms<br>
</div>