array_conv Subroutine

public subroutine array_conv(list, name, conv)

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: list
character(len=*), intent(in) :: name
integer, intent(out) :: conv(:)

Called by

proc~~array_conv~~CalledByGraph proc~array_conv array_conv proc~fslink_init_part2 FSlink_init_part2 proc~fslink_init_part2->proc~array_conv program~reims_p reims_p program~reims_p->proc~fslink_init_part2

Source Code

subroutine array_conv(list,name,conv)
    character(len=*), intent(in) :: list,name
    integer, intent(out) :: conv(:)

    integer :: name_pos, colon_pos, end_pos, i, idx, position, num, next_comma
    character(:), allocatable :: value_str

    name_pos = index(list, trim(name))
    colon_pos = index(list(name_pos:), ':') + name_pos - 1
    end_pos = index(list(colon_pos+1:), ' ')
    if (end_pos == 0) then
        end_pos = len(list)+1
    else
        end_pos = colon_pos + end_pos
    end if
    value_str = list(colon_pos+1:end_pos-1)   

    conv = 0
    idx = 1
    position = 1
    do
        read(value_str(position:), '(I5)', iostat=i) num
        if (i /= 0) exit
        if (num <= size(conv)) conv(num) = idx
        idx = idx + 1
        next_comma = index(value_str(position:), ',')
        if (next_comma == 0) exit
        position = next_comma + position
        if (position == 1) exit
    end do

end subroutine array_conv