  function getinfo (args)
  name = subwrd(args,1)
  file = subwrd(args,2)

**************************************************
**************************************************
****                                          ****
****    This routine is used to "get" info    ****
****    about the grads table file in use.    ****
****                                          ****
**************************************************
**************************************************

* Phyical Constants
* -----------------
grav = 9.80665

* -----------------

if( file = "" )
'query file'
       file = sublin(result,1)
       file = subwrd(file,2)
endif

  'query ctlinfo 'file
         ctlinfo = result
            dset = sublin(result,1)
            dset = subwrd(dset,2)

  'query file 'file
  xlab       = sublin(result,1)
  desc       = sublin(result,2)
  desc       = subwrd(desc,2)
  file       = subwrd(xlab,2)

if( name = "numfiles" )
    'query files'
           files = result
           ftest = sublin(files,1)
           ftest = subwrd(ftest,1)
     if(   ftest = No )
     numfiles = NULL
     else
     numfiles = 1
         line = 3*numfiles-2
          dum = sublin(files,line)
         while (dum!="")
                numfiles = numfiles+1
                    line = 3*numfiles-2
                     dum = sublin(files,line)
         endwhile
       numfiles = numfiles-1
       endif
return numfiles
endif
   

* Note:  Define label following colon:
         numdot  = 0
         numdot1 = 1
         while ( numdot1<20 )
         dot = substr(xlab,numdot1,1)
         if( dot=':' )
         numdot = numdot1
         endif
         numdot1 = numdot1 + 1
         endwhile
         if( numdot!=0 )
         numdot = numdot+1
         label = substr( xlab,numdot,80 )
         else
         label = " "
         endif
         if(label!=" ")
            num=1
            xxx=0
            while(num<81)
            val=substr(label,num,1)
            if(val!=' ')
            xxx=1
            endif
            num=num+1
            endwhile
            if(xxx=0)
            label = " "
         endif
         endif

  tabl_file  = sublin(result,2)
  tabl_file  = subwrd(tabl_file,2)
  data_file  = sublin(result,3)
  data_file  = substr(data_file,11,80)
  resolution = sublin(result,5)
  xdim       = subwrd(resolution,3)
  ydim       = subwrd(resolution,6)
  zdim       = subwrd(resolution,9)
  tdim       = subwrd(resolution,12)
  edim       = subwrd(resolution,15)
  nvars      = sublin(result,6)
  nvars      = subwrd(nvars,5)


* Get Time Increment
* ------------------
 if (name="tinc" )
         n = 1
      while( n >0 )
             line = sublin(ctlinfo,n)
             word = subwrd(line,1)
         if( word = 'tdef' )
             dumm = subwrd(line,5)
           length = strlen(dumm)
             tinc = substr( dumm,1,length-2 )
             unit = substr( dumm,length-1,length )
         if( unit = 'mn' ) ; tinc = tinc/60 ; endif
             n  = 0
          else
             n  = n + 1
          endif
      endwhile
 endif

* Get Time Unit
* -------------
 if (name="tunit" )
         n = 1
      while( n >0 )
             line = sublin(ctlinfo,n)
             word = subwrd(line,1)
         if( word = 'tdef' )
             tinc = subwrd(line,5)
           length = strlen(tinc)
                 unit = substr( tinc,length-1,length )
             if( unit = 'yr' ) ; tunit = year  ; endif
             if( unit = 'mo' ) ; tunit = month ; endif
             if( unit = 'dy' ) ; tunit = day   ; endif
             if( unit = 'hr' ) ; tunit = hour  ; endif
             if( unit = 'mn' ) ; tunit = hour  ; endif
             n = 0
          else
             n = n + 1
          endif
      endwhile
 endif

* Get UNDEF value
* ---------------
 if (name="undef" )
         n = 1
      while( n >0 )
             line = sublin(ctlinfo,n)
             word = subwrd(line,1)
         if( word = 'undef' )
            undef = subwrd(line,2)
             n  = 0
          else
             n  = n + 1
          endif
      endwhile
 endif

* Get DLAT value
* --------------
 if (name="dlat" )
         n = 1
      while( n >0 )
             line = sublin(ctlinfo,n)
             word = subwrd(line,1)
         if( word = 'ydef' )
             form = subwrd(line,3)
            'run uppercase 'form
                            form = result
             if( form = 'LEVELS' )
                 lat1 = subwrd(line,4)
                 lat2 = subwrd(line,5)
                 dlat = lat2-lat1
             else
                 dlat = subwrd(line,5)
             endif
             n  = 0
          else
             n  = n + 1
          endif
      endwhile
 endif

* Get DLON value
* --------------
 if (name="dlon" )
         n = 1
      while( n >0 )
             line = sublin(ctlinfo,n)
             word = subwrd(line,1)
         if( word = 'xdef' )
             form = subwrd(line,3)
            'run uppercase 'form
                            form = result
             if( form = 'LEVELS' )
                 lon1 = subwrd(line,4)
                 lon2 = subwrd(line,5)
                 dlon = lon2-lon1
             else
                 dlon = subwrd(line,5)
             endif
             n  = 0
          else
             n  = n + 1
          endif
      endwhile
* Re-Define DLON based on XDIM (for more accuracy)
* ------------------------------------------------
      dlon = 360/xdim
 endif


if(label=" ")
   label=tabl_file
endif


* Query File Dimensions
* ---------------------
  'q dims'

  xline = sublin(result,2)
  xfreq = subwrd(xline,3)
  xpos  = subwrd(xline,9)
  lon   = subwrd(xline,6)
  xmin  = subwrd(xline,11)
  xmax  = subwrd(xline,13)
if (xfreq="varying")
  lons  = subwrd(xline,6)' 'subwrd(xline,8)
  lonmin= subwrd(xline,6)
  lonmax= subwrd(xline,8)
else
  lons  = subwrd(xline,6)' 'subwrd(xline,6)
  lonmin= subwrd(xline,6)
  lonmax= subwrd(xline,6)
endif

  yline = sublin(result,3)
  yfreq = subwrd(yline,3)
  ypos  = subwrd(yline,9)
  lat   = subwrd(yline,6)
  ymin  = subwrd(yline,11)
  ymax  = subwrd(yline,13)
if (yfreq="varying")
  lats  = subwrd(yline,6)' 'subwrd(yline,8)
  latmin= subwrd(yline,6)
  latmax= subwrd(yline,8)
else
  lats  = subwrd(yline,6)' 'subwrd(yline,6)
  latmin= subwrd(yline,6)
  latmax= subwrd(yline,6)
endif

  zline = sublin(result,4)
  zfreq = subwrd(zline,3)
  zpos  = subwrd(zline,9)
if (zfreq="varying")
  zmin  = subwrd(zline,11)
  zmax  = subwrd(zline,13)
else
  zmin  = subwrd(zline,9)
  zmax  = subwrd(zline,9)
endif
  levs  = substr(zline,16,16)

  level = sublin(result,4)
  level = subwrd(level,6)

  tline = sublin(result,5)
  date  = subwrd(tline,6)
  tfreq = subwrd(tline,3)
  time  = subwrd(tline,9)
if (tfreq="varying")
  tmin  = subwrd(tline,11)
  tmax  = subwrd(tline,13)
  time  = tmin' 'tmax
endif
if (tfreq="fixed")
  tmin  = time
  tmax  = time
endif

  eline = sublin(result,6)
  efreq = subwrd(eline,3)
if (efreq="varying")
  ens   = subwrd(eline,6)' 'subwrd(eline,8)
  emin  = subwrd(eline,6)
  emax  = subwrd(eline,8)
else
  ens   = subwrd(eline,6)
  emin  = subwrd(eline,6)
  emax  = subwrd(eline,6)
endif

* Find month from Date info
* -------------------------
  n = 1
  bit = substr(date,n,1)
  while( bit!="" & n<20 )
  bit = substr(date,n,1)
     n = n+1
  endwhile
  month = substr(date,n-8,3)
  year  = substr(date,n-5,4)

* Page Attributes
* ---------------
'q gxinfo'
pagex = sublin(result,2)
pagey = sublin(result,2)
pagex = subwrd(pagex ,4)
pagey = subwrd(pagey ,6)
 

* Return Options
* --------------
 if (name="dset" ) ; return dset          ; endif
 if (name="file" ) ; return file          ; endif
 if (name="desc" ) ; return desc          ; endif
 if (name="page" ) ; return pagex' 'pagey ; endif
 if (name="pagex") ; return pagex         ; endif
 if (name="pagey") ; return pagey         ; endif
 if (name="tabl" ) ; return tabl_file     ; endif
 if (name="label") ; return label         ; endif
 if (name="time" ) ; return time          ; endif
 if (name="date" ) ; return date          ; endif

 if (name="xdim" ) ; return xdim ; endif
 if (name="ydim" ) ; return ydim ; endif
 if (name="zdim" ) ; return zdim ; endif
 if (name="tdim" ) ; return tdim ; endif
 if (name="edim" ) ; return edim ; endif

 if (name="tfreq") ; return tfreq ; endif
 if (name="xfreq") ; return xfreq ; endif
 if (name="yfreq") ; return yfreq ; endif
 if (name="zfreq") ; return zfreq ; endif
 if (name="efreq") ; return efreq ; endif

 if (name="month") ; return month ; endif
 if (name="year")  ; return year  ; endif
 if (name="level") ; return level ; endif
 if (name="lons" ) ; return lons  ; endif
 if (name="lats" ) ; return lats  ; endif

 if (name="lon"   ) ; return lon    ; endif
 if (name="lonmin") ; return lonmin ; endif
 if (name="lonmax") ; return lonmax ; endif
 if (name="dlon"  ) ; return dlon   ; endif
 if (name="xpos"  ) ; return xpos   ; endif
 if (name="xmin"  ) ; return xmin   ; endif
 if (name="xmax"  ) ; return xmax   ; endif

 if (name="lat"   ) ; return lat    ; endif
 if (name="latmin") ; return latmin ; endif
 if (name="latmax") ; return latmax ; endif
 if (name="dlat"  ) ; return dlat   ; endif
 if (name="ypos"  ) ; return ypos   ; endif
 if (name="ymin"  ) ; return ymin   ; endif
 if (name="ymax"  ) ; return ymax   ; endif

 if (name="zpos" ) ; return zpos ; endif
 if (name="zmin" ) ; return zmin ; endif
 if (name="zmax" ) ; return zmax ; endif

 if (name="ens"  ) ; return ens  ; endif
 if (name="emin" ) ; return emin ; endif
 if (name="emax" ) ; return emax ; endif

 if (name="tinc" ) ; return tinc  ; endif
 if (name="tmin" ) ; return tmin  ; endif
 if (name="tmax" ) ; return tmax  ; endif
 if (name="tunit") ; return tunit ; endif
 if (name="undef") ; return undef ; endif
 if (name="nvars") ; return nvars ; endif

 if (name="grav" ) ; return grav  ; endif
