Years.gs Script
 
*calculates yearly averages from gpcp8796.dat
*since the 1987 data does not begin until july, it is excluded.
*
************Modifications Box****************
indata = "gpcp99.ctl"
*outplot = "c:\grads\1996\plots\gpcyears.gmf"
datname = "GPCP"
years = 3
*********************************************
*
'reinit'
'open 'indata
'set gxout shaded'
'set lat -90 90'
'set lon -180 180'
'set parea .8 10.8 1.25 7.5'
*
*loop to calculate each year's average and 
*write it to the file gpcyears.gmf
*
y= 1
while (y < years)
  yr = 87+y
  'enable print 'outplot
   a=y*12
   b=y*(12+1)
    'define yavg=ave(p,t='a',t='b',1)'
        'set clevs 2 4 6 8 10 12 14 16 18 20 22'
        'set ccols 7 12 8 2 6 9 4 11 5 13 3 10'
      'd yavg'
      'run cbar'
      'draw title Average Annual 'datname' Precipitation (mm/day): 19'yr
   'print'
   'clear'
  y=y+1
endwhile
’quit’