NAG Library Manual, Mark 28.3
Interfaces:  FL   CL   CPP   AD 

NAG FL Interface Introduction
Example description
    Program g01fefe

!     G01FEF Example Program Text

!     Mark 28.3 Release. NAG Copyright 2022.

!     .. Use Statements ..
      Use nag_library, Only: g01fef, 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,*) 'G01FEF Example Program Results'
      Write (nout,*)

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

!     Display titles
      Write (nout,*) ' Probability     A         B     Deviate'
      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 = g01fef(p,a,b,tol,ifail)
        If (ifail/=0) Then
          If (ifail/=3 .And. ifail/=4) Then
            Exit d_lp
          End If
        End If

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

99999 Format (1X,F9.4,2F10.3,F10.4,A,I1)
    End Program g01fefe