    Program f07jrfe

!     F07JRF Example Program Text

!     Mark 24 Release. NAG Copyright 2012.

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

      Allocate (e(n-1),d(n))

!     Read the lower bidiagonal part of the tridiagonal matrix A from
!     data file

      Read (nin,*) d(1:n)
      Read (nin,*) e(1:n-1)

!     Factorize the tridiagonal matrix A
!     The NAG name equivalent of zpttrf is f07jrf
      Call zpttrf(n,d,e,info)

      If (info>0) Then
        Write (nout,99999) 'The leading minor of order ', info, &
          ' is not positive definite'
      End If

!     Print details of the factorization

      Write (nout,*) 'Details of factorization'
      Write (nout,*)
      Write (nout,*) ' The diagonal elements of D'
      Write (nout,99998) d(1:n)
      Write (nout,*)
      Write (nout,*) ' Sub-diagonal elements of the Cholesky factor L'
      Write (nout,99998) e(1:n-1)

99999 Format (1X,A,I3,A)
99998 Format (1X,8F9.4)
    End Program f07jrfe
