    PROGRAM f16rbfe

!      F16RBF Example Program Text

!      Mark 23 Release. NAG Copyright 2011.

!      .. Use Statements ..
       USE nag_library, ONLY : f01zcf, f16rbf, nag_frobenius_norm,             &
                               nag_inf_norm, nag_max_norm, nag_one_norm, nag_wp
!      .. Implicit None Statement ..
       IMPLICIT NONE
!      .. Parameters ..
       INTEGER, PARAMETER              :: nin = 5, nout = 6
!      .. Local Scalars ..
       REAL (KIND=nag_wp)              :: r_fro, r_inf, r_max, r_one
       INTEGER                         :: i, ifail, j, kl, ku, lda, ldab, m, n
       CHARACTER (1)                   :: job
!      .. Local Arrays ..
       REAL (KIND=nag_wp), ALLOCATABLE :: a(:,:), ab(:,:)
!      .. Intrinsic Functions ..
       INTRINSIC                          max, min
!      .. Executable Statements ..
       WRITE (nout,*) 'F16RBF Example Program Results'

!      Skip heading in data file
       READ (nin,*)

       READ (nin,*) m, n, kl, ku
       lda = m
       ldab = kl + ku + 1
       ALLOCATE (a(lda,n),ab(ldab,n))

!      Read A from data file into rectangular storage

       DO i = 1, m
          READ (nin,*) (a(i,j),j=max(1,i-kl),min(n,i+ku))
       END DO

!      Convert A to packed storage

       job = 'P'

       ifail = 0
       CALL f01zcf(job,m,n,kl,ku,a,lda,ab,ldab,ifail)

       WRITE (nout,*)
       WRITE (nout,99999) 'Norms of banded matrix AB:'
       WRITE (nout,*)

       r_one = f16rbf(nag_one_norm,m,n,kl,ku,ab,ldab)
       WRITE (nout,99998) 'One norm           = ', r_one

       r_inf = f16rbf(nag_inf_norm,m,n,kl,ku,ab,ldab)
       WRITE (nout,99998) 'Infinity norm      = ', r_inf

       r_fro = f16rbf(nag_frobenius_norm,m,n,kl,ku,ab,ldab)
       WRITE (nout,99998) 'Frobenius norm     = ', r_fro

       r_max = f16rbf(nag_max_norm,m,n,kl,ku,ab,ldab)
       WRITE (nout,99998) 'Maximum norm       = ', r_max

99999  FORMAT (1X,A)
99998  FORMAT (1X,A,F9.4)
    END PROGRAM f16rbfe
