    PROGRAM f01zcfe

!      F01ZCF Example Program Text

!      Mark 23 Release. NAG Copyright 2011.

!      .. Use Statements ..
       USE nag_library, ONLY : f01zcf, nag_wp, x04caf
!      .. Implicit None Statement ..
       IMPLICIT NONE
!      .. Parameters ..
       INTEGER, PARAMETER              :: nin = 5, nout = 6
!      .. Local Scalars ..
       INTEGER                         :: i, ifail, kl, ku, lda, ldb, m, n
!      .. Local Arrays ..
       REAL (KIND=nag_wp), ALLOCATABLE :: a(:,:), b(:,:)
!      .. Executable Statements ..
       WRITE (nout,*) 'F01ZCF Example Program Results'
!      Skip heading in data file
       READ (nin,*)
       WRITE (nout,*)
       FLUSH (nout)
       READ (nin,*) m, n, kl, ku
       lda = n
       ldb = lda
       ALLOCATE (a(lda,n),b(ldb,n))
!      Read a banded matrix of size m by n. kl is the number of
!      sub-diagonals, ku the number of super-diagonals.
       DO i = 1, n
          READ (nin,*) a(i,1:n)
       END DO
!      Clear the packed matrix array B, so that no elements are
!      unassigned when we print B later.
       b(1:(kl+ku+1),1:n) = 0.0E+0_nag_wp
!      ifail: behaviour on error exit
!             =0 for hard exit, =1 for quiet-soft, =-1 for noisy-soft
       ifail = 0
!      Print the unpacked matrix
       CALL x04caf('G','X',n,n,a,lda,'Unpacked Matrix A:',ifail)

       WRITE (nout,*)
       FLUSH (nout)

!      Convert to packed matrix form
       ifail = 0
       CALL f01zcf('Pack',m,n,kl,ku,a,lda,b,ldb,ifail)

!      Print the packed matrix
       ifail = 0
       CALL x04caf('G','X',kl+ku+1,n,b,ldb,'Packed Matrix B:',ifail)

    END PROGRAM f01zcfe
