f_dst_gamma_cdf Function

public impure function f_dst_gamma_cdf(x, alpha, beta, loc, tail) result(p)

Impure wrapper function for f_dst_gamma_cdf_core. Handles optional arguments and invalid values for arguments.

Arguments

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

sample position

real(kind=wp), intent(in), optional :: alpha

shape parameter

real(kind=wp), intent(in), optional :: beta

scale parameter

real(kind=wp), intent(in), optional :: loc

location parameter

character(len=*), intent(in), optional :: tail

tail options

Return Value real(kind=wp)

returned probability integral


Calls

proc~~f_dst_gamma_cdf~~CallsGraph proc~f_dst_gamma_cdf f_dst_gamma_cdf proc~f_dst_gamma_cdf_core f_dst_gamma_cdf_core proc~f_dst_gamma_cdf->proc~f_dst_gamma_cdf_core proc~s_err_print s_err_print proc~f_dst_gamma_cdf->proc~s_err_print proc~f_dst_gammai_core f_dst_gammai_core proc~f_dst_gamma_cdf_core->proc~f_dst_gammai_core proc~f_utl_r2c f_utl_r2c proc~s_err_print->proc~f_utl_r2c

Called by

proc~~f_dst_gamma_cdf~~CalledByGraph proc~f_dst_gamma_cdf f_dst_gamma_cdf interface~fsml_gamma_cdf fsml_gamma_cdf interface~fsml_gamma_cdf->proc~f_dst_gamma_cdf

Source Code

impure function f_dst_gamma_cdf(x, alpha, beta, loc, tail) result(p)

! ==== Description
!! Impure wrapper function for `f_dst_gamma_cdf_core`.
!! Handles optional arguments and invalid values for arguments.

! ==== Declarations
  real(wp)        , intent(in)           :: x       !! sample position
  real(wp)        , intent(in), optional :: alpha   !! shape  parameter
  real(wp)        , intent(in), optional :: beta    !! scale parameter
  real(wp)        , intent(in), optional :: loc     !! location parameter
  character(len=*), intent(in), optional :: tail    !! tail options
  real(wp)                               :: alpha_w !! final value for alpha
  real(wp)                               :: beta_w  !! final value for beta
  real(wp)                               :: loc_w   !! final value for loc
  character(len=16)                      :: tail_w  !! final tail option
  real(wp)                               :: z       !! standardised variable
  real(wp)                               :: p       !! returned probability integral

! ==== Instructions

! ---- handle input

  ! assume alpha = 1, overwrite if specified
  alpha_w = 1.0_wp
  if (present(alpha)) alpha_w = alpha

  ! assume beta = 1, overwrite if specified
  beta_w = 1.0_wp
  if (present(beta)) beta_w = beta

  ! assume loc = 0, overwrite if specified
  loc_w = 0.0_wp
  if (present(loc)) loc_w = loc

  ! assume left-tailed, overwrite if specified
  tail_w = "left"
  if (present(tail)) tail_w = tail

  ! check if alpha value is valid
  if (alpha_w .le. 0.0_wp) then
     ! write error message and assign sentinel value if invalid
     call s_err_print(fsml_error(1))
     p = c_sentinel_r
     return
  endif

  ! check if beta value is valid
  if (beta_w .le. 0.0_wp) then
     ! write error message and assign sentinel value if invalid
     call s_err_print(fsml_error(1))
     p = c_sentinel_r
     return
  endif

  ! check if tail options are valid
  if (tail_w .ne. "left" .and. tail_w .ne. "right" .and. &
     &tail_w .ne. "two" .and. tail_w .ne. "confidence") then
     ! write error message and assign sentinel value if invalid
     call s_err_print(fsml_error(2))
     p = c_sentinel_r
     return
  endif

! ---- compute CDF

  ! call pure function to calculate probability integral
  p = f_dst_gamma_cdf_core(x, alpha_w, beta_w, loc_w, tail_w)


end function f_dst_gamma_cdf