*     F11DPF Example Program Text
*     Mark 20 Revised. NAG Copyright 2001.
*     .. Parameters ..
      INTEGER          NIN, NOUT
      PARAMETER        (NIN=5,NOUT=6)
      INTEGER          NMAX, LA, LIWORK
      PARAMETER        (NMAX=1000,LA=10000,LIWORK=7*NMAX+2)
*     .. Local Scalars ..
      DOUBLE PRECISION DTOL
      INTEGER          I, IFAIL, LFILL, N, NNZ, NNZC, NPIVM
      CHARACTER        CHECK, MILU, PSTRAT, TRANS
*     .. Local Arrays ..
      COMPLEX *16      A(LA), X(NMAX), Y(NMAX)
      INTEGER          ICOL(LA), IDIAG(NMAX), IPIVP(NMAX), IPIVQ(NMAX),
     +                 IROW(LA), ISTR(NMAX+1), IWORK(LIWORK)
*     .. External Subroutines ..
      EXTERNAL         F11DNF, F11DPF
*     .. Executable Statements ..
      WRITE (NOUT,*) 'F11DPF Example Program Results'
      WRITE (NOUT,*)
*     Skip heading in data file
      READ (NIN,*)
*
*     Read order of matrix and number of non-zero entries
*
      READ (NIN,*) N
      IF (N.LE.NMAX) THEN
         READ (NIN,*) NNZ
*
*        Read the matrix A
*
         DO 20 I = 1, NNZ
            READ (NIN,*) A(I), IROW(I), ICOL(I)
   20    CONTINUE
*
*        Read the vector y
*
         READ (NIN,*) (Y(I),I=1,N)
*
*        Calculate LU factorization
*
         LFILL = -1
         DTOL = 0.0D0
         PSTRAT = 'C'
         MILU = 'N'
         IFAIL = 0
*
         CALL F11DNF(N,NNZ,A,LA,IROW,ICOL,LFILL,DTOL,PSTRAT,MILU,IPIVP,
     +               IPIVQ,ISTR,IDIAG,NNZC,NPIVM,IWORK,LIWORK,IFAIL)
*
*        Check value of NPIVM
*
         IF (NPIVM.GT.0) THEN
*
            WRITE (NOUT,*) 'Factorization is not complete'
*
         ELSE
*
*           Solve P L D U x = y
*
            TRANS = 'N'
            CHECK = 'C'
*
            CALL F11DPF(TRANS,N,A,LA,IROW,ICOL,IPIVP,IPIVQ,ISTR,IDIAG,
     +                  CHECK,Y,X,IFAIL)
*
*           Output results
*
            WRITE (NOUT,*) 'Solution of linear system'
            DO 40 I = 1, N
               WRITE (NOUT,'(1X,''('',D16.4,'','',D16.4,'')'')') X(I)
   40       CONTINUE
*
         END IF
*
      END IF
      STOP
      END
