    PROGRAM f01vmfe

!      F01VMF Example Program Text

!      Mark 23 Release. NAG Copyright 2011.

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

       ALLOCATE (ap(lenap),arf(lenarf))

!      Read an RFP matrix into array ARF
       READ (nin,*) arf

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

       WRITE (nout,*)
       FLUSH (nout)

!      Convert to packed vector form
       info = 0
!      The NAG name equivalent of ztfttp is f01vmf
       CALL ztfttp(transr,uplo,n,arf,ap,info)

!      Print the packed vector
       title = 'Packed Array AP:     '
       ifail = 0
       CALL x04dbf(matrix,diag,lenap,inc1,ap,lenap,brac,form,title,intlabel, &
          rlabs,nolabel,clabs,ncols,indent,ifail)

    END PROGRAM f01vmfe
