    PROGRAM nag_airy_fun_ex01

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

      ! .. Use Statements ..
      USE nag_examples_io, ONLY : nag_std_out
      USE nag_airy_fun, ONLY : nag_airy_ai
      ! .. Implicit None Statement ..
      IMPLICIT NONE
      ! .. Intrinsic Functions ..
      INTRINSIC KIND
      ! .. Parameters ..
      INTEGER, PARAMETER :: wp = KIND(1.0D0)
      ! .. Local Scalars ..
      INTEGER :: i
      REAL (wp) :: result_r
      COMPLEX (wp) :: result_c
      ! .. Local Arrays ..
      REAL (wp) :: x(7)
      COMPLEX (wp) :: z(4)
      ! .. Executable Statements ..
      WRITE (nag_std_out,*) 'Example Program Results for nag_airy_fun_ex01'

      x = (/ -10.0_wp, -1.0_wp, 0.0_wp, 1.0_wp, 5.0_wp, 10.0_wp, 20.0_wp/)

      ! Airy function Ai - real arguments
      WRITE (nag_std_out,*)
      WRITE (nag_std_out,*) '       x          Ai(x)'
      DO i = 1, 7

        result_r = nag_airy_ai(x(i))

        WRITE (nag_std_out,'(2(1x,1p,E12.3))') x(i), result_r
      END DO

      ! Derivative of Airy function Ai - real arguments
      WRITE (nag_std_out,*)
      WRITE (nag_std_out,*) '       x          Ai''(x)'
      DO i = 1, 7

        result_r = nag_airy_ai(x(i),deriv=.TRUE.)

        WRITE (nag_std_out,'(2(1x,1p,E12.3))') x(i), result_r
      END DO

      z(1) = (0.3_wp,0.4_wp)
      z(2) = (0.2_wp,0.0_wp)
      z(3) = (1.1_wp,-6.6_wp)
      z(4) = (-1.0_wp,0.0_wp)

      ! Airy function Ai - complex arguments, no scaling
      WRITE (nag_std_out,*)
      WRITE (nag_std_out,*) '          z                  Ai(z)'
      DO i = 1, 4

        result_c = nag_airy_ai(z(i))

        WRITE (nag_std_out,'(2(2x,''('',F8.4,'','',F8.4,'')''))') z(i), &
         result_c
      END DO

      ! Airy function Ai - complex arguments, scaled
      WRITE (nag_std_out,*)
      WRITE (nag_std_out,*) '          z               scaled  Ai(z)'
      DO i = 1, 4

        result_c = nag_airy_ai(z(i),scale=.TRUE.)

        WRITE (nag_std_out,'(2(2x,''('',F8.4,'','',F8.4,'')''))') z(i), &
         result_c
      END DO

      ! Derivative of Airy function Ai - complex argument, no scaling
      WRITE (nag_std_out,*)
      WRITE (nag_std_out,*) '          z                  Ai''(z)'
      DO i = 1, 4

        result_c = nag_airy_ai(z(i),deriv=.TRUE.)

        WRITE (nag_std_out,'(2(2x,''('',F8.4,'','',F8.4,'')''))') z(i), &
         result_c
      END DO

      ! Derivative of Airy function Ai - complex argument, scaled
      WRITE (nag_std_out,*)
      WRITE (nag_std_out,*) '          z              scaled  Ai''(z)'
      DO i = 1, 4

        result_c = nag_airy_ai(z(i),scale=.TRUE.,deriv=.TRUE.)

        WRITE (nag_std_out,'(2(2x,''('',F8.4,'','',F8.4,'')''))') z(i), &
         result_c
      END DO

    END PROGRAM nag_airy_fun_ex01
