    Program g01fffe

!     G01FFF Example Program Text

!     Mark 24 Release. NAG Copyright 2012.

!     .. Use Statements ..
      Use nag_library, Only: g01fff, nag_wp
!     .. Implicit None Statement ..
      Implicit None
!     .. Parameters ..
      Integer, Parameter               :: nin = 5, nout = 6
!     .. Local Scalars ..
      Real (Kind=nag_wp)               :: a, b, p, tol, x
      Integer                          :: ifail
!     .. Executable Statements ..
      Write (nout,*) 'G01FFF Example Program Results'
      Write (nout,*)

!     Skip heading in data file
      Read (nin,*)

!     Display titles
      Write (nout,*) '   P       A       B           X'
      Write (nout,*)

!     Use default tolerance
      tol = 0.0E0_nag_wp

d_lp: Do
        Read (nin,*,Iostat=ifail) p, a, b
        If (ifail/=0) Then
          Exit d_lp
        End If

!       Calculate deviates (inverse CDF)
        ifail = -1
        x = g01fff(p,a,b,tol,ifail)
        If (ifail/=0) Then
          If (ifail/=4 .And. ifail/=5) Then
            Exit d_lp
          End If
        End If

!       Display results
        Write (nout,99999) p, a, b, x
      End Do d_lp

99999 Format (1X,3F8.3,F10.3,A,I1)
    End Program g01fffe
