/[lmdze]/trunk/dyn3d/Guide/guide.f
ViewVC logotype

Annotation of /trunk/dyn3d/Guide/guide.f

Parent Directory Parent Directory | Revision Log Revision Log


Revision 85 - (hide annotations)
Thu Mar 6 17:35:22 2014 UTC (10 years, 2 months ago) by guez
Original Path: trunk/dyn3d/guide.f
File size: 9747 byte(s)
Removed option to guide surface pressure because it was not
functional: psrea1 was not defined in procedure guide. Removed local
variables psrea1 and psrea2 of procedure guide. ps becomes an
"intent(in)" argument in guide. Removed case guide_p in guide. Removed
variable guide_p of module conf_guide_m. Removed case guide_p and
argument ps in read_reanalyse. Removed case guide_p and argument ps in
reanalyse2nat.

1 guez 20 MODULE guide_m
2 guez 3
3 guez 29 ! From dyn3d/guide.F, version 1.3 2005/05/25 13:10:09
4     ! and dyn3d/guide.h, version 1.1.1.1 2004/05/19 12:53:06
5 guez 3
6 guez 37 IMPLICIT NONE
7    
8 guez 36 REAL aire_min, aire_max
9 guez 3
10 guez 20 CONTAINS
11 guez 3
12 guez 29 SUBROUTINE guide(itau, ucov, vcov, teta, q, masse, ps)
13 guez 3
14 guez 29 ! Author: F.Hourdin
15 guez 3
16 guez 83 USE comconst, ONLY: cpp, daysec, dtvr, kappa
17     USE comgeom, ONLY: aire, rlatu, rlonv
18     USE conf_gcm_m, ONLY: day_step, iperiod
19 guez 44 use conf_guide_m, only: conf_guide, guide_u, guide_v, guide_t, guide_q, &
20 guez 85 ncep, ini_anal, tau_min_u, tau_max_u, tau_min_v, tau_max_v, &
21 guez 44 tau_min_t, tau_max_t, tau_min_q, tau_max_q, tau_min_p, tau_max_p, &
22     online
23 guez 83 USE dimens_m, ONLY: jjm, llm
24     USE disvert_m, ONLY: ap, bp, preff, presnivs
25     USE exner_hyb_m, ONLY: exner_hyb
26     USE inigrads_m, ONLY: inigrads
27 guez 67 use massdair_m, only: massdair
28 guez 44 use netcdf, only: nf90_nowrite, nf90_open, nf90_close, nf90_inq_dimid, &
29     nf90_inquire_dimension
30 guez 39 use nr_util, only: pi
31 guez 83 USE paramet_m, ONLY: iip1, ip1jm, ip1jmp1, jjp1, llmp1
32     USE q_sat_m, ONLY: q_sat
33     USE serre, ONLY: clat, clon
34 guez 44 use tau2alpha_m, only: tau2alpha, dxdys
35 guez 3
36 guez 83 INTEGER, INTENT(IN):: itau
37    
38 guez 44 ! variables dynamiques
39 guez 83 REAL ucov(ip1jmp1, llm), vcov(ip1jm, llm) ! vents covariants
40 guez 29 REAL, intent(inout):: teta(ip1jmp1, llm) ! temperature potentielle
41 guez 36 REAL q(ip1jmp1, llm) ! temperature potentielle
42 guez 70 REAL, intent(out):: masse(ip1jmp1, llm) ! masse d'air
43 guez 85 REAL, intent(in):: ps(ip1jmp1) ! pression au sol
44 guez 3
45 guez 83 ! Local:
46    
47 guez 44 ! variables dynamiques pour les reanalyses.
48     REAL, save:: ucovrea1(ip1jmp1, llm), vcovrea1(ip1jm, llm) !vts cov reas
49     REAL, save:: tetarea1(ip1jmp1, llm) ! temp pot reales
50     REAL, save:: qrea1(ip1jmp1, llm) ! temp pot reales
51     REAL, save:: ucovrea2(ip1jmp1, llm), vcovrea2(ip1jm, llm) !vts cov reas
52     REAL, save:: tetarea2(ip1jmp1, llm) ! temp pot reales
53     REAL, save:: qrea2(ip1jmp1, llm) ! temp pot reales
54     REAL, save:: masserea2(ip1jmp1, llm) ! masse
55 guez 3
56 guez 44 REAL, save:: alpha_q(ip1jmp1)
57     REAL, save:: alpha_t(ip1jmp1), alpha_p(ip1jmp1)
58     REAL, save:: alpha_u(ip1jmp1), alpha_v(ip1jm)
59     REAL dday_step, toto, reste
60     real, save:: itau_test
61     INTEGER, save:: step_rea, count_no_rea
62 guez 3
63 guez 36 INTEGER ilon, ilat
64     REAL factt, ztau(ip1jmp1)
65 guez 3
66 guez 36 INTEGER ij, l
67 guez 44 INTEGER ncidpl, varidpl, status
68 guez 36 INTEGER rcod, rid
69     REAL ditau, tau, a
70 guez 44 INTEGER, SAVE:: nlev
71 guez 3
72 guez 44 ! TEST SUR QSAT
73 guez 36 REAL p(ip1jmp1, llmp1), pk(ip1jmp1, llm), pks(ip1jmp1)
74     REAL pkf(ip1jmp1, llm)
75     REAL pres(ip1jmp1, llm)
76 guez 3
77 guez 36 REAL qsat(ip1jmp1, llm)
78     REAL unskap
79     REAL tnat(ip1jmp1, llm)
80 guez 3
81 guez 37 LOGICAL:: first = .TRUE.
82 guez 44 CHARACTER(len=10) file
83     INTEGER:: igrads = 2
84     REAL:: dtgrads = 100.
85 guez 3
86 guez 29 !-----------------------------------------------------------------------
87 guez 3
88 guez 29 PRINT *, 'Call sequence information: guide'
89 guez 3
90 guez 29 ! calcul de l'humidite saturante
91 guez 3
92 guez 37 forall (l = 1: llm + 1) p(:, l) = ap(l) + bp(l) * ps
93 guez 29 CALL massdair(p, masse)
94     CALL exner_hyb(ps, p, pks, pk, pkf)
95     tnat(:, :) = pk(:, :)*teta(:, :)/cpp
96     unskap = 1./kappa
97     pres(:, :) = preff*(pk(:, :)/cpp)**unskap
98     qsat = q_sat(tnat, pres)
99 guez 3
100 guez 44 ! initialisations pour la lecture des reanalyses.
101     ! alpha determine la part des injections de donnees a chaque etape
102     ! alpha=1 signifie pas d'injection
103     ! alpha=0 signifie injection totale
104 guez 3
105 guez 29 IF (online==-1) THEN
106     RETURN
107     END IF
108 guez 3
109 guez 29 IF (first) THEN
110     CALL conf_guide
111     file = 'guide'
112     CALL inigrads(igrads, rlonv, 180./pi, -180., 180., rlatu, -90., 90., &
113     180./pi, presnivs, 1., dtgrads, file, 'dyn_zon ')
114 guez 44 PRINT *, '1: en-ligne, 0: hors-ligne (x=x_rea), -1: climat (x=x_gcm)'
115     IF (online==-1) RETURN
116 guez 3
117 guez 29 IF (online==1) THEN
118 guez 44 ! Constantes de temps de rappel en jour
119     ! 0.1 c'est en gros 2h30.
120     ! 1e10 est une constante infinie donc en gros pas de guidage
121 guez 3
122 guez 44 ! coordonnees du centre du zoom
123 guez 29 CALL coordij(clon, clat, ilon, ilat)
124 guez 44 ! aire de la maille au centre du zoom
125 guez 29 aire_min = aire(ilon+(ilat-1)*iip1)
126 guez 44 ! aire maximale de la maille
127 guez 29 aire_max = 0.
128     DO ij = 1, ip1jmp1
129     aire_max = max(aire_max, aire(ij))
130     END DO
131 guez 44 ! factt = pas de temps en fraction de jour
132 guez 29 factt = dtvr*iperiod/daysec
133 guez 3
134 guez 29 CALL tau2alpha(3, iip1, jjm, factt, tau_min_v, tau_max_v, alpha_v)
135     CALL tau2alpha(2, iip1, jjp1, factt, tau_min_u, tau_max_u, alpha_u)
136     CALL tau2alpha(1, iip1, jjp1, factt, tau_min_t, tau_max_t, alpha_t)
137     CALL tau2alpha(1, iip1, jjp1, factt, tau_min_p, tau_max_p, alpha_p)
138     CALL tau2alpha(1, iip1, jjp1, factt, tau_min_q, tau_max_q, alpha_q)
139 guez 3
140 guez 29 CALL dump2d(iip1, jjp1, aire, 'AIRE MAILLe ')
141 guez 44 CALL dump2d(iip1, jjp1, alpha_u, 'COEFF U ')
142     CALL dump2d(iip1, jjp1, alpha_t, 'COEFF T ')
143 guez 3
144 guez 44 ! Cas ou on force exactement par les variables analysees
145 guez 29 ELSE
146     alpha_t = 0.
147     alpha_u = 0.
148     alpha_v = 0.
149     alpha_p = 0.
150 guez 44 ! physic=.false.
151 guez 29 END IF
152 guez 3
153 guez 29 itau_test = 1001
154     step_rea = 1
155     count_no_rea = 0
156     ncidpl = -99
157 guez 3
158 guez 44 ! itau_test montre si l'importation a deja ete faite au rang itau
159 guez 29 ! lecture d'un fichier netcdf pour determiner le nombre de niveaux
160     if (guide_u) then
161     if (ncidpl.eq.-99) rcod=nf90_open('u.nc',Nf90_NOWRITe,ncidpl)
162     endif
163 guez 3
164 guez 29 if (guide_v) then
165     if (ncidpl.eq.-99) rcod=nf90_open('v.nc',nf90_nowrite,ncidpl)
166     endif
167 guez 3
168 guez 29 if (guide_T) then
169     if (ncidpl.eq.-99) rcod=nf90_open('T.nc',nf90_nowrite,ncidpl)
170     endif
171 guez 3
172 guez 29 if (guide_Q) then
173     if (ncidpl.eq.-99) rcod=nf90_open('hur.nc',nf90_nowrite, ncidpl)
174     endif
175 guez 3
176 guez 29 IF (ncep) THEN
177 guez 44 status = nf90_inq_dimid(ncidpl, 'LEVEL', rid)
178 guez 29 ELSE
179 guez 44 status = nf90_inq_dimid(ncidpl, 'PRESSURE', rid)
180 guez 29 END IF
181 guez 44 status = nf90_inquire_dimension(ncidpl, rid, len=nlev)
182 guez 29 PRINT *, 'nlev', nlev
183     rcod = nf90_close(ncidpl)
184 guez 44 ! Lecture du premier etat des reanalyses.
185 guez 29 CALL read_reanalyse(1, ps, ucovrea2, vcovrea2, tetarea2, qrea2, &
186 guez 85 masserea2, 1, nlev)
187 guez 29 qrea2(:, :) = max(qrea2(:, :), 0.1)
188 guez 3
189 guez 44 ! Debut de l'integration temporelle:
190 guez 29 END IF ! first
191 guez 3
192 guez 29 ! IMPORTATION DES VENTS, PRESSION ET TEMPERATURE REELS:
193 guez 3
194 guez 29 ditau = real(itau)
195     dday_step = real(day_step)
196     WRITE (*, *) 'ditau, dday_step'
197     WRITE (*, *) ditau, dday_step
198     toto = 4*ditau/dday_step
199     reste = toto - aint(toto)
200 guez 3
201 guez 29 IF (reste==0.) THEN
202     IF (itau_test==itau) THEN
203     WRITE (*, *) 'deuxieme passage de advreel a itau=', itau
204     STOP
205     ELSE
206     vcovrea1(:, :) = vcovrea2(:, :)
207     ucovrea1(:, :) = ucovrea2(:, :)
208     tetarea1(:, :) = tetarea2(:, :)
209     qrea1(:, :) = qrea2(:, :)
210 guez 3
211 guez 29 PRINT *, 'LECTURE REANALYSES, pas ', step_rea, 'apres ', &
212     count_no_rea, ' non lectures'
213     step_rea = step_rea + 1
214     itau_test = itau
215     CALL read_reanalyse(step_rea, ps, ucovrea2, vcovrea2, tetarea2, &
216 guez 85 qrea2, masserea2, 1, nlev)
217 guez 29 qrea2(:, :) = max(qrea2(:, :), 0.1)
218     factt = dtvr*iperiod/daysec
219     ztau(:) = factt/max(alpha_t(:), 1.E-10)
220 guez 44 CALL wrgrads(igrads, 1, aire, 'aire ', 'aire ')
221     CALL wrgrads(igrads, 1, dxdys, 'dxdy ', 'dxdy ')
222     CALL wrgrads(igrads, 1, alpha_u, 'au ', 'au ')
223     CALL wrgrads(igrads, 1, alpha_t, 'at ', 'at ')
224     CALL wrgrads(igrads, 1, ztau, 'taut ', 'taut ')
225     CALL wrgrads(igrads, llm, ucov, 'u ', 'u ')
226     CALL wrgrads(igrads, llm, ucovrea2, 'ua ', 'ua ')
227     CALL wrgrads(igrads, llm, teta, 'T ', 'T ')
228     CALL wrgrads(igrads, llm, tetarea2, 'Ta ', 'Ta ')
229     CALL wrgrads(igrads, llm, qrea2, 'Qa ', 'Qa ')
230     CALL wrgrads(igrads, llm, q, 'Q ', 'Q ')
231 guez 3
232 guez 44 CALL wrgrads(igrads, llm, qsat, 'QSAT ', 'QSAT ')
233 guez 3
234 guez 29 END IF
235     ELSE
236     count_no_rea = count_no_rea + 1
237     END IF
238 guez 3
239 guez 44 ! Guidage
240     ! x_gcm = a * x_gcm + (1-a) * x_reanalyses
241 guez 3
242 guez 29 IF (ini_anal) PRINT *, 'ATTENTION !!! ON PART DU GUIDAGE'
243 guez 3
244 guez 29 ditau = real(itau)
245     dday_step = real(day_step)
246 guez 3
247 guez 29 tau = 4*ditau/dday_step
248     tau = tau - aint(tau)
249 guez 3
250 guez 44 ! ucov
251 guez 29 IF (guide_u) THEN
252     DO l = 1, llm
253     DO ij = 1, ip1jmp1
254     a = (1.-tau)*ucovrea1(ij, l) + tau*ucovrea2(ij, l)
255     ucov(ij, l) = (1.-alpha_u(ij))*ucov(ij, l) + alpha_u(ij)*a
256     IF (first .AND. ini_anal) ucov(ij, l) = a
257     END DO
258     END DO
259     END IF
260 guez 3
261 guez 29 IF (guide_t) THEN
262     DO l = 1, llm
263     DO ij = 1, ip1jmp1
264     a = (1.-tau)*tetarea1(ij, l) + tau*tetarea2(ij, l)
265     teta(ij, l) = (1.-alpha_t(ij))*teta(ij, l) + alpha_t(ij)*a
266     IF (first .AND. ini_anal) teta(ij, l) = a
267     END DO
268     END DO
269     END IF
270 guez 3
271 guez 29 IF (guide_q) THEN
272     DO l = 1, llm
273     DO ij = 1, ip1jmp1
274     a = (1.-tau)*qrea1(ij, l) + tau*qrea2(ij, l)
275 guez 44 ! hum relative en % -> hum specif
276 guez 29 a = qsat(ij, l)*a*0.01
277     q(ij, l) = (1.-alpha_q(ij))*q(ij, l) + alpha_q(ij)*a
278     IF (first .AND. ini_anal) q(ij, l) = a
279     END DO
280     END DO
281     END IF
282 guez 3
283 guez 29 ! vcov
284     IF (guide_v) THEN
285     DO l = 1, llm
286     DO ij = 1, ip1jm
287     a = (1.-tau)*vcovrea1(ij, l) + tau*vcovrea2(ij, l)
288     vcov(ij, l) = (1.-alpha_v(ij))*vcov(ij, l) + alpha_v(ij)*a
289     IF (first .AND. ini_anal) vcov(ij, l) = a
290     END DO
291     IF (first .AND. ini_anal) vcov(ij, l) = a
292     END DO
293     END IF
294 guez 3
295 guez 29 first = .FALSE.
296 guez 3
297 guez 29 END SUBROUTINE guide
298 guez 20
299     END MODULE guide_m

  ViewVC Help
Powered by ViewVC 1.1.21