    PROGRAM x04dffe

!      X04DFF Example Program Text

!      Mark 23 Release. NAG Copyright 2011.

!      .. Use Statements ..
       USE nag_library, ONLY : nag_wp, x04dff
!      .. Implicit None Statement ..
       IMPLICIT NONE
!      .. Parameters ..
       INTEGER, PARAMETER              :: nmax = 5, nout = 6
       INTEGER, PARAMETER              :: lda = nmax
       CHARACTER (7), PARAMETER        :: clabs(nmax) = (/  'Un     ',         &
                                          'Deux   ',  'Trois  ',  'Quatre ',   &
                                          'Cinq   '  /)
       CHARACTER (7), PARAMETER        :: rlabs(nmax) = (/  'Uno    ',         &
                                          'Due    ',  'Tre    ',  'Quattro',   &
                                          'Cinque '  /)
!      .. Local Scalars ..
       REAL (KIND=nag_wp)              :: aa
       INTEGER                         :: i, ifail, indent, j, ncols
       CHARACTER (19)                  :: form
!      .. Local Arrays ..
       COMPLEX (KIND=nag_wp)           :: a(lda,lda)
!      .. Intrinsic Functions ..
       INTRINSIC                          cmplx, real
!      .. Executable Statements ..
       WRITE (nout,*) 'X04DFF 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

       ncols = 80
       indent = 0

!      Print nmax by nmax band matrix with 1 sub-diagonal, 1 super-diagonal,
!      default format, bracketed complex numbers, and integer row and
!      column labels

       form = ' '

       ifail = 0
       CALL x04dff(nmax,nmax,1,1,a,lda,'Bracketed',form,'Example 1:', &
          'Integer',rlabs,'Integer',clabs,ncols,indent,ifail)

       WRITE (nout,*)
       FLUSH (nout)

!      Print (nmax-1) by (nmax-1) band matrix with 1 sub-diagonal,
!      2 super-diagonals, user-supplied format and row and column labels.

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

       ifail = 0
       CALL x04dff(nmax-1,nmax-1,1,2,a,lda,'Direct',form,'Example 2:', &
          'Character',rlabs,'Character',clabs,ncols,indent,ifail)

       WRITE (nout,*)
       FLUSH (nout)

!      Print (nmax-1) by (nmax-1) band matrix with 1 sub-diagonal,
!      2 super-diagonals, in MATLAB format.
!      Row and column labelling and USEFRM are ignored.

       form = 'MATLABF7.1'

       ifail = 0
       CALL x04dff(nmax-1,nmax-1,1,2,a,lda,' ',form,'A',' ',rlabs,' ',clabs, &
          ncols,indent,ifail)

    END PROGRAM x04dffe
