*     F11MGF Example Program Text
*     Mark 21 Release. NAG Copyright 2004.
*     .. Parameters ..
      INTEGER          NIN, NOUT
      PARAMETER        (NIN=5,NOUT=6)
      INTEGER          LA, NMAX
      PARAMETER        (LA=10000,NMAX=1000)
      DOUBLE PRECISION ONE
      PARAMETER        (ONE=1.D0)
*     .. Local Scalars ..
      DOUBLE PRECISION ANORM, FLOP, RCOND, THRESH
      INTEGER          I, IFAIL, N, NNZ, NNZL, NNZU, NZLMX, NZLUMX,
     +                 NZUMX
      CHARACTER        NORM, SPEC
*     .. Local Arrays ..
      DOUBLE PRECISION A(LA), LVAL(8*LA), UVAL(8*LA)
      INTEGER          ICOLZP(NMAX+1), IL(7*NMAX+8*LA+4), IPRM(7*NMAX),
     +                 IROWIX(LA), IU(2*NMAX+8*LA+1)
*     .. External Subroutines ..
      EXTERNAL         F11MDF, F11MEF, F11MGF, F11MLF
*     .. Executable Statements ..
      WRITE (NOUT,*) 'F11MGF Example Program Results'
*     Skip heading in data file
      READ (NIN,*)
*
*     Read order of matrix
*
      READ (NIN,*) N
      IF (N.LE.NMAX) THEN
*
*        Read the matrix A
*
         DO 20 I = 1, N + 1
            READ (NIN,*) ICOLZP(I)
   20    CONTINUE
         NNZ = ICOLZP(N+1) - 1
         DO 40 I = 1, NNZ
            READ (NIN,*) A(I), IROWIX(I)
   40    CONTINUE

*
*        Calculate COLAMD permutation
*
         SPEC = 'M'
         IFAIL = 0
         CALL F11MDF(SPEC,N,ICOLZP,IROWIX,IPRM,IFAIL)
*
*        Factorise
*
         THRESH = ONE
         IFAIL = 0
         NZLMX = 8*NNZ
         NZLUMX = 8*NNZ
         NZUMX = 8*NNZ
         CALL F11MEF(N,IROWIX,A,IPRM,THRESH,NZLMX,NZLUMX,NZUMX,IL,
     +               LVAL,IU,UVAL,NNZL,NNZU,FLOP,IFAIL)
*
*        Calculate norm
*
         NORM = '1'
         IFAIL = 0
         CALL F11MLF(NORM,ANORM,N,ICOLZP,IROWIX,A,IFAIL)
*
*        Calculate condition number
*
         IFAIL = 0
         CALL F11MGF(NORM,N,IL,LVAL,IU,UVAL,ANORM,RCOND,IFAIL)
*
*         Output result
*
         WRITE (NOUT,*)
         WRITE (NOUT,*) 'Norm  ,Condition number'
         WRITE (NOUT,'(F7.3,A1,F7.3)') ANORM, ',', 1/RCOND

*
      END IF
      END
