3 |
implicit none |
implicit none |
4 |
|
|
5 |
INTEGER, PARAMETER:: nmax = 30000 |
INTEGER, PARAMETER:: nmax = 30000 |
6 |
|
DOUBLE PRECISION abs_y |
7 |
|
|
8 |
|
private abs_y, funcd |
9 |
|
|
10 |
contains |
contains |
11 |
|
|
12 |
subroutine invert_zoom_x(xf, xtild, Xprimt, xlon, xprimm, xuv) |
subroutine invert_zoom_x(beta, xf, xtild, G, xlon, xprim, xuv) |
13 |
|
|
14 |
use coefpoly_m, only: coefpoly |
use coefpoly_m, only: coefpoly, a1, a2, a3 |
15 |
USE dimens_m, ONLY: iim |
USE dimens_m, ONLY: iim |
16 |
|
use dynetat0_m, only: clon, grossismx |
17 |
use nr_util, only: pi_d, twopi_d |
use nr_util, only: pi_d, twopi_d |
18 |
use serre, only: clon |
use numer_rec_95, only: hunt, rtsafe |
19 |
|
|
20 |
|
DOUBLE PRECISION, intent(in):: beta, Xf(0:), xtild(0:), G(0:) ! (0:nmax) |
21 |
|
|
22 |
DOUBLE PRECISION, intent(in):: Xf(0:), xtild(0:), Xprimt(0:) ! (0:2 * nmax) |
real, intent(out):: xlon(:), xprim(:) ! (iim) |
|
real, intent(out):: xlon(:), xprimm(:) ! (iim) |
|
23 |
|
|
24 |
DOUBLE PRECISION, intent(in):: xuv |
DOUBLE PRECISION, intent(in):: xuv |
25 |
|
! between - 0.25 and 0.5 |
26 |
! 0. si calcul aux points scalaires |
! 0. si calcul aux points scalaires |
27 |
! 0.5 si calcul aux points U |
! 0.5 si calcul aux points U |
28 |
|
|
29 |
! Local: |
! Local: |
30 |
DOUBLE PRECISION xo1, Xfi, a0, a1, a2, a3, Xf1, Xprimin |
DOUBLE PRECISION Y |
31 |
integer i, it, iter |
DOUBLE PRECISION h ! step of the uniform grid |
32 |
DOUBLE PRECISION, parameter:: my_eps = 1d-6 |
integer i, it |
33 |
|
|
34 |
DOUBLE PRECISION xxprim(iim), xvrai(iim) |
DOUBLE PRECISION xvrai(iim), Gvrai(iim) |
35 |
! intermediary variables because xlon and xprimm are simple precision |
! intermediary variables because xlon and xprim are simple precision |
36 |
|
|
37 |
!------------------------------------------------------------------ |
!------------------------------------------------------------------ |
38 |
|
|
39 |
DO i = 1, iim |
print *, "Call sequence information: invert_zoom_x" |
40 |
Xfi = - pi_d + (i + xuv - 0.75d0) * twopi_d / iim |
it = 0 ! initial guess |
41 |
|
h = twopi_d / iim |
|
it = 2 * nmax |
|
|
do while (xfi < xf(it) .and. it >= 1) |
|
|
it = it - 1 |
|
|
end do |
|
|
|
|
|
! Calcul de Xf(xvrai(i)) |
|
|
|
|
|
xvrai(i) = xtild(it) |
|
|
|
|
|
IF (it == 2 * nmax) THEN |
|
|
it = 2 * nmax -1 |
|
|
END IF |
|
42 |
|
|
43 |
CALL coefpoly(Xf(it), Xf(it + 1), Xprimt(it), Xprimt(it + 1), & |
DO i = 1, iim |
44 |
xtild(it), xtild(it + 1), a0, a1, a2, a3) |
Y = - pi_d + (i + xuv - 0.75d0) * h |
45 |
Xf1 = Xf(it) |
! - pi <= y < pi |
46 |
Xprimin = a1 + xvrai(i) * (2d0 * a2 + xvrai(i) * 3d0 * a3) |
abs_y = abs(y) |
47 |
xo1 = xvrai(i) |
|
48 |
iter = 1 |
! Distinguish boundaries in order to avoid roundoff error. |
49 |
|
! funcd should be exactly equal to 0 at xtild(it) or xtild(it + |
50 |
do |
! 1) and could be very small with the wrong sign so rtsafe |
51 |
xvrai(i) = xvrai(i) - (Xf1 - Xfi) / Xprimin |
! would fail. |
52 |
IF (ABS(xvrai(i) - xo1) <= my_eps .or. iter == 300) exit |
if (abs_y == 0d0) then |
53 |
xo1 = xvrai(i) |
xvrai(i) = 0d0 |
54 |
Xf1 = a0 + xvrai(i) * (a1 + xvrai(i) * (a2 + xvrai(i) * a3)) |
gvrai(i) = grossismx |
55 |
Xprimin = a1 + xvrai(i) * (2d0 * a2 + xvrai(i) * 3d0 * a3) |
else if (abs_y == pi_d) then |
56 |
end DO |
xvrai(i) = pi_d |
57 |
|
gvrai(i) = 2d0 * beta - grossismx |
58 |
if (ABS(xvrai(i) - xo1) > my_eps) then |
else |
59 |
! iter == 300 |
call hunt(xf, abs_y, it, my_lbound = 0) |
60 |
print *, 'Pas de solution.' |
! {0 <= it <= nmax - 1} |
61 |
print *, i, xfi |
|
62 |
STOP 1 |
! Calcul de xvrai(i) et Gvrai(i) |
63 |
|
CALL coefpoly(Xf(it), Xf(it + 1), G(it), G(it + 1), xtild(it), & |
64 |
|
xtild(it + 1)) |
65 |
|
xvrai(i) = rtsafe(funcd, xtild(it), xtild(it + 1), xacc = 1d-6) |
66 |
|
Gvrai(i) = a1 + xvrai(i) * (2d0 * a2 + xvrai(i) * 3d0 * a3) |
67 |
end if |
end if |
68 |
|
|
69 |
xxprim(i) = twopi_d / (iim * Xprimin) |
if (y < 0d0) xvrai(i) = - xvrai(i) |
70 |
end DO |
end DO |
71 |
|
|
72 |
DO i = 1, iim -1 |
DO i = 1, iim -1 |
77 |
END DO |
END DO |
78 |
|
|
79 |
xlon = xvrai + clon |
xlon = xvrai + clon |
80 |
xprimm = xxprim |
xprim = h / Gvrai |
81 |
|
|
82 |
end subroutine invert_zoom_x |
end subroutine invert_zoom_x |
83 |
|
|
84 |
|
!********************************************************************** |
85 |
|
|
86 |
|
SUBROUTINE funcd(x, fval, fderiv) |
87 |
|
|
88 |
|
use coefpoly_m, only: a0, a1, a2, a3 |
89 |
|
|
90 |
|
DOUBLE PRECISION, INTENT(IN):: x |
91 |
|
DOUBLE PRECISION, INTENT(OUT):: fval, fderiv |
92 |
|
|
93 |
|
fval = a0 + x * (a1 + x * (a2 + x * a3)) - abs_y |
94 |
|
fderiv = a1 + x * (2d0 * a2 + x * 3d0 * a3) |
95 |
|
|
96 |
|
END SUBROUTINE funcd |
97 |
|
|
98 |
end module invert_zoom_x_m |
end module invert_zoom_x_m |