# dqawoe.f

          SUBROUTINE DQAWOE (F, A, B, OMEGA, INTEGR, EPSABS, EPSREL, LIMIT,
         +   ICALL, MAXP1, RESULT, ABSERR, NEVAL, IER, LAST, ALIST, BLIST,
         +   RLIST, ELIST, IORD, NNLOG, MOMCOM, CHEBMO)
    C***BEGIN PROLOGUE  DQAWOE
    C***PURPOSE  Calculate an approximation to a given definite integral
    C            I = Integral of F(X)*W(X) over (A,B), where
    C                     W(X) = COS(OMEGA*X)
    C                 or  W(X)=SIN(OMEGA*X),
    C            hopefully satisfying the following claim for accuracy
    C                 ABS(I-RESULT).LE.MAX(EPSABS,EPSREL*ABS(I)).
    C***LIBRARY   SLATEC (QUADPACK)
    C***CATEGORY  H2A2A1
    C***TYPE      DOUBLE PRECISION (QAWOE-S, DQAWOE-D)
    C***KEYWORDS  AUTOMATIC INTEGRATOR, CLENSHAW-CURTIS METHOD,
    C             EXTRAPOLATION, GLOBALLY ADAPTIVE,
    C             INTEGRAND WITH OSCILLATORY COS OR SIN FACTOR, QUADPACK,
    C             QUADRATURE, 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 Oscillatory integrals
    C        Standard fortran subroutine
    C        Double precision version
    C
    C        PARAMETERS
    C         ON ENTRY
    C            F      - Double precision
    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      - Double precision
    C                     Lower limit of integration
    C
    C            B      - Double precision
    C                     Upper limit of integration
    C
    C            OMEGA  - Double precision
    C                     Parameter in the integrand weight function
    C
    C            INTEGR - Integer
    C                     Indicates which of the WEIGHT functions is to be
    C                     used
    C                     INTEGR = 1      W(X) = COS(OMEGA*X)
    C                     INTEGR = 2      W(X) = SIN(OMEGA*X)
    C                     If INTEGR.NE.1 and INTEGR.NE.2, the routine
    C                     will end with IER = 6.
    C
    C            EPSABS - Double precision
    C                     Absolute accuracy requested
    C            EPSREL - Double precision
    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 subdivisions
    C                     in the partition of (A,B), LIMIT.GE.1.
    C
    C            ICALL  - Integer
    C                     If DQAWOE is to be used only once, ICALL must
    C                     be set to 1.  Assume that during this call, the
    C                     Chebyshev moments (for CLENSHAW-CURTIS integration
    C                     of degree 24) have been computed for intervals of
    C                     lengths (ABS(B-A))*2**(-L), L=0,1,2,...MOMCOM-1.
    C                     If ICALL.GT.1 this means that DQAWOE has been
    C                     called twice or more on intervals of the same
    C                     length ABS(B-A). The Chebyshev moments already
    C                     computed are then re-used in subsequent calls.
    C                     If ICALL.LT.1, the routine will end with IER = 6.
    C
    C            MAXP1  - Integer
    C                     Gives an upper bound on the number of Chebyshev
    C                     moments which can be stored, i.e. for the
    C                     intervals of lengths ABS(B-A)*2**(-L),
    C                     L=0,1, ..., MAXP1-2, MAXP1.GE.1.
    C                     If MAXP1.LT.1, the routine will end with IER = 6.
    C
    C         ON RETURN
    C            RESULT - Double precision
    C                     Approximation to the integral
    C
    C            ABSERR - Double precision
    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
    C                             requested 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
    C                             subdivisions by increasing the value of
    C                             LIMIT (and taking according dimension
    C                             adjustments into account). However, if
    C                             this yields no improvement it is advised
    C                             to analyze the integrand, in order to
    C                             determine the integration difficulties.
    C                             If the position of a local difficulty can
    C                             be 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 the
    C                             integrator on the subranges. If possible,
    C                             an appropriate special-purpose integrator
    C                             should be used which is designed for
    C                             handling the type of difficulty involved.
    C                         = 2 The occurrence of roundoff error is
    C                             detected, which prevents the requested
    C                             tolerance from being achieved.
    C                             The error may be under-estimated.
    C                         = 3 Extremely bad integrand behaviour occurs
    C                             at some points of the integration
    C                             interval.
    C                         = 4 The algorithm does not converge.
    C                             Roundoff error is detected in the
    C                             extrapolation table.
    C                             It is presumed that the requested
    C                             tolerance cannot be achieved due to
    C                             roundoff in the extrapolation table,
    C                             and that the returned result is the
    C                             best which can be obtained.
    C                         = 5 The integral is probably divergent, or
    C                             slowly convergent. It must be noted that
    C                             divergence can occur with any other value
    C                             of IER.GT.0.
    C                         = 6 The input is invalid, because
    C                             (EPSABS.LE.0 and
    C                              EPSREL.LT.MAX(50*REL.MACH.ACC.,0.5D-28))
    C                             or (INTEGR.NE.1 and INTEGR.NE.2) or
    C                             ICALL.LT.1 or MAXP1.LT.1.
    C                             RESULT, ABSERR, NEVAL, LAST, RLIST(1),
    C                             ELIST(1), IORD(1) and NNLOG(1) are set
    C                             to ZERO. ALIST(1) and BLIST(1) are set
    C                             to A and B respectively.
    C
    C            LAST  -  Integer
    C                     On return, LAST equals the number of
    C                     subintervals produces in the subdivision
    C                     process, which determines the number of
    C                     significant elements actually in the
    C                     WORK ARRAYS.
    C            ALIST  - Double precision
    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  - Double precision
    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  - Double precision
    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  - Double precision
    C                     Vector of dimension at least LIMIT, the first
    C                      LAST  elements of which are the moduli of the
    C                     absolute 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,
    C                     such that ELIST(IORD(1)), ...,
    C                     ELIST(IORD(K)) form a decreasing sequence, with
    C                     K = LAST if LAST.LE.(LIMIT/2+2), and
    C                     K = LIMIT+1-LAST otherwise.
    C
    C            NNLOG  - Integer
    C                     Vector of dimension at least LIMIT, containing the
    C                     subdivision levels of the subintervals, i.e.
    C                     IWORK(I) = L means that the subinterval
    C                     numbered I is of length ABS(B-A)*2**(1-L)
    C
    C         ON ENTRY AND RETURN
    C            MOMCOM - Integer
    C                     Indicating that the Chebyshev moments
    C                     have been computed for intervals of lengths
    C                     (ABS(B-A))*2**(-L), L=0,1,2, ..., MOMCOM-1,
    C                     MOMCOM.LT.MAXP1
    C
    C            CHEBMO - Double precision
    C                     Array of dimension (MAXP1,25) containing the
    C                     Chebyshev moments
    C
    C***REFERENCES  (NONE)
    C***ROUTINES CALLED  D1MACH, DQC25F, DQELG, DQPSRT
    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  DQAWOE