!c Description:
!c  相番号を元に, 気相に 1 それ以外に 0 を代入した配列 alpha を作成
!c
!c Current Code Owner: 
!c   sugiyama@gfd-dennou.org
!c
!c Histry: 
!c   Version    Date          Comment
!c   -------    ----------    --------
!c   1.0        2003-02-06    作成
!c
!c Copyright (C) SUGIYAMA Ko-ichiro, 2003, All rights reserved

module interface_phase2alpha
  interface

     subroutine phase2alpha(phase, alpha)
       implicit none
       real(8), intent(out), allocatable  :: alpha(:)
       integer, intent(in)                :: phase(:)
     end subroutine phase2alpha

  end interface
end module interface_phase2alpha



subroutine phase2alpha(phase, alpha)
  implicit none
  real(8), intent(out), allocatable  :: alpha(:)
  integer, intent(in)                :: phase(:)

  real(8), allocatable               :: alpha_tmp(:) 
  integer                            :: N

  
  N = size(phase, 1)
  allocate(alpha(N), alpha_tmp(N))

  alpha = 1.0D0
  alpha_tmp = 0.0D0 
  alpha = merge(alpha, alpha_tmp, phase == 1)

  deallocate(alpha_tmp)

end subroutine phase2alpha
