      SUBROUTINE CR5FLD(GAMMA,GAMMA2,SCF,AMBIENT,TIME,BAD)
C
C USING 576 SECOND CR-5 EDR RECORD, INTERPOLATE SECONDARY MAG
C DATA (.96 SEC) POINTS TO PRIMARY MAG DATA RATE (.24 SEC) 
C TO COMPUTE SPACECRAFT AND AMBIENT FIELDS.  
C
C ORIGINAL SOURCE - SBK 10/21/94
C MODIFIED TO INCLUDE DELTA MODULATED WORDS -  SBK 02/21/96
C
      INTEGER*2 TIME(6)
      REAL*4 GAMMA(3,2400),GAMMA2(3,600),SCF(3,2400),AMBIENT(3,2400)
C
C     IMPLEMENT SPACECRAFT FIELD COUPLING COEFFICIENT, ALPHA, 
C     IN COMPUTATION OF S/C FIELD
C
C     COEF = ALPHA/(1.0-ALPHA)  WHERE ALPHA = .1876
C          = 0.230921
C
      DATA ALPHA/0.1876/,COEF/0.230921/
C
      INCLUDE 'UNPACK.INC'
C
      DO I=1,2400
C
C STEP INTERPOLATE .96 SECOND CR-5 SECONDARY MAG DATA TO .24 SECOND 
C PRIMARY MAG RATE
C
       ISEC = (I-1)/4 + 1
       DO J = 1,3
C
C COMPUTER DIFFERENCE BETWEEN PRIMARY AND SECONDARY MAGNETOMETERS
C
        IF (GAMMA(J,I).NE.BAD.AND.
     &      GAMMA2(J,ISEC).NE.BAD) THEN
         SCF(J,I) = (GAMMA2(J,ISEC)-GAMMA(J,I))*COEF
        ELSE
         SCF(J,I) = BAD
        END IF
C
C COMPUTE AMBIENT FIELD FOR RETURN AT PRIMARY MODE RATE
C
        IF (GAMMA(J,I).NE.BAD.AND.SCF(J,I).NE.BAD) THEN
         AMBIENT(J,I) = GAMMA(J,I) - SCF(J,I)
        ELSE
         AMBIENT(J,I) = BAD
        END IF
C
       END DO
C
      END DO
C
      RETURN
      END
