    PROGRAM x04dafe

!      X04DAF Example Program Text

!      Mark 23 Release. NAG Copyright 2011.

!      .. Use Statements ..
       USE nag_library, ONLY : nag_wp, x04daf
!      .. Implicit None Statement ..
       IMPLICIT NONE
!      .. Parameters ..
       INTEGER, PARAMETER              :: nmax = 4, nout = 6
       INTEGER, PARAMETER              :: lda = nmax
!      .. Local Scalars ..
       REAL (KIND=nag_wp)              :: aa
       INTEGER                         :: i, ifail, j
!      .. Local Arrays ..
       COMPLEX (KIND=nag_wp)           :: a(lda,nmax)
!      .. Intrinsic Functions ..
       INTRINSIC                          cmplx, real
!      .. Executable Statements ..
       WRITE (nout,*) 'X04DAF Example Program Results'

       WRITE (nout,*)
       FLUSH (nout)

!      Generate an array of data

       DO j = 1, nmax

          DO i = 1, lda
             aa = real(10*i+j,kind=nag_wp)
             a(i,j) = cmplx(aa,-aa,kind=nag_wp)
          END DO

       END DO

!      Print nmax by (nmax-1) rectangular matrix

       ifail = 0
       CALL x04daf('General',' ',nmax,nmax-1,a,lda,'Example 1:',ifail)

       WRITE (nout,*)
       FLUSH (nout)

!      Print nmax by nmax lower triangular matrix

       ifail = 0
       CALL x04daf('Lower','Non-unit',nmax,nmax,a,lda,'Example 2:',ifail)

    END PROGRAM x04dafe
