fdoc

subroutinepush

subroutine push(list, s)

Append s to list, allocating it if needed.

Arguments

NameTypeIntentAttributesDescription
listtype(string_t)inoutallocatabledimension(:)

the list

scharacter(len=*)in

the string to append

Source

Show the code
subroutine push(list, s)
    type(string_t), allocatable, intent(inout) :: list(:)   !! the list
    character(len=*), intent(in) :: s                       !! the string to append
    type(string_t), allocatable :: tmp(:)
    integer :: n, k

    n = 0
    if (allocated(list)) n = size(list)
    allocate (tmp(n + 1))
    do k = 1, n
        call move_alloc(list(k)%s, tmp(k)%s)
    end do
    tmp(n + 1)%s = s
    call move_alloc(tmp, list)
end subroutine push

Graphs

Called by