c*** utilfuns.f
      SUBROUTINE ICAP (A, B, RESULT)
C
      IMPLICIT DOUBLE PRECISION (A-H,O-Z)
C
C Written by:
C
C
c   Hong Jiang
c   Dept. of Math., Stat. and Computer Science
c   Marquette University
C   Milwaukee, WI 53233
C
C         and
C
C   R. Baker Kearfott
C
C   Department of Mathematics
C   U.S.L. Box 4-1010
C   Lafayette, LA 70504
C
C   April 11, 1992
C
C Part of the interval elementary function library
C (Utility function)
C
C***********************************************************************
C
C Function --
C
C  DICAP computes the intersection of the two intervals A and B, and
C  places  the result in RESULT.
C
C***********************************************************************
C
C Argument declarations --
C
      DOUBLE PRECISION A(2), B(2), RESULT(2)
C
C***********************************************************************
C
C Internal variable declarations --
C
C
C***********************************************************************
C
C Common block declarations --
C
C
      INTEGER ISIG, IERR, IROUT, IPRTCL, ISEVER, IERPUN
      COMMON /ERFLGS/ ISIG, IERR, IROUT, IPRTCL, ISEVER, IERPUN
C
C The above common block stores signalling information for error
C conditions.  In particular,
C
C ISIG   is set to 0 at the beginning of SIMINI, and is reset
C        to the severity level of the error (1, 2, or 3) when an error
C        condition occurs.  The user may reset the flag to zero after an
C        error condition, depending on the error, if ISEVER is set to
C        allow execution after an error of its severity.
C
C IERR   is the number of the error condition, if an error occurred in
C        the last routine in INTLIB with error checking.  If no errors
C        occurred in the last such routine called, then IERR is zero.
C        The specific error conditions associated with particular error
C        numbers is defined in the routine ERRTST.
C
C IROUT  is the code number of the package routine in which the error
C        occurred
C
C IPRTCL controls the level of error which is printed.  IPRCTL=0 prints
C        all levels, while IPRCTL=1 prints only errors of level 1 or
C        greater.  If IPRTCL=4, then no error information is printed.
C
C ISEVER gives the error level which will stop execution.  ISEVER=0
C        causes any error to stop execution, while ISEVER>=3 causes only
C        errors of severity 3 to stop execution.  Generally, severity 3
C        errors correspond to when it is impossible to assign a result
C        with any meaningful interpretation.
C
C IERPUN is the Fortran unit number to which errors should be printed.
C
C***********************************************************************
C
C Fortran-supplied functions and subroutines --
C
C   MIN, MAX
C
C***********************************************************************
C
C Package-supplied functions and subroutines --
C
C   ERRTST
C
C***********************************************************************
C
C Internal variable declarations --
C
      DOUBLE PRECISION T(2)
C
C***********************************************************************
C
C Beginning of executable statements --
C
C  Identifying code for this routine --
C
      IROUT = 13
      IERR = 0
C
      T(1) = MAX (A(1), B(1))
      T(2) = MIN (A(2), B(2))
      RESULT(1) = T(1)
      RESULT(2) = T(2)
      IF (RESULT(1).GT.RESULT(2)) THEN
         IERR=13
         CALL ERRTST(RESULT)
      END IF
C
      RETURN
      END
C***********************************************************************
C***********************************************************************
      LOGICAL FUNCTION IDISJ (A, B)
C
      IMPLICIT DOUBLE PRECISION (A-H,O-Z)
C
C Written by:
C
C
c   Hong Jiang
c   Dept. of Math., Stat. and Computer Science
c   Marquette University
C   Milwaukee, WI 53233
C
C         and
C
C   R. Baker Kearfott
C
C   Department of Mathematics
C   U.S.L. Box 4-1010
C   Lafayette, LA 70504
C
C   April 11, 1992
C
C Part of the interval elementary function library
C (Utility function)
C
C***********************************************************************
C
C Function --
C
C  This function returns .TRUE. if the intervals A and B are disjoint,
C  and .FALSE. otherwise.
C
C***********************************************************************
C
C Argument declarations --
C
      DOUBLE PRECISION A(2), B(2)
C
C***********************************************************************
C
C Beginning of executable statements --
C
      IDISJ = (A(2) .LT. B(1)) .OR. (B(2) .LT. A(1))
C
      RETURN
      END
C***********************************************************************
C***********************************************************************
      SUBROUTINE IHULL (A, B, RESULT)
C
      IMPLICIT DOUBLE PRECISION (A-H,O-Z)
C
C Written by:
C
C
c   Hong Jiang
c   Dept. of Math., Stat. and Computer Science
c   Marquette University
C   Milwaukee, WI 53233
C
C         and
C
C   R. Baker Kearfott
C
C   Department of Mathematics
C   U.S.L. Box 4-1010
C   Lafayette, LA 70504
C
C   April 11, 1992
C
C Part of the interval elementary function library
C (Utility function)
C
C***********************************************************************
C
C Function --
C
C  IHULL returns the convex-hull of the interval A and the interval B
C  in RESULT.  If one of the intervals is empty (lower bound is greater
C  than upper bound), then just the upper interval is returned.
C
C***********************************************************************
C
C Argument declarations --
C
      DOUBLE PRECISION A(2), B(2), RESULT(2)
C
C***********************************************************************
C
C Internal variable declarations --
C
      DOUBLE PRECISION T(2)
C
C***********************************************************************
C
C Beginning of executable statements --
C
      IF ( A(1).GT.A(2) ) THEN
         IF (B(1).GT.B(2)) THEN
            T(1) = MAX(A(2),B(2))
            T(2) = MIN(A(1),B(2))
         ELSE
            T(1) = B(1)
            T(2) = B(2)
         END IF
      ELSE IF ( B(1).GT.B(2) ) THEN
         T(1) = A(1)
         T(2) = A(2)
      ELSE
         T(1) = MIN (A(1), B(1))
         T(2) = MAX (A(2), B(2))
         RESULT(1) = T(1)
         RESULT(2) = T(2)
      END IF
C
      RETURN
      END
C***********************************************************************
C***********************************************************************
      LOGICAL FUNCTION IILEI (A, B)
C
      IMPLICIT DOUBLE PRECISION (A-H,O-Z)
C
C Written by:
C
C
c   Hong Jiang
c   Dept. of Math., Stat. and Computer Science
c   Marquette University
C   Milwaukee, WI 53233
C
C         and
C
C   R. Baker Kearfott
C
C   Department of Mathematics
C   U.S.L. Box 4-1010
C   Lafayette, LA 70504
C
C   April 11, 1992
C
C Part of the interval elementary function library
C (Utility function)
C
C***********************************************************************
C
C Function --
C
C  IILEI sets its value to .TRUE. if interval A is in the closure of
C  interval B.  The value of IILEI is .FALSE. otherwise.
C
C***********************************************************************
C
C Argument declarations --
C
      DOUBLE PRECISION A(2), B(2)
C
C***********************************************************************
C
C Beginning of executable statements --
C
      IILEI = (A(1) .GE. B(1)) .AND. (A(2) .LE. B(2))
C
      RETURN
      END
C***********************************************************************
C***********************************************************************
      LOGICAL FUNCTION IILTI (A, B)
C
      IMPLICIT DOUBLE PRECISION (A-H,O-Z)
C
C Written by:
C
C
c   Hong Jiang
c   Dept. of Math., Stat. and Computer Science
c   Marquette University
C   Milwaukee, WI 53233
C
C         and
C
C   R. Baker Kearfott
C
C   Department of Mathematics
C   U.S.L. Box 4-1010
C   Lafayette, LA 70504
C
C   April 11, 1992
C
C Part of the interval elementary function library
C (Utility function)
C
C***********************************************************************
C
C Function --
C
C  IILE sets its value to .TRUE. if interval A is in the interior of
C  interval B.  The value of IILE is .FALSE. otherwise.
C
C***********************************************************************
C
C Argument declarations --
C
      DOUBLE PRECISION A(2), B(2)
C
C***********************************************************************
C
C Beginning of executable statements --
C
      IILTI = (A(1) .GT. B(1)) .AND. (A(2) .LT. B(2))
C
      RETURN
      END
C***********************************************************************
C***********************************************************************
      DOUBLE PRECISION FUNCTION IINF (A)
C
      IMPLICIT DOUBLE PRECISION (A-H,O-Z)
C
C Written by:
C
C
c   Hong Jiang
c   Dept. of Math., Stat. and Computer Science
c   Marquette University
C   Milwaukee, WI 53233
C
C         and
C
C   R. Baker Kearfott
C
C   Department of Mathematics
C   U.S.L. Box 4-1010
C   Lafayette, LA 70504
C
C   April 11, 1992
C
C Part of the interval elementary function library
C (Utility function)
C
C***********************************************************************
C
C Function --
C
C  IINF returns the lower endpoint of the interval A.
C
C***********************************************************************
C
C Argument declarations --
C
      DOUBLE PRECISION A(2)
C
C***********************************************************************
C
C Beginning of executable statements --
C
      IINF = A(1)
C
      RETURN
      END
C***********************************************************************
C***********************************************************************
      DOUBLE PRECISION FUNCTION IMID (X)
C
      IMPLICIT DOUBLE PRECISION (A-H,O-Z)
C
C Written by:
C
C
c   Hong Jiang
c   Dept. of Math., Stat. and Computer Science
c   Marquette University
C   Milwaukee, WI 53233
C
C         and
C
C   R. Baker Kearfott
C
C   Department of Mathematics
C   U.S.L. Box 4-1010
C   Lafayette, LA 70504
C
C   April 11, 1992
C
C Part of the interval elementary function library
C (Utility function)
C
C***********************************************************************
C
C Function --
C
C  IMID returns a floating point approximation to the midpoint
C  of the interval A, using available floating point arithmetic.  The
C  value returned by this routine can be considered to DEFINE the
C  midpoint.
C
C***********************************************************************
C
C Argument declarations --
C
      DOUBLE PRECISION X(2)
C
C***********************************************************************
C
C Common block declarations --
C
      DOUBLE PRECISION MAXX, MXLGM1, NEGINF, POSINF, A(2), PI(2), E(2),
     *   PI2(2), PI3(2), PI4(2), PI6(2), PI8(2), E14(2), A3(2), ONE(2),
     *   OD2F(2), OD3F(2), OD4F(2), OD5F(2), OD6F(2), OD7F(2), OD8F(2),
     *   OD9F(2), OD10F(2), OD11F(2), OD12F(2), OD14F(2), EIGHT(2),
     *   ZERO(2), TWO(2), THREE(2), FOUR(2), SXTNTH(2), NINE(2), TEN(2),
     *   TWOT7(2), SQT10(2), ESXTNT(2), SXTEEN(2), THIRD(2), FOURTH(2),
     *   FIFTH(2), SIXTH(2), SEVNTH(2), EIGHTH(2), NINTH(2), TENTH(2),
     *   ELEVTH(2), TWLVTH(2), THRTTH(2), FORTTH(2), TT7TH(2), TINY2,
     *   CBTEP, SQT3(2), ODSQT3(2)
C
      COMMON /MTHCNS/  MAXX, MXLGM1, NEGINF, POSINF, A, PI, E, PI2, PI3,
     *   PI4, PI6, PI8, ONE, OD2F, OD3F, E14, A3, OD4F, OD5F, OD6F,
     *   OD7F, OD8F, OD9F, OD10F, OD11F, OD12F, OD14F, EIGHT, ZERO, TWO,
     *   THREE, FOUR, SXTNTH, NINE, TEN, TWOT7, SQT10, ESXTNT, SXTEEN,
     *   THIRD, FOURTH, FIFTH, SIXTH, SEVNTH, EIGHTH, NINTH, TENTH,
     *   ELEVTH, TWLVTH, THRTTH, FORTTH, TT7TH, TINY2, CBTEP, SQT3,
     *   ODSQT3
C
      INTEGER ITINY2, JTINY2
C
      COMMON /IMATH/   ITINY2, JTINY2
C
C
C  The above common blocks hold mathematical constants which are used in
C  the elementary function routines.
C
C  Variable descriptions
C
C  MAXX        a double precision representation of the largest
C              representable integer
C
C  MXLGM1      an approximation to the logarithm of .25 times the
C              largest representable machine number, minus 1. This
C              should be a rigorous lower bound on the logarithm of the
C              largest representable machine number.  Its default
C              computation in SIMINI is to use the Fortran LOG function.
C              This should be changed if the Fortran LOG function is not
C              sufficiently accurate.
C
C
C  A           an interval enclosure for 1/pi
C
C  PI          an interval enclosure for pi
C
C  PI2         an interval enclosure for pi/2
C
C  PI3         an interval enclosure for pi/3
C
C  PI4         an interval enclosure for pi/4
C
C  PI6         an interval enclosure for pi/6
C
C  PI8         an interval enclosure for pi/8
C
C  E           an interval enclosure for E
C
C  E14         an interval enclosure for e^{1/4}
C
C  ESXTNT      an interval enclosure for e^{1/16}
C
C  SQT10       an interval enclosure for SQRT(10)
C
C  TINY2       the maximum of the smallest machine number and the
C              reciprocal of the largest machine number.  This quantity
C              is checked to avoid overflow in certain places.
C
C  CBTEP       an approximation to the cube root of six times the
C              largest distance between numbers.
C
C  SQT3        an interval enclosure for the square root of 3.
C
C  ODSQT3      the reciprocal of the square root of 3 times
C              1+ 100*MXULP, used in argument reduction in the
C              arctangent routine.
C
C  ITINY2      the logarithm base 10 of TINY2 truncated to an integer.
C
C  JTINY2      sixteen times the logarithm base e of TINY2 truncated to
C              an integer.
C
C  See the statements in the routine SIMINI for the definitions of
C  the other constants.
C
C***********************************************************************
C
C Beginning of executable statements --
C
      IMID = X(1) + (X(2) - X(1)) / TWO(1)
C
      RETURN
      END
C***********************************************************************
C***********************************************************************
      DOUBLE PRECISION FUNCTION IMIG (A)
C
      IMPLICIT DOUBLE PRECISION (A-H,O-Z)
C
C Written by:
C
C   R. Baker Kearfott
C
C   Department of Mathematics
C   U.S.L. Box 4-1010
C   Lafayette, LA 70504
C
C   April 11, 1992
C
C Part of the interval elementary function library
C (Utility function)
C
C***********************************************************************
C
C Function --
C
C  IMIG returns the mignitude of the interval A. Since ABS is not
C  assumed to give an exact result, the result is rounded down.
C
C***********************************************************************
C
C Argument declarations --
C
      DOUBLE PRECISION A(2)
C
C***********************************************************************
C
C Internal variable declarations --
C
      DOUBLE PRECISION TMP(2)
C
C***********************************************************************
C
C Fortran-supplied functions and subroutines --
C
C  ABS, MIN
C
C***********************************************************************
C
C Package-supplied functions and subroutines --
C
C  RNDOUT
C
C***********************************************************************
C
C Beginning of executable statements --
C
      IF ( ((A(1).GT.0D0) .AND. (A(2).GT.0D0))
     * .OR.((A(1).LT.0D0) .AND. (A(2).LT.0D0)) ) THEN
         TMP(1) = ABS(A(2))
         CALL RNDOUT(TMP,.TRUE.,.FALSE.)
         TMP(2)=TMP(1)
         TMP(1) = ABS(A(1))
         CALL RNDOUT(TMP,.TRUE.,.FALSE.)
         IMIG = MIN (TMP(1), TMP(2))
      ELSE
         IMIG = 0D0
      END IF
C
      RETURN
      END
C***********************************************************************
C***********************************************************************
      SUBROUTINE INEG (A, RESULT)
C
      IMPLICIT DOUBLE PRECISION (A-H,O-Z)
C
C Written by:
C
C
c   Hong Jiang
c   Dept. of Math., Stat. and Computer Science
c   Marquette University
C   Milwaukee, WI 53233
C
C         and
C
C   R. Baker Kearfott
C
C   Department of Mathematics
C   U.S.L. Box 4-1010
C   Lafayette, LA 70504
C
C   April 11, 1992
C
C Part of the interval elementary function library
C (Utility function)
C
C***********************************************************************
C
C Function --
C
C  INEG performs interval unary negation.  The result is rounded out in
C  case the negatives of the endpoints are not representable.
C
C***********************************************************************
C
C Argument declarations --
C
      DOUBLE PRECISION A(2), RESULT(2)
C
C***********************************************************************
C
C Package-supplied functions and subroutines --
C
C  RNDOUT
C
C***********************************************************************
C
C Internal variable declarations --
C
      DOUBLE PRECISION T(2)
C
C***********************************************************************
C
C Beginning of executable statements --
C
      T(1) = A(1)
      T(2) = A(2)
      RESULT(1) = -T(2)
      RESULT(2) = -T(1)
      CALL RNDOUT (RESULT, .TRUE.,.TRUE.)
C
      RETURN
      END
C***********************************************************************
C***********************************************************************
      DOUBLE PRECISION FUNCTION INTABS (A)
C
      IMPLICIT DOUBLE PRECISION (A-H,O-Z)
C
C Written by:
C
C
c   Hong Jiang
c   Dept. of Math., Stat. and Computer Science
c   Marquette University
C   Milwaukee, WI 53233
C
C         and
C
C   R. Baker Kearfott
C
C   Department of Mathematics
C   U.S.L. Box 4-1010
C   Lafayette, LA 70504
C
C   April 11, 1992
C
C Part of the interval elementary function library
C (Utility function)
C
C***********************************************************************
C
C Function --
C
C  INTABS returns the maximum absolute value of the interval A.
C  Since ABS is not assumed to give an exact result, the result is
C  rounded up.
C
C***********************************************************************
C
C Argument declarations --
C
      DOUBLE PRECISION A(2)
C
C***********************************************************************
C
C Internal variable declarations --
C
      DOUBLE PRECISION TMP(2)
C
C***********************************************************************
C
C Fortran-supplied functions and subroutines --
C
C  ABS, MAX
C
C***********************************************************************
C
C Package-supplied functions and subroutines --
C
C  RNDOUT
C
C***********************************************************************
C
C Beginning of executable statements --
C
      TMP(2) = ABS(A(1))
      CALL RNDOUT(TMP,.FALSE.,.TRUE.)
      TMP(1)=TMP(2)
      TMP(2) = ABS(A(2))
      CALL RNDOUT(TMP,.FALSE.,.TRUE.)
C
      INTABS = MAX (TMP(1), TMP(2))
C
      RETURN
      END
C***********************************************************************
C***********************************************************************
      LOGICAL FUNCTION IRLEI (A, B)
C
      IMPLICIT DOUBLE PRECISION (A-H,O-Z)
C
C Written by:
C
C
c   Hong Jiang
c   Dept. of Math., Stat. and Computer Science
c   Marquette University
C   Milwaukee, WI 53233
C
C         and
C
C   R. Baker Kearfott
C
C   Department of Mathematics
C   U.S.L. Box 4-1010
C   Lafayette, LA 70504
C
C   April 11, 1992
C
C Part of the interval elementary function library
C (Utility function)
C
C***********************************************************************
C
C Function --
C
C  IRLEI sets its value to .TRUE. if double precision value A is in the
C  closure of the interval B. The value of IRLEI is set to .FALSE.
C  otherwise.
C
C***********************************************************************
C
C Argument declarations --
C
      DOUBLE PRECISION A, B(2)
C
C***********************************************************************
C
C Beginning of executable statements --
C
      IRLEI = (A .GE. B(1)) .AND. (A .LE. B(2))
C
      RETURN
      END
C***********************************************************************
C***********************************************************************
      LOGICAL FUNCTION IRLTI (A, B)
C
      IMPLICIT DOUBLE PRECISION (A-H,O-Z)
C
C Written by:
C
C
c   Hong Jiang
c   Dept. of Math., Stat. and Computer Science
c   Marquette University
C   Milwaukee, WI 53233
C
C         and
C
C   R. Baker Kearfott
C
C   Department of Mathematics
C   U.S.L. Box 4-1010
C   Lafayette, LA 70504
C
C   April 11, 1992
C
C Part of the interval elementary function library
C (Utility function)
C
C***********************************************************************
C
C Function --
C
C  IRLEI sets its value to .TRUE. if double precision value A is in the
C  interior of the interval B. The value of IRLEI is set to .FALSE.
C  otherwise.
C
C***********************************************************************
C
C Argument declarations --
C
      DOUBLE PRECISION A, B(2)
C
C***********************************************************************
C
C Beginning of executable statements --
C
      IRLTI = (A .GT. B(1)) .AND. (A .LT. B(2))
C
      RETURN
      END
C***********************************************************************
C***********************************************************************
      DOUBLE PRECISION FUNCTION ISUP (A)
C
      IMPLICIT DOUBLE PRECISION (A-H,O-Z)
C
C Written by:
C
C
c   Hong Jiang
c   Dept. of Math., Stat. and Computer Science
c   Marquette University
C   Milwaukee, WI 53233
C
C         and
C
C   R. Baker Kearfott
C
C   Department of Mathematics
C   U.S.L. Box 4-1010
C   Lafayette, LA 70504
C
C   April 11, 1992
C
C Part of the interval elementary function library
C (Utility function)
C
C***********************************************************************
C
C Function --
C
C  IINF returns the upper endpoint of the interval A.
C
C***********************************************************************
C
C Argument declarations --
C
      DOUBLE PRECISION A(2)
C
C***********************************************************************
C
C Beginning of executable statements --
C
      ISUP = A(2)
C
      RETURN
      END
C***********************************************************************
C***********************************************************************
      SUBROUTINE IVL1 (R, RESULT)
C
      IMPLICIT DOUBLE PRECISION (A-H,O-Z)
C
C Written by:
C
C
c   Hong Jiang
c   Dept. of Math., Stat. and Computer Science
c   Marquette University
C   Milwaukee, WI 53233
C
C         and
C
C   R. Baker Kearfott
C
C   Department of Mathematics
C   U.S.L. Box 4-1010
C   Lafayette, LA 70504
C
C   April 11, 1992
C
C Part of the interval elementary function library
C (Utility function)
C
C***********************************************************************
C
C Function --
C
C  IVL1 constructs an interval RESULT from the double precision variable
C  R.  This is done by using simulated directed roundings with RNDOUT.
C
C***********************************************************************
C
C Argument declarations --
C
      DOUBLE PRECISION R, RESULT(2)
C
C***********************************************************************
C
C Package-supplied functions and subroutines --
C
C  RNDOUT
C
C***********************************************************************
C
C Internal variable declarations --
C
      DOUBLE PRECISION T
C
C***********************************************************************
C
C Beginning of executable statements --
C
      T = R
      RESULT(1) = T
      RESULT(2) = T
      IF (T.NE.0D0) CALL RNDOUT (RESULT, .TRUE.,.TRUE.)
C
      RETURN
      END
C***********************************************************************
C***********************************************************************
      SUBROUTINE IVL2 (R1, R2, RESULT)
C
      IMPLICIT DOUBLE PRECISION (A-H,O-Z)
C
C Written by:
C
C
c   Hong Jiang
c   Dept. of Math., Stat. and Computer Science
c   Marquette University
C   Milwaukee, WI 53233
C
C         and
C
C   R. Baker Kearfott
C
C   Department of Mathematics
C   U.S.L. Box 4-1010
C   Lafayette, LA 70504
C
C   April 11, 1992
C
C Part of the interval elementary function library
C (Utility function)
C
C***********************************************************************
C
C Function --
C
C  IVL2 constructs an interval RESULT, roughly equal to [R1,R2], from
C  the double precision variables R1 and R2.  This is done by using
C  simulated directed roundings with RNDOUT.
C
C***********************************************************************
C
C Argument declarations --
C
      DOUBLE PRECISION R1, R2, RESULT(2)
C
C***********************************************************************
C
C Package-supplied functions and subroutines --
C
C  RNDOUT
C
C***********************************************************************
C
C Internal variable declarations --
C
      DOUBLE PRECISION T(2)
      LOGICAL RNDUP, RNDDWN
C
C***********************************************************************
C
C Common block declarations --
C
C
      INTEGER ISIG, IERR, IROUT, IPRTCL, ISEVER, IERPUN
      COMMON /ERFLGS/ ISIG, IERR, IROUT, IPRTCL, ISEVER, IERPUN
C
C The above common block stores signalling information for error
C conditions.  In particular,
C
C ISIG   is set to 0 at the beginning of SIMINI, and is reset
C        to the severity level of the error (1, 2, or 3) when an error
C        condition occurs.  The user may reset the flag to zero after an
C        error condition, depending on the error, if ISEVER is set to
C        allow execution after an error of its severity.
C
C IERR   is the number of the error condition, if an error occurred in
C        the last routine in INTLIB with error checking.  If no errors
C        occurred in the last such routine called, then IERR is zero.
C        The specific error conditions associated with particular error
C        numbers is defined in the routine ERRTST.
C
C IROUT  is the code number of the package routine in which the error
C        occurred
C
C IPRTCL controls the level of error which is printed.  IPRCTL=0 prints
C        all levels, while IPRCTL=1 prints only errors of level 1 or
C        greater.  If IPRTCL=4, then no error information is printed.
C
C ISEVER gives the error level which will stop execution.  ISEVER=0
C        causes any error to stop execution, while ISEVER>=3 causes only
C        errors of severity 3 to stop execution.  Generally, severity 3
C        errors correspond to when it is impossible to assign a result
C        with any meaningful interpretation.
C
C IERPUN is the Fortran unit number to which errors should be printed.
C
C***********************************************************************
C
C Beginning of executable statements --
C
C  Identifying code for this routine --
C
      IROUT = 15
      IERR = 0
C
      T(1) = R1
      T(2) = R2
      RESULT(1) = T(1)
      RESULT(2) = T(2)
C
      IF (RESULT(2).LT.RESULT(1)) THEN
         IERR = 1
         CALL ERRTST(RESULT)
      END IF
C
      RNDDWN = T(1).NE.0D0
      RNDUP = T(2).NE.0D0
      CALL RNDOUT (RESULT, RNDDWN, RNDUP)
C
      RETURN
      END
C***********************************************************************
C***********************************************************************
      SUBROUTINE IVLABS (A, RESULT)
C
      IMPLICIT DOUBLE PRECISION (A-H,O-Z)
C
C Written by:
C
C   R. Baker Kearfott
C
C   Department of Mathematics
C   U.S.L. Box 4-1010
C   Lafayette, LA 70504
C
C   April 11, 1992
C
C Part of the interval elementary function library
C (Utility function)
C
C***********************************************************************
C
C Function --
C
C  IVLABS returns a rigorous bound on the range of the absolute value
C  of the interval A.  The intrinsic function ABS is assumed to be
C  accurate to the same accuracy as the elementary operations.
C
C***********************************************************************
C
C Argument declarations --
C
      DOUBLE PRECISION A(2), RESULT(2)
C
C***********************************************************************
C
C Internal variable declarations --
C
      DOUBLE PRECISION TMP(2), TA(2)
C
C***********************************************************************
C
C Fortran-supplied functions and subroutines --
C
C  ABS
C
C***********************************************************************
C
C Package-supplied functions and subroutines --
C
C  RNDOUT
C
C***********************************************************************
C
C Beginning of executable statements --
C
      TA(1) = A(1)
      TA(2) = A(2)

      TMP(1) = ABS(TA(1))
      TMP(2) = ABS(TA(2))

      IF (TMP(1).LE.TMP(2)) THEN
         RESULT(1) = TMP(1)
         RESULT(2) = TMP(2)
      ELSE
         RESULT(1) = TMP(2)
         RESULT(2) = TMP(1)
      END IF

      CALL RNDOUT(RESULT,.TRUE.,.TRUE.)

      IF ( ( TA(1).LE.0 .AND. TA(2).GE.0 ) .OR. RESULT(1).LT. 0)
     1   RESULT(1) = 0D0

      RETURN
      END
C***********************************************************************
C***********************************************************************
      SUBROUTINE IVLI (A, RESULT)
C
      IMPLICIT DOUBLE PRECISION (A-H,O-Z)
C
C Written by:
C
C   R. Baker Kearfott
C
C   Department of Mathematics
C   U.S.L. Box 4-1010
C   Lafayette, LA 70504
C
C   January 8, 1993
C
C Part of the interval elementary function library
C (Utility function)
C
C***********************************************************************
C
C Function --
C
C  IVLI places the contents of interval A in RESULT.
C
C***********************************************************************
C
C Argument declarations --
C
      DOUBLE PRECISION A(2), RESULT(2)
C
C***********************************************************************
C
C Beginning of executable statements --
C
      RESULT(1) = A(1)
      RESULT(2) = A(2)
C
      RETURN
      END
C***********************************************************************
C***********************************************************************
      DOUBLE PRECISION FUNCTION IWID (A)
C
      IMPLICIT DOUBLE PRECISION (A-H,O-Z)
C
C Written by:
C
C   R. Baker Kearfott
C
C   Department of Mathematics
C   U.S.L. Box 4-1010
C   Lafayette, LA 70504
C
C   April 11, 1992
C
C Part of the interval elementary function library
C (Utility function)
C
C***********************************************************************
C
C Function --
C
C  IWID returns the width of the interval A, rounded up.
C
C***********************************************************************
C
C Argument declarations --
C
      DOUBLE PRECISION A(2)
C
C***********************************************************************
C
C Internal variable declarations --
C
      DOUBLE PRECISION TMP(2)
C
C***********************************************************************
C
C Package-supplied functions and subroutines --
C
C  RNDOUT
C
C***********************************************************************
C
C Beginning of executable statements --
C
      TMP(2) = A(2)-A(1)
      CALL RNDOUT(TMP,.FALSE.,.TRUE.)
C
      IWID = TMP(2)
C
      RETURN
      END

