NAG Library Manual, Mark 30.1
Interfaces:  FL   CL   CPP   AD 

NAG FL Interface Introduction
Example description
    Program f01zafe

!     F01ZAF Example Program Text

!     Mark 30.1 Release. NAG Copyright 2024.

!     .. Use Statements ..
      Use nag_library, Only: f01zaf, nag_wp, x04cbf
!     .. Implicit None Statement ..
      Implicit None
!     .. Parameters ..
      Integer, Parameter               :: nin = 5, nout = 6
!     .. Local Scalars ..
      Integer                          :: i, ifail, lb, lda, lenb, n
      Character (1)                    :: diag, uplo
!     .. Local Arrays ..
      Real (Kind=nag_wp), Allocatable  :: a(:,:), b(:)
      Character (1)                    :: clabs(1), rlabs(1)
!     .. Executable Statements ..
      Write (nout,*) 'F01ZAF Example Program Results'
!     Skip heading in data file
      Read (nin,*)
      Write (nout,*)
      Flush (nout)
      Read (nin,*) n, uplo, diag
      lda = n
      lenb = (n*(n+1))/2
      Allocate (a(lda,n),b(lenb))
!     Read a triangular matrix of order n
      Do i = 1, n
        Read (nin,*) a(i,1:n)
      End Do

!     ifail: behaviour on error exit
!             =0 for hard exit, =1 for quiet-soft, =-1 for noisy-soft
      ifail = 0
!     Print the unpacked matrix
      Call x04cbf(uplo,diag,n,n,a,lda,'F5.2','Unpacked Matrix A:','I',rlabs,   &
        'I',clabs,80,0,ifail)

      Write (nout,*)
      Flush (nout)

!     Convert to packed vector form
      ifail = 0
      Call f01zaf('Pack',uplo,diag,n,a,lda,b,ifail)

      lb = n*(n+1)/2

!     Print the packed vector
      ifail = 0
      Call x04cbf('G','X',lb,1,b,lb,'F5.2','Packed Vector B:','I',rlabs,'N',   &
        clabs,80,0,ifail)

    End Program f01zafe