!+ Subroutine to perform a parabolic fit.
!
! Method:
!	Three values, F1, F2 and F3 are supplied at points S1, S2 and
!	S3. A parabola, Q0+Q1*([S]-S0)**2 is fitted.
!
! Current Owner of Code: J. M. Edwards
!
! History:
!	Version		Date			Comment
!	1.0		12-04-95		First Version under RCS
!						(J. M. Edwards)
!
! Description of Code:
!   FORTRAN 77  with extensions listed in documentation.
!
!- ---------------------------------------------------------------------
      SUBROUTINE FIT_PARABOLA(S1, S2, S3
     &   , F1, F2, F3
     &   , S0
     &   , L_FIT)
!
!
      IMPLICIT NONE
!
!
!     INCLUDE HEADER FILES.
      INCLUDE 'incl/prec_machine.ucf'
      INCLUDE 'incl/precision.pcf'
!
!     DUMMY ARGUMENTS.
      LOGICAL	!, INTENT(OUT)
     &    L_FIT
!             FIT SUCCEEDED
      REAL*8	!, INTENT(IN)
     &     S1
!             DATA POINT
     &   , S2
!             DATA POINT
     &   , S3
!             DATA POINT
     &   , F1
!             DATA VALUE
     &   , F2
!             DATA VALUE
     &   , F3
!             DATA VALUE
      REAL*8	!, INTENT(OUT)
     &     S0
!             POSITION OF MINIMUM
!
!     LOCAL VARIABLES.
      REAL*8
     &     A
!             ALGEBRAIC TERM
     &   , B
!             ALGEBRAIC TERM
     &   , C
!             ALGEBRAIC TERM
     &   , D
!             ALGEBRAIC TERM
!
!
!     LOCATE THE TURNING POINT.
      A=(F1-F2)*(S2-S3)
      B=A*(S2+S3)
      C=(F3-F2)*(S2-S1)
      D=C*(S2+S1)
      IF (ABS(A-C).GT.0.0D+00) THEN
         S0=0.5D+00*(B-D)/(A-C)
!        CHECK THAT IT IS A MINIMUM.
         IF (ABS(F1-F2).GT.0.0D+00) THEN
            IF (((F1-F2)*(S1-S2)*(S1+S2-2.0D+00*S0))
     &            .GT.0.0D+00) THEN
               L_FIT=.TRUE.
            ELSE
               L_FIT=.FALSE.
            ENDIF
         ELSE
            IF (((F2-F3)*(S2-S3)*(S2+S3-2.0D+00*S0))
     &            .GT.0.0D+00) THEN
               L_FIT=.TRUE.
            ELSE
               L_FIT=.FALSE.
            ENDIF
         ENDIF
      ELSE
         L_FIT=.FALSE.
      ENDIF
!
!
!
!
      RETURN
      END
