    PROGRAM g01eufe

!      G01EUF Example Program Text

!      Mark 23 Release. NAG Copyright 2011.

!      .. Use Statements ..
       USE nag_library, ONLY : g01euf, g01zuf, nag_wp, x02alf
!      .. Implicit None Statement ..
       IMPLICIT NONE
!      .. Parameters ..
       INTEGER, PARAMETER              :: mode = 1, nin = 5, nout = 6
!      .. Local Scalars ..
       REAL (KIND=nag_wp)              :: beta2, c1, c2, rkappa, x, xl, xu, y
       INTEGER                         :: ifail
!      .. Local Arrays ..
       REAL (KIND=nag_wp)              :: rcomm(322)
!      .. Executable Statements ..
       WRITE (nout,*) 'G01EUF Example Program Results'
       WRITE (nout,*)

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

!      Display titles
       WRITE (nout,99998) 'X', 'RKAPPA', 'BETA2', 'Y', 'IFAIL'
       WRITE (nout,*)

       c1 = -x02alf()
       c2 = -x02alf()
D_LP:  DO
          READ (nin,*,IOSTAT=ifail) x, rkappa, beta2
          IF (ifail/=0) THEN
             EXIT D_LP
          END IF

          IF ((rkappa/=c1) .OR. (beta2/=c2)) THEN
!            If RKAPPA or BETA2 have changed, initialise array RCOMM
             ifail = 0
             CALL g01zuf(rkappa,beta2,mode,xl,xu,rcomm,ifail)
          END IF

!         Compute the value of the Vavilov distribution function
          ifail = 0
          y = g01euf(x,rcomm,ifail)

!         Display results
          WRITE (nout,99999) x, rkappa, beta2, y, ifail
          c1 = rkappa
          c2 = beta2
       END DO D_LP

99999  FORMAT (1X,F4.1,5X,F4.1,5X,F4.1,3X,1P,E12.4,I6)
99998  FORMAT (1X,A2,5X,A6,4X,A5,8X,A1,8X,A5)
    END PROGRAM g01eufe
