NAG Library Manual, Mark 28.6
Interfaces:  FL   CL   CPP   AD 

NAG FL Interface Introduction
Example description
    Program f11dafe

!     F11DAF Example Program Text

!     Mark 28.6 Release. NAG Copyright 2022.

!     .. Use Statements ..
      Use nag_library, Only: f11daf, nag_wp
!     .. Implicit None Statement ..
      Implicit None
!     .. Parameters ..
      Integer, Parameter               :: nin = 5, nout = 6
!     .. Local Scalars ..
      Real (Kind=nag_wp)               :: dtol
      Integer                          :: i, ifail, la, lfill, liwork, n, nnz, &
                                          nnzc, npivm
      Character (1)                    :: milu, pstrat
!     .. Local Arrays ..
      Real (Kind=nag_wp), Allocatable  :: a(:)
      Integer, Allocatable             :: icol(:), idiag(:), ipivp(:),         &
                                          ipivq(:), irow(:), istr(:), iwork(:)
!     .. Executable Statements ..
      Write (nout,*) 'F11DAF Example Program Results'
      Write (nout,*)

!     Skip heading in data file

      Read (nin,*)

!     Read algorithmic parameters

      Read (nin,*) n
      Read (nin,*) nnz

      la = 2*nnz
      liwork = 7*n + 2

      Allocate (a(la),icol(la),idiag(n),ipivp(n),ipivq(n),irow(la),istr(n+1),  &
        iwork(liwork))
      Read (nin,*) lfill, dtol
      Read (nin,*) pstrat
      Read (nin,*) milu

!     Read the matrix A

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

!     Calculate incomplete LU factorization

!     ifail: behaviour on error exit
!             =0 for hard exit, =1 for quiet-soft, =-1 for noisy-soft
      ifail = 0
      Call f11daf(n,nnz,a,la,irow,icol,lfill,dtol,pstrat,milu,ipivp,ipivq,     &
        istr,idiag,nnzc,npivm,iwork,liwork,ifail)

!     Output original matrix

      Write (nout,*) ' Original Matrix'
      Write (nout,'(A,I4)') ' N     =', n
      Write (nout,'(A,I4)') ' NNZ   =', nnz
      Do i = 1, nnz
        Write (nout,'(I8,E16.4,2I8)') i, a(i), irow(i), icol(i)
      End Do
      Write (nout,*)

!     Output details of the factorization

      Write (nout,*) ' Factorization'
      Write (nout,'(A,I4)') ' N     =', n
      Write (nout,'(A,I4)') ' NNZ   =', nnzc
      Write (nout,'(A,I4)') ' NPIVM =', npivm
      Do i = nnz + 1, nnz + nnzc
        Write (nout,'(I8,E16.4,2I8)') i, a(i), irow(i), icol(i)
      End Do
      Write (nout,*)

      Write (nout,*) '        I       IPIVP(I)  IPIVQ(I)'
      Do i = 1, n
        Write (nout,'(3I10)') i, ipivp(i), ipivq(i)
      End Do

    End Program f11dafe