    PROGRAM f05aafe

!      F05AAF Example Program Text

!      Mark 23 Release. NAG Copyright 2011.

!      .. Use Statements ..
       USE nag_library, ONLY : f05aaf, nag_wp
!      .. Implicit None Statement ..
       IMPLICIT NONE
!      .. Parameters ..
       INTEGER, PARAMETER              :: nin = 5, nout = 6
!      .. Local Scalars ..
       REAL (KIND=nag_wp)              :: cc
       INTEGER                         :: i, icol, ifail, lda, m, n1, n2
!      .. Local Arrays ..
       REAL (KIND=nag_wp), ALLOCATABLE :: a(:,:), s(:)
!      .. Executable Statements ..
       WRITE (nout,*) 'F05AAF Example Program Results'

!      Skip heading in data file
       READ (nin,*)

       READ (nin,*) m, n1, n2
       lda = m
       ALLOCATE (a(lda,n2),s(n2))

       READ (nin,*) (a(i,1:n2),i=1,m)

       ifail = 0
       CALL f05aaf(a,lda,m,n1,n2,s,cc,icol,ifail)

       WRITE (nout,*)
       WRITE (nout,99999) 'N1 = ', n1, '  N2 = ', n2
       WRITE (nout,*)
       WRITE (nout,99998) 'CC = ', cc, ' ICOL = ', icol
       WRITE (nout,*)
       WRITE (nout,*) 'Final vectors'
       WRITE (nout,99997) (a(i,n1:n2),i=1,m)

99999  FORMAT (1X,A,I2,A,I2)
99998  FORMAT (1X,A,F7.4,A,I2)
99997  FORMAT (1X,3F9.4)
    END PROGRAM f05aafe
