subroutine kdsaw_to_r4(izone,inzmax,inzact,ito,zto,ierr)

  ! REAL interface to REAL*8 routine (see below)

  implicit NONE

  integer, intent(in) :: izone          ! selected pre-sawtooth zone 
  integer, intent(in) :: inzmax         ! max number of post-sawtooth zones

  integer, intent(out) :: inzact        ! actual number of post-sawtooth zones
  integer, intent(out) :: ito(inzmax)   ! post-sawtooth zone indices
  real, intent(out) :: zto(inzmax)      ! post-sawtooth material fractions
  integer, intent(out) :: ierr          ! error code (0=OK)

  real*8 zto_r8(inzmax)

  call kdsaw_to(izone,inzmax,inzact,ito,zto_r8,ierr)
  zto = zto_r8

end subroutine kdsaw_to_r4

subroutine kdsaw_to(izone,inzmax,inzact,ito,zto,ierr)

  ! give distribution of material of pre-sawtooth zone "izone" to
  ! affected post-sawtooth zones.

  use kdsaw_module
  implicit NONE

  integer, intent(in) :: izone          ! selected pre-sawtooth zone 
  integer, intent(in) :: inzmax         ! max number of post-sawtooth zones

  integer, intent(out) :: inzact        ! actual number of post-sawtooth zones
  integer, intent(out) :: ito(inzmax)   ! post-sawtooth zone indices
  real(fp), intent(out) :: zto(inzmax)    ! post-sawtooth material fractions
  integer, intent(out) :: ierr          ! error code (0=OK)

  !------------------------

  integer itoi(mj)
  real(fp) ztoi(mj)

  integer izi,j
  !------------------------

  ierr=0
  inzact=0
  ito=0
  zto=0

  izi=izone+lcentr-1

  if((izi.lt.lcentr).or.(izi.gt.ledge)) then
     write(abs(nonlin),*) ' ?kdsaw_to:  invalid zone index: ',izone
     ierr=1
     return
  endif

  itoi=0
  ztoi=zero

  !  outside mixing region?

  if(izi.gt.imix) then
     inzact=1
     ito(1)=izone
     zto(1)=one
     return
  endif

  ! inside...

  do j=1,inzmxp(izi)
     itoi(izmixp(j,izi))=1
     ztoi(izmixp(j,izi))=ztoi(izmixp(j,izi)) + zzmixp(j,izi)
  enddo

  do j=lcentr,ledge
     if(itoi(j).gt.0) then
        if(inzact.eq.inzmax) then
           write(abs(nonlin),*) ' ?kdsaw_to:  inzmax too small: ',inzmax
           ierr=2
           return
        else
           inzact=inzact+1
           ito(inzact)=j-lcentr+1
           zto(inzact)=ztoi(j)
        endif
     endif
  enddo

end subroutine kdsaw_to
