Return the index of the variable with name 'var_name', or -1 if not found.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(CFG_t), | intent(in) | :: | cfg | |||
| character(len=*), | intent(in) | :: | var_name | |||
| integer, | intent(out) | :: | ix |
subroutine get_var_index(cfg, var_name, ix) type(CFG_t), intent(in) :: cfg character(len=*), intent(in) :: var_name integer, intent(out) :: ix integer :: i if (cfg%sorted) then call binary_search_variable(cfg, var_name, ix) else ! Linear search do i = 1, cfg%num_vars if (cfg%vars(i)%var_name == var_name) exit end do ! If not found, set i to -1 if (i == cfg%num_vars + 1) i = -1 ix = i end if end subroutine get_var_index