fdoc

subroutineadd_symbolprivate

subroutine add_symbol(list, name, id)

Add name for entity id to list, replacing any entity it has.

Arguments

NameTypeIntentAttributesDescription
listtype(symbol_list_t)inout

the names

namecharacter(len=*)in

the name

idintegerin

the entity

Calls

Source

Show the code
subroutine add_symbol(list, name, id)
    type(symbol_list_t), intent(inout) :: list  !! the names
    character(len=*), intent(in) :: name        !! the name
    integer, intent(in) :: id                   !! the entity
    type(symbol_t), allocatable :: grown(:)
    integer :: k, at

    at = index_find(list%index, name)
    if (at > 0) then
        list%s(at)%id = id
        return
    end if
    if (list%n == size(list%s)) then
        allocate (grown(2*list%n))
        do k = 1, list%n
            call move_alloc(list%s(k)%name, grown(k)%name)
            grown(k)%id = list%s(k)%id
        end do
        call move_alloc(grown, list%s)
    end if
    list%n = list%n + 1
    list%s(list%n)%name = name
    list%s(list%n)%id = id
    call index_set(list%index, name, list%n)
end subroutine add_symbol

Graphs

Calls

Called by