!c Description:
!c   phase から存在する相の数を計算
!c
!c Current Code Owner: 
!c   sugiyama@gfd-dennou.org
!c
!c Histry: 
!c   Version    Date          Comment
!c   -------    ----------    --------
!c   1.0        2003-02-25    作成
!c
!c Copyright (C) SUGIYAMA Ko-ichiro, 2003, All rights reserved

module interface_phase_count
  interface
     
     subroutine phase_count(phase, max)
       implicit none
       integer, intent(in)  :: phase(:)
       integer, intent(out) :: max
     end subroutine phase_count

  end interface
end module interface_phase_count




subroutine phase_count(phase, max)
  implicit none
  integer, intent(in)  :: phase(:)
  integer, intent(out) :: max
  integer              :: p(4)


  p = 0
  p(1) = 1
  if (count(phase == 2) /= 0)  p(2) = 1
  if (count(phase == 3) /= 0)  p(3) = 1
  p(4) = count(phase == 4) 

  max = sum(p)

end subroutine phase_count
