*     F11MEF 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 FLOP, THRESH
      INTEGER          I, IFAIL, N, NNZ, NNZL, NNZU, NZLMX, NZLUMX,
     +                 NZUMX
      CHARACTER        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)
      CHARACTER        CLABS(1), RLABS(1)
*     .. External Subroutines ..
      EXTERNAL         F11MDF, F11MEF, X04CBF
*     .. Executable Statements ..
      WRITE (NOUT,*) 'F11MEF 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)
*
*        Output results
*
         WRITE (NOUT,*)
         WRITE (NOUT,*)
     +     'Number of nonzeros in factors (excluding unit diagonal)'
         WRITE (NOUT,'(I8)') NNZL + NNZU - N

         CALL X04CBF('G','X',1,10,LVAL,1,'F7.2',
     +               'Factor elements in LVAL','N',RLABS,'N',CLABS,80,0,
     +               IFAIL)
         CALL X04CBF('G','X',1,4,UVAL,1,'F7.2',
     +               'Factor elements in UVAL','N',RLABS,'N',CLABS,80,0,
     +               IFAIL)

*
      END IF
      END
