Program f11jqfe
! F11JQF Example Program Text
! Mark 30.0 Release. NAG Copyright 2024.
! .. Use Statements ..
Use nag_library, Only: f11jnf, f11jqf, nag_wp
! .. Implicit None Statement ..
Implicit None
! .. Parameters ..
Integer, Parameter :: nin = 5, nout = 6
! .. Local Scalars ..
Real (Kind=nag_wp) :: dscale, dtol, rnorm, tol
Integer :: i, ifail, itn, la, lfill, liwork, &
lwork, maxitn, n, nnz, nnzc, npivm
Character (6) :: method
Character (1) :: mic, pstrat
! .. Local Arrays ..
Complex (Kind=nag_wp), Allocatable :: a(:), b(:), work(:), x(:)
Integer, Allocatable :: icol(:), ipiv(:), irow(:), istr(:), &
iwork(:)
! .. Executable Statements ..
Write (nout,*) 'F11JQF Example Program Results'
! Skip heading in data file
Read (nin,*)
! Read algorithmic parameters
Read (nin,*) n
Read (nin,*) nnz
la = 3*nnz
liwork = 2*la + 7*n + 1
lwork = 7*n + 120
Allocate (a(la),b(n),work(lwork),x(n),icol(la),ipiv(n),irow(la), &
istr(n+1),iwork(liwork))
Read (nin,*) method
Read (nin,*) lfill, dtol
Read (nin,*) mic, dscale
Read (nin,*) pstrat
Read (nin,*) tol, maxitn
! Read the matrix A
Do i = 1, nnz
Read (nin,*) a(i), irow(i), icol(i)
End Do
! Read rhs vector b and initial approximate solution x
Read (nin,*) b(1:n)
Read (nin,*) x(1:n)
! Calculate incomplete Cholesky factorization
! ifail: behaviour on error exit
! =0 for hard exit, =1 for quiet-soft, =-1 for noisy-soft
ifail = 0
Call f11jnf(n,nnz,a,la,irow,icol,lfill,dtol,mic,dscale,pstrat,ipiv,istr, &
nnzc,npivm,iwork,liwork,ifail)
! Solve Ax = b using F11JQF
Call f11jqf(method,n,nnz,a,la,irow,icol,ipiv,istr,b,tol,maxitn,x,rnorm, &
itn,work,lwork,ifail)
Write (nout,99999) 'Converged in', itn, ' iterations'
Write (nout,99998) 'Final residual norm =', rnorm
! Output x
Write (nout,99997) x(1:n)
99999 Format (1X,A,I10,A)
99998 Format (1X,A,1P,E16.3)
99997 Format (1X,'(',E16.4,',',E16.4,')')
End Program f11jqfe