interpolate_profile_value Function

public function interpolate_profile_value(x_nodes, y_nodes, x_query) result(y_query)

Arguments

Type IntentOptional Attributes Name
real(kind=dp), intent(in) :: x_nodes(:)
real(kind=dp), intent(in) :: y_nodes(:)
real(kind=dp), intent(in) :: x_query

Return Value real(kind=dp)


Called by

proc~~interpolate_profile_value~~CalledByGraph proc~interpolate_profile_value interpolate_profile_value proc~sample_monotonic_phi_hat_at_z sample_monotonic_phi_hat_at_z proc~sample_monotonic_phi_hat_at_z->proc~interpolate_profile_value proc~sample_type_a_phi_hat_at_z sample_type_a_phi_hat_at_z proc~sample_type_a_phi_hat_at_z->proc~interpolate_profile_value proc~sample_zhao_state_at_z sample_zhao_state_at_z proc~sample_zhao_state_at_z->proc~sample_monotonic_phi_hat_at_z proc~sample_zhao_state_at_z->proc~sample_type_a_phi_hat_at_z proc~sample_zhao_reservoir_state sample_zhao_reservoir_state proc~sample_zhao_reservoir_state->proc~sample_zhao_state_at_z proc~resolve_sheath_injection_context resolve_sheath_injection_context proc~resolve_sheath_injection_context->proc~sample_zhao_reservoir_state proc~init_particle_batch_from_config init_particle_batch_from_config proc~init_particle_batch_from_config->proc~resolve_sheath_injection_context

Source Code

  real(dp) function interpolate_profile_value(x_nodes, y_nodes, x_query) result(y_query)
    real(dp), intent(in) :: x_nodes(:), y_nodes(:), x_query

    integer :: i
    real(dp) :: t

    if (size(x_nodes) /= size(y_nodes)) error stop 'Interpolation node size mismatch.'
    if (x_query <= x_nodes(1)) then
      y_query = y_nodes(1)
      return
    end if
    do i = 2, size(x_nodes)
      if (x_query <= x_nodes(i)) then
        t = (x_query - x_nodes(i - 1))/max(x_nodes(i) - x_nodes(i - 1), tiny(1.0d0))
        y_query = (1.0d0 - t)*y_nodes(i - 1) + t*y_nodes(i)
        return
      end if
    end do
    y_query = y_nodes(size(y_nodes))
  end function interpolate_profile_value