    Program f01vefe

!     F01VEF Example Program Text

!     Mark 24 Release. NAG Copyright 2012.

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