         real*8 function minmod(a, b)

c------------------------------------------------------------
c        Implements minmod function described in Project 2 
c        handout.
c------------------------------------------------------------

         implicit      none

         character*8   cdnm
         parameter   ( cdnm = 'minmod' ) 

         logical       ltrace
         parameter   ( ltrace = .false. )

         real*8       a,    b 

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

         if ( ltrace ) then
            write(0,*) cdnm,':  a = ',a
            write(0,*) cdnm,':  b = ',b
         endif
         if ( a * b .le. 0.0d0 )  then
             minmod = 0.0d0
         elseif ( abs(a) .le. abs(b) ) then
             minmod = a
         else 
             minmod = b
         endif
         if ( ltrace ) then
            write(0,*) cdnm,':  minmod = ',minmod
         endif
         return
         end

