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

Contents of /trunk/dyn3d/bilan_dyn.f

Parent Directory Parent Directory | Revision Log Revision Log


Revision 254 - (show annotations)
Mon Feb 5 10:39:38 2018 UTC (6 years, 3 months ago) by guez
File size: 7334 byte(s)
Move Sources/* to root directory.
1 module bilan_dyn_m
2
3 IMPLICIT NONE
4
5 contains
6
7 SUBROUTINE bilan_dyn(ps, masse, pk, flux_u, flux_v, teta, phi, ucov, vcov, &
8 trac)
9
10 ! From LMDZ4/libf/dyn3d/bilan_dyn.F, version 1.5 2005/03/16 10:12:17
11
12 ! Sous-programme consacr\'e \`a des diagnostics dynamiques de
13 ! base. De fa\c{}con g\'en\'erale, les moyennes des scalaires Q
14 ! sont pond\'er\'ees par la masse. Les flux de masse sont, eux,
15 ! simplement moyenn\'es.
16
17 USE comconst, ONLY: cpp
18 USE comgeom, ONLY: constang_2d, cu_2d, cv_2d
19 use covcont_m, only: covcont
20 USE dimens_m, ONLY: iim, jjm, llm
21 use enercin_m, only: enercin
22 USE histwrite_m, ONLY: histwrite
23 use init_dynzon_m, only: ncum, fileid, znom, ntr, nq, nom
24 use massbar_m, only: massbar
25 USE paramet_m, ONLY: iip1, jjp1
26
27 real, intent(in):: ps(iip1, jjp1)
28 real, intent(in):: masse(iip1, jjp1, llm), pk(iip1, jjp1, llm)
29 real, intent(in):: flux_u(iip1, jjp1, llm)
30 real, intent(in):: flux_v(iip1, jjm, llm)
31 real, intent(in):: teta(iip1, jjp1, llm)
32 real, intent(in):: phi(iip1, jjp1, llm)
33 real, intent(in):: ucov(:, :, :) ! (iip1, jjp1, llm)
34 real, intent(in):: vcov(iip1, jjm, llm)
35 real, intent(in):: trac(:, :, :) ! (iim + 1, jjm + 1, llm)
36
37 ! Local:
38
39 integer:: icum = 0
40 integer:: itau = 0
41 real qy, factv(jjm, llm)
42
43 ! Variables dynamiques interm\'ediaires
44 REAL vcont(iip1, jjm, llm), ucont(iip1, jjp1, llm)
45 REAL ang(iip1, jjp1, llm), unat(iip1, jjp1, llm)
46 REAL massebx(iip1, jjp1, llm), masseby(iip1, jjm, llm)
47 REAL ecin(iip1, jjp1, llm)
48
49 ! Champ contenant les scalaires advect\'es
50 real Q(iip1, jjp1, llm, nQ)
51
52 ! Champs cumul\'es
53 real, save:: ps_cum(iip1, jjp1)
54 real, save:: masse_cum(iip1, jjp1, llm)
55 real, save:: flux_u_cum(iip1, jjp1, llm)
56 real, save:: flux_v_cum(iip1, jjm, llm)
57 real, save:: Q_cum(iip1, jjp1, llm, nQ)
58 real, save:: flux_uQ_cum(iip1, jjp1, llm, nQ)
59 real, save:: flux_vQ_cum(iip1, jjm, llm, nQ)
60
61 ! champs de tansport en moyenne zonale
62 integer itr
63 integer, parameter:: iave = 1, itot = 2, immc = 3, itrs = 4, istn = 5
64
65 real vq(jjm, llm, ntr, nQ), vqtmp(jjm, llm)
66 real avq(jjm, 2: ntr, nQ), psiQ(jjm, llm + 1, nQ)
67 real zmasse(jjm, llm)
68 real v(jjm, llm), psi(jjm, llm + 1)
69 integer i, j, l, iQ
70
71 !-----------------------------------------------------------------
72
73 ! Calcul des champs dynamiques
74
75 ! \'Energie cin\'etique
76 ucont = 0
77 CALL covcont(llm, ucov, vcov, ucont, vcont)
78 CALL enercin(vcov, ucov, vcont, ucont, ecin)
79
80 ! moment cin\'etique
81 forall (l = 1: llm)
82 ang(:, :, l) = ucov(:, :, l) + constang_2d
83 unat(:, :, l) = ucont(:, :, l) * cu_2d
84 end forall
85
86 Q(:, :, :, 1) = teta * pk / cpp
87 Q(:, :, :, 2) = phi
88 Q(:, :, :, 3) = ecin
89 Q(:, :, :, 4) = ang
90 Q(:, :, :, 5) = unat
91 Q(:, :, :, 6) = trac
92 Q(:, :, :, 7) = 1.
93
94 ! Cumul
95
96 if (icum == 0) then
97 ps_cum = 0.
98 masse_cum = 0.
99 flux_u_cum = 0.
100 flux_v_cum = 0.
101 Q_cum = 0.
102 flux_vQ_cum = 0.
103 flux_uQ_cum = 0.
104 endif
105
106 itau = itau + 1
107 icum = icum + 1
108
109 ! Accumulation des flux de masse horizontaux
110 ps_cum = ps_cum + ps
111 masse_cum = masse_cum + masse
112 flux_u_cum = flux_u_cum + flux_u
113 flux_v_cum = flux_v_cum + flux_v
114 forall (iQ = 1: nQ) Q_cum(:, :, :, iQ) = Q_cum(:, :, :, iQ) &
115 + Q(:, :, :, iQ) * masse
116
117 ! Flux longitudinal
118 forall (iQ = 1: nQ, i = 1: iim) flux_uQ_cum(i, :, :, iQ) &
119 = flux_uQ_cum(i, :, :, iQ) &
120 + flux_u(i, :, :) * 0.5 * (Q(i, :, :, iQ) + Q(i + 1, :, :, iQ))
121 flux_uQ_cum(iip1, :, :, :) = flux_uQ_cum(1, :, :, :)
122
123 ! Flux m\'eridien
124 forall (iQ = 1: nQ, j = 1: jjm) flux_vQ_cum(:, j, :, iQ) &
125 = flux_vQ_cum(:, j, :, iQ) &
126 + flux_v(:, j, :) * 0.5 * (Q(:, j, :, iQ) + Q(:, j + 1, :, iQ))
127
128 writing_step: if (icum == ncum) then
129 ! Normalisation
130 forall (iQ = 1: nQ) Q_cum(:, :, :, iQ) = Q_cum(:, :, :, iQ) / masse_cum
131 ps_cum = ps_cum / ncum
132 masse_cum = masse_cum / ncum
133 flux_u_cum = flux_u_cum / ncum
134 flux_v_cum = flux_v_cum / ncum
135 flux_uQ_cum = flux_uQ_cum / ncum
136 flux_vQ_cum = flux_vQ_cum / ncum
137
138 ! Transport m\'eridien
139
140 ! Cumul zonal des masses des mailles
141
142 v = 0.
143 zmasse = 0.
144 call massbar(masse_cum, massebx, masseby)
145 do l = 1, llm
146 do j = 1, jjm
147 do i = 1, iim
148 zmasse(j, l) = zmasse(j, l) + masseby(i, j, l)
149 v(j, l) = v(j, l) + flux_v_cum(i, j, l)
150 enddo
151 factv(j, l) = cv_2d(1, j) / zmasse(j, l)
152 enddo
153 enddo
154
155 ! Transport dans le plan latitude-altitude
156
157 vq = 0.
158 psiQ = 0.
159 do iQ = 1, nQ
160 vqtmp = 0.
161 do l = 1, llm
162 do j = 1, jjm
163 ! Calcul des moyennes zonales du transport total et de vqtmp
164 do i = 1, iim
165 vq(j, l, itot, iQ) = vq(j, l, itot, iQ) &
166 + flux_vQ_cum(i, j, l, iQ)
167 qy = 0.5 * (Q_cum(i, j, l, iQ) * masse_cum(i, j, l) &
168 + Q_cum(i, j + 1, l, iQ) * masse_cum(i, j + 1, l))
169 vqtmp(j, l) = vqtmp(j, l) + flux_v_cum(i, j, l) * qy &
170 / (0.5 * (masse_cum(i, j, l) + masse_cum(i, j + 1, l)))
171 vq(j, l, iave, iQ) = vq(j, l, iave, iQ) + qy
172 enddo
173 ! Decomposition
174 vq(j, l, iave, iQ) = vq(j, l, iave, iQ) / zmasse(j, l)
175 vq(j, l, itot, iQ) = vq(j, l, itot, iQ) * factv(j, l)
176 vqtmp(j, l) = vqtmp(j, l) * factv(j, l)
177 vq(j, l, immc, iQ) = v(j, l) * vq(j, l, iave, iQ) * factv(j, l)
178 vq(j, l, itrs, iQ) = vq(j, l, itot, iQ) - vqtmp(j, l)
179 vq(j, l, istn, iQ) = vqtmp(j, l) - vq(j, l, immc, iQ)
180 enddo
181 enddo
182 ! Fonction de courant m\'eridienne pour la quantit\'e Q
183 do l = llm, 1, -1
184 do j = 1, jjm
185 psiQ(j, l, iQ) = psiQ(j, l + 1, iQ) + vq(j, l, itot, iQ)
186 enddo
187 enddo
188 enddo
189
190 ! Fonction de courant pour la circulation m\'eridienne moyenne
191 psi = 0.
192 do l = llm, 1, -1
193 do j = 1, jjm
194 psi(j, l) = psi(j, l + 1) + v(j, l)
195 v(j, l) = v(j, l) * factv(j, l)
196 enddo
197 enddo
198
199 ! Sorties proprement dites
200 do iQ = 1, nQ
201 do itr = 1, ntr
202 call histwrite(fileid, znom(itr, iQ), itau, vq(:, :, itr, iQ))
203 enddo
204 call histwrite(fileid, 'psi' // nom(iQ), itau, psiQ(:, :llm, iQ))
205 enddo
206
207 call histwrite(fileid, 'masse', itau, zmasse)
208 call histwrite(fileid, 'v', itau, v)
209 psi = psi * 1e-9
210 call histwrite(fileid, 'psi', itau, psi(:, :llm))
211
212 ! Int\'egrale verticale
213
214 forall (iQ = 1: nQ, itr = 2: ntr) avq(:, itr, iQ) &
215 = sum(vq(:, :, itr, iQ) * zmasse, dim=2) / cv_2d(1, :)
216
217 do iQ = 1, nQ
218 do itr = 2, ntr
219 call histwrite(fileid, 'a' // znom(itr, iQ), itau, avq(:, itr, iQ))
220 enddo
221 enddo
222
223 icum = 0
224 endif writing_step
225
226 end SUBROUTINE bilan_dyn
227
228 end module bilan_dyn_m

  ViewVC Help
Powered by ViewVC 1.1.21