Program g01eufe

!     G01EUF Example Program Text

!     Mark 25 Release. NAG Copyright 2014.

!     .. 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