CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
      SUBROUTINE CORRECT_VSW_JUN97(VSW)
C+
C
C FUNCTIONAL DESCRIPTION:
C
C     Subroutine to correct the solar wind speed from the PM.  The correction
C     is based on the speed itself, and is based on a series of linear fits to
C     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.  In principle, a single
C     subroutine could replace both CORRECT_VSW and this routine, but that
C     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_JUN97(VSW)
!	    REAL(KIND=4), INTENT(INOUT) :: VSW
!	  END SUBROUTINE CORRECT_VSW_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     24-JUN-1997    John Paquette
C
C This version:   1.0   24-JUN-1997
C
C DEVELOPMENT HISTORY:
C 
C  Author       Date            Description of Change 
C  --------     -----------     --------------------- 
C  J. PAQUETTE  24-JUN-1997     Created
C  L. Bleau	15-NOV-1999	added comments
C  L. Bleau	15-MAR-2000	added comments
C 
C-
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
CDEC$ IDENT	'1.0'
C
      PARAMETER NUM_SEGMENTS=6
      INTEGER I
      LOGICAL SEGMENT
      REAL*4 VSW 
      REAL*4 LLIMIT(NUM_SEGMENTS)/250.0, 291.53, 348.51, 387.75, 439.4, 580.0/
      REAL*4 ULIMIT(NUM_SEGMENTS)/291.53, 348.51, 387.75, 439.4, 580.0, 9999./
      REAL*4 OFFSET(NUM_SEGMENTS)/0.96, 0.74634, 1.1589, 0.96447, 0.91242, 1.01/
      REAL*4 INV_SLOPE(NUM_SEGMENTS) /1.E15, 1364.5, -2217.3, 19793., 5918.2, 1.E15/
C
C Set flag telling us whether we've found the right segment to .FALSE.
C
      SEGMENT = .FALSE.
C
C If Vsw < lower limit of fit, apply the correction factor corresponding to the lower limit
C
      IF(VSW .LT. LLIMIT(1))THEN
        VSW =VSW/(OFFSET(1) + LLIMIT(1)/INV_SLOPE(1))
        SEGMENT = .TRUE.
      ENDIF
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/INV_SLOPE(I))
          SEGMENT = .TRUE. 
        ENDIF
        I = I + 1
 200  CONTINUE
C
      RETURN
      END
