source: LMDZ5/branches/testing/libf/phylmd/cv3_vertmix.F90 @ 2275

Last change on this file since 2275 was 2056, checked in by Laurent Fairhead, 10 years ago

Merged trunk changes r1997:2055 into testing branch

  • 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: 6.3 KB
RevLine 
[2056]1SUBROUTINE cv3_vertmix(len, nd, iflag, plim1, plim2, p, ph, &
2                       t, q, u, v, w, &
3                       wi, nk, tmix, thmix, qmix, qsmix, umix, vmix, plcl)
[1992]4  ! **************************************************************
5  ! *
6  ! CV3_VERTMIX   Brassage adiabatique d'une couche d'epaisseur *
7  ! arbitraire.                                   *
8  ! *
9  ! written by   : Grandpeix Jean-Yves, 28/12/2001, 13.14.24    *
10  ! modified by :  Filiberti M-A 06/2005 vectorisation          *
11  ! **************************************************************
[879]12
[1992]13  IMPLICIT NONE
14  ! ==============================================================
[879]15
[2056]16  ! vertmix : determines theta, t, q, qs, u and v of the mixture generated by
17  ! adiabatic mixing of air between plim1 and plim2 with weighting w.
18  ! If plim1 and plim2 fall within the same model layer, then theta, ... v
19  ! are those of that layer.
20  ! A minimum value (dpmin) is imposed upon plim1-plim2
[879]21
[1992]22  ! ===============================================================
[879]23
[1992]24  include "cvthermo.h"
25  include "YOETHF.h"
26  include "YOMCST.h"
27  include "FCTTRE.h"
[2056]28!inputs:
29  INTEGER, INTENT (IN)                      ::  nd, len
30  INTEGER, DIMENSION (len), INTENT (IN)     ::  nk
31  REAL, DIMENSION (nd), INTENT (IN)        ::  w
32  REAL, DIMENSION (len), INTENT (IN)        :: plim1, plim2
33  REAL, DIMENSION (len,nd), INTENT (IN)     :: t, q
34  REAL, DIMENSION (len,nd), INTENT (IN)     :: u, v
35  REAL, DIMENSION (len,nd), INTENT (IN)     :: p
36  REAL, DIMENSION (len,nd+1), INTENT (IN)   :: ph
37!input/output:
38  INTEGER, DIMENSION (len), INTENT (INOUT)  ::  iflag
39!outputs:
40  REAL, DIMENSION (len), INTENT (OUT)       :: tmix, thmix, qmix
41  REAL, DIMENSION (len), INTENT (OUT)       :: umix, vmix
42  REAL, DIMENSION (len), INTENT (OUT)       :: qsmix
43  REAL, DIMENSION (len), INTENT (OUT)       :: plcl
44  REAL, DIMENSION (len,nd), INTENT (OUT)    :: wi
45!internal variables :
[1992]46  INTEGER i, j
[2056]47  INTEGER niflag7
48  INTEGER, DIMENSION(len)                   :: j1, j2
49  REAL                                      :: a, b
50  REAL                                      :: cpn
51  REAL                                      :: x, y, p0, p0m1, zdelta, zcor
52  REAL                                      :: dpmin=1.
53!$OMP THREADPRIVATE(dpmin)
54  REAL, DIMENSION(len)                      :: plim2p  ! = min(plim2(:),plim1(:)-dpmin)
55  REAL, DIMENSION(len)                      :: ahm, dpw, coef
56  REAL, DIMENSION(len)                      :: rdcp, a2, b2, pnk
57  REAL, DIMENSION(len)                      :: rh, chi
58  REAL, DIMENSION(len)                      :: eqwght
59  REAL, DIMENSION(len,nd)                   :: p1, p2
[879]60
[2056]61
62!!  print *,' ->cv3_vertmix, plim1,plim2 ', plim1,plim2   !jyg
63  plim2p(:) = min(plim2(:),plim1(:)-dpmin)
64  j1(:)=nd
65  j2(:) = 0
[1992]66  DO j = 1, nd
67    DO i = 1, len
68      IF (plim1(i)<=ph(i,j)) j1(i) = j
[2056]69!!!      IF (plim2p(i)>=ph(i,j+1) .AND. plim2p(i)<ph(i,j)) j2(i) = j
70      IF (plim2p(i)< ph(i,j)) j2(i) = j
[1992]71    END DO
72  END DO
[879]73
[1992]74  DO j = 1, nd
75    DO i = 1, len
76      wi(i, j) = 0.
77    END DO
78  END DO
79  DO i = 1, len
80    ahm(i) = 0.
81    qmix(i) = 0.
82    umix(i) = 0.
83    vmix(i) = 0.
84    dpw(i) = 0.
85    a2(i) = 0.0
86    b2(i) = 0.
87    pnk(i) = p(i, nk(i))
88  END DO
[2056]89  eqwght(:) = 0.
[879]90
[1992]91  p0 = 1000.
92  p0m1 = 1./p0
[879]93
[1992]94  DO i = 1, len
[2056]95    IF (j2(i) < j1(i)) THEN
96      coef(i) = 1.
97      eqwght(i) = 1.
98    ELSE
99      coef(i) = 1./(plim1(i)-plim2p(i))
100    ENDIF
[1992]101  END DO
[879]102
[2056]103!!  print *,'cv3_vertmix, j1,j2,coef ', j1,j2,coef  !jyg
104
[1992]105  DO j = 1, nd
106    DO i = 1, len
107      IF (j>=j1(i) .AND. j<=j2(i)) THEN
108        p1(i, j) = min(ph(i,j), plim1(i))
[2056]109        p2(i, j) = max(ph(i,j+1), plim2p(i))
[1992]110        ! CRtest:couplage thermiques: deja normalise
111        ! wi(i,j) = w(j)
112        ! print*,'wi',wi(i,j)
[2056]113        wi(i, j) = w(j)*(p1(i,j)-p2(i,j))*coef(i)+eqwght(i)
[1992]114        dpw(i) = dpw(i) + wi(i, j)
[2056]115
116!!  print *,'cv3_vertmix, j, wi(1,j),dpw ', j, wi(1,j),dpw  !jyg
117
[1992]118      END IF
119    END DO
120  END DO
[2056]121
[1992]122  ! CR:print
123  ! do i=1,len
[2056]124  ! print*,'plim',plim1(i),plim2p(i)
[1992]125  ! enddo
126  DO j = 1, nd
127    DO i = 1, len
128      IF (j>=j1(i) .AND. j<=j2(i)) THEN
129        wi(i, j) = wi(i, j)/dpw(i)
130        ahm(i) = ahm(i) + (cpd*(1.-q(i,j))+q(i,j)*cpv)*t(i, j)*wi(i, j)
131        qmix(i) = qmix(i) + q(i, j)*wi(i, j)
132        umix(i) = umix(i) + u(i, j)*wi(i, j)
133        vmix(i) = vmix(i) + v(i, j)*wi(i, j)
134      END IF
135    END DO
136  END DO
[879]137
[1992]138  DO i = 1, len
139    rdcp(i) = (rrd*(1.-qmix(i))+qmix(i)*rrv)/(cpd*(1.-qmix(i))+qmix(i)*cpv)
140  END DO
[879]141
142
[2056]143!!  print *,'cv3_vertmix, rdcp ', rdcp  !jyg
[879]144
[2056]145
146
[1992]147  DO j = 1, nd
148    DO i = 1, len
149      IF (j>=j1(i) .AND. j<=j2(i)) THEN
150        ! c            x=(.5*(p1(i,j)+p2(i,j))*p0m1)**rdcp(i)
151        y = (.5*(p1(i,j)+p2(i,j))/pnk(i))**rdcp(i)
152        ! c            a2(i)=a2(i)+(cpd*(1.-qmix(i))+qmix(i)*cpv)*x*wi(i,j)
153        b2(i) = b2(i) + (cpd*(1.-qmix(i))+qmix(i)*cpv)*y*wi(i, j)
154      END IF
155    END DO
156  END DO
157
158  DO i = 1, len
159    tmix(i) = ahm(i)/b2(i)
160    thmix(i) = tmix(i)*(p0/pnk(i))**rdcp(i)
161    ! print*,'thmix ahm',ahm(i),b2(i)
162    ! print*,'thmix t',tmix(i),p0
163    ! print*,'thmix p',pnk(i),rdcp(i)
164    ! print*,'thmix',thmix(i)
165    ! c         thmix(i) = ahm(i)/a2(i)
166    ! c         tmix(i)= thmix(i)*(pnk(i)*p0m1)**rdcp(i)
167    zdelta = max(0., sign(1.,rtt-tmix(i)))
168    qsmix(i) = r2es*foeew(tmix(i), zdelta)/(pnk(i)*100.)
169    qsmix(i) = min(0.5, qsmix(i))
170    zcor = 1./(1.-retv*qsmix(i))
171    qsmix(i) = qsmix(i)*zcor
172  END DO
173
174  ! -------------------------------------------------------------------
175  ! --- Calculate lifted condensation level of air at parcel origin level
176  ! --- (Within 0.2% of formula of Bolton, MON. WEA. REV.,1980)
177  ! -------------------------------------------------------------------
178
179  a = 1669.0 ! convect3
180  b = 122.0 ! convect3
181
182
183  niflag7 = 0
184  DO i = 1, len
185
186    IF (iflag(i)/=7) THEN ! modif sb Jun7th 2002
187
188      rh(i) = qmix(i)/qsmix(i)
189      chi(i) = tmix(i)/(a-b*rh(i)-tmix(i)) ! convect3
190      ! ATTENTION, la LIGNE DESSOUS A ETE RAJOUTEE ARBITRAIREMENT ET
191      ! MASQUE UN PB POTENTIEL
192      chi(i) = max(chi(i), 0.)
193      rh(i) = max(rh(i), 0.)
194      plcl(i) = pnk(i)*(rh(i)**chi(i))
[2056]195      IF (((plcl(i)<200.0) .OR. (plcl(i)>=2000.0)) .AND. (iflag(i)==0)) &
196          iflag(i) = 8
[1992]197
198    ELSE
199
200      niflag7 = niflag7 + 1
[2056]201      plcl(i) = plim2p(i)
[1992]202
203    END IF ! iflag=7
204
205    ! print*,'NIFLAG7  =',niflag7
206
207  END DO
208
[2056]209!!  print *,' cv3_vertmix->'  !jyg
210
211
[1992]212  RETURN
213END SUBROUTINE cv3_vertmix
214
Note: See TracBrowser for help on using the repository browser.