Program f11jnfe

!     F11JNF Example Program Text

!     Mark 25 Release. NAG Copyright 2014.

!     .. Use Statements ..
      Use nag_library, Only: f11jnf, nag_wp
!     .. Implicit None Statement ..
      Implicit None
!     .. Parameters ..
      Integer, Parameter               :: nin = 5, nout = 6
!     .. Local Scalars ..
      Real (Kind=nag_wp)               :: dscale, dtol
      Integer                          :: i, ifail, la, lfill, liwork, n, nnz, &
                                          nnzc, npivm
      Character (1)                    :: mic, pstrat
!     .. Local Arrays ..
      Complex (Kind=nag_wp), Allocatable :: a(:)
      Integer, Allocatable             :: icol(:), ipiv(:), irow(:), istr(:),  &
                                          iwork(:)
!     .. Executable Statements ..
      Write (nout,*) 'F11JNF Example Program Results'
!     Skip heading in data file
      Read (nin,*)

!     Read algorithmic parameters

      Read (nin,*) n
      Read (nin,*) nnz
      la = 3*nnz
      liwork = 2*la + 7*n + 1
      Allocate (a(la),icol(la),ipiv(n),irow(la),istr(n+1),iwork(liwork))
      Read (nin,*) lfill, dtol
      Read (nin,*) mic, dscale
      Read (nin,*) pstrat

!     Read the matrix A

      Do i = 1, nnz
        Read (nin,*) a(i), irow(i), icol(i)
      End Do

!     Calculate incomplete Cholesky factorization

!     ifail: behaviour on error exit
!             =0 for hard exit, =1 for quiet-soft, =-1 for noisy-soft
      ifail = 0
      Call f11jnf(n,nnz,a,la,irow,icol,lfill,dtol,mic,dscale,pstrat,ipiv,istr, &
        nnzc,npivm,iwork,liwork,ifail)

!     Output original matrix

      Write (nout,*) ' Original Matrix'
      Write (nout,99997) 'N     =', n
      Write (nout,99997) 'NNZ   =', nnz
      Do i = 1, nnz
        Write (nout,99999) i, a(i), irow(i), icol(i)
      End Do
      Write (nout,*)

!     Output details of the factorization

      Write (nout,*) ' Factorization'
      Write (nout,99997) 'N     =', n
      Write (nout,99997) 'NNZ   =', nnzc
      Write (nout,99997) 'NPIVM =', npivm
      Do i = nnz + 1, nnz + nnzc
        Write (nout,99999) i, a(i), irow(i), icol(i)
      End Do
      Write (nout,*)

      Write (nout,*) '      I     IPIV(I)'
      Do i = 1, n
        Write (nout,99998) i, ipiv(i)
      End Do

99999 Format (I8,5X,'(',E16.4,',',E16.4,')',2I8)
99998 Format (1X,2I8)
99997 Format (1X,A,I16)
    End Program f11jnfe