      program rd_dbl91

      parameter (msfc=100,msat=50)
      common /sfcobs/ nsfc,isvar(msfc),istxt(msfc)
      character(80) file,istxt
      character(50) satnd(16),climd(4),surfd(11)
      character(10) upprd(6),upprv(6)
      dimension clim(4),satn(msat),surf(msfc),psig(91),uppr(91,6)
      data lugrb/10/

c  define the satellite elements
c  -----------------------------


      satnd( 1) = '004001  YEAR  YEAR         YEAR                   '
      satnd( 2) = '004002  MNTH  MONTH        MONTH                  '
      satnd( 3) = '004003  DAYS  DAY          DAY                    '
      satnd( 4) = '004004  HOUR  HOUR         HOUR                   '
      satnd( 5) = '004005  MINU  MINUTE       MINUTE                 '
      satnd( 6) = '004006  SECO  SECOND       SECOND                 '
      satnd( 7) = '006002  CLON  DEGREES      LONGITUDE              '
      satnd( 8) = '005002  CLAT  DEGREES      LATITUDE               '
      satnd( 9) = '001007  SAID  CODE TABLE   SAT IDENTIFIER         '
      satnd(10) = '002019  SIID  CODE TABLE   SAT INSTRUMENTS        '
      satnd(11) = '005043  FOVN  NUMERIC      BEAM POSITION          '
      satnd(12) = '008012  LSQL  CODE TABLE   LAND/SEA QUALIFIER     '
      satnd(13) = '007024  SAZA  DEGREE       SAT ZENITH ANGLE       '
      satnd(14) = '007025  SOZA  DEGREE       SOLAR ZENITH ANGLE     '
      satnd(15) = '010001  HOLS  METER        HEIGHT OF LAND SURFACE '
      satnd(16) = '007002  HMSL  METER        HEIGHT OR ALTITUDE     '

c  define the climate values
c  -------------------------

      climd(1)='iv=27 ! low  vegetation cover'
      climd(2)='iv=28 ! high vegetation cover'
      climd(3)='iv=29 ! low  vegetation type'
      climd(4)='iv=30 ! high vegetation type'

c  read in the list of surface values to include
c  ---------------------------------------------

      open(lugrb,file='surface.lst');n=0
3     if(n+1.gt.msfc)  return 
      read(lugrb,'(5x,i3,4x,a80)',end=4)isvar(n+1),istxt(n+1)
      n=n+1; nsfc=n
      goto3
4     print*,'read ',nsfc,' surface variable definitions'
      if(nsfc.gt.msfc) return

c  define the upper air values
c  ---------------------------

      upprd(1)=' cloud cov'; upprv(1)='    iv=248'
      upprd(2)=' cloud ice'; upprv(2)='    iv=247'
      upprd(3)=' cloud h2o'; upprv(3)='    iv=246'
      upprd(4)=' ozone mmr'; upprv(4)='    iv=203'
      upprd(5)=' tempature'; upprv(5)='    iv=130'
      upprd(6)=' spf humid'; upprv(6)='    iv=133'

c  open the thinned dbl91 file and read one record
c  -----------------------------------------------
c------------   dbl91 data are written in BigEndian.
      open(20,file="DBL91",form='unformatted')
      read(20,end=10) nsat,nclm,nsfc,nupr,kmax 
      write(*,*) nsat,nclm,nsfc,nupr,kmax
 
      read(20,end=10) nsat,nclm,nsfc,nupr,kmax,(satn(m),m=1,nsat),
     .               (clim(m),m=1,nclm),(surf(m),m=1,nsfc),
     .               (psig(l),l=1,kmax),((uppr(l,m),l=1,kmax),m=1,nupr)


      write(*,*) "01010101010101"

      print*
      print'(f20.2,2x,a50)',(satn(m),satnd(m),m=1,16)                   
      print*
      print'(f20.5,2x,a50)',(clim(m),climd(m),m=1,nclm)
      print*
      print9,(surf(m),isvar(m),m,istxt(m),m=1,nsfc)
9     format(f20.5,2x,2i5,2x,a50)
      print*
      print'("    pres(pa)",6a12)',upprd
      print'("            ",6a12)',upprv
      print*
      print'(7e12.4)',(psig(k),(uppr(k,m),m=1,nupr),k=1,kmax)
      print*
      
    
c      print'(f20.2,2x,x50)',(satn(m),m=1,nsat)                 

10    stop
      end
      

