    PROGRAM g07befe

!      G07BEF Example Program Text

!      Mark 23 Release. NAG Copyright 2011.

!      .. Use Statements ..
       USE nag_library, ONLY : g07bef, nag_wp
!      .. Implicit None Statement ..
       IMPLICIT NONE
!      .. Parameters ..
       INTEGER, PARAMETER              :: nin = 5, nout = 6
!      .. Local Scalars ..
       REAL (KIND=nag_wp)              :: beta, corr, dev, gamma, sebeta,      &
                                          segam, tol
       INTEGER                         :: ifail, lic, maxit, n, nit
       CHARACTER (1)                   :: cens
!      .. Local Arrays ..
       REAL (KIND=nag_wp), ALLOCATABLE :: wk(:), x(:)
       INTEGER, ALLOCATABLE            :: ic(:)
!      .. Executable Statements ..
       WRITE (nout,*) 'G07BEF Example Program Results'
       WRITE (nout,*)

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

!      Read in the problem size and control parameters
       READ (nin,*) cens, n, tol, maxit

       IF (cens=='N' .OR. cens=='n') THEN
          lic = 0
       ELSE
          lic = n
       END IF
       ALLOCATE (x(n),ic(lic),wk(n))

!      Read in data
       READ (nin,*) x(1:n)

!      Read in censor flag if required
       IF (lic>0) THEN
          READ (nin,*) ic(1:n)
       END IF

!      Read in initial estimate of GAMMA
       READ (nin,*) gamma

!      Calculate estimates
       ifail = 0
       CALL g07bef(cens,n,x,ic,beta,gamma,tol,maxit,sebeta,segam,corr,dev,nit, &
          wk,ifail)

!      Display results
       WRITE (nout,99999) ' BETA  = ', beta, ' Standard error = ', sebeta
       WRITE (nout,99999) ' GAMMA = ', gamma, ' Standard error = ', segam

99999  FORMAT (1X,2(A,F10.4))
    END PROGRAM g07befe
