NAG Library Manual, Mark 29
```    Program g01tafe
!     G01TAF Example Program Text

!     Mark 29.0 Release. NAG Copyright 2023.

!     .. Use Statements ..
Use nag_library, Only: g01taf, nag_wp
!     .. Implicit None Statement ..
Implicit None
!     .. Parameters ..
Integer, Parameter               :: nin = 5, nout = 6
!     .. Local Scalars ..
Integer                          :: i, ifail, lout, lp, ltail, lxmu,     &
lxstd
!     .. Local Arrays ..
Real (Kind=nag_wp), Allocatable  :: p(:), x(:), xmu(:), xstd(:)
Integer, Allocatable             :: ivalid(:)
Character (1), Allocatable       :: tail(:)
!     .. Intrinsic Procedures ..
Intrinsic                        :: max, mod, repeat
!     .. Executable Statements ..
Write (nout,*) 'G01TAF Example Program Results'
Write (nout,*)

!     Skip heading in data file

!     Read in the input vectors
Allocate (tail(ltail))

Allocate (p(lp))

Allocate (xmu(lxmu))

Allocate (xstd(lxstd))

!     Allocate memory for output
lout = max(lp,ltail,lxmu,lxstd)
Allocate (x(lout),ivalid(lout))

!     Calculate the deviate (inverse CDF)
ifail = -1
Call g01taf(ltail,tail,lp,p,lxmu,xmu,lxstd,xstd,x,ivalid,ifail)

If (ifail==0 .Or. ifail==1) Then
!       Display titles
Write (nout,*)
Write (nout,*)                                                         &
'   TAIL      P        XMU      XSTD       X     IVALID'
Write (nout,*) repeat('-',56)

!       Display results
Do i = 1, lout
Write (nout,99999) tail(mod(i-1,ltail)+1), p(mod(i-1,lp)+1),         &
xmu(mod(i-1,lxmu)+1), xstd(mod(i-1,lxstd)+1), x(i), ivalid(i)
End Do
End If

99999 Format (5X,A1,4X,F6.3,2(4X,F6.3),3X,F7.3,4X,I3)
End Program g01tafe
```