# qawce.f

          SUBROUTINE QAWCE (F, A, B, C, EPSABS, EPSREL, LIMIT, RESULT,
         +   ABSERR, NEVAL, IER, ALIST, BLIST, RLIST, ELIST, IORD, LAST)
    C***BEGIN PROLOGUE  QAWCE
    C***PURPOSE  The routine calculates an approximation result to a
    C            CAUCHY PRINCIPAL VALUE I = Integral of F*W over (A,B)
    C            (W(X) = 1/(X-C), (C.NE.A, C.NE.B), hopefully satisfying
    C            following claim for accuracy
    C            ABS(I-RESULT).LE.MAX(EPSABS,EPSREL*ABS(I))
    C***LIBRARY   SLATEC (QUADPACK)
    C***CATEGORY  H2A2A1, J4
    C***TYPE      SINGLE PRECISION (QAWCE-S, DQAWCE-D)
    C***KEYWORDS  AUTOMATIC INTEGRATOR, CAUCHY PRINCIPAL VALUE,
    C             CLENSHAW-CURTIS METHOD, QUADPACK, QUADRATURE,
    C             SPECIAL-PURPOSE
    C***AUTHOR  Piessens, Robert
    C             Applied Mathematics and Programming Division
    C             K. U. Leuven
    C           de Doncker, Elise
    C             Applied Mathematics and Programming Division
    C             K. U. Leuven
    C***DESCRIPTION
    C
    C        Computation of a CAUCHY PRINCIPAL VALUE
    C        Standard fortran subroutine
    C        Real version
    C
    C        PARAMETERS
    C         ON ENTRY
    C            F      - Real
    C                     Function subprogram defining the integrand
    C                     function F(X). The actual name for F needs to be
    C                     declared E X T E R N A L in the driver program.
    C
    C            A      - Real
    C                     Lower limit of integration
    C
    C            B      - Real
    C                     Upper limit of integration
    C
    C            C      - Real
    C                     Parameter in the WEIGHT function, C.NE.A, C.NE.B
    C                     If C = A OR C = B, the routine will end with
    C                     IER = 6.
    C
    C            EPSABS - Real
    C                     Absolute accuracy requested
    C            EPSREL - Real
    C                     Relative accuracy requested
    C                     If  EPSABS.LE.0
    C                     and EPSREL.LT.MAX(50*REL.MACH.ACC.,0.5D-28),
    C                     the routine will end with IER = 6.
    C
    C            LIMIT  - Integer
    C                     Gives an upper bound on the number of subintervals
    C                     in the partition of (A,B), LIMIT.GE.1
    C
    C         ON RETURN
    C            RESULT - Real
    C                     Approximation to the integral
    C
    C            ABSERR - Real
    C                     Estimate of the modulus of the absolute error,
    C                     which should equal or exceed ABS(I-RESULT)
    C
    C            NEVAL  - Integer
    C                     Number of integrand evaluations
    C
    C            IER    - Integer
    C                     IER = 0 Normal and reliable termination of the
    C                             routine. It is assumed that the requested
    C                             accuracy has been achieved.
    C                     IER.GT.0 Abnormal termination of the routine
    C                             the estimates for integral and error are
    C                             less reliable. It is assumed that the
    C                             requested accuracy has not been achieved.
    C            ERROR MESSAGES
    C                     IER = 1 Maximum number of subdivisions allowed
    C                             has been achieved. One can allow more sub-
    C                             divisions by increasing the value of
    C                             LIMIT. However, if this yields no
    C                             improvement it is advised to analyze the
    C                             the integrand, in order to determine the
    C                             the integration difficulties. If the
    C                             position of a local difficulty can be
    C                             determined (e.g. SINGULARITY,
    C                             DISCONTINUITY within the interval) one
    C                             will probably gain from splitting up the
    C                             interval at this point and calling
    C                             appropriate integrators on the subranges.
    C                         = 2 The occurrence of roundoff error is detec-
    C                             ted, which prevents the requested
    C                             tolerance from being achieved.
    C                         = 3 Extremely bad integrand behaviour
    C                             occurs at some interior points of
    C                             the integration interval.
    C                         = 6 The input is invalid, because
    C                             C = A or C = B or
    C                             (EPSABS.LE.0 and
    C                              EPSREL.LT.MAX(50*REL.MACH.ACC.,0.5D-28))
    C                             or LIMIT.LT.1.
    C                             RESULT, ABSERR, NEVAL, RLIST(1), ELIST(1),
    C                             IORD(1) and LAST are set to zero. ALIST(1)
    C                             and BLIST(1) are set to A and B
    C                             respectively.
    C
    C            ALIST   - Real
    C                      Vector of dimension at least LIMIT, the first
    C                       LAST  elements of which are the left
    C                      end points of the subintervals in the partition
    C                      of the given integration range (A,B)
    C
    C            BLIST   - Real
    C                      Vector of dimension at least LIMIT, the first
    C                       LAST  elements of which are the right
    C                      end points of the subintervals in the partition
    C                      of the given integration range (A,B)
    C
    C            RLIST   - Real
    C                      Vector of dimension at least LIMIT, the first
    C                       LAST  elements of which are the integral
    C                      approximations on the subintervals
    C
    C            ELIST   - Real
    C                      Vector of dimension LIMIT, the first  LAST
    C                      elements of which are the moduli of the absolute
    C                      error estimates on the subintervals
    C
    C            IORD    - Integer
    C                      Vector of dimension at least LIMIT, the first K
    C                      elements of which are pointers to the error
    C                      estimates over the subintervals, so that
    C                      ELIST(IORD(1)), ..., ELIST(IORD(K)) with K = LAST
    C                      If LAST.LE.(LIMIT/2+2), and K = LIMIT+1-LAST
    C                      otherwise, form a decreasing sequence
    C
    C            LAST    - Integer
    C                      Number of subintervals actually produced in
    C                      the subdivision process
    C
    C***REFERENCES  (NONE)
    C***ROUTINES CALLED  QC25C, QPSRT, R1MACH
    C***REVISION HISTORY  (YYMMDD)
    C   800101  DATE WRITTEN
    C   890531  Changed all specific intrinsics to generic.  (WRB)
    C   890831  Modified array declarations.  (WRB)
    C   890831  REVISION DATE from Version 3.2
    C   891214  Prologue converted to Version 4.0 format.  (BAB)
    C***END PROLOGUE  QAWCE