      SUBROUTINE CR1CNT(GAMMA,GAMMA2,BAD,TIME,INBOARD)
C
C CR1 ROUTINE
C
C WRITTEN BY S. B. KRAMER  10/03/95
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,800),GAMMA2(3,800),PRISEN(3),SECSEN(3)
C
      INCLUDE 'UNPACK.INC'
C
      IF (SYS2(32)) RECTEST = .TRUE.
C
      DO IWRD = 1,800
C
C 8 MF CYCLE COUNTER (80 MF / CR-1 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) PRIOFF(IAX) = OBOFF(IAX,OBRNG(ICYC))
        IF (.NOT.INBOARD) SECOFF(IAX) = IBOFF(IAX,IBRNG(ICYC))
        IF (.NOT.INBOARD) PRISEN(IAX) = OBSENS(IAX,OBRNG(ICYC))
        IF (.NOT.INBOARD) SECSEN(IAX) = IBSENS(IAX,IBRNG(ICYC))
        IF (INBOARD) PRIOFF(IAX) = IBOFF(IAX,IBRNG(ICYC))
        IF (INBOARD) SECOFF(IAX) = OBOFF(IAX,OBRNG(ICYC))
        IF (INBOARD) PRISEN(IAX) = IBSENS(IAX,IBRNG(ICYC))
        IF (INBOARD) SECSEN(IAX) = OBSENS(IAX,OBRNG(ICYC))
       END DO
C
C BEGIN 3 AXES GAMMA CONVERSION
C
       DO IAX = 1,3
C
C CONVERT PRIMARY MODE CR-1 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-1 COUNTS TO GAMMAS
C
        GAMMA2(IAX,IWRD) = BAD
        IF (SREF(IAX,IWRD).NE.0) GAMMA2(IAX,IWRD) =
     &  (SREF(IAX,IWRD)-SECOFF(IAX))*SECSEN(IAX)
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))') 
     &  IWRD,PREF(1,IWRD),PREF(2,IWRD),PREF(3,IWRD),
     &  GAMMA(1,IWRD),GAMMA(2,IWRD),GAMMA(3,IWRD),
     &  IWRD,SREF(1,IWRD),SREF(2,IWRD),SREF(3,IWRD),
     &  GAMMA2(1,IWRD),GAMMA2(2,IWRD),GAMMA2(3,IWRD)
C
       END IF
C
      END DO
C
      RETURN 
      END
