      SUBROUTINE CR2CNT(GAMMA,GAMMA2,BAD,TIME,INBOARD)
C
C CR-2 ROUTINE
C
C ORIGINAL SOURCE WRITTEN BY SANDY KRAMER  03/22/96
C
C THIS SUBROUTINE SUBTRACTS THE ZERO OFFSET FROM EACH COUNT AND MULTIPIES THE
C RESULTING DIFFERENCE BY THE SENSITIVITY TO YIELD FIELD STRENGTH IN GAMMAS.
C
      INTEGER*2 TIME(6)
      INTEGER*4 PRIOFF(3),SECOFF(3)
      LOGICAL*1 RECTEST,INBOARD
      REAL*4 GAMMA(3,400),GAMMA2(3,200),PRISEN(3),SECSEN(3)
C
      INCLUDE 'UNPACK.INC'
C
      IF ( SYS2(32) ) RECTEST = .TRUE.
C
      DO IWRD = 1,400
C
       IWRD2 = (IWRD-1)/2 + 1
C
C STAT1 WORD COUNTER (5 STAT1 WORDS PER 40 MF CR-2 RECORD)
C
       ICYC = INT((IWRD-1)/80) + 1
C
C ASSIGN OFFSETS AND SENSITIVITIES TO LOCAL VARIABLES CHECKING PRIME
C LFM STATUS.
C
       DO IAX = 1,3
        IF ( .NOT.INBOARD ) THEN
         PRIOFF(IAX) = OBOFF(IAX,OBRNG(ICYC))
         SECOFF(IAX) = IBOFF(IAX,IBRNG(ICYC))
         PRISEN(IAX) = OBSENS(IAX,OBRNG(ICYC))
         SECSEN(IAX) = IBSENS(IAX,IBRNG(ICYC))
        ELSE
         PRIOFF(IAX) = IBOFF(IAX,IBRNG(ICYC))
         SECOFF(IAX) = OBOFF(IAX,OBRNG(ICYC))
         PRISEN(IAX) = IBSENS(IAX,IBRNG(ICYC))
         SECSEN(IAX) = OBSENS(IAX,OBRNG(ICYC))
        END IF
       END DO
C
C BEGIN 3 AXES GAMMA CONVERSION
C
       DO IAX = 1,3
C
C CONVERT PRIMARY MODE CR-2 COUNTS TO GAMMAS
C
        GAMMA(IAX,IWRD) = BAD
        IF ( PREF(IAX,IWRD).NE.0 ) GAMMA(IAX,IWRD) = 
     &  (PREF(IAX,IWRD)-PRIOFF(IAX))*PRISEN(IAX)
C
C CONVERT SECONDARY MODE CR-2 COUNTS TO GAMMAS
C
        IF ( MOD(IWRD,2).NE.0 ) THEN
         GAMMA2(IAX,IWRD2) = BAD
         IF ( SREF(IAX,IWRD2).NE.0 ) GAMMA2(IAX,IWRD2) =
     &   (SREF(IAX,IWRD2)-SECOFF(IAX))*SECSEN(IAX)
        END IF
C
C END 3 AXES GAMMA CONVERSION
C
       END DO
C
C OUTPUT COUNTS AND GAMMAS
C
       IF ( RECTEST ) THEN
C
        IF ( IWRD.EQ.1 ) WRITE(81,'(1X,''EDR TIME: '',6(1X,I3))') TIME
C
        WRITE(81,'(4(1X,I5),3(1X,F7.3),4(1X,I5),3(1X,F7.3),
     &             1X,I2,2(1X,Z4.4),4(1X,I1))') 
     &  IWRD,PREF(1,IWRD),PREF(2,IWRD),PREF(3,IWRD),
     &  GAMMA(1,IWRD),GAMMA(2,IWRD),GAMMA(3,IWRD),
     &  IWRD2,SREF(1,IWRD2),SREF(2,IWRD2),SREF(3,IWRD2),
     &  GAMMA2(1,IWRD2),GAMMA2(2,IWRD2),GAMMA2(3,IWRD2),
     &  ICYC,STAT1(ICYC),STAT2(ICYC),
     &  IBMODE(ICYC),OBMODE(ICYC),IBRNG(ICYC),OBRNG(ICYC)
C
       END IF
C
      END DO
C
      RETURN 
      END
