/[lmdze]/trunk/Sources/phylmd/cv_driver.f
ViewVC logotype

Diff of /trunk/Sources/phylmd/cv_driver.f

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

trunk/libf/phylmd/cv_driver.f revision 14 by guez, Mon Jul 28 14:48:09 2008 UTC trunk/phylmd/cv_driver.f revision 91 by guez, Wed Mar 26 17:18:58 2014 UTC
# Line 1  Line 1 
1  !  module cv_driver_m
 ! $Header: /home/cvsroot/LMDZ4/libf/phylmd/cv_driver.F,v 1.3 2005/04/15 12:36:17 lmdzadmin Exp $  
 !  
       SUBROUTINE cv_driver(len,nd,ndp1,ntra,iflag_con,  
      &                   t1,q1,qs1,u1,v1,tra1,  
      &                   p1,ph1,iflag1,ft1,fq1,fu1,fv1,ftra1,  
      &                   precip1,VPrecip1,  
      &                   cbmf1,sig1,w01,  
      &                   icb1,inb1,  
      &                   delt,Ma1,upwd1,dnwd1,dnwd01,qcondc1,wd1,cape1,  
      &                   da1,phi1,mp1)  
 C  
       use dimens_m  
       use dimphy  
       implicit none  
 C  
 C.............................START PROLOGUE............................  
 C  
 C PARAMETERS:  
 C      Name            Type         Usage            Description  
 C   ----------      ----------     -------  ----------------------------  
 C  
 C      len           Integer        Input        first (i) dimension  
 C      nd            Integer        Input        vertical (k) dimension  
 C      ndp1          Integer        Input        nd + 1  
 C      ntra          Integer        Input        number of tracors  
 C      iflag_con     Integer        Input        version of convect (3/4)  
 C      t1            Real           Input        temperature  
 C      q1            Real           Input        specific hum  
 C      qs1           Real           Input        sat specific hum  
 C      u1            Real           Input        u-wind  
 C      v1            Real           Input        v-wind  
 C      tra1          Real           Input        tracors  
 C      p1            Real           Input        full level pressure  
 C      ph1           Real           Input        half level pressure  
 C      iflag1        Integer        Output       flag for Emanuel conditions  
 C      ft1           Real           Output       temp tend  
 C      fq1           Real           Output       spec hum tend  
 C      fu1           Real           Output       u-wind tend  
 C      fv1           Real           Output       v-wind tend  
 C      ftra1         Real           Output       tracor tend  
 C      precip1       Real           Output       precipitation  
 C      VPrecip1      Real           Output       vertical profile of precipitations  
 C      cbmf1         Real           Output       cloud base mass flux  
 C      sig1          Real           In/Out       section adiabatic updraft  
 C      w01           Real           In/Out       vertical velocity within adiab updraft  
 C      delt          Real           Input        time step  
 C      Ma1           Real           Output       mass flux adiabatic updraft  
 C      upwd1         Real           Output       total upward mass flux (adiab+mixed)  
 C      dnwd1         Real           Output       saturated downward mass flux (mixed)  
 C      dnwd01        Real           Output       unsaturated downward mass flux  
 C      qcondc1       Real           Output       in-cld mixing ratio of condensed water  
 C      wd1           Real           Output       downdraft velocity scale for sfc fluxes  
 C      cape1         Real           Output       CAPE  
 C  
 C S. Bony, Mar 2002:  
 C       * Several modules corresponding to different physical processes  
 C       * Several versions of convect may be used:  
 C               - iflag_con=3: version lmd  (previously named convect3)  
 C               - iflag_con=4: version 4.3b (vect. version, previously convect1/2)  
 C   + tard:     - iflag_con=5: version lmd with ice (previously named convectg)  
 C S. Bony, Oct 2002:  
 C       * Vectorization of convect3 (ie version lmd)  
 C  
 C..............................END PROLOGUE.............................  
 c  
 c  
   
       integer len  
       integer nd  
       integer ndp1  
       integer noff  
       integer, intent(in):: iflag_con  
       integer ntra  
       real t1(len,nd)  
       real q1(len,nd)  
       real qs1(len,nd)  
       real u1(len,nd)  
       real v1(len,nd)  
       real p1(len,nd)  
       real ph1(len,ndp1)  
       integer iflag1(len)  
       real ft1(len,nd)  
       real fq1(len,nd)  
       real fu1(len,nd)  
       real fv1(len,nd)  
       real precip1(len)  
       real cbmf1(len)  
       real VPrecip1(len,nd+1)  
       real Ma1(len,nd)  
       real upwd1(len,nd)  
       real dnwd1(len,nd)  
       real dnwd01(len,nd)  
   
       real qcondc1(len,nd)     ! cld  
       real wd1(len)            ! gust  
       real cape1(len)      
   
       real da1(len,nd),phi1(len,nd,nd),mp1(len,nd)  
       real da(len,nd),phi(len,nd,nd),mp(len,nd)  
       real, intent(in):: tra1(len,nd,ntra)  
       real ftra1(len,nd,ntra)  
   
       real, intent(in):: delt  
   
 !-------------------------------------------------------------------  
 ! --- ARGUMENTS  
 !-------------------------------------------------------------------  
 ! --- On input:  
 !  
 !  t:   Array of absolute temperature (K) of dimension ND, with first  
 !       index corresponding to lowest model level. Note that this array  
 !       will be altered by the subroutine if dry convective adjustment  
 !       occurs and if IPBL is not equal to 0.  
 !  
 !  q:   Array of specific humidity (gm/gm) of dimension ND, with first  
 !       index corresponding to lowest model level. Must be defined  
 !       at same grid levels as T. Note that this array will be altered  
 !       if dry convective adjustment occurs and if IPBL is not equal to 0.  
 !  
 !  qs:  Array of saturation specific humidity of dimension ND, with first  
 !       index corresponding to lowest model level. Must be defined  
 !       at same grid levels as T. Note that this array will be altered  
 !       if dry convective adjustment occurs and if IPBL is not equal to 0.  
 !  
 !  u:   Array of zonal wind velocity (m/s) of dimension ND, witth first  
 !       index corresponding with the lowest model level. Defined at  
 !       same levels as T. Note that this array will be altered if  
 !       dry convective adjustment occurs and if IPBL is not equal to 0.  
 !  
 !  v:   Same as u but for meridional velocity.  
 !  
 !  tra: Array of passive tracer mixing ratio, of dimensions (ND,NTRA),  
 !       where NTRA is the number of different tracers. If no  
 !       convective tracer transport is needed, define a dummy  
 !       input array of dimension (ND,1). Tracers are defined at  
 !       same vertical levels as T. Note that this array will be altered  
 !       if dry convective adjustment occurs and if IPBL is not equal to 0.  
 !  
 !  p:   Array of pressure (mb) of dimension ND, with first  
 !       index corresponding to lowest model level. Must be defined  
 !       at same grid levels as T.  
 !  
 !  ph:  Array of pressure (mb) of dimension ND+1, with first index  
 !       corresponding to lowest level. These pressures are defined at  
 !       levels intermediate between those of P, T, Q and QS. The first  
 !       value of PH should be greater than (i.e. at a lower level than)  
 !       the first value of the array P.  
 !  
 !  nl:  The maximum number of levels to which convection can penetrate, plus 1.  
 !       NL MUST be less than or equal to ND-1.  
 !  
 !  delt: The model time step (sec) between calls to CONVECT  
 !  
 !----------------------------------------------------------------------------  
 ! ---   On Output:  
 !  
 !  iflag: An output integer whose value denotes the following:  
 !       VALUE   INTERPRETATION  
 !       -----   --------------  
 !         0     Moist convection occurs.  
 !         1     Moist convection occurs, but a CFL condition  
 !               on the subsidence warming is violated. This  
 !               does not cause the scheme to terminate.  
 !         2     Moist convection, but no precip because ep(inb) lt 0.0001  
 !         3     No moist convection because new cbmf is 0 and old cbmf is 0.  
 !         4     No moist convection; atmosphere is not  
 !               unstable  
 !         6     No moist convection because ihmin le minorig.  
 !         7     No moist convection because unreasonable  
 !               parcel level temperature or specific humidity.  
 !         8     No moist convection: lifted condensation  
 !               level is above the 200 mb level.  
 !         9     No moist convection: cloud base is higher  
 !               then the level NL-1.  
 !  
 !  ft:   Array of temperature tendency (K/s) of dimension ND, defined at same  
 !        grid levels as T, Q, QS and P.  
 !  
 !  fq:   Array of specific humidity tendencies ((gm/gm)/s) of dimension ND,  
 !        defined at same grid levels as T, Q, QS and P.  
 !  
 !  fu:   Array of forcing of zonal velocity (m/s^2) of dimension ND,  
 !        defined at same grid levels as T.  
 !  
 !  fv:   Same as FU, but for forcing of meridional velocity.  
 !  
 !  ftra: Array of forcing of tracer content, in tracer mixing ratio per  
 !        second, defined at same levels as T. Dimensioned (ND,NTRA).  
 !  
 !  precip: Scalar convective precipitation rate (mm/day).  
 !  
 !  VPrecip: Vertical profile of convective precipitation (kg/m2/s).  
 !  
 !  wd:   A convective downdraft velocity scale. For use in surface  
 !        flux parameterizations. See convect.ps file for details.  
 !  
 !  tprime: A convective downdraft temperature perturbation scale (K).  
 !          For use in surface flux parameterizations. See convect.ps  
 !          file for details.  
 !  
 !  qprime: A convective downdraft specific humidity  
 !          perturbation scale (gm/gm).  
 !          For use in surface flux parameterizations. See convect.ps  
 !          file for details.  
 !  
 !  cbmf: The cloud base mass flux ((kg/m**2)/s). THIS SCALAR VALUE MUST  
 !        BE STORED BY THE CALLING PROGRAM AND RETURNED TO CONVECT AT  
 !        ITS NEXT CALL. That is, the value of CBMF must be "remembered"  
 !        by the calling program between calls to CONVECT.  
 !  
 !  det:   Array of detrainment mass flux of dimension ND.  
 !  
 !-------------------------------------------------------------------  
 c  
 c  Local arrays  
 c  
   
       integer i,k,n,il,j  
       integer icbmax  
       integer nk1(klon)  
       integer icb1(klon)  
       integer inb1(klon)  
       integer icbs1(klon)  
   
       real plcl1(klon)  
       real tnk1(klon)  
       real qnk1(klon)  
       real gznk1(klon)  
       real pnk1(klon)  
       real qsnk1(klon)  
       real pbase1(klon)  
       real buoybase1(klon)  
   
       real lv1(klon,klev)  
       real cpn1(klon,klev)  
       real tv1(klon,klev)  
       real gz1(klon,klev)  
       real hm1(klon,klev)  
       real h1(klon,klev)  
       real tp1(klon,klev)  
       real tvp1(klon,klev)  
       real clw1(klon,klev)  
       real sig1(klon,klev)  
       real w01(klon,klev)  
       real th1(klon,klev)  
 c  
       integer ncum  
 c  
 c (local) compressed fields:  
 c  
       integer nloc  
       parameter (nloc=klon) ! pour l'instant  
   
       integer idcum(nloc)  
       integer iflag(nloc),nk(nloc),icb(nloc)  
       integer nent(nloc,klev)  
       integer icbs(nloc)  
       integer inb(nloc), inbis(nloc)  
   
       real cbmf(nloc),plcl(nloc),tnk(nloc),qnk(nloc),gznk(nloc)  
       real t(nloc,klev),q(nloc,klev),qs(nloc,klev)  
       real u(nloc,klev),v(nloc,klev)  
       real gz(nloc,klev),h(nloc,klev),lv(nloc,klev),cpn(nloc,klev)  
       real p(nloc,klev),ph(nloc,klev+1),tv(nloc,klev),tp(nloc,klev)  
       real clw(nloc,klev)  
       real dph(nloc,klev)  
       real pbase(nloc), buoybase(nloc), th(nloc,klev)  
       real tvp(nloc,klev)  
       real sig(nloc,klev), w0(nloc,klev)  
       real hp(nloc,klev), ep(nloc,klev), sigp(nloc,klev)  
       real frac(nloc), buoy(nloc,klev)  
       real cape(nloc)  
       real m(nloc,klev), ment(nloc,klev,klev), qent(nloc,klev,klev)  
       real uent(nloc,klev,klev), vent(nloc,klev,klev)  
       real ments(nloc,klev,klev), qents(nloc,klev,klev)  
       real sij(nloc,klev,klev), elij(nloc,klev,klev)  
       real qp(nloc,klev), up(nloc,klev), vp(nloc,klev)  
       real wt(nloc,klev), water(nloc,klev), evap(nloc,klev)  
       real b(nloc,klev), ft(nloc,klev), fq(nloc,klev)  
       real fu(nloc,klev), fv(nloc,klev)  
       real upwd(nloc,klev), dnwd(nloc,klev), dnwd0(nloc,klev)  
       real Ma(nloc,klev), mike(nloc,klev), tls(nloc,klev)  
       real tps(nloc,klev), qprime(nloc), tprime(nloc)  
       real precip(nloc)  
       real VPrecip(nloc,klev+1)  
       real tra(nloc,klev,ntra), trap(nloc,klev,ntra)  
       real ftra(nloc,klev,ntra), traent(nloc,klev,klev,ntra)  
       real qcondc(nloc,klev)  ! cld  
       real wd(nloc)           ! gust  
   
 !-------------------------------------------------------------------  
 ! --- SET CONSTANTS AND PARAMETERS  
 !-------------------------------------------------------------------  
   
 c -- set simulation flags:  
 c   (common cvflag)  
   
        CALL cv_flag  
   
 c -- set thermodynamical constants:  
 c       (common cvthermo)  
   
        CALL cv_thermo(iflag_con)  
   
 c -- set convect parameters  
 c  
 c       includes microphysical parameters and parameters that  
 c       control the rate of approach to quasi-equilibrium)  
 c       (common cvparam)  
   
       if (iflag_con.eq.3) then  
        CALL cv3_param(nd,delt)  
       endif  
2    
3        if (iflag_con.eq.4) then    implicit none
4    
5    contains
6    
7      SUBROUTINE cv_driver(len, nd, ndp1, ntra, t1, q1, qs1, u1, v1, tra1, p1, &
8           ph1, iflag1, ft1, fq1, fu1, fv1, ftra1, precip1, VPrecip1, cbmf1, &
9           sig1, w01, icb1, inb1, delt, Ma1, upwd1, dnwd1, dnwd01, qcondc1, wd1, &
10           cape1, da1, phi1, mp1)
11    
12        ! From LMDZ4/libf/phylmd/cv_driver.F, version 1.3, 2005/04/15 12:36:17
13    
14        ! Main driver for convection
15    
16        ! S. Bony, March 2002:
17    
18        ! Several modules corresponding to different physical processes
19    
20        ! Several versions of convect may be used:
21        ! - iflag_con = 3: version lmd  (previously named convect3)
22        ! - iflag_con = 4: version 4.3b (vect. version, previously convect1/2)
23    
24        ! Plus tard :
25        ! - iflag_con = 5: version lmd with ice (previously named convectg)
26    
27        ! S. Bony, Oct 2002:
28        ! Vectorization of convect3 (ie version lmd)
29    
30        use clesphys2, only: iflag_con
31        use cv3_compress_m, only: cv3_compress
32        use cv3_param_m, only: cv3_param
33        USE dimphy, ONLY: klev, klon
34    
35        ! PARAMETERS:
36        !      Name            Type         Usage            Description
37        !   ----------      ----------     -------  ----------------------------
38    
39        !      len           Integer        Input        first (i) dimension
40        !      nd            Integer        Input        vertical (k) dimension
41        !      ndp1          Integer        Input        nd + 1
42        !      ntra          Integer        Input        number of tracors
43        !      t1            Real           Input        temperature
44        !      q1            Real           Input        specific hum
45        !      qs1           Real           Input        sat specific hum
46        !      u1            Real           Input        u-wind
47        !      v1            Real           Input        v-wind
48        !      tra1          Real           Input        tracors
49        !      p1            Real           Input        full level pressure
50        !      ph1           Real           Input        half level pressure
51        !      iflag1        Integer        Output       flag for Emanuel conditions
52        !      ft1           Real           Output       temp tend
53        !      fq1           Real           Output       spec hum tend
54        !      fu1           Real           Output       u-wind tend
55        !      fv1           Real           Output       v-wind tend
56        !      ftra1         Real           Output       tracor tend
57        !      precip1       Real           Output       precipitation
58        !      VPrecip1      Real           Output       vertical profile of precipitations
59        !      cbmf1         Real           Output       cloud base mass flux
60        !      delt          Real           Input        time step
61        !      Ma1           Real           Output       mass flux adiabatic updraft
62        !      qcondc1       Real           Output       in-cld mixing ratio of condensed water
63        !      wd1           Real           Output       downdraft velocity scale for sfc fluxes
64        !      cape1         Real           Output       CAPE
65    
66        integer len
67        integer nd
68        integer ndp1
69        integer, intent(in):: ntra
70        real, intent(in):: t1(len, nd)
71        real q1(len, nd)
72        real qs1(len, nd)
73        real, intent(in):: u1(len, nd)
74        real, intent(in):: v1(len, nd)
75        real, intent(in):: tra1(len, nd, ntra)
76        real p1(len, nd)
77        real ph1(len, ndp1)
78        integer iflag1(len)
79        real ft1(len, nd)
80        real fq1(len, nd)
81        real fu1(len, nd)
82        real fv1(len, nd)
83        real ftra1(len, nd, ntra)
84        real precip1(len)
85        real VPrecip1(len, nd+1)
86        real cbmf1(len)
87        real, intent(inout):: sig1(klon, klev) ! section adiabatic updraft
88    
89        real, intent(inout):: w01(klon, klev)
90        ! vertical velocity within adiabatic updraft
91    
92        integer icb1(klon)
93        integer inb1(klon)
94        real, intent(in):: delt
95        real Ma1(len, nd)
96        real, intent(out):: upwd1(len, nd) ! total upward mass flux (adiab+mixed)
97        real, intent(out):: dnwd1(len, nd) ! saturated downward mass flux (mixed)
98        real, intent(out):: dnwd01(len, nd) ! unsaturated downward mass flux
99    
100        real qcondc1(len, nd)     ! cld
101        real wd1(len)            ! gust
102        real cape1(len)
103    
104        real da1(len, nd), phi1(len, nd, nd), mp1(len, nd)
105    
106        !-------------------------------------------------------------------
107        ! --- ARGUMENTS
108        !-------------------------------------------------------------------
109        ! --- On input:
110    
111        !  t:   Array of absolute temperature (K) of dimension ND, with first
112        !       index corresponding to lowest model level. Note that this array
113        !       will be altered by the subroutine if dry convective adjustment
114        !       occurs and if IPBL is not equal to 0.
115    
116        !  q:   Array of specific humidity (gm/gm) of dimension ND, with first
117        !       index corresponding to lowest model level. Must be defined
118        !       at same grid levels as T. Note that this array will be altered
119        !       if dry convective adjustment occurs and if IPBL is not equal to 0.
120    
121        !  qs:  Array of saturation specific humidity of dimension ND, with first
122        !       index corresponding to lowest model level. Must be defined
123        !       at same grid levels as T. Note that this array will be altered
124        !       if dry convective adjustment occurs and if IPBL is not equal to 0.
125    
126        !  u:   Array of zonal wind velocity (m/s) of dimension ND, witth first
127        !       index corresponding with the lowest model level. Defined at
128        !       same levels as T. Note that this array will be altered if
129        !       dry convective adjustment occurs and if IPBL is not equal to 0.
130    
131        !  v:   Same as u but for meridional velocity.
132    
133        !  tra: Array of passive tracer mixing ratio, of dimensions (ND, NTRA),
134        !       where NTRA is the number of different tracers. If no
135        !       convective tracer transport is needed, define a dummy
136        !       input array of dimension (ND, 1). Tracers are defined at
137        !       same vertical levels as T. Note that this array will be altered
138        !       if dry convective adjustment occurs and if IPBL is not equal to 0.
139    
140        !  p:   Array of pressure (mb) of dimension ND, with first
141        !       index corresponding to lowest model level. Must be defined
142        !       at same grid levels as T.
143    
144        !  ph:  Array of pressure (mb) of dimension ND+1, with first index
145        !       corresponding to lowest level. These pressures are defined at
146        !       levels intermediate between those of P, T, Q and QS. The first
147        !       value of PH should be greater than (i.e. at a lower level than)
148        !       the first value of the array P.
149    
150        !  nl:  The maximum number of levels to which convection can penetrate, plus 1.
151        !       NL MUST be less than or equal to ND-1.
152    
153        !  delt: The model time step (sec) between calls to CONVECT
154    
155        !----------------------------------------------------------------------------
156        ! ---   On Output:
157    
158        !  iflag: An output integer whose value denotes the following:
159        !       VALUE   INTERPRETATION
160        !       -----   --------------
161        !         0     Moist convection occurs.
162        !         1     Moist convection occurs, but a CFL condition
163        !               on the subsidence warming is violated. This
164        !               does not cause the scheme to terminate.
165        !         2     Moist convection, but no precip because ep(inb) lt 0.0001
166        !         3     No moist convection because new cbmf is 0 and old cbmf is 0.
167        !         4     No moist convection; atmosphere is not
168        !               unstable
169        !         6     No moist convection because ihmin le minorig.
170        !         7     No moist convection because unreasonable
171        !               parcel level temperature or specific humidity.
172        !         8     No moist convection: lifted condensation
173        !               level is above the 200 mb level.
174        !         9     No moist convection: cloud base is higher
175        !               then the level NL-1.
176    
177        !  ft:   Array of temperature tendency (K/s) of dimension ND, defined at same
178        !        grid levels as T, Q, QS and P.
179    
180        !  fq:   Array of specific humidity tendencies ((gm/gm)/s) of dimension ND,
181        !        defined at same grid levels as T, Q, QS and P.
182    
183        !  fu:   Array of forcing of zonal velocity (m/s^2) of dimension ND,
184        !        defined at same grid levels as T.
185    
186        !  fv:   Same as FU, but for forcing of meridional velocity.
187    
188        !  ftra: Array of forcing of tracer content, in tracer mixing ratio per
189        !        second, defined at same levels as T. Dimensioned (ND, NTRA).
190    
191        !  precip: Scalar convective precipitation rate (mm/day).
192    
193        !  VPrecip: Vertical profile of convective precipitation (kg/m2/s).
194    
195        !  wd:   A convective downdraft velocity scale. For use in surface
196        !        flux parameterizations. See convect.ps file for details.
197    
198        !  tprime: A convective downdraft temperature perturbation scale (K).
199        !          For use in surface flux parameterizations. See convect.ps
200        !          file for details.
201    
202        !  qprime: A convective downdraft specific humidity
203        !          perturbation scale (gm/gm).
204        !          For use in surface flux parameterizations. See convect.ps
205        !          file for details.
206    
207        !  cbmf: The cloud base mass flux ((kg/m**2)/s). THIS SCALAR VALUE MUST
208        !        BE STORED BY THE CALLING PROGRAM AND RETURNED TO CONVECT AT
209        !        ITS NEXT CALL. That is, the value of CBMF must be "remembered"
210        !        by the calling program between calls to CONVECT.
211    
212        !  det:   Array of detrainment mass flux of dimension ND.
213    
214        !-------------------------------------------------------------------
215    
216        !  Local arrays
217    
218        integer noff
219        real da(len, nd), phi(len, nd, nd), mp(len, nd)
220    
221        integer i, k, n, il, j
222        integer icbmax
223        integer nk1(klon)
224        integer icbs1(klon)
225    
226        real plcl1(klon)
227        real tnk1(klon)
228        real qnk1(klon)
229        real gznk1(klon)
230        real pnk1(klon)
231        real qsnk1(klon)
232        real pbase1(klon)
233        real buoybase1(klon)
234    
235        real lv1(klon, klev)
236        real cpn1(klon, klev)
237        real tv1(klon, klev)
238        real gz1(klon, klev)
239        real hm1(klon, klev)
240        real h1(klon, klev)
241        real tp1(klon, klev)
242        real tvp1(klon, klev)
243        real clw1(klon, klev)
244        real th1(klon, klev)
245    
246        integer ncum
247    
248        ! (local) compressed fields:
249    
250        integer nloc
251        parameter (nloc = klon) ! pour l'instant
252    
253        integer idcum(nloc)
254        integer iflag(nloc), nk(nloc), icb(nloc)
255        integer nent(nloc, klev)
256        integer icbs(nloc)
257        integer inb(nloc), inbis(nloc)
258    
259        real cbmf(nloc), plcl(nloc), tnk(nloc), qnk(nloc), gznk(nloc)
260        real t(nloc, klev), q(nloc, klev), qs(nloc, klev)
261        real u(nloc, klev), v(nloc, klev)
262        real gz(nloc, klev), h(nloc, klev), lv(nloc, klev), cpn(nloc, klev)
263        real p(nloc, klev), ph(nloc, klev+1), tv(nloc, klev), tp(nloc, klev)
264        real clw(nloc, klev)
265        real dph(nloc, klev)
266        real pbase(nloc), buoybase(nloc), th(nloc, klev)
267        real tvp(nloc, klev)
268        real sig(nloc, klev), w0(nloc, klev)
269        real hp(nloc, klev), ep(nloc, klev), sigp(nloc, klev)
270        real frac(nloc), buoy(nloc, klev)
271        real cape(nloc)
272        real m(nloc, klev), ment(nloc, klev, klev), qent(nloc, klev, klev)
273        real uent(nloc, klev, klev), vent(nloc, klev, klev)
274        real ments(nloc, klev, klev), qents(nloc, klev, klev)
275        real sij(nloc, klev, klev), elij(nloc, klev, klev)
276        real qp(nloc, klev), up(nloc, klev), vp(nloc, klev)
277        real wt(nloc, klev), water(nloc, klev), evap(nloc, klev)
278        real b(nloc, klev), ft(nloc, klev), fq(nloc, klev)
279        real fu(nloc, klev), fv(nloc, klev)
280        real upwd(nloc, klev), dnwd(nloc, klev), dnwd0(nloc, klev)
281        real Ma(nloc, klev), mike(nloc, klev), tls(nloc, klev)
282        real tps(nloc, klev), qprime(nloc), tprime(nloc)
283        real precip(nloc)
284        real VPrecip(nloc, klev+1)
285        real tra(nloc, klev, ntra), trap(nloc, klev, ntra)
286        real ftra(nloc, klev, ntra), traent(nloc, klev, klev, ntra)
287        real qcondc(nloc, klev)  ! cld
288        real wd(nloc)           ! gust
289    
290        !-------------------------------------------------------------------
291        ! --- SET CONSTANTS AND PARAMETERS
292        !-------------------------------------------------------------------
293    
294        ! -- set simulation flags:
295        !   (common cvflag)
296    
297        CALL cv_flag
298    
299        ! -- set thermodynamical constants:
300        !     (common cvthermo)
301    
302        CALL cv_thermo
303    
304        ! -- set convect parameters
305    
306        !     includes microphysical parameters and parameters that
307        !     control the rate of approach to quasi-equilibrium)
308        !     (common cvparam)
309    
310        if (iflag_con.eq.3) then
311           CALL cv3_param(nd, delt)
312        endif
313    
314        if (iflag_con.eq.4) then
315         CALL cv_param(nd)         CALL cv_param(nd)
316        endif      endif
317    
318  !---------------------------------------------------------------------      !---------------------------------------------------------------------
319  ! --- INITIALIZE OUTPUT ARRAYS AND PARAMETERS      ! --- INITIALIZE OUTPUT ARRAYS AND PARAMETERS
320  !---------------------------------------------------------------------      !---------------------------------------------------------------------
321    
322        do 20 k=1,nd      do k = 1, nd
323          do 10 i=1,len         do  i = 1, len
324           ft1(i,k)=0.0            ft1(i, k) = 0.0
325           fq1(i,k)=0.0            fq1(i, k) = 0.0
326           fu1(i,k)=0.0            fu1(i, k) = 0.0
327           fv1(i,k)=0.0            fv1(i, k) = 0.0
328           tvp1(i,k)=0.0            tvp1(i, k) = 0.0
329           tp1(i,k)=0.0            tp1(i, k) = 0.0
330           clw1(i,k)=0.0            clw1(i, k) = 0.0
331  cym            !ym
332           clw(i,k)=0.0                clw(i, k) = 0.0
333           gz1(i,k) = 0.            gz1(i, k)  =  0.
334           VPrecip1(i,k) = 0.            VPrecip1(i, k) = 0.
335           Ma1(i,k)=0.0            Ma1(i, k) = 0.0
336           upwd1(i,k)=0.0            upwd1(i, k) = 0.0
337           dnwd1(i,k)=0.0            dnwd1(i, k) = 0.0
338           dnwd01(i,k)=0.0            dnwd01(i, k) = 0.0
339           qcondc1(i,k)=0.0            qcondc1(i, k) = 0.0
340   10     continue         end do
341   20   continue      end do
342    
343        do 30 j=1,ntra      do  j = 1, ntra
344         do 31 k=1,nd         do  k = 1, nd
345          do 32 i=1,len            do  i = 1, len
346           ftra1(i,k,j)=0.0               ftra1(i, k, j) = 0.0
347   32     continue                end do
348   31    continue             end do
349   30   continue          end do
350    
351        do 60 i=1,len      do  i = 1, len
352          precip1(i)=0.0         precip1(i) = 0.0
353          iflag1(i)=0         iflag1(i) = 0
354          wd1(i)=0.0         wd1(i) = 0.0
355          cape1(i)=0.0         cape1(i) = 0.0
356          VPrecip1(i,nd+1)=0.0         VPrecip1(i, nd+1) = 0.0
357   60   continue      end do
358    
359        if (iflag_con.eq.3) then      if (iflag_con.eq.3) then
360          do il=1,len         do il = 1, len
361           sig1(il,nd)=sig1(il,nd)+1.            sig1(il, nd) = sig1(il, nd) + 1.
362           sig1(il,nd)=amin1(sig1(il,nd),12.1)            sig1(il, nd)  =  min(sig1(il, nd), 12.1)
363          enddo         enddo
364        endif      endif
365    
366  !--------------------------------------------------------------------      !--------------------------------------------------------------------
367  ! --- CALCULATE ARRAYS OF GEOPOTENTIAL, HEAT CAPACITY & STATIC ENERGY      ! --- CALCULATE ARRAYS OF GEOPOTENTIAL, HEAT CAPACITY & STATIC ENERGY
368  !--------------------------------------------------------------------      !--------------------------------------------------------------------
369    
370        if (iflag_con.eq.3) then      if (iflag_con.eq.3) then
371         CALL cv3_prelim(len,nd,ndp1,t1,q1,p1,ph1            ! nd->na         CALL cv3_prelim(len, nd, ndp1, t1, q1, p1, ph1, lv1, cpn1, tv1, gz1, &
372       o               ,lv1,cpn1,tv1,gz1,h1,hm1,th1)              h1, hm1, th1)! nd->na
373        endif      endif
374    
375        if (iflag_con.eq.4) then      if (iflag_con.eq.4) then
376         CALL cv_prelim(len,nd,ndp1,t1,q1,p1,ph1         CALL cv_prelim(len, nd, ndp1, t1, q1, p1, ph1 &
377       o               ,lv1,cpn1,tv1,gz1,h1,hm1)              , lv1, cpn1, tv1, gz1, h1, hm1)
378        endif      endif
379    
380  !--------------------------------------------------------------------      !--------------------------------------------------------------------
381  ! --- CONVECTIVE FEED      ! --- CONVECTIVE FEED
382  !--------------------------------------------------------------------      !--------------------------------------------------------------------
383    
384        if (iflag_con.eq.3) then      if (iflag_con.eq.3) then
385         CALL cv3_feed(len,nd,t1,q1,qs1,p1,ph1,hm1,gz1           ! nd->na         CALL cv3_feed(len, nd, t1, q1, qs1, p1, ph1, hm1, gz1            &
386       o         ,nk1,icb1,icbmax,iflag1,tnk1,qnk1,gznk1,plcl1)              , nk1, icb1, icbmax, iflag1, tnk1, qnk1, gznk1, plcl1) ! nd->na
387        endif      endif
388    
389        if (iflag_con.eq.4) then      if (iflag_con.eq.4) then
390         CALL cv_feed(len,nd,t1,q1,qs1,p1,hm1,gz1         CALL cv_feed(len, nd, t1, q1, qs1, p1, hm1, gz1 &
391       o         ,nk1,icb1,icbmax,iflag1,tnk1,qnk1,gznk1,plcl1)              , nk1, icb1, icbmax, iflag1, tnk1, qnk1, gznk1, plcl1)
392        endif      endif
393    
394  !--------------------------------------------------------------------      !--------------------------------------------------------------------
395  ! --- UNDILUTE (ADIABATIC) UPDRAFT / 1st part      ! --- UNDILUTE (ADIABATIC) UPDRAFT / 1st part
396  ! (up through ICB for convect4, up through ICB+1 for convect3)      ! (up through ICB for convect4, up through ICB+1 for convect3)
397  !     Calculates the lifted parcel virtual temperature at nk, the      !     Calculates the lifted parcel virtual temperature at nk, the
398  !     actual temperature, and the adiabatic liquid water content.      !     actual temperature, and the adiabatic liquid water content.
399  !--------------------------------------------------------------------      !--------------------------------------------------------------------
400    
401        if (iflag_con.eq.3) then      if (iflag_con.eq.3) then
402         CALL cv3_undilute1(len,nd,t1,q1,qs1,gz1,plcl1,p1,nk1,icb1  ! nd->na         CALL cv3_undilute1(len, nd, t1, q1, qs1, gz1, plcl1, p1, nk1, icb1   &
403       o                        ,tp1,tvp1,clw1,icbs1)              , tp1, tvp1, clw1, icbs1) ! nd->na
404        endif      endif
405    
406        if (iflag_con.eq.4) then      if (iflag_con.eq.4) then
407         CALL cv_undilute1(len,nd,t1,q1,qs1,gz1,p1,nk1,icb1,icbmax         CALL cv_undilute1(len, nd, t1, q1, qs1, gz1, p1, nk1, icb1, icbmax &
408       :                        ,tp1,tvp1,clw1)              , tp1, tvp1, clw1)
409        endif      endif
410    
411  !-------------------------------------------------------------------      !-------------------------------------------------------------------
412  ! --- TRIGGERING      ! --- TRIGGERING
413  !-------------------------------------------------------------------      !-------------------------------------------------------------------
414    
415        if (iflag_con.eq.3) then      if (iflag_con.eq.3) then
416         CALL cv3_trigger(len,nd,icb1,plcl1,p1,th1,tv1,tvp1      ! nd->na         CALL cv3_trigger(len, nd, icb1, plcl1, p1, th1, tv1, tvp1, pbase1, &
417       o                 ,pbase1,buoybase1,iflag1,sig1,w01)              buoybase1, iflag1, sig1, w01) ! nd->na
418        endif      endif
419    
420        if (iflag_con.eq.4) then      if (iflag_con.eq.4) then
421         CALL cv_trigger(len,nd,icb1,cbmf1,tv1,tvp1,iflag1)         CALL cv_trigger(len, nd, icb1, cbmf1, tv1, tvp1, iflag1)
422        endif      endif
423    
424  !=====================================================================      ! --- IF THIS POINT IS REACHED, MOIST CONVECTIVE ADJUSTMENT IS NECESSARY
425  ! --- IF THIS POINT IS REACHED, MOIST CONVECTIVE ADJUSTMENT IS NECESSARY  
426  !=====================================================================      ncum = 0
427        do  i = 1, len
428        ncum=0         if(iflag1(i).eq.0)then
429        do 400 i=1,len            ncum = ncum+1
430          if(iflag1(i).eq.0)then            idcum(ncum) = i
431             ncum=ncum+1         endif
432             idcum(ncum)=i      end do
433          endif  
434   400  continue      !       print*, 'klon, ncum = ', len, ncum
435    
436  c       print*,'klon, ncum = ',len,ncum      IF (ncum.gt.0) THEN
437    
438        IF (ncum.gt.0) THEN         !^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
439           ! --- COMPRESS THE FIELDS
440  !^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^         !        (-> vectorization over convective gridpoints)
441  ! --- COMPRESS THE FIELDS         !^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
442  !               (-> vectorization over convective gridpoints)  
443  !^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^         if (iflag_con.eq.3) then
444              CALL cv3_compress(len, nloc, ncum, nd, ntra, iflag1, nk1, icb1, &
445        if (iflag_con.eq.3) then                 icbs1, plcl1, tnk1, qnk1, gznk1, pbase1, buoybase1, t1, q1, &
446         CALL cv3_compress( len,nloc,ncum,nd,ntra                 qs1, u1, v1, gz1, th1, tra1, h1, lv1, cpn1, p1, ph1, tv1, tp1, &
447       :    ,iflag1,nk1,icb1,icbs1                 tvp1, clw1, sig1, w01, iflag, nk, icb, icbs, plcl, tnk, qnk, &
448       :    ,plcl1,tnk1,qnk1,gznk1,pbase1,buoybase1                 gznk, pbase, buoybase, t, q, qs, u, v, gz, th, tra, h, lv, &
449       :    ,t1,q1,qs1,u1,v1,gz1,th1                 cpn, p, ph, tv, tp, tvp, clw, sig, w0)
450       :    ,tra1         endif
451       :    ,h1,lv1,cpn1,p1,ph1,tv1,tp1,tvp1,clw1  
452       :    ,sig1,w01         if (iflag_con.eq.4) then
453       o    ,iflag,nk,icb,icbs            CALL cv_compress( len, nloc, ncum, nd &
454       o    ,plcl,tnk,qnk,gznk,pbase,buoybase                 , iflag1, nk1, icb1 &
455       o    ,t,q,qs,u,v,gz,th                 , cbmf1, plcl1, tnk1, qnk1, gznk1 &
456       o    ,tra                 , t1, q1, qs1, u1, v1, gz1 &
457       o    ,h,lv,cpn,p,ph,tv,tp,tvp,clw                 , h1, lv1, cpn1, p1, ph1, tv1, tp1, tvp1, clw1 &
458       o    ,sig,w0  )                 , iflag, nk, icb &
459        endif                 , cbmf, plcl, tnk, qnk, gznk &
460                   , t, q, qs, u, v, gz, h, lv, cpn, p, ph, tv, tp, tvp, clw  &
461        if (iflag_con.eq.4) then                 , dph )
462         CALL cv_compress( len,nloc,ncum,nd         endif
463       :    ,iflag1,nk1,icb1  
464       :    ,cbmf1,plcl1,tnk1,qnk1,gznk1         !-------------------------------------------------------------------
465       :    ,t1,q1,qs1,u1,v1,gz1         ! --- UNDILUTE (ADIABATIC) UPDRAFT / second part :
466       :    ,h1,lv1,cpn1,p1,ph1,tv1,tp1,tvp1,clw1         ! ---   FIND THE REST OF THE LIFTED PARCEL TEMPERATURES
467       o    ,iflag,nk,icb         ! ---   &
468       o    ,cbmf,plcl,tnk,qnk,gznk         ! ---   COMPUTE THE PRECIPITATION EFFICIENCIES AND THE
469       o    ,t,q,qs,u,v,gz,h,lv,cpn,p,ph,tv,tp,tvp,clw         ! ---   FRACTION OF PRECIPITATION FALLING OUTSIDE OF CLOUD
470       o    ,dph )         ! ---   &
471        endif         ! ---   FIND THE LEVEL OF NEUTRAL BUOYANCY
472           !-------------------------------------------------------------------
473  !-------------------------------------------------------------------  
474  ! --- UNDILUTE (ADIABATIC) UPDRAFT / second part :         if (iflag_con.eq.3) then
475  ! ---   FIND THE REST OF THE LIFTED PARCEL TEMPERATURES            CALL cv3_undilute2(nloc, ncum, nd, icb, icbs, nk         &
476  ! ---   &                 , tnk, qnk, gznk, t, q, qs, gz &
477  ! ---   COMPUTE THE PRECIPITATION EFFICIENCIES AND THE                 , p, h, tv, lv, pbase, buoybase, plcl &
478  ! ---   FRACTION OF PRECIPITATION FALLING OUTSIDE OF CLOUD                 , inb, tp, tvp, clw, hp, ep, sigp, buoy) !na->nd
479  ! ---   &         endif
480  ! ---   FIND THE LEVEL OF NEUTRAL BUOYANCY  
481  !-------------------------------------------------------------------         if (iflag_con.eq.4) then
482              CALL cv_undilute2(nloc, ncum, nd, icb, nk &
483        if (iflag_con.eq.3) then                 , tnk, qnk, gznk, t, q, qs, gz &
484         CALL cv3_undilute2(nloc,ncum,nd,icb,icbs,nk        !na->nd                 , p, dph, h, tv, lv &
485       :                        ,tnk,qnk,gznk,t,q,qs,gz                 , inb, inbis, tp, tvp, clw, hp, ep, sigp, frac)
486       :                        ,p,h,tv,lv,pbase,buoybase,plcl         endif
487       o                        ,inb,tp,tvp,clw,hp,ep,sigp,buoy)  
488        endif         !-------------------------------------------------------------------
489           ! --- CLOSURE
490        if (iflag_con.eq.4) then         !-------------------------------------------------------------------
491         CALL cv_undilute2(nloc,ncum,nd,icb,nk  
492       :                        ,tnk,qnk,gznk,t,q,qs,gz         if (iflag_con.eq.3) then
493       :                        ,p,dph,h,tv,lv            CALL cv3_closure(nloc, ncum, nd, icb, inb               &
494       o             ,inb,inbis,tp,tvp,clw,hp,ep,sigp,frac)                 , pbase, p, ph, tv, buoy &
495        endif                 , sig, w0, cape, m) ! na->nd
496           endif
497  !-------------------------------------------------------------------  
498  ! --- CLOSURE         if (iflag_con.eq.4) then
499  !-------------------------------------------------------------------            CALL cv_closure(nloc, ncum, nd, nk, icb &
500                   , tv, tvp, p, ph, dph, plcl, cpn &
501        if (iflag_con.eq.3) then                 , iflag, cbmf)
502         CALL cv3_closure(nloc,ncum,nd,icb,inb              ! na->nd         endif
503       :                       ,pbase,p,ph,tv,buoy  
504       o                       ,sig,w0,cape,m)         !-------------------------------------------------------------------
505        endif         ! --- MIXING
506           !-------------------------------------------------------------------
507        if (iflag_con.eq.4) then  
508         CALL cv_closure(nloc,ncum,nd,nk,icb         if (iflag_con.eq.3) then
509       :                ,tv,tvp,p,ph,dph,plcl,cpn            CALL cv3_mixing(nloc, ncum, nd, nd, ntra, icb, nk, inb     &
510       o                ,iflag,cbmf)                 , ph, t, q, qs, u, v, tra, h, lv, qnk &
511        endif                 , hp, tv, tvp, ep, clw, m, sig &
512                   , ment, qent, uent, vent, nent, sij, elij, ments, qents, traent)! na->nd
513  !-------------------------------------------------------------------         endif
514  ! --- MIXING  
515  !-------------------------------------------------------------------         if (iflag_con.eq.4) then
516              CALL cv_mixing(nloc, ncum, nd, icb, nk, inb, inbis &
517        if (iflag_con.eq.3) then                 , ph, t, q, qs, u, v, h, lv, qnk &
518         CALL cv3_mixing(nloc,ncum,nd,nd,ntra,icb,nk,inb    ! na->nd                 , hp, tv, tvp, ep, clw, cbmf &
519       :                     ,ph,t,q,qs,u,v,tra,h,lv,qnk                 , m, ment, qent, uent, vent, nent, sij, elij)
520       :                     ,hp,tv,tvp,ep,clw,m,sig         endif
521       o ,ment,qent,uent,vent, nent,sij,elij,ments,qents,traent)  
522        endif         !-------------------------------------------------------------------
523           ! --- UNSATURATED (PRECIPITATING) DOWNDRAFTS
524        if (iflag_con.eq.4) then         !-------------------------------------------------------------------
525         CALL cv_mixing(nloc,ncum,nd,icb,nk,inb,inbis  
526       :                     ,ph,t,q,qs,u,v,h,lv,qnk         if (iflag_con.eq.3) then
527       :                     ,hp,tv,tvp,ep,clw,cbmf            CALL cv3_unsat(nloc, ncum, nd, nd, ntra, icb, inb     &
528       o                     ,m,ment,qent,uent,vent,nent,sij,elij)                 , t, q, qs, gz, u, v, tra, p, ph &
529        endif                 , th, tv, lv, cpn, ep, sigp, clw &
530                   , m, ment, elij, delt, plcl &
531  !-------------------------------------------------------------------                 , mp, qp, up, vp, trap, wt, water, evap, b)! na->nd
532  ! --- UNSATURATED (PRECIPITATING) DOWNDRAFTS         endif
533  !-------------------------------------------------------------------  
534           if (iflag_con.eq.4) then
535        if (iflag_con.eq.3) then            CALL cv_unsat(nloc, ncum, nd, inb, t, q, qs, gz, u, v, p, ph &
536         CALL cv3_unsat(nloc,ncum,nd,nd,ntra,icb,inb    ! na->nd                 , h, lv, ep, sigp, clw, m, ment, elij &
537       :               ,t,q,qs,gz,u,v,tra,p,ph                 , iflag, mp, qp, up, vp, wt, water, evap)
538       :               ,th,tv,lv,cpn,ep,sigp,clw         endif
539       :               ,m,ment,elij,delt,plcl  
540       o          ,mp,qp,up,vp,trap,wt,water,evap,b)         !-------------------------------------------------------------------
541        endif         ! --- YIELD
542           !     (tendencies, precipitation, variables of interface with other
543        if (iflag_con.eq.4) then         !      processes, etc)
544         CALL cv_unsat(nloc,ncum,nd,inb,t,q,qs,gz,u,v,p,ph         !-------------------------------------------------------------------
545       :                   ,h,lv,ep,sigp,clw,m,ment,elij  
546       o                   ,iflag,mp,qp,up,vp,wt,water,evap)         if (iflag_con.eq.3) then
547        endif            CALL cv3_yield(nloc, ncum, nd, nd, ntra             &
548                   , icb, inb, delt &
549  !-------------------------------------------------------------------                 , t, q, u, v, tra, gz, p, ph, h, hp, lv, cpn, th &
550  ! --- YIELD                 , ep, clw, m, tp, mp, qp, up, vp, trap &
551  !     (tendencies, precipitation, variables of interface with other                 , wt, water, evap, b &
552  !      processes, etc)                 , ment, qent, uent, vent, nent, elij, traent, sig &
553  !-------------------------------------------------------------------                 , tv, tvp &
554                   , iflag, precip, VPrecip, ft, fq, fu, fv, ftra &
555        if (iflag_con.eq.3) then                 , upwd, dnwd, dnwd0, ma, mike, tls, tps, qcondc, wd)! na->nd
556         CALL cv3_yield(nloc,ncum,nd,nd,ntra            ! na->nd         endif
557       :                     ,icb,inb,delt  
558       :                     ,t,q,u,v,tra,gz,p,ph,h,hp,lv,cpn,th         if (iflag_con.eq.4) then
559       :                     ,ep,clw,m,tp,mp,qp,up,vp,trap            CALL cv_yield(nloc, ncum, nd, nk, icb, inb, delt &
560       :                     ,wt,water,evap,b                 , t, q, u, v, gz, p, ph, h, hp, lv, cpn &
561       :                     ,ment,qent,uent,vent,nent,elij,traent,sig                 , ep, clw, frac, m, mp, qp, up, vp &
562       :                     ,tv,tvp                 , wt, water, evap &
563       o                     ,iflag,precip,VPrecip,ft,fq,fu,fv,ftra                 , ment, qent, uent, vent, nent, elij &
564       o                     ,upwd,dnwd,dnwd0,ma,mike,tls,tps,qcondc,wd)                 , tv, tvp &
565        endif                 , iflag, wd, qprime, tprime &
566                   , precip, cbmf, ft, fq, fu, fv, Ma, qcondc)
567        if (iflag_con.eq.4) then         endif
568         CALL cv_yield(nloc,ncum,nd,nk,icb,inb,delt  
569       :              ,t,q,u,v,gz,p,ph,h,hp,lv,cpn         !^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
570       :              ,ep,clw,frac,m,mp,qp,up,vp         ! --- passive tracers
571       :              ,wt,water,evap         !^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
572       :              ,ment,qent,uent,vent,nent,elij  
573       :              ,tv,tvp         if (iflag_con.eq.3) then
574       o              ,iflag,wd,qprime,tprime            CALL cv3_tracer(nloc, len, ncum, nd, nd, &
575       o              ,precip,cbmf,ft,fq,fu,fv,Ma,qcondc)                 ment, sij, da, phi)
576        endif         endif
577    
578  !^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^         !^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
579  ! --- passive tracers         ! --- UNCOMPRESS THE FIELDS
580  !^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^         !^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
581           ! set iflag1  = 42 for non convective points
582        if (iflag_con.eq.3) then         do  i = 1, len
583         CALL cv3_tracer(nloc,len,ncum,nd,nd,            iflag1(i) = 42
584       :                  ment,sij,da,phi)         end do
585        endif  
586           if (iflag_con.eq.3) then
587  !^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^            CALL cv3_uncompress(nloc, len, ncum, nd, ntra, idcum &
588  ! --- UNCOMPRESS THE FIELDS                 , iflag &
589  !^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                 , precip, VPrecip, sig, w0 &
590  c set iflag1 =42 for non convective points                 , ft, fq, fu, fv, ftra &
591        do  i=1,len                 , inb  &
592          iflag1(i)=42                 , Ma, upwd, dnwd, dnwd0, qcondc, wd, cape &
593        end do                 , da, phi, mp &
594  c                 , iflag1 &
595        if (iflag_con.eq.3) then                 , precip1, VPrecip1, sig1, w01 &
596         CALL cv3_uncompress(nloc,len,ncum,nd,ntra,idcum                 , ft1, fq1, fu1, fv1, ftra1 &
597       :          ,iflag                 , inb1 &
598       :          ,precip,VPrecip,sig,w0                 , Ma1, upwd1, dnwd1, dnwd01, qcondc1, wd1, cape1  &
599       :          ,ft,fq,fu,fv,ftra                 , da1, phi1, mp1)
600       :          ,inb         endif
601       :          ,Ma,upwd,dnwd,dnwd0,qcondc,wd,cape  
602       :          ,da,phi,mp         if (iflag_con.eq.4) then
603       o          ,iflag1            CALL cv_uncompress(nloc, len, ncum, nd, idcum &
604       o          ,precip1,VPrecip1,sig1,w01                 , iflag &
605       o          ,ft1,fq1,fu1,fv1,ftra1                 , precip, cbmf &
606       o          ,inb1                 , ft, fq, fu, fv &
607       o          ,Ma1,upwd1,dnwd1,dnwd01,qcondc1,wd1,cape1                 , Ma, qcondc             &
608       o          ,da1,phi1,mp1)                 , iflag1 &
609        endif                 , precip1, cbmf1 &
610                   , ft1, fq1, fu1, fv1 &
611        if (iflag_con.eq.4) then                 , Ma1, qcondc1 )
612         CALL cv_uncompress(nloc,len,ncum,nd,idcum         endif
613       :          ,iflag      ENDIF ! ncum>0
      :          ,precip,cbmf  
      :          ,ft,fq,fu,fv  
      :          ,Ma,qcondc              
      o          ,iflag1  
      o          ,precip1,cbmf1  
      o          ,ft1,fq1,fu1,fv1  
      o          ,Ma1,qcondc1 )            
       endif  
   
       ENDIF ! ncum>0  
   
 9999  continue  
   
       return  
       end  
   
 !==================================================================  
       SUBROUTINE cv_flag  
       implicit none  
   
       include "cvflag.h"  
   
 c -- si .TRUE., on rend la gravite plus explicite et eventuellement  
 c differente de 10.0 dans convect3:  
       cvflag_grav = .TRUE.  
   
       return  
       end  
   
 !==================================================================  
       SUBROUTINE cv_thermo(iflag_con)  
       use YOMCST  
           implicit none  
   
 c-------------------------------------------------------------  
 c Set thermodynamical constants for convectL  
 c-------------------------------------------------------------  
   
       include "cvthermo.h"  
   
       integer, intent(in):: iflag_con  
   
   
 c original set from convect:  
       if (iflag_con.eq.4) then  
        cpd=1005.7  
        cpv=1870.0  
        cl=4190.0  
        rrv=461.5  
        rrd=287.04  
        lv0=2.501E6  
        g=9.8  
        t0=273.15  
        grav=g  
       endif  
   
 c constants consistent with LMDZ:  
       if (iflag_con.eq.3) then  
        cpd = RCPD  
        cpv = RCPV  
        cl  = RCW  
        rrv = RV  
        rrd = RD  
        lv0 = RLVTT  
        g   = RG     ! not used in convect3  
 c ori      t0  = RTT  
        t0  = 273.15 ! convect3 (RTT=273.16)  
 c maf       grav= 10.    ! implicitely or explicitely used in convect3  
        grav= g    ! implicitely or explicitely used in convect3  
       endif  
   
       rowl=1000.0 !(a quelle variable de YOMCST cela correspond-il?)  
   
       clmcpv=cl-cpv  
       clmcpd=cl-cpd  
       cpdmcp=cpd-cpv  
       cpvmcpd=cpv-cpd  
       cpvmcl=cl-cpv ! for convect3  
       eps=rrd/rrv  
       epsi=1.0/eps  
       epsim1=epsi-1.0  
 c      ginv=1.0/g  
       ginv=1.0/grav  
       hrd=0.5*rrd  
614    
615        return    end SUBROUTINE cv_driver
       end  
616    
617    end module cv_driver_m

Legend:
Removed from v.14  
changed lines
  Added in v.91

  ViewVC Help
Powered by ViewVC 1.1.21