check_if_conversion_required Subroutine

public subroutine check_if_conversion_required(list, name, conversion_required, max_value)

Arguments

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

Calls

proc~~check_if_conversion_required~~CallsGraph proc~check_if_conversion_required check_if_conversion_required proc~count_chars count_chars proc~check_if_conversion_required->proc~count_chars

Called by

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

Source Code

subroutine check_if_conversion_required(list,name,conversion_required,max_value)
    character(len=*), intent(in) :: list,name
    logical, intent(out) :: conversion_required
    integer, intent(out) :: max_value

    integer :: name_pos, colon_pos, end_pos, num_commas, str_len, i, num_count, pos, start, length
    character(:), allocatable :: value_str
    integer, allocatable :: aa(:)
    
    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)
    conversion_required = (trim(value_str) /= '0')

    max_value=0
    if(conversion_required) then
        start = 1
        pos = 0
        length = len_trim(value_str)
        num_count = count_chars(value_str, ',') + 1
        allocate(aa(num_count))
    
        do i = 1, num_count
            pos = scan(value_str(start:length), ',')
            if (pos == 0) then
                read(value_str(start:length), *) aa(i)
            else
                read(value_str(start:start + pos - 2), *) aa(i)
                start = start + pos
            end if
        end do
        max_value=maxval(aa)
    endif

end subroutine check_if_conversion_required