PROGRAM f01lhfe ! F01LHF Example Program Text ! Mark 23 Release. NAG Copyright 2011. ! .. 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 20 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) 20 CONTINUE END PROGRAM f01lhfe