    PROGRAM c02ajfe

!      C02AJF Example Program Text

!      Mark 23 Release. NAG Copyright 2011.

!      .. Use Statements ..
       USE nag_library, ONLY : c02ajf, nag_wp
!      .. Implicit None Statement ..
       IMPLICIT NONE
!      .. Parameters ..
       INTEGER, PARAMETER              :: nin = 5, nout = 6
!      .. Local Scalars ..
       REAL (KIND=nag_wp)              :: a, b, c
       INTEGER                         :: ifail
!      .. Local Arrays ..
       REAL (KIND=nag_wp)              :: zlg(2), zsm(2)
!      .. Intrinsic Functions ..
       INTRINSIC                          abs
!      .. Executable Statements ..
       WRITE (nout,*) 'C02AJF Example Program Results'

!      Skip heading in data file
       READ (nin,*)

       READ (nin,*) a, b, c

       ifail = -1
       CALL c02ajf(a,b,c,zsm,zlg,ifail)

       IF (ifail==0) THEN
          WRITE (nout,*)
          WRITE (nout,*) 'Roots of quadratic equation'
          WRITE (nout,*)

          IF (zsm(2)==0.0E0_nag_wp) THEN

!            2 real roots.

             WRITE (nout,99999) 'z = ', zsm(1)
             WRITE (nout,99999) 'z = ', zlg(1)
          ELSE

!            2 complex roots.

             WRITE (nout,99998) 'z = ', zsm(1), ' +/- ', abs(zsm(2)), '*i'
          END IF

       END IF

99999  FORMAT (1X,A,1P,E12.4)
99998  FORMAT (1X,A,1P,E12.4,A,E12.4,A)
    END PROGRAM c02ajfe
