*     G11CAF Example Program Text
*     Mark 19 Release. NAG Copyright 1999.
*     .. Parameters ..
      INTEGER          NIN, NOUT
      PARAMETER        (NIN=5,NOUT=6)
      INTEGER          NMAX, MMAX, SMAX, MLWK
      PARAMETER        (NMAX=500,MMAX=20,SMAX=10,MLWK=10000)
*     .. Local Scalars ..
      DOUBLE PRECISION DEV, TOL
      INTEGER          I, IFAIL, IP, IPRINT, J, LDZ, LWK, M, MAXIT, N,
     +                 NS
*     .. Local Arrays ..
      DOUBLE PRECISION B(MMAX), COV(MMAX*(MMAX+1)/2), SC(MMAX),
     +                 SE(MMAX), WK(MLWK), Z(NMAX,MMAX)
      INTEGER          IC(NMAX), ISI(NMAX), ISZ(MMAX), NCA(SMAX),
     +                 NCT(SMAX)
*     .. External Subroutines ..
      EXTERNAL         G11CAF
*     .. Executable Statements ..
      WRITE (NOUT,*) 'G11CAF Example Program Results'
*     Skip heading in data file
      READ (NIN,*)
      LDZ = NMAX
      LWK = MLWK
      TOL = 1.0D-5
      READ (NIN,*) N, M, NS, MAXIT, IPRINT
      IF (N.LE.NMAX .AND. M.LE.MMAX .AND. NS.LE.SMAX) THEN
         DO 20 I = 1, N
            READ (NIN,*) ISI(I), IC(I), (Z(I,J),J=1,M)
   20    CONTINUE
         READ (NIN,*) (ISZ(J),J=1,M), IP
         READ (NIN,*) (B(J),J=1,M)
*
         IFAIL = 0
*
         CALL G11CAF(N,M,NS,Z,LDZ,ISZ,IP,IC,ISI,DEV,B,SE,SC,COV,NCA,NCT,
     +               TOL,MAXIT,IPRINT,WK,LWK,IFAIL)
*
         WRITE (NOUT,*)
         WRITE (NOUT,99999) ' Deviance = ', DEV
         WRITE (NOUT,*)
         WRITE (NOUT,*) ' Strata     No. Cases   No. Controls'
         WRITE (NOUT,*)
         DO 40 I = 1, NS
            WRITE (NOUT,99998) I, NCA(I), NCT(I)
   40    CONTINUE
         WRITE (NOUT,*)
         WRITE (NOUT,*) ' Parameter      Estimate',
     +     '       Standard Error'
         WRITE (NOUT,*)
         DO 60 I = 1, IP
            WRITE (NOUT,99997) I, B(I), SE(I)
   60    CONTINUE
      END IF
*
99999 FORMAT (A,D13.4)
99998 FORMAT (3X,I3,2(10X,I2))
99997 FORMAT (I6,2(10X,F8.4))
      END
