    use grid_obs,only:raw_obs
    use resolution
    use ferror
    use io
    type(raw_obs)::obs
    character(MAX_FILE_NAME_LEN)::fn
    character(7)::asigma
    integer::k,iseq,istart,istop,nobsin
    integer,external::iargc  ! g95 intrinsic
    character(4)::tag
    logical::partial_grid
 
    call parseline(partial_grid,fn)
    open(unit=INNOSWAP,file=fn,form='unformatted',status='old')
    k=0
    if(partial_grid) then
       read(INNOSWAP) tag,iseq,istart,istop,nobsin
    else
       read(INNOSWAP) iseq
       istart=1
       istop=LATG
       nobsin=0
    endif
    write(IOUT,103) trim(fn)
103 format('data file: ',a)
    write(IOUT,101) iseq,istart,istop,nobsin
101 format('sequence number: ',i0,' starting lat: ',i0,' ending lat: ',i0, &
        ' nobs: ',i0)
102 format('#',4x,'k',' type',3x,'x_grd',3x,'y_grd',3x,'sigma',3x,'lambda', &
       5x,'phi',6x,'value',6x,'stdev',6x,'p_lev',6x,'prss',' qcm','  cat', &
       ' field')
    do
       read(INNOSWAP,end=10) obs
       if(mod(k,50).eq.0) write(IOUT,102)
       k=k+1
       if(obs%sigma.lt.LEVS+1) then
          write(asigma,'(f7.3)') obs%sigma
       else
          asigma='  undef'
       endif
       write(IOUT,100) k,obs%typecode,obs%x_grd,obs%y_grd,asigma, &
          obs%lambda,obs%phi,obs%value,obs%sdev,obs%p_lev,obs%prss,obs%qcm, &
          obs%cat,trim(obs%field)
    enddo
 10 continue
100 format(i7,i5,2f8.3,a7,1x,2f8.3,2es11.3,2f11.3,1x,f4.1,1x,i5,1x,a)
    stop
    end
!--------------------------------------------------------------------------
    subroutine parseline(partial_grid,fn)
    use command_line_support
    implicit none
    logical,intent(out)::partial_grid
    character(*),intent(out)::fn
!
    character(*),parameter::OPTIONS='a'
    character(80)::optarg
    character::opt
    integer::iopt,optind
!
    partial_grid=.true.
    do
       call getopt(iopt,optarg,optind,OPTIONS)
       if(iopt.lt.0) exit
       opt=char(iopt)
       select case(opt)
       case('a')   ! global grid
          partial_grid=.false.
       case default
          call usage
       endselect
    enddo
    call getarg(optind,fn)
    return
       contains
       subroutine usage
       use io
       write(IERR,100)
100    format('ydump: [-a (all obs/global grid)] obsfile')
       return
       end subroutine usage
    end subroutine parseline
