source: LMDZ6/branches/cirrus/libf/phylmdiso/cv3_estatmix.F90 @ 5326

Last change on this file since 5326 was 4143, checked in by dcugnet, 3 years ago
  • Some variables are renamed or replaced by direct equivalents:
    • iso_indnum -> tracers(:)%iso_iName
    • niso_possibles -> niso
    • iqiso -> iqIsoPha ; index_trac -> itZonIso
    • ok_iso_verif -> isoCheck
    • ntraceurs_zone -> nzone ; ntraciso -> ntiso
    • qperemin -> min_qparent ; masseqmin -> min_qmass ; ratiomin -> min_ratio
  • Some renamed variables are only aliased with the older name (using USE <module>, ONLY: <oldName> => <newName>) in routines where they are repeated many times.
  • Few hard-coded indexes are now computed (examples: ilic, iso, ivap, irneb, iq_vap, iq_liq, iso_H2O, iso_HDO, iso_HTO, iso_O17, iso_O18).
  • The IF(isoCheck) test is now embedded in the check_isotopes_seq and check_isotopes_loc routines (lighter calling).
  • Property svn:keywords set to Id
File size: 6.6 KB
Line 
1SUBROUTINE cv3_estatmix(len, nd, iflag, plim1, plim2, p, ph, &
2                       t, q, u, v, h, gz, w, &
3                       wi, nk, tmix, thmix, qmix, qsmix, umix, vmix, plcl &
4#ifdef ISO
5     &                 ,xt,xtmix &
6#endif
7                       )
8#ifdef ISO
9    use infotrac_phy, ONLY: ntiso
10#endif
11  ! **************************************************************
12  ! *
13  ! CV3_ESTATMIX  Determine the properties of an adiabatic updraft  *
14  !                made of air coming from several layers by        *
15  !                mixing static energy                             *
16  !                                                                 *
17  ! written by   : Grandpeix Jean-Yves, 28/12/2001, 13.14.24        *
18  ! modified by :  Filiberti M-A 06/2005 vectorisation              *
19  ! ****************************************************************
20
21  IMPLICIT NONE
22  ! ==============================================================
23
24  ! estatmix : determines theta, t, q, qs, u and v of the lifted mixture
25  ! made of air between plim1 and plim2 with weighting w.
26  ! If plim1 and plim2 fall within the same model layer, then theta, ... v
27  ! are those of that layer.
28  ! A minimum value (dpmin) is imposed upon plim1-plim2
29
30  ! ===============================================================
31
32  include "cvthermo.h"
33  include "YOETHF.h"
34  include "YOMCST.h"
35  include "FCTTRE.h"
36!inputs:
37  INTEGER, INTENT (IN)                      :: nd, len
38  INTEGER, DIMENSION (len), INTENT (IN)     :: nk
39  REAL, DIMENSION (len), INTENT (IN)        :: plim1, plim2
40  REAL, DIMENSION (len,nd), INTENT (IN)     :: t, q
41  REAL, DIMENSION (len,nd), INTENT (IN)     :: u, v
42  REAL, DIMENSION (len,nd), INTENT (IN)     :: h ! static energy of the layers
43  REAL, DIMENSION (len,nd), INTENT (IN)     :: gz
44  REAL, DIMENSION (nd), INTENT (IN)         :: w
45  REAL, DIMENSION (len,nd), INTENT (IN)     :: p
46  REAL, DIMENSION (len,nd+1), INTENT (IN)   :: ph
47#ifdef ISO
48  REAL, DIMENSION (ntiso,len,nd), INTENT (IN)     :: xt
49#endif
50!input/output:
51  INTEGER, DIMENSION (len), INTENT (INOUT)  ::  iflag
52!outputs:
53  REAL, DIMENSION (len), INTENT (OUT)       :: tmix, thmix, qmix
54  REAL, DIMENSION (len), INTENT (OUT)       :: umix, vmix
55  REAL, DIMENSION (len), INTENT (OUT)       :: qsmix
56  REAL, DIMENSION (len), INTENT (OUT)       :: plcl
57  REAL, DIMENSION (len,nd), INTENT (OUT)    :: wi
58#ifdef ISO
59  REAL, DIMENSION (ntiso,len), INTENT (OUT)     :: xtmix
60#endif
61!internal variables :
62  INTEGER i, j
63  INTEGER niflag7
64  INTEGER, DIMENSION(len)                   :: j1, j2
65  REAL                                      :: a, b
66  REAL                                      :: cpn
67  REAL                                      :: x, y, p0, zdelta, zcor
68  REAL, SAVE                                :: dpmin=1.
69!$OMP THREADPRIVATE(dpmin)
70  REAL, DIMENSION(len)                      :: plim2p  ! = min(plim2(:),plim1(:)-dpmin)
71  REAL, DIMENSION(len)                      :: dpw, coef
72  REAL, DIMENSION(len)                      :: hmix ! static energy of the updraft
73  REAL, DIMENSION(len)                      :: rdcp, pnk
74  REAL, DIMENSION(len)                      :: rh, chi
75  REAL, DIMENSION(len)                      :: eqwght
76  REAL, DIMENSION(len,nd)                   :: p1, p2
77#ifdef ISO
78  INTEGER ixt
79#endif
80
81
82!!  print *,' ->cv3_vertmix, plim1,plim2 ', plim1,plim2   !jyg
83  plim2p(:) = min(plim2(:),plim1(:)-dpmin)
84  j1(:)=nd
85  j2(:) = 0
86  DO j = 1, nd
87    DO i = 1, len
88      IF (plim1(i)<=ph(i,j)) j1(i) = j
89!!!      IF (plim2p(i)>=ph(i,j+1) .AND. plim2p(i)<ph(i,j)) j2(i) = j
90      IF (plim2p(i)< ph(i,j)) j2(i) = j
91    END DO
92  END DO
93
94  DO j = 1, nd
95    DO i = 1, len
96      wi(i, j) = 0.
97    END DO
98  END DO
99  DO i = 1, len
100    hmix(i) = 0.
101    qmix(i) = 0.
102    umix(i) = 0.
103    vmix(i) = 0.
104    dpw(i) = 0.
105    pnk(i) = p(i, nk(i))
106#ifdef ISO
107    xtmix(:,i) = 0.
108#endif
109  END DO
110  eqwght(:) = 0.
111
112  p0 = 1000.
113
114  DO i = 1, len
115    IF (j2(i) < j1(i)) THEN
116      coef(i) = 1.
117      eqwght(i) = 1.
118    ELSE
119      coef(i) = 1./(plim1(i)-plim2p(i))
120    ENDIF
121  END DO
122
123!!  print *,'cv3_vertmix, j1,j2,coef ', j1,j2,coef  !jyg
124
125  DO j = 1, nd
126    DO i = 1, len
127      IF (j>=j1(i) .AND. j<=j2(i)) THEN
128        p1(i, j) = min(ph(i,j), plim1(i))
129        p2(i, j) = max(ph(i,j+1), plim2p(i))
130        ! CRtest:couplage thermiques: deja normalise
131        ! wi(i,j) = w(j)
132        ! print*,'wi',wi(i,j)
133        wi(i, j) = w(j)*(p1(i,j)-p2(i,j))*coef(i)+eqwght(i)
134        dpw(i) = dpw(i) + wi(i, j)
135
136!!  print *,'cv3_vertmix, j, wi(1,j),dpw ', j, wi(1,j),dpw  !jyg
137
138      END IF
139    END DO
140  END DO
141
142  ! CR:print
143  ! do i=1,len
144  ! print*,'plim',plim1(i),plim2p(i)
145  ! enddo
146  DO j = 1, nd
147    DO i = 1, len
148      IF (j>=j1(i) .AND. j<=j2(i)) THEN
149        wi(i, j) = wi(i, j)/dpw(i)
150        hmix(i) = hmix(i) + h(i, j)*wi(i, j)
151        qmix(i) = qmix(i) +  q(i, j)*wi(i, j)
152        umix(i) = umix(i) +  u(i, j)*wi(i, j)
153        vmix(i) = vmix(i) +  v(i, j)*wi(i, j)
154#ifdef ISO
155        do ixt=1,ntiso
156          xtmix(ixt,i) = xtmix(ixt,i) +  xt(ixt,i, j)*wi(i, j)
157        enddo
158#endif
159      END IF
160    END DO
161  END DO
162
163  DO i = 1, len
164    rdcp(i) = (rrd*(1.-qmix(i))+qmix(i)*rrv)/(cpd*(1.-qmix(i))+qmix(i)*cpv)
165  END DO
166
167
168!!  print *,'cv3_vertmix, rdcp ', rdcp  !jyg
169
170  DO i = 1, len
171    tmix(i) = (hmix(i) - gz(i,1))/(cpd*(1.-qmix(i)) + qmix(i)*cpv)
172    !      (Use of Cpv since we are dealing with dry static energy)
173    thmix(i) = tmix(i)*(p0/pnk(i))**rdcp(i)
174    ! print*,'tmix thmix hmix ',tmix(i),thmix(i),hmix(i)
175    zdelta = max(0., sign(1.,rtt-tmix(i)))
176    qsmix(i) = r2es*foeew(tmix(i), zdelta)/(pnk(i)*100.)
177    qsmix(i) = min(0.5, qsmix(i))
178    zcor = 1./(1.-retv*qsmix(i))
179    qsmix(i) = qsmix(i)*zcor
180  END DO
181
182  ! -------------------------------------------------------------------
183  ! --- Calculate lifted condensation level of air at parcel origin level
184  ! --- (Within 0.2% of formula of Bolton, MON. WEA. REV.,1980)
185  ! -------------------------------------------------------------------
186
187  a = 1669.0 ! convect3
188  b = 122.0 ! convect3
189
190
191  niflag7 = 0
192  DO i = 1, len
193
194    IF (iflag(i)/=7) THEN ! modif sb Jun7th 2002
195
196      rh(i) = qmix(i)/qsmix(i)
197      chi(i) = tmix(i)/(a-b*rh(i)-tmix(i)) ! convect3
198      ! ATTENTION, la LIGNE DESSOUS A ETE RAJOUTEE ARBITRAIREMENT ET
199      ! MASQUE UN PB POTENTIEL
200      chi(i) = max(chi(i), 0.)
201      rh(i) = max(rh(i), 0.)
202      plcl(i) = pnk(i)*(rh(i)**chi(i))
203      IF (((plcl(i)<200.0) .OR. (plcl(i)>=2000.0)) .AND. (iflag(i)==0)) &
204          iflag(i) = 8
205
206    ELSE
207
208      niflag7 = niflag7 + 1
209      plcl(i) = plim2p(i)
210
211    END IF ! iflag=7
212
213    ! print*,'NIFLAG7  =',niflag7
214
215  END DO
216
217!!  print *,' cv3_vertmix->'  !jyg
218
219
220  RETURN
221END SUBROUTINE cv3_estatmix
222
Note: See TracBrowser for help on using the repository browser.