<html dir="ltr"><head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<meta name="GENERATOR" content="MSHTML 8.00.7600.16700">
<style id="owaTempEditStyle"></style><style title="owaParaStyle"><!--P {
        MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px
}
--></style>
</head>
<body ocsi="x">
<div style="FONT-FAMILY: Tahoma; DIRECTION: ltr; COLOR: #000000; FONT-SIZE: 13px">
<div>
<p style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class="MsoNormal"><font size="3" face="Calibri">Dear all,</font></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class="MsoNormal"><font size="3" face="Calibri">Thanks for the response, but the reply has not solved my problem. Let me make my question more specific. I would like to calculate the average of the SWDOWN
(short wave radiation) over certain land type, here referring to rural land type (LU_index =not 1).</font></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class="MsoNormal"><font size="3" face="Calibri">The following is my original code.<span style="mso-spacerun: yes">
</span>First of all, I want summate all the values of SWDOWN for all the grids with LU_index!=1 and LU_index!=1, then divided by the total number of nrr.<span style="mso-spacerun: yes">
</span>tim, m and n might be larger, here for simplifying purpose, setting them for only one loop each.</font></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class="MsoNormal"><font size="3" face="Calibri">The problem is the outputs of SWDOWN.1 or SWDOWN.2 are not a single value, the program treat SWDOWN.1 as a vector, even the t, x, y (tim, m, n) are fixed to
one value. </font></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class="MsoNormal"><font size="3"><font face="Calibri">Firstly, there is an error for this sentence<span style="mso-spacerun: yes">
</span></font></font></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class="MsoNormal"><font size="3"><font face="Calibri"><span style="mso-spacerun: yes">
</span>SWDOWN_nrr1=SWDOWN_nrr1+SWDOWN.1</font></font></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class="MsoNormal"><font size="3" face="Calibri">Or I try to output SWDOWN.1 to a single value
</font></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class="MsoNormal"><font size="3"><font face="Calibri"><span style="mso-spacerun: yes">
</span>SW1=subwrd(SWDOWN.1,1)</font></font></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class="MsoNormal"><font size="3"><font face="Calibri"><span style="mso-spacerun: yes"> </span>the program treats SW1 as a string, not a value, so<span style="mso-spacerun: yes">
</span></font></font></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class="MsoNormal"><font size="3" face="Calibri">SW5=SW1+SW2<span style="mso-spacerun: yes">
</span>makes mistakes, as well as<span style="mso-spacerun: yes"> </span>SWDOWN_nrr1=SWDOWN_nrr1+'SW1'</font></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class="MsoNormal"><font size="3" face="Calibri">Possible solutions for my problems are:<span style="mso-spacerun: yes">
</span>convert the output of SWDOWN.1 to a single value, which I can use for summation.<span style="mso-spacerun: yes">
</span>SWDOWN_nrr1=SWDOWN_nrr1+SWDOWN.1; </font></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class="MsoNormal"><font size="3" face="Calibri">or convert a string to a value, which I can also use it for summation.<span style="mso-spacerun: yes">
</span>SWDOWN_nrr1=SWDOWN_nrr1+'SW1'</font></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class="MsoNormal">
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
<o:p><font size="3" face="Calibri"> </font></o:p></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class="MsoNormal"><font size="3" face="Calibri">Thank you very much!</font></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class="MsoNormal"><font size="3" face="Calibri">Qinglan Li</font></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class="MsoNormal"><o:p><font size="3" face="Calibri"> </font></o:p></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class="MsoNormal"><o:p><font size="3" face="Calibri"> </font></o:p></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class="MsoNormal"><font size="3"><font face="Calibri"><span style="mso-spacerun: yes"> </span>'reinit'</font></font></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class="MsoNormal"><font size="3" face="Calibri">'open Small_Nest3_Moisture_2000July23-27_00_UTC_2000_land_AH100.ctl'</font></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class="MsoNormal"><font size="3" face="Calibri">'open Small_Nest3_Moisture_2000July23-27_00_UTC_1980_land_AH100_changed_0.7profile.ctl'</font></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class="MsoNormal"><font size="3" face="Calibri">tim=25</font></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class="MsoNormal"><font size="3" face="Calibri">while(tim<=25)</font></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class="MsoNormal"><font size="3" face="Calibri">SWDOWN_rr1=0</font></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class="MsoNormal"><font size="3" face="Calibri">SWDOWN_rr2=0</font></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class="MsoNormal"><font size="3"><font face="Calibri"><span style="mso-spacerun: yes">
</span>'set t 'tim''</font></font></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class="MsoNormal"><font size="3" face="Calibri">nrr=0</font></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class="MsoNormal"><font size="3" face="Calibri">SWDOWN_nrr1=0</font></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class="MsoNormal"><font size="3" face="Calibri">SWDOWN_nrr2=0</font></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class="MsoNormal"><font size="3" face="Calibri">m=1</font></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class="MsoNormal"><font size="3" face="Calibri">while(m<=1)</font></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class="MsoNormal"><font size="3" face="Calibri">n=1</font></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class="MsoNormal"><font size="3" face="Calibri">while(n<=1)</font></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class="MsoNormal"><font size="3"><font face="Calibri"><span style="mso-spacerun: yes">
</span>'set x 'm''</font></font></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class="MsoNormal"><font size="3"><font face="Calibri"><span style="mso-spacerun: yes">
</span>'set y 'n''</font></font></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class="MsoNormal"><font size="3"><font face="Calibri"><span style="mso-spacerun: yes">
</span>LU1=LU_index.1</font></font></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class="MsoNormal"><font size="3"><font face="Calibri"><span style="mso-spacerun: yes">
</span>LU2=LU_index.2</font></font></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class="MsoNormal"><font size="3"><font face="Calibri"><span style="mso-spacerun: yes">
</span>SW1=subwrd(SWDOWN.1,1)</font></font></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class="MsoNormal"><font size="3"><font face="Calibri"><span style="mso-spacerun: yes">
</span>SW2=subwrd(SWDOWN.2,1)</font></font></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class="MsoNormal"><font size="3"><font face="Calibri"><span style="mso-spacerun: yes">
</span>SW5=SW1+SW2<span style="mso-spacerun: yes">
</span>********error</font></font></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class="MsoNormal"><font size="3"><font face="Calibri"><span style="mso-spacerun: yes">
</span>SW3=1.1</font></font></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class="MsoNormal"><font size="3"><font face="Calibri"><span style="mso-spacerun: yes">
</span>SW4=2.2 </font></font></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class="MsoNormal"><font size="3"><font face="Calibri"><span style="mso-spacerun: yes">
</span>if (LU1!=1 & LU2!=1)</font></font></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class="MsoNormal"><font size="3"><font face="Calibri"><span style="mso-spacerun: yes">
</span>nrr=nrr+1</font></font></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class="MsoNormal"><font size="3"><font face="Calibri"><span style="mso-spacerun: yes">
</span>SWDOWN_nrr1=SWDOWN_nrr1+'SW1'<span style="mso-spacerun: yes"> </span>
******error</font></font></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class="MsoNormal"><font size="3"><font face="Calibri"><span style="mso-spacerun: yes">
</span>SWDOWN_nrr2=SWDOWN_nrr2+'SW2'<span style="mso-spacerun: yes"> </span>
******error</font></font></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class="MsoNormal"><font size="3"><font face="Calibri"><span style="mso-spacerun: yes">
</span>endif</font></font></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class="MsoNormal"><font size="3"><font face="Calibri"><span style="mso-spacerun: yes">
</span>n=n+1</font></font></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class="MsoNormal"><font size="3" face="Calibri">endwhile</font></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class="MsoNormal"><font size="3"><font face="Calibri"><span style="mso-spacerun: yes">
</span>m=m+1</font></font></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class="MsoNormal"><font size="3" face="Calibri">endwhile</font></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class="MsoNormal"><font size="3" face="Calibri">SWDOWN_rr1=SWDOWN_nrr1/nrr</font></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class="MsoNormal"><font size="3" face="Calibri">SWDOWN_rr2=SWDOWN_nrr2/nrr</font></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class="MsoNormal"><font size="3" face="Calibri">*'d SWDOWN_rr1'</font></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class="MsoNormal"><font size="3" face="Calibri">*'d SWDOWN_rr2'</font></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class="MsoNormal"><font size="3"><font face="Calibri"><span style="mso-spacerun: yes"> </span>'d 'SWDOWN_nrr1''</font></font></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class="MsoNormal"><font size="3"><font face="Calibri"><span style="mso-spacerun: yes"> </span>'d 'SWDOWN_nrr2''
</font></font></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class="MsoNormal"><font size="3"><font face="Calibri"><span style="mso-spacerun: yes"> </span>'fprintf 'LU1' LU1.txt'</font></font></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class="MsoNormal"><font size="3"><font face="Calibri"><span style="mso-spacerun: yes"> </span>'d 'LU2''</font></font></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class="MsoNormal"><font size="3"><font face="Calibri"><span style="mso-spacerun: yes"> </span>'fprintf 'SW1' SW1.txt'</font></font></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class="MsoNormal"><font size="3"><font face="Calibri"><span style="mso-spacerun: yes"> </span>'fprintf 'SW5' SW5.txt'</font></font></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class="MsoNormal"><font size="3"><font face="Calibri"><span style="mso-spacerun: yes"> </span>'fprintf 'nrr' nrr.txt'</font></font></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class="MsoNormal"><font size="3"><font face="Calibri"><span style="mso-spacerun: yes"> </span>'fprintf 'SWDOWN_nrr2' SWDOWN_nrr2.txt'</font></font></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class="MsoNormal"><font size="3"><font face="Calibri"><span style="mso-spacerun: yes">
</span>tim=tim+1</font></font></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class="MsoNormal"><font size="3" face="Calibri">endwhile</font></p>
</div>
<div dir="ltr"><font color="#000000" size="2" face="Tahoma"></font> </div>
<div style="DIRECTION: ltr" id="divRpF599509">
<hr tabindex="-1">
<font color="#000000" size="2" face="Tahoma"><b>From:</b> gradsusr-bounces@gradsusr.org [gradsusr-bounces@gradsusr.org] On Behalf Of Jeffrey Duda [jdduda@iastate.edu]<br>
<b>Sent:</b> Wednesday, January 05, 2011 3:34 AM<br>
<b>To:</b> GrADS Users Forum<br>
<b>Subject:</b> Re: [gradsusr] How to convert a string to a real number?<br>
</font><br>
</div>
<div></div>
<div>As far as I'm aware, you shouldn't have to explicitly convert in grads scripting. Just use your quotes correctly. Here's an example from a script I wrote to compute theta-e:<br>
<br>
These constants are set as variables within the grads script only (i.e., they don't exist in the command window...I can't display Rv or Rd etc.). Thus they're regarded as constants or strings.<br>
<br>
Rv = 461.5<br>
Rd = 287.05<br>
Cp = 1005<br>
lv = 2.5e6<br>
<br>
In the actual theta-e computation below, notice how the variables are used between single quotes so as not to be a part of a command that would otherwise be issued in the command window. This is all you should have to do to use a string as a number or vice
versa.<br>
<br>
'tempK = tc + 273'<br>
'es = 6.11*exp((2.5e6/461.5)*((1/273) - (1/tempK)))'<br>
'e = qvapor*((p+pb)/100) / (qvapor + 0.622)'<br>
'equivt = tempK + 'Lv'*qvapor/'Cp'<br>
'thetae = equivt*pow(1000/slp,'Rd'/'Cp')'<br>
<br>
<br>
I hope this helps, but ask more questions if it doesn't.<br>
<br>
Jeff Duda<br>
<br>
<div class="gmail_quote">On Tue, Jan 4, 2011 at 1:24 PM, Murphy, Darren W <span dir="ltr">
<<a href="mailto:dwmurphy@nps.edu">dwmurphy@nps.edu</a>></span> wrote:<br>
<blockquote style="BORDER-LEFT: rgb(204,204,204) 1px solid; MARGIN: 0pt 0pt 0pt 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">
<div><font face="Calibri, Verdana, Helvetica, Arial"><span style="FONT-SIZE: 11pt">I’d like to second this question. I am having the same issue. I think the Grads literature says that some commands can use a number as a string for calculations. However,
when I try and use my number “string” in a max or min Grads function, it throws an error.<br>
<br>
Thanks,<br>
Darren<br>
<br>
<br>
On 1/4/11 6:45 AM, "qinglan" <<a href="http://qinglan@hku.hk" target="_blank">qinglan@hku.hk</a>> wrote:<br>
<br>
</span></font>
<blockquote><font size="2"><font face="Tahoma, Verdana, Helvetica, Arial"><span style="FONT-SIZE: 10pt">Dear All,<br>
<br>
</span></font></font><font size="4"><font face="Calibri, Verdana, Helvetica, Arial"><span style="FONT-SIZE: 14pt">Is there anybody know how to convert a string to a real number in Grads? For example, if my string is ‘300.5’, I want to get the value of 300.5,
which is a real number, how to do that?<br>
<br>
Really appreciate your help!<br>
Best regards,<br>
Qinglan Li<br>
</span></font></font><font size="2"><font face="Tahoma, Verdana, Helvetica, Arial"><span style="FONT-SIZE: 10pt"><br>
</span></font></font><font face="Calibri, Verdana, Helvetica, Arial"><span style="FONT-SIZE: 11pt"><br>
<hr align="center" size="3" width="95%">
</span></font><font size="2"><font face="Consolas, Courier New, Courier"><span style="FONT-SIZE: 10pt">_______________________________________________<br>
gradsusr mailing list<br>
<a href="http://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>
</span></font></font></blockquote>
</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">
<br>
-- <br>
Jeff Duda<br>
Iowa State University<br>
Meteorology Graduate Student<br>
3134 Agronomy Hall<br>
<a href="http://www.meteor.iastate.edu/~jdduda" target="_blank">www.meteor.iastate.edu/~jdduda</a><br>
</div>
</div>
</body>
</html>