source: LMDZ5/trunk/libf/phylmd/cv3_cine.F90 @ 3740

Last change on this file since 3740 was 2416, checked in by jyg, 9 years ago

Accounting for situations where the adiabatic
ascent does not go above pLCL - 50 hPa in
cv3_cine.F90.

  • Property copyright set to
    Name of program: LMDZ
    Creation date: 1984
    Version: LMDZ5
    License: CeCILL version 2
    Holder: Laboratoire de m\'et\'eorologie dynamique, CNRS, UMR 8539
    See the license file in the root directory
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 12.8 KB
Line 
1
2! $Id: cv3_cine.F90 2416 2015-12-24 11:58:33Z lguez $
3
4SUBROUTINE cv3_cine(nloc, ncum, nd, icb, inb, pbase, plcl, p, ph, tv, tvp, &
5    cina, cinb, plfc)
6
7  ! **************************************************************
8  ! *
9  ! CV3_CINE                                                    *
10  ! *
11  ! *
12  ! written by   :   Frederique Cheruy                          *
13  ! vectorization:   Jean-Yves Grandpeix, 19/06/2003, 11.54.43  *
14  ! modified by :                                               *
15  ! **************************************************************
16
17  IMPLICIT NONE
18
19  include "YOMCST.h"
20  include "cvthermo.h"
21  include "cv3param.h"
22  ! input:
23  INTEGER ncum, nd, nloc
24  INTEGER icb(nloc), inb(nloc)
25  REAL pbase(nloc), plcl(nloc)
26  REAL p(nloc, nd), ph(nloc, nd+1)
27  REAL tv(nloc, nd), tvp(nloc, nd)
28
29  ! output
30  REAL cina(nloc), cinb(nloc), plfc(nloc)
31
32  ! local variables
33  INTEGER il, i, j, k
34  INTEGER itop(nloc), ineg(nloc), ilow(nloc)
35  INTEGER ifst(nloc), isublcl(nloc)
36  LOGICAL lswitch(nloc), lswitch1(nloc), lswitch2(nloc), lswitch3(nloc)
37  LOGICAL exist_lfc(nloc)
38  REAL dpmax
39  REAL deltap, dcin
40  REAL buoylcl(nloc), tvplcl(nloc), tvlcl(nloc)
41  REAL p0(nloc)
42  REAL buoyz(nloc), buoy(nloc, nd)
43
44  ! -------------------------------------------------------------
45  ! Initialization
46  ! -------------------------------------------------------------
47  DO il = 1, ncum
48    cina(il) = 0.
49    cinb(il) = 0.
50  END DO
51
52  ! --------------------------------------------------------------
53  ! Recompute buoyancies
54  ! --------------------------------------------------------------
55  DO k = 1, nd
56    DO il = 1, ncum
57      ! print*,'tvp tv=',tvp(il,k),tv(il,k)
58      buoy(il, k) = tvp(il, k) - tv(il, k)
59    END DO
60  END DO
61  ! ---------------------------------------------------------------
62
63  ! calcul de la flottabilite a LCL (Buoylcl)
64  ! ifst = first P-level above lcl
65  ! isublcl = highest P-level below lcl.
66  ! ---------------------------------------------------------------
67
68  DO il = 1, ncum
69    tvplcl(il) = tvp(il, 1)*(plcl(il)/p(il,1))**(2./7.) !For dry air, R/Cp=2/7
70  END DO
71
72  DO il = 1, ncum
73    IF (plcl(il)>p(il,icb(il))) THEN
74      ifst(il) = icb(il)
75      isublcl(il) = icb(il) - 1
76    ELSE
77      ifst(il) = icb(il) + 1
78      isublcl(il) = icb(il)
79    END IF
80  END DO
81
82  DO il = 1, ncum
83    tvlcl(il) = tv(il, ifst(il)-1) + (tv(il,ifst(il))-tv(il,ifst(il)-1))*( &
84      plcl(il)-p(il,ifst(il)-1))/(p(il,ifst(il))-p(il,ifst(il)-1))
85  END DO
86
87  DO il = 1, ncum
88    buoylcl(il) = tvplcl(il) - tvlcl(il)
89  END DO
90
91  ! ---------------------------------------------------------------
92  ! premiere couche contenant un  niveau de flotabilite positive
93  ! et premiere couche contenant un  niveau de flotabilite negative
94  ! au dessus du niveau de condensation
95  ! ---------------------------------------------------------------
96  DO il = 1, ncum
97    itop(il) = nl - 1
98    ineg(il) = nl - 1
99    exist_lfc(il) = .FALSE.
100  END DO
101  DO k = nl - 1, 1, -1
102    DO il = 1, ncum
103      IF (k>=ifst(il)) THEN
104        IF (buoy(il,k)>0.) THEN
105          itop(il) = k
106          exist_lfc(il) = .TRUE.
107        ELSE
108          ineg(il) = k
109        END IF
110      END IF
111    END DO
112  END DO
113
114  ! ---------------------------------------------------------------
115  ! When there is no positive buoyancy level, set Plfc, Cina and Cinb
116  ! to arbitrary extreme values.
117  ! ---------------------------------------------------------------
118  DO il = 1, ncum
119    IF (.NOT. exist_lfc(il)) THEN
120      plfc(il) = 1.111
121      cinb(il) = -1111.
122      cina(il) = -1112.
123    END IF
124  END DO
125
126
127  ! ---------------------------------------------------------------
128  ! -- Two cases : BUOYlcl >= 0 and BUOYlcl < 0.
129  ! ---------------------------------------------------------------
130
131  ! --------------------
132  ! -- 1.0 BUOYlcl >=0.
133  ! --------------------
134
135  dpmax = 50.
136  DO il = 1, ncum
137    lswitch1(il) = buoylcl(il) >= 0. .AND. exist_lfc(il)
138    lswitch(il) = lswitch1(il)
139  END DO
140
141  ! 1.1 No inhibition case
142  ! ----------------------
143  ! If buoyancy is positive at LCL and stays positive over a large enough
144  ! pressure interval (=DPMAX), inhibition is set to zero,
145
146  DO il = 1, ncum
147    IF (lswitch(il)) THEN
148      IF (p(il,ineg(il))<p(il,icb(il))-dpmax) THEN
149        plfc(il) = plcl(il)
150        cina(il) = 0.
151        cinb(il) = 0.
152      END IF
153    END IF
154  END DO
155
156  ! 1.2 Upper inhibition only case
157  ! ------------------------------
158  DO il = 1, ncum
159    lswitch2(il) = p(il, ineg(il)) >= p(il, icb(il)) - dpmax
160    lswitch(il) = lswitch1(il) .AND. lswitch2(il)
161  END DO
162
163  ! 1.2.1 Recompute itop (=1st layer with positive buoyancy above ineg)
164  ! -------------------------------------------------------------------
165
166  DO il = 1, ncum
167    IF (lswitch(il)) THEN
168      itop(il) = nl - 1
169    END IF
170  END DO
171
172  DO k = nl, 1, -1
173    DO il = 1, ncum
174      IF (lswitch(il)) THEN
175        IF (k>=ineg(il) .AND. buoy(il,k)>0) THEN
176          itop(il) = k
177        END IF
178      END IF
179    END DO
180  END DO
181
182  ! If there is no layer with positive buoyancy above ineg, set Plfc,
183  ! Cina and Cinb to arbitrary extreme values.
184  DO il = 1, ncum
185    IF (lswitch(il) .AND. itop(il) == nl - 1) THEN
186      plfc(il) = 1.121
187      cinb(il) = -1121.
188      cina(il) = -1122.
189    END IF
190  END DO
191
192  DO il = 1, ncum
193    lswitch3(il) = itop(il) < nl -1
194    lswitch(il) = lswitch1(il) .AND. lswitch2(il) .AND. lswitch3(il)
195  END DO
196
197  DO il = 1, ncum
198    IF (lswitch(il)) THEN
199      cinb(il) = 0.
200
201      ! 1.2.2  Calcul de la pression du niveau de flot. nulle juste au-dessus
202      ! de LCL
203      ! ---------------------------------------------------------------------------
204      IF (ineg(il)>isublcl(il)+1) THEN
205        ! In order to get P0, one may interpolate linearly buoyancies
206        ! between P(ineg) and P(ineg-1).
207        p0(il) = (buoy(il,ineg(il))*p(il,ineg(il)-1)-buoy(il,ineg(il)-1)*p(il,ineg(il)))/ &
208          (buoy(il,ineg(il))-buoy(il,ineg(il)-1))
209      ELSE
210        ! In order to get P0, one has to interpolate between P(ineg) and
211        ! Plcl.
212        p0(il) = (buoy(il,ineg(il))*plcl(il)-buoylcl(il)*p(il,ineg(il)))/ &
213          (buoy(il,ineg(il))-buoylcl(il))
214      END IF
215    END IF
216  END DO
217
218  ! 1.2.3 Computation of PLFC
219  ! -------------------------
220  DO il = 1, ncum
221    IF (lswitch(il)) THEN
222      plfc(il) = (buoy(il,itop(il))*p(il,itop(il)-1)-buoy(il,itop( &
223        il)-1)*p(il,itop(il)))/(buoy(il,itop(il))-buoy(il,itop(il)-1))
224    END IF
225  END DO
226
227  ! 1.2.4 Computation of CINA
228  ! -------------------------
229
230  ! Upper part of CINA : integral from P(itop-1) to Plfc
231  DO il = 1, ncum
232    IF (lswitch(il)) THEN
233      deltap = p(il, itop(il)-1) - plfc(il)
234      dcin = rd*buoy(il, itop(il)-1)*deltap/(p(il,itop(il)-1)+plfc(il))
235      cina(il) = min(0., dcin)
236    END IF
237  END DO
238
239  ! Middle part of CINA : integral from P(ineg) to P(itop-1)
240  DO k = 1, nl
241    DO il = 1, ncum
242      IF (lswitch(il)) THEN
243        IF (k>=ineg(il) .AND. k<=itop(il)-2) THEN
244          deltap = p(il, k) - p(il, k+1)
245          dcin = 0.5*rd*(buoy(il,k)+buoy(il,k+1))*deltap/ph(il, k+1)
246          cina(il) = cina(il) + min(0., dcin)
247        END IF
248      END IF
249    END DO
250  END DO
251
252  ! Lower part of CINA : integral from P0 to P(ineg)
253  DO il = 1, ncum
254    IF (lswitch(il)) THEN
255      deltap = p0(il) - p(il, ineg(il))
256      dcin = rd*buoy(il, ineg(il))*deltap/(p(il,ineg(il))+p0(il))
257      cina(il) = cina(il) + min(0., dcin)
258    END IF
259  END DO
260
261
262  ! ------------------
263  ! -- 2.0 BUOYlcl <0.
264  ! ------------------
265
266  DO il = 1, ncum
267    lswitch1(il) = buoylcl(il) < 0. .AND. exist_lfc(il)
268    lswitch(il) = lswitch1(il)
269  END DO
270
271  ! 2.0.1 Premiere  couche ou la flotabilite est negative au dessus du sol
272  ! ----------------------------------------------------
273  ! au cas ou elle existe  sinon ilow=1 (nk apres)
274  ! on suppose que la parcelle part de la premiere couche
275
276  DO il = 1, ncum
277    IF (lswitch(il)) THEN
278      ilow(il) = 1
279    END IF
280  END DO
281
282  DO k = nl, 1, -1
283    DO il = 1, ncum
284      IF (lswitch(il) .AND. k<=icb(il)-1) THEN
285        IF (buoy(il,k)<0.) THEN
286          ilow(il) = k
287        END IF
288      END IF
289    END DO
290  END DO
291
292  ! 2.0.2  Calcul de la pression du niveau de flot. nulle sous le nuage
293  ! ----------------------------------------------------
294  DO il = 1, ncum
295    IF (lswitch(il)) THEN
296      IF (ilow(il)>1) THEN
297        p0(il) = (buoy(il,ilow(il))*p(il,ilow(il)-1)-buoy(il,ilow( &
298          il)-1)*p(il,ilow(il)))/(buoy(il,ilow(il))-buoy(il,ilow(il)-1))
299        buoyz(il) = 0.
300      ELSE
301        p0(il) = p(il, 1)
302        buoyz(il) = buoy(il, 1)
303      END IF
304    END IF
305  END DO
306
307  ! 2.1. Computation of CINB
308  ! -----------------------
309
310  DO il = 1, ncum
311    lswitch2(il) = (isublcl(il)==1 .AND. ilow(il)==1) .OR. &
312      (isublcl(il)==ilow(il)-1)
313    lswitch(il) = lswitch1(il) .AND. lswitch2(il)
314  END DO
315  ! c      IF (    (isublcl .EQ. 1 .AND. ilow .EQ. 1)
316  ! c     $    .OR.(isublcl .EQ. ilow-1)) THEN
317
318  ! 2.1.1 First case : Plcl just above P0
319  ! -------------------------------------
320  DO il = 1, ncum
321    IF (lswitch(il)) THEN
322      deltap = p0(il) - plcl(il)
323      dcin = rd*(buoyz(il)+buoylcl(il))*deltap/(p0(il)+plcl(il))
324      cinb(il) = min(0., dcin)
325    END IF
326  END DO
327
328  DO il = 1, ncum
329    lswitch(il) = lswitch1(il) .AND. .NOT. lswitch2(il)
330  END DO
331  ! c      ELSE
332
333  ! 2.1.2 Second case : there is at least one P-level between P0 and Plcl
334  ! ---------------------------------------------------------------------
335
336  ! Lower part of CINB : integral from P0 to P(ilow)
337  DO il = 1, ncum
338    IF (lswitch(il)) THEN
339      deltap = p0(il) - p(il, ilow(il))
340      dcin = rd*(buoyz(il)+buoy(il,ilow(il)))*deltap/(p0(il)+p(il,ilow(il)))
341      cinb(il) = min(0., dcin)
342    END IF
343  END DO
344
345
346  ! Middle part of CINB : integral from P(ilow) to P(isublcl)
347  ! c      DO k = ilow,isublcl-1
348  DO k = 1, nl
349    DO il = 1, ncum
350      IF (lswitch(il) .AND. k>=ilow(il) .AND. k<=isublcl(il)-1) THEN
351        deltap = p(il, k) - p(il, k+1)
352        dcin = 0.5*rd*(buoy(il,k)+buoy(il,k+1))*deltap/ph(il, k+1)
353        cinb(il) = cinb(il) + min(0., dcin)
354      END IF
355    END DO
356  END DO
357
358  ! Upper part of CINB : integral from P(isublcl) to Plcl
359  DO il = 1, ncum
360    IF (lswitch(il)) THEN
361      deltap = p(il, isublcl(il)) - plcl(il)
362      dcin = rd*(buoy(il,isublcl(il))+buoylcl(il))*deltap/ &
363        (p(il,isublcl(il))+plcl(il))
364      cinb(il) = cinb(il) + min(0., dcin)
365    END IF
366  END DO
367
368
369  ! c      ENDIF
370
371  ! 2.2 Computation of CINA
372  ! ---------------------
373
374  DO il = 1, ncum
375    lswitch2(il) = plcl(il) > p(il, itop(il)-1)
376    lswitch(il) = lswitch1(il) .AND. lswitch2(il)
377  END DO
378
379  ! 2.2.1 FIrst case : Plcl > P(itop-1)
380  ! ---------------------------------
381  ! In order to get Plfc, one may interpolate linearly buoyancies
382  ! between P(itop) and P(itop-1).
383  DO il = 1, ncum
384    IF (lswitch(il)) THEN
385      plfc(il) = (buoy(il,itop(il))*p(il,itop(il)-1)-buoy(il,itop( &
386        il)-1)*p(il,itop(il)))/(buoy(il,itop(il))-buoy(il,itop(il)-1))
387    END IF
388  END DO
389
390  ! Upper part of CINA : integral from P(itop-1) to Plfc
391  DO il = 1, ncum
392    IF (lswitch(il)) THEN
393      deltap = p(il, itop(il)-1) - plfc(il)
394      dcin = rd*buoy(il, itop(il)-1)*deltap/(p(il,itop(il)-1)+plfc(il))
395      cina(il) = min(0., dcin)
396    END IF
397  END DO
398
399  ! Middle part of CINA : integral from P(icb+1) to P(itop-1)
400  DO k = 1, nl
401    DO il = 1, ncum
402      IF (lswitch(il) .AND. k>=icb(il)+1 .AND. k<=itop(il)-2) THEN
403        deltap = p(il, k) - p(il, k+1)
404        dcin = 0.5*rd*(buoy(il,k)+buoy(il,k+1))*deltap/ph(il, k+1)
405        cina(il) = cina(il) + min(0., dcin)
406      END IF
407    END DO
408  END DO
409
410  ! Lower part of CINA : integral from Plcl to P(icb+1)
411  DO il = 1, ncum
412    IF (lswitch(il)) THEN
413      IF (plcl(il)>p(il,icb(il))) THEN
414        IF (icb(il)<itop(il)-1) THEN
415          deltap = p(il, icb(il)) - p(il, icb(il)+1)
416          dcin = 0.5*rd*(buoy(il,icb(il))+buoy(il,icb(il)+1))*deltap/ &
417            ph(il, icb(il)+1)
418          cina(il) = cina(il) + min(0., dcin)
419        END IF
420
421        deltap = plcl(il) - p(il, icb(il))
422        dcin = rd*(buoylcl(il)+buoy(il,icb(il)))*deltap/ &
423          (plcl(il)+p(il,icb(il)))
424        cina(il) = cina(il) + min(0., dcin)
425      ELSE
426        deltap = plcl(il) - p(il, icb(il)+1)
427        dcin = rd*(buoylcl(il)+buoy(il,icb(il)+1))*deltap/ &
428          (plcl(il)+p(il,icb(il)+1))
429        cina(il) = cina(il) + min(0., dcin)
430      END IF
431    END IF
432  END DO
433
434  DO il = 1, ncum
435    lswitch(il) = lswitch1(il) .AND. .NOT. lswitch2(il)
436  END DO
437  ! c      ELSE
438
439  ! 2.2.2 Second case : Plcl lies between P(itop-1) and P(itop);
440  ! ----------------------------------------------------------
441  ! In order to get Plfc, one has to interpolate between P(itop) and Plcl.
442  DO il = 1, ncum
443    IF (lswitch(il)) THEN
444      plfc(il) = (buoy(il,itop(il))*plcl(il)-buoylcl(il)*p(il,itop(il)))/ &
445        (buoy(il,itop(il))-buoylcl(il))
446    END IF
447  END DO
448
449  DO il = 1, ncum
450    IF (lswitch(il)) THEN
451      deltap = plcl(il) - plfc(il)
452      dcin = rd*buoylcl(il)*deltap/(plcl(il)+plfc(il))
453      cina(il) = min(0., dcin)
454    END IF
455  END DO
456  ! c      ENDIF
457
458
459
460  RETURN
461END SUBROUTINE cv3_cine
Note: See TracBrowser for help on using the repository browser.