    PROGRAM f01vefe

!      F01VEF Example Program Text

!      Mark 23 Release. NAG Copyright 2011.

!      .. Use Statements ..
       USE nag_library, ONLY : dtrttf, nag_wp, x04cbf
!      .. Implicit None Statement ..
       IMPLICIT NONE
!      .. Parameters ..
       INTEGER, PARAMETER              :: inc1 = 1, indent = 0, ncols = 80,    &
                                          nin = 5, nout = 6
       CHARACTER (1), PARAMETER        :: diag =   'N',  intlabel =   'I',     &
                                          matrix =   'G',  nolabel =   'N'
       CHARACTER (4), PARAMETER        :: form = 'F5.2'
!      .. Local Scalars ..
       INTEGER                         :: i, ifail, info, lda, lenarf, n
       CHARACTER (21)                  :: title
       CHARACTER (1)                   :: transr, uplo
!      .. Local Arrays ..
       REAL (KIND=nag_wp), ALLOCATABLE :: a(:,:), arf(:)
       CHARACTER (1)                   :: clabs(1), rlabs(1)
!      .. Executable Statements ..
       WRITE (nout,*) 'F01VEF Example Program Results'
!      Skip heading in data file
       READ (nin,*)
       WRITE (nout,*)
       FLUSH (nout)
       READ (nin,*) n, uplo, transr
       lda = n
       lenarf = n*(n+1)/2
       ALLOCATE (a(lda,n),arf(lenarf))

!      Read a triangular matrix of order n into array A
       DO i = 1, n
          READ (nin,*) a(i,1:n)
       END DO

!      Print the unpacked array A
       title = 'Unpacked Matrix A:   '
       ifail = 0
       CALL x04cbf(uplo,diag,n,n,a,lda,form,title,intlabel,rlabs,intlabel, &
          clabs,ncols,indent,ifail)

       WRITE (nout,*)
       FLUSH (nout)

!      Convert to Rectangular Full Packed form
       info = 0
!      The NAG name equivalent of dtrttf is f01vef
       CALL dtrttf(transr,uplo,n,a,lda,arf,info)

!      Print the Rectangular Full Packed array
       title = 'RFP Packed Array ARF:'
       ifail = 0
       CALL x04cbf(matrix,diag,lenarf,inc1,arf,lenarf,form,title,intlabel, &
          rlabs,nolabel,clabs,ncols,indent,ifail)

    END PROGRAM f01vefe
