<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Aaron:<br>
<br>
I'm not quite sure what you want fcsthr1 to look like. "incr" is a
constant value of 3, and "i" runs from 0 to 80 incremented by 3. Do
you want fcsthr1 to be 3000, 3003, 3006, 3009, 3012, ..., 3080? If
so, you can do this via if/then, e.g., (echoing Jeff's reply about
the unnecessary quotes, below all quotes are single):<br>
<br>
incr=3<br>
START=0<br>
END=80<br>
i=START<br>
<br>
while(i <= END)<br>
fcsthr1 = incr''i<br>
if ( i < 100 )<br>
fcsthr1 = incr'0'i<br>
endif<br>
if ( i < 10 )<br>
fcsthr1 = incr'00'i<br>
endif<br>
i = i + 3<br>
say fcsthr1<br>
endwhile<br>
<br>
<br>
<br>
<div class="moz-cite-prefix">On 12/27/13 7:02 AM, Jeff Duda wrote:<br>
</div>
<blockquote
cite="mid:CAAig09D2mnoFtmf2RjwgfC5mWAPuCDegr=hcb_pOq1zzO=EwJA@mail.gmail.com"
type="cite">
<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 moz-do-not-send="true"
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 = ''runhr''Z26DEC2013</div>
<div>fhr = 0</div>
<div>path = 'graphix/gem/25km/'</div>
<div>sysdate2 = 20131226</div>
<div><br>
</div>
<div>'reinit'</div>
<div>
<br>
</div>
<div>incr=3</div>
<div>START=0</div>
<div>END=80</div>
<div>(line 2) i=''START''</div>
<div><br>
</div>
<div>(line 3) while('i' <= 'END')</div>
</div>
<div><br>
</div>
<div>In (what I've marked as) line 1, I'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'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 "say init" after you define
init to have grads spit out the value of the variable to the
window. In line 2, it seems you're setting the variable i as
the string "START". 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'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 < 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"><<a
moz-do-not-send="true"
href="mailto:Aaron.Perry@lsc.vsc.edu" target="_blank">Aaron.Perry@lsc.vsc.edu</a>></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 'open .ctl' line.<br>
<div><br>
The reason for this is because I have 10+ control
files that I'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't process anything and the
screen stays black. Clearly, I'm doing something
wrong...<br>
<br>
In UNIX, you can simply use printf "%0*d\n" to
accomplish three leading zeros. I've tried modifying
this process by putting a "!" in front of printf to
run the process outside of GrADS but, this doesn't
seem to be working...<br>
<br>
I've attached the "working" 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 moz-do-not-send="true"
href="mailto:gradsusr@gradsusr.org">gradsusr@gradsusr.org</a><br>
<a moz-do-not-send="true"
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>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
gradsusr mailing list
<a class="moz-txt-link-abbreviated" href="mailto:gradsusr@gradsusr.org">gradsusr@gradsusr.org</a>
<a class="moz-txt-link-freetext" href="http://gradsusr.org/mailman/listinfo/gradsusr">http://gradsusr.org/mailman/listinfo/gradsusr</a>
</pre>
</blockquote>
<br>
</body>
</html>