    PROGRAM f07jrfe

!      F07JRF Example Program Text

!      Mark 23 Release. NAG Copyright 2011.

!      .. 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
