    PROGRAM f11mlfe

!      F11MLF Example Program Text

!      Mark 23 Release. NAG Copyright 2011.

!      .. Use Statements ..
       USE nag_library, ONLY : f11mlf, nag_wp
!      .. Implicit None Statement ..
       IMPLICIT NONE
!      .. Parameters ..
       INTEGER, PARAMETER              :: nin = 5, nout = 6
!      .. Local Scalars ..
       REAL (KIND=nag_wp)              :: anorm
       INTEGER                         :: i, ifail, n, nnz
       CHARACTER (1)                   :: norm
!      .. Local Arrays ..
       REAL (KIND=nag_wp), ALLOCATABLE :: a(:)
       INTEGER, ALLOCATABLE            :: icolzp(:), irowix(:)
!      .. Executable Statements ..
       WRITE (nout,*) 'F11MLF Example Program Results'
!      Skip heading in data file
       READ (nin,*)

!      Read order of matrix and number of right hand sides

       READ (nin,*) n

       ALLOCATE (icolzp(n+1))

!      Read the matrix A

       READ (nin,*) icolzp(1:n+1)
       nnz = icolzp(n+1) - 1

       ALLOCATE (a(nnz),irowix(nnz))

       DO i = 1, nnz
          READ (nin,*) a(i), irowix(i)
       END DO

!      Calculate 1-norm

       norm = '1'

!      ifail: behaviour on error exit
!             =0 for hard exit, =1 for quiet-soft, =-1 for noisy-soft
       ifail = 0
       CALL f11mlf(norm,anorm,n,icolzp,irowix,a,ifail)

!      Output norm

       WRITE (nout,*)
       WRITE (nout,*) 'One-norm'
       WRITE (nout,'(F7.3)') anorm

!      Calculate M-norm

       norm = 'M'

       ifail = 0
       CALL f11mlf(norm,anorm,n,icolzp,irowix,a,ifail)

!      Output norm

       WRITE (nout,*)
       WRITE (nout,*) 'Max'
       WRITE (nout,'(F7.3)') anorm

!      Calculate I-norm

       norm = 'I'

       ifail = 0
       CALL f11mlf(norm,anorm,n,icolzp,irowix,a,ifail)

!      Output norm

       WRITE (nout,*)
       WRITE (nout,*) 'Infinity-norm'
       WRITE (nout,'(F7.3)') anorm

    END PROGRAM f11mlfe
