    PROGRAM nag_write_mat_ex10

      ! 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_bnd_mat
      ! .. Implicit None Statement ..
      IMPLICIT NONE
      ! .. Intrinsic Functions ..
      INTRINSIC CMPLX, KIND, REAL
      ! .. Parameters ..
      INTEGER, PARAMETER :: kl = 2, ku = 1, n = 5
      INTEGER, PARAMETER :: wp = KIND(1.0D0)
      INTEGER, PARAMETER :: diag_index = ku + 1
      ! .. Local Scalars ..
      INTEGER :: i, j
      REAL (wp) :: aa
      CHARACTER (80) :: format, title
      ! .. Local Arrays ..
      COMPLEX (wp) :: a(kl+ku+1,n)
      ! .. Executable Statements ..
      WRITE (nag_std_out,*) 'Example Program Results for nag_write_mat_ex10'

      ! Generate an array of data

      DO i = 1, kl + ku + 1
        DO j = 1, n
          aa = REAL(10*i+j,kind=wp)
          a(i,j) = CMPLX(aa,-0.5_wp*aa,kind=wp)
        END DO
      END DO

      ! Write the complex 5 by 5 banded matrix stored in a.

      WRITE (nag_std_out,*)

      CALL nag_write_bnd_mat(ku,a)

      ! Write the lower part of the banded matrix stored in a
      ! using a title

      title = 'Output the lower part of the complex band matrix &
       &i.e. no super-diagonal'
      WRITE (nag_std_out,*)

      CALL nag_write_bnd_mat(0,a(diag_index:,:),title=title)

      ! Write one sub-diagonal and one super-diagonal of the banded
      ! matrix stored in a using a title, integer row and column using
      ! unaltered user supplied format

      title = 'Output one sub-diagonal and one super-diagonal of &
       &the complex band matrix'
      WRITE (nag_std_out,*)
      format = 'ss,f7.1,sp,f6.1,"i"'

      CALL nag_write_bnd_mat(1,a(diag_index-1:diag_index+1,:),title=title, &
       format=format,cmplx_form='d',int_col_labels=.TRUE., &
       int_row_labels=.TRUE.)

    END PROGRAM nag_write_mat_ex10
