```    Program g02eafe

!     G02EAF Example Program Text

!     Mark 27.0 Release. NAG Copyright 2019.

!     .. Use Statements ..
Use nag_library, Only: g02eaf, nag_wp
!     .. Implicit None Statement ..
Implicit None
!     .. Parameters ..
Integer, Parameter               :: nin = 5, nout = 6, vnlen = 3
!     .. Local Scalars ..
Integer                          :: i, ifail, k, ldmodl, ldx, lwt, m, n, &
nmod
Character (1)                    :: mean, weight
!     .. Local Arrays ..
Real (Kind=nag_wp), Allocatable  :: rss(:), wk(:), wt(:), x(:,:), y(:)
Integer, Allocatable             :: isx(:), mrank(:), nterms(:)
Character (vnlen), Allocatable   :: modl(:,:), vname(:)
!     .. Intrinsic Procedures ..
Intrinsic                        :: count, max
!     .. Executable Statements ..
Write (nout,*) 'G02EAF Example Program Results'
Write (nout,*)

!     Skip heading in data file

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

If (weight=='W' .Or. weight=='w') Then
lwt = n
Else
lwt = 0
End If
ldx = n
Allocate (x(ldx,m),vname(m),isx(m),y(n),wt(lwt))

!     Read in data
If (lwt>0) Then
Else
End If

!     Read in variable inclusion flags

!     Read in first VNLEN characters of the variable names

!     Calculate the number of free variables
k = count(isx(1:m)==1)

ldmodl = max(m,2**k)
m+1)))

!     Calculate residual sums of squares for all possible models
ifail = 0