!Description:
!  2 分木ソートの結果の変数出力
!
! Current Code Owner: sugiyama@gfd-dennou.org
!
! History: 
!   Version    Date          Comment
!   -------    ----------    -------
!   1.0        2003-01-31    新規作成
!
! Copyright (C) SUGIYAMA Ko-ichiro, 2003, All rights reserved

module interface_binsort_output
  interface

     recursive subroutine binsort_output(ptr, e, var)
       use prm_type, only: type_tree
       type(type_tree), pointer :: ptr
       integer, intent(inout)   :: e
       integer, intent(inout)   :: var(:)
     end subroutine binsort_output

  end interface
end module interface_binsort_output



recursive subroutine binsort_output(ptr, e, var)
  use prm_type, only: type_tree

  implicit none
  type(type_tree), pointer :: ptr
  integer, intent(inout)   :: e
  integer, intent(inout)   :: var(:)
  

  if (associated(ptr)) then 
     call binsort_output(ptr%left, e, var)
     e = e + 1
     var(e) = ptr%node
     call binsort_output(ptr%right, e, var)
  end if

end subroutine binsort_output

