PROGRAM f07csfe ! F07CSF Example Program Text ! Mark 23 Release. NAG Copyright 2011. ! .. Use Statements .. USE nag_library, ONLY : nag_wp, x04dbf, zgttrf, zgttrs ! .. Implicit None Statement .. IMPLICIT NONE ! .. Parameters .. INTEGER, PARAMETER :: nin = 5, nout = 6 ! .. Local Scalars .. INTEGER :: i, ifail, info, ldb, n, nrhs ! .. Local Arrays .. COMPLEX (KIND=nag_wp), ALLOCATABLE :: b(:,:), d(:), dl(:), du(:), du2(:) INTEGER, ALLOCATABLE :: ipiv(:) CHARACTER (1) :: clabs(1), rlabs(1) ! .. Executable Statements .. WRITE (nout,*) 'F07CSF Example Program Results' WRITE (nout,*) FLUSH (nout) ! Skip heading in data file READ (nin,*) READ (nin,*) n, nrhs ldb = n ALLOCATE (b(ldb,nrhs),d(n),dl(n-1),du(n-1),du2(n-2),ipiv(n)) ! Read the tridiagonal matrix A from data file READ (nin,*) du(1:n-1) READ (nin,*) d(1:n) READ (nin,*) dl(1:n-1) ! Read the right hand matrix B READ (nin,*) (b(i,1:nrhs),i=1,n) ! Factorize the tridiagonal matrix A ! The NAG name equivalent of zgttrf is f07crf CALL zgttrf(n,dl,d,du,du2,ipiv,info) IF (info==0) THEN ! Solve the equations AX = B ! The NAG name equivalent of zgttrs is f07csf CALL zgttrs('No transpose',n,nrhs,dl,d,du,du2,ipiv,b,ldb,info) ! Print the solution ! ifail: behaviour on error exit ! =0 for hard exit, =1 for quiet-soft, =-1 for noisy-soft ifail = 0 CALL x04dbf('General',' ',n,nrhs,b,ldb,'Bracketed','F7.4', & 'Solution(s)','Integer',rlabs,'Integer',clabs,80,0,ifail) ELSE WRITE (nout,99999) 'The (', info, ',', info, ')', & ' element of the factor U is zero' END IF 99999 FORMAT (1X,A,I3,A,I3,A,A) END PROGRAM f07csfe