    PROGRAM nag_write_mat_ex01

      ! 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_gen_mat
      ! .. Implicit None Statement ..
      IMPLICIT NONE
      ! .. Intrinsic Functions ..
      INTRINSIC KIND, REAL
      ! .. Parameters ..
      INTEGER, PARAMETER :: m = 4, n = 3
      INTEGER, PARAMETER :: wp = KIND(1.0D0)
      ! .. Local Scalars ..
      INTEGER :: i, j
      CHARACTER (80) :: title
      ! .. Local Arrays ..
      REAL (wp) :: a(m,n)
      ! .. Executable Statements ..
      WRITE (nag_std_out,*) 'Example Program Results for nag_write_mat_ex01'

      ! Generate an array of data

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

      ! Write rectangular matrix with no optional parameters set

      WRITE (nag_std_out,*)

      CALL nag_write_gen_mat(a)

      ! Write the same matrix with title, format and integer labels

      title = 'Output of the same matrix with title and integer &
       &labels using F8.1 format'

      WRITE (nag_std_out,*)

      CALL nag_write_gen_mat(a,format='F8.1',title=title, &
       int_row_labels=.TRUE.,int_col_labels=.TRUE.)

    END PROGRAM nag_write_mat_ex01
