      SUBROUTINE XREFT(MODE,NCTL)
C   
C     THIS SUBROUTINE ACCUMULATES CROSS REFERENCES
C   
C     ENTRY PARAMETERS
C        MODE  - INDICATES DEFINITION (0), OR REFERENCE (1)
C        NCTL  - 1 INDICATES DO ONLY WRITE TO DISK
C        IXPNT - CURRENT POINTER INTO REFERENCE TABLE
C   
C   
      INTEGER FTYPE
      REAL ITABV(249)
      COMMON ICRD,IPRT,MCFLE,IDFLE,MCREC,IDREC,IFORM,ITRUN,ILOUT,IXCOL
      COMMON MLAB,MOPC,IBIT,ICCNT,IWORD,IERRL,IERRI,IEND,IFRMC
      COMMON LSOR,LIF,LSYM,LREF,LDEF,LOCT,ITRMI,ITRMO
      COMMON ILEN,KLEN,LLEN,KWORD,IFLD(2400),IYFLD,IZFLD
      COMMON IFBIT,ZVAL,CVAL,JREAD,IN(80),INB(80),LINE,IPAGE,LISN
      COMMON IALPH(37),IAST,IDOLR,ISHRP
      COMMON ICOLN,IBLNK,ICTAB,ISEMI,ICOMM,IPLUS,IMIN,IMULT,IDIV
      COMMON IRPAR,ILPAR,IATT(9),JATT(5),LATT(9),IFPAR(16),NBASE,JBASE
      COMMON ICOL,IFCOL,MCOL,MLCOL,IOLIN,ICNT,LTITL(50),IADDR(4,12)
      COMMON ITYPE,JTYPE,FTYPE,IERR,IERRS,IOPVA,JCOL,IBUG
      COMMON ITAB(4,249),ITABS(249),ITABV,NAME(4),INDEX,INDET,ISYM,LTAB
      COMMON IXTAB(256),MXREF,IXT,IXPNT,IXCNT,IXPAG,MCORE(128)
C INCLUDE(:F1:METAD.COM)
C   
      IF(IXT) 110,10,10
10    IF(IXCNT-IXPAG) 20,40,40
20    IF(NCTL) 30,30,50
30    IF(IXPNT-MXREF) 100,50,50
40    IXT = -LISN
      GO TO 110
C     WRITE OUT PAGE TO FILE
50    K = MXREF/64
      I1 = 0
      DO 70 I=1,K
      DO 60 M1 = 1,64
      M2 = I1+M1
      IXTAB(M1) = IXTAB(M2)
60    CONTINUE
      MCREC = IXT
C   
C     THE CROSS REFERENCE FILE IS WRITTEN INTO BY
C     THE FOLLOWING STATEMENT
C   
      CALL INOUT(3)
      I1 = I1+64
      IXT = IXT+1
70    CONTINUE
      IF(NCTL) 80,80,110
80    IXCNT = IXCNT+1 
      IXPNT = 0 
      IF(IXCNT-IXPAG) 100,40,40 
C     PUT DEFINITION OR REFERENCE IN TABLE
100   IXPNT = IXPNT+1 
      IXTAB(IXPNT) = INDEX
      IXPNT = IXPNT+1 
      IXTAB(IXPNT) = LISN*(MODE+MODE-1) 
110   RETURN
      END 
RN
      END 
