Program f11jrfe
! F11JRF Example Program Text
! Mark 29.2 Release. NAG Copyright 2023.
! .. Use Statements ..
Use nag_library, Only: f11jrf, nag_wp
! .. Implicit None Statement ..
Implicit None
! .. Parameters ..
Integer, Parameter :: nin = 5, nout = 6
! .. Local Scalars ..
Real (Kind=nag_wp) :: omega
Integer :: i, ifail, n, nnz
Character (1) :: check
! .. Local Arrays ..
Complex (Kind=nag_wp), Allocatable :: a(:), x(:), y(:)
Real (Kind=nag_wp), Allocatable :: rdiag(:)
Integer, Allocatable :: icol(:), irow(:), iwork(:)
! .. Intrinsic Procedures ..
Intrinsic :: real
! .. Executable Statements ..
Write (nout,*) 'F11JRF Example Program Results'
! Skip heading in data file
Read (nin,*)
! Read algorithmic parameters
Read (nin,*) n
Read (nin,*) nnz
Allocate (a(nnz),x(n),y(n),rdiag(n),icol(nnz),irow(nnz),iwork(n+1))
Read (nin,*) check
Read (nin,*) omega
! Read the matrix A
Do i = 1, nnz
Read (nin,*) a(i), irow(i), icol(i)
End Do
! Read rhs vector y
Read (nin,*) y(1:n)
! Fill in the diagonal part
Do i = 1, nnz
If (irow(i)==icol(i)) Then
rdiag(irow(i)) = 1.E0_nag_wp/real(a(i))
End If
End Do
! Solve Mx = b using F11JRF
! ifail: behaviour on error exit
! =0 for hard exit, =1 for quiet-soft, =-1 for noisy-soft
ifail = 0
Call f11jrf(n,nnz,a,irow,icol,rdiag,omega,check,y,x,iwork,ifail)
! Output x
Write (nout,99999) x(1:n)
99999 Format (1X,'(',E16.4,',',E16.4,')')
End Program f11jrfe