!c Description:
!c   温度・圧力・初期組成から, 熱力学関数 G と平衡時の組成を導くルーチン
!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_unpacking
  interface

     subroutine unpacking(mol, order, min, mol_out)
       real(8), intent(in)  :: min
       real(8), intent(in)  :: mol(:)
       real(8), intent(out) :: mol_out(:)
       integer, intent(in)  :: order(:)
     end subroutine unpacking

  end interface
end module interface_unpacking




subroutine unpacking(mol, order, min, mol_out)
  implicit none
  real(8), intent(in)  :: min
  real(8), intent(in)  :: mol(:)
  real(8), intent(out) :: mol_out(:)
  integer, intent(in)  :: order(:)

  integer              :: i, s
  integer              :: N, M
  

  N = size(mol_out, 1)
  M = size(mol, 1)
  mol_out = min

  do s = 1, N
     do i = 1, M
        if (order(i) == s) mol_out(s) = mol(i)
     end do
  end do
  
end subroutine unpacking
