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


module interface_list_insert
  interface list_insert
     
     subroutine list_insert_comps(atmnum, enum, object)
       use prm_type, only: list_comps, type_comps
       integer, intent(in)          :: atmnum
       real(8), intent(in)          :: enum
       type(list_comps), pointer    :: object
     end subroutine list_insert_comps
     
     subroutine list_insert_data(temp, data, object)
       use prm_type, only: list_data
       real(8), intent(in)          :: temp
       real(8), intent(in)          :: data
       type(list_data), pointer     :: object
     end subroutine list_insert_data
     
     subroutine list_insert_spl(temp, cp, cp_int, cp_dvt_int, C, D, E, object)
       use prm_type, only: list_spl, type_spl
       real(8), intent(in)          :: temp
       real(8), intent(in)          :: cp
       real(8), intent(in)          :: cp_int
       real(8), intent(in)          :: cp_dvt_int
       real(8), intent(in)          :: C
       real(8), intent(in)          :: D
       real(8), intent(in)          :: E
       type(list_spl), pointer      :: object
     end subroutine list_insert_spl

  end interface
end module interface_list_insert



subroutine list_insert_comps(atmnum, enum, object)
  use prm_type, only: list_comps, type_comps

  implicit none
  integer, intent(in)          :: atmnum
  real(8), intent(in)          :: enum
  type(list_comps), pointer    :: object

  type(type_comps)             :: oneobject
  type(list_comps), pointer    :: p, q
  

  oneobject%atmnum = atmnum
  oneobject%enum = enum

  p => object
  do 
     if (p%record%atmnum > oneobject%atmnum) exit
     p => p%next
  end do
  allocate(q)
  
  !挿入
  q = p
  p%record = oneobject
  
  !つなぎ変え
  p%next => q
  
end subroutine list_insert_comps


subroutine list_insert_data(temp, data, object)
  use prm_type, only: list_data, type_data

  implicit none
  real(8), intent(in)          :: temp
  real(8), intent(in)          :: data
  type(list_data), pointer     :: object

  type(type_data)              :: oneobject
  type(list_data), pointer     :: p, q
  

  oneobject%temp = temp
  oneobject%data = data

  p => object
  do 
     if (p%record%temp > oneobject%temp) exit
     p => p%next
  end do
  allocate(q)
  
  !挿入
  q = p
  p%record = oneobject
  
  !つなぎ変え
  p%next => q

end subroutine list_insert_data




subroutine list_insert_spl(temp, cp, cp_int, cp_dvt_int, C, D, E, object)  
  use prm_type, only: list_spl, type_spl

  implicit none
  real(8), intent(in)          :: temp
  real(8), intent(in)          :: cp
  real(8), intent(in)          :: cp_int
  real(8), intent(in)          :: cp_dvt_int
  real(8), intent(in)          :: C
  real(8), intent(in)          :: D
  real(8), intent(in)          :: E
  type(list_spl), pointer      :: object
  
  type(type_spl)              :: oneobject  
  type(list_spl), pointer     :: p, q
  

  oneobject = type_spl(temp, cp, cp_int, cp_dvt_int, C, D, E)

  p => object
  do 
     if (p%record%temp > oneobject%temp) exit
     p => p%next
  end do
  allocate(q)
  
  !挿入
  q = p
  p%record = oneobject
  
  !つなぎ変え
  p%next => q

end subroutine list_insert_spl



