    PROGRAM x04cafe

!      X04CAF Example Program Text

!      Mark 23 Release. NAG Copyright 2011.

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

       WRITE (nout,*)
       FLUSH (nout)

!      Generate an array of data

       DO j = 1, nmax

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

       END DO

!      Print 3 by nmax rectangular matrix

       ifail = 0
       CALL x04caf('General',' ',3,nmax,a,lda,'Example 1:',ifail)

       WRITE (nout,*)
       FLUSH (nout)

!      Print nmax by nmax lower triangular matrix

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

    END PROGRAM x04cafe
