fdoc

subroutineread_targetsprivate

subroutine read_targets(c, text, targets, next)

Read the names separated by commas at the start of text.

Arguments

NameTypeIntentAttributesDescription
ctype(fypp_t)inout

the state

textcharacter(len=*)in

the text

targetsintegeroutallocatabledimension(:)

the names

nextintegerout

the position after them

Calls

Source

Show the code
subroutine read_targets(c, text, targets, next)
    type(fypp_t), intent(inout) :: c                !! the state
    character(len=*), intent(in) :: text            !! the text
    integer, allocatable, intent(out) :: targets(:) !! the names
    integer, intent(out) :: next                    !! the position after them
    integer :: at, start, id
    logical :: bracket

    allocate (targets(0))
    at = skip_blanks(text, 1)
    bracket = .false.
    if (at <= len(text)) then
        if (text(at:at) == '(') then
            bracket = .true.
            at = skip_blanks(text, at + 1)
        end if
    end if
    do
        start = at
        do while (at <= len(text))
            if (.not. in_name(text(at:at))) exit
            at = at + 1
        end do
        if (at == start) then
            call fail(c, 'cannot read the variables in: '//text)
            exit
        end if
        call intern(c, text(start:at - 1), id)
        call push_id(targets, id)
        at = skip_blanks(text, at)
        if (at > len(text)) exit
        if (text(at:at) /= ',') exit
        at = skip_blanks(text, at + 1)
    end do
    if (bracket .and. at <= len(text)) then
        if (text(at:at) == ')') at = skip_blanks(text, at + 1)
    end if
    next = at
end subroutine read_targets

Graphs

Calls

Called by