This is my gs file.
'xloc = aminlocx(slp,lon=120,lon=135,lat=20,lat=30)'
'yloc = aminlocy(slp,lon=120,lon=135,lat=20,lat=30)'
'lonn = 39.58386 + 0.22522523*(xloc-1)'
'latt = -8.64826 + 0.22522523*(yloc-1)'
'lonmin = lonn-1'
'lonmax = lonn+1'
'latmin = latt-1'
'latmax = latt+1'
'q w2xy 'lonmin' 'latmin
xpos1=subwrd(result,3)
ypos1=subwrd(result,6)
'q w2xy 'lonmax' 'latmax
xpos2=subwrd(result,3)
ypos2=subwrd(result,6)
'set line 2 1 6'
'draw rec 'xpos1' 'ypos1' 'xpos2' 'ypos2
And I got error like this
Query Error: Syntax is QUERY W2XY Lon Lat
Query Error: Syntax is QUERY W2XY Lon Lat
DRAW error: Syntax is DRAW REC xlo ylo xhi yhi
How do I fix it?
It should be noted that there are two types of variables in the GrADS script. One is a script variable and the other is a GrADS variable. The former variable must be outside of the quotes and the latter is referenced inside the quotes. For example, in the following line of your script
lonminandlatminare treated as script variables. On the other hand, in the following linexlocis treated as a GrADS variable.Now, if you want to get
xlocas a script variable, you can write as the following.Alternatively, for contexts where
displayis not allowed, you can also write as the following.Finally, your script will be rewritten like this.