    PROGRAM g01edfe

!      G01EDF Example Program Text

!      Mark 23 Release. NAG Copyright 2011.

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