f_sts_quantile Function

public impure function f_sts_quantile(x, p) result(q)

Impure wrapper for f_sts_quantile_core.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: x(:)

data vector (assumed size array)

real(kind=wp), intent(in) :: p

desired percentile

Return Value real(kind=wp)

quantile value


Calls

proc~~f_sts_quantile~~CallsGraph proc~f_sts_quantile f_sts_quantile proc~f_sts_quantile_core f_sts_quantile_core proc~f_sts_quantile->proc~f_sts_quantile_core proc~f_utl_assign_nan f_utl_assign_nan proc~f_sts_quantile->proc~f_utl_assign_nan proc~s_err_print s_err_print proc~f_sts_quantile->proc~s_err_print proc~s_utl_sort s_utl_sort proc~f_sts_quantile_core->proc~s_utl_sort proc~s_utl_sort->proc~f_utl_assign_nan

Called by

proc~~f_sts_quantile~~CalledByGraph proc~f_sts_quantile f_sts_quantile interface~fsml_quantile fsml_quantile interface~fsml_quantile->proc~f_sts_quantile

Source Code

impure function f_sts_quantile(x, p) result(q)

! ==== Description
!! Impure wrapper for `f_sts_quantile_core`.

! ==== Declarations
  real(wp)   , intent(in)  :: x(:) !! data vector (assumed size array)
  real(wp)   , intent(in)  :: p    !! desired percentile
  real(wp)                 :: q    !! quantile value

! ==== Instructions

! ---- handle input

  ! check if size is valid
  if (size(x) .le. 1) then
     ! write error message and assign NaN value if invalid
     call s_err_print(fsml_error(4))
     q = f_utl_assign_nan()
     return
  endif

  ! check if p value is valid
  if (p .gt. 1.0_wp .or. p .lt. 0.0_wp) then
     ! write error message and assign NaN value if invalid
     call s_err_print(fsml_error(1))
     q = f_utl_assign_nan()
     return
  endif

! ---- compute quantile value

  ! call pure function
  q = f_sts_quantile_core(x, p)

end function f_sts_quantile