! chars.f90 - character type support routines
! Copyright (C) by TOYODA Eizi, 2000.  All rights reserved.
! vi: set sw=4 ts=8:

module dc_chars

    implicit none

contains

    function char_array_to_char(array) result(result)
	character, intent(in)::		array(:)
	character(len = size(array))::	result
	integer::			i
    continue
	! result = transfer(array, result) と書いたほうが DVF では遅かった
	do, i = 1, size(array)
	    result(i: i) = array(i)
	enddo
    end function

    function char_7array_to_char(array) result(result)
	character, intent(in)::		array(:, :, :, :, :, :, :)
	character(len = size(array))::	result
	integer::			i
    continue
	! 添字すべてについてループをまわすのは遅いし、明らかに読みにくい
	result = transfer(array, result)
    end function

    function char_to_char_7array(chars, d) result(result)
	character(len = *), intent(in)::	chars
	integer, intent(in)::			d(7)
	character:: result(d(1), d(2), d(3), d(4), d(5), d(6), d(7))
    continue
	result = reshape(transfer(chars, 'c', len(chars)), d, (/' '/))
    end function

end module
