    PROGRAM nag_polynom_eqn_ex01

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

      ! .. Use Statements ..
      USE nag_examples_io, ONLY : nag_std_in, nag_std_out
      USE nag_polynom_eqn, ONLY : nag_polynom_roots
      ! .. Implicit None Statement ..
      IMPLICIT NONE
      ! .. Intrinsic Functions ..
      INTRINSIC KIND
      ! .. Parameters ..
      INTEGER, PARAMETER :: wp = KIND(1.0D0)
      ! .. Local Scalars ..
      INTEGER :: i, n
      ! .. Local Arrays ..
      REAL (wp), ALLOCATABLE :: a(:)
      COMPLEX (wp), ALLOCATABLE :: z(:)
      ! .. Executable Statements ..
      WRITE (nag_std_out,*) 'Example Program Results for nag_polynom_eqn_ex01'

      READ (nag_std_in,*)          ! Skip heading in data file
      READ (nag_std_in,*) n

      ALLOCATE (a(0:n),z(n))       ! Allocate storage

      ! Read the polynomial coefficients
      READ (nag_std_in,*) a

      ! Find the roots

      CALL nag_polynom_roots(a,z)

      WRITE (nag_std_out,'(/,1X,A,I4,/)') 'Degree of Polynomial =', n

      DO i = 1, n
        WRITE (nag_std_out,'(1X,A,"(",E12.4,",",E12.4,")")') 'z = ', z(i)
      END DO

      DEALLOCATE (a,z)             ! Deallocate storage

    END PROGRAM nag_polynom_eqn_ex01
