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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 208 - (show annotations)
Wed Dec 7 16:44:53 2016 UTC (7 years, 4 months ago) by guez
File size: 4884 byte(s)
Module academic was not used.

Useful values for iflag_phys were only 0 and 1 so changed type to logical.

Definition of fmagic was duplicated in procedures alboc and alboc_cd
so moved it up to interfsurf_hq and also moved multiplication by
fmagic (following LMDZ).

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\'ees 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 REAL x0, xim0, dx, dxm
40 REAL chmax
41 INTEGER imod, idat, i, ichang, id0, id1, nid, idatmax1
42
43 !-----------------------------------------------------
44
45 idatmax = assert_eq(size(dlonid), size(fdat), "inter_barx idatmax")
46 imodmax = size(rlonimod)
47
48 ! REDEFINITION DE L'ORIGINE DES ABSCISSES
49 ! A L'INTERFACE OUEST DE LA PREMIERE MAILLE DU MODELE
50 DO imod = 1, imodmax
51 xxim(imod) = rlonimod(imod)
52 ENDDO
53
54 chmax = maxval(xxim)
55 IF(chmax < 6.50) THEN
56 DO imod = 1, imodmax
57 xxim(imod) = xxim(imod) * 180./pi
58 ENDDO
59 ENDIF
60
61 xim0 = xxim(imodmax) - 360.
62
63 DO imod = 1, imodmax
64 xxim(imod) = xxim(imod) - xim0
65 ENDDO
66
67 idatmax1 = idatmax +1
68
69 DO idat = 1, idatmax
70 xxd(idat) = dlonid(idat)
71 ENDDO
72
73 chmax = maxval(xxd(:idatmax))
74 IF(chmax < 6.50) THEN
75 DO idat = 1, idatmax
76 xxd(idat) = xxd(idat) * 180./pi
77 ENDDO
78 ENDIF
79
80 DO idat = 1, idatmax
81 xxd(idat) = AMOD(xxd(idat) - xim0, 360.)
82 fdd(idat) = fdat (idat)
83 ENDDO
84
85 i = 2
86 DO while (xxd(i) >= xxd(i-1) .and. i < idatmax)
87 i = i + 1
88 ENDDO
89 IF (xxd(i) < xxd(i-1)) THEN
90 ichang = i
91 ! *** reorganisation des longitudes entre 0. et 360. degres ****
92 nid = idatmax - ichang +1
93 DO i = 1, nid
94 xchan (i) = xxd(i+ichang -1)
95 fdchan(i) = fdd(i+ichang -1)
96 ENDDO
97 DO i=1, ichang -1
98 xchan (i+ nid) = xxd(i)
99 fdchan(i+nid) = fdd(i)
100 ENDDO
101 DO i =1, idatmax
102 xxd(i) = xchan(i)
103 fdd(i) = fdchan(i)
104 ENDDO
105 end IF
106
107 ! translation des champs de donnees par rapport
108 ! a la nouvelle origine, avec redondance de la
109 ! maille a cheval sur les bords
110
111 id0 = 0
112 id1 = 0
113
114 DO idat = 1, idatmax
115 IF (xxd(idatmax1- idat) < 360.) exit
116 id1 = id1 + 1
117 ENDDO
118
119 DO idat = 1, idatmax
120 IF (xxd(idat) > 0.) exit
121 id0 = id0 + 1
122 END DO
123
124 IF(id1 /= 0) then
125 DO idat = 1, id1
126 xxid(idat) = xxd(idatmax - id1 + idat) - 360.
127 fxd (idat) = fdd(idatmax - id1 + idat)
128 END DO
129 DO idat = 1, idatmax - id1
130 xxid(idat + id1) = xxd(idat)
131 fxd (idat + id1) = fdd(idat)
132 END DO
133 end IF
134
135 IF(id0 /= 0) then
136 DO idat = 1, idatmax - id0
137 xxid(idat) = xxd(idat + id0)
138 fxd (idat) = fdd(idat + id0)
139 END DO
140
141 DO idat = 1, id0
142 xxid (idatmax - id0 + idat) = xxd(idat) + 360.
143 fxd (idatmax - id0 + idat) = fdd(idat)
144 END DO
145 else
146 DO idat = 1, idatmax
147 xxid(idat) = xxd(idat)
148 fxd (idat) = fdd(idat)
149 ENDDO
150 end IF
151 xxid(idatmax1) = xxid(1) + 360.
152 fxd (idatmax1) = fxd(1)
153
154 ! initialisation du champ du modele
155
156 inter_barx(:) = 0.
157
158 ! iteration
159
160 x0 = xim0
161 dxm = 0.
162 imod = 1
163 idat = 1
164
165 do while (imod <= imodmax)
166 do while (xxim(imod) > xxid(idat))
167 dx = xxid(idat) - x0
168 dxm = dxm + dx
169 inter_barx(imod) = inter_barx(imod) + dx * fxd(idat)
170 x0 = xxid(idat)
171 idat = idat + 1
172 end do
173 IF (xxim(imod) < xxid(idat)) THEN
174 dx = xxim(imod) - x0
175 dxm = dxm + dx
176 inter_barx(imod) = (inter_barx(imod) + dx * fxd(idat)) / dxm
177 x0 = xxim(imod)
178 dxm = 0.
179 imod = imod + 1
180 ELSE
181 dx = xxim(imod) - x0
182 dxm = dxm + dx
183 inter_barx(imod) = (inter_barx(imod) + dx * fxd(idat)) / dxm
184 x0 = xxim(imod)
185 dxm = 0.
186 imod = imod + 1
187 idat = idat + 1
188 END IF
189 end do
190
191 END function inter_barx
192
193 end module inter_barx_m

  ViewVC Help
Powered by ViewVC 1.1.21