/[lmdze]/trunk/dyn3d/invert_zoom_x.f
ViewVC logotype

Annotation of /trunk/dyn3d/invert_zoom_x.f

Parent Directory Parent Directory | Revision Log Revision Log


Revision 265 - (hide annotations)
Tue Mar 20 09:35:59 2018 UTC (6 years, 2 months ago) by guez
File size: 2693 byte(s)
Rename module dimens_m to dimensions.
1 guez 131 module invert_zoom_x_m
2 guez 121
3     implicit none
4    
5     INTEGER, PARAMETER:: nmax = 30000
6 guez 149 DOUBLE PRECISION abs_y
7 guez 121
8 guez 149 private abs_y, funcd
9    
10 guez 121 contains
11    
12 guez 167 subroutine invert_zoom_x(beta, xf, xtild, G, xlon, xprim, xuv)
13 guez 121
14 guez 149 use coefpoly_m, only: coefpoly, a1, a2, a3
15 guez 265 USE dimensions, ONLY: iim
16 guez 167 use dynetat0_m, only: clon, grossismx
17 guez 124 use nr_util, only: pi_d, twopi_d
18 guez 149 use numer_rec_95, only: hunt, rtsafe
19 guez 121
20 guez 167 DOUBLE PRECISION, intent(in):: beta, Xf(0:), xtild(0:), G(0:) ! (0:nmax)
21 guez 146
22 guez 148 real, intent(out):: xlon(:), xprim(:) ! (iim)
23 guez 121
24     DOUBLE PRECISION, intent(in):: xuv
25 guez 145 ! between - 0.25 and 0.5
26 guez 121 ! 0. si calcul aux points scalaires
27 guez 145 ! 0.5 si calcul aux points U
28 guez 121
29     ! Local:
30 guez 149 DOUBLE PRECISION Y
31 guez 154 DOUBLE PRECISION h ! step of the uniform grid
32 guez 149 integer i, it
33 guez 121
34 guez 150 DOUBLE PRECISION xvrai(iim), Gvrai(iim)
35 guez 255 ! intermediary variables because xlon and xprim are single precision
36 guez 126
37 guez 121 !------------------------------------------------------------------
38    
39 guez 167 print *, "Call sequence information: invert_zoom_x"
40 guez 145 it = 0 ! initial guess
41 guez 154 h = twopi_d / iim
42 guez 145
43 guez 126 DO i = 1, iim
44 guez 154 Y = - pi_d + (i + xuv - 0.75d0) * h
45 guez 148 ! - pi <= y < pi
46     abs_y = abs(y)
47 guez 121
48 guez 167 ! Distinguish boundaries in order to avoid roundoff error.
49     ! funcd should be exactly equal to 0 at xtild(it) or xtild(it +
50     ! 1) and could be very small with the wrong sign so rtsafe
51     ! would fail.
52     if (abs_y == 0d0) then
53     xvrai(i) = 0d0
54     gvrai(i) = grossismx
55     else if (abs_y == pi_d) then
56     xvrai(i) = pi_d
57     gvrai(i) = 2d0 * beta - grossismx
58     else
59     call hunt(xf, abs_y, it, my_lbound = 0)
60     ! {0 <= it <= nmax - 1}
61 guez 121
62 guez 167 ! 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
68    
69 guez 148 if (y < 0d0) xvrai(i) = - xvrai(i)
70 guez 121 end DO
71    
72     DO i = 1, iim -1
73     IF (xvrai(i + 1) < xvrai(i)) THEN
74 guez 124 print *, 'xvrai(', i + 1, ') < xvrai(', i, ')'
75 guez 121 STOP 1
76     END IF
77     END DO
78    
79 guez 127 xlon = xvrai + clon
80 guez 154 xprim = h / Gvrai
81 guez 121
82 guez 131 end subroutine invert_zoom_x
83 guez 121
84 guez 149 !**********************************************************************
85    
86     SUBROUTINE funcd(x, fval, fderiv)
87    
88     use coefpoly_m, only: a0, a1, a2, a3
89    
90 guez 150 DOUBLE PRECISION, INTENT(IN):: x
91     DOUBLE PRECISION, INTENT(OUT):: fval, fderiv
92 guez 149
93     fval = a0 + x * (a1 + x * (a2 + x * a3)) - abs_y
94 guez 150 fderiv = a1 + x * (2d0 * a2 + x * 3d0 * a3)
95 guez 149
96     END SUBROUTINE funcd
97    
98 guez 131 end module invert_zoom_x_m

  ViewVC Help
Powered by ViewVC 1.1.21