Get a location in the lookup table
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(LT_t), | intent(in) | :: | my_lt | |||
| real(kind=dp), | intent(in) | :: | x |
elemental function LT_get_loc(my_lt, x) result(my_loc) type(LT_t), intent(in) :: my_lt real(dp), intent(in) :: x type(LT_loc_t) :: my_loc real(dp) :: frac frac = (x - my_lt%x_min) * my_lt%inv_dx my_loc%low_ix = ceiling(frac) my_loc%low_frac = my_loc%low_ix - frac ! Check bounds if (my_loc%low_ix < 1) then my_loc%low_ix = 1 my_loc%low_frac = 1 else if (my_loc%low_ix >= my_lt%n_points) then my_loc%low_ix = my_lt%n_points - 1 my_loc%low_frac = 0 end if end function LT_get_loc