    PROGRAM f07wdfe

!      F07WDF Example Program Text

!      Mark 23 Release. NAG Copyright 2011.

!      .. Use Statements ..
       USE nag_library, ONLY : dpftrf, dtfttr, nag_wp, x04caf
!      .. Implicit None Statement ..
       IMPLICIT NONE
!      .. Parameters ..
       INTEGER, PARAMETER              :: nin = 5, nout = 6
!      .. Local Scalars ..
       INTEGER                         :: ifail, info, ldf, lena, n
       CHARACTER (1)                   :: transr, uplo
!      .. Local Arrays ..
       REAL (KIND=nag_wp), ALLOCATABLE :: a(:), f(:,:)
!      .. Executable Statements ..
       WRITE (nout,*) 'F07WDF Example Program Results'
!      Skip heading in data file
       READ (nin,*)
       READ (nin,*) n, uplo, transr

       lena = n*(n+1)/2
       ldf = n
       ALLOCATE (a(lena),f(ldf,n))

!      Read RFP packed array A from data file
       READ (nin,*) a(1:lena)

!      Factorize A
!      The NAG name equivalent of dpftrf is f07wdf
       CALL dpftrf(transr,uplo,n,a,info)

       WRITE (nout,*)
       FLUSH (nout)
       IF (info==0) THEN

!         Convert factor to full array form, and print it
!         The NAG name equivalent of dtfttr is f01vgf
          CALL dtfttr(transr,uplo,n,a,f,ldf,info)
          ifail = 0
          CALL x04caf(uplo,'Nonunit',n,n,f,ldf,'Factor',ifail)

       ELSE
          WRITE (nout,*) 'A is not positive definite'
       END IF

    END PROGRAM f07wdfe
