    PROGRAM g01ezfe

!      G01EZF Example Program Text

!      Mark 23 Release. NAG Copyright 2011.

!      .. Use Statements ..
       USE nag_library, ONLY : g01ezf, nag_wp
!      .. Implicit None Statement ..
       IMPLICIT NONE
!      .. Parameters ..
       INTEGER, PARAMETER              :: nin = 5, nout = 6
!      .. Local Scalars ..
       REAL (KIND=nag_wp)              :: d, prob
       INTEGER                         :: ifail, n1, n2
!      .. Executable Statements ..
       WRITE (nout,*) 'G01EZF Example Program Results'
       WRITE (nout,*)

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

!      Display titles
       WRITE (nout,*) '    D      N1    N2    Two-sided probability'
       WRITE (nout,*)

D_LP:  DO
          READ (nin,*,IOSTAT=ifail) n1, n2, d
          IF (ifail/=0) THEN
             EXIT D_LP
          END IF

!         Calculate probaility
          ifail = -1
          prob = g01ezf(n1,n2,d,ifail)
          IF (ifail/=0) THEN
             IF (ifail/=3) THEN
                EXIT D_LP
             END IF
          END IF

!         Display results
          WRITE (nout,99999) d, n1, n2, prob
       END DO D_LP

99999  FORMAT (1X,F7.4,2X,I4,2X,I4,10X,F7.4)
    END PROGRAM g01ezfe
