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

NAG FL Interface Introduction
Example description
    Program f07cafe

!     F07CAF Example Program Text

!     Mark 28.3 Release. NAG Copyright 2022.

!     .. Use Statements ..
      Use nag_library, Only: dgtsv, nag_wp
!     .. Implicit None Statement ..
      Implicit None
!     .. Parameters ..
      Integer, Parameter               :: nin = 5, nout = 6
!     .. Local Scalars ..
      Integer                          :: info, n
!     .. Local Arrays ..
      Real (Kind=nag_wp), Allocatable  :: b(:), d(:), dl(:), du(:)
!     .. Executable Statements ..
      Write (nout,*) 'F07CAF Example Program Results'
      Write (nout,*)
!     Skip heading in data file
      Read (nin,*)
      Read (nin,*) n

      Allocate (b(n),d(n),dl(n-1),du(n-1))

!     Read the tridiagonal matrix A and the right hand side B from
!     data file

      Read (nin,*) du(1:n-1)
      Read (nin,*) d(1:n)
      Read (nin,*) dl(1:n-1)
      Read (nin,*) b(1:n)

!     Solve the equations Ax = b for x

!     The NAG name equivalent of dgtsv is f07caf
      Call dgtsv(n,1,dl,d,du,b,n,info)

      If (info==0) Then

!       Print solution

        Write (nout,*) 'Solution'
        Write (nout,99999) b(1:n)

      Else
        Write (nout,99998) 'The (', info, ',', info, ')',                      &
          ' element of the factor U is zero'
      End If

99999 Format ((1X,7F11.4))
99998 Format (1X,A,I3,A,I3,A,A)
    End Program f07cafe