************************************************************************
*
function get_month(date)
*
*  Finds "month", given a GrADS "date" string...
*
*  Note, it is assumed "date" is defined using the GrADS command
*    'set t '...
*  and "date" is of the form "year:month:day:hour"
*
say date
ns = strlen(date)
*
*  verify date format...
*
n = 1 ; nc = 0
while ( n <= ns )
  ch = substr(date,n,1)
  if( ch = ':' )
    nc = nc + 1
  endif
  n=n+1
endwhile
if( nc != 3 )
  say 'error, invalid date format...'
  return error
endif
*
*  skip over the "year" portion of the date...
*
n=1
while ( n <= ns )
  ch = substr(date,n,1)
  if( ch = ':' )
    nms = n + 1
    break
  endif
  n=n+1
endwhile
*
*  find the "month" portion of the date...
*
n=nms
while ( n <= ns )
  ch = substr(date,n,1)
  if( ch = ':' )
    nml = n - nms
    break
  endif
  n=n+1
endwhile
month = substr(date,nms,nml)
*
*  convert the numerical "month" to a character abbreviation...
*
if( month = 1 )
  month = Jan
  return month
endif
if( month = 2 )
  month = Feb
  return month
endif
if( month = 3 )
  month = Mar
  return month
endif
if( month = 4 )
  month = Apr
  return month
endif
if( month = 5 )
  month = May
  return month
endif
if( month = 6 )
  month = Jun
  return month
endif
if( month = 7 )
  month = Jul
  return month
endif
if( month = 8 )
  month = Aug
  return month
endif
if( month = 9 )
  month = Sep
  return month
endif
if( month = 10 )
  month = Oct
  return month
endif
if( month = 11 )
  month = Nov
  return month
endif
if( month = 12 )
  month = Dec
  return month
endif
say 'error, no match found...'
return error
*
************************************************************************
