         subroutine indep_res(q_np1, q_n, x, res, Nx, Ng, lambda)

c------------------------------------------------------------
c        Independent residual evaluator.  See Notes on Basic 
c        Finite Difference Techniques for Time Dependent 
c        PDEs for more information.
c------------------------------------------------------------

         implicit      none

         character*9   cdnm
         parameter   ( cdnm = 'indep_res' ) 

         logical       ltrace
         parameter   ( ltrace = .false. )

         logical       res_trace
         parameter   ( res_trace = .false. )

         real*8        cpi
         parameter   ( cpi = 3.141 5926 5358 9793 d0 )

         integer       Nx
         integer       Ng
 
         real*8        q_np1 ( Nx ) 
         real*8        q_n   ( Nx ) 
      
         real*8        x     ( Nx )   

         real*8        lambda
         integer       i

         real*8        dt,     dx

         real*8        res    ( Nx )

         real*8        norm_res

c============================================================
c============================================================

         dx = x(2) - x(1)
         dt = lambda * (x(2) - x(1))
         if ( ltrace ) then
            write(0,*) cdnm,':        Nx =', Nx
            write(0,*) cdnm,':        Ng =', Ng
            write(0,*) cdnm,':    lambda =', lambda
            write(0,*) cdnm,':        dx =', dx
            write(0,*) cdnm,':        dt =', dt
         endif
         do i = 1, Ng+1
            res(i) = 0.0d0
         enddo
         do i = Ng+2, Nx - Ng - 1 
            res(i) = (q_np1(i)-q_n(i)) / dt +
     &         (0.5d0*(0.5d0*(q_n(i+1) + q_np1(i+1)))**2-
     &          0.5d0*(0.5d0*(q_n(i-1) + q_np1(i-1)))**2 
     &         ) / (2.0d0 * dx) 
 
         enddo
         do i = Nx-Ng, Nx
            res(i) = 0.0d0
         enddo
         call norm(norm_res, res, Nx  )
         if ( res_trace ) then
           write(0,*) cdnm,': nrm_res =',norm_res
         endif
         return 
         end
