      LOGICAL FUNCTION L15CT_COMP_INI()
C----------------------------------------------------------------------
C-
C-   Purpose and Methods : 
C-
C-   Returned value  : 
C-   Inputs  : 
C-   Outputs : 
C-   Controls: 
C-
C-   Created  11-MAY-1994   Gregory L. Griffin
C-
C----------------------------------------------------------------------
      IMPLICIT NONE
C----------------------------------------------------------------------

      INCLUDE 'D0$INC:L15CALDBB_DATA_BLOCK.PARAMS'
      INCLUDE 'D0$INC:L15CAL_COMP_ERROR_COUNT.INC'
      INCLUDE 'D0$INC:L15CT_LUNS.INC'
      INCLUDE 'D0$INC:L15CT_COMP_INFO.INC'
      INCLUDE 'D0$INC:L15CT_COMP_RCP_VARS.INC'
      INCLUDE 'D0$INC:L15CT_COMP_ntuple.INC'

      INTEGER i, j, k
      INTEGER ierr
      LOGICAL OK

      INTEGER   iunit, ier
      CHARACTER filename*14

      L15CT_COMP_INI = .TRUE.

      type *, '&^%$#@!)(*& In INI'

C     ***** Setup columnwise ntuple

      nid      = 1
      TOPNAME  = 'l15ct_comp'
      FILENAME = TOPNAME // '.paw'
      type *, 'Opening ', FILENAME, ' .........'
      CALL GTUNIT(211,IUNIT,IER)
      CALL HROPEN(IUNIT,TOPNAME,FILENAME,'N',1024,IER)

      CALL HBNT(nid, 'L1.5 Cal Trig Compare', ' ')


      CALL HBNAME( nid, 'LWTF', LWTF_header(1),
     &     ' LWTF_header(2):I, LWTF_debug(2):I, LWTF_8(2):I' )





C     ***** Zero counters

      num_evts = 0

      Ecount_num_no_2_crates = 0
      Ecount_LWTF_Header  = 0


      DO i=1,2
        count_normal(i)        = 0
        count_MFP(i)           = 0
        count_not_norm_MFP(i)  = 0
        Ecount_Crate_ID(i)     = 0 
        Ecount_data_valid(i)   = 0

        LWTF_header(i)         = 0
        LWTF_debug(i)          = 0
        LWTF_8(i)              = 0
      ENDDO
      DO i=1,4
        DO j=1,11
          DO k=0,4
            diff_debug(k,j,i)              = 0
            diff_debug_at_least_one(k,j,i) = 0
          ENDDO
        ENDDO
      ENDDO
      DO i=1,11
        diff_LDSP_HEADER(i) = 0
        DO j=1,3
          diff_LDSP_LW(i,j) = 0
        ENDDO
      ENDDO
      CALL VZERO(diff_header,L15CAL_HEADER_LENGTH)

C     ***** OPEN files

      CALL GTUNIT(211,LUN(1),ierr)
      CALL GTUNIT(211,LUN(2),ierr)
      CALL GTUNIT(211,LUN(3),ierr)
      CALL GTUNIT(211,LUN(4),ierr)

      CALL D0OPEN(LUN(1), 'L15CAL_COMP.brief','O',OK)
      CALL D0OPEN(LUN(2), 'L15CAL_COMP.full','O',OK)
      CALL D0OPEN(LUN(3), 'L15CAL_COMP.sum','O',OK)
      CALL D0OPEN(LUN(4), 'L15CAL_COMP.test','O',OK)


C     ***** Init and read in RCP

      CALL INRCP('L15CT_COMPARE.RCP',ierr)
      IF (ierr .NE. 0) THEN
        CALL ERRMSG('L15CT_COMPARE','L15CT_COMP_INI',                   
     &    'Cannot find L15CT_COMPARE.RCP','F')
      ENDIF
      CALL EZPICK('L15CT_COMPARE_RCP')
      CALL EZERR(ierr)
      IF (ierr .NE. 0) THEN
        CALL ERRMSG('L15CT_COMPARE','L15CT_COMP_INI',
     &    'L15CT_COMPARE.RCP does not have L15CT_COMPARE bank','F')
      ENDIF


c      CALL EZGET('DO_HEADER',      DO_HEADER,       IERR)
      CALL EZGET('DO_FRAME_CODE',  DO_FRAME_CODE,   IERR)
      CALL EZGET('DO_FRAME_PARAM', DO_FRAME_PARAM,  IERR)
      CALL EZGET('DO_TOOL_PARAM',  DO_TOOL_PARAM,   IERR)
      CALL EZGET('DO_LDSP',        DO_LDSP,         IERR)
      CALL EZGET('DO_GDSP',        DO_GDSP,         IERR)
      CALL EZGET('DO_DEBUG',       DO_DEBUG,        IERR)

      CALL EZGET('MAX_HEADER_DIFFS',     MAX_HEADER_DIFFS,     IERR)
      CALL EZGET('MAX_FRAME_CODE_DIFFS', MAX_FRAME_CODE_DIFFS, IERR)
      CALL EZGET('MAX_FRAME_PARAM_DIFFS',MAX_FRAME_PARAM_DIFFS,IERR)
      CALL EZGET('MAX_TOOL_PARAM_DIFFS', MAX_TOOL_PARAM_DIFFS, IERR)
      CALL EZGET('MAX_LDSP_DIFFS'  ,     MAX_LDSP_DIFFS,       IERR)
      CALL EZGET('MAX_GDSP_DIFFS'  ,     MAX_GDSP_DIFFS,       IERR)
      CALL EZGET('MAX_DEBUG_DIFFS' ,     MAX_DEBUG_DIFFS(0),   IERR)

      CALL EZGET('REAL_ONLY',       REAL_ONLY,        IERR)

      CALL EZRSET     !Dumps bank or something like that.

  999 RETURN
      END
