      subroutine dds (prosca,ctonb,ctcab,n,sscale,nm,depl,aux,jmin,jmax,
     &                precos,diag,alpha,ybar,sbar)
c----
c
c     This subroutine has the same role as dd (computation of the
c     product H.g). It supposes however that the (y,s) pairs are not
c     stored in core memory, but on a devise chosen by the user.
c     The access to this devise is performed via the subroutine ystbl.
c
c----
      use control_vectors
      implicit none
c
c         arguments
c
      logical sscale
      integer n,nm,jmin,jmax        
      real precos,alpha(nm)
      type (control_vector) :: depl,diag,aux
      type (control_vector) :: ybar,sbar
      external prosca,ctonb,ctcab
c
c         variables locales
c
      integer jfin,i,j,jp
      real r,ps

      call ctonb (n,depl,aux)

      jfin=jmax
      if (jfin.lt.jmin) jfin=jmax+nm
c
c         phase de descente
c
      do j=jfin,jmin,-1
          jp=j
          if (jp.gt.nm) jp=jp-nm
          stop 'ystbl:dead code'
c         call ystbl (.false.,ybar,sbar,n,jp)
          ps = DOT_PRODUCT (aux,sbar)
          r=ps
          alpha(jp)=r
          aux%data = aux%data - r * ybar%data
      enddo
c
c         preconditionnement
c
      if (sscale) then
          aux%data = aux%data * precos
      else
          aux%data = aux%data * diag%data
      endif
c
c         remontee
c
      do j=jmin,jfin
          jp=j
          if (jp.gt.nm) jp=jp-nm
          stop 'ystbl:dead code'
c         call ystbl (.false.,ybar,sbar,n,jp)
          ps = DOT_PRODUCT (aux,ybar)
          r=alpha(jp)-ps
          aux%data = aux%data + r * sbar%data
      enddo

      call ctcab (n,aux,depl)

      return
      end
c
c-----------------------------------------------------------------------
c

