string_cat Function

public function string_cat(strings, delim) result(cat)

Concatenate an array of type(string_t) into a single CHARACTER variable

Arguments

Type IntentOptional Attributes Name
type(string_t), intent(in) :: strings(:)
character(len=*), intent(in), optional :: delim

Return Value character(len=:), allocatable


Source Code

function string_cat(strings,delim) result(cat)
    type(string_t), intent(in) :: strings(:)
    character(*), intent(in), optional :: delim
    character(:), allocatable :: cat

    integer :: i
    character(:), allocatable :: delim_str

    if (size(strings) < 1) then
        cat = ''
        return
    end if

    if (present(delim)) then
        delim_str = delim
    else
        delim_str = ''
    end if

    cat = strings(1)%s
    do i=2,size(strings)

        cat = cat//delim_str//strings(i)%s

    end do

end function string_cat