CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
      SUBROUTINE CORRECT_VSW_H(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 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(VSW)
!	    REAL(KIND=4), INTENT(INOUT) :: VSW
!	  END SUBROUTINE CORRECT_VSW_H
!	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     18-FEB-1997    John Paquette
C
C This version:   1.1   16-APR-1999
C
C DEVELOPMENT HISTORY:
C 
C  Author       Date            Description of Change 
C  --------     -----------     --------------------- 
C  J. PAQUETTE  18-FEB-1997     Created(from CORRECT_VSW)
C  L. Bleau	16-APR-1999	added declarations, IMPLICIT NONE
C  L. Bleau	15-NOV-1999	added formal comment block
C  L. Bleau	15-MAR-2000	added comments
C 
C-
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
CDEC$ IDENT	'1.1'
C
      IMPLICIT NONE
      INTEGER NUM_SEGMENTS
      PARAMETER (NUM_SEGMENTS=11)
      INTEGER I
      LOGICAL SEGMENT
      REAL*8 VSW 
      REAL*8 LLIMIT(NUM_SEGMENTS)/0., 300., 325., 365., 405., 465., 510., 600., 675., 760., 870./
      REAL*8 ULIMIT(NUM_SEGMENTS)/300., 325., 365., 405., 465., 510., 600., 675., 760., 870., 1050./
      REAL*8 OFFSET(NUM_SEGMENTS)/0.915000, 1.20410, 0.815859, 1.15548, 0.855169, 1.32005, 
     &                            0.817815, 1.32230, 0.661820, 1.22230, 0.884620 /
      REAL*8 SLOPE(NUM_SEGMENTS) /0.00030000, -0.00066381, 0.00053091, -0.00039957, 0.00034195, -0.00065779,
     &                            0.00032698, -0.00051383, 0.00046471, -0.00027273, 0.00011538 /
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
          VSW =VSW/(OFFSET(I) + VSW*SLOPE(I))
          SEGMENT = .TRUE. 
        ENDIF
        I = I + 1
 200  CONTINUE
C
      RETURN
      END
