Program x04ccfe

!     X04CCF Example Program Text

!     Mark 26.1 Release. NAG Copyright 2016.

!     .. Use Statements ..
      Use nag_library, Only: dtrttp, nag_wp, x04ccf
!     .. Implicit None Statement ..
      Implicit None
!     .. Parameters ..
      Integer, Parameter               :: n = 5, nout = 6
!     .. Local Scalars ..
      Integer                          :: i, ifail, info, j, lda
      Character (1)                    :: uplo
!     .. Local Arrays ..
      Real (Kind=nag_wp), Allocatable  :: a(:,:), ap(:)
!     .. Intrinsic Procedures ..
      Intrinsic                        :: real
!     .. Executable Statements ..
      Write (nout,*) 'X04CCF Example Program Results'

      Write (nout,*)
      Flush (nout)

!     Generate a full-format symmetric array of data

      lda = n
      Allocate (a(lda,n))

      Do j = 1, n

        Do i = 1, j
          a(i,j) = real(10*i+j,kind=nag_wp)
          a(j,i) = a(i,j)
        End Do

      End Do

!     Print order (n-1) lower triangular matrix

!     Convert a to packed storage.

      Allocate (ap(n*(n+1)/2))

!     The lower triangle.

      uplo = 'L'

!     The NAG name equivalent of dtrttp is f01vaf
      Call dtrttp(uplo,n-1,a,lda,ap,info)

      If (info/=0) Then
        Write (nout,99999) 'Failure in DTRTTP. INFO =', info
        Go To 100
      End If

      ifail = 0
      Call x04ccf('Lower','Unit',n-1,ap,'Example 1:',ifail)

      Write (nout,*)
      Flush (nout)

!     Print order n upper triangular matrix

!     Convert the upper triangle of a to packed storage.

      uplo = 'U'

!     The NAG name equivalent of dtrttp is f01vaf
      Call dtrttp(uplo,n,a,lda,ap,info)

      If (info/=0) Then
        Write (nout,99999) 'Failure in DTRTTP. INFO =', info
        Go To 100
      End If

      ifail = 0
      Call x04ccf('Upper','Non-unit',n,ap,'Example 2:',ifail)

100   Continue

99999 Format (1X,A,I4)
    End Program x04ccfe