18 function f1d(x)
result(fx)
20 real(dp),
intent(in) :: x
45 pure logical function is_close(a, b, rtol, atol, symmetric)
47 real(dp),
intent(in) :: a
48 real(dp),
intent(in) :: b
49 real(dp),
intent(in),
optional :: rtol
50 real(dp),
intent(in),
optional :: atol
51 logical(LGP),
intent(in),
optional :: symmetric
53 real(dp) :: lrtol, latol
54 logical(LGP) :: lsymmetric
63 if (.not.
present(rtol))
then
68 if (.not.
present(atol))
then
73 if (.not.
present(symmetric))
then
76 lsymmetric = symmetric
81 is_close = abs(a - b) <= max(lrtol * max(abs(a), abs(b)), latol)
84 is_close = (abs(a - b) <= (latol + lrtol * abs(b)))
91 integer(I4B),
intent(in) :: a
92 integer(I4B),
intent(in) :: n
93 integer(I4B),
intent(in),
optional :: d
103 mo = a - n * floor(real(a - ld) / n)
109 real(dp),
intent(in) :: a
110 real(dp),
intent(in) :: n
111 real(dp),
intent(in),
optional :: d
121 mo = a - n * floor((a - ld) / n)
135 procedure(
f1d),
pointer,
intent(in) :: f
140 real(dp) :: a, b, c, t
141 real(dp) :: aminusb, cminusb
142 real(dp) :: fa, fb, fc, fm, ft
143 real(dp) :: faminusfb, fcminusfb
144 real(dp) :: phi, philo, phihi
145 real(dp) :: racb, rcab, rbca
146 real(dp) :: tol, tl, tlc
147 real(dp) :: xi, xm, xt
160 if (fa ==
dzero)
then
163 else if (fb ==
dzero)
then
171 if (sign(ft, fa) == ft)
then
190 if (dabs(fb) < dabs(fa))
then
194 tol =
dtwo * epsm * dabs(xm) + epsa
195 tl = tol / dabs(cminusb)
196 if ((tl > 5d-1) .or. (fm ==
dzero))
then
200 xi = aminusb / cminusb
201 phi = faminusfb / fcminusfb
204 if ((phi > philo) .and. (phi < phihi))
then
205 racb = fa / fcminusfb
206 rcab = fc / faminusfb
207 rbca = fb / (fc - fa)
208 t = racb * (rcab - rbca * (c - a) / aminusb)
253 procedure(
f1d),
pointer,
intent(in) :: f
258 real(dp) :: a, b, c, d, e, s, p, q
259 real(dp) :: fa, fb, fc, r, tol1, xm
271 if (fa ==
dzero)
then
274 else if (fb ==
dzero)
then
280 if (fa * (fb / dabs(fb)) .ge.
dzero) &
281 call pstop(1,
'f(ax) and f(bx) do not have different signs,')
292 if (.not. (dabs(fc) .ge. dabs(fb)))
then
301 tol1 =
dtwo * eps * dabs(b) +
dhalf * tol
303 if ((dabs(xm) .le. tol1) .or. (fb .eq.
dzero))
then
309 if ((dabs(e) .ge. tol1) .and. (dabs(fa) .gt. dabs(fb)))
then
315 p = s * (
dtwo * xm * q * (q - r) - (b - a) * (r -
done))
323 if (p .le.
dzero)
then
330 if (((
dtwo * p) .ge. (
dthree * xm * q - dabs(tol1 * q))) .or. &
331 (p .ge. dabs(
dhalf * s * q)))
then
345 if (dabs(d) .le. tol1)
then
346 if (xm .le.
dzero)
then
356 rs = (fb * (fc / dabs(fc))) .gt.
dzero
369 real(dp),
intent(in) :: x
This module contains simulation constants.
real(dp), parameter dsame
real constant for values that are considered the same based on machine precision
integer(i4b), parameter linelength
maximum length of a standard line
integer(i4b), parameter lenhugeline
maximum length of a huge line
real(dp), parameter dprecsqrt
real(dp), parameter dhalf
real constant 1/2
real(dp), parameter dzero
real constant zero
real(dp), parameter dprec
real constant machine precision
integer(i4b), parameter maxcharlen
maximum length of char string
@ vsummary
write summary output
real(dp), parameter dtwo
real constant 2
real(dp), parameter dthree
real constant 3
real(dp), parameter done
real constant 1
subroutine pstop(status, message)
Stop the program, optionally specifying an error status code.
This module defines variable data types.
real(dp) function, public zero_ch(x0, x1, f, epsa)
Compute zeros on an interval using Chadrupatla's method.
pure integer(i4b) function mod_offset_int(a, n, d)
Modulo with offset for integer values.
pure real(dp) function mod_offset_dbl(a, n, d)
Modulo with offset for double precision values.
real(dp) function, public get_perturbation(x)
Calculate a numerical perturbation given the value of x.
real(dp) function, public zero_br(ax, bx, f, tol)
Compute a zero of the function f(x) in the interval (x0, x1).
pure logical function, public is_close(a, b, rtol, atol, symmetric)
Check if a real value is approximately equal to another.