    PROGRAM nag_t_dist_ex01

      ! Example Program Text for nag_t_dist
      ! NAG fl90, Release 4. NAG Copyright 2000.

      ! .. Use Statements ..
      USE nag_examples_io, ONLY : nag_std_out
      USE nag_t_dist, ONLY : nag_t_prob, nag_t_deviate
      ! .. Implicit None Statement ..
      IMPLICIT NONE
      ! .. Intrinsic Functions ..
      INTRINSIC KIND
      ! .. Parameters ..
      INTEGER, PARAMETER :: wp = KIND(1.0D0)
      ! .. Local Scalars ..
      INTEGER :: i
      REAL (wp) :: df, prob, t, t_calculated
      ! .. Local Arrays ..
      CHARACTER (1) :: tail(4)
      ! .. Executable Statements ..
      WRITE (nag_std_out,*) 'Example Program Results for nag_t_dist_ex01'

      WRITE (nag_std_out,*)
      WRITE (nag_std_out,*) 'TAIL    T      DF     PROB      DEVIATE'
      WRITE (nag_std_out,*)

      t = 0.85_wp
      df = 10.0_wp
      tail = (/ 'L', 'S', 'C', 'U'/)

      DO i = 1, 4

        prob = nag_t_prob(tail(i),t,df)
        t_calculated = nag_t_deviate(tail(i),prob,df)

        WRITE (nag_std_out,'(2X,A,4x,F6.3,F8.3,F8.4,f10.4)') tail(i), t, df, &
         prob, t_calculated
      END DO

    END PROGRAM nag_t_dist_ex01
