    PROGRAM nag_gamma_fun_ex02

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

      ! .. Use Statements ..
      USE nag_examples_io, ONLY : nag_std_out
      USE nag_gamma_fun, ONLY : nag_polygamma
      ! .. Implicit None Statement ..
      IMPLICIT NONE
      ! .. Intrinsic Functions ..
      INTRINSIC KIND
      ! .. Parameters ..
      INTEGER, PARAMETER :: m = 5, n = 4
      INTEGER, PARAMETER :: wp = KIND(1.0D0)
      ! .. Local Scalars ..
      INTEGER :: i
      ! .. Local Arrays ..
      REAL (wp) :: psi(0:n-1), x(m)
      ! .. Executable Statements ..
      WRITE (nag_std_out,*) 'Example Program Results for nag_gamma_fun_ex02'

      WRITE (nag_std_out,*)
      WRITE (nag_std_out,*) &
       '      x          psi(0,x)      psi(1,x)      psi(2,x)      psi(3,x)'
      x = (/ 0.1_wp, 0.5_wp, 2.5_wp, 3.6_wp, 8.0_wp/)

      DO i = 1, m

        CALL nag_polygamma(x(i),psi)

        WRITE (nag_std_out,fmt='(1X,5(1PE12.4,2X))') x(i), psi
      END DO

    END PROGRAM nag_gamma_fun_ex02
