      SUBROUTINE CR1FLD(GAMMA,GAMMA2,SCF,AMBIENT,TIME,BAD)
C
C USING 48 SECOND CR-1 EDR RECORD, COMPUTE SPACECRAFT AND AMBIENT FIELDS.  
C
C WRITTEN BY S. B. KRAMER   10/04/95
C CHECK FOR PRIME LFM  SBK  10/26/95
C
      INTEGER*2 TIME(6)
C
      REAL*4 GAMMA(3,800),GAMMA2(3,800),SCF(3,800),AMBIENT(3,800)
C
C     IMPLEMENT SPACECRAFT FIELD COUPLING COEFFICIENT, ALPHA, 
C     IN COMPUTATION OF S/C FIELD
C
C     COEF = ALPHA/(1.0-ALPHA)  WHERE ALPHA = .1846
C          = 0.230921
C
      DATA ALPHA/0.1876/,COEF/0.230921/
C
      INCLUDE 'UNPACK.INC'
C
      DO I=1,800
       ISTAT = (I-1)/100 + 1
       DO J = 1,3
C
C COMPUTER DIFFERENCE BETWEEN PRIMARY AND SECONDARY MAGNETOMETERS
C AND THEN COMPUTE AMBIENT FIELD FOR RETURN AT PRIMARY MAG RATE.
C *NOTE:  PRIMARY MAG RATE = SECONDARY MAG RATE FOR CR-1 MODE.
C
        IF ( GAMMA(J,I).NE.BAD .AND.
     &       GAMMA2(J,I).NE.BAD ) THEN
         SCF(J,I) = (GAMMA2(J,I)-GAMMA(J,I))*COEF
         IF ( PRIME(ISTAT) ) THEN                     ! INBOARD PRIME
          SCF(J,I) = -SCF(J,I)
          AMBIENT(J,I) = GAMMA2(J,I) - SCF(J,I)
         ELSE                                         ! OUTBOARD PRIME
          AMBIENT(J,I) = GAMMA(J,I) - SCF(J,I)
         END IF
        ELSE
         SCF(J,I) = BAD
         AMBIENT(J,I) = BAD
        END IF
C
       END DO
      END DO
C
      RETURN
      END
