```    Program g02gafe

!     G02GAF Example Program Text

!     Mark 27.0 Release. NAG Copyright 2019.

!     .. Use Statements ..
Use nag_library, Only: g02gaf, nag_wp
!     .. Implicit None Statement ..
Implicit None
!     .. Parameters ..
Integer, Parameter               :: nin = 5, nout = 6
!     .. Local Scalars ..
Real (Kind=nag_wp)               :: a, eps, rss, s, tol
Integer                          :: i, idf, ifail, ip, iprint, irank,    &
ldv, ldx, lwt, m, maxit, n
Character (1)                    :: link, mean, offset, weight
!     .. Local Arrays ..
Real (Kind=nag_wp), Allocatable  :: b(:), cov(:), se(:), v(:,:), wk(:),  &
wt(:), x(:,:), y(:)
Integer, Allocatable             :: isx(:)
!     .. Intrinsic Procedures ..
Intrinsic                        :: count
!     .. Executable Statements ..
Write (nout,*) 'G02GAF Example Program Results'
Write (nout,*)

!     Skip heading in data file

!     Read in the problem size

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

If (lwt>0) Then
Else
End If

!     Read in variable inclusion flags

!     Calculate IP
ip = count(isx(1:m)>0)
If (mean=='M' .Or. mean=='m') Then
ip = ip + 1
End If

End If

ldv = n
Allocate (b(ip),se(ip),cov(ip*(ip+1)/2),v(ldv,ip+7),wk((ip*ip+3*ip+      &
22)/2))

If (offset=='Y' .Or. offset=='y') Then
End If

Read (nin,*) iprint, eps, tol, maxit

!     Fit the generalized linear model with Normal errors
ifail = -1
irank,se,cov,v,ldv,tol,maxit,iprint,eps,wk,ifail)
If (ifail/=0) Then
If (ifail<6) Then
Go To 100
End If
End If

!     Display results
Write (nout,99999) 'Residual sum of squares     = ', rss
Write (nout,99998) ' Residual degrees of freedom = ', idf
Write (nout,*)
Write (nout,*) '      Estimate    Standard error'
Write (nout,*)
Write (nout,99997)(b(i),se(i),i=1,ip)
Write (nout,*)
Write (nout,*) '     Y        FV     Residual       H'
Write (nout,*)
Write (nout,99996)(y(i),v(i,2),v(i,5),v(i,6),i=1,n)

100   Continue

99999 Format (1X,A,E12.4)
99998 Format (1X,A,I2)
99997 Format (1X,2F14.4)
99996 Format (1X,F7.1,F10.2,F12.4,F10.3)
End Program g02gafe
```