NAG Library Manual, Mark 28.5
```    Program g02ecfe

!     G02ECF Example Program Text

!     Mark 28.5 Release. NAG Copyright 2022.

!     .. Use Statements ..
Use nag_library, Only: g02eaf, g02ecf, nag_wp
!     .. Implicit None Statement ..
Implicit None
!     .. Parameters ..
Integer, Parameter               :: nin = 5, nout = 6, vnlen = 3
!     .. Local Scalars ..
Real (Kind=nag_wp)               :: sigsq, tss
Integer                          :: i, ifail, k, ldmodl, ldx, lwt, m, n, &
nmod
Character (1)                    :: mean, weight
!     .. Local Arrays ..
Real (Kind=nag_wp), Allocatable  :: cp(:), rsq(:), rss(:), wk(:), wt(:), &
x(:,:), y(:)
Integer, Allocatable             :: isx(:), mrank(:), nterms(:)
Character (vnlen), Allocatable   :: modl(:,:), vname(:)
!     .. Intrinsic Procedures ..
Intrinsic                        :: count, max, real
!     .. Executable Statements ..
Write (nout,*) 'G02ECF 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),wt(lwt),y(n),isx(m),vname(m))

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
ifail = 0
nterms,mrank,wk,ifail)

!     Extract total sums of squares

!     Calculate best estimate of true variance from full model

Allocate (rsq(nmod),cp(nmod))

!     Calculate R-squared and Mallows Cp
ifail = 0