    PROGRAM f04atfe

!      F04ATF Example Program Text

!      Mark 23 Release. NAG Copyright 2011.

!      .. Use Statements ..
       USE nag_library, ONLY : f04atf, nag_wp
!      .. Implicit None Statement ..
       IMPLICIT NONE
!      .. Parameters ..
       INTEGER, PARAMETER              :: nin = 5, nout = 6
!      .. Local Scalars ..
       INTEGER                         :: i, ifail, lda, ldaa, n
!      .. Local Arrays ..
       REAL (KIND=nag_wp), ALLOCATABLE :: a(:,:), aa(:,:), b(:), c(:),         &
                                          wks1(:), wks2(:)
!      .. Executable Statements ..
       WRITE (nout,*) 'F04ATF Example Program Results'
       WRITE (nout,*)
!      Skip heading in data file
       READ (nin,*)
       READ (nin,*) n
       lda = n
       ldaa = n
       ALLOCATE (a(lda,n),aa(ldaa,n),b(n),c(n),wks1(n),wks2(n))
       READ (nin,*) (a(i,1:n),i=1,n), b(1:n)

!      ifail: behaviour on error exit
!             =0 for hard exit, =1 for quiet-soft, =-1 for noisy-soft
       ifail = 0
       CALL f04atf(a,lda,b,n,c,aa,ldaa,wks1,wks2,ifail)

       WRITE (nout,*) ' Solution'
       WRITE (nout,99999) c(1:n)

99999  FORMAT (1X,F9.4)
    END PROGRAM f04atfe
