    PROGRAM nag_write_mat_ex06

      ! 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 :: m = 5, n = 5
      INTEGER, PARAMETER :: wp = KIND(1.0D0)
      ! .. Local Scalars ..
      INTEGER :: i, j
      REAL (wp) :: aa
      CHARACTER (1) :: cmplx_form, diag, uplo
      CHARACTER (20) :: format
      ! .. Local Arrays ..
      COMPLEX (wp) :: a(m,n)
      ! .. Executable Statements ..
      WRITE (nag_std_out,*) 'Example Program Results for nag_write_mat_ex06'

      ! Generate an array of data ..

      DO j = 1, n
        DO i = 1, m
          aa = 10*i + j
          a(i,j) = CMPLX(aa,-aa,kind=wp)
        END DO
      END DO

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

      uplo = 'L'
      diag = 'N'
      format = '1PE13.4'
      cmplx_form = 'B'

      CALL nag_write_tri_mat(uplo,a,diag=diag,format=format, &
       cmplx_form=cmplx_form)

    END PROGRAM nag_write_mat_ex06
