    PROGRAM x04ddfe

!      X04DDF Example Program Text

!      Mark 23 Release. NAG Copyright 2011.

!      .. Use Statements ..
       USE nag_library, ONLY : nag_wp, x04ddf
!      .. Implicit None Statement ..
       IMPLICIT NONE
!      .. Parameters ..
       INTEGER, PARAMETER              :: nmax = 4, nout = 6
       INTEGER, PARAMETER              :: la = (nmax*(nmax+1))/2
       CHARACTER (7), PARAMETER        :: clabs(nmax) = (/  'Un     ',         &
                                          'Deux   ',  'Trois  ',  'Quatre '  /)
       CHARACTER (7), PARAMETER        :: rlabs(nmax) = (/  'Uno    ',         &
                                          'Due    ',  'Tre    ',  'Quattro'  /)
!      .. Local Scalars ..
       REAL (KIND=nag_wp)              :: aa
       INTEGER                         :: i, ifail, indent, ncols
       CHARACTER (19)                  :: form
!      .. Local Arrays ..
       COMPLEX (KIND=nag_wp)           :: a(la)
!      .. Intrinsic Functions ..
       INTRINSIC                          cmplx, real
!      .. Executable Statements ..
       WRITE (nout,*) 'X04DDF Example Program Results'

       WRITE (nout,*)
       FLUSH (nout)

!      Generate an array of data

       DO i = 1, la
          aa = real(i,kind=nag_wp)
          a(i) = cmplx(aa,-aa,kind=nag_wp)
       END DO

       ncols = 80
       indent = 0

!      Print order nmax lower triangular matrix with default format and
!      integer row and column labels, and bracketed complex elements

       form = ' '

       ifail = 0
       CALL x04ddf('Lower','Non-unit',nmax,a,'Bracketed',form,'Example 1:', &
          'Integer',rlabs,'Integer',clabs,ncols,indent,ifail)

       WRITE (nout,*)
       FLUSH (nout)

!      Print order nmax upper triangular matrix with user-supplied format
!      and row and column labels, using the supplied format directly

       form = 'SS,F7.1,SP,F6.1,''i'''

       ifail = 0
       CALL x04ddf('Upper','Unit',nmax,a,'Direct',form,'Example 2:', &
          'Character',rlabs,'Character',clabs,ncols,indent,ifail)

       WRITE (nout,*)
       FLUSH (nout)

!      Print order nmax upper triangular matrix in MATLAB format
!      Row and column labelling and USEFRM are ignored

       form = 'MATLABF8.2'

       ifail = 0
       CALL x04ddf('Upper','Non-unit',nmax,a,' ',form,'A',' ',rlabs,' ',clabs, &
          ncols,indent,ifail)

    END PROGRAM x04ddfe
