NAG Library Manual, Mark 30.1
Interfaces:  FL   CL   CPP   AD 

NAG FL Interface Introduction
Example description
    Program f04axfe

!     F04AXF Example Program Text

!     Mark 30.1 Release. NAG Copyright 2024.

!     .. Use Statements ..
      Use nag_library, Only: f01brf, f04axf, nag_wp
!     .. Implicit None Statement ..
      Implicit None
!     .. Parameters ..
      Integer, Parameter               :: nin = 5, nout = 6
!     .. Local Scalars ..
      Real (Kind=nag_wp)               :: resid, u
      Integer                          :: i, ifail, licn, lirn, mtype, n, nz
      Logical                          :: grow, lblock
!     .. Local Arrays ..
      Real (Kind=nag_wp), Allocatable  :: a(:), rhs(:), w(:)
      Integer, Allocatable             :: icn(:), ikeep(:,:), irn(:), iw(:,:)
      Integer                          :: idisp(10)
      Logical                          :: abort(4)
!     .. Executable Statements ..
      Write (nout,*) 'F04AXF Example Program Results'
      Write (nout,*)
!     Skip heading in data file
      Read (nin,*)
      Read (nin,*) n, nz
      licn = 3*nz
      lirn = 3*nz/2
      Allocate (a(licn),rhs(n),w(n),icn(licn),ikeep(n,5),irn(lirn),iw(n,8))
      Read (nin,*)(a(i),irn(i),icn(i),i=1,nz)
      u = 0.1E0_nag_wp
      lblock = .True.
      grow = .True.
      abort(1) = .True.
      abort(2) = .True.
      abort(3) = .False.
      abort(4) = .True.

!     ifail: behaviour on error exit
!             =0 for hard exit, =1 for quiet-soft, =-1 for noisy-soft
      ifail = 0
!     Decomposition of sparse matrix
      Call f01brf(n,nz,a,licn,irn,lirn,icn,u,ikeep,iw,w,lblock,grow,abort,     &
        idisp,ifail)

      If (grow) Then
        Write (nout,*) 'On exit from F01BRF'
        Write (nout,99999) 'Value of W(1) = ', w(1)
      End If
      Read (nin,*) rhs(1:n)
      mtype = 1

!     Approximate solution of sparse linear equations
      Call f04axf(n,a,licn,icn,ikeep,rhs,w,mtype,idisp,resid)

      Write (nout,*)
      Write (nout,*) 'On exit from F04AXF'
      Write (nout,*) ' Solution'
      Write (nout,99998) rhs(1:n)

99999 Format (1X,A,F9.4)
99998 Format (1X,F9.4)
    End Program f04axfe