fdoc

subroutinepush_intpure

pure subroutine push_int(list, value)

Append value to list, allocating it if needed.

Arguments

NameTypeIntentAttributesDescription
listintegerinoutallocatabledimension(:)

the list

valueintegerin

the value to append

Source

Show the code
pure subroutine push_int(list, value)
    integer, allocatable, intent(inout) :: list(:)  !! the list
    integer, intent(in) :: value                    !! the value to append
    integer, allocatable :: grown(:)
    integer :: n

    n = 0
    if (allocated(list)) n = size(list)
    allocate (grown(n + 1))
    if (n > 0) grown(1:n) = list
    grown(n + 1) = value
    call move_alloc(grown, list)
end subroutine push_int

Graphs

Called by