source: LMDZ5/trunk/libf/phylmd/cv3p2_closure.F90 @ 2379

Last change on this file since 2379 was 2374, checked in by jyg, 9 years ago

Creation of a new closure routine for Emanuel
convective scheme: cv3p2_closure.F90 (called when
iflag_clos=3) is a cleaned up and reordered
version of cv3p1_closure.F90. cv3p1_closure.F90
(called when iflag_clos=2) is kept for numerical
compatibility with earlier versions.

File size: 21.5 KB
Line 
1
2
3SUBROUTINE cv3p2_closure(nloc, ncum, nd, icb, inb, pbase, plcl, p, ph, tv, &
4    tvp, buoy, supmax, ok_inhib, ale, alp, omega,sig, w0, ptop2, cape, cin, m, &
5    iflag, coef, plim1, plim2, asupmax, supmax0, asupmaxmin, cbmflast, plfc, &
6    wbeff)
7
8
9  ! **************************************************************
10  ! *
11  ! CV3P2_CLOSURE                                               *
12  ! Ale & Alp Closure of Convect3              *
13  ! *
14  ! written by   :   Kerry Emanuel                              *
15  ! vectorization:   S. Bony                                    *
16  ! modified by :    Jean-Yves Grandpeix, 18/06/2003, 19.32.10  *
17  ! Julie Frohwirth,     14/10/2005  17.44.22  *
18  ! **************************************************************
19
20  USE print_control_mod, ONLY: prt_level, lunout
21  IMPLICIT NONE
22
23  include "cvthermo.h"
24  include "cv3param.h"
25  include "YOMCST2.h"
26  include "YOMCST.h"
27  include "conema3.h"
28
29  ! input:
30  INTEGER, INTENT (IN)                               :: ncum, nd, nloc
31  INTEGER, DIMENSION (nloc), INTENT (IN)             :: icb, inb
32  REAL, DIMENSION (nloc), INTENT (IN)                :: pbase, plcl
33  REAL, DIMENSION (nloc, nd), INTENT (IN)            :: p
34  REAL, DIMENSION (nloc, nd+1), INTENT (IN)          :: ph
35  REAL, DIMENSION (nloc, nd), INTENT (IN)            :: tv, tvp, buoy
36  REAL, DIMENSION (nloc, nd), INTENT (IN)            :: supmax
37  LOGICAL, INTENT (IN)                               :: ok_inhib ! enable convection inhibition by dryness
38  REAL, DIMENSION (nloc), INTENT (IN)                :: ale, alp
39  REAL, DIMENSION (nloc, nd), INTENT (IN)            :: omega
40
41  ! input/output:
42  REAL, DIMENSION (nloc, nd), INTENT (INOUT)         :: sig, w0
43  REAL, DIMENSION (nloc), INTENT (INOUT)             :: ptop2
44
45  ! output:
46  REAL, DIMENSION (nloc), INTENT (OUT)               :: cape, cin
47  REAL, DIMENSION (nloc, nd), INTENT (OUT)           :: m
48  REAL, DIMENSION (nloc), INTENT (OUT)               :: plim1, plim2
49  REAL, DIMENSION (nloc, nd), INTENT (OUT)           :: asupmax
50  REAL, DIMENSION (nloc), INTENT (OUT)               :: supmax0
51  REAL, DIMENSION (nloc), INTENT (OUT)               :: asupmaxmin
52  REAL, DIMENSION (nloc), INTENT (OUT)               :: cbmflast, plfc
53  REAL, DIMENSION (nloc), INTENT (OUT)               :: wbeff
54  INTEGER, DIMENSION (nloc), INTENT (OUT)            :: iflag
55
56  ! local variables:
57  INTEGER                                            :: il, i, j, k, icbmax
58  INTEGER, DIMENSION (nloc)                          :: i0, klfc
59  REAL                                               :: deltap, fac, w, amu
60  REAL, DIMENSION (nloc, nd)                         :: rhodp               ! Factor such that m=rhodp*sig*w
61  REAL                                               :: pbmxup
62  REAL, DIMENSION (nloc, nd)                         :: dtmin, sigold
63  REAL, DIMENSION (nloc, nd)                         :: coefmix
64  REAL, DIMENSION (nloc)                             :: pzero, ptop2old
65  REAL, DIMENSION (nloc)                             :: cina, cinb
66  INTEGER, DIMENSION (nloc)                          :: ibeg
67  INTEGER, DIMENSION (nloc)                          :: nsupmax
68  REAL                                               :: supcrit
69  REAL, DIMENSION (nloc, nd)                         :: temp
70  REAL, DIMENSION (nloc)                             :: p1, pmin
71  REAL, DIMENSION (nloc)                             :: asupmax0
72  LOGICAL, DIMENSION (nloc)                          :: ok
73  REAL, DIMENSION (nloc, nd)                         :: siglim, wlim, mlim
74  REAL, DIMENSION (nloc)                             :: wb2
75  REAL, DIMENSION (nloc)                             :: cbmf0        ! initial cloud base mass flux
76  REAL, DIMENSION (nloc)                             :: cbmflim      ! cbmf given by Cape closure
77  REAL, DIMENSION (nloc)                             :: cbmfalp      ! cbmf given by Alp closure
78  REAL, DIMENSION (nloc)                             :: cbmfalpb     ! bounded cbmf given by Alp closure
79  REAL, DIMENSION (nloc)                             :: cbmfmax      ! upper bound on cbmf
80  REAL, DIMENSION (nloc)                             :: coef
81  REAL, DIMENSION (nloc)                             :: xp, xq, xr, discr, b3, b4
82  REAL, DIMENSION (nloc)                             :: theta, bb
83  REAL                                               :: term1, term2, term3
84  REAL, DIMENSION (nloc)                             :: alp2                  ! Alp with offset
85
86  REAL                                               :: sigmax
87  PARAMETER (sigmax=0.1)
88!!  PARAMETER (sigmax=10.)
89
90  CHARACTER (LEN=20)                                 :: modname = 'cv3p2_closure'
91  CHARACTER (LEN=80)                                 :: abort_message
92
93  INTEGER,SAVE                                       :: igout=1
94!$OMP THREADPRIVATE(igout)
95
96 IF (prt_level>=20) print *,' -> cv3p2_closure, Ale ',ale(igout)
97
98
99  ! -------------------------------------------------------
100  ! -- Initialization
101  ! -------------------------------------------------------
102
103
104  DO il = 1, ncum
105    alp2(il) = max(alp(il), 1.E-5)
106    ! IM
107    alp2(il) = max(alp(il), 1.E-12)
108  END DO
109
110  pbmxup = 50. ! PBMXUP+PBCRIT = cloud depth above which mixed updraughts
111  ! exist (if any)
112
113  IF (prt_level>=20) PRINT *, 'cv3p2_closure nloc ncum nd icb inb nl', nloc, &
114    ncum, nd, icb(nloc), inb(nloc), nl
115  DO k = 1, nl
116    DO il = 1, ncum
117      m(il, k) = 0.0
118      rhodp(il,k) = 0.007*p(il, k)*(ph(il,k)-ph(il,k+1))/tv(il, k)
119    END DO
120  END DO
121
122  ! -------------------------------------------------------
123  ! -- Reset sig(i) and w0(i) for i>inb and i<icb
124  ! -------------------------------------------------------
125
126  ! update sig and w0 above LNB:
127
128  DO k = 1, nl - 1
129    DO il = 1, ncum
130      IF ((inb(il)<(nl-1)) .AND. (k>=(inb(il)+1))) THEN
131        sig(il, k) = beta*sig(il, k) + 2.*alpha*buoy(il, inb(il))*abs(buoy(il,inb(il)))
132        sig(il, k) = amax1(sig(il,k), 0.0)
133        w0(il, k) = beta*w0(il, k)
134      END IF
135    END DO
136  END DO
137
138  ! if(prt.level.GE.20) print*,'cv3p2_closure apres 100'
139  ! compute icbmax:
140
141  icbmax = 2
142  DO il = 1, ncum
143    icbmax = max(icbmax, icb(il))
144  END DO
145  ! if(prt.level.GE.20) print*,'cv3p2_closure apres 200'
146
147  ! update sig and w0 below cloud base:
148
149  DO k = 1, icbmax
150    DO il = 1, ncum
151      IF (k<=icb(il)) THEN
152        sig(il, k) = beta*sig(il, k) - 2.*alpha*buoy(il, icb(il))*buoy(il,icb(il))
153        sig(il, k) = amax1(sig(il,k), 0.0)
154        w0(il, k) = beta*w0(il, k)
155      END IF
156    END DO
157  END DO
158  IF (prt_level>=20) PRINT *, 'cv3p2_closure apres 300'
159
160  ! -------------------------------------------------------------
161  ! -- Reset fractional areas of updrafts and w0 at initial time
162  ! -- and after 10 time steps of no convection
163  ! -------------------------------------------------------------
164
165  DO k = 1, nl - 1
166    DO il = 1, ncum
167      IF (sig(il,nd)<1.5 .OR. sig(il,nd)>12.0) THEN
168        sig(il, k) = 0.0
169        w0(il, k) = 0.0
170      END IF
171    END DO
172  END DO
173  IF (prt_level>=20) PRINT *, 'cv3p2_closure apres 400'
174
175  ! -------------------------------------------------------
176  ! -- Compute initial cloud base mass flux (Cbmf0)
177  ! -------------------------------------------------------
178  DO il = 1, ncum
179    cbmf0(il) = 0.0
180  END DO
181
182  DO k = 1, nl
183    DO il = 1, ncum
184      IF (k>=icb(il) .AND. k<=inb(il) &
185          .AND. icb(il)+1<=inb(il)) THEN
186        cbmf0(il) = cbmf0(il) + sig(il, k)*w0(il,k)*rhodp(il,k)
187      END IF
188    END DO
189  END DO
190
191  ! -------------------------------------------------------------
192  ! jyg1
193  ! --  Calculate adiabatic ascent top pressure (ptop)
194  ! -------------------------------------------------------------
195
196
197  ! c 1. Start at first level where precipitations form
198  DO il = 1, ncum
199    pzero(il) = plcl(il) - pbcrit
200  END DO
201
202  ! c 2. Add offset
203  DO il = 1, ncum
204    pzero(il) = pzero(il) - pbmxup
205  END DO
206  DO il = 1, ncum
207    ptop2old(il) = ptop2(il)
208  END DO
209
210  DO il = 1, ncum
211    ! CR:c est quoi ce 300??
212    p1(il) = pzero(il) - 300.
213  END DO
214
215  ! compute asupmax=abs(supmax) up to lnm+1
216
217  DO il = 1, ncum
218    ok(il) = .TRUE.
219    nsupmax(il) = inb(il)
220  END DO
221
222  DO i = 1, nl
223    DO il = 1, ncum
224      IF (i>icb(il) .AND. i<=inb(il)) THEN
225        IF (p(il,i)<=pzero(il) .AND. supmax(il,i)<0 .AND. ok(il)) THEN
226          nsupmax(il) = i
227          ok(il) = .FALSE.
228        END IF ! end IF (P(i) ...  )
229      END IF ! end IF (icb+1 le i le inb)
230    END DO
231  END DO
232
233  IF (prt_level>=20) PRINT *, 'cv3p2_closure apres 2.'
234  DO i = 1, nl
235    DO il = 1, ncum
236      asupmax(il, i) = abs(supmax(il,i))
237    END DO
238  END DO
239
240
241  DO il = 1, ncum
242    asupmaxmin(il) = 10.
243    pmin(il) = 100.
244    ! IM ??
245    asupmax0(il) = 0.
246  END DO
247
248  ! c 3.  Compute in which level is Pzero
249
250  ! IM bug      i0 = 18
251  DO il = 1, ncum
252    i0(il) = nl
253  END DO
254
255  DO i = 1, nl
256    DO il = 1, ncum
257      IF (i>icb(il) .AND. i<=inb(il)) THEN
258        IF (p(il,i)<=pzero(il) .AND. p(il,i)>=p1(il)) THEN
259          IF (pzero(il)>p(il,i) .AND. pzero(il)<p(il,i-1)) THEN
260            i0(il) = i
261          END IF
262        END IF
263      END IF
264    END DO
265  END DO
266  IF (prt_level>=20) PRINT *, 'cv3p2_closure apres 3.'
267
268  ! c 4.  Compute asupmax at Pzero
269
270  DO i = 1, nl
271    DO il = 1, ncum
272      IF (i>icb(il) .AND. i<=inb(il)) THEN
273        IF (p(il,i)<=pzero(il) .AND. p(il,i)>=p1(il)) THEN
274          asupmax0(il) = ((pzero(il)-p(il,i0(il)-1))*asupmax(il,i0(il))- &
275            (pzero(il)-p(il,i0(il)))*asupmax(il,i0(il)-1))/(p(il,i0(il))-p(il,i0(il)-1))
276        END IF
277      END IF
278    END DO
279  END DO
280
281
282  DO i = 1, nl
283    DO il = 1, ncum
284      IF (p(il,i)==pzero(il)) THEN
285        asupmax(i, il) = asupmax0(il)
286      END IF
287    END DO
288  END DO
289  IF (prt_level>=20) PRINT *, 'cv3p2_closure apres 4.'
290
291  ! c 5. Compute asupmaxmin, minimum of asupmax
292
293  DO i = 1, nl
294    DO il = 1, ncum
295      IF (i>icb(il) .AND. i<=inb(il)) THEN
296        IF (p(il,i)<=pzero(il) .AND. p(il,i)>=p1(il)) THEN
297          IF (asupmax(il,i)<asupmaxmin(il)) THEN
298            asupmaxmin(il) = asupmax(il, i)
299            pmin(il) = p(il, i)
300          END IF
301        END IF
302      END IF
303    END DO
304  END DO
305
306  DO il = 1, ncum
307    ! IM
308    IF (prt_level>=20) THEN
309      PRINT *, 'cv3p2_closure il asupmax0 asupmaxmin', il, asupmax0(il), &
310        asupmaxmin(il), pzero(il), pmin(il)
311    END IF
312    IF (asupmax0(il)<asupmaxmin(il)) THEN
313      asupmaxmin(il) = asupmax0(il)
314      pmin(il) = pzero(il)
315    END IF
316  END DO
317  IF (prt_level>=20) PRINT *, 'cv3p2_closure apres 5.'
318
319
320  ! Compute Supmax at Pzero
321
322  DO i = 1, nl
323    DO il = 1, ncum
324      IF (i>icb(il) .AND. i<=inb(il)) THEN
325        IF (p(il,i)<=pzero(il)) THEN
326          supmax0(il) = ((p(il,i)-pzero(il))*asupmax(il,i-1)- &
327            (p(il,i-1)-pzero(il))*asupmax(il,i))/(p(il,i)-p(il,i-1))
328          GO TO 425
329        END IF ! end IF (P(i) ... )
330      END IF ! end IF (icb+1 le i le inb)
331    END DO
332  END DO
333
334425 CONTINUE
335  IF (prt_level>=20) PRINT *, 'cv3p2_closure apres 425.'
336
337  ! c 6. Calculate ptop2
338
339  DO il = 1, ncum
340    IF (asupmaxmin(il)<supcrit1) THEN
341      ptop2(il) = pmin(il)
342    END IF
343
344    IF (asupmaxmin(il)>supcrit1 .AND. asupmaxmin(il)<supcrit2) THEN
345      ptop2(il) = ptop2old(il)
346    END IF
347
348    IF (asupmaxmin(il)>supcrit2) THEN
349      ptop2(il) = ph(il, inb(il))
350    END IF
351  END DO
352
353  IF (prt_level>=20) PRINT *, 'cv3p2_closure apres 6.'
354
355  ! c 7. Compute multiplying factor for adiabatic updraught mass flux
356
357
358  IF (ok_inhib) THEN
359
360    DO i = 1, nl
361      DO il = 1, ncum
362        IF (i<=nl) THEN
363          coefmix(il, i) = (min(ptop2(il),ph(il,i))-ph(il,i))/(ph(il,i+1)-ph(il,i))
364          coefmix(il, i) = min(coefmix(il,i), 1.)
365        END IF
366      END DO
367    END DO
368
369
370  ELSE ! when inhibition is not taken into account, coefmix=1
371
372
373
374    DO i = 1, nl
375      DO il = 1, ncum
376        IF (i<=nl) THEN
377          coefmix(il, i) = 1.
378        END IF
379      END DO
380    END DO
381
382  END IF ! ok_inhib
383  IF (prt_level>=20) PRINT *, 'cv3p2_closure apres 7.'
384  ! -------------------------------------------------------------------
385  ! -------------------------------------------------------------------
386
387
388  ! jyg2
389
390  ! ==========================================================================
391
392
393  ! -------------------------------------------------------------
394  ! -- Calculate convective inhibition (CIN)
395  ! -------------------------------------------------------------
396
397  ! do i=1,nloc
398  ! print*,'avant cine p',pbase(i),plcl(i)
399  ! enddo
400  ! do j=1,nd
401  ! do i=1,nloc
402  ! print*,'avant cine t',tv(i),tvp(i)
403  ! enddo
404  ! enddo
405  CALL cv3_cine(nloc, ncum, nd, icb, inb, pbase, plcl, p, ph, tv, tvp, cina, &
406    cinb, plfc)
407
408  DO il = 1, ncum
409    cin(il) = cina(il) + cinb(il)
410  END DO
411  IF (prt_level>=20) PRINT *, 'cv3p2_closure after cv3_cine: cina, cinb, cin ', &
412                              cina(igout), cinb(igout), cin(igout)
413  ! -------------------------------------------------------------
414  ! --Update buoyancies to account for Ale
415  ! -------------------------------------------------------------
416
417  CALL cv3_buoy(nloc, ncum, nd, icb, inb, pbase, plcl, p, ph, ale, cin, tv, &
418    tvp, buoy)
419  IF (prt_level>=20) PRINT *, 'cv3p2_closure after cv3_buoy'
420
421  ! -------------------------------------------------------------
422  ! -- Calculate convective available potential energy (cape),
423  ! -- vertical velocity (w), fractional area covered by
424  ! -- undilute updraft (sig), and updraft mass flux (m)
425  ! -------------------------------------------------------------
426
427  DO il = 1, ncum
428    cape(il) = 0.0
429  END DO
430
431  ! compute dtmin (minimum buoyancy between ICB and given level k):
432
433  DO k = 1, nl
434    DO il = 1, ncum
435      dtmin(il, k) = 100.0
436    END DO
437  END DO
438
439  DO k = 1, nl
440    DO j = minorig, nl
441      DO il = 1, ncum
442        IF ((k>=(icb(il)+1)) .AND. (k<=inb(il)) .AND. (j>=icb(il)) &
443                             .AND. (j<=(k-1))) THEN
444          dtmin(il, k) = amin1(dtmin(il,k), buoy(il,j))
445        END IF
446      END DO
447    END DO
448  END DO
449!
450  IF (prt_level >= 20) THEN
451    print *,'cv3p2_closure: dtmin ', (k, dtmin(igout,k), k=1,nl)
452  ENDIF
453!
454  ! the interval on which cape is computed starts at pbase :
455
456  DO k = 1, nl
457    DO il = 1, ncum
458
459      IF ((k>=(icb(il)+1)) .AND. (k<=inb(il))) THEN
460
461        deltap = min(pbase(il), ph(il,k-1)) - min(pbase(il), ph(il,k))
462        cape(il) = cape(il) + rrd*buoy(il, k-1)*deltap/p(il, k-1)
463        cape(il) = amax1(0.0, cape(il))
464        sigold(il, k) = sig(il, k)
465
466
467        ! jyg       Coefficient coefmix limits convection to levels where a
468        ! sufficient
469        ! fraction of mixed draughts are ascending.
470        siglim(il, k) = coefmix(il, k)*alpha1*dtmin(il, k)*abs(dtmin(il,k))
471        siglim(il, k) = amax1(siglim(il,k), 0.0)
472        siglim(il, k) = amin1(siglim(il,k), 0.01)
473        ! c         fac=AMIN1(((dtcrit-dtmin(il,k))/dtcrit),1.0)
474        fac = 1.
475        wlim(il, k) = fac*sqrt(cape(il))
476        amu = siglim(il, k)*wlim(il, k)
477!!        rhodp(il,k) = 0.007*p(il, k)*(ph(il,k)-ph(il,k+1))/tv(il, k) !cor jyg : computed earlier
478        mlim(il, k) = amu*rhodp(il,k)
479        ! print*, 'siglim ', k,siglim(1,k)
480      END IF
481
482    END DO
483  END DO
484  IF (prt_level>=20) PRINT *, 'cv3p2_closure apres 600'
485
486  DO il = 1, ncum
487    ! IM beg
488    IF (prt_level>=20) THEN
489      PRINT *, 'cv3p2_closure il icb mlim ph ph+1 ph+2', il, icb(il), &
490        mlim(il, icb(il)+1), ph(il, icb(il)), ph(il, icb(il)+1), &
491        ph(il, icb(il)+2)
492    END IF
493
494    IF (icb(il)+1<=inb(il)) THEN
495      ! IM end
496      mlim(il, icb(il)) = 0.5*mlim(il,icb(il)+1)*(ph(il,icb(il))-ph(il,icb(il)+1))/ &
497                                               (ph(il,icb(il)+1)-ph(il,icb(il)+2))
498      ! IM beg
499    END IF !(icb(il.le.inb(il))) then
500    ! IM end
501  END DO
502  IF (prt_level>=20) PRINT *, 'cv3p2_closure apres 700'
503
504  !
505  ! ------------------------------------------------------------------------
506  ! c     Compute Cloud base mass flux given by Cape closure (cbmflim = cbmf of
507  ! c     elementary systems), cbmf given by Alp closure (cbmfalp), cbmf given by Alp
508  ! c     closure with an upper bound imposed (cbmfalpb) and cbmf resulting from
509  ! c     time integration (cbmflast).
510  ! ------------------------------------------------------------------------
511
512  DO il = 1, ncum
513    cbmflim(il) = 0.
514    cbmfalp(il) = 0.
515    cbmfalpb(il) = 0.
516    cbmflast(il) = 0.
517  END DO
518
519  ! c 1. Compute cloud base mass flux of elementary system (Cbmflim)
520
521  DO k = 1, nl
522    DO il = 1, ncum
523      ! old       IF (k .ge. icb(il) .and. k .le. inb(il)) THEN
524      ! IM        IF (k .ge. icb(il)+1 .and. k .le. inb(il)) THEN
525      IF (k>=icb(il) .AND. k<=inb(il) & !cor jyg
526          .AND. icb(il)+1<=inb(il)) THEN !cor jyg
527        cbmflim(il) = cbmflim(il) + mlim(il, k)
528      END IF
529    END DO
530  END DO
531  IF (prt_level>=20) PRINT *, 'cv3p2_closure after cbmflim: cbmflim ', cbmflim(igout)
532
533  ! 1.5 Compute cloud base mass flux given by Alp closure (Cbmfalp), maximum
534  !     allowed mass flux (Cbmfmax) and bounded mass flux (Cbmfalpb)
535  !     Cbmfalpb is set to zero if Cbmflim (the mass flux of elementary cloud)
536  !     is exceedingly small.
537
538  DO il = 1, ncum
539    wb2(il) = sqrt(2.*max(ale(il)+cin(il),0.))
540  END DO
541
542  DO il = 1, ncum
543    IF (plfc(il)<100.) THEN
544      ! This is an irealistic value for plfc => no calculation of wbeff
545      wbeff(il) = 100.1
546    ELSE
547      ! Calculate wbeff
548      IF (flag_wb==0) THEN
549        wbeff(il) = wbmax
550      ELSE IF (flag_wb==1) THEN
551        wbeff(il) = wbmax/(1.+500./(ph(il,1)-plfc(il)))
552      ELSE IF (flag_wb==2) THEN
553        wbeff(il) = wbmax*(0.01*(ph(il,1)-plfc(il)))**2
554      END IF
555    END IF
556  END DO
557
558!CR:Compute k at plfc
559  DO il=1,ncum
560           klfc(il)=nl
561  ENDDO
562  DO k=1,nl
563     DO il=1,ncum
564        if ((plfc(il).lt.ph(il,k)).and.(plfc(il).ge.ph(il,k+1))) then
565           klfc(il)=k
566        endif
567     ENDDO
568  ENDDO
569!RC
570
571  DO il = 1, ncum
572    ! jyg    Modification du coef de wb*wb pour conformite avec papier Wake
573    ! c       cbmfalp(il) = alp2(il)/(0.5*wb*wb-Cin(il))
574    cbmfalp(il) = alp2(il)/(2.*wbeff(il)*wbeff(il)-cin(il))
575!CR: Add large-scale component to the mass-flux
576!encore connu sous le nom "Experience du tube de dentifrice"
577    if ((coef_clos_ls.gt.0.).and.(plfc(il).gt.0.)) then
578       cbmfalp(il) = cbmfalp(il) - coef_clos_ls*min(0.,1./RG*omega(il,klfc(il)))
579    endif
580!RC
581    IF (cbmfalp(il)==0 .AND. alp2(il)/=0.) THEN
582      WRITE (lunout, *) 'cv3p2_closure cbmfalp=0 and alp NE 0 il alp2 alp cin ' , &
583                         il, alp2(il), alp(il), cin(il)
584      abort_message = ''
585      CALL abort_physic(modname, abort_message, 1)
586    END IF
587    cbmfmax(il) = sigmax*wb2(il)*100.*p(il, icb(il))/(rrd*tv(il,icb(il)))
588  END DO
589
590  DO il = 1, ncum
591    IF (cbmflim(il)>1.E-6) THEN
592      ! ATTENTION TEST CR
593      ! if (cbmfmax(il).lt.1.e-12) then
594      cbmfalpb(il) = min(cbmfalp(il), cbmfmax(il))
595      ! else
596      ! cbmfalpb(il) = cbmfalp(il)
597      ! endif
598      ! print*,'cbmfalpb',cbmfalp(il),cbmfmax(il)
599    END IF
600  END DO
601  IF (prt_level>=20) PRINT *, 'cv3p2_closure apres cbmfalpb: cbmfalpb ',cbmfalpb(igout)
602
603  ! c 2. Compute coefficient and apply correction
604
605  DO il = 1, ncum
606    coef(il) = (cbmfalpb(il)+1.E-10)/(cbmflim(il)+1.E-10)
607  END DO
608  IF (prt_level>=20) PRINT *, 'cv3p2_closure apres coef_plantePLUS'
609
610     DO k = 1, nl
611       DO il = 1, ncum
612         IF (k>=icb(il)+1 .AND. k<=inb(il)) THEN
613           amu = beta*sig(il, k)*w0(il, k) + (1.-beta)*coef(il)*siglim(il, k)*wlim(il, k)
614           w0(il, k) = wlim(il, k)
615           w0(il, k) = max(w0(il,k), 1.E-10)
616           sig(il, k) = amu/w0(il, k)
617           sig(il, k) = min(sig(il,k), 1.)
618           ! c         amu = 0.5*(SIG(il,k)+sigold(il,k))*W0(il,k)
619           !jyg m(il, k) = amu*0.007*p(il, k)*(ph(il,k)-ph(il,k+1))/tv(il, k)
620           m(il, k) = amu*rhodp(il,k)
621         END IF
622       END DO
623     END DO
624  ! jyg2
625  DO il = 1, ncum
626    w0(il, icb(il)) = 0.5*w0(il, icb(il)+1)
627    m(il, icb(il)) = 0.5*m(il, icb(il)+1)*(ph(il,icb(il))-ph(il,icb(il)+1))/ &
628                                         (ph(il,icb(il)+1)-ph(il,icb(il)+2))
629    sig(il, icb(il)) = sig(il, icb(il)+1)
630    sig(il, icb(il)-1) = sig(il, icb(il))
631  END DO
632  IF (prt_level>=20) PRINT *, 'cv3p2_closure apres w0_sig_M: w0, sig ', &
633                         (k,w0(igout,k),sig(igout,k), k=icb(igout),inb(igout))
634
635  ! c 3. Compute final cloud base mass flux;
636  ! c    set iflag to 3 if cloud base mass flux is exceedingly small and is
637  ! c     decreasing (i.e. if the final mass flux (cbmflast) is greater than
638  ! c     the target mass flux (cbmfalpb)).
639
640!jyg  DO il = 1, ncum
641!jyg    cbmflast(il) = 0.
642!jyg  END DO
643
644  DO k = 1, nl
645    DO il = 1, ncum
646      IF (k>=icb(il) .AND. k<=inb(il)) THEN
647          !IMpropo??      IF ((k.ge.(icb(il)+1)).and.(k.le.inb(il))) THEN
648        cbmflast(il) = cbmflast(il) + m(il, k)
649      END IF
650    END DO
651  END DO
652  IF (prt_level>=20) PRINT *, 'cv3p2_closure apres cbmflast: cbmflast ',cbmflast(igout)
653
654  DO il = 1, ncum
655    IF (cbmflast(il)<1.E-6 .AND. cbmflast(il)>=cbmfalpb(il)) THEN
656      iflag(il) = 3
657    END IF
658  END DO
659
660  DO k = 1, nl
661    DO il = 1, ncum
662      IF (iflag(il)>=3) THEN
663        m(il, k) = 0.
664        sig(il, k) = 0.
665        w0(il, k) = 0.
666      END IF
667    END DO
668  END DO
669!
670  IF (prt_level >= 10) THEN
671   print *,'cv3p2_closure: iflag ',iflag(igout)
672  ENDIF
673!
674
675  ! c 4. Introduce a correcting factor for coef, in order to obtain an
676  ! effective
677  ! c    sigdz larger in the present case (using cv3p2_closure) than in the
678  ! old
679  ! c    closure (using cv3_closure).
680  IF (1==0) THEN
681    DO il = 1, ncum
682      ! c      coef(il) = 2.*coef(il)
683      coef(il) = 5.*coef(il)
684    END DO
685    ! version CVS du ..2008
686  ELSE
687    IF (iflag_cvl_sigd==0) THEN
688      ! test pour verifier qu on fait la meme chose qu avant: sid constant
689      coef(1:ncum) = 1.
690    ELSE
691      coef(1:ncum) = min(2.*coef(1:ncum), 5.)
692      coef(1:ncum) = max(2.*coef(1:ncum), 0.2)
693    END IF
694  END IF
695
696  IF (prt_level>=20) PRINT *, 'cv3p2_closure FIN'
697  RETURN
698END SUBROUTINE cv3p2_closure
699
700
Note: See TracBrowser for help on using the repository browser.