    PROGRAM nag_write_mat_ex08

      ! Example Program Text for nag_write_mat
      ! NAG fl90, Release 4. NAG Copyright 2000.

      ! .. Use Statements ..
      USE nag_examples_io, ONLY : nag_std_out
      USE nag_write_mat, ONLY : nag_write_tri_mat
      ! .. Implicit None Statement ..
      IMPLICIT NONE
      ! .. Intrinsic Functions ..
      INTRINSIC CMPLX, KIND
      ! .. Parameters ..
      INTEGER, PARAMETER :: n = 3
      INTEGER, PARAMETER :: wp = KIND(1.0D0)
      INTEGER, PARAMETER :: la = (n*(n+1))/2
      ! .. Local Scalars ..
      INTEGER :: i
      CHARACTER (20) :: format
      CHARACTER (80) :: title
      ! .. Local Arrays ..
      COMPLEX (wp) :: a(la)
      CHARACTER (20) :: row_labels(n)
      ! .. Executable Statements ..
      WRITE (nag_std_out,*) 'Example Program Results for nag_write_mat_ex08'

      ! Generate an array of data ..

      DO i = 1, la
        a(i) = CMPLX(2*i,la-i,kind=wp)
      END DO

      DO i = 1, n
        WRITE (row_labels(i),'(a,i3)') 'Row ', i
      END DO

      ! Write n by n complex triangular matrix with various optional
      ! parameters set

      format = 'F10.4'
      title = 'Output a packed complex triangular matrix'

      WRITE (nag_std_out,*)

      CALL nag_write_tri_mat('u',a,format=format,title=title, &
       row_labels=row_labels,int_col_labels=.TRUE.,cmplx_form='D')

    END PROGRAM nag_write_mat_ex08
