subroutine kdsaw_from_r4(izone,inzmax,inzact,ifrom,zfrom,ierr)

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

  implicit NONE

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

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

  real*8 zfrom_r8(inzmax)

  call kdsaw_from(izone,inzmax,inzact,ifrom,zfrom_r8,ierr)
  zfrom = zfrom_r8

end subroutine kdsaw_from_r4

subroutine kdsaw_from(izone,inzmax,inzact,ifrom,zfrom,ierr)

  ! give statistics on what fraction of material from which pre-sawtooth
  ! zones constitute the material in a selected post-sawtooth zone.

  use kdsaw_module
  implicit NONE

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

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

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

  integer ifromi(mj)
  real(fp) zfromi(mj)

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

  ierr=0
  inzact=0
  ifrom=0
  zfrom=zero

  izi=izone+lcentr-1

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

  ifromi=0
  zfromi=zero

  !  outside mixing region?

  if(izi.gt.imix) then
     inzact=1
     ifrom(1)=izone
     zfrom(1)=1
     return
  endif

  ! inside...

  do j=1,inzmix(izi)
     ifromi(izmix(j,izi))=1
     zfromi(izmix(j,izi))=zfromi(izmix(j,izi)) + zzmix(j,izi)
  enddo

  do j=lcentr,ledge
     if(ifromi(j).gt.0) then
        if(inzact.eq.inzmax) then
           write(abs(nonlin),*) ' ?kdsaw_from:  inzmax too small: ',inzmax
           ierr=2
           return
        else
           inzact=inzact+1
           ifrom(inzact)=j-lcentr+1
           zfrom(inzact)=zfromi(j)
        endif
     endif
  enddo

end subroutine kdsaw_from
