LT_create_from_data Function

public function LT_create_from_data(x_min, x_max, spaced_data) result(my_lt)

This function returns a new lookup table from regularly spaced data

Arguments

Type IntentOptional Attributes Name
real(kind=dp), intent(in) :: x_min

Minimum coordinate

real(kind=dp), intent(in) :: x_max

Maximum coordinate

real(kind=dp), intent(in) :: spaced_data(:,:)

Input data of shape (n_points, n_cols)

Return Value type(LT_t)


Source Code

  function LT_create_from_data(x_min, x_max, spaced_data) result(my_lt)
    real(dp), intent(in) :: x_min
    !< Minimum coordinate
    real(dp), intent(in) :: x_max
    !< Maximum coordinate
    real(dp), intent(in) :: spaced_data(:, :)
    !< Input data of shape (n_points, n_cols)
    integer              :: n_points, n_cols
    type(LT_t)           :: my_lt

    n_points = size(spaced_data, 1)
    n_cols   = size(spaced_data, 2)

    if (x_max <= x_min) stop "LT_create error: x_max <= x_min"
    if (n_points <= 1) stop "LT_create error: n_points <= 1"

    my_lt%n_cols   = n_cols
    my_lt%n_points = n_points
    my_lt%x_min    = x_min
    my_lt%dx       = (x_max - x_min) / (n_points - 1)
    my_lt%inv_dx   = 1 / my_lt%dx

    my_lt%rows_cols = spaced_data
    my_lt%cols_rows = transpose(spaced_data)
  end function LT_create_from_data