    PROGRAM nag_f_dist_ex01

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

      ! .. Use Statements ..
      USE nag_examples_io, ONLY : nag_std_out, nag_std_in
      USE nag_f_dist, ONLY : nag_f_prob, nag_f_deviate
      ! .. Implicit None Statement ..
      IMPLICIT NONE
      ! .. Intrinsic Functions ..
      INTRINSIC KIND
      ! .. Parameters ..
      INTEGER, PARAMETER :: wp = KIND(1.0D0)
      ! .. Local Scalars ..
      REAL (wp) :: df1, df2, f, f_calculated, prob, probl
      CHARACTER (1) :: tail
      ! .. Executable Statements ..
      WRITE (nag_std_out,*) 'Example Program Results for nag_f_dist_ex01'

      READ (nag_std_in,*)          ! Skip heading in data file

      WRITE (nag_std_out,*)
      WRITE (nag_std_out,*) 'TAIL    F      DF1     DF2      PROB     DEVIATE'
      WRITE (nag_std_out,*)

      DO
        READ (nag_std_in,*,end=20) tail, f, df1, df2

        prob = nag_f_prob(tail,f,df1,df2)

        probl = prob
        IF (tail=='u' .OR. tail=='U') probl = 1.0_wp - prob

        f_calculated = nag_f_deviate(probl,df1,df2)

        WRITE (nag_std_out,'(2x,A1,3x,F6.3,2F8.3,2F10.4)') tail, f, df1, df2, &
         prob, f_calculated
      END DO
20    CONTINUE

    END PROGRAM nag_f_dist_ex01
