      program extract_frames

      parameter( mx=500 )

      dimension u(mx), u_exact(Mx)

      open(unit=1,file='frames.dat',form='unformatted')
      open(unit=2,file='frame.dat')

      read(1) Nw, CFL, i_fd_type, 
     &        Nx, xL, dx, x_shift_0, period,
     &        nt, t_final, dt, dt_print, i_skip, n_frames

      print *, 'enter frame number to extract <= ', n_frames
      read(5,*) i_extract

      if( i_extract .gt. n_frames) then
         print *, 'ERROR: frame number exceeds max number in file'
         stop
      end if

      do n=1, i_extract-1
         read(1)
         read(1)
         read(1)
      end do

      read(1) i_frame, n, t
      read(1) (u(i),i=1,Nx)
      read(1) (u_exact(i),i=1,Nx)

      print *, 'extracted i_frame, n, t = ', i_frame, n, t

      do i=1, Nx
         write(2,10) dx*(i-1), u(i), u_exact(i)
10       format(1p3e12.4)
      end do

      stop
      end
