/[lmdze]/trunk/dyn3d/Inter_barxy/inter_barx.f
ViewVC logotype

Contents of /trunk/dyn3d/Inter_barxy/inter_barx.f

Parent Directory Parent Directory | Revision Log Revision Log


Revision 122 - (show annotations)
Tue Feb 3 19:30:48 2015 UTC (9 years, 3 months ago) by guez
File size: 4921 byte(s)
In procedure fxhyp_loop_ik, when testing whether xvrai is between -pi
and pi, changed back the boundaries from -pi - 1d-5 to - pi_d - 0.1
and from pi + 1d-5 to pi_d + 0.1. Fixed the logic: for ik = 1, we
rearrange longitudes between -pi and pi, if necessary. For other
values of ik, we apply the same rearrangement.

In module serre, change the default values of dzoomx and dzoomy to
0.2, because dzoomx must be > 0 when grossismx > 1.

With this revision, we recover the results of revision 120 and we
remove the bug that appeared with clon = 20.

1 module inter_barx_m
2
3 implicit none
4
5 contains
6
7 function inter_barx(dlonid, fdat, rlonimod)
8
9 ! From dyn3d/inter_barx.F, version 1.1.1.1 2004/05/19 12:53:06
10
11 ! Authors: Robert Sadourny, P. Le Van
12
13 ! INTERPOLATION BARYCENTRIQUE BASEE SUR LES AIRES
14 ! VERSION UNIDIMENSIONNELLE, EN LONGITUDE .
15
16 ! idat : indice du champ de donnees, de 1 a idatmax
17 ! imod : indice du champ du modele, de 1 a imodmax
18 ! fdat(idat) : champ de donnees (entrees)
19 ! inter_barx(imod) : champ du modele (sorties)
20 ! dlonid(idat): abscisses des interfaces des mailles donnees
21 ! rlonimod(imod): abscisses des interfaces des mailles modele
22 ! (L'indice 1 correspond a l'interface mailLE 1 / maille 2)
23 ! (Les abscisses sont exprimées en degres)
24
25 use nr_util, only: assert_eq, pi
26
27 REAL, intent(in):: dlonid(:)
28 real, intent(in):: fdat(:)
29 real, intent(in):: rlonimod(:)
30
31 real inter_barx(size(rlonimod))
32
33 ! Variables locales
34
35 INTEGER idatmax, imodmax
36 REAL xxid(size(dlonid)+1), xxd(size(dlonid)+1), fdd(size(dlonid)+1)
37 REAL fxd(size(dlonid)+1), xchan(size(dlonid)+1), fdchan(size(dlonid)+1)
38 REAL xxim(size(rlonimod))
39
40 REAL x0, xim0, dx, dxm
41 REAL chmin, chmax
42
43 INTEGER imod, idat, i, ichang, id0, id1, nid, idatmax1
44
45 !-----------------------------------------------------
46
47 idatmax = assert_eq(size(dlonid), size(fdat), "inter_barx idatmax")
48 imodmax = size(rlonimod)
49
50 ! REDEFINITION DE L'ORIGINE DES ABSCISSES
51 ! A L'INTERFACE OUEST DE LA PREMIERE MAILLE DU MODELE
52 DO imod = 1, imodmax
53 xxim(imod) = rlonimod(imod)
54 ENDDO
55
56 CALL minmax(imodmax, xxim, chmin, chmax)
57 IF(chmax < 6.50) THEN
58 DO imod = 1, imodmax
59 xxim(imod) = xxim(imod) * 180./pi
60 ENDDO
61 ENDIF
62
63 xim0 = xxim(imodmax) - 360.
64
65 DO imod = 1, imodmax
66 xxim(imod) = xxim(imod) - xim0
67 ENDDO
68
69 idatmax1 = idatmax +1
70
71 DO idat = 1, idatmax
72 xxd(idat) = dlonid(idat)
73 ENDDO
74
75 CALL minmax(idatmax, xxd, chmin, chmax)
76 IF(chmax < 6.50) THEN
77 DO idat = 1, idatmax
78 xxd(idat) = xxd(idat) * 180./pi
79 ENDDO
80 ENDIF
81
82 DO idat = 1, idatmax
83 xxd(idat) = AMOD(xxd(idat) - xim0, 360.)
84 fdd(idat) = fdat (idat)
85 ENDDO
86
87 i = 2
88 DO while (xxd(i) >= xxd(i-1) .and. i < idatmax)
89 i = i + 1
90 ENDDO
91 IF (xxd(i) < xxd(i-1)) THEN
92 ichang = i
93 ! *** reorganisation des longitudes entre 0. et 360. degres ****
94 nid = idatmax - ichang +1
95 DO i = 1, nid
96 xchan (i) = xxd(i+ichang -1)
97 fdchan(i) = fdd(i+ichang -1)
98 ENDDO
99 DO i=1, ichang -1
100 xchan (i+ nid) = xxd(i)
101 fdchan(i+nid) = fdd(i)
102 ENDDO
103 DO i =1, idatmax
104 xxd(i) = xchan(i)
105 fdd(i) = fdchan(i)
106 ENDDO
107 end IF
108
109 ! translation des champs de donnees par rapport
110 ! a la nouvelle origine, avec redondance de la
111 ! maille a cheval sur les bords
112
113 id0 = 0
114 id1 = 0
115
116 DO idat = 1, idatmax
117 IF (xxd(idatmax1- idat) < 360.) exit
118 id1 = id1 + 1
119 ENDDO
120
121 DO idat = 1, idatmax
122 IF (xxd(idat) > 0.) exit
123 id0 = id0 + 1
124 END DO
125
126 IF(id1 /= 0) then
127 DO idat = 1, id1
128 xxid(idat) = xxd(idatmax - id1 + idat) - 360.
129 fxd (idat) = fdd(idatmax - id1 + idat)
130 END DO
131 DO idat = 1, idatmax - id1
132 xxid(idat + id1) = xxd(idat)
133 fxd (idat + id1) = fdd(idat)
134 END DO
135 end IF
136
137 IF(id0 /= 0) then
138 DO idat = 1, idatmax - id0
139 xxid(idat) = xxd(idat + id0)
140 fxd (idat) = fdd(idat + id0)
141 END DO
142
143 DO idat = 1, id0
144 xxid (idatmax - id0 + idat) = xxd(idat) + 360.
145 fxd (idatmax - id0 + idat) = fdd(idat)
146 END DO
147 else
148 DO idat = 1, idatmax
149 xxid(idat) = xxd(idat)
150 fxd (idat) = fdd(idat)
151 ENDDO
152 end IF
153 xxid(idatmax1) = xxid(1) + 360.
154 fxd (idatmax1) = fxd(1)
155
156 ! initialisation du champ du modele
157
158 inter_barx(:) = 0.
159
160 ! iteration
161
162 x0 = xim0
163 dxm = 0.
164 imod = 1
165 idat = 1
166
167 do while (imod <= imodmax)
168 do while (xxim(imod) > xxid(idat))
169 dx = xxid(idat) - x0
170 dxm = dxm + dx
171 inter_barx(imod) = inter_barx(imod) + dx * fxd(idat)
172 x0 = xxid(idat)
173 idat = idat + 1
174 end do
175 IF (xxim(imod) < xxid(idat)) THEN
176 dx = xxim(imod) - x0
177 dxm = dxm + dx
178 inter_barx(imod) = (inter_barx(imod) + dx * fxd(idat)) / dxm
179 x0 = xxim(imod)
180 dxm = 0.
181 imod = imod + 1
182 ELSE
183 dx = xxim(imod) - x0
184 dxm = dxm + dx
185 inter_barx(imod) = (inter_barx(imod) + dx * fxd(idat)) / dxm
186 x0 = xxim(imod)
187 dxm = 0.
188 imod = imod + 1
189 idat = idat + 1
190 END IF
191 end do
192
193 END function inter_barx
194
195 end module inter_barx_m

  ViewVC Help
Powered by ViewVC 1.1.21