    PROGRAM nag_bessel_fun_ex02

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

      ! .. Use Statements ..
      USE nag_examples_io, ONLY : nag_std_out
      USE nag_bessel_fun, ONLY : nag_bessel_i, nag_bessel_j, nag_bessel_k, &
       nag_bessel_y
      ! .. Implicit None Statement ..
      IMPLICIT NONE
      ! .. Intrinsic Functions ..
      INTRINSIC CMPLX, KIND
      ! .. Parameters ..
      INTEGER, PARAMETER :: n = 4
      INTEGER, PARAMETER :: wp = KIND(1.0D0)
      CHARACTER (*), PARAMETER :: fmt1 = &
       '(I2, 4(2X,''('',F7.3,'','',F7.3,'')''))'
      CHARACTER (*), PARAMETER :: fmt2 = &
       '(1X,A,1X,''('',F7.3,'','',F7.3,'')'',A,F7.3,A)'
      ! .. Local Scalars ..
      INTEGER :: i
      REAL (wp) :: nu
      COMPLEX (wp) :: z
      ! .. Local Arrays ..
      COMPLEX (wp) :: bess_i(n), bess_j(n), bess_k(n), bess_y(n)
      ! .. Executable Statements ..
      WRITE (nag_std_out,*) 'Example Program Results for nag_bessel_fun_ex02'

      WRITE (nag_std_out,*)
      nu = 5.1_wp
      z = CMPLX(3.0_wp,2.0_wp,kind=wp)
      WRITE (nag_std_out,fmt2) 'Results for z = ', z, ',  nu = ', nu, &
       ',  scale = .FALSE.'
      WRITE (nag_std_out,*) 'n          I(z)               J(z) &
       &              K(z)               Y(z)'

      bess_i = nag_bessel_i(z,nu,n)
      bess_j = nag_bessel_j(z,nu,n)
      bess_k = nag_bessel_k(z,nu,n)
      bess_y = nag_bessel_y(z,nu,n)

      DO i = 1, n
        WRITE (nag_std_out,fmt1) i, bess_i(i), bess_j(i), bess_k(i), bess_y(i)
      END DO

      nu = 2.1_wp
      z = CMPLX(1.0_wp,-2.0_wp,kind=wp)
      WRITE (nag_std_out,*)
      WRITE (nag_std_out,fmt2) 'Results for z = ', z, ',  nu = ', nu, &
       ',  scale = .TRUE.'
      WRITE (nag_std_out,*) 'n          I(z)               J(z) &
       &              K(z)               Y(z)'

      bess_i = nag_bessel_i(z,nu,n,scale=.TRUE.)
      bess_j = nag_bessel_j(z,nu,n,scale=.TRUE.)
      bess_k = nag_bessel_k(z,nu,n,scale=.TRUE.)
      bess_y = nag_bessel_y(z,nu,n,scale=.TRUE.)

      DO i = 1, n
        WRITE (nag_std_out,fmt1) i, bess_i(i), bess_j(i), bess_k(i), bess_y(i)
      END DO

    END PROGRAM nag_bessel_fun_ex02
