module tohist
  use sep
  interface to_history2
     module procedure to_hist_int_array
     module procedure to_hist_float_array
  end interface

contains
  subroutine to_hist_int_array (name, value, file)
    character (len = *), intent (in)               :: name,file
    integer, intent (in), dimension (:)           :: value
    character (len = len(name) + 3)     :: varname
    integer :: n,i
    n = size(value)
    do i=1,n
       write (varname,"(a,i1)") name,i
       call to_history (varname, value(i),file)
    end do
  end subroutine to_hist_int_array

  subroutine to_hist_float_array (name, value, file)
    character (len = *), intent (in)               :: name,file
    real, intent (in), dimension (:)           :: value
    character (len = len(name) + 3)     :: varname
    integer :: n,i
    n = size(value)
    do i=1,n
       write (varname,"(a,i1)") name,i
       call to_history (varname, value(i),file)
    end do
  end subroutine to_hist_float_array
end module tohist
