NAG Library Manual, Mark 29.3
```    Program g03dbfe

!     G03DBF Example Program Text

!     Mark 29.3 Release. NAG Copyright 2023.

!     .. Use Statements ..
Use nag_library, Only: g03daf, g03dbf, nag_wp, x04caf
!     .. Implicit None Statement ..
Implicit None
!     .. Parameters ..
Integer, Parameter               :: nin = 5, nout = 6
!     .. Local Scalars ..
Real (Kind=nag_wp)               :: df, sig, stat
Integer                          :: i, ifail, ldd, ldgmn, ldox, ldx,     &
lgc, lwk, lwt, m, n, ng, nobs, nvar
Character (1)                    :: equal, mode, weight
!     .. Local Arrays ..
Real (Kind=nag_wp), Allocatable  :: d(:,:), det(:), gc(:), gmn(:,:),     &
ox(:,:), wk(:), wt(:), x(:,:)
Integer, Allocatable             :: ing(:), isx(:), iwk(:), nig(:)
!     .. Intrinsic Procedures ..
Intrinsic                        :: count, max
!     .. Executable Statements ..
Write (nout,*) 'G03DBF Example Program Results'
Write (nout,*)
Flush (nout)

!     Skip headings in data file

!     Read in the problem size
Read (nin,*) n, m, ng, weight

If (weight=='W' .Or. weight=='w') Then
lwt = n
Else
lwt = 0
End If
ldox = n
Allocate (ox(ldox,m),ing(n),wt(lwt),isx(m))

If (lwt>0) Then
Else
End If

!     Read in variable inclusion flags

!     Calculate NVAR
nvar = count(isx(1:m)==1)

ldgmn = ng
lgc = (ng+1)*nvar*(nvar+1)/2
lwk = max(n*(nvar+1),2*nvar)
Allocate (nig(ng),gmn(ldgmn,nvar),det(ng),gc(lgc),wk(lwk),iwk(ng))

!     Compute covariance matrix
ifail = 0
Call g03daf(weight,n,m,ox,ldox,isx,nvar,ing,ng,wt,nig,gmn,ldgmn,det,gc,  &
stat,df,sig,wk,iwk,ifail)

!     Read in size data from which to compute distances

If (mode=='S' .Or. mode=='s') Then
ldd = nobs
Else
nobs = 0
ldd = ng
End If

ldx = nobs
Allocate (x(ldx,m),d(ldd,ng))

!     Read in data from which to compute distances
If (nobs>0) Then