<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style id="owaParaStyle" type="text/css">
<!--
p
        {margin-top:0;
        margin-bottom:0}
p
        {margin-top:0;
        margin-bottom:0}
-->
P {margin-top:0;margin-bottom:0;}</style>
</head>
<body ocsi="0" fpstyle="1" bgcolor="#FFFFFF">
<div style="direction: ltr;font-family: Tahoma;color: #000000;font-size: 10pt;">I actually solved this issue on my own...<br>
<br>
Just needed to relocate 'reinit' to directly above the open ctl line.<br>
<br>
Thank you everyone for your patience and help!<br>
<div><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">
<div style="font-family:Tahoma; font-size:13px"><font size="3"><font face="Arial"><font size="2" face="Tahoma"><font size="2"><br>
Onward and Upward,<br>
<br>
</font>Aaron D. Perry<br>
</font><font size="3"><font size="3"><font size="2" face="Tahoma">Boston, MA<br>
Lyndon State College '15<br>
Twitter: <a href="https://twitter.com/AaronPerryLSC">@AaronPerryLSC</a><br>
</font></font></font></font></font><font size="3"><font face="Arial"><font size="3"><font size="3"><font size="2" face="Tahoma">Mobile: 617-780-4312</font></font></font></font></font></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div style="font-family: Times New Roman; color: #000000; font-size: 16px">
<hr tabindex="-1">
<div style="direction: ltr;" id="divRpF922491"><font size="2" color="#000000" face="Tahoma"><b>From:</b> gradsusr-bounces@gradsusr.org [gradsusr-bounces@gradsusr.org] on behalf of Perry, Aaron @ LSC [Aaron.Perry@lsc.vsc.edu]<br>
<b>Sent:</b> Friday, December 27, 2013 4:06 PM<br>
<b>To:</b> GrADS Users Forum<br>
<b>Subject:</b> Re: [gradsusr] Using A While Loop To Sequentially Loop Through Many Hours/Control Files<br>
</font><br>
</div>
<div></div>
<div>
<div style="direction:ltr; font-family:Tahoma; color:#000000; font-size:10pt">
<div style="direction:ltr; font-family:Tahoma; color:#000000; font-size:10pt">Hi James,<br>
<br>
Thanks for your reply!<br>
<br>
I feel like this step is exactly what I need, except you're right, I don't need the "incr = 3" in that script at all.<br>
<br>
To clear the air, I have a bunch of control files that are called 000.ctl, 003.ctl, 006.ctl, 012.ctl...240.ctl and I'm trying to set some sort of loop that will automate the process of opening each control file without having to create 80 different scripts
for each individual control file. I've successfully gotten the loop to work but, a new issues has now come up..<br>
<br>
When I try to create the graphic using gxprint, it creates the first graphic for hour 000 and then uses that for each graphic/hour afterwards.<br>
<br>
I've attached the updated script to this email.<br>
<br>
I feel like I'm so close!<br>
<br>
<br>
<div><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">
<div style="font-family:Tahoma; font-size:13px"><font size="3"><font face="Arial"><font size="2" face="Tahoma"><font size="2">Onward and Upward,<br>
<br>
</font>Aaron D. Perry<br>
</font><font size="3"><font size="3"><font size="2" face="Tahoma">Boston, MA<br>
Lyndon State College '15<br>
Twitter: <a href="https://twitter.com/AaronPerryLSC" target="_blank">@AaronPerryLSC</a><br>
</font></font></font></font></font><font size="3"><font face="Arial"><font size="3"><font size="3"><font size="2" face="Tahoma">Mobile: 617-780-4312</font></font></font></font></font></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div style="font-family:Times New Roman; color:#000000; font-size:16px">
<hr tabindex="-1">
<div id="divRpF541957" style="direction:ltr"><font size="2" color="#000000" face="Tahoma"><b>From:</b> gradsusr-bounces@gradsusr.org [gradsusr-bounces@gradsusr.org] on behalf of James T. Potemra [jimp@hawaii.edu]<br>
<b>Sent:</b> Friday, December 27, 2013 3:03 PM<br>
<b>To:</b> GrADS Users Forum<br>
<b>Subject:</b> Re: [gradsusr] Using A While Loop To Sequentially Loop Through Many Hours/Control Files<br>
</font><br>
</div>
<div></div>
<div>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 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 href="http://www.iges.org/grads/gadoc/mathfunctions.html" target="_blank">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 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 href="mailto:gradsusr@gradsusr.org" target="_blank">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>
<br>
<fieldset class="mimeAttachmentHeader" target="_blank"></fieldset> <br>
<pre>_______________________________________________
gradsusr mailing list
<a class="moz-txt-link-abbreviated" href="mailto:gradsusr@gradsusr.org" target="_blank">gradsusr@gradsusr.org</a>
<a class="moz-txt-link-freetext" href="http://gradsusr.org/mailman/listinfo/gradsusr" target="_blank">http://gradsusr.org/mailman/listinfo/gradsusr</a>
</pre>
</blockquote>
<br>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>