Example description
    Program f01vgfe

!     F01VGF Example Program Text

!     Mark 26.2 Release. NAG Copyright 2017.

!     .. Use Statements ..
      Use nag_library, Only: dtfttr, 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, k, lar1, lda, lenar, &
                                          n, q
      Character (21)                   :: title
      Character (1)                    :: transr, uplo
!     .. Local Arrays ..
      Real (Kind=nag_wp), Allocatable  :: a(:,:), ar(:)
      Character (1)                    :: clabs(1), rlabs(1)
!     .. Executable Statements ..
      Write (nout,*) 'F01VGF Example Program Results'
!     Skip heading in data file
      Read (nin,*)
      Write (nout,*)
      Flush (nout)
      Read (nin,*) n, uplo, transr
      lda = n
      lenar = n*(n+1)/2
      Allocate (a(lda,n),ar(lenar))

!     Setup notional dimensions of RFP matrix AR
      k = n/2
      q = n - k
      If (transr=='N' .Or. transr=='n') Then
        lar1 = 2*k + 1
      Else
        lar1 = q
      End If

!     Read an RFP matrix into array AR
      Do i = 1, lar1
        Read (nin,*) ar(i:lenar:lar1)
      End Do

!     Print the Rectangular Full Packed array
      title = 'RFP Packed Array AR:'
      ifail = 0
      Call x04cbf(matrix,diag,lenar,inc1,ar,lenar,form,title,intlabel,rlabs,   &
        nolabel,clabs,ncols,indent,ifail)
      Write (nout,*)
      Flush (nout)

!     Convert to triangular form
!     The NAG name equivalent of dtfttr is f01vgf
      Call dtfttr(transr,uplo,n,ar,a,lda,info)

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

    End Program f01vgfe