    PROGRAM f03bffe

!      F03BFF Example Program Text

!      Mark 23 Release. NAG Copyright 2011.

!      .. Use Statements ..
       USE nag_library, ONLY : dpotrf, f03bff, nag_wp, x04caf
!      .. Implicit None Statement ..
       IMPLICIT NONE
!      .. Parameters ..
       INTEGER, PARAMETER              :: nin = 5, nout = 6
       CHARACTER (1), PARAMETER        :: uplo = 'l'
!      .. Local Scalars ..
       REAL (KIND=nag_wp)              :: d
       INTEGER                         :: i, id, ifail, info, lda, n
!      .. Local Arrays ..
       REAL (KIND=nag_wp), ALLOCATABLE :: a(:,:)
!      .. Executable Statements ..
       WRITE (nout,*) 'F03BFF Example Program Results'

!      Skip heading in data file
       READ (nin,*)

       READ (nin,*) n
       lda = n
       ALLOCATE (a(lda,n))

       READ (nin,*) (a(i,1:n),i=1,n)

!      Factorize A
!      The NAG name equivalent of dpotrf is f07fdf
       CALL dpotrf(uplo,n,a,lda,info)

       WRITE (nout,*)
       FLUSH (nout)
       ifail = 0
       CALL x04caf('L','N',n,n,a,lda,'Array A after factorization',ifail)

       ifail = 0
       CALL f03bff(n,a,lda,d,id,ifail)

       WRITE (nout,*)
       WRITE (nout,99999) d, id
       WRITE (nout,*)
       WRITE (nout,99998) d*2.0_nag_wp**id

99999  FORMAT (1X,'D = ',F13.5,' ID = ',I12)
99998  FORMAT (1X,'Value of determinant = ',E13.5)
    END PROGRAM f03bffe
