PROGRAM f11dpfe ! F11DPF Example Program Text ! Mark 23 Release. NAG Copyright 2011. ! .. Use Statements .. USE nag_library, ONLY : f11dnf, f11dpf, nag_wp ! .. Implicit None Statement .. IMPLICIT NONE ! .. Parameters .. INTEGER, PARAMETER :: nin = 5, nout = 6 ! .. Local Scalars .. REAL (KIND=nag_wp) :: dtol INTEGER :: i, ifail, la, lfill, liwork, n, nnz, & nnzc, npivm CHARACTER (1) :: check, milu, pstrat, trans ! .. Local Arrays .. COMPLEX (KIND=nag_wp), ALLOCATABLE :: a(:), x(:), y(:) INTEGER, ALLOCATABLE :: icol(:), idiag(:), ipivp(:), & ipivq(:), irow(:), istr(:), iwork(:) ! .. Executable Statements .. WRITE (nout,*) 'F11DPF Example Program Results' WRITE (nout,*) ! Skip heading in data file READ (nin,*) ! Read order of matrix and number of non-zero entries READ (nin,*) n READ (nin,*) nnz la = 3*nnz liwork = 7*n + 2 ALLOCATE (a(la),x(n),y(n),icol(la),idiag(n),ipivp(n),ipivq(n),irow(la), & istr(n+1),iwork(liwork)) ! Read the matrix A DO i = 1, nnz READ (nin,*) a(i), irow(i), icol(i) END DO ! Read the vector y READ (nin,*) y(1:n) ! Calculate LU factorization lfill = -1 dtol = 0.0E0_nag_wp pstrat = 'C' milu = 'N' ! ifail: behaviour on error exit ! =0 for hard exit, =1 for quiet-soft, =-1 for noisy-soft ifail = 0 CALL f11dnf(n,nnz,a,la,irow,icol,lfill,dtol,pstrat,milu,ipivp,ipivq, & istr,idiag,nnzc,npivm,iwork,liwork,ifail) ! Check value of NPIVM IF (npivm>0) THEN WRITE (nout,*) 'Factorization is not complete' ELSE ! Solve P L D U x = y trans = 'N' check = 'C' ifail = 0 CALL f11dpf(trans,n,a,la,irow,icol,ipivp,ipivq,istr,idiag,check,y,x, & ifail) ! Output results WRITE (nout,*) 'Solution of linear system' WRITE (nout,99999) x(1:n) END IF 99999 FORMAT (1X,'(',E16.4,',',E16.4,')') END PROGRAM f11dpfe