get_toml_real_scalar_or_array3 Subroutine

public subroutine get_toml_real_scalar_or_array3(table, key, value, value_len, context)

Arguments

Type IntentOptional Attributes Name
type(toml_table), intent(inout) :: table
type(toml_key), intent(in) :: key
real(kind=dp), intent(out) :: value(3)
integer(kind=i32), intent(out) :: value_len
character(len=*), intent(in) :: context

Calls

proc~~get_toml_real_scalar_or_array3~~CallsGraph proc~get_toml_real_scalar_or_array3 get_toml_real_scalar_or_array3 get_value get_value proc~get_toml_real_scalar_or_array3->get_value proc~require_toml_success require_toml_success proc~get_toml_real_scalar_or_array3->proc~require_toml_success proc~stop_config_error stop_config_error proc~get_toml_real_scalar_or_array3->proc~stop_config_error toml_len toml_len proc~get_toml_real_scalar_or_array3->toml_len proc~require_toml_success->proc~stop_config_error

Source Code

  subroutine get_toml_real_scalar_or_array3(table, key, value, value_len, context)
    type(toml_table), intent(inout) :: table
    type(toml_key), intent(in) :: key
    real(dp), intent(out) :: value(3)
    integer(i32), intent(out) :: value_len
    character(len=*), intent(in) :: context
    type(toml_array), pointer :: array
    real(dp) :: scalar_value
    integer :: i, n, stat

    value = 0.0d0
    value_len = 0_i32
    call get_value(table, key, scalar_value, stat=stat)
    if (stat == toml_stat%success) then
      if (.not. ieee_is_finite(scalar_value)) call stop_config_error(trim(context)//' must be finite.')
      value(1) = scalar_value
      value_len = 1_i32
      return
    end if

    nullify (array)
    call get_value(table, key, array, stat=stat)
    call require_toml_success(stat, context)
    if (.not. associated(array)) call stop_config_error('Invalid TOML value for '//trim(context)//'.')
    n = toml_len(array)
    if (n < 1 .or. n > 3) then
      call stop_config_error(trim(context)//' must be a number or an array of 1 to 3 numbers.')
    end if
    do i = 1, n
      call get_value(array, i, value(i), stat=stat)
      call require_toml_success(stat, context)
      if (.not. ieee_is_finite(value(i))) call stop_config_error(trim(context)//' must contain finite values.')
    end do
    value_len = int(n, i32)
  end subroutine get_toml_real_scalar_or_array3