      program test_read_l2
      implicit none
#include "structures.h"

C  Sample program to read a level2 d golfball file and print
c     Profile ID, Lat, Lon, P_surf and Tsurf
      integer iprt
      record /IO_struct/ l2io
      record /Level2_header/ l2h
      record /airs_level2/ l2d
      integer iret, i

      write (*,*) 'Input Filename'
      read (*,'(a100)') l2io.filename
      l2io.unformatted=.true.
      l2io.iounit=21
      l2io.oldornew='old'

      iprt=1
      call open_l2_sim (iprt, l2io, l2h, iret )
      write(*, '(a10,4a8)') "Prof ID", "Lat", "Lon", 'P_surf', 'T_surf'
      do i=1, l2h.nobs
         call read_l2_sim (iprt, l2io, l2h, l2d, iret)
         write (*,"(a10, 4f8.2)") l2d.idprof, l2d.alat, l2d.alon, l2d.psurf, l2d.tsurf
      enddo

      end
