Program f11dcfe ! F11DCF Example Program Text ! Mark 24 Release. NAG Copyright 2012. ! .. Use Statements .. Use nag_library, Only: f11daf, f11dcf, nag_wp ! .. Implicit None Statement .. Implicit None ! .. Parameters .. Integer, Parameter :: nin = 5, nout = 6 ! .. Local Scalars .. Real (Kind=nag_wp) :: dtol, rnorm, tol Integer :: i, ifail, itn, la, lfill, liwork, & lwork, m, maxitn, n, nnz, nnzc, npivm Character (8) :: method Character (1) :: milu, pstrat ! .. Local Arrays .. Real (Kind=nag_wp), Allocatable :: a(:), b(:), work(:), x(:) Integer, Allocatable :: icol(:), idiag(:), ipivp(:), & ipivq(:), irow(:), istr(:), iwork(:) ! .. Intrinsic Procedures .. Intrinsic :: max ! .. Executable Statements .. Write (nout,*) 'F11DCF Example Program Results' Write (nout,*) ! Skip heading in data file Read (nin,*) ! Read algorithmic parameters Read (nin,*) n, m Read (nin,*) nnz la = 3*nnz liwork = 7*n + 2 lwork = max(4*n+m*(m+n+5)+101,8*n+100,2*n*(m+3)+m*(m+2)+100,11*n+100) Allocate (a(la),b(n),work(lwork),x(n),icol(la),idiag(n),ipivp(n), & ipivq(n),irow(la),istr(n+1),iwork(liwork)) Read (nin,*) method Read (nin,*) lfill, dtol Read (nin,*) pstrat Read (nin,*) milu Read (nin,*) tol, maxitn ! Read the matrix A Do i = 1, nnz Read (nin,*) a(i), irow(i), icol(i) End Do ! Read right-hand side vector b and initial approximate solution x Read (nin,*) b(1:n) Read (nin,*) x(1:n) ! Calculate incomplete LU factorization ! ifail: behaviour on error exit ! =0 for hard exit, =1 for quiet-soft, =-1 for noisy-soft ifail = 0 Call f11daf(n,nnz,a,la,irow,icol,lfill,dtol,pstrat,milu,ipivp,ipivq, & istr,idiag,nnzc,npivm,iwork,liwork,ifail) ! Solve Ax = b using F11DCF ifail = 0 Call f11dcf(method,n,nnz,a,la,irow,icol,ipivp,ipivq,istr,idiag,b,m,tol, & maxitn,x,rnorm,itn,work,lwork,ifail) Write (nout,99999) itn Write (nout,99998) rnorm Write (nout,*) ! Output x Write (nout,*) ' X' Write (nout,99997) x(1:n) 99999 Format (1X,' Converged in',I10,' iterations') 99998 Format (1X,' Final residual norm =',1P,E16.3) 99997 Format (1X,1P,E16.4) End Program f11dcfe