CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
      SUBROUTINE CORRECT_VSW_H_JUN97(VSW)
C+
C
C FUNCTIONAL DESCRIPTION:
C
C     Subroutine to correct the solar wind speed from the Hefti algorithm.  The
C     correction is based on the speed itself, and is based on a series of
C     linear fits to several different speed ranges. 
C
C     The corrections in this routine are derived from 16 months of data
C     (ending DOY 153 of 1997).  This routine is meant to be applied after the
C     speed has already been corrected by CORRECT_VSW_H.  In principle, a
C     single subroutine could replace both CORRECT_VSW_H and this routine, but
C     that would have been more labor and time intensive. 
C
C FORMAL ARGUMENTS:
C
C     VSW:
C       R*4	  I/O	Variable containing the input solar wind speed.  Upon
C			return it will contain the corrected solar wind speed.
C
C INTERFACE:
C
!	INTERFACE
!	  SUBROUTINE CORRECT_VSW_H_JUN97(VSW)
!	    REAL(KIND=4), INTENT(INOUT) :: VSW
!	  END SUBROUTINE CORRECT_VSW_H_JUN97
!	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     26-JUN-1997    John Paquette
C
C This version:   1.0   26-JUN-1997
C
C DEVELOPMENT HISTORY:
C 
C  Author       Date            Description of Change 
C  --------     -----------     --------------------- 
C  J. PAQUETTE  26-JUN-1997     Created(from CORRECT_VSW_H)
C  L. Bleau	15-NOV-1999	added formal comment block
C  L. Bleau	15-MAR-2000	added comments
C 
C-
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
CDEC$ IDENT	'1.0'
C
      PARAMETER NUM_SEGMENTS=5
      INTEGER I
      LOGICAL SEGMENT
      REAL*8 VSW, CF 
      REAL*8 LLIMIT(NUM_SEGMENTS)/0., 328.82, 361.52, 565., 598.72/
      REAL*8 ULIMIT(NUM_SEGMENTS)/328.82, 361.52, 565., 598.72, 9999./
      REAL*8 OFFSET(NUM_SEGMENTS)/1.3168, 0.90802, 1.0107, 0.87958, 1.005/
      REAL*8 SLOPE(NUM_SEGMENTS) /-0.00098174, 0.00026142, -2.2569E-5, 0.000209048, 0.0/
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((VSW .GE. LLIMIT(I)).AND.(VSW .LT. ULIMIT(I)))THEN
C
C Restrict correction factor to 1.4 or less
C
          CF = MIN(OFFSET(I) + VSW*SLOPE(I),1.4D0)
          VSW =VSW/CF
          SEGMENT = .TRUE. 
        ENDIF
        I = I + 1
 200  CONTINUE
C
      RETURN
      END
