    PROGRAM nag_write_mat_ex09

      ! 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 KIND
      ! .. Parameters ..
      INTEGER, PARAMETER :: norder = 5
      INTEGER, PARAMETER :: wp = KIND(1.0D0)
      INTEGER, PARAMETER :: la = (norder*(norder+1))/2
      ! .. Local Scalars ..
      INTEGER :: i, indent
      LOGICAL :: int_col_labels, int_row_labels
      CHARACTER (20) :: format
      CHARACTER (80) :: title
      CHARACTER (1) :: uplo
      ! .. Local Arrays ..
      REAL (wp) :: a(la)
      ! .. Executable Statements ..
      WRITE (nag_std_out,*) 'Example Program Results for nag_write_mat_ex09'

      ! Generate an array of data for the packed triangular matrix

      DO i = 1, la
        a(i) = i
      END DO

      ! Write a real lower triangular matrix of order norder
      ! with various optional parameters set

      uplo = 'L'
      format = '1PE13.4'
      title = 'Output a packed real triangular matrix'
      int_row_labels = .TRUE.
      int_col_labels = .TRUE.
      indent = 5

      WRITE (nag_std_out,*)

      CALL nag_write_tri_mat(uplo,a,format=format,title=title, &
       int_row_labels=int_row_labels,int_col_labels=int_col_labels, &
       indent=indent)

    END PROGRAM nag_write_mat_ex09
