!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-02-14    作成
!c
!c Copyright (C) SUGIYAMA Ko-ichiro, 2003, All rights reserved


module interface_mol2emol
  interface 

     subroutine mol2emol(mol, struct, emol)
       real(8), intent(in)                :: mol(:)
       real(8), intent(in)                :: struct(:,:)
       real(8), intent(out), allocatable  :: emol(:)
     end subroutine mol2emol

  end interface 
end module interface_mol2emol



subroutine mol2emol(mol, struct, emol)
  implicit none
  real(8), intent(in)                :: mol(:)
  real(8), intent(in)                :: struct(:,:)
  real(8), intent(out), allocatable  :: emol(:)

  integer                            :: e, N, M


  N = size(struct, 1)  !化学種数
  M = size(struct, 2)  !元素数

  if (allocated(emol)) deallocate(emol)
  allocate(emol(M))

  do e = 1, M
     emol(e) = dot_product(mol(1:N), struct(1:N, e))
  end do

end subroutine mol2emol



