[gradsusr] Loop help

Muhammad Yunus Ahmad Mazuki ukm.yunus at gmail.com
Tue Jul 2 21:14:50 EDT 2013


How about this? Replace the integer 1 with a script variable year, and
integer 2 with scrip variable tvalue.

year=1
tvalue=673
*start loop
while(loop<=672)
*your loops, example
'define y'year'=pdsi.1(t='tvalue')'
year=year+1
tvalue=tvalue+1
endwhile

Notice that y1= becomes y'year'= . If you want to put the variable at then
end, say you want to display t1 until t672, you need to leave out the '
mark at the end, example

'display t'year

Its the same if you're using something in the front.

variable'mean=something(something)'

The script variable are in string, so you can do lots of things with it,
including looping variables being plotted, automated plots title
corresponding to time of your choosing and others. So in one loop, you can
calculate, plot (with correspoding title, matching contours or shades) and
save them in pictures or binaries form.

For more information, please refer to GrADS scripting.

Yunus




On Wed, Jul 3, 2013 at 4:42 AM, Emily Wilson
<wilson.emily.parker at gmail.com>wrote:

> Hello! I need help formatting a loop command in a GrADS script.  I am
> using GrADS to extract PDSI data from a NetCDF file.  My script so far
> looks like this....
>
>  'reinit'
> *
>  'sdfopen pdsi.mon.mean.selfcalibrated.nc'
> *
>  'enable print grads.outfile'
>   say '** OUTPUT FILE: grads.outfile'
>  'clear'
>  'set grads off'
>  'set mpdset lores'
>  'set lon -106 -106'
>  'set lat 40 40'
> *
> *
>   'define y1=pdsi.1(t=673)'
>
>
> Now I want to define y1 thru y1260 with corresponding t= values starting
> at 673 and ending with 1936.  Instead of typing all of this out, I know I
> can use a loop but I do not no how to format that code.  Could someone
> please help me format this loop.
> Thanks in advance,
> *Emily P. Wilson, Intern*
> Research and Conservation Department
> Denver Botanic Gardens
> 1007 York St.
> Denver, CO 80206
> 720-865-3593
>
> _______________________________________________
> gradsusr mailing list
> gradsusr at gradsusr.org
> http://gradsusr.org/mailman/listinfo/gradsusr
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20130703/8f1af809/attachment-0003.html 


More information about the gradsusr mailing list