```    Program g02hafe

!     G02HAF Example Program Text

!     Mark 27.0 Release. NAG Copyright 2019.

!     .. Use Statements ..
Use nag_library, Only: g02haf, nag_wp, x04abf
!     .. Implicit None Statement ..
Implicit None
!     .. Parameters ..
Integer, Parameter               :: iset = 1, nin = 5, nout = 6
!     .. Local Scalars ..
Real (Kind=nag_wp)               :: cpsi, cucv, dchi, h1, h2, h3, sigma, &
tol
Integer                          :: i, ifail, indc, indw, ipsi, isigma,  &
ldc, ldx, m, maxit, n, nadv, nitmon
!     .. Local Arrays ..
Real (Kind=nag_wp), Allocatable  :: c(:,:), rs(:), stat(:), theta(:),    &
wgt(:), x(:,:), y(:)
!     .. Executable Statements ..
Write (nout,*) 'G02HAF Example Program Results'
Write (nout,*)

!     Skip heading in data file

!     Read in the problem size

ldx = n
ldc = m
Allocate (x(ldx,m),y(n),theta(m),c(ldc,m),stat(4),rs(n),wgt(n))

Read (nin,*) indw, ipsi, isigma, nitmon, maxit, tol

!     Read in appropriate weight function parameters
If (indw/=0) Then
End If
If (ipsi>0) Then
If (ipsi==1) Then
Else If (ipsi==2) Then
End If
If (isigma>0) Then
End If
End If

!     Set the advisory channel to NOUT for monitoring information
If (nitmon/=0) Then
End If

!     Perform M-estimate regression
ifail = -1
Call g02haf(indw,ipsi,isigma,indc,n,m,x,ldx,y,cpsi,h1,h2,h3,cucv,dchi,   &
theta,sigma,c,ldc,rs,wgt,tol,maxit,nitmon,stat,ifail)
If (ifail/=0) Then
If (ifail<7) Then
Go To 100
Else
Write (nout,*)                                                       &
'       Some of the following results may be unreliable'
End If
End If

!     Display results
Write (nout,99999) 'Sigma = ', sigma
Write (nout,*)
Write (nout,*) '       THETA      Standard'
Write (nout,*) '                   errors'
Write (nout,99998)(theta(i),c(i,i),i=1,m)
Write (nout,*)
Write (nout,*) '     Weights     Residuals'
Write (nout,99998)(wgt(i),rs(i),i=1,n)

100   Continue

99999 Format (1X,A,F10.4)
99998 Format (1X,F12.4,F13.4)
End Program g02hafe
```