*     ************************************************************************

      subroutine dtscal( n, scal, x, incx, y, incy )

*     ************************************************************************

*     Purpose :
*     ---------

*     This subroutine sets the vector Y to SCAL times the vector X.
*     The components of these vectors that are considered are the 
*     components of indices (1+(i-1)*abs(INCX)) and (1+(i-1)*abs(INCY)) 
*     for i=1 up to i=n.

*     Parameters :
*     ------------

*     n       ( int )

*       input  : number of components of Y to set to SCAL*X.
*       output : unmodified.

*     scal    ( dble )

*       input  : the scalar multiplier to X.
*       output : unmodified.

*     x       ( dble )

*       input  : a vector containing the components to copy in Y
*                after multiplication by SCAL.
*       output : unmodified.

*     incx    ( int )

*       input  : increment to consider between two successive
*                components of X.
*                If INCX is negative, then its absolute value
*                is considered.
*       output : unmodifed.

*     y       ( dble )

*       input  : a vector containing the components to set
*                to the value SCAL*some component of X.
*       output : identical to the input value, except for the
*                components for the components 1+i*INCY
*                (i=0, ..., n-1) that are set to the values of
*                SCAL*x(j) (j=1+i*INCX).

*     incy    ( int )

*       input  : increment to consider between two successive
*                components of Y.
*                If INCY is negative, then its absolute value
*                is considered.
*       output : unmodifed.

*     Routines used :
*     ---------------

*     None.

*     Programming :
*     -------------

*     Ph.L. Toint 

*     Remarks :
*     ---------

*     This routine is written to complete blasd, and its parameter list
*     is similarly arranged.

*     ========================================================================

*     Routine parameters

      integer          incx, n, incy
      double precision scal, x(*), y(*)

*     Internal variables

      integer          ix, m, i, iy, iix, iiy

      if( n.le.0 ) return

      ix = abs(incx)
      iy = abs(incy)

      if( ix.ne.1 .or. iy.ne.1 ) then

        iix = 1
        iiy = 1
        do 100 i = 1 , n
          y(iix) = scal*x(iiy)
          iix    = iix + ix
          iiy    = iiy + iy
  100   continue

      else

        m = mod(n,5)

        if( m.ne.0 ) then
          do 200 i = 1 , m
             y(i) = scal*x(i)
  200     continue
        endif

        if( n.ge.5 ) then
          ix = m + 1
          do 300 i = ix , n , 5
            y(i)   = scal*x(i)
            y(i+1) = scal*x(i+1)
            y(i+2) = scal*x(i+2)
            y(i+3) = scal*x(i+3)
            y(i+4) = scal*x(i+4)
  300     continue
        endif

      endif

      return
      end
