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

NAG FL Interface Introduction
Example description
    Program f01lhfe

!     F01LHF Example Program Text

!     Mark 30.1 Release. NAG Copyright 2024.

!     .. Use Statements ..
      Use nag_library, Only: f01lhf, f04lhf, nag_wp, x04caf
!     .. Implicit None Statement ..
      Implicit None
!     .. Parameters ..
      Integer, Parameter               :: lena = 200, nin = 5, nout = 6
!     .. Local Scalars ..
      Real (Kind=nag_wp)               :: tol
      Integer                          :: i, ifail, ir, j, k, kpivot, ldb, n,  &
                                          nbasek, nbloks
!     .. Local Arrays ..
      Real (Kind=nag_wp), Allocatable  :: a(:), b(:,:)
      Integer, Allocatable             :: blkstr(:,:), pivot(:)
!     .. Executable Statements ..
      Write (nout,*) 'F01LHF Example Program Results'
      Write (nout,*)
      Flush (nout)
!     Skip heading in data file
      Read (nin,*)
      Read (nin,*) nbloks
      Allocate (a(lena),blkstr(3,nbloks))
      nbasek = 0
      n = 0
      Do i = 1, nbloks
        Read (nin,*) blkstr(1:3,i)
        If (nbasek+blkstr(2,i)*blkstr(1,i)>lena) Then
          Write (nout,*) ' Array A is too small for this problem'
          Go To 100
        Else
          Do k = 1, blkstr(1,i)
            Read (nin,*)(a(nbasek+(j-1)*blkstr(1,i)+k),j=1,blkstr(2,i))
          End Do
        End If
        nbasek = nbasek + blkstr(2,i)*blkstr(1,i)
        n = n + blkstr(1,i)
      End Do
      ldb = n
      Read (nin,*) ir
      Allocate (b(ldb,ir),pivot(n))
      tol = 0.0E0_nag_wp

!     ifail: behaviour on error exit
!            =0 for hard exit, =1 for quiet-soft, =-1 for noisy-soft
      ifail = 0
      Call f01lhf(n,nbloks,blkstr,a,lena,pivot,tol,kpivot,ifail)

      Read (nin,*)(b(1:n,j),j=1,ir)

      ifail = 0
      Call f04lhf('N',n,nbloks,blkstr,a,lena,pivot,b,ldb,ir,ifail)

      Call x04caf('G','X',n,ir,b,ldb,'Component Solution',ifail)
100   Continue

    End Program f01lhfe