    PROGRAM nag_bessel_fun_ex07

      ! 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_y
      ! .. Implicit None Statement ..
      IMPLICIT NONE
      ! .. Intrinsic Functions ..
      INTRINSIC CMPLX, KIND
      ! .. Parameters ..
      INTEGER, PARAMETER :: wp = KIND(1.0D0)
      CHARACTER (*), PARAMETER :: fmt1 = '(1X,''('',F9.4,'','',F9.4,'')'')'
      CHARACTER (*), PARAMETER :: fmt2 = &
       '(1X,A,1X,''('',F9.4,'','',F9.4,'')'',A,F9.4)'
      ! .. Local Scalars ..
      INTEGER :: i, n
      REAL (wp) :: nu
      COMPLEX (wp) :: z
      ! .. Local Arrays ..
      COMPLEX (wp), ALLOCATABLE :: bess(:)
      ! .. Executable Statements ..
      WRITE (nag_std_out,*) 'Example Program Results for nag_bessel_fun_ex07'

      WRITE (nag_std_out,*)
      n = 3
      WRITE (nag_std_out,*) 'Calling with n = 3'
      WRITE (nag_std_out,*)

      ALLOCATE (bess(n))           ! Allocate storage

      nu = 1.58_wp
      z = CMPLX(-2.3_wp,5.6_wp,kind=wp)

      bess = nag_bessel_y(z,nu,n)

      WRITE (nag_std_out,fmt2) 'Results for z = ', z, '  and nu = ', nu
      WRITE (nag_std_out,*) 'scale = .FALSE.'
      WRITE (nag_std_out,*)
      WRITE (nag_std_out,fmt1) bess
      WRITE (nag_std_out,*)

      DO i = 1, n

        bess(i) = nag_bessel_y(z,nu+i-1,scale=.TRUE.)

      END DO

      WRITE (nag_std_out,*) 'scale = .TRUE.'
      WRITE (nag_std_out,*)
      WRITE (nag_std_out,fmt1) bess
      WRITE (nag_std_out,*)

      DEALLOCATE (bess)            ! Deallocate storage

    END PROGRAM nag_bessel_fun_ex07
