Program g01edfe

!     G01EDF Example Program Text

!     Mark 26 Release. NAG Copyright 2016.

!     .. Use Statements ..
      Use nag_library, Only: g01edf, nag_wp
!     .. Implicit None Statement ..
      Implicit None
!     .. Parameters ..
      Integer, Parameter               :: nin = 5, nout = 6
!     .. Local Scalars ..
      Real (Kind=nag_wp)               :: df1, df2, f, prob
      Integer                          :: ifail
      Character (1)                    :: tail
!     .. Executable Statements ..
      Write (nout,*) 'G01EDF Example Program Results'
      Write (nout,*)

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

!     Display titles
      Write (nout,*) ' TAIL      F      DF1     DF2     Probability'
      Write (nout,*)

d_lp: Do
        Read (nin,*,Iostat=ifail) tail, f, df1, df2
        If (ifail/=0) Then
          Exit d_lp
        End If

!       Calculate probability
        ifail = -1
        prob = g01edf(tail,f,df1,df2,ifail)
        If (ifail/=0) Then
          If (ifail/=4) Then
            Exit d_lp
          End If
        End If

!       Display results
        Write (nout,99999) tail, f, df1, df2, prob
      End Do d_lp

99999 Format (3X,A1,4X,F6.3,2F8.2,7X,F7.4)
    End Program g01edfe