anchor.diff:          WRITE(*,*) 'FINISHED WITH:', DELTAC, CON, CHI2
       END IF
   
  -    CALC_CHI2 = CHI2 / NDX
  +    CALC_CHI2 = CHI2 / (NDX - 1)
   
   END FUNCTION CALC_CHI2
   
  
positive.code: 
  END FUNCTION CALC_RFACTOR
  
  DOUBLE PRECISION FUNCTION CALC_CHI2 (QOBS, IOBS, OBSERR, ICALC, N, QMIN, QMAX, CON, VERBOSE)
  
      ! Calculate the reduced chi-squared statistic comparing IOBS (experiment) to
      ! ICALC (calculated curve)
      !
      ! Chi^2 = 1/N * sum ((F_obs - F_calc)^2 / OBSERR^2)
  
      DOUBLE PRECISION, DIMENSION(*), INTENT(IN) :: QOBS, OBSERR, IOBS, ICALC
      INTEGER, INTENT(IN) :: N
  
negative.code: 
          DO NDX = 1, N
              IF ( ( QOBS(NDX) .LE. QMAX ) .AND. ( QOBS(NDX) .GT. QMIN ) ) THEN
                  TMPCHI2 = ( (CON * ICALC(NDX)) - IOBS(NDX) )**2
                  TMPCHI2 = TMPCHI2 / OBSERR2(NDX)
                  CHI2 = CHI2 + TMPCHI2
              END IF
  