!c Description:
!c   モル数が少な過ぎて系に寄与しない元素を選択
!c
!c Current Code Owner: 
!c   sugiyama@gfd-dennou.org
!c
!c Histry: 
!c   Version    Date          Comment
!c   -------    ----------    --------
!c   1.0        2003-03-01    作成
!c
!c Copyright (C) SUGIYAMA Ko-ichiro, 2003, All rights reserved

module interface_ChkElmMol
  interface
     
     subroutine ChkElmMol(struct, ssw, esw)
       real(8), intent(in)               :: struct(:,:)
       logical, intent(in)               :: ssw(:) 
       logical, intent(out), allocatable :: esw(:) 
     end subroutine ChkElmMol
     
  end interface
end module interface_ChkElmMol




subroutine ChkElmMol(struct, ssw, esw)
  use interface_packing
  
  implicit none
  real(8), intent(in)               :: struct(:,:)
  logical, intent(in)               :: ssw(:) 
  logical, intent(out), allocatable :: esw(:) 

  real(8), allocatable              :: struct_tmp(:,:)
  integer                           :: M
  
  
!!!
!!!初期化
!!!
  M = size(struct, 2)
  if (allocated(esw)) deallocate(esw)
  allocate(esw(M))
  esw = .true.

  
!!!
!!!化学種を削除したことで元素も無くなる場合に備える
!!!
  call packing(struct, ssw, esw, struct_tmp)
  esw = sum(struct_tmp,1) /= 0.0d0

!!!
!!!どの元素を削除したか保管しておく
!!!
  

    
!!!
!!!後かたづけ
!!!
  deallocate(struct_tmp)
  
end subroutine ChkElmMol



