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

NAG FL Interface Introduction
Example description
    Program f01brfe

!     F01BRF Example Program Text

!     Mark 30.2 Release. NAG Copyright 2024.

!     .. Use Statements ..
      Use nag_library, Only: f01brf, nag_wp, x04abf
!     .. Implicit None Statement ..
      Implicit None
!     .. Parameters ..
      Integer, Parameter               :: iset = 1, nin = 5, nout = 6
!     .. Local Scalars ..
      Real (Kind=nag_wp)               :: pivot
      Integer                          :: i, ifail, licn, lirn, n, nz, outchn
      Logical                          :: grow, lblock
!     .. Local Arrays ..
      Real (Kind=nag_wp), Allocatable  :: a(:), w(:)
      Integer, Allocatable             :: icn(:), ikeep(:,:), irn(:), iw(:,:)
      Integer                          :: idisp(10)
      Logical                          :: abort(4)
!     .. Executable Statements ..
      Write (nout,*) 'F01BRF Example Program Results'
      outchn = nout
!     Skip heading in data file
      Read (nin,*)
      Read (nin,*) n, nz
      licn = 3*nz
      lirn = 3*nz/2
      Allocate (a(licn),w(n),icn(licn),ikeep(n,5),irn(lirn),iw(n,8))
      Call x04abf(iset,outchn)
      Read (nin,*)(a(i),irn(i),icn(i),i=1,nz)
      pivot = 0.1E0_nag_wp
      lblock = .True.
      grow = .True.
      abort(1) = .True.
      abort(2) = .True.
      abort(3) = .False.
      abort(4) = .True.

!     ifail: behaviour on error exit
!            =110 for noisy, hard exit
      ifail = 110
      Call f01brf(n,nz,a,licn,irn,lirn,icn,pivot,ikeep,iw,w,lblock,grow,abort, &
        idisp,ifail)

      Write (nout,*)
      Write (nout,99999) 'Number of nonzeros in decomposition         =',      &
        idisp(2)
      Write (nout,99999) 'Minimum size of array IRN                    =',     &
        idisp(6)
      Write (nout,99999) 'Minimum size of arrays A and ICN             =',     &
        idisp(7)
      Write (nout,99999) 'Number of compresses on IRN (IDISP(3))       =',     &
        idisp(3)
      Write (nout,99999) 'Number of compresses on A and ICN (IDISP(4)) =',     &
        idisp(4)
      If (grow) Then
        Write (nout,*)
        Write (nout,99998) 'Value of W(1) =', w(1)
      End If
      If (lblock) Then
        Write (nout,*)
        Write (nout,99999) 'Structural rank                =', idisp(8)
        Write (nout,99999) 'Number of diagonal blocks      =', idisp(9)
        Write (nout,99999) 'Size of largest diagonal block =', idisp(10)
      End If

99999 Format (1X,A,I5,A,I5)
99998 Format (1X,A,F8.4)
    End Program f01brfe