PROGRAM f01lefe ! F01LEF Example Program Text ! Mark 23 Release. NAG Copyright 2011. ! .. Use Statements .. USE nag_library, ONLY : f01lef, f04lef, nag_wp ! .. Implicit None Statement .. IMPLICIT NONE ! .. Parameters .. INTEGER, PARAMETER :: nin = 5, nout = 6 ! .. Local Scalars .. REAL (KIND=nag_wp) :: lambda, tol INTEGER :: ifail, job, n ! .. Local Arrays .. REAL (KIND=nag_wp), ALLOCATABLE :: a(:), b(:), c(:), d(:), y(:) INTEGER, ALLOCATABLE :: ipiv(:) ! .. Executable Statements .. WRITE (nout,*) 'F01LEF Example Program Results' WRITE (nout,*) ! Skip heading in data file READ (nin,*) READ (nin,*) n ALLOCATE (a(n),b(n),c(n),d(n),y(n),ipiv(n)) READ (nin,*) a(1:n) READ (nin,*) b(2:n) READ (nin,*) c(2:n) tol = 0.00005E0_nag_wp lambda = 0.0E0_nag_wp ! ifail: behaviour on error exit ! =0 for hard exit, =1 for quiet-soft, =-1 for noisy-soft ifail = 0 CALL f01lef(n,a,lambda,b,c,tol,d,ipiv,ifail) IF (ipiv(n)/=0) THEN WRITE (nout,*) 'Matrix is singular or nearly singular' WRITE (nout,99999) 'Diagonal element', ipiv(n), 'is small' ELSE WRITE (nout,*) 'Details of factorization' WRITE (nout,*) WRITE (nout,*) ' Main diagonal of U' WRITE (nout,99998) a(1:n) WRITE (nout,*) WRITE (nout,*) ' First super-diagonal of U' WRITE (nout,99998) b(2:n) WRITE (nout,*) WRITE (nout,*) ' Second super-diagonal of U' WRITE (nout,99998) d(3:n) WRITE (nout,*) WRITE (nout,*) ' Multipliers' WRITE (nout,99998) c(2:n) WRITE (nout,*) WRITE (nout,*) ' Vector of interchanges' WRITE (nout,99997) ipiv(1:(n-1)) READ (nin,*) y(1:n) job = 1 ifail = 0 CALL f04lef(job,n,a,b,c,d,ipiv,y,tol,ifail) WRITE (nout,*) WRITE (nout,*) ' Solution vector' WRITE (nout,99998) y(1:n) END IF 99999 FORMAT (1X,A,I4,A) 99998 FORMAT (1X,8F9.4) 99997 FORMAT (1X,5I9) END PROGRAM f01lefe