Program f04lhfe
! F04LHF Example Program Text
! Mark 27.3 Release. NAG Copyright 2021.
! .. Use Statements ..
Use nag_library, Only: f01lhf, f04lhf, nag_wp
! .. Implicit None Statement ..
Implicit None
! .. Parameters ..
Integer, Parameter :: lena = 200, nin = 5, nout = 6
! .. Local Scalars ..
Real (Kind=nag_wp) :: tol
Integer :: i, ifail, index, ir, j, k, ldb, n, &
nbasek, nbloks
! .. Local Arrays ..
Real (Kind=nag_wp), Allocatable :: a(:), b(:,:)
Integer, Allocatable :: blkstr(:,:), pivot(:)
! .. Executable Statements ..
Write (nout,*) 'F04LHF Example Program Results'
Write (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)
Do k = 1, blkstr(1,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
Read (nin,*)(a(nbasek+(j-1)*blkstr(1,i)+k),j=1,blkstr(2,i))
End If
End Do
nbasek = nbasek + blkstr(2,i)*blkstr(1,i)
n = n + blkstr(1,i)
End Do
Read (nin,*) ir
ldb = n
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,index,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)
Write (nout,*) 'Component Solution'
Do i = 1, n
Write (nout,99999) i, b(i,1:ir)
End Do
100 Continue
99999 Format (1X,I5,6X,5F7.4)
End Program f04lhfe