    Program f05aafe

!     F05AAF Example Program Text

!     Mark 24 Release. NAG Copyright 2012.

!     .. 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
