    PROGRAM f04aefe

!      F04AEF Example Program Text

!      Mark 23 Release. NAG Copyright 2011.

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

!      ifail: behaviour on error exit
!             =0 for hard exit, =1 for quiet-soft, =-1 for noisy-soft
       ifail = 0
       CALL f04aef(a,lda,b,ldb,n,m,c,ldc,wkspce,aa,ldaa,bb,ldbb,ifail)

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

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