qawf.f 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. *DECK QAWF
  2. SUBROUTINE QAWF (F, A, OMEGA, INTEGR, EPSABS, RESULT, ABSERR,
  3. + NEVAL, IER, LIMLST, LST, LENIW, MAXP1, LENW, IWORK, WORK)
  4. C***BEGIN PROLOGUE QAWF
  5. C***PURPOSE The routine calculates an approximation result to a given
  6. C Fourier integral
  7. C I = Integral of F(X)*W(X) over (A,INFINITY)
  8. C where W(X) = COS(OMEGA*X) or W(X) = SIN(OMEGA*X).
  9. C Hopefully satisfying following claim for accuracy
  10. C ABS(I-RESULT).LE.EPSABS.
  11. C***LIBRARY SLATEC (QUADPACK)
  12. C***CATEGORY H2A3A1
  13. C***TYPE SINGLE PRECISION (QAWF-S, DQAWF-D)
  14. C***KEYWORDS AUTOMATIC INTEGRATOR, CONVERGENCE ACCELERATION,
  15. C FOURIER INTEGRALS, INTEGRATION BETWEEN ZEROS, QUADPACK,
  16. C QUADRATURE, SPECIAL-PURPOSE INTEGRAL
  17. C***AUTHOR Piessens, Robert
  18. C Applied Mathematics and Programming Division
  19. C K. U. Leuven
  20. C de Doncker, Elise
  21. C Applied Mathematics and Programming Division
  22. C K. U. Leuven
  23. C***DESCRIPTION
  24. C
  25. C Computation of Fourier integrals
  26. C Standard fortran subroutine
  27. C Real version
  28. C
  29. C
  30. C PARAMETERS
  31. C ON ENTRY
  32. C F - Real
  33. C Function subprogram defining the integrand
  34. C function F(X). The actual name for F needs to be
  35. C declared E X T E R N A L in the driver program.
  36. C
  37. C A - Real
  38. C Lower limit of integration
  39. C
  40. C OMEGA - Real
  41. C Parameter in the integrand WEIGHT function
  42. C
  43. C INTEGR - Integer
  44. C Indicates which of the WEIGHT functions is used
  45. C INTEGR = 1 W(X) = COS(OMEGA*X)
  46. C INTEGR = 2 W(X) = SIN(OMEGA*X)
  47. C IF INTEGR.NE.1.AND.INTEGR.NE.2, the routine
  48. C will end with IER = 6.
  49. C
  50. C EPSABS - Real
  51. C Absolute accuracy requested, EPSABS.GT.0.
  52. C If EPSABS.LE.0, the routine will end with IER = 6.
  53. C
  54. C ON RETURN
  55. C RESULT - Real
  56. C Approximation to the integral
  57. C
  58. C ABSERR - Real
  59. C Estimate of the modulus of the absolute error,
  60. C Which should equal or exceed ABS(I-RESULT)
  61. C
  62. C NEVAL - Integer
  63. C Number of integrand evaluations
  64. C
  65. C IER - Integer
  66. C IER = 0 Normal and reliable termination of the
  67. C routine. It is assumed that the requested
  68. C accuracy has been achieved.
  69. C IER.GT.0 Abnormal termination of the routine.
  70. C The estimates for integral and error are
  71. C less reliable. It is assumed that the
  72. C requested accuracy has not been achieved.
  73. C ERROR MESSAGES
  74. C If OMEGA.NE.0
  75. C IER = 1 Maximum number of cycles allowed
  76. C has been achieved, i.e. of subintervals
  77. C (A+(K-1)C,A+KC) where
  78. C C = (2*INT(ABS(OMEGA))+1)*PI/ABS(OMEGA),
  79. C FOR K = 1, 2, ..., LST.
  80. C One can allow more cycles by increasing
  81. C the value of LIMLST (and taking the
  82. C according dimension adjustments into
  83. C account). Examine the array IWORK which
  84. C contains the error flags on the cycles, in
  85. C order to look for eventual local
  86. C integration difficulties.
  87. C If the position of a local difficulty
  88. C can be determined (e.g. singularity,
  89. C discontinuity within the interval) one
  90. C will probably gain from splitting up the
  91. C interval at this point and calling
  92. C appropriate integrators on the subranges.
  93. C = 4 The extrapolation table constructed for
  94. C convergence acceleration of the series
  95. C formed by the integral contributions over
  96. C the cycles, does not converge to within
  97. C the requested accuracy.
  98. C As in the case of IER = 1, it is advised
  99. C to examine the array IWORK which contains
  100. C the error flags on the cycles.
  101. C = 6 The input is invalid because
  102. C (INTEGR.NE.1 AND INTEGR.NE.2) or
  103. C EPSABS.LE.0 or LIMLST.LT.1 or
  104. C LENIW.LT.(LIMLST+2) or MAXP1.LT.1 or
  105. C LENW.LT.(LENIW*2+MAXP1*25).
  106. C RESULT, ABSERR, NEVAL, LST are set to
  107. C zero.
  108. C = 7 Bad integrand behaviour occurs within
  109. C one or more of the cycles. Location and
  110. C type of the difficulty involved can be
  111. C determined from the first LST elements of
  112. C vector IWORK. Here LST is the number of
  113. C cycles actually needed (see below).
  114. C IWORK(K) = 1 The maximum number of
  115. C subdivisions (=(LENIW-LIMLST)
  116. C /2) has been achieved on the
  117. C K th cycle.
  118. C = 2 Occurrence of roundoff error
  119. C is detected and prevents the
  120. C tolerance imposed on the K th
  121. C cycle, from being achieved
  122. C on this cycle.
  123. C = 3 Extremely bad integrand
  124. C behaviour occurs at some
  125. C points of the K th cycle.
  126. C = 4 The integration procedure
  127. C over the K th cycle does
  128. C not converge (to within the
  129. C required accuracy) due to
  130. C roundoff in the extrapolation
  131. C procedure invoked on this
  132. C cycle. It is assumed that the
  133. C result on this interval is
  134. C the best which can be
  135. C obtained.
  136. C = 5 The integral over the K th
  137. C cycle is probably divergent
  138. C or slowly convergent. It must
  139. C be noted that divergence can
  140. C occur with any other value of
  141. C IWORK(K).
  142. C If OMEGA = 0 and INTEGR = 1,
  143. C The integral is calculated by means of DQAGIE,
  144. C and IER = IWORK(1) (with meaning as described
  145. C for IWORK(K),K = 1).
  146. C
  147. C DIMENSIONING PARAMETERS
  148. C LIMLST - Integer
  149. C LIMLST gives an upper bound on the number of
  150. C cycles, LIMLST.GE.3.
  151. C If LIMLST.LT.3, the routine will end with IER = 6.
  152. C
  153. C LST - Integer
  154. C On return, LST indicates the number of cycles
  155. C actually needed for the integration.
  156. C If OMEGA = 0, then LST is set to 1.
  157. C
  158. C LENIW - Integer
  159. C Dimensioning parameter for IWORK. On entry,
  160. C (LENIW-LIMLST)/2 equals the maximum number of
  161. C subintervals allowed in the partition of each
  162. C cycle, LENIW.GE.(LIMLST+2).
  163. C If LENIW.LT.(LIMLST+2), the routine will end with
  164. C IER = 6.
  165. C
  166. C MAXP1 - Integer
  167. C MAXP1 gives an upper bound on the number of
  168. C Chebyshev moments which can be stored, i.e. for
  169. C the intervals of lengths ABS(B-A)*2**(-L),
  170. C L = 0,1, ..., MAXP1-2, MAXP1.GE.1.
  171. C If MAXP1.LT.1, the routine will end with IER = 6.
  172. C LENW - Integer
  173. C Dimensioning parameter for WORK
  174. C LENW must be at least LENIW*2+MAXP1*25.
  175. C If LENW.LT.(LENIW*2+MAXP1*25), the routine will
  176. C end with IER = 6.
  177. C
  178. C WORK ARRAYS
  179. C IWORK - Integer
  180. C Vector of dimension at least LENIW
  181. C On return, IWORK(K) FOR K = 1, 2, ..., LST
  182. C contain the error flags on the cycles.
  183. C
  184. C WORK - Real
  185. C Vector of dimension at least
  186. C On return,
  187. C WORK(1), ..., WORK(LST) contain the integral
  188. C approximations over the cycles,
  189. C WORK(LIMLST+1), ..., WORK(LIMLST+LST) contain
  190. C the error estimates over the cycles.
  191. C further elements of WORK have no specific
  192. C meaning for the user.
  193. C
  194. C***REFERENCES (NONE)
  195. C***ROUTINES CALLED QAWFE, XERMSG
  196. C***REVISION HISTORY (YYMMDD)
  197. C 800101 DATE WRITTEN
  198. C 890831 Modified array declarations. (WRB)
  199. C 891009 Removed unreferenced variable. (WRB)
  200. C 891009 REVISION DATE from Version 3.2
  201. C 891214 Prologue converted to Version 4.0 format. (BAB)
  202. C 900315 CALLs to XERROR changed to CALLs to XERMSG. (THJ)
  203. C***END PROLOGUE QAWF
  204. C
  205. REAL A,ABSERR,EPSABS,F,OMEGA,RESULT,WORK
  206. INTEGER IER,INTEGR,LENIW,LIMIT,LIMLST,LVL,LST,L1,L2,L3,L4,L5,L6,
  207. 1 MAXP1,NEVAL
  208. C
  209. DIMENSION IWORK(*),WORK(*)
  210. C
  211. EXTERNAL F
  212. C
  213. C CHECK VALIDITY OF LIMLST, LENIW, MAXP1 AND LENW.
  214. C
  215. C***FIRST EXECUTABLE STATEMENT QAWF
  216. IER = 6
  217. NEVAL = 0
  218. RESULT = 0.0E+00
  219. ABSERR = 0.0E+00
  220. IF(LIMLST.LT.3.OR.LENIW.LT.(LIMLST+2).OR.MAXP1.LT.1.OR.LENW.LT.
  221. 1 (LENIW*2+MAXP1*25)) GO TO 10
  222. C
  223. C PREPARE CALL FOR QAWFE
  224. C
  225. LIMIT = (LENIW-LIMLST)/2
  226. L1 = LIMLST+1
  227. L2 = LIMLST+L1
  228. L3 = LIMIT+L2
  229. L4 = LIMIT+L3
  230. L5 = LIMIT+L4
  231. L6 = LIMIT+L5
  232. LL2 = LIMIT+L1
  233. CALL QAWFE(F,A,OMEGA,INTEGR,EPSABS,LIMLST,LIMIT,MAXP1,RESULT,
  234. 1 ABSERR,NEVAL,IER,WORK(1),WORK(L1),IWORK(1),LST,WORK(L2),
  235. 2 WORK(L3),WORK(L4),WORK(L5),IWORK(L1),IWORK(LL2),WORK(L6))
  236. C
  237. C CALL ERROR HANDLER IF NECESSARY
  238. C
  239. LVL = 0
  240. 10 IF(IER.EQ.6) LVL = 1
  241. IF (IER .NE. 0) CALL XERMSG ('SLATEC', 'QAWF',
  242. + 'ABNORMAL RETURN', IER, LVL)
  243. RETURN
  244. END