    PROGRAM x04cdfe

!      X04CDF Example Program Text

!      Mark 23 Release. NAG Copyright 2011.

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

       WRITE (nout,*)
       FLUSH (nout)

!      Generate an array of data

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

       ncols = 80
       indent = 0

!      Print order (namx-1) lower triangular matrix with default format and
!      integer row and column labels

       ifail = 0
       CALL x04cdf('Lower','Non-unit',nmax-1,a,' ','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

       ifail = 0
       CALL x04cdf('Upper','Unit',nmax,a,'F8.2','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 is ignored

       ifail = 0
       CALL x04cdf('Upper','Non-unit',nmax,a,'MATLABF8.2','A',' ',rlabs,' ', &
          clabs,ncols,indent,ifail)

    END PROGRAM x04cdfe
