<div dir="ltr">The difference between command line commands and scripting variables is biting you here. You cannot directly access values from the arrays in your data file in a single command in a GrADS script. You have to display the variable first, then use the sublin, subwrd, or substr script commands to capture the field value. For instance, let's say you have 850-mb temperature. You would have to do something like this:<div><br></div><div>'set lon -110'</div><div>'set lat 31'</div><div>'d tc(lev=850)'</div><div>t1 = subwrd(result,4)</div><div><br></div><div>Notice how only the last of those commands is a true internal-GrADS scripting command. The rest are just command line stuff.</div><div><br></div><div>You may want to play around with your data and script at a base level before fully programming. There are complications depending on how you setup your displayed grid. You did not provide any information in your email, so I have to be generic.</div><div><br></div><div>If used a control file to open the data and you have a PDEF line, you are likely going to be dealing with grid interpolation rather than exact grid point values. In that case, GrADS will output something like<br>"Notice: plotting interpolated data"</div><div>when you run any display command at the command line. I would test your own data to see if this is the case. If it is, then your script will need an additional line to capture the field value:</div><div>line = sublin(result,2)</div><div>t1 = subwrd(line,4)</div><div><br></div><div>Notice the second argument of these functions. They indicate which line, inline word, or subword string to pull out from the input (the first argument). Your output may look different than what I have used in the past (usually the 4th word contains the value itself), so you may need to end up using a different index value. Also, 'result' is a fixed keyword. Pretty much any command you issue at the command line in GrADS will have some text output for you stored within <i>result</i>. So just adding</div><div><br></div><div>say result</div><div><br></div><div>after display commands will give you some information on what GrADS is doing, and this is the source of where you grab the field values. So run 'say result' after some of your display commands to see 1) how many lines are being out put (so you know how to use sublin()), 2) How many words there are in the line you want (for subwrd()), and 3) which specific word or substring within a word you want (if needed). Note that subwrd parses the input line using blank characters as a delimiter, so you don't need to specify spaces.</div><div><br></div><div>Now, you want to pull out an array of values, so you'll need to loop this behavior. Ultimately, your code will need to look something like this:</div><div><br></div><div>start_lat = 31</div><div>end_lat = 37.5</div><div>start_lon = -115</div><div>end_lon = -108</div><div>delta_lat = 0.5</div><div>delta_lon = 0.5</div><div>ln = start_lon</div><div>while (ln <= end_lon)</div><div> 'set lon 'ln</div><div> lt = start_lat</div><div> while (lt <= end_lat)</div><div>  'set lat 'lt</div><div>  'd tc(lev=800)-tc(lev=700)'</div><div>  line = sublin(result,2)</div><div>  T_Diff = subwrd(line,4)</div><div>  lt = lt + delta_lat</div><div> endwhile</div><div> ln = ln + delta_lon</div><div>endwhile</div><div><br></div><div>in order to get what it appears you want.</div><div><br></div><div>I know, GrADS scripting is a bit unintuitive, and has something of a learning curve, and the notion of mixed display and script commands fools a lot of people and can be a real turn off. But this is how this particular application works.</div><div><br></div><div>Jeff Duda</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Feb 13, 2020 at 7:09 PM Jan Ising <<a href="mailto:jising@aggies.ncat.edu">jising@aggies.ncat.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr">Hello,<div><br></div><div>    I am new to GrADS and came across an issue that has given me quite some frustration. I am writing a script that calculates the temperature difference between two levels at each point within a region and then displays the values in the terminal (my script is indented to do more than this but the root of my issue arises from here). The problem is that the terminal displays the literal value of T_Diff (i.e " 'tc(Lev = 800) - tc(Lev = 700)' ", and not 15,18,22,etc... (for example)). Here is my code:</div><div><br></div><div>(open file and setup basic graphics output formatting)</div><div><br></div><div>TheLat = 31  <br></div><div></div><div>while(TheLat >=31 & TheLat <=37.5)</div><div>'set Lat 'TheLat</div><div>TheLong = -115</div><div>    while (TheLong>=-115 & TheLong<=-108)</div><div>        'set Lon 'TheLong<br clear="all"><div>        T_Diff = 'tc(Lev = 800) - tc(Lev = 700)'  <br></div><div>        say T_Diff</div><div>        TheLong = TheLong + 0.5<b></b><i></i><u></u><sub></sub><sup></sup><strike></strike><br></div><div>    endwhile</div><div></div><div></div><div>TheLat = TheLat + 0.5</div><div>endwhile</div><div><br></div><div>Perhaps this issue is a simple syntax error, perhaps it is a logic error, either way I am here to figure that out, any help would be greatly appreciated!</div><div><br></div><div><br></div><div dir="ltr"><div dir="ltr">-Thank you,<br></div><div dir="ltr"><div>Jon</div></div></div></div></div></div></div>
_______________________________________________<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" rel="noreferrer" target="_blank">http://gradsusr.org/mailman/listinfo/gradsusr</a><br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><font size="2"><span>Jeff Duda, Research Scientist</span></font></div><div dir="ltr"><font size="2"><span></span></font>University of Colorado Boulder</div><div dir="ltr"><font size="2"><span></span></font>Cooperative Institute for Research in Environmental Sciences</div><div dir="ltr">NOAA/OAR/ESRL/Global Systems Division<br><font size="2"><span>

<span>Boulder, CO<br></span></span></font>



</div></div></div></div></div></div></div></div>