CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
      SUBROUTINE CORRECT_ANGLE(THETA_BIN,ANGLE)
C+
C
C FUNCTIONAL DESCRIPTION:
C
C     Routine to derive actual angle from the theta bin using a multi-line
C     segment fit.
C
C     Formerly used these values for offsets: -28.590, -12.752, -10.687,
C     -13.8154   and these values for slopes: 4.9452, 1.7776, 1.4335, 1.7811
C     New values derived from fit to 16 months of data (through 134/1997),
C     EXCEPT, lowest line segment, which is required to be -7.8 degrees at 4,
C     and to be continuous at 5. 
C
C FORMAL ARGUMENTS:
C
C     THETA_BIN:
C       R*4        I	Input value of theta bin.
C
C     ANGLE:
C       R*4        O	Upon return will contain the actual (computed) angle.
C
C INTERFACE:
C
!	INTERFACE
!	  ELEMENTAL SUBROUTINE CORRECT_ANGLE(THETA_BIN,ANGLE)
!	    REAL(KIND=4), INTENT(IN) :: THETA_BIN
!	    REAL(KIND=4), INTENT(OUT) :: ANGLE
!	  END SUBROUTINE CORRECT_ANGLE
!	END INTERFACE
C
C IMPLICIT INPUTS:
C
C     None
C
C IMPLICIT OUTPUTS:
C
C     None
C
C SIDE EFFECTS:
C
C     None
C
C COMMON BLOCKS:
C
C     None
C
C INCLUDE FILES:
C
C     None
C
C DESIGN:
C
C
C
C CREATED:
C
C     13-FEB-1997    John Paquette
C
C This version:   1.3   16-APR-1999
C    
C DEVELOPMENT HISTORY:
C 
C  Author       Date            Description of Change 
C  --------     -----------     --------------------- 
C  J. PAQUETTE  13-FEB-1997     Created
C  J. PAQUETTE  13-FEB-1997     Original 3 segment fit supplanted by a 4
C                               segment fit; Changed 20's to 19's
C  J. PAQUETTE  23-MAY-1997     New slopes and offsets
C  L. Bleau	 1-APR-1999	added comments
C  L. Bleau	16-APR-1999	added declarations, IMPLICIT NONE
C  L. Bleau	 2-NOV-1999	added comments
C  L. Bleau	15-NOV-1999	added comments
C-
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
CDEC$ IDENT	'1.3'
C
      IMPLICIT NONE
      INTEGER NUM_SEGMENTS
      PARAMETER (NUM_SEGMENTS=4)
      REAL*4 THETA_BIN, ANGLE
      REAL*4 LLIMIT(NUM_SEGMENTS)/0.0, 5.0, 6.0, 9.0/
      REAL*4 ULIMIT(NUM_SEGMENTS)/5.0, 6.0, 9.0, 19.0/
      REAL*4 OFFSET(NUM_SEGMENTS)/-24.018, -13.356, -9.837, -17.0721/
      REAL*4 SLOPE(NUM_SEGMENTS)/4.0545, 1.9221, 1.3356, 2.1395/
      INTEGER I
      LOGICAL SEGMENT
C
C Idiot checks
C
      IF(THETA_BIN .LT. 0.0)THEN
        ANGLE = OFFSET(1)
        RETURN
      ELSEIF(THETA_BIN .GE. 19.0)THEN
        ANGLE = OFFSET(NUM_SEGMENTS) + SLOPE(NUM_SEGMENTS)*19.0
        RETURN
      ENDIF
C
C Set flag telling us whether we've found the right segment to .FALSE.
C
      SEGMENT = .FALSE.
C
C Find the segment that the current velocity lies in, then apply correction
C
      I = 1
      DO 200 WHILE((.NOT.SEGMENT).AND.(I .LE. NUM_SEGMENTS))
        IF((THETA_BIN .GE. LLIMIT(I)).AND.(THETA_BIN .LT. ULIMIT(I)))THEN
          ANGLE = OFFSET(I) + SLOPE(I)*THETA_BIN
          SEGMENT = .TRUE. 
        ENDIF
        I = I + 1
 200  CONTINUE
C
      RETURN
      END
