compute Cauchy principal value of f(x)/(x-c)
over a finite interval
the routine calculates an approximation result to a
cauchy principal value i = integral of f*w
over (a,b)
(w(x) = 1/((x-c), c/=a, c/=b)
, hopefully satisfying
following claim for accuracy
abs(i-result)<=max(epsabe,epsrel*abs(i))
.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
procedure(func) | :: | f |
function subprogram defining the integrand function |
|||
real(kind=wp), | intent(in) | :: | a |
under limit of integration |
||
real(kind=wp), | intent(in) | :: | b |
upper limit of integration |
||
real(kind=wp), | intent(in) | :: | c |
parameter in the weight function, |
||
real(kind=wp), | intent(in) | :: | Epsabs |
absolute accuracy requested |
||
real(kind=wp), | intent(in) | :: | Epsrel |
relative accuracy requested
if |
||
real(kind=wp), | intent(out) | :: | Result |
approximation to the integral |
||
real(kind=wp), | intent(out) | :: | Abserr |
estimate or the modulus of the absolute error,
which should equal or exceed |
||
integer, | intent(out) | :: | Neval |
number of integrand evaluations |
||
integer, | intent(out) | :: | Ier |
error messages:
* ier = 1 maximum number of subdivisions allowed
has been achieved. one can allow more sub-
divisions by increasing the value of limit
(and taking the according dimension
adjustments into account). however, if
this yields no improvement it is advised
to analyze the integrand in order to
determine the integration difficulties.
if the position of a local difficulty
can be determined (e.g. singularity,
discontinuity within the interval) one
will probably gain from splitting up the
interval at this point and calling
appropriate integrators on the subranges.
* ier = 2 the occurrence of roundoff error is
detected, which prevents the requested
tolerance from being achieved.
* ier = 3 extremely bad integrand behaviour occurs
at some points of the integration
interval.
* ier = 6 the input is invalid, because
|
||
integer, | intent(in) | :: | Limit |
dimensioning parameter for |
||
integer, | intent(in) | :: | Lenw |
dimensioning parameter for |
||
integer, | intent(out) | :: | Last |
on return, |
||
integer | :: | Iwork(Limit) |
vector of dimension at least |
|||
real(kind=wp) | :: | Work(Lenw) |
vector of dimension at least
|
subroutine dqawc(f, a, b, c, Epsabs, Epsrel, Result, Abserr, Neval, Ier, & Limit, Lenw, Last, Iwork, Work) implicit none procedure(func) :: f !! function subprogram defining the integrand function `f(x)`. real(wp), intent(in) :: a !! under limit of integration real(wp), intent(in) :: b !! upper limit of integration real(wp), intent(in) :: c !! parameter in the weight function, `c/=a`, `c/=b`. !! if `c = a` or `c = b`, the routine will end with !! ier = 6 . real(wp), intent(in) :: Epsabs !! absolute accuracy requested real(wp), intent(in) :: Epsrel !! relative accuracy requested !! if `epsabs<=0` !! and `epsrel<max(50*rel.mach.acc.,0.5e-28)`, !! the routine will end with ier = 6. real(wp), intent(out) :: Result !! approximation to the integral real(wp), intent(out) :: Abserr !! estimate or the modulus of the absolute error, !! which should equal or exceed `abs(i-result)` integer, intent(out) :: Neval !! number of integrand evaluations integer, intent(out) :: Ier !! * ier = 0 normal and reliable termination of the !! routine. it is assumed that the requested !! accuracy has been achieved. !! * ier>0 abnormal termination of the routine !! the estimates for integral and error are !! less reliable. it is assumed that the !! requested accuracy has not been achieved. !! !! error messages: !! * ier = 1 maximum number of subdivisions allowed !! has been achieved. one can allow more sub- !! divisions by increasing the value of limit !! (and taking the according dimension !! adjustments into account). however, if !! this yields no improvement it is advised !! to analyze the integrand in order to !! determine the integration difficulties. !! if the position of a local difficulty !! can be determined (e.g. singularity, !! discontinuity within the interval) one !! will probably gain from splitting up the !! interval at this point and calling !! appropriate integrators on the subranges. !! * ier = 2 the occurrence of roundoff error is !! detected, which prevents the requested !! tolerance from being achieved. !! * ier = 3 extremely bad integrand behaviour occurs !! at some points of the integration !! interval. !! * ier = 6 the input is invalid, because !! `c = a` or `c = b` or !! (`epsabs<=0` and `epsrel<max(50*rel.mach.acc.,0.5e-28)`) !! or `limit<1` or `lenw<limit*4`. !! `esult`, `abserr`, `neval`, `last` are set to !! zero. except when `lenw` or `limit` is invalid, !! `iwork(1)`, `work(limit*2+1)` and !! `work(limit*3+1)` are set to zero, `work(1)` !! is set to a and `work(limit+1)` to `b`. integer, intent(in) :: Limit !! dimensioning parameter for `iwork`. !! `limit` determines the maximum number of subintervals !! in the partition of the given integration interval !! `(a,b)`, `limit>=1`. !! if `limit<1`, the routine will end with ier = 6. integer, intent(in) :: Lenw !! dimensioning parameter for `work`. !! `lenw` must be at least `limit*4`. !! if `lenw<limit*4`, the routine will end with !! ier = 6. integer, intent(out) :: Last !! on return, `last` equals the number of subintervals !! produced in the subdivision process, which !! determines the number of significant elements !! actually in the work arrays. real(wp) :: Work(Lenw) !! vector of dimension at least `lenw`. !! on return: !! !! * `work(1), ..., work(last)` contain the left !! end points of the subintervals in the !! partition of `(a,b)`, !! * `work(limit+1), ..., work(limit+last)` contain !! the right end points, !! * `work(limit*2+1), ..., work(limit*2+last)` contain !! the integral approximations over the subintervals, !! * `work(limit*3+1), ..., work(limit*3+last)` !! contain the error estimates. integer :: Iwork(Limit) !! vector of dimension at least `limit`, the first `k` !! elements of which contain pointers !! to the error estimates over the subintervals, !! such that `work(limit*3+iwork(1)),...,work(limit*3+iwork(k))` !! form a decreasing sequence, with `k = last` if !! `last<=(limit/2+2)`, and `k = limit+1-last` otherwise integer :: lvl, l1, l2, l3 ! check validity of limit and lenw. Ier = 6 Neval = 0 Last = 0 Result = 0.0_wp Abserr = 0.0_wp if (Limit >= 1 .and. Lenw >= Limit*4) then ! prepare call for dqawce. l1 = Limit + 1 l2 = Limit + l1 l3 = Limit + l2 call dqawce(f, a, b, c, Epsabs, Epsrel, Limit, Result, Abserr, Neval, & Ier, Work(1), Work(l1), Work(l2), Work(l3), Iwork, Last) ! call error handler if necessary. lvl = 0 end if if (Ier == 6) lvl = 1 if (Ier /= 0) call xerror('abnormal return from dqawc', Ier, lvl) end subroutine dqawc