Changeset 5141 for LMDZ6/branches/Amaury_dev
- Timestamp:
- Jul 29, 2024, 12:37:08 PM (5 months ago)
- Location:
- LMDZ6/branches/Amaury_dev/libf
- Files:
-
- 2 deleted
- 23 edited
- 6 moved
Legend:
- Unmodified
- Added
- Removed
-
LMDZ6/branches/Amaury_dev/libf/phylmd/cv3_buoy.F90
r5105 r5141 9 9 ! modified by : * 10 10 ! ************************************************************** 11 USE lmdz_cvthermo 12 USE lmdz_cv3param 11 13 12 14 IMPLICIT NONE 13 15 14 include "cvthermo.h"15 include "cv3param.h"16 16 include "YOMCST2.h" 17 17 -
LMDZ6/branches/Amaury_dev/libf/phylmd/cv3_cine.F90
r5105 r5141 1 2 1 ! $Id$ 3 2 4 3 SUBROUTINE cv3_cine(nloc, ncum, nd, icb, inb, pbase, plcl, p, ph, tv, tvp, & 5 cina, cinb, plfc)4 cina, cinb, plfc) 6 5 7 6 ! ************************************************************** … … 14 13 ! modified by : * 15 14 ! ************************************************************** 15 USE lmdz_cvthermo 16 USE lmdz_cv3param 16 17 17 18 IMPLICIT NONE 18 19 19 20 include "YOMCST.h" 20 include "cvthermo.h"21 include "cv3param.h"22 21 ! input: 23 22 INTEGER ncum, nd, nloc 24 23 INTEGER icb(nloc), inb(nloc) 25 24 REAL pbase(nloc), plcl(nloc) 26 REAL p(nloc, nd), ph(nloc, nd +1)25 REAL p(nloc, nd), ph(nloc, nd + 1) 27 26 REAL tv(nloc, nd), tvp(nloc, nd) 28 27 … … 67 66 68 67 DO il = 1, ncum 69 tvplcl(il) = tvp(il, 1) *(plcl(il)/p(il,1))**(2./7.) !For dry air, R/Cp=2/770 END DO 71 72 DO il = 1, ncum 73 IF (plcl(il)>p(il, icb(il))) THEN68 tvplcl(il) = tvp(il, 1) * (plcl(il) / p(il, 1))**(2. / 7.) !For dry air, R/Cp=2/7 69 END DO 70 71 DO il = 1, ncum 72 IF (plcl(il)>p(il, icb(il))) THEN 74 73 ifst(il) = icb(il) 75 74 isublcl(il) = icb(il) - 1 … … 81 80 82 81 DO il = 1, ncum 83 tvlcl(il) = tv(il, ifst(il) -1) + (tv(il,ifst(il))-tv(il,ifst(il)-1))*(&84 plcl(il)-p(il,ifst(il)-1))/(p(il,ifst(il))-p(il,ifst(il)-1))82 tvlcl(il) = tv(il, ifst(il) - 1) + (tv(il, ifst(il)) - tv(il, ifst(il) - 1)) * (& 83 plcl(il) - p(il, ifst(il) - 1)) / (p(il, ifst(il)) - p(il, ifst(il) - 1)) 85 84 END DO 86 85 … … 102 101 DO il = 1, ncum 103 102 IF (k>=ifst(il)) THEN 104 IF (buoy(il, k)>0.) THEN103 IF (buoy(il, k)>0.) THEN 105 104 itop(il) = k 106 105 exist_lfc(il) = .TRUE. … … 146 145 DO il = 1, ncum 147 146 IF (lswitch(il)) THEN 148 IF (p(il, ineg(il))<p(il,icb(il))-dpmax) THEN147 IF (p(il, ineg(il))<p(il, icb(il)) - dpmax) THEN 149 148 plfc(il) = plcl(il) 150 149 cina(il) = 0. … … 173 172 DO il = 1, ncum 174 173 IF (lswitch(il)) THEN 175 IF (k>=ineg(il) .AND. buoy(il, k)>0) THEN174 IF (k>=ineg(il) .AND. buoy(il, k)>0) THEN 176 175 itop(il) = k 177 176 END IF … … 191 190 192 191 DO il = 1, ncum 193 lswitch3(il) = itop(il) < nl - 1192 lswitch3(il) = itop(il) < nl - 1 194 193 lswitch(il) = lswitch1(il) .AND. lswitch2(il) .AND. lswitch3(il) 195 194 END DO … … 202 201 ! de LCL 203 202 ! --------------------------------------------------------------------------- 204 IF (ineg(il)>isublcl(il) +1) THEN203 IF (ineg(il)>isublcl(il) + 1) THEN 205 204 ! In order to get P0, one may interpolate linearly buoyancies 206 205 ! between P(ineg) and P(ineg-1). 207 p0(il) = (buoy(il, ineg(il))*p(il,ineg(il)-1)-buoy(il,ineg(il)-1)*p(il,ineg(il)))/ &208 (buoy(il,ineg(il))-buoy(il,ineg(il)-1))206 p0(il) = (buoy(il, ineg(il)) * p(il, ineg(il) - 1) - buoy(il, ineg(il) - 1) * p(il, ineg(il))) / & 207 (buoy(il, ineg(il)) - buoy(il, ineg(il) - 1)) 209 208 ELSE 210 209 ! In order to get P0, one has to interpolate between P(ineg) and 211 210 ! Plcl. 212 p0(il) = (buoy(il, ineg(il))*plcl(il)-buoylcl(il)*p(il,ineg(il)))/ &213 (buoy(il,ineg(il))-buoylcl(il))211 p0(il) = (buoy(il, ineg(il)) * plcl(il) - buoylcl(il) * p(il, ineg(il))) / & 212 (buoy(il, ineg(il)) - buoylcl(il)) 214 213 END IF 215 214 END IF … … 220 219 DO il = 1, ncum 221 220 IF (lswitch(il)) THEN 222 plfc(il) = (buoy(il, itop(il))*p(il,itop(il)-1)-buoy(il,itop(&223 il)-1)*p(il,itop(il)))/(buoy(il,itop(il))-buoy(il,itop(il)-1))221 plfc(il) = (buoy(il, itop(il)) * p(il, itop(il) - 1) - buoy(il, itop(& 222 il) - 1) * p(il, itop(il))) / (buoy(il, itop(il)) - buoy(il, itop(il) - 1)) 224 223 END IF 225 224 END DO … … 231 230 DO il = 1, ncum 232 231 IF (lswitch(il)) THEN 233 deltap = p(il, itop(il) -1) - plfc(il)234 dcin = rd *buoy(il, itop(il)-1)*deltap/(p(il,itop(il)-1)+plfc(il))232 deltap = p(il, itop(il) - 1) - plfc(il) 233 dcin = rd * buoy(il, itop(il) - 1) * deltap / (p(il, itop(il) - 1) + plfc(il)) 235 234 cina(il) = min(0., dcin) 236 235 END IF … … 241 240 DO il = 1, ncum 242 241 IF (lswitch(il)) THEN 243 IF (k>=ineg(il) .AND. k<=itop(il) -2) THEN244 deltap = p(il, k) - p(il, k +1)245 dcin = 0.5 *rd*(buoy(il,k)+buoy(il,k+1))*deltap/ph(il, k+1)242 IF (k>=ineg(il) .AND. k<=itop(il) - 2) THEN 243 deltap = p(il, k) - p(il, k + 1) 244 dcin = 0.5 * rd * (buoy(il, k) + buoy(il, k + 1)) * deltap / ph(il, k + 1) 246 245 cina(il) = cina(il) + min(0., dcin) 247 246 END IF … … 254 253 IF (lswitch(il)) THEN 255 254 deltap = p0(il) - p(il, ineg(il)) 256 dcin = rd *buoy(il, ineg(il))*deltap/(p(il,ineg(il))+p0(il))255 dcin = rd * buoy(il, ineg(il)) * deltap / (p(il, ineg(il)) + p0(il)) 257 256 cina(il) = cina(il) + min(0., dcin) 258 257 END IF … … 282 281 DO k = nl, 1, -1 283 282 DO il = 1, ncum 284 IF (lswitch(il) .AND. k<=icb(il) -1) THEN285 IF (buoy(il, k)<0.) THEN283 IF (lswitch(il) .AND. k<=icb(il) - 1) THEN 284 IF (buoy(il, k)<0.) THEN 286 285 ilow(il) = k 287 286 END IF … … 295 294 IF (lswitch(il)) THEN 296 295 IF (ilow(il)>1) THEN 297 p0(il) = (buoy(il, ilow(il))*p(il,ilow(il)-1)-buoy(il,ilow(&298 il)-1)*p(il,ilow(il)))/(buoy(il,ilow(il))-buoy(il,ilow(il)-1))296 p0(il) = (buoy(il, ilow(il)) * p(il, ilow(il) - 1) - buoy(il, ilow(& 297 il) - 1) * p(il, ilow(il))) / (buoy(il, ilow(il)) - buoy(il, ilow(il) - 1)) 299 298 buoyz(il) = 0. 300 299 ELSE … … 310 309 DO il = 1, ncum 311 310 lswitch2(il) = (isublcl(il)==1 .AND. ilow(il)==1) .OR. & 312 (isublcl(il)==ilow(il)-1)311 (isublcl(il)==ilow(il) - 1) 313 312 lswitch(il) = lswitch1(il) .AND. lswitch2(il) 314 313 END DO … … 321 320 IF (lswitch(il)) THEN 322 321 deltap = p0(il) - plcl(il) 323 dcin = rd *(buoyz(il)+buoylcl(il))*deltap/(p0(il)+plcl(il))322 dcin = rd * (buoyz(il) + buoylcl(il)) * deltap / (p0(il) + plcl(il)) 324 323 cinb(il) = min(0., dcin) 325 324 END IF … … 338 337 IF (lswitch(il)) THEN 339 338 deltap = p0(il) - p(il, ilow(il)) 340 dcin = rd *(buoyz(il)+buoy(il,ilow(il)))*deltap/(p0(il)+p(il,ilow(il)))339 dcin = rd * (buoyz(il) + buoy(il, ilow(il))) * deltap / (p0(il) + p(il, ilow(il))) 341 340 cinb(il) = min(0., dcin) 342 341 END IF … … 348 347 DO k = 1, nl 349 348 DO il = 1, ncum 350 IF (lswitch(il) .AND. k>=ilow(il) .AND. k<=isublcl(il) -1) THEN351 deltap = p(il, k) - p(il, k +1)352 dcin = 0.5 *rd*(buoy(il,k)+buoy(il,k+1))*deltap/ph(il, k+1)349 IF (lswitch(il) .AND. k>=ilow(il) .AND. k<=isublcl(il) - 1) THEN 350 deltap = p(il, k) - p(il, k + 1) 351 dcin = 0.5 * rd * (buoy(il, k) + buoy(il, k + 1)) * deltap / ph(il, k + 1) 353 352 cinb(il) = cinb(il) + min(0., dcin) 354 353 END IF … … 360 359 IF (lswitch(il)) THEN 361 360 deltap = p(il, isublcl(il)) - plcl(il) 362 dcin = rd *(buoy(il,isublcl(il))+buoylcl(il))*deltap/ &363 (p(il,isublcl(il))+plcl(il))361 dcin = rd * (buoy(il, isublcl(il)) + buoylcl(il)) * deltap / & 362 (p(il, isublcl(il)) + plcl(il)) 364 363 cinb(il) = cinb(il) + min(0., dcin) 365 364 END IF … … 373 372 374 373 DO il = 1, ncum 375 lswitch2(il) = plcl(il) > p(il, itop(il) -1)374 lswitch2(il) = plcl(il) > p(il, itop(il) - 1) 376 375 lswitch(il) = lswitch1(il) .AND. lswitch2(il) 377 376 END DO … … 383 382 DO il = 1, ncum 384 383 IF (lswitch(il)) THEN 385 plfc(il) = (buoy(il, itop(il))*p(il,itop(il)-1)-buoy(il,itop(&386 il)-1)*p(il,itop(il)))/(buoy(il,itop(il))-buoy(il,itop(il)-1))384 plfc(il) = (buoy(il, itop(il)) * p(il, itop(il) - 1) - buoy(il, itop(& 385 il) - 1) * p(il, itop(il))) / (buoy(il, itop(il)) - buoy(il, itop(il) - 1)) 387 386 END IF 388 387 END DO … … 391 390 DO il = 1, ncum 392 391 IF (lswitch(il)) THEN 393 deltap = p(il, itop(il) -1) - plfc(il)394 dcin = rd *buoy(il, itop(il)-1)*deltap/(p(il,itop(il)-1)+plfc(il))392 deltap = p(il, itop(il) - 1) - plfc(il) 393 dcin = rd * buoy(il, itop(il) - 1) * deltap / (p(il, itop(il) - 1) + plfc(il)) 395 394 cina(il) = min(0., dcin) 396 395 END IF … … 400 399 DO k = 1, nl 401 400 DO il = 1, ncum 402 IF (lswitch(il) .AND. k>=icb(il) +1 .AND. k<=itop(il)-2) THEN403 deltap = p(il, k) - p(il, k +1)404 dcin = 0.5 *rd*(buoy(il,k)+buoy(il,k+1))*deltap/ph(il, k+1)401 IF (lswitch(il) .AND. k>=icb(il) + 1 .AND. k<=itop(il) - 2) THEN 402 deltap = p(il, k) - p(il, k + 1) 403 dcin = 0.5 * rd * (buoy(il, k) + buoy(il, k + 1)) * deltap / ph(il, k + 1) 405 404 cina(il) = cina(il) + min(0., dcin) 406 405 END IF … … 411 410 DO il = 1, ncum 412 411 IF (lswitch(il)) THEN 413 IF (plcl(il)>p(il, icb(il))) THEN414 IF (icb(il)<itop(il) -1) THEN415 deltap = p(il, icb(il)) - p(il, icb(il) +1)416 dcin = 0.5 *rd*(buoy(il,icb(il))+buoy(il,icb(il)+1))*deltap/ &417 ph(il, icb(il)+1)412 IF (plcl(il)>p(il, icb(il))) THEN 413 IF (icb(il)<itop(il) - 1) THEN 414 deltap = p(il, icb(il)) - p(il, icb(il) + 1) 415 dcin = 0.5 * rd * (buoy(il, icb(il)) + buoy(il, icb(il) + 1)) * deltap / & 416 ph(il, icb(il) + 1) 418 417 cina(il) = cina(il) + min(0., dcin) 419 418 END IF 420 419 421 420 deltap = plcl(il) - p(il, icb(il)) 422 dcin = rd *(buoylcl(il)+buoy(il,icb(il)))*deltap/ &423 (plcl(il)+p(il,icb(il)))421 dcin = rd * (buoylcl(il) + buoy(il, icb(il))) * deltap / & 422 (plcl(il) + p(il, icb(il))) 424 423 cina(il) = cina(il) + min(0., dcin) 425 424 ELSE 426 deltap = plcl(il) - p(il, icb(il) +1)427 dcin = rd *(buoylcl(il)+buoy(il,icb(il)+1))*deltap/ &428 (plcl(il)+p(il,icb(il)+1))425 deltap = plcl(il) - p(il, icb(il) + 1) 426 dcin = rd * (buoylcl(il) + buoy(il, icb(il) + 1)) * deltap / & 427 (plcl(il) + p(il, icb(il) + 1)) 429 428 cina(il) = cina(il) + min(0., dcin) 430 429 END IF … … 442 441 DO il = 1, ncum 443 442 IF (lswitch(il)) THEN 444 plfc(il) = (buoy(il, itop(il))*plcl(il)-buoylcl(il)*p(il,itop(il)))/ &445 (buoy(il,itop(il))-buoylcl(il))443 plfc(il) = (buoy(il, itop(il)) * plcl(il) - buoylcl(il) * p(il, itop(il))) / & 444 (buoy(il, itop(il)) - buoylcl(il)) 446 445 END IF 447 446 END DO … … 450 449 IF (lswitch(il)) THEN 451 450 deltap = plcl(il) - plfc(il) 452 dcin = rd *buoylcl(il)*deltap/(plcl(il)+plfc(il))451 dcin = rd * buoylcl(il) * deltap / (plcl(il) + plfc(il)) 453 452 cina(il) = min(0., dcin) 454 453 END IF … … 456 455 ! c ENDIF 457 456 458 459 460 461 457 END SUBROUTINE cv3_cine -
LMDZ6/branches/Amaury_dev/libf/phylmd/cv3_crit.F90
r5105 r5141 9 9 ! modified by : * 10 10 ! ************************************************************** 11 USE lmdz_cv3param 11 12 12 13 IMPLICIT NONE 13 14 include "cv3param.h"15 14 16 15 ! input: -
LMDZ6/branches/Amaury_dev/libf/phylmd/cv3_enthalpmix.F90
r5105 r5141 10 10 ! modified by : Filiberti M-A 06/2005 vectorisation * 11 11 ! ************************************************************** 12 12 USE lmdz_cvthermo 13 13 IMPLICIT NONE 14 14 ! ============================================================== … … 22 22 ! =============================================================== 23 23 24 include "cvthermo.h"25 24 include "YOETHF.h" 26 25 include "YOMCST.h" -
LMDZ6/branches/Amaury_dev/libf/phylmd/cv3_estatmix.F90
r5105 r5141 11 11 ! modified by : Filiberti M-A 06/2005 vectorisation * 12 12 ! **************************************************************** 13 13 USE lmdz_cvthermo 14 14 IMPLICIT NONE 15 15 ! ============================================================== … … 23 23 ! =============================================================== 24 24 25 include "cvthermo.h"26 25 include "YOETHF.h" 27 26 include "YOMCST.h" -
LMDZ6/branches/Amaury_dev/libf/phylmd/cv3_mixscale.F90
r5105 r5141 9 9 ! ************************************************************** 10 10 11 USE lmdz_cv3param 12 11 13 IMPLICIT NONE 12 13 include "cv3param.h"14 14 15 15 !inputs: -
LMDZ6/branches/Amaury_dev/libf/phylmd/cv3_routines.F90
r5140 r5141 1 2 1 ! $Id$ 3 2 … … 11 10 USE lmdz_conema3 12 11 USE lmdz_cvflag 12 USE lmdz_cv3param 13 13 14 14 IMPLICIT NONE 15 15 16 !------------------------------------------------------------ 17 !Set parameters for convectL for iflag_con = 3 18 !------------------------------------------------------------ 19 20 21 !*** PBCRIT IS THE CRITICAL CLOUD DEPTH (MB) BENEATH WHICH THE *** 22 !*** PRECIPITATION EFFICIENCY IS ASSUMED TO BE ZERO *** 23 !*** PTCRIT IS THE CLOUD DEPTH (MB) ABOVE WHICH THE PRECIP. *** 24 !*** EFFICIENCY IS ASSUMED TO BE UNITY *** 25 !*** SIGD IS THE FRACTIONAL AREA COVERED BY UNSATURATED DNDRAFT *** 26 !*** SPFAC IS THE FRACTION OF PRECIPITATION FALLING OUTSIDE *** 27 !*** OF CLOUD *** 28 29 ![TAU: CHARACTERISTIC TIMESCALE USED TO COMPUTE ALPHA & BETA] 30 !*** ALPHA AND BETA ARE PARAMETERS THAT CONTROL THE RATE OF *** 31 !*** APPROACH TO QUASI-EQUILIBRIUM *** 32 !*** (THEIR STANDARD VALUES ARE 1.0 AND 0.96, RESPECTIVELY) *** 33 !*** (BETA MUST BE LESS THAN OR EQUAL TO 1) *** 34 35 !*** DTCRIT IS THE CRITICAL BUOYANCY (K) USED TO ADJUST THE *** 36 !*** APPROACH TO QUASI-EQUILIBRIUM *** 37 !*** IT MUST BE LESS THAN 0 *** 38 39 include "cv3param.h" 40 41 INTEGER, INTENT(IN) :: nd 42 INTEGER, INTENT(IN) :: k_upper 43 REAL, INTENT(IN) :: delt ! timestep (seconds) 44 45 ! Local variables 46 CHARACTER (LEN=20) :: modname = 'cv3_param' 47 CHARACTER (LEN=80) :: abort_message 16 !------------------------------------------------------------ 17 !Set parameters for convectL for iflag_con = 3 18 !------------------------------------------------------------ 19 20 21 !*** PBCRIT IS THE CRITICAL CLOUD DEPTH (MB) BENEATH WHICH THE *** 22 !*** PRECIPITATION EFFICIENCY IS ASSUMED TO BE ZERO *** 23 !*** PTCRIT IS THE CLOUD DEPTH (MB) ABOVE WHICH THE PRECIP. *** 24 !*** EFFICIENCY IS ASSUMED TO BE UNITY *** 25 !*** SIGD IS THE FRACTIONAL AREA COVERED BY UNSATURATED DNDRAFT *** 26 !*** SPFAC IS THE FRACTION OF PRECIPITATION FALLING OUTSIDE *** 27 !*** OF CLOUD *** 28 29 ![TAU: CHARACTERISTIC TIMESCALE USED TO COMPUTE ALPHA & BETA] 30 !*** ALPHA AND BETA ARE PARAMETERS THAT CONTROL THE RATE OF *** 31 !*** APPROACH TO QUASI-EQUILIBRIUM *** 32 !*** (THEIR STANDARD VALUES ARE 1.0 AND 0.96, RESPECTIVELY) *** 33 !*** (BETA MUST BE LESS THAN OR EQUAL TO 1) *** 34 35 !*** DTCRIT IS THE CRITICAL BUOYANCY (K) USED TO ADJUST THE *** 36 !*** APPROACH TO QUASI-EQUILIBRIUM *** 37 !*** IT MUST BE LESS THAN 0 *** 38 39 INTEGER, INTENT(IN) :: nd 40 INTEGER, INTENT(IN) :: k_upper 41 REAL, INTENT(IN) :: delt ! timestep (seconds) 42 43 ! Local variables 44 CHARACTER (LEN = 20) :: modname = 'cv3_param' 45 CHARACTER (LEN = 80) :: abort_message 48 46 49 47 LOGICAL, SAVE :: first = .TRUE. 50 !$OMP THREADPRIVATE(first)51 52 !glb noff: integer limit for convection (nd-noff)53 ! minorig: First level of convection54 55 ! -- limit levels for convection:56 57 !jyg<58 ! noff is chosen such that nl = k_upper so that upmost loops end at about 22 km59 60 noff = min(max(nd -k_upper, 1), (nd+1)/2)61 !! noff = 162 !>jyg48 !$OMP THREADPRIVATE(first) 49 50 !glb noff: integer limit for convection (nd-noff) 51 ! minorig: First level of convection 52 53 ! -- limit levels for convection: 54 55 !jyg< 56 ! noff is chosen such that nl = k_upper so that upmost loops end at about 22 km 57 58 noff = min(max(nd - k_upper, 1), (nd + 1) / 2) 59 !! noff = 1 60 !>jyg 63 61 minorig = 1 64 62 nl = nd - noff … … 67 65 68 66 IF (first) THEN 69 ! -- "microphysical" parameters:70 ! IM beg: ajout fis. reglage ep71 ! CR+JYG: shedding coefficient (used when iflag_mix_adiab=1)72 ! IM lu dans physiq.def via conf_phys.F90 epmax = 0.99367 ! -- "microphysical" parameters: 68 ! IM beg: ajout fis. reglage ep 69 ! CR+JYG: shedding coefficient (used when iflag_mix_adiab=1) 70 ! IM lu dans physiq.def via conf_phys.F90 epmax = 0.993 73 71 74 72 omtrain = 45.0 ! used also for snow (no disctinction rain/snow) 75 ! -- misc:73 ! -- misc: 76 74 dtovsh = -0.2 ! dT for overshoot 77 ! cc dttrig = 5. ! (loose) condition for triggering75 ! cc dttrig = 5. ! (loose) condition for triggering 78 76 dttrig = 10. ! (loose) condition for triggering 79 77 dtcrit = -2.0 80 ! -- end of convection81 ! -- interface cloud parameterization:78 ! -- end of convection 79 ! -- interface cloud parameterization: 82 80 delta = 0.01 ! cld 83 ! -- interface with boundary-layer (gust factor): (sb)81 ! -- interface with boundary-layer (gust factor): (sb) 84 82 betad = 10.0 ! original value (from convect 4.3) 85 83 86 ! Var interm pour le getin87 cv_flag_feed=188 CALL getin_p('cv_flag_feed',cv_flag_feed)89 90 CALL getin_p('t_top_max',T_top_max)91 dpbase=-40.92 CALL getin_p('dpbase',dpbase)93 pbcrit=150.094 CALL getin_p('pbcrit',pbcrit)95 ptcrit=500.096 CALL getin_p('ptcrit',ptcrit)97 sigdz=0.0198 CALL getin_p('sigdz',sigdz)99 spfac=0.15100 CALL getin_p('spfac',spfac)101 tau=8000.102 CALL getin_p('tau',tau)103 flag_wb=1104 CALL getin_p('flag_wb',flag_wb)105 wbmax=6.106 CALL getin_p('wbmax',wbmax)107 ok_convstop=.False.108 CALL getin_p('ok_convstop ',ok_convstop)109 tau_stop=15000.110 CALL getin_p('tau_stop ',tau_stop)111 ok_intermittent=.False.112 CALL getin_p('ok_intermittent',ok_intermittent)113 ok_optim_yield=.False.114 CALL getin_p('ok_optim_yield',ok_optim_yield)115 ok_homo_tend=.TRUE.116 CALL getin_p('ok_homo_tend',ok_homo_tend)117 ok_entrain=.TRUE.118 CALL getin_p('ok_entrain',ok_entrain)119 120 coef_peel=0.25121 CALL getin_p('coef_peel',coef_peel)122 123 flag_epKEorig=1124 CALL getin_p('flag_epKEorig',flag_epKEorig)125 elcrit=0.0003126 CALL getin_p('elcrit',elcrit)127 tlcrit=-55.0128 CALL getin_p('tlcrit',tlcrit)129 ejectliq=0.130 CALL getin_p('ejectliq',ejectliq)131 ejectice=0.132 CALL getin_p('ejectice',ejectice)133 134 CALL getin_p('cvflag_prec_eject',cvflag_prec_eject)135 136 CALL getin_p('qsat_depends_on_qt',qsat_depends_on_qt)137 138 CALL getin_p('adiab_ascent_mass_flux_depends_on_ejectliq',adiab_ascent_mass_flux_depends_on_ejectliq)139 140 84 ! Var interm pour le getin 85 cv_flag_feed = 1 86 CALL getin_p('cv_flag_feed', cv_flag_feed) 87 T_top_max = 1000. 88 CALL getin_p('t_top_max', T_top_max) 89 dpbase = -40. 90 CALL getin_p('dpbase', dpbase) 91 pbcrit = 150.0 92 CALL getin_p('pbcrit', pbcrit) 93 ptcrit = 500.0 94 CALL getin_p('ptcrit', ptcrit) 95 sigdz = 0.01 96 CALL getin_p('sigdz', sigdz) 97 spfac = 0.15 98 CALL getin_p('spfac', spfac) 99 tau = 8000. 100 CALL getin_p('tau', tau) 101 flag_wb = 1 102 CALL getin_p('flag_wb', flag_wb) 103 wbmax = 6. 104 CALL getin_p('wbmax', wbmax) 105 ok_convstop = .False. 106 CALL getin_p('ok_convstop ', ok_convstop) 107 tau_stop = 15000. 108 CALL getin_p('tau_stop ', tau_stop) 109 ok_intermittent = .False. 110 CALL getin_p('ok_intermittent', ok_intermittent) 111 ok_optim_yield = .False. 112 CALL getin_p('ok_optim_yield', ok_optim_yield) 113 ok_homo_tend = .TRUE. 114 CALL getin_p('ok_homo_tend', ok_homo_tend) 115 ok_entrain = .TRUE. 116 CALL getin_p('ok_entrain', ok_entrain) 117 118 coef_peel = 0.25 119 CALL getin_p('coef_peel', coef_peel) 120 121 flag_epKEorig = 1 122 CALL getin_p('flag_epKEorig', flag_epKEorig) 123 elcrit = 0.0003 124 CALL getin_p('elcrit', elcrit) 125 tlcrit = -55.0 126 CALL getin_p('tlcrit', tlcrit) 127 ejectliq = 0. 128 CALL getin_p('ejectliq', ejectliq) 129 ejectice = 0. 130 CALL getin_p('ejectice', ejectice) 131 cvflag_prec_eject = .FALSE. 132 CALL getin_p('cvflag_prec_eject', cvflag_prec_eject) 133 qsat_depends_on_qt = .FALSE. 134 CALL getin_p('qsat_depends_on_qt', qsat_depends_on_qt) 135 adiab_ascent_mass_flux_depends_on_ejectliq = .FALSE. 136 CALL getin_p('adiab_ascent_mass_flux_depends_on_ejectliq', adiab_ascent_mass_flux_depends_on_ejectliq) 137 keepbug_ice_frac = .TRUE. 138 CALL getin_p('keepbug_ice_frac', keepbug_ice_frac) 141 139 142 140 WRITE (*, *) 't_top_max=', t_top_max … … 160 158 WRITE (*, *) 'ejectliq=', ejectliq 161 159 WRITE (*, *) 'ejectice=', ejectice 162 WRITE (*, *) 'cvflag_prec_eject =', cvflag_prec_eject 163 WRITE (*, *) 'qsat_depends_on_qt =', qsat_depends_on_qt 160 WRITE (*, *) 'cvflag_prec_eject =', cvflag_prec_eject 161 WRITE (*, *) 'qsat_depends_on_qt =', qsat_depends_on_qt 164 162 WRITE (*, *) 'adiab_ascent_mass_flux_depends_on_ejectliq =', adiab_ascent_mass_flux_depends_on_ejectliq 165 WRITE (*, *) 'keepbug_ice_frac =', keepbug_ice_frac 163 WRITE (*, *) 'keepbug_ice_frac =', keepbug_ice_frac 166 164 167 165 first = .FALSE. 168 166 END IF ! (first) 169 167 170 beta = 1.0 - delt /tau168 beta = 1.0 - delt / tau 171 169 alpha1 = 1.5E-3 172 !JYG Correction bug alpha 173 alpha1 = alpha1*1.5 174 alpha = alpha1*delt/tau 175 !JYG Bug 176 ! cc increase alpha to compensate W decrease: 177 ! c alpha = alpha*1.5 178 179 noconv_stop = max(2.,tau_stop/delt) 180 170 !JYG Correction bug alpha 171 alpha1 = alpha1 * 1.5 172 alpha = alpha1 * delt / tau 173 !JYG Bug 174 ! cc increase alpha to compensate W decrease: 175 ! c alpha = alpha*1.5 176 177 noconv_stop = max(2., tau_stop / delt) 181 178 182 179 END SUBROUTINE cv3_param … … 184 181 SUBROUTINE cv3_incrcount(len, nd, delt, sig) 185 182 USE lmdz_cvflag 186 187 IMPLICIT NONE 188 189 ! ===================================================================== 190 ! Increment the counter sig(nd) 191 ! =====================================================================192 193 include "cv3param.h"194 195 !inputs:196 INTEGER, INTENT(IN) 197 INTEGER, INTENT(IN) 198 REAL, INTENT(IN) 199 200 !input/output201 REAL, DIMENSION(len, nd), INTENT(INOUT):: sig202 203 !local variables183 USE lmdz_cvthermo 184 USE lmdz_cv3param 185 186 IMPLICIT NONE 187 188 ! ===================================================================== 189 ! Increment the counter sig(nd) 190 ! ===================================================================== 191 192 !inputs: 193 INTEGER, INTENT(IN) :: len 194 INTEGER, INTENT(IN) :: nd 195 REAL, INTENT(IN) :: delt ! timestep (seconds) 196 197 !input/output 198 REAL, DIMENSION(len, nd), INTENT(INOUT) :: sig 199 200 !local variables 204 201 INTEGER il 205 202 206 ! print *,'cv3_incrcount : noconv_stop ',noconv_stop 207 ! print *,'cv3_incrcount in, sig(1,nd) ',sig(1,nd) 208 IF(ok_convstop) THEN 209 DO il = 1, len 210 sig(il, nd) = sig(il, nd) + 1. 211 sig(il, nd) = min(sig(il,nd), noconv_stop+0.1) 212 END DO 213 ELSE 214 DO il = 1, len 215 sig(il, nd) = sig(il, nd) + 1. 216 sig(il, nd) = min(sig(il,nd), 12.1) 217 END DO 218 ENDIF ! (ok_convstop) 219 ! print *,'cv3_incrcount out, sig(1,nd) ',sig(1,nd) 220 203 ! print *,'cv3_incrcount : noconv_stop ',noconv_stop 204 ! print *,'cv3_incrcount in, sig(1,nd) ',sig(1,nd) 205 IF(ok_convstop) THEN 206 DO il = 1, len 207 sig(il, nd) = sig(il, nd) + 1. 208 sig(il, nd) = min(sig(il, nd), noconv_stop + 0.1) 209 END DO 210 ELSE 211 DO il = 1, len 212 sig(il, nd) = sig(il, nd) + 1. 213 sig(il, nd) = min(sig(il, nd), 12.1) 214 END DO 215 ENDIF ! (ok_convstop) 216 ! print *,'cv3_incrcount out, sig(1,nd) ',sig(1,nd) 221 217 222 218 END SUBROUTINE cv3_incrcount 223 219 224 SUBROUTINE cv3_prelim(len, nd, ndp1, t, q, p, ph, & 225 lv, lf, cpn, tv, gz, h, hm, th) 220 SUBROUTINE cv3_prelim(len, nd, ndp1, t, q, p, ph, lv, lf, cpn, tv, gz, h, hm, th) 221 USE lmdz_cv3param 222 USE lmdz_cvthermo 223 226 224 IMPLICIT NONE 227 225 228 ! =====================================================================229 ! --- CALCULATE ARRAYS OF GEOPOTENTIAL, HEAT CAPACITY & STATIC ENERGY230 ! "ori": from convect4.3 (vectorized)231 ! "convect3": to be exactly consistent with convect3232 ! =====================================================================233 234 ! inputs:226 ! ===================================================================== 227 ! --- CALCULATE ARRAYS OF GEOPOTENTIAL, HEAT CAPACITY & STATIC ENERGY 228 ! "ori": from convect4.3 (vectorized) 229 ! "convect3": to be exactly consistent with convect3 230 ! ===================================================================== 231 232 ! inputs: 235 233 INTEGER len, nd, ndp1 236 234 REAL t(len, nd), q(len, nd), p(len, nd), ph(len, ndp1) 237 235 238 ! outputs:236 ! outputs: 239 237 REAL lv(len, nd), lf(len, nd), cpn(len, nd), tv(len, nd) 240 238 REAL gz(len, nd), h(len, nd), hm(len, nd) 241 239 REAL th(len, nd) 242 240 243 ! local variables:241 ! local variables: 244 242 INTEGER k, i 245 243 REAL rdcp … … 247 245 REAL cpx(len, nd) 248 246 249 include "cvthermo.h" 250 include "cv3param.h" 251 252 253 ! ori do 110 k=1,nlp 254 ! abderr do 110 k=1,nl ! convect3 247 ! ori do 110 k=1,nlp 248 ! abderr do 110 k=1,nl ! convect3 255 249 DO k = 1, nlp 256 250 257 251 DO i = 1, len 258 ! debug lv(i,k)= lv0-clmcpv*(t(i,k)-t0)259 lv(i, k) = lv0 - clmcpv *(t(i,k)-273.15)260 !! lf(i, k) = lf0 - clmci*(t(i,k)-273.15) ! erreur de signe !!261 lf(i, k) = lf0 + clmci *(t(i,k)-273.15)262 cpn(i, k) = cpd *(1.0-q(i,k)) + cpv*q(i, k)263 cpx(i, k) = cpd *(1.0-q(i,k)) + cl*q(i, k)264 ! ori tv(i,k)=t(i,k)*(1.0+q(i,k)*epsim1)265 tv(i, k) = t(i, k) *(1.0+q(i,k)/eps-q(i,k))266 rdcp = (rrd *(1.-q(i,k))+q(i,k)*rrv)/cpn(i, k)267 th(i, k) = t(i, k) *(1000.0/p(i,k))**rdcp268 END DO 269 END DO 270 271 ! gz = phi at the full levels (same as p).272 273 !! DO i = 1, len !jyg274 !! gz(i, 1) = 0.0 !jyg275 !! END DO !jyg276 gz(:,:) = 0. !jyg: initialization of the whole array277 ! ori do 140 k=2,nlp252 ! debug lv(i,k)= lv0-clmcpv*(t(i,k)-t0) 253 lv(i, k) = lv0 - clmcpv * (t(i, k) - 273.15) 254 !! lf(i, k) = lf0 - clmci*(t(i,k)-273.15) ! erreur de signe !! 255 lf(i, k) = lf0 + clmci * (t(i, k) - 273.15) 256 cpn(i, k) = cpd * (1.0 - q(i, k)) + cpv * q(i, k) 257 cpx(i, k) = cpd * (1.0 - q(i, k)) + cl * q(i, k) 258 ! ori tv(i,k)=t(i,k)*(1.0+q(i,k)*epsim1) 259 tv(i, k) = t(i, k) * (1.0 + q(i, k) / eps - q(i, k)) 260 rdcp = (rrd * (1. - q(i, k)) + q(i, k) * rrv) / cpn(i, k) 261 th(i, k) = t(i, k) * (1000.0 / p(i, k))**rdcp 262 END DO 263 END DO 264 265 ! gz = phi at the full levels (same as p). 266 267 !! DO i = 1, len !jyg 268 !! gz(i, 1) = 0.0 !jyg 269 !! END DO !jyg 270 gz(:, :) = 0. !jyg: initialization of the whole array 271 ! ori do 140 k=2,nlp 278 272 DO k = 2, nl ! convect3 279 273 DO i = 1, len 280 tvx = t(i, k) *(1.+q(i,k)/eps-q(i,k)) !convect3281 tvy = t(i, k -1)*(1.+q(i,k-1)/eps-q(i,k-1)) !convect3282 gz(i, k) = gz(i, k -1) + 0.5*rrd*(tvx+tvy)* & !convect3283 (p(i,k-1)-p(i,k))/ph(i, k) !convect3284 285 ! c print *,' gz(',k,')',gz(i,k),' tvx',tvx,' tvy ',tvy286 287 ! ori gz(i,k)=gz(i,k-1)+hrd*(tv(i,k-1)+tv(i,k))288 ! ori & *(p(i,k-1)-p(i,k))/ph(i,k)289 END DO 290 END DO 291 292 ! h = phi + cpT (dry static energy).293 ! hm = phi + cp(T-Tbase)+Lq294 295 ! ori do 170 k=1,nlp274 tvx = t(i, k) * (1. + q(i, k) / eps - q(i, k)) !convect3 275 tvy = t(i, k - 1) * (1. + q(i, k - 1) / eps - q(i, k - 1)) !convect3 276 gz(i, k) = gz(i, k - 1) + 0.5 * rrd * (tvx + tvy) * & !convect3 277 (p(i, k - 1) - p(i, k)) / ph(i, k) !convect3 278 279 ! c print *,' gz(',k,')',gz(i,k),' tvx',tvx,' tvy ',tvy 280 281 ! ori gz(i,k)=gz(i,k-1)+hrd*(tv(i,k-1)+tv(i,k)) 282 ! ori & *(p(i,k-1)-p(i,k))/ph(i,k) 283 END DO 284 END DO 285 286 ! h = phi + cpT (dry static energy). 287 ! hm = phi + cp(T-Tbase)+Lq 288 289 ! ori do 170 k=1,nlp 296 290 DO k = 1, nl ! convect3 297 291 DO i = 1, len 298 h(i, k) = gz(i, k) + cpn(i, k)*t(i, k) 299 hm(i, k) = gz(i, k) + cpx(i, k)*(t(i,k)-t(i,1)) + lv(i, k)*q(i, k) 300 END DO 301 END DO 302 292 h(i, k) = gz(i, k) + cpn(i, k) * t(i, k) 293 hm(i, k) = gz(i, k) + cpx(i, k) * (t(i, k) - t(i, 1)) + lv(i, k) * q(i, k) 294 END DO 295 END DO 303 296 304 297 END SUBROUTINE cv3_prelim 305 298 306 299 SUBROUTINE cv3_feed(len, nd, ok_conserv_q, & 307 308 309 310 300 t, q, u, v, p, ph, h, gz, & 301 p1feed, p2feed, wght, & 302 wghti, tnk, thnk, qnk, qsnk, unk, vnk, & 303 cpnk, hnk, nk, icb, icbmax, iflag, gznk, plcl) 311 304 312 305 USE lmdz_phys_transfert_para, ONLY: bcast 313 306 USE add_phys_tend_mod, ONLY: fl_cor_ebil 314 307 USE lmdz_print_control, ONLY: prt_level 308 USE lmdz_cvthermo 309 USE lmdz_cv3param 310 315 311 IMPLICIT NONE 316 312 317 ! ================================================================ 318 ! Purpose: CONVECTIVE FEED 319 320 ! Main differences with cv_feed: 321 ! - ph added in input 322 ! - here, nk(i)=minorig 323 ! - icb defined differently (plcl compared with ph instead of p) 324 ! - dry static energy as argument instead of moist static energy 325 326 ! Main differences with convect3: 327 ! - we do not compute dplcldt and dplcldr of CLIFT anymore 328 ! - values iflag different (but tests identical) 329 ! - A,B explicitely defined (!...) 330 ! ================================================================ 331 332 include "cv3param.h" 333 include "cvthermo.h" 334 335 !inputs: 336 INTEGER, INTENT (IN) :: len, nd 337 LOGICAL, INTENT (IN) :: ok_conserv_q 338 REAL, DIMENSION (len, nd), INTENT (IN) :: t, q, p 339 REAL, DIMENSION (len, nd), INTENT (IN) :: u, v 340 REAL, DIMENSION (len, nd), INTENT (IN) :: h, gz 341 REAL, DIMENSION (len, nd+1), INTENT (IN) :: ph 342 REAL, DIMENSION (len), INTENT (IN) :: p1feed 343 REAL, DIMENSION (nd), INTENT (IN) :: wght 344 !input-output 345 REAL, DIMENSION (len), INTENT (INOUT) :: p2feed 346 !outputs: 347 INTEGER, INTENT (OUT) :: icbmax 348 INTEGER, DIMENSION (len), INTENT (OUT) :: iflag, nk, icb 349 REAL, DIMENSION (len, nd), INTENT (OUT) :: wghti 350 REAL, DIMENSION (len), INTENT (OUT) :: tnk, thnk, qnk, qsnk 351 REAL, DIMENSION (len), INTENT (OUT) :: unk, vnk 352 REAL, DIMENSION (len), INTENT (OUT) :: cpnk, hnk, gznk 353 REAL, DIMENSION (len), INTENT (OUT) :: plcl 354 355 !local variables: 313 ! ================================================================ 314 ! Purpose: CONVECTIVE FEED 315 316 ! Main differences with cv_feed: 317 ! - ph added in input 318 ! - here, nk(i)=minorig 319 ! - icb defined differently (plcl compared with ph instead of p) 320 ! - dry static energy as argument instead of moist static energy 321 322 ! Main differences with convect3: 323 ! - we do not compute dplcldt and dplcldr of CLIFT anymore 324 ! - values iflag different (but tests identical) 325 ! - A,B explicitely defined (!...) 326 ! ================================================================ 327 328 !inputs: 329 INTEGER, INTENT (IN) :: len, nd 330 LOGICAL, INTENT (IN) :: ok_conserv_q 331 REAL, DIMENSION (len, nd), INTENT (IN) :: t, q, p 332 REAL, DIMENSION (len, nd), INTENT (IN) :: u, v 333 REAL, DIMENSION (len, nd), INTENT (IN) :: h, gz 334 REAL, DIMENSION (len, nd + 1), INTENT (IN) :: ph 335 REAL, DIMENSION (len), INTENT (IN) :: p1feed 336 REAL, DIMENSION (nd), INTENT (IN) :: wght 337 !input-output 338 REAL, DIMENSION (len), INTENT (INOUT) :: p2feed 339 !outputs: 340 INTEGER, INTENT (OUT) :: icbmax 341 INTEGER, DIMENSION (len), INTENT (OUT) :: iflag, nk, icb 342 REAL, DIMENSION (len, nd), INTENT (OUT) :: wghti 343 REAL, DIMENSION (len), INTENT (OUT) :: tnk, thnk, qnk, qsnk 344 REAL, DIMENSION (len), INTENT (OUT) :: unk, vnk 345 REAL, DIMENSION (len), INTENT (OUT) :: cpnk, hnk, gznk 346 REAL, DIMENSION (len), INTENT (OUT) :: plcl 347 348 !local variables: 356 349 INTEGER i, k, iter, niter 357 350 INTEGER ihmin(len) … … 363 356 LOGICAL nocond(len) 364 357 365 !jyg20140217<358 !jyg20140217< 366 359 INTEGER iostat 367 360 LOGICAL, SAVE :: first 368 361 LOGICAL, SAVE :: ok_new_feed 369 362 REAL, SAVE :: dp_lcl_feed 370 !$OMP THREADPRIVATE (first,ok_new_feed,dp_lcl_feed)363 !$OMP THREADPRIVATE (first,ok_new_feed,dp_lcl_feed) 371 364 DATA first/.TRUE./ 372 365 DATA dp_lcl_feed/2./ 373 366 374 367 IF (first) THEN 375 !$OMP MASTER368 !$OMP MASTER 376 369 ok_new_feed = ok_conserv_q 377 OPEN (98, FILE ='cv3feed_param.data', STATUS='old', FORM='formatted', IOSTAT=iostat)370 OPEN (98, FILE = 'cv3feed_param.data', STATUS = 'old', FORM = 'formatted', IOSTAT = iostat) 378 371 IF (iostat==0) THEN 379 READ (98, *, END =998) ok_new_feed380 998 CONTINUE372 READ (98, *, END = 998) ok_new_feed 373 998 CONTINUE 381 374 CLOSE (98) 382 375 END IF 383 376 PRINT *, ' ok_new_feed: ', ok_new_feed 384 !$OMP END MASTER377 !$OMP END MASTER 385 378 CALL bcast(ok_new_feed) 386 first = .FALSE. 379 first = .FALSE. 387 380 END IF 388 !jyg>389 ! -------------------------------------------------------------------390 ! --- Origin level of ascending parcels for convect3:391 ! -------------------------------------------------------------------381 !jyg> 382 ! ------------------------------------------------------------------- 383 ! --- Origin level of ascending parcels for convect3: 384 ! ------------------------------------------------------------------- 392 385 393 386 DO i = 1, len … … 396 389 END DO 397 390 398 ! -------------------------------------------------------------------399 ! --- Adjust feeding layer thickness so that lifting up to the top of400 ! --- the feeding layer does not induce condensation (i.e. so that401 ! --- plcl < p2feed).402 ! --- Method : iterative secant method.403 ! -------------------------------------------------------------------404 405 ! 1- First bracketing of the solution : ph(nk+1), p2feed406 407 ! 1.a- LCL associated with p2feed391 ! ------------------------------------------------------------------- 392 ! --- Adjust feeding layer thickness so that lifting up to the top of 393 ! --- the feeding layer does not induce condensation (i.e. so that 394 ! --- plcl < p2feed). 395 ! --- Method : iterative secant method. 396 ! ------------------------------------------------------------------- 397 398 ! 1- First bracketing of the solution : ph(nk+1), p2feed 399 400 ! 1.a- LCL associated with p2feed 408 401 DO i = 1, len 409 402 pup(i) = p2feed(i) 410 403 END DO 411 IF (fl_cor_ebil >=2 404 IF (fl_cor_ebil >=2) THEN 412 405 CALL cv3_estatmix(len, nd, iflag, p1feed, pup, p, ph, & 413 414 406 t, q, u, v, h, gz, wght, & 407 wghti, nk, tnk, thnk, qnk, qsnk, unk, vnk, plclup) 415 408 ELSE 416 409 CALL cv3_enthalpmix(len, nd, iflag, p1feed, pup, p, ph, & 417 418 419 ENDIF ! (fl_cor_ebil >=2 ) 420 ! 1.b- LCL associated with ph(nk+1)410 t, q, u, v, wght, & 411 wghti, nk, tnk, thnk, qnk, qsnk, unk, vnk, plclup) 412 ENDIF ! (fl_cor_ebil >=2 ) 413 ! 1.b- LCL associated with ph(nk+1) 421 414 DO i = 1, len 422 plo(i) = ph(i, nk(i) +1)423 END DO 424 IF (fl_cor_ebil >=2 415 plo(i) = ph(i, nk(i) + 1) 416 END DO 417 IF (fl_cor_ebil >=2) THEN 425 418 CALL cv3_estatmix(len, nd, iflag, p1feed, plo, p, ph, & 426 427 419 t, q, u, v, h, gz, wght, & 420 wghti, nk, tnk, thnk, qnk, qsnk, unk, vnk, plcllo) 428 421 ELSE 429 422 CALL cv3_enthalpmix(len, nd, iflag, p1feed, plo, p, ph, & 430 431 432 ENDIF ! (fl_cor_ebil >=2 ) 433 ! 2- Iterations423 t, q, u, v, wght, & 424 wghti, nk, tnk, thnk, qnk, qsnk, unk, vnk, plcllo) 425 ENDIF ! (fl_cor_ebil >=2 ) 426 ! 2- Iterations 434 427 niter = 5 435 428 DO iter = 1, niter … … 443 436 pfeed(i) = pup(i) 444 437 ELSE 445 !JYG20140217<438 !JYG20140217< 446 439 IF (ok_new_feed) THEN 447 pfeed(i) = (pup(i) *(plo(i)-plcllo(i)-dp_lcl_feed)+&448 plo(i)*(plclup(i)-pup(i)+dp_lcl_feed))/ &449 (plo(i)-plcllo(i)+plclup(i)-pup(i))440 pfeed(i) = (pup(i) * (plo(i) - plcllo(i) - dp_lcl_feed) + & 441 plo(i) * (plclup(i) - pup(i) + dp_lcl_feed)) / & 442 (plo(i) - plcllo(i) + plclup(i) - pup(i)) 450 443 ELSE 451 pfeed(i) = (pup(i) *(plo(i)-plcllo(i))+&452 plo(i)*(plclup(i)-pup(i)))/ &453 (plo(i)-plcllo(i)+plclup(i)-pup(i))444 pfeed(i) = (pup(i) * (plo(i) - plcllo(i)) + & 445 plo(i) * (plclup(i) - pup(i))) / & 446 (plo(i) - plcllo(i) + plclup(i) - pup(i)) 454 447 END IF 455 !JYG>448 !JYG> 456 449 END IF 457 450 END DO 458 !jyg20140217<459 ! For the last iteration, make sure that the top of the feeding layer460 ! and LCL are not in the same layer:451 !jyg20140217< 452 ! For the last iteration, make sure that the top of the feeding layer 453 ! and LCL are not in the same layer: 461 454 IF (ok_new_feed) THEN 462 455 IF (iter==niter) THEN 463 DO i = 1, len !jyg464 pfeedmin(i) = ph(i, minorig+1) !jyg456 DO i = 1, len !jyg 457 pfeedmin(i) = ph(i, minorig + 1) !jyg 465 458 ENDDO !jyg 466 DO k = minorig +1, nl !jyg467 !! DO k = minorig, nl !jyg459 DO k = minorig + 1, nl !jyg 460 !! DO k = minorig, nl !jyg 468 461 DO i = 1, len 469 IF (ph(i, k)>=plclfeed(i)) pfeedmin(i) = ph(i, k)462 IF (ph(i, k)>=plclfeed(i)) pfeedmin(i) = ph(i, k) 470 463 END DO 471 464 END DO … … 475 468 END IF 476 469 END IF 477 !jyg>478 479 IF (fl_cor_ebil >=2 470 !jyg> 471 472 IF (fl_cor_ebil >=2) THEN 480 473 CALL cv3_estatmix(len, nd, iflag, p1feed, pfeed, p, ph, & 481 482 474 t, q, u, v, h, gz, wght, & 475 wghti, nk, tnk, thnk, qnk, qsnk, unk, vnk, plclfeed) 483 476 ELSE 484 477 CALL cv3_enthalpmix(len, nd, iflag, p1feed, pfeed, p, ph, & 485 486 487 ENDIF ! (fl_cor_ebil >=2 ) 488 !jyg20140217<478 t, q, u, v, wght, & 479 wghti, nk, tnk, thnk, qnk, qsnk, unk, vnk, plclfeed) 480 ENDIF ! (fl_cor_ebil >=2 ) 481 !jyg20140217< 489 482 IF (ok_new_feed) THEN 490 483 DO i = 1, len 491 posit(i) = (sign(1., plclfeed(i)-pfeed(i)+dp_lcl_feed)+1.)*0.5492 IF (plclfeed(i) -pfeed(i)+dp_lcl_feed==0.) posit(i) = 1.484 posit(i) = (sign(1., plclfeed(i) - pfeed(i) + dp_lcl_feed) + 1.) * 0.5 485 IF (plclfeed(i) - pfeed(i) + dp_lcl_feed==0.) posit(i) = 1. 493 486 END DO 494 487 ELSE 495 488 DO i = 1, len 496 posit(i) = (sign(1., plclfeed(i)-pfeed(i))+1.)*0.5489 posit(i) = (sign(1., plclfeed(i) - pfeed(i)) + 1.) * 0.5 497 490 IF (plclfeed(i)==pfeed(i)) posit(i) = 1. 498 491 END DO 499 492 END IF 500 !jyg>493 !jyg> 501 494 DO i = 1, len 502 ! - posit = 1 when lcl is below top of feeding layer (plclfeed>pfeed)503 ! - => pup=pfeed504 ! - posit = 0 when lcl is above top of feeding layer (plclfeed<pfeed)505 ! - => plo=pfeed506 pup(i) = posit(i) *pfeed(i) + (1.-posit(i))*pup(i)507 plo(i) = (1. -posit(i))*pfeed(i) + posit(i)*plo(i)508 plclup(i) = posit(i) *plclfeed(i) + (1.-posit(i))*plclup(i)509 plcllo(i) = (1. -posit(i))*plclfeed(i) + posit(i)*plcllo(i)495 ! - posit = 1 when lcl is below top of feeding layer (plclfeed>pfeed) 496 ! - => pup=pfeed 497 ! - posit = 0 when lcl is above top of feeding layer (plclfeed<pfeed) 498 ! - => plo=pfeed 499 pup(i) = posit(i) * pfeed(i) + (1. - posit(i)) * pup(i) 500 plo(i) = (1. - posit(i)) * pfeed(i) + posit(i) * plo(i) 501 plclup(i) = posit(i) * plclfeed(i) + (1. - posit(i)) * plclup(i) 502 plcllo(i) = (1. - posit(i)) * plclfeed(i) + posit(i) * plcllo(i) 510 503 END DO 511 504 END DO ! iter … … 517 510 518 511 DO i = 1, len 519 cpnk(i) = cpd *(1.0-qnk(i)) + cpv*qnk(i)520 hnk(i) = gz(i, 1) + cpnk(i) *tnk(i)521 END DO 522 523 ! -------------------------------------------------------------------524 ! --- Check whether parcel level temperature and specific humidity525 ! --- are reasonable526 ! -------------------------------------------------------------------512 cpnk(i) = cpd * (1.0 - qnk(i)) + cpv * qnk(i) 513 hnk(i) = gz(i, 1) + cpnk(i) * tnk(i) 514 END DO 515 516 ! ------------------------------------------------------------------- 517 ! --- Check whether parcel level temperature and specific humidity 518 ! --- are reasonable 519 ! ------------------------------------------------------------------- 527 520 IF (cv_flag_feed == 1) THEN 528 521 DO i = 1, len 529 522 IF (((tnk(i)<250.0) .OR. & 530 (qnk(i)<=0.0)) .AND. &531 (iflag(i)==0)) iflag(i) = 7523 (qnk(i)<=0.0)) .AND. & 524 (iflag(i)==0)) iflag(i) = 7 532 525 END DO 533 526 ELSEIF (cv_flag_feed >= 2) THEN 534 ! --- and demand that LCL be high enough527 ! --- and demand that LCL be high enough 535 528 DO i = 1, len 536 529 IF (((tnk(i)<250.0) .OR. & 537 (qnk(i)<=0.0) .OR. &538 (plcl(i)>min(0.99*ph(i,1),ph(i,3)))) .AND. &539 (iflag(i)==0)) iflag(i) = 7530 (qnk(i)<=0.0) .OR. & 531 (plcl(i)>min(0.99 * ph(i, 1), ph(i, 3)))) .AND. & 532 (iflag(i)==0)) iflag(i) = 7 540 533 END DO 541 534 ENDIF 542 535 IF (prt_level >= 10) THEN 543 print *, 'cv3_feed : iflag(1), pfeed(1), plcl(1), wghti(1,k) ', &544 iflag(1), pfeed(1), plcl(1), (wghti(1,k),k=1,10)536 print *, 'cv3_feed : iflag(1), pfeed(1), plcl(1), wghti(1,k) ', & 537 iflag(1), pfeed(1), plcl(1), (wghti(1, k), k = 1, 10) 545 538 ENDIF 546 539 547 ! -------------------------------------------------------------------548 ! --- Calculate first level above lcl (=icb)549 ! -------------------------------------------------------------------550 551 !@ do 270 i=1,len552 !@ icb(i)=nlm553 !@ 270 continue554 !@c555 !@ do 290 k=minorig,nl556 !@ do 280 i=1,len557 !@ if((k.ge.(nk(i)+1)).AND.(p(i,k).lt.plcl(i)))558 !@ & icb(i)=min(icb(i),k)559 !@ 280 continue560 !@ 290 continue561 !@c562 !@ do 300 i=1,len563 !@ if((icb(i).ge.nlm).AND.(iflag(i).EQ.0))iflag(i)=9564 !@ 300 continue540 ! ------------------------------------------------------------------- 541 ! --- Calculate first level above lcl (=icb) 542 ! ------------------------------------------------------------------- 543 544 !@ do 270 i=1,len 545 !@ icb(i)=nlm 546 !@ 270 continue 547 !@c 548 !@ do 290 k=minorig,nl 549 !@ do 280 i=1,len 550 !@ if((k.ge.(nk(i)+1)).AND.(p(i,k).lt.plcl(i))) 551 !@ & icb(i)=min(icb(i),k) 552 !@ 280 continue 553 !@ 290 continue 554 !@c 555 !@ do 300 i=1,len 556 !@ if((icb(i).ge.nlm).AND.(iflag(i).EQ.0))iflag(i)=9 557 !@ 300 continue 565 558 566 559 DO i = 1, len … … 568 561 END DO 569 562 570 ! la modification consiste a comparer plcl a ph et non a p:571 ! icb est defini par : ph(icb)<plcl<ph(icb-1)572 !@ do 290 k=minorig,nl563 ! la modification consiste a comparer plcl a ph et non a p: 564 ! icb est defini par : ph(icb)<plcl<ph(icb-1) 565 !@ do 290 k=minorig,nl 573 566 DO k = 3, nl - 1 ! modif pour que icb soit sup/egal a 2 574 567 DO i = 1, len 575 IF (ph(i, k)<plcl(i)) icb(i) = min(icb(i), k)576 END DO 577 END DO 578 579 580 ! PRINT*,'icb dans cv3_feed '581 ! WRITE(*,'(64i2)') icb(2:len-1)582 ! CALL dump2d(64,43,'plcl dans cv3_feed ',plcl(2:len-1))568 IF (ph(i, k)<plcl(i)) icb(i) = min(icb(i), k) 569 END DO 570 END DO 571 572 573 ! PRINT*,'icb dans cv3_feed ' 574 ! WRITE(*,'(64i2)') icb(2:len-1) 575 ! CALL dump2d(64,43,'plcl dans cv3_feed ',plcl(2:len-1)) 583 576 584 577 DO i = 1, len 585 !@ if((icb(i).ge.nlm).AND.(iflag(i).EQ.0))iflag(i)=9578 !@ if((icb(i).ge.nlm).AND.(iflag(i).EQ.0))iflag(i)=9 586 579 IF ((icb(i)==nlm) .AND. (iflag(i)==0)) iflag(i) = 9 587 580 END DO … … 591 584 END DO 592 585 593 ! Compute icbmax.586 ! Compute icbmax. 594 587 595 588 icbmax = 2 596 589 DO i = 1, len 597 !! icbmax=max(icbmax,icb(i))590 !! icbmax=max(icbmax,icb(i)) 598 591 IF (iflag(i)<7) icbmax = max(icbmax, icb(i)) ! sb Jun7th02 599 592 END DO 600 593 601 602 594 END SUBROUTINE cv3_feed 603 595 604 596 SUBROUTINE cv3_undilute1(len, nd, t, qs, gz, plcl, p, icb, tnk, qnk, gznk, & 605 tp, tvp, clw, icbs) 597 tp, tvp, clw, icbs) 598 USE lmdz_cvthermo 599 USE lmdz_cv3param 600 606 601 IMPLICIT NONE 607 602 608 ! ---------------------------------------------------------------- 609 ! Equivalent de TLIFT entre NK et ICB+1 inclus 610 611 ! Differences with convect4: 612 ! - specify plcl in input 613 ! - icbs is the first level above LCL (may differ from icb) 614 ! - in the iterations, used x(icbs) instead x(icb) 615 ! - many minor differences in the iterations 616 ! - tvp is computed in only one time 617 ! - icbs: first level above Plcl (IMIN de TLIFT) in output 618 ! - if icbs=icb, compute also tp(icb+1),tvp(icb+1) & clw(icb+1) 619 ! ---------------------------------------------------------------- 620 621 include "cvthermo.h" 622 include "cv3param.h" 623 624 ! inputs: 625 INTEGER, INTENT (IN) :: len, nd 626 INTEGER, DIMENSION (len), INTENT (IN) :: icb 627 REAL, DIMENSION (len, nd), INTENT (IN) :: t, qs, gz 628 REAL, DIMENSION (len), INTENT (IN) :: tnk, qnk, gznk 629 REAL, DIMENSION (len, nd), INTENT (IN) :: p 630 REAL, DIMENSION (len), INTENT (IN) :: plcl ! convect3 631 632 ! outputs: 633 INTEGER, DIMENSION (len), INTENT (OUT) :: icbs 634 REAL, DIMENSION (len, nd), INTENT (OUT) :: tp, tvp, clw 635 636 ! local variables: 603 ! ---------------------------------------------------------------- 604 ! Equivalent de TLIFT entre NK et ICB+1 inclus 605 606 ! Differences with convect4: 607 ! - specify plcl in input 608 ! - icbs is the first level above LCL (may differ from icb) 609 ! - in the iterations, used x(icbs) instead x(icb) 610 ! - many minor differences in the iterations 611 ! - tvp is computed in only one time 612 ! - icbs: first level above Plcl (IMIN de TLIFT) in output 613 ! - if icbs=icb, compute also tp(icb+1),tvp(icb+1) & clw(icb+1) 614 ! ---------------------------------------------------------------- 615 616 ! inputs: 617 INTEGER, INTENT (IN) :: len, nd 618 INTEGER, DIMENSION (len), INTENT (IN) :: icb 619 REAL, DIMENSION (len, nd), INTENT (IN) :: t, qs, gz 620 REAL, DIMENSION (len), INTENT (IN) :: tnk, qnk, gznk 621 REAL, DIMENSION (len, nd), INTENT (IN) :: p 622 REAL, DIMENSION (len), INTENT (IN) :: plcl ! convect3 623 624 ! outputs: 625 INTEGER, DIMENSION (len), INTENT (OUT) :: icbs 626 REAL, DIMENSION (len, nd), INTENT (OUT) :: tp, tvp, clw 627 628 ! local variables: 637 629 INTEGER i, k 638 630 INTEGER icb1(len), icbsmax2 ! convect3 … … 643 635 REAL cpinv(len) ! convect3 644 636 645 ! -------------------------------------------------------------------646 ! --- Calculates the lifted parcel virtual temperature at nk,647 ! --- the actual temperature, and the adiabatic648 ! --- liquid water content. The procedure is to solve the equation.649 ! cp*tp+L*qp+phi=cp*tnk+L*qnk+gznk.650 ! -------------------------------------------------------------------651 652 653 ! *** Calculate certain parcel quantities, including static energy ***637 ! ------------------------------------------------------------------- 638 ! --- Calculates the lifted parcel virtual temperature at nk, 639 ! --- the actual temperature, and the adiabatic 640 ! --- liquid water content. The procedure is to solve the equation. 641 ! cp*tp+L*qp+phi=cp*tnk+L*qnk+gznk. 642 ! ------------------------------------------------------------------- 643 644 645 ! *** Calculate certain parcel quantities, including static energy *** 654 646 655 647 DO i = 1, len 656 ah0(i) = (cpd *(1.-qnk(i))+cl*qnk(i))*tnk(i) + qnk(i)*(lv0-clmcpv*(tnk(i)-273.15)) + gznk(i)657 cpp(i) = cpd *(1.-qnk(i)) + qnk(i)*cpv658 cpinv(i) = 1. /cpp(i)659 END DO 660 661 ! *** Calculate lifted parcel quantities below cloud base ***648 ah0(i) = (cpd * (1. - qnk(i)) + cl * qnk(i)) * tnk(i) + qnk(i) * (lv0 - clmcpv * (tnk(i) - 273.15)) + gznk(i) 649 cpp(i) = cpd * (1. - qnk(i)) + qnk(i) * cpv 650 cpinv(i) = 1. / cpp(i) 651 END DO 652 653 ! *** Calculate lifted parcel quantities below cloud base *** 662 654 663 655 DO i = 1, len !convect3 664 656 icb1(i) = min(max(icb(i), 2), nl) 665 ! if icb is below LCL, start loop at ICB+1:666 ! (icbs est le premier niveau au-dessus du LCL)657 ! if icb is below LCL, start loop at ICB+1: 658 ! (icbs est le premier niveau au-dessus du LCL) 667 659 icbs(i) = icb1(i) !convect3 668 IF (plcl(i)<p(i, icb1(i))) THEN669 icbs(i) = min(icbs(i) +1, nl) !convect3660 IF (plcl(i)<p(i, icb1(i))) THEN 661 icbs(i) = min(icbs(i) + 1, nl) !convect3 670 662 END IF 671 663 END DO !convect3 … … 678 670 679 671 680 ! Re-compute icbsmax (icbsmax2): !convect3681 ! !convect3672 ! Re-compute icbsmax (icbsmax2): !convect3 673 ! !convect3 682 674 icbsmax2 = 2 !convect3 683 675 DO i = 1, len !convect3 … … 685 677 END DO !convect3 686 678 687 ! initialization outputs:679 ! initialization outputs: 688 680 689 681 DO k = 1, icbsmax2 ! convect3 … … 695 687 END DO ! convect3 696 688 697 ! tp and tvp below cloud base:689 ! tp and tvp below cloud base: 698 690 699 691 DO k = minorig, icbsmax2 - 1 700 692 DO i = 1, len 701 tp(i, k) = tnk(i) - (gz(i, k)-gznk(i))*cpinv(i)702 tvp(i, k) = tp(i, k) *(1.+qnk(i)/eps-qnk(i)) !whole thing (convect3)703 END DO 704 END DO 705 706 ! *** Find lifted parcel quantities above cloud base ***693 tp(i, k) = tnk(i) - (gz(i, k) - gznk(i)) * cpinv(i) 694 tvp(i, k) = tp(i, k) * (1. + qnk(i) / eps - qnk(i)) !whole thing (convect3) 695 END DO 696 END DO 697 698 ! *** Find lifted parcel quantities above cloud base *** 707 699 708 700 DO i = 1, len 709 701 tg = ticb(i) 710 ! ori qg=qs(i,icb(i))702 ! ori qg=qs(i,icb(i)) 711 703 qg = qsicb(i) ! convect3 712 ! debug alv=lv0-clmcpv*(ticb(i)-t0)713 alv = lv0 - clmcpv *(ticb(i)-273.15)714 715 ! First iteration.716 717 ! ori s=cpd+alv*alv*qg/(rrv*ticb(i)*ticb(i))718 s = cpd *(1.-qnk(i)) + cl*qnk(i) + & ! convect3719 alv*alv*qg/(rrv*ticb(i)*ticb(i)) ! convect3720 s = 1. /s721 ! ori ahg=cpd*tg+(cl-cpd)*qnk(i)*ticb(i)+alv*qg+gzicb(i)722 ahg = cpd *tg + (cl-cpd)*qnk(i)*tg + alv*qg + gzicb(i) ! convect3723 tg = tg + s *(ah0(i)-ahg)724 ! ori tg=max(tg,35.0)725 ! debug tc=tg-t0704 ! debug alv=lv0-clmcpv*(ticb(i)-t0) 705 alv = lv0 - clmcpv * (ticb(i) - 273.15) 706 707 ! First iteration. 708 709 ! ori s=cpd+alv*alv*qg/(rrv*ticb(i)*ticb(i)) 710 s = cpd * (1. - qnk(i)) + cl * qnk(i) + & ! convect3 711 alv * alv * qg / (rrv * ticb(i) * ticb(i)) ! convect3 712 s = 1. / s 713 ! ori ahg=cpd*tg+(cl-cpd)*qnk(i)*ticb(i)+alv*qg+gzicb(i) 714 ahg = cpd * tg + (cl - cpd) * qnk(i) * tg + alv * qg + gzicb(i) ! convect3 715 tg = tg + s * (ah0(i) - ahg) 716 ! ori tg=max(tg,35.0) 717 ! debug tc=tg-t0 726 718 tc = tg - 273.15 727 719 denom = 243.5 + tc 728 720 denom = max(denom, 1.0) ! convect3 729 ! ori IF(tc.ge.0.0)THEN730 es = 6.112 *exp(17.67*tc/denom)731 ! ori else732 ! ori es=exp(23.33086-6111.72784/tg+0.15215*log(tg))733 ! ori endif734 ! ori qg=eps*es/(p(i,icb(i))-es*(1.-eps))735 qg = eps *es/(p(i,icbs(i))-es*(1.-eps))736 737 ! Second iteration.738 739 740 ! ori s=cpd+alv*alv*qg/(rrv*ticb(i)*ticb(i))741 ! ori s=1./s742 ! ori ahg=cpd*tg+(cl-cpd)*qnk(i)*ticb(i)+alv*qg+gzicb(i)743 ahg = cpd *tg + (cl-cpd)*qnk(i)*tg + alv*qg + gzicb(i) ! convect3744 tg = tg + s *(ah0(i)-ahg)745 ! ori tg=max(tg,35.0)746 ! debug tc=tg-t0721 ! ori IF(tc.ge.0.0)THEN 722 es = 6.112 * exp(17.67 * tc / denom) 723 ! ori else 724 ! ori es=exp(23.33086-6111.72784/tg+0.15215*log(tg)) 725 ! ori endif 726 ! ori qg=eps*es/(p(i,icb(i))-es*(1.-eps)) 727 qg = eps * es / (p(i, icbs(i)) - es * (1. - eps)) 728 729 ! Second iteration. 730 731 732 ! ori s=cpd+alv*alv*qg/(rrv*ticb(i)*ticb(i)) 733 ! ori s=1./s 734 ! ori ahg=cpd*tg+(cl-cpd)*qnk(i)*ticb(i)+alv*qg+gzicb(i) 735 ahg = cpd * tg + (cl - cpd) * qnk(i) * tg + alv * qg + gzicb(i) ! convect3 736 tg = tg + s * (ah0(i) - ahg) 737 ! ori tg=max(tg,35.0) 738 ! debug tc=tg-t0 747 739 tc = tg - 273.15 748 740 denom = 243.5 + tc 749 741 denom = max(denom, 1.0) ! convect3 750 ! ori IF(tc.ge.0.0)THEN751 es = 6.112 *exp(17.67*tc/denom)752 ! ori else753 ! ori es=exp(23.33086-6111.72784/tg+0.15215*log(tg))754 ! ori end if755 ! ori qg=eps*es/(p(i,icb(i))-es*(1.-eps))756 qg = eps *es/(p(i,icbs(i))-es*(1.-eps))757 758 alv = lv0 - clmcpv *(ticb(i)-273.15)759 760 ! ori c approximation here:761 ! ori tp(i,icb(i))=(ah0(i)-(cl-cpd)*qnk(i)*ticb(i)762 ! ori & -gz(i,icb(i))-alv*qg)/cpd763 764 ! convect3: no approximation:765 tp(i, icbs(i)) = (ah0(i) -gz(i,icbs(i))-alv*qg)/(cpd+(cl-cpd)*qnk(i))766 767 ! ori clw(i,icb(i))=qnk(i)-qg768 ! ori clw(i,icb(i))=max(0.0,clw(i,icb(i)))742 ! ori IF(tc.ge.0.0)THEN 743 es = 6.112 * exp(17.67 * tc / denom) 744 ! ori else 745 ! ori es=exp(23.33086-6111.72784/tg+0.15215*log(tg)) 746 ! ori end if 747 ! ori qg=eps*es/(p(i,icb(i))-es*(1.-eps)) 748 qg = eps * es / (p(i, icbs(i)) - es * (1. - eps)) 749 750 alv = lv0 - clmcpv * (ticb(i) - 273.15) 751 752 ! ori c approximation here: 753 ! ori tp(i,icb(i))=(ah0(i)-(cl-cpd)*qnk(i)*ticb(i) 754 ! ori & -gz(i,icb(i))-alv*qg)/cpd 755 756 ! convect3: no approximation: 757 tp(i, icbs(i)) = (ah0(i) - gz(i, icbs(i)) - alv * qg) / (cpd + (cl - cpd) * qnk(i)) 758 759 ! ori clw(i,icb(i))=qnk(i)-qg 760 ! ori clw(i,icb(i))=max(0.0,clw(i,icb(i))) 769 761 clw(i, icbs(i)) = qnk(i) - qg 770 clw(i, icbs(i)) = max(0.0, clw(i,icbs(i))) 771 772 rg = qg/(1.-qnk(i)) 773 ! ori tvp(i,icb(i))=tp(i,icb(i))*(1.+rg*epsi) 774 ! convect3: (qg utilise au lieu du vrai mixing ratio rg) 775 tvp(i, icbs(i)) = tp(i, icbs(i))*(1.+qg/eps-qnk(i)) !whole thing 776 777 END DO 778 779 ! ori do 380 k=minorig,icbsmax2 780 ! ori do 370 i=1,len 781 ! ori tvp(i,k)=tvp(i,k)-tp(i,k)*qnk(i) 782 ! ori 370 continue 783 ! ori 380 continue 784 785 786 ! -- The following is only for convect3: 787 788 ! * icbs is the first level above the LCL: 789 ! if plcl<p(icb), then icbs=icb+1 790 ! if plcl>p(icb), then icbs=icb 791 792 ! * the routine above computes tvp from minorig to icbs (included). 793 794 ! * to compute buoybase (in cv3_trigger.F), both tvp(icb) and tvp(icb+1) 795 ! must be known. This is the case if icbs=icb+1, but not if icbs=icb. 796 797 ! * therefore, in the case icbs=icb, we compute tvp at level icb+1 798 ! (tvp at other levels will be computed in cv3_undilute2.F) 799 762 clw(i, icbs(i)) = max(0.0, clw(i, icbs(i))) 763 764 rg = qg / (1. - qnk(i)) 765 ! ori tvp(i,icb(i))=tp(i,icb(i))*(1.+rg*epsi) 766 ! convect3: (qg utilise au lieu du vrai mixing ratio rg) 767 tvp(i, icbs(i)) = tp(i, icbs(i)) * (1. + qg / eps - qnk(i)) !whole thing 768 769 END DO 770 771 ! ori do 380 k=minorig,icbsmax2 772 ! ori do 370 i=1,len 773 ! ori tvp(i,k)=tvp(i,k)-tp(i,k)*qnk(i) 774 ! ori 370 continue 775 ! ori 380 continue 776 777 778 ! -- The following is only for convect3: 779 780 ! * icbs is the first level above the LCL: 781 ! if plcl<p(icb), then icbs=icb+1 782 ! if plcl>p(icb), then icbs=icb 783 784 ! * the routine above computes tvp from minorig to icbs (included). 785 786 ! * to compute buoybase (in cv3_trigger.F), both tvp(icb) and tvp(icb+1) 787 ! must be known. This is the case if icbs=icb+1, but not if icbs=icb. 788 789 ! * therefore, in the case icbs=icb, we compute tvp at level icb+1 790 ! (tvp at other levels will be computed in cv3_undilute2.F) 800 791 801 792 DO i = 1, len 802 ticb(i) = t(i, icb(i) +1)803 gzicb(i) = gz(i, icb(i) +1)804 qsicb(i) = qs(i, icb(i) +1)793 ticb(i) = t(i, icb(i) + 1) 794 gzicb(i) = gz(i, icb(i) + 1) 795 qsicb(i) = qs(i, icb(i) + 1) 805 796 END DO 806 797 … … 808 799 tg = ticb(i) 809 800 qg = qsicb(i) ! convect3 810 ! debug alv=lv0-clmcpv*(ticb(i)-t0)811 alv = lv0 - clmcpv *(ticb(i)-273.15)812 813 ! First iteration.814 815 ! ori s=cpd+alv*alv*qg/(rrv*ticb(i)*ticb(i))816 s = cpd *(1.-qnk(i)) + cl*qnk(i) & ! convect3817 +alv*alv*qg/(rrv*ticb(i)*ticb(i)) ! convect3818 s = 1. /s819 ! ori ahg=cpd*tg+(cl-cpd)*qnk(i)*ticb(i)+alv*qg+gzicb(i)820 ahg = cpd *tg + (cl-cpd)*qnk(i)*tg + alv*qg + gzicb(i) ! convect3821 tg = tg + s *(ah0(i)-ahg)822 ! ori tg=max(tg,35.0)823 ! debug tc=tg-t0801 ! debug alv=lv0-clmcpv*(ticb(i)-t0) 802 alv = lv0 - clmcpv * (ticb(i) - 273.15) 803 804 ! First iteration. 805 806 ! ori s=cpd+alv*alv*qg/(rrv*ticb(i)*ticb(i)) 807 s = cpd * (1. - qnk(i)) + cl * qnk(i) & ! convect3 808 + alv * alv * qg / (rrv * ticb(i) * ticb(i)) ! convect3 809 s = 1. / s 810 ! ori ahg=cpd*tg+(cl-cpd)*qnk(i)*ticb(i)+alv*qg+gzicb(i) 811 ahg = cpd * tg + (cl - cpd) * qnk(i) * tg + alv * qg + gzicb(i) ! convect3 812 tg = tg + s * (ah0(i) - ahg) 813 ! ori tg=max(tg,35.0) 814 ! debug tc=tg-t0 824 815 tc = tg - 273.15 825 816 denom = 243.5 + tc 826 817 denom = max(denom, 1.0) ! convect3 827 ! ori IF(tc.ge.0.0)THEN828 es = 6.112 *exp(17.67*tc/denom)829 ! ori else830 ! ori es=exp(23.33086-6111.72784/tg+0.15215*log(tg))831 ! ori endif832 ! ori qg=eps*es/(p(i,icb(i))-es*(1.-eps))833 qg = eps *es/(p(i,icb(i)+1)-es*(1.-eps))834 835 ! Second iteration.836 837 838 ! ori s=cpd+alv*alv*qg/(rrv*ticb(i)*ticb(i))839 ! ori s=1./s840 ! ori ahg=cpd*tg+(cl-cpd)*qnk(i)*ticb(i)+alv*qg+gzicb(i)841 ahg = cpd *tg + (cl-cpd)*qnk(i)*tg + alv*qg + gzicb(i) ! convect3842 tg = tg + s *(ah0(i)-ahg)843 ! ori tg=max(tg,35.0)844 ! debug tc=tg-t0818 ! ori IF(tc.ge.0.0)THEN 819 es = 6.112 * exp(17.67 * tc / denom) 820 ! ori else 821 ! ori es=exp(23.33086-6111.72784/tg+0.15215*log(tg)) 822 ! ori endif 823 ! ori qg=eps*es/(p(i,icb(i))-es*(1.-eps)) 824 qg = eps * es / (p(i, icb(i) + 1) - es * (1. - eps)) 825 826 ! Second iteration. 827 828 829 ! ori s=cpd+alv*alv*qg/(rrv*ticb(i)*ticb(i)) 830 ! ori s=1./s 831 ! ori ahg=cpd*tg+(cl-cpd)*qnk(i)*ticb(i)+alv*qg+gzicb(i) 832 ahg = cpd * tg + (cl - cpd) * qnk(i) * tg + alv * qg + gzicb(i) ! convect3 833 tg = tg + s * (ah0(i) - ahg) 834 ! ori tg=max(tg,35.0) 835 ! debug tc=tg-t0 845 836 tc = tg - 273.15 846 837 denom = 243.5 + tc 847 838 denom = max(denom, 1.0) ! convect3 848 ! ori IF(tc.ge.0.0)THEN 849 es = 6.112*exp(17.67*tc/denom) 850 ! ori else 851 ! ori es=exp(23.33086-6111.72784/tg+0.15215*log(tg)) 852 ! ori end if 853 ! ori qg=eps*es/(p(i,icb(i))-es*(1.-eps)) 854 qg = eps*es/(p(i,icb(i)+1)-es*(1.-eps)) 855 856 alv = lv0 - clmcpv*(ticb(i)-273.15) 857 858 ! ori c approximation here: 859 ! ori tp(i,icb(i))=(ah0(i)-(cl-cpd)*qnk(i)*ticb(i) 860 ! ori & -gz(i,icb(i))-alv*qg)/cpd 861 862 ! convect3: no approximation: 863 tp(i, icb(i)+1) = (ah0(i)-gz(i,icb(i)+1)-alv*qg)/(cpd+(cl-cpd)*qnk(i)) 864 865 ! ori clw(i,icb(i))=qnk(i)-qg 866 ! ori clw(i,icb(i))=max(0.0,clw(i,icb(i))) 867 clw(i, icb(i)+1) = qnk(i) - qg 868 clw(i, icb(i)+1) = max(0.0, clw(i,icb(i)+1)) 869 870 rg = qg/(1.-qnk(i)) 871 ! ori tvp(i,icb(i))=tp(i,icb(i))*(1.+rg*epsi) 872 ! convect3: (qg utilise au lieu du vrai mixing ratio rg) 873 tvp(i, icb(i)+1) = tp(i, icb(i)+1)*(1.+qg/eps-qnk(i)) !whole thing 874 875 END DO 876 839 ! ori IF(tc.ge.0.0)THEN 840 es = 6.112 * exp(17.67 * tc / denom) 841 ! ori else 842 ! ori es=exp(23.33086-6111.72784/tg+0.15215*log(tg)) 843 ! ori end if 844 ! ori qg=eps*es/(p(i,icb(i))-es*(1.-eps)) 845 qg = eps * es / (p(i, icb(i) + 1) - es * (1. - eps)) 846 847 alv = lv0 - clmcpv * (ticb(i) - 273.15) 848 849 ! ori c approximation here: 850 ! ori tp(i,icb(i))=(ah0(i)-(cl-cpd)*qnk(i)*ticb(i) 851 ! ori & -gz(i,icb(i))-alv*qg)/cpd 852 853 ! convect3: no approximation: 854 tp(i, icb(i) + 1) = (ah0(i) - gz(i, icb(i) + 1) - alv * qg) / (cpd + (cl - cpd) * qnk(i)) 855 856 ! ori clw(i,icb(i))=qnk(i)-qg 857 ! ori clw(i,icb(i))=max(0.0,clw(i,icb(i))) 858 clw(i, icb(i) + 1) = qnk(i) - qg 859 clw(i, icb(i) + 1) = max(0.0, clw(i, icb(i) + 1)) 860 861 rg = qg / (1. - qnk(i)) 862 ! ori tvp(i,icb(i))=tp(i,icb(i))*(1.+rg*epsi) 863 ! convect3: (qg utilise au lieu du vrai mixing ratio rg) 864 tvp(i, icb(i) + 1) = tp(i, icb(i) + 1) * (1. + qg / eps - qnk(i)) !whole thing 865 866 END DO 877 867 878 868 END SUBROUTINE cv3_undilute1 879 869 880 870 SUBROUTINE cv3_trigger(len, nd, icb, plcl, p, th, tv, tvp, thnk, & 881 pbase, buoybase, iflag, sig, w0) 871 pbase, buoybase, iflag, sig, w0) 872 USE lmdz_cv3param 873 882 874 IMPLICIT NONE 883 875 884 ! ------------------------------------------------------------------- 885 ! --- TRIGGERING 886 887 ! - computes the cloud base 888 ! - triggering (crude in this version) 889 ! - relaxation of sig and w0 when no convection 890 891 ! Caution1: if no convection, we set iflag=14 892 ! (it used to be 0 in convect3) 893 894 ! Caution2: at this stage, tvp (and thus buoy) are know up 895 ! through icb only! 896 ! -> the buoyancy below cloud base not (yet) set to the cloud base buoyancy 897 ! ------------------------------------------------------------------- 898 899 include "cv3param.h" 900 901 ! input: 876 ! ------------------------------------------------------------------- 877 ! --- TRIGGERING 878 879 ! - computes the cloud base 880 ! - triggering (crude in this version) 881 ! - relaxation of sig and w0 when no convection 882 883 ! Caution1: if no convection, we set iflag=14 884 ! (it used to be 0 in convect3) 885 886 ! Caution2: at this stage, tvp (and thus buoy) are know up 887 ! through icb only! 888 ! -> the buoyancy below cloud base not (yet) set to the cloud base buoyancy 889 ! ------------------------------------------------------------------- 890 891 ! input: 902 892 INTEGER len, nd 903 893 INTEGER icb(len) … … 906 896 REAL thnk(len) 907 897 908 ! output:898 ! output: 909 899 REAL pbase(len), buoybase(len) 910 900 911 ! input AND output:901 ! input AND output: 912 902 INTEGER iflag(len) 913 903 REAL sig(len, nd), w0(len, nd) 914 904 915 ! local variables:905 ! local variables: 916 906 INTEGER i, k 917 907 REAL tvpbase, tvbase, tdif, ath, ath1 918 908 919 909 920 ! *** set cloud base buoyancy at (plcl+dpbase) level buoyancy910 ! *** set cloud base buoyancy at (plcl+dpbase) level buoyancy 921 911 922 912 DO i = 1, len 923 913 pbase(i) = plcl(i) + dpbase 924 tvpbase = tvp(i, icb(i)) *(pbase(i)-p(i,icb(i)+1))/(p(i,icb(i))-p(i,icb(i)+1)) + &925 tvp(i, icb(i)+1)*(p(i,icb(i))-pbase(i)) /(p(i,icb(i))-p(i,icb(i)+1))926 tvbase = tv(i, icb(i)) *(pbase(i)-p(i,icb(i)+1))/(p(i,icb(i))-p(i,icb(i)+1)) + &927 tv(i, icb(i)+1)*(p(i,icb(i))-pbase(i)) /(p(i,icb(i))-p(i,icb(i)+1))914 tvpbase = tvp(i, icb(i)) * (pbase(i) - p(i, icb(i) + 1)) / (p(i, icb(i)) - p(i, icb(i) + 1)) + & 915 tvp(i, icb(i) + 1) * (p(i, icb(i)) - pbase(i)) / (p(i, icb(i)) - p(i, icb(i) + 1)) 916 tvbase = tv(i, icb(i)) * (pbase(i) - p(i, icb(i) + 1)) / (p(i, icb(i)) - p(i, icb(i) + 1)) + & 917 tv(i, icb(i) + 1) * (p(i, icb(i)) - pbase(i)) / (p(i, icb(i)) - p(i, icb(i) + 1)) 928 918 buoybase(i) = tvpbase - tvbase 929 919 END DO 930 920 931 921 932 ! *** make sure that column is dry adiabatic between the surface ***933 ! *** and cloud base, and that lifted air is positively buoyant ***934 ! *** at cloud base ***935 ! *** if not, return to calling program after resetting ***936 ! *** sig(i) and w0(i) ***937 938 939 ! oct3 do 200 i=1,len940 ! oct3941 ! oct3 tdif = buoybase(i)942 ! oct3 ath1 = th(i,1)943 ! oct3 ath = th(i,icb(i)-1) - dttrig944 ! oct3945 ! oct3 if (tdif.lt.dtcrit .OR. ath.gt.ath1) THEN946 ! oct3 do 60 k=1,nl947 ! oct3 sig(i,k) = beta*sig(i,k) - 2.*alpha*tdif*tdif948 ! oct3 sig(i,k) = AMAX1(sig(i,k),0.0)949 ! oct3 w0(i,k) = beta*w0(i,k)950 ! oct3 60 continue951 ! oct3 iflag(i)=4 ! pour version vectorisee952 ! oct3c convect3 iflag(i)=0953 ! oct3cccc RETURN954 ! oct3 endif955 ! oct3956 ! oct3200 continue957 958 ! -- oct3: on reecrit la boucle 200 (pour la vectorisation)922 ! *** make sure that column is dry adiabatic between the surface *** 923 ! *** and cloud base, and that lifted air is positively buoyant *** 924 ! *** at cloud base *** 925 ! *** if not, return to calling program after resetting *** 926 ! *** sig(i) and w0(i) *** 927 928 929 ! oct3 do 200 i=1,len 930 ! oct3 931 ! oct3 tdif = buoybase(i) 932 ! oct3 ath1 = th(i,1) 933 ! oct3 ath = th(i,icb(i)-1) - dttrig 934 ! oct3 935 ! oct3 if (tdif.lt.dtcrit .OR. ath.gt.ath1) THEN 936 ! oct3 do 60 k=1,nl 937 ! oct3 sig(i,k) = beta*sig(i,k) - 2.*alpha*tdif*tdif 938 ! oct3 sig(i,k) = AMAX1(sig(i,k),0.0) 939 ! oct3 w0(i,k) = beta*w0(i,k) 940 ! oct3 60 continue 941 ! oct3 iflag(i)=4 ! pour version vectorisee 942 ! oct3c convect3 iflag(i)=0 943 ! oct3cccc RETURN 944 ! oct3 endif 945 ! oct3 946 ! oct3200 continue 947 948 ! -- oct3: on reecrit la boucle 200 (pour la vectorisation) 959 949 960 950 DO k = 1, nl … … 963 953 tdif = buoybase(i) 964 954 ath1 = thnk(i) 965 ath = th(i, icb(i) -1) - dttrig955 ath = th(i, icb(i) - 1) - dttrig 966 956 967 957 IF (tdif<dtcrit .OR. ath>ath1) THEN 968 sig(i, k) = beta *sig(i, k) - 2.*alpha*tdif*tdif969 sig(i, k) = amax1(sig(i, k), 0.0)970 w0(i, k) = beta *w0(i, k)958 sig(i, k) = beta * sig(i, k) - 2. * alpha * tdif * tdif 959 sig(i, k) = amax1(sig(i, k), 0.0) 960 w0(i, k) = beta * w0(i, k) 971 961 iflag(i) = 14 ! pour version vectorisee 972 ! convect3 iflag(i)=0962 ! convect3 iflag(i)=0 973 963 END IF 974 964 … … 976 966 END DO 977 967 978 ! fin oct3 -- 979 968 ! fin oct3 -- 980 969 981 970 END SUBROUTINE cv3_trigger 982 971 983 972 SUBROUTINE cv3_compress(len, nloc, ncum, nd, ntra, & 984 985 986 987 988 989 990 991 992 993 994 995 973 iflag1, nk1, icb1, icbs1, & 974 plcl1, tnk1, qnk1, gznk1, pbase1, buoybase1, & 975 t1, q1, qs1, u1, v1, gz1, th1, & 976 tra1, & 977 h1, lv1, cpn1, p1, ph1, tv1, tp1, tvp1, clw1, & 978 sig1, w01, & 979 iflag, nk, icb, icbs, & 980 plcl, tnk, qnk, gznk, pbase, buoybase, & 981 t, q, qs, u, v, gz, th, & 982 tra, & 983 h, lv, cpn, p, ph, tv, tp, tvp, clw, & 984 sig, w0) 996 985 USE lmdz_print_control, ONLY: lunout 997 986 USE lmdz_abort_physic, ONLY: abort_physic 987 USE lmdz_cv3param 988 998 989 IMPLICIT NONE 999 990 1000 include "cv3param.h" 1001 1002 !inputs: 991 !inputs: 1003 992 INTEGER len, ncum, nd, ntra, nloc 1004 993 INTEGER iflag1(len), nk1(len), icb1(len), icbs1(len) … … 1007 996 REAL t1(len, nd), q1(len, nd), qs1(len, nd), u1(len, nd), v1(len, nd) 1008 997 REAL gz1(len, nd), h1(len, nd), lv1(len, nd), cpn1(len, nd) 1009 REAL p1(len, nd), ph1(len, nd +1), tv1(len, nd), tp1(len, nd)998 REAL p1(len, nd), ph1(len, nd + 1), tv1(len, nd), tp1(len, nd) 1010 999 REAL tvp1(len, nd), clw1(len, nd) 1011 1000 REAL th1(len, nd) … … 1013 1002 REAL tra1(len, nd, ntra) 1014 1003 1015 !outputs:1016 ! en fait, on a nloc=len pour l'instant (cf cv_driver)1004 !outputs: 1005 ! en fait, on a nloc=len pour l'instant (cf cv_driver) 1017 1006 INTEGER iflag(nloc), nk(nloc), icb(nloc), icbs(nloc) 1018 1007 REAL plcl(nloc), tnk(nloc), qnk(nloc), gznk(nloc) … … 1020 1009 REAL t(nloc, nd), q(nloc, nd), qs(nloc, nd), u(nloc, nd), v(nloc, nd) 1021 1010 REAL gz(nloc, nd), h(nloc, nd), lv(nloc, nd), cpn(nloc, nd) 1022 REAL p(nloc, nd), ph(nloc, nd +1), tv(nloc, nd), tp(nloc, nd)1011 REAL p(nloc, nd), ph(nloc, nd + 1), tv(nloc, nd), tp(nloc, nd) 1023 1012 REAL tvp(nloc, nd), clw(nloc, nd) 1024 1013 REAL th(nloc, nd) … … 1026 1015 REAL tra(nloc, nd, ntra) 1027 1016 1028 !local variables:1017 !local variables: 1029 1018 INTEGER i, k, nn, j 1030 1019 1031 CHARACTER (LEN =20) :: modname = 'cv3_compress'1032 CHARACTER (LEN =80) :: abort_message1020 CHARACTER (LEN = 20) :: modname = 'cv3_compress' 1021 CHARACTER (LEN = 80) :: abort_message 1033 1022 1034 1023 DO k = 1, nl + 1 … … 1059 1048 END DO 1060 1049 1061 !AC! do 121 j=1,ntra1062 !AC!ccccc do 111 k=1,nl+11063 !AC! do 111 k=1,nd1064 !AC! nn=01065 !AC! do 101 i=1,len1066 !AC! IF(iflag1(i).EQ.0)THEN1067 !AC! nn=nn+11068 !AC! tra(nn,k,j)=tra1(i,k,j)1069 !AC! endif1070 !AC! 101 continue1071 !AC! 111 continue1072 !AC! 121 continue1050 !AC! do 121 j=1,ntra 1051 !AC!ccccc do 111 k=1,nl+1 1052 !AC! do 111 k=1,nd 1053 !AC! nn=0 1054 !AC! do 101 i=1,len 1055 !AC! IF(iflag1(i).EQ.0)THEN 1056 !AC! nn=nn+1 1057 !AC! tra(nn,k,j)=tra1(i,k,j) 1058 !AC! endif 1059 !AC! 101 continue 1060 !AC! 111 continue 1061 !AC! 121 continue 1073 1062 1074 1063 IF (nn/=ncum) THEN … … 1095 1084 END DO 1096 1085 1097 1098 1086 END SUBROUTINE cv3_compress 1099 1087 … … 1102 1090 1103 1091 1104 !JAM--------------------------------------------------------------------1105 ! Calcul de la quantité d'eau sous forme de glace1106 ! --------------------------------------------------------------------1092 !JAM-------------------------------------------------------------------- 1093 ! Calcul de la quantité d'eau sous forme de glace 1094 ! -------------------------------------------------------------------- 1107 1095 INTEGER nl, len 1108 1096 REAL qi(len, nl) … … 1113 1101 DO k = 3, nl 1114 1102 DO i = 1, len 1115 IF (t(i, k)>263.15) THEN1103 IF (t(i, k)>263.15) THEN 1116 1104 qi(i, k) = 0. 1117 1105 ELSE 1118 IF (t(i, k)<243.15) THEN1106 IF (t(i, k)<243.15) THEN 1119 1107 qi(i, k) = clw(i, k) 1120 1108 ELSE 1121 fracg = (263.15 -t(i,k))/201122 qi(i, k) = clw(i, k) *fracg1109 fracg = (263.15 - t(i, k)) / 20 1110 qi(i, k) = clw(i, k) * fracg 1123 1111 END IF 1124 1112 END IF 1125 ! PRINT*,t(i,k),qi(i,k),'temp,testglace' 1126 END DO 1127 END DO 1128 1129 1113 ! PRINT*,t(i,k),qi(i,k),'temp,testglace' 1114 END DO 1115 END DO 1130 1116 1131 1117 END SUBROUTINE icefrac 1132 1118 1133 1119 SUBROUTINE cv3_undilute2(nloc, ncum, nd, iflag, icb, icbs, nk, & 1134 1135 1136 1137 1120 tnk, qnk, gznk, hnk, t, q, qs, gz, & 1121 p, ph, h, tv, lv, lf, pbase, buoybase, plcl, & 1122 inb, tp, tvp, clw, hp, ep, sigp, buoy, & 1123 frac_a, frac_s, qpreca, qta) 1138 1124 USE lmdz_print_control, ONLY: prt_level 1139 1125 USE lmdz_conema3 1140 1126 USE lmdz_cvflag 1127 USE lmdz_cvthermo 1128 USE lmdz_cv3param 1141 1129 1142 1130 IMPLICIT NONE 1143 1131 1144 ! --------------------------------------------------------------------- 1145 ! Purpose: 1146 ! FIND THE REST OF THE LIFTED PARCEL TEMPERATURES 1147 ! & 1148 ! COMPUTE THE PRECIPITATION EFFICIENCIES AND THE 1149 ! FRACTION OF PRECIPITATION FALLING OUTSIDE OF CLOUD 1150 ! & 1151 ! FIND THE LEVEL OF NEUTRAL BUOYANCY 1152 1153 ! Main differences convect3/convect4: 1154 ! - icbs (input) is the first level above LCL (may differ from icb) 1155 ! - many minor differences in the iterations 1156 ! - condensed water not removed from tvp in convect3 1157 ! - vertical profile of buoyancy computed here (use of buoybase) 1158 ! - the determination of inb is different 1159 ! - no inb1, ONLY inb in output 1160 ! --------------------------------------------------------------------- 1161 1162 include "cvthermo.h" 1163 include "cv3param.h" 1132 ! --------------------------------------------------------------------- 1133 ! Purpose: 1134 ! FIND THE REST OF THE LIFTED PARCEL TEMPERATURES 1135 ! & 1136 ! COMPUTE THE PRECIPITATION EFFICIENCIES AND THE 1137 ! FRACTION OF PRECIPITATION FALLING OUTSIDE OF CLOUD 1138 ! & 1139 ! FIND THE LEVEL OF NEUTRAL BUOYANCY 1140 1141 ! Main differences convect3/convect4: 1142 ! - icbs (input) is the first level above LCL (may differ from icb) 1143 ! - many minor differences in the iterations 1144 ! - condensed water not removed from tvp in convect3 1145 ! - vertical profile of buoyancy computed here (use of buoybase) 1146 ! - the determination of inb is different 1147 ! - no inb1, ONLY inb in output 1148 ! --------------------------------------------------------------------- 1149 1164 1150 include "YOMCST2.h" 1165 1151 1166 !inputs:1167 INTEGER, INTENT (IN) 1168 INTEGER, DIMENSION (nloc), INTENT (IN) 1169 REAL, DIMENSION (nloc, nd), INTENT (IN) 1170 REAL, DIMENSION (nloc, nd), INTENT (IN) 1171 REAL, DIMENSION (nloc, nd +1), INTENT (IN):: ph1172 REAL, DIMENSION (nloc), INTENT (IN) 1173 REAL, DIMENSION (nloc), INTENT (IN) 1174 REAL, DIMENSION (nloc, nd), INTENT (IN) 1175 REAL, DIMENSION (nloc), INTENT (IN) 1176 1177 !input/outputs:1178 REAL, DIMENSION (nloc, nd), INTENT (INOUT) 1179 1180 INTEGER, DIMENSION (nloc), INTENT (INOUT) 1181 1182 !outputs:1183 INTEGER, DIMENSION (nloc), INTENT (OUT) 1184 REAL, DIMENSION (nloc, nd), INTENT (OUT) 1185 REAL, DIMENSION (nloc, nd), INTENT (OUT) 1186 REAL, DIMENSION (nloc, nd), INTENT (OUT) 1187 REAL, DIMENSION (nloc, nd), INTENT (OUT) 1188 REAL, DIMENSION (nloc, nd), INTENT (OUT) 1189 1190 !local variables:1152 !inputs: 1153 INTEGER, INTENT (IN) :: ncum, nd, nloc 1154 INTEGER, DIMENSION (nloc), INTENT (IN) :: icb, icbs, nk 1155 REAL, DIMENSION (nloc, nd), INTENT (IN) :: t, q, qs, gz 1156 REAL, DIMENSION (nloc, nd), INTENT (IN) :: p 1157 REAL, DIMENSION (nloc, nd + 1), INTENT (IN) :: ph 1158 REAL, DIMENSION (nloc), INTENT (IN) :: tnk, qnk, gznk 1159 REAL, DIMENSION (nloc), INTENT (IN) :: hnk 1160 REAL, DIMENSION (nloc, nd), INTENT (IN) :: lv, lf, tv, h 1161 REAL, DIMENSION (nloc), INTENT (IN) :: pbase, buoybase, plcl 1162 1163 !input/outputs: 1164 REAL, DIMENSION (nloc, nd), INTENT (INOUT) :: tp, tvp, clw ! Input for k = 1, icb+1 (computed in cv3_undilute1) 1165 ! Output above 1166 INTEGER, DIMENSION (nloc), INTENT (INOUT) :: iflag 1167 1168 !outputs: 1169 INTEGER, DIMENSION (nloc), INTENT (OUT) :: inb 1170 REAL, DIMENSION (nloc, nd), INTENT (OUT) :: ep, sigp, hp 1171 REAL, DIMENSION (nloc, nd), INTENT (OUT) :: buoy 1172 REAL, DIMENSION (nloc, nd), INTENT (OUT) :: frac_a, frac_s 1173 REAL, DIMENSION (nloc, nd), INTENT (OUT) :: qpreca 1174 REAL, DIMENSION (nloc, nd), INTENT (OUT) :: qta 1175 1176 !local variables: 1191 1177 INTEGER i, j, k 1192 1178 REAL smallestreal 1193 1179 REAL tg, qg, dqgdT, ahg, alv, alf, s, tc, es, esi, denom, rg, tca, elacrit 1194 REAL 1195 REAL 1196 REAL 1197 REAL 1198 REAL, DIMENSION (nloc, nd):: qi1199 REAL, DIMENSION (nloc, nd) :: ha ! moist static energy of adiabatic ascents1200 1201 REAL, DIMENSION (nloc, nd) :: hla ! liquid water static energy of adiabatic ascents1202 1203 REAL, DIMENSION (nloc, nd):: qcld ! specific cloud water1204 REAL, DIMENSION (nloc, nd):: qhsat ! specific humidity at saturation1205 REAL, DIMENSION (nloc, nd):: dqhsatdT ! dqhsat/dT1206 REAL, DIMENSION (nloc, nd):: frac ! ice fraction function of envt temperature1207 REAL, DIMENSION (nloc, nd):: qps ! specific solid precipitation1208 REAL, DIMENSION (nloc, nd):: qpl ! specific liquid precipitation1209 REAL, DIMENSION (nloc) 1210 LOGICAL, DIMENSION (nloc) 1211 INTEGER, DIMENSION (nloc) 1212 REAL 1213 REAL 1214 REAL 1215 REAL 1216 REAL, SAVE 1180 REAL :: phinu2p 1181 REAL :: qhthreshold 1182 REAL :: als 1183 REAL :: qsat_new, snew 1184 REAL, DIMENSION (nloc, nd) :: qi 1185 REAL, DIMENSION (nloc, nd) :: ha ! moist static energy of adiabatic ascents 1186 ! taking into account precip ejection 1187 REAL, DIMENSION (nloc, nd) :: hla ! liquid water static energy of adiabatic ascents 1188 ! taking into account precip ejection 1189 REAL, DIMENSION (nloc, nd) :: qcld ! specific cloud water 1190 REAL, DIMENSION (nloc, nd) :: qhsat ! specific humidity at saturation 1191 REAL, DIMENSION (nloc, nd) :: dqhsatdT ! dqhsat/dT 1192 REAL, DIMENSION (nloc, nd) :: frac ! ice fraction function of envt temperature 1193 REAL, DIMENSION (nloc, nd) :: qps ! specific solid precipitation 1194 REAL, DIMENSION (nloc, nd) :: qpl ! specific liquid precipitation 1195 REAL, DIMENSION (nloc) :: ah0, cape, capem, byp 1196 LOGICAL, DIMENSION (nloc) :: lcape 1197 INTEGER, DIMENSION (nloc) :: iposit 1198 REAL :: denomm1 1199 REAL :: by, defrac, pden, tbis 1200 REAL :: fracg 1201 REAL :: deltap 1202 REAL, SAVE :: Tx, Tm 1217 1203 DATA Tx/263.15/, Tm/243.15/ 1218 !$OMP THREADPRIVATE(Tx, Tm)1219 REAL 1220 REAL 1221 REAL 1204 !$OMP THREADPRIVATE(Tx, Tm) 1205 REAL :: aa, bb, dd, ddelta, discr 1206 REAL :: ff, fp 1207 REAL :: coefx, coefm, Zx, Zm, Ux, U, Um 1222 1208 1223 1209 IF (prt_level >= 10) THEN 1224 print *, 'cv3_undilute2.0. icvflag_Tpa, t(1,k), q(1,k), qs(1,k) ', &1225 icvflag_Tpa, (k, t(1,k), q(1,k), qs(1,k), k = 1,nl)1210 print *, 'cv3_undilute2.0. icvflag_Tpa, t(1,k), q(1,k), qs(1,k) ', & 1211 icvflag_Tpa, (k, t(1, k), q(1, k), qs(1, k), k = 1, nl) 1226 1212 ENDIF 1227 smallestreal =tiny(smallestreal)1228 1229 ! =====================================================================1230 ! --- SOME INITIALIZATIONS1231 ! =====================================================================1213 smallestreal = tiny(smallestreal) 1214 1215 ! ===================================================================== 1216 ! --- SOME INITIALIZATIONS 1217 ! ===================================================================== 1232 1218 1233 1219 DO k = 1, nl … … 1238 1224 1239 1225 1240 ! ===================================================================== 1241 ! --- FIND THE REST OF THE LIFTED PARCEL TEMPERATURES 1242 ! ===================================================================== 1243 1244 ! --- The procedure is to solve the equation. 1245 ! cp*tp+L*qp+phi=cp*tnk+L*qnk+gznk. 1246 1247 ! *** Calculate certain parcel quantities, including static energy *** 1248 1226 ! ===================================================================== 1227 ! --- FIND THE REST OF THE LIFTED PARCEL TEMPERATURES 1228 ! ===================================================================== 1229 1230 ! --- The procedure is to solve the equation. 1231 ! cp*tp+L*qp+phi=cp*tnk+L*qnk+gznk. 1232 1233 ! *** Calculate certain parcel quantities, including static energy *** 1249 1234 1250 1235 DO i = 1, ncum 1251 ah0(i) = (cpd *(1.-qnk(i))+cl*qnk(i))*tnk(i)+ &1252 ! debug qnk(i)*(lv0-clmcpv*(tnk(i)-t0))+gznk(i)1253 qnk(i)*(lv0-clmcpv*(tnk(i)-273.15)) + gznk(i)1254 END DO 1255 1256 ! Ice fraction1236 ah0(i) = (cpd * (1. - qnk(i)) + cl * qnk(i)) * tnk(i) + & 1237 ! debug qnk(i)*(lv0-clmcpv*(tnk(i)-t0))+gznk(i) 1238 qnk(i) * (lv0 - clmcpv * (tnk(i) - 273.15)) + gznk(i) 1239 END DO 1240 1241 ! Ice fraction 1257 1242 1258 1243 IF (cvflag_ice) THEN 1259 1244 DO k = minorig, nl 1260 1245 DO i = 1, ncum 1261 frac(i, k) = (Tx - t(i,k))/(Tx - Tm)1262 frac(i, k) = min(max(frac(i,k),0.0), 1.0)1246 frac(i, k) = (Tx - t(i, k)) / (Tx - Tm) 1247 frac(i, k) = min(max(frac(i, k), 0.0), 1.0) 1263 1248 END DO 1264 1249 END DO 1265 ! Below cloud base, set ice fraction to cloud base value1250 ! Below cloud base, set ice fraction to cloud base value 1266 1251 DO k = 1, nl 1267 1252 DO i = 1, ncum 1268 1253 IF (k<icb(i)) THEN 1269 frac(i, k) = frac(i,icb(i))1254 frac(i, k) = frac(i, icb(i)) 1270 1255 END IF 1271 1256 END DO … … 1274 1259 DO k = 1, nl 1275 1260 DO i = 1, ncum 1276 frac(i,k) = 0.1261 frac(i, k) = 0. 1277 1262 END DO 1278 1263 END DO 1279 1264 ENDIF ! (cvflag_ice) 1280 1265 1281 1282 1266 DO k = minorig, nl 1283 DO i = 1, ncum1284 ha(i, k) = ah0(i)1285 hla(i, k) = hnk(i)1286 qta(i, k) = qnk(i)1287 qpreca(i, k) = 0.1288 frac_a(i, k) = 0.1289 frac_s(i, k) = frac(i,k)1290 qpl(i, k) = 0.1291 qps(i, k) = 0.1292 qhsat(i, k) = qs(i,k)1293 qcld(i, k) = max(qta(i,k)-qhsat(i,k),0.)1294 IF (k <= icb(i) +1) THEN1295 qhsat(i, k) = qnk(i)-clw(i,k)1296 qcld(i, k) = clw(i,k)1297 ENDIF 1267 DO i = 1, ncum 1268 ha(i, k) = ah0(i) 1269 hla(i, k) = hnk(i) 1270 qta(i, k) = qnk(i) 1271 qpreca(i, k) = 0. 1272 frac_a(i, k) = 0. 1273 frac_s(i, k) = frac(i, k) 1274 qpl(i, k) = 0. 1275 qps(i, k) = 0. 1276 qhsat(i, k) = qs(i, k) 1277 qcld(i, k) = max(qta(i, k) - qhsat(i, k), 0.) 1278 IF (k <= icb(i) + 1) THEN 1279 qhsat(i, k) = qnk(i) - clw(i, k) 1280 qcld(i, k) = clw(i, k) 1281 ENDIF 1298 1282 ENDDO 1299 1283 ENDDO 1300 1284 1301 !jyg<1302 ! =====================================================================1303 ! --- SET THE THE FRACTION OF PRECIPITATION FALLING OUTSIDE OF CLOUD1304 ! =====================================================================1285 !jyg< 1286 ! ===================================================================== 1287 ! --- SET THE THE FRACTION OF PRECIPITATION FALLING OUTSIDE OF CLOUD 1288 ! ===================================================================== 1305 1289 DO k = 1, nl 1306 1290 DO i = 1, ncum … … 1309 1293 END DO 1310 1294 END DO 1311 !>jyg1312 1313 ! *** Find lifted parcel quantities above cloud base ***1314 1315 !----------------------------------------------------------------------------1295 !>jyg 1296 1297 ! *** Find lifted parcel quantities above cloud base *** 1298 1299 !---------------------------------------------------------------------------- 1316 1300 1317 1301 IF (icvflag_Tpa == 2) THEN 1318 1302 1319 !----------------------------------------------------------------------------1303 !---------------------------------------------------------------------------- 1320 1304 1321 1305 DO k = minorig + 1, nl 1322 DO i = 1, ncum1323 tp(i, k) = t(i,k)1306 DO i = 1, ncum 1307 tp(i, k) = t(i, k) 1324 1308 ENDDO 1325 !! alv = lv0 - clmcpv*(t(i,k)-273.15)1326 !! alf = lf0 + clmci*(t(i,k)-273.15)1327 !! als = alf + alv1328 DO j = 1, 41309 !! alv = lv0 - clmcpv*(t(i,k)-273.15) 1310 !! alf = lf0 + clmci*(t(i,k)-273.15) 1311 !! als = alf + alv 1312 DO j = 1, 4 1329 1313 DO i = 1, ncum 1330 ! ori IF(k.ge.(icb(i)+1))THEN1331 IF (k>=(icbs(i) +1)) THEN ! convect31314 ! ori IF(k.ge.(icb(i)+1))THEN 1315 IF (k>=(icbs(i) + 1)) THEN ! convect3 1332 1316 tg = tp(i, k) 1333 1317 IF (tg > Tx) THEN 1334 es = 6.112 *exp(17.67*(tg - 273.15)/(tg + 243.5 - 273.15))1335 qg = eps *es/(p(i,k)-es*(1.-eps))1318 es = 6.112 * exp(17.67 * (tg - 273.15) / (tg + 243.5 - 273.15)) 1319 qg = eps * es / (p(i, k) - es * (1. - eps)) 1336 1320 ELSE 1337 esi = exp(23.33086 -(6111.72784/tg)+0.15215*log(tg))1338 qg = eps *esi/(p(i,k)-esi*(1.-eps))1321 esi = exp(23.33086 - (6111.72784 / tg) + 0.15215 * log(tg)) 1322 qg = eps * esi / (p(i, k) - esi * (1. - eps)) 1339 1323 ENDIF 1340 ! Ice fraction1324 ! Ice fraction 1341 1325 ff = 0. 1342 fp = 1. /(Tx - Tm)1326 fp = 1. / (Tx - Tm) 1343 1327 IF (tg < Tx) THEN 1344 1328 IF (tg > Tm) THEN 1345 ff = (Tx - tg) *fp1329 ff = (Tx - tg) * fp 1346 1330 ELSE 1347 1331 ff = 1. 1348 1332 ENDIF ! (tg > Tm) 1349 1333 ENDIF ! (tg < Tx) 1350 ! Intermediate variables1351 aa = cpd + (cl -cpd)*qnk(i) + lv(i,k)*lv(i,k)*qg/(rrv*tg*tg)1352 ahg = (cpd + (cl -cpd)*qnk(i))*tg + lv(i,k)*qg - &1353 lf(i,k)*ff*(qnk(i) - qg) + gz(i,k)1354 dd = lf(i, k)*lv(i,k)*qg/(rrv*tg*tg)1355 ddelta = lf(i, k)*(qnk(i) - qg)1356 bb = aa + ddelta *fp + dd*fp*(Tx-tg)1357 ! Compute Zx and Zm1334 ! Intermediate variables 1335 aa = cpd + (cl - cpd) * qnk(i) + lv(i, k) * lv(i, k) * qg / (rrv * tg * tg) 1336 ahg = (cpd + (cl - cpd) * qnk(i)) * tg + lv(i, k) * qg - & 1337 lf(i, k) * ff * (qnk(i) - qg) + gz(i, k) 1338 dd = lf(i, k) * lv(i, k) * qg / (rrv * tg * tg) 1339 ddelta = lf(i, k) * (qnk(i) - qg) 1340 bb = aa + ddelta * fp + dd * fp * (Tx - tg) 1341 ! Compute Zx and Zm 1358 1342 coefx = aa 1359 1343 coefm = aa + dd 1360 1344 IF (tg > Tx) THEN 1361 Zx = ahg + coefx*(Tx - tg)1362 Zm = ahg - ddelta + coefm*(Tm - tg)1345 Zx = ahg + coefx * (Tx - tg) 1346 Zm = ahg - ddelta + coefm * (Tm - tg) 1363 1347 ELSE 1364 1348 IF (tg > Tm) THEN 1365 Zx = ahg + (coefx +fp*ddelta)*(Tx - Tg)1366 Zm = ahg + (coefm +fp*ddelta)*(Tm - Tg)1349 Zx = ahg + (coefx + fp * ddelta) * (Tx - Tg) 1350 Zm = ahg + (coefm + fp * ddelta) * (Tm - Tg) 1367 1351 ELSE 1368 Zx = ahg + ddelta + coefx *(Tx - tg)1369 Zm = ahg + coefm*(Tm - tg)1352 Zx = ahg + ddelta + coefx * (Tx - tg) 1353 Zm = ahg + coefm * (Tm - tg) 1370 1354 ENDIF ! (tg .gt. Tm) 1371 1355 ENDIF ! (tg .gt. Tx) 1372 ! Compute the masks Um, U, Ux1373 Um = (sign(1., Zm -ah0(i))+1.)/2.1374 Ux = (sign(1., ah0(i) -Zx)+1.)/2.1375 U = (1. - Um) *(1. - Ux)1376 ! Compute the updated parcell temperature Tp : 3 cases depending on tg value1356 ! Compute the masks Um, U, Ux 1357 Um = (sign(1., Zm - ah0(i)) + 1.) / 2. 1358 Ux = (sign(1., ah0(i) - Zx) + 1.) / 2. 1359 U = (1. - Um) * (1. - Ux) 1360 ! Compute the updated parcell temperature Tp : 3 cases depending on tg value 1377 1361 IF (tg > Tx) THEN 1378 discr = bb *bb - 4*dd*fp*(ah0(i) - ahg + ddelta*fp*(Tx-tg))1379 Tp(i, k) = tg + &1380 Um* (ah0(i) - ahg + ddelta) /(aa + dd) + &1381 U *2*(ah0(i) - ahg + ddelta*fp*(Tx-tg))/(bb + sqrt(discr)) + &1382 Ux* (ah0(i) - ahg) /aa1362 discr = bb * bb - 4 * dd * fp * (ah0(i) - ahg + ddelta * fp * (Tx - tg)) 1363 Tp(i, k) = tg + & 1364 Um * (ah0(i) - ahg + ddelta) / (aa + dd) + & 1365 U * 2 * (ah0(i) - ahg + ddelta * fp * (Tx - tg)) / (bb + sqrt(discr)) + & 1366 Ux * (ah0(i) - ahg) / aa 1383 1367 ELSEIF (tg > Tm) THEN 1384 discr = bb *bb - 4*dd*fp*(ah0(i) - ahg)1385 Tp(i, k) = tg + &1386 Um* (ah0(i) - ahg + ddelta*fp*(tg-Tm))/(aa + dd) + &1387 U *2*(ah0(i) - ahg) /(bb + sqrt(discr)) + &1388 Ux* (ah0(i) - ahg + ddelta*fp*(tg-Tx))/aa1368 discr = bb * bb - 4 * dd * fp * (ah0(i) - ahg) 1369 Tp(i, k) = tg + & 1370 Um * (ah0(i) - ahg + ddelta * fp * (tg - Tm)) / (aa + dd) + & 1371 U * 2 * (ah0(i) - ahg) / (bb + sqrt(discr)) + & 1372 Ux * (ah0(i) - ahg + ddelta * fp * (tg - Tx)) / aa 1389 1373 ELSE 1390 discr = bb *bb - 4*dd*fp*(ah0(i) - ahg + ddelta*fp*(Tm-tg))1391 Tp(i, k) = tg + &1392 Um* (ah0(i) - ahg) /(aa + dd) + &1393 U *2*(ah0(i) - ahg + ddelta*fp*(Tm-tg))/(bb + sqrt(discr)) + &1394 Ux* (ah0(i) - ahg - ddelta) /aa1374 discr = bb * bb - 4 * dd * fp * (ah0(i) - ahg + ddelta * fp * (Tm - tg)) 1375 Tp(i, k) = tg + & 1376 Um * (ah0(i) - ahg) / (aa + dd) + & 1377 U * 2 * (ah0(i) - ahg + ddelta * fp * (Tm - tg)) / (bb + sqrt(discr)) + & 1378 Ux * (ah0(i) - ahg - ddelta) / aa 1395 1379 ENDIF ! (tg .gt. Tx) 1396 1380 1397 !! print *,' j, k, Um, U, Ux, aa, bb, discr, dd, ddelta ', j, k, Um, U, Ux, aa, bb, discr, dd, ddelta1398 !! print *,' j, k, ah0(i), ahg, tg, qg, tp(i,k), ff ', j, k, ah0(i), ahg, tg, qg, tp(i,k), ff1381 !! print *,' j, k, Um, U, Ux, aa, bb, discr, dd, ddelta ', j, k, Um, U, Ux, aa, bb, discr, dd, ddelta 1382 !! print *,' j, k, ah0(i), ahg, tg, qg, tp(i,k), ff ', j, k, ah0(i), ahg, tg, qg, tp(i,k), ff 1399 1383 END IF ! (k>=(icbs(i)+1)) 1400 1384 END DO ! i = 1, ncum 1401 1385 END DO ! j = 1,4 1402 1386 DO i = 1, ncum 1403 IF (k>=(icbs(i) +1)) THEN ! convect31387 IF (k>=(icbs(i) + 1)) THEN ! convect3 1404 1388 tg = tp(i, k) 1405 1389 IF (tg > Tx) THEN 1406 es = 6.112 *exp(17.67*(tg - 273.15)/(tg + 243.5 - 273.15))1407 qg = eps *es/(p(i,k)-es*(1.-eps))1390 es = 6.112 * exp(17.67 * (tg - 273.15) / (tg + 243.5 - 273.15)) 1391 qg = eps * es / (p(i, k) - es * (1. - eps)) 1408 1392 ELSE 1409 esi = exp(23.33086 -(6111.72784/tg)+0.15215*log(tg))1410 qg = eps *esi/(p(i,k)-esi*(1.-eps))1393 esi = exp(23.33086 - (6111.72784 / tg) + 0.15215 * log(tg)) 1394 qg = eps * esi / (p(i, k) - esi * (1. - eps)) 1411 1395 ENDIF 1412 1396 clw(i, k) = qnk(i) - qg 1413 clw(i, k) = max(0.0, clw(i, k))1414 tvp(i, k) = max(0., tp(i, k)*(1.+qg/eps-qnk(i)))1415 ! PRINT*,tvp(i,k),'tvp'1416 IF (clw(i, k)<1.E-11) THEN1397 clw(i, k) = max(0.0, clw(i, k)) 1398 tvp(i, k) = max(0., tp(i, k) * (1. + qg / eps - qnk(i))) 1399 ! PRINT*,tvp(i,k),'tvp' 1400 IF (clw(i, k)<1.E-11) THEN 1417 1401 tp(i, k) = tv(i, k) 1418 1402 tvp(i, k) = tv(i, k) … … 1421 1405 END DO ! i = 1, ncum 1422 1406 END DO ! k = minorig + 1, nl 1423 !----------------------------------------------------------------------------1407 !---------------------------------------------------------------------------- 1424 1408 1425 1409 ELSE IF (icvflag_Tpa == 1) THEN ! (icvflag_Tpa == 2) 1426 1410 1427 !----------------------------------------------------------------------------1411 !---------------------------------------------------------------------------- 1428 1412 1429 1413 DO k = minorig + 1, nl 1430 DO i = 1, ncum1431 tp(i, k) = t(i,k)1414 DO i = 1, ncum 1415 tp(i, k) = t(i, k) 1432 1416 ENDDO 1433 !! alv = lv0 - clmcpv*(t(i,k)-273.15)1434 !! alf = lf0 + clmci*(t(i,k)-273.15)1435 !! als = alf + alv1436 DO j = 1, 41417 !! alv = lv0 - clmcpv*(t(i,k)-273.15) 1418 !! alf = lf0 + clmci*(t(i,k)-273.15) 1419 !! als = alf + alv 1420 DO j = 1, 4 1437 1421 DO i = 1, ncum 1438 ! ori IF(k.ge.(icb(i)+1))THEN1439 IF (k>=(icbs(i) +1)) THEN ! convect31422 ! ori IF(k.ge.(icb(i)+1))THEN 1423 IF (k>=(icbs(i) + 1)) THEN ! convect3 1440 1424 tg = tp(i, k) 1441 1425 IF (tg > Tx .OR. .NOT.cvflag_ice) THEN 1442 es = 6.112 *exp(17.67*(tg - 273.15)/(tg + 243.5 - 273.15))1443 qg = eps *es/(p(i,k)-es*(1.-eps))1444 dqgdT = lv(i, k)*qg/(rrv*tg*tg)1426 es = 6.112 * exp(17.67 * (tg - 273.15) / (tg + 243.5 - 273.15)) 1427 qg = eps * es / (p(i, k) - es * (1. - eps)) 1428 dqgdT = lv(i, k) * qg / (rrv * tg * tg) 1445 1429 ELSE 1446 esi = exp(23.33086 -(6111.72784/tg)+0.15215*log(tg))1447 qg = eps *esi/(p(i,k)-esi*(1.-eps))1448 dqgdT = (lv(i, k)+lf(i,k))*qg/(rrv*tg*tg)1430 esi = exp(23.33086 - (6111.72784 / tg) + 0.15215 * log(tg)) 1431 qg = eps * esi / (p(i, k) - esi * (1. - eps)) 1432 dqgdT = (lv(i, k) + lf(i, k)) * qg / (rrv * tg * tg) 1449 1433 ENDIF 1450 1434 IF (qsat_depends_on_qt) THEN 1451 dqgdT = dqgdT *(1.-qta(i,k-1))/(1.-qg)**21452 qg = qg *(1.-qta(i,k-1))/(1.-qg)1435 dqgdT = dqgdT * (1. - qta(i, k - 1)) / (1. - qg)**2 1436 qg = qg * (1. - qta(i, k - 1)) / (1. - qg) 1453 1437 ENDIF 1454 ahg = (cpd + (cl -cpd)*qta(i,k-1))*tg + lv(i,k)*qg - &1455 lf(i,k)*frac(i,k)*(qta(i,k-1) - qg) + gz(i,k)1456 Tp(i, k) = tg + (ah0(i) - ahg)/ &1457 (cpd + (cl -cpd)*qta(i,k-1) + (lv(i,k)+frac(i,k)*lf(i,k))*dqgdT)1458 !! print *,'undilute2 iterations k, Tp(i,k), ah0(i), ahg ', &1459 !! k, Tp(i,k), ah0(i), ahg1438 ahg = (cpd + (cl - cpd) * qta(i, k - 1)) * tg + lv(i, k) * qg - & 1439 lf(i, k) * frac(i, k) * (qta(i, k - 1) - qg) + gz(i, k) 1440 Tp(i, k) = tg + (ah0(i) - ahg) / & 1441 (cpd + (cl - cpd) * qta(i, k - 1) + (lv(i, k) + frac(i, k) * lf(i, k)) * dqgdT) 1442 !! print *,'undilute2 iterations k, Tp(i,k), ah0(i), ahg ', & 1443 !! k, Tp(i,k), ah0(i), ahg 1460 1444 END IF ! (k>=(icbs(i)+1)) 1461 1445 END DO ! i = 1, ncum 1462 1446 END DO ! j = 1,4 1463 1447 DO i = 1, ncum 1464 IF (k>=(icbs(i) +1)) THEN ! convect31448 IF (k>=(icbs(i) + 1)) THEN ! convect3 1465 1449 tg = tp(i, k) 1466 1450 IF (tg > Tx .OR. .NOT.cvflag_ice) THEN 1467 es = 6.112 *exp(17.67*(tg - 273.15)/(tg + 243.5 - 273.15))1468 qg = eps *es/(p(i,k)-es*(1.-eps))1451 es = 6.112 * exp(17.67 * (tg - 273.15) / (tg + 243.5 - 273.15)) 1452 qg = eps * es / (p(i, k) - es * (1. - eps)) 1469 1453 ELSE 1470 esi = exp(23.33086 -(6111.72784/tg)+0.15215*log(tg))1471 qg = eps *esi/(p(i,k)-esi*(1.-eps))1454 esi = exp(23.33086 - (6111.72784 / tg) + 0.15215 * log(tg)) 1455 qg = eps * esi / (p(i, k) - esi * (1. - eps)) 1472 1456 ENDIF 1473 1457 IF (qsat_depends_on_qt) THEN 1474 qg = qg *(1.-qta(i,k-1))/(1.-qg)1458 qg = qg * (1. - qta(i, k - 1)) / (1. - qg) 1475 1459 ENDIF 1476 qhsat(i, k) = qg1460 qhsat(i, k) = qg 1477 1461 END IF ! (k>=(icbs(i)+1)) 1478 1462 END DO ! i = 1, ncum 1479 1463 DO i = 1, ncum 1480 IF (k>=(icbs(i) +1)) THEN ! convect31481 clw(i, k) = qta(i, k-1) - qhsat(i,k)1482 clw(i, k) = max(0.0, clw(i, k))1483 tvp(i, k) = max(0., tp(i, k)*(1.+qhsat(i,k)/eps-qta(i,k-1)))1484 ! PRINT*,tvp(i,k),'tvp'1485 IF (clw(i, k)<1.E-11) THEN1464 IF (k>=(icbs(i) + 1)) THEN ! convect3 1465 clw(i, k) = qta(i, k - 1) - qhsat(i, k) 1466 clw(i, k) = max(0.0, clw(i, k)) 1467 tvp(i, k) = max(0., tp(i, k) * (1. + qhsat(i, k) / eps - qta(i, k - 1))) 1468 ! PRINT*,tvp(i,k),'tvp' 1469 IF (clw(i, k)<1.E-11) THEN 1486 1470 tp(i, k) = tv(i, k) 1487 1471 tvp(i, k) = tv(i, k) … … 1492 1476 IF (cvflag_prec_eject) THEN 1493 1477 DO i = 1, ncum 1494 IF (k>=(icbs(i) +1)) THEN ! convect31495 ! Specific precipitation (liquid and solid) and ice content 1496 ! before ejection of precipitation !!jygprl1497 elacrit = elcrit *min(max(1.-(tp(i,k)-T0)/Tlcrit, 0.), 1.) !!jygprl1498 !!!! qcld(i,k) = min(clw(i,k), elacrit) !!jygprl1499 qhthreshold = elacrit *(1.-qta(i,k-1))/(1.-elacrit)1500 qcld(i, k) = min(clw(i,k), qhthreshold) !!jygprl1501 !!!! phinu2p = max(qhsat(i,k-1) + qcld(i,k-1) - (qhsat(i,k) + qcld(i,k)),0.) !!jygprl1502 phinu2p = max(clw(i, k) - max(qta(i,k-1) - qhsat(i,k-1), qhthreshold), 0.)1503 qpl(i, k) = qpl(i,k-1) + (1.-frac(i,k))*phinu2p !!jygprl1504 qps(i, k) = qps(i,k-1) + frac(i,k) *phinu2p !!jygprl1505 qi(i, k) = (1.-ejectliq)*clw(i,k)*frac(i,k) + & !!jygprl1506 ejectliq*(qps(i,k-1) + frac(i,k)*(phinu2p+qcld(i,k))) !!jygprl1507 !!1508 ! =====================================================================================1509 ! Ejection of precipitation from adiabatic ascents if requested (cvflag_prec_eject=True):1510 ! Compute the steps of total water (qta), of moist static energy (ha), of specific 1511 ! precipitation (qpl and qps) and of specific cloud water (qcld) associated with precipitation1512 ! ejection.1513 ! =====================================================================================1514 1515 ! Verif1516 qpreca(i, k) = ejectliq*qpl(i,k) + ejectice*qps(i,k) !!jygprl1517 frac_a(i, k) = ejectice*qps(i,k)/max(qpreca(i,k),smallestreal) !!jygprl1518 frac_s(i, k) = (1.-ejectliq)*frac(i,k) + & !!jygprl1519 ejectliq*(1. - (qpl(i,k)+(1.-frac(i,k))*qcld(i,k))/max(clw(i,k),smallestreal)) !!jygprl1520 1521 denomm1 = 1. /(1. - qpreca(i,k))1522 1523 qta(i, k) = qta(i,k-1) - &1524 qpreca(i,k)*(1.-qta(i,k-1))*denomm11525 ha(i, k) = ha(i,k-1) + &1526 ( qpreca(i,k)*(-(1.-qta(i,k-1))*(cl-cpd)*tp(i,k) + &1527 lv(i,k)*qhsat(i,k) - lf(i,k)*(frac_s(i,k)*qcld(i,k)+qps(i,k))) + &1528 lf(i,k)*ejectice*qps(i,k))*denomm11529 hla(i, k) = hla(i,k-1) + &1530 ( qpreca(i,k)*(-(1.-qta(i,k-1))*(cpv-cpd)*tp(i,k) - &1531 lv(i,k)*((1.-frac_s(i,k))*qcld(i,k)+qpl(i,k)) - &1532 (lv(i,k)+lf(i,k))*(frac_s(i,k)*qcld(i,k)+qps(i,k))) + &1533 lv(i,k)*ejectliq*qpl(i,k) + (lv(i,k)+lf(i,k))*ejectice*qps(i,k))*denomm11534 qpl(i, k) = qpl(i,k)*(1.-ejectliq)*denomm11535 qps(i, k) = qps(i,k)*(1.-ejectice)*denomm11536 qcld(i, k) = qcld(i,k)*denomm11537 qhsat(i, k) = qhsat(i,k)*(1.-qta(i,k))/(1.-qta(i,k-1))1538 END IF ! (k>=(icbs(i)+1))1478 IF (k>=(icbs(i) + 1)) THEN ! convect3 1479 ! Specific precipitation (liquid and solid) and ice content 1480 ! before ejection of precipitation !!jygprl 1481 elacrit = elcrit * min(max(1. - (tp(i, k) - T0) / Tlcrit, 0.), 1.) !!jygprl 1482 !!!! qcld(i,k) = min(clw(i,k), elacrit) !!jygprl 1483 qhthreshold = elacrit * (1. - qta(i, k - 1)) / (1. - elacrit) 1484 qcld(i, k) = min(clw(i, k), qhthreshold) !!jygprl 1485 !!!! phinu2p = max(qhsat(i,k-1) + qcld(i,k-1) - (qhsat(i,k) + qcld(i,k)),0.) !!jygprl 1486 phinu2p = max(clw(i, k) - max(qta(i, k - 1) - qhsat(i, k - 1), qhthreshold), 0.) 1487 qpl(i, k) = qpl(i, k - 1) + (1. - frac(i, k)) * phinu2p !!jygprl 1488 qps(i, k) = qps(i, k - 1) + frac(i, k) * phinu2p !!jygprl 1489 qi(i, k) = (1. - ejectliq) * clw(i, k) * frac(i, k) + & !!jygprl 1490 ejectliq * (qps(i, k - 1) + frac(i, k) * (phinu2p + qcld(i, k))) !!jygprl 1491 !! 1492 ! ===================================================================================== 1493 ! Ejection of precipitation from adiabatic ascents if requested (cvflag_prec_eject=True): 1494 ! Compute the steps of total water (qta), of moist static energy (ha), of specific 1495 ! precipitation (qpl and qps) and of specific cloud water (qcld) associated with precipitation 1496 ! ejection. 1497 ! ===================================================================================== 1498 1499 ! Verif 1500 qpreca(i, k) = ejectliq * qpl(i, k) + ejectice * qps(i, k) !!jygprl 1501 frac_a(i, k) = ejectice * qps(i, k) / max(qpreca(i, k), smallestreal) !!jygprl 1502 frac_s(i, k) = (1. - ejectliq) * frac(i, k) + & !!jygprl 1503 ejectliq * (1. - (qpl(i, k) + (1. - frac(i, k)) * qcld(i, k)) / max(clw(i, k), smallestreal)) !!jygprl 1504 1505 denomm1 = 1. / (1. - qpreca(i, k)) 1506 1507 qta(i, k) = qta(i, k - 1) - & 1508 qpreca(i, k) * (1. - qta(i, k - 1)) * denomm1 1509 ha(i, k) = ha(i, k - 1) + & 1510 (qpreca(i, k) * (-(1. - qta(i, k - 1)) * (cl - cpd) * tp(i, k) + & 1511 lv(i, k) * qhsat(i, k) - lf(i, k) * (frac_s(i, k) * qcld(i, k) + qps(i, k))) + & 1512 lf(i, k) * ejectice * qps(i, k)) * denomm1 1513 hla(i, k) = hla(i, k - 1) + & 1514 (qpreca(i, k) * (-(1. - qta(i, k - 1)) * (cpv - cpd) * tp(i, k) - & 1515 lv(i, k) * ((1. - frac_s(i, k)) * qcld(i, k) + qpl(i, k)) - & 1516 (lv(i, k) + lf(i, k)) * (frac_s(i, k) * qcld(i, k) + qps(i, k))) + & 1517 lv(i, k) * ejectliq * qpl(i, k) + (lv(i, k) + lf(i, k)) * ejectice * qps(i, k)) * denomm1 1518 qpl(i, k) = qpl(i, k) * (1. - ejectliq) * denomm1 1519 qps(i, k) = qps(i, k) * (1. - ejectice) * denomm1 1520 qcld(i, k) = qcld(i, k) * denomm1 1521 qhsat(i, k) = qhsat(i, k) * (1. - qta(i, k)) / (1. - qta(i, k - 1)) 1522 END IF ! (k>=(icbs(i)+1)) 1539 1523 END DO ! i = 1, ncum 1540 1524 ENDIF ! (cvflag_prec_eject) … … 1542 1526 END DO ! k = minorig + 1, nl 1543 1527 1544 !----------------------------------------------------------------------------1528 !---------------------------------------------------------------------------- 1545 1529 1546 1530 ELSE IF (icvflag_Tpa == 0) THEN! (icvflag_Tpa == 2) ELSE IF(icvflag_Tpa == 1) 1547 1531 1548 !---------------------------------------------------------------------------- 1549 1550 DO k = minorig + 1, nl 1551 DO i = 1, ncum 1552 ! ori IF(k.ge.(icb(i)+1))THEN 1553 IF (k>=(icbs(i)+1)) THEN ! convect3 1554 tg = t(i, k) 1555 qg = qs(i, k) 1556 ! debug alv=lv0-clmcpv*(t(i,k)-t0) 1557 alv = lv0 - clmcpv*(t(i,k)-273.15) 1558 1559 ! First iteration. 1560 1561 ! ori s=cpd+alv*alv*qg/(rrv*t(i,k)*t(i,k)) 1562 s = cpd*(1.-qnk(i)) + cl*qnk(i) + & ! convect3 1563 alv*alv*qg/(rrv*t(i,k)*t(i,k)) ! convect3 1564 s = 1./s 1565 ! ori ahg=cpd*tg+(cl-cpd)*qnk(i)*t(i,k)+alv*qg+gz(i,k) 1566 ahg = cpd*tg + (cl-cpd)*qnk(i)*tg + alv*qg + gz(i, k) ! convect3 1567 tg = tg + s*(ah0(i)-ahg) 1568 ! ori tg=max(tg,35.0) 1569 ! debug tc=tg-t0 1570 tc = tg - 273.15 1571 denom = 243.5 + tc 1572 denom = max(denom, 1.0) ! convect3 1573 ! ori IF(tc.ge.0.0)THEN 1574 es = 6.112*exp(17.67*tc/denom) 1575 ! ori else 1576 ! ori es=exp(23.33086-6111.72784/tg+0.15215*log(tg)) 1577 ! ori endif 1578 qg = eps*es/(p(i,k)-es*(1.-eps)) 1579 1580 ! Second iteration. 1581 1582 ! ori s=cpd+alv*alv*qg/(rrv*t(i,k)*t(i,k)) 1583 ! ori s=1./s 1584 ! ori ahg=cpd*tg+(cl-cpd)*qnk(i)*t(i,k)+alv*qg+gz(i,k) 1585 ahg = cpd*tg + (cl-cpd)*qnk(i)*tg + alv*qg + gz(i, k) ! convect3 1586 tg = tg + s*(ah0(i)-ahg) 1587 ! ori tg=max(tg,35.0) 1588 ! debug tc=tg-t0 1589 tc = tg - 273.15 1590 denom = 243.5 + tc 1591 denom = max(denom, 1.0) ! convect3 1592 ! ori IF(tc.ge.0.0)THEN 1593 es = 6.112*exp(17.67*tc/denom) 1594 ! ori else 1595 ! ori es=exp(23.33086-6111.72784/tg+0.15215*log(tg)) 1596 ! ori endif 1597 qg = eps*es/(p(i,k)-es*(1.-eps)) 1598 1599 ! debug alv=lv0-clmcpv*(t(i,k)-t0) 1600 alv = lv0 - clmcpv*(t(i,k)-273.15) 1601 ! PRINT*,'cpd dans convect2 ',cpd 1602 ! PRINT*,'tp(i,k),ah0(i),cl,cpd,qnk(i),t(i,k),gz(i,k),alv,qg,cpd' 1603 ! PRINT*,tp(i,k),ah0(i),cl,cpd,qnk(i),t(i,k),gz(i,k),alv,qg,cpd 1604 1605 ! ori c approximation here: 1606 ! ori tp(i,k)=(ah0(i)-(cl-cpd)*qnk(i)*t(i,k)-gz(i,k)-alv*qg)/cpd 1607 1608 ! convect3: no approximation: 1609 IF (cvflag_ice) THEN 1610 tp(i, k) = max(0., (ah0(i)-gz(i,k)-alv*qg)/(cpd+(cl-cpd)*qnk(i))) 1611 ELSE 1612 tp(i, k) = (ah0(i)-gz(i,k)-alv*qg)/(cpd+(cl-cpd)*qnk(i)) 1613 END IF 1614 1615 clw(i, k) = qnk(i) - qg 1616 clw(i, k) = max(0.0, clw(i,k)) 1617 rg = qg/(1.-qnk(i)) 1618 ! ori tvp(i,k)=tp(i,k)*(1.+rg*epsi) 1619 ! convect3: (qg utilise au lieu du vrai mixing ratio rg): 1620 tvp(i, k) = tp(i, k)*(1.+qg/eps-qnk(i)) ! whole thing 1621 IF (cvflag_ice) THEN 1622 IF (clw(i,k)<1.E-11) THEN 1623 tp(i, k) = tv(i, k) 1624 tvp(i, k) = tv(i, k) 1532 !---------------------------------------------------------------------------- 1533 1534 DO k = minorig + 1, nl 1535 DO i = 1, ncum 1536 ! ori IF(k.ge.(icb(i)+1))THEN 1537 IF (k>=(icbs(i) + 1)) THEN ! convect3 1538 tg = t(i, k) 1539 qg = qs(i, k) 1540 ! debug alv=lv0-clmcpv*(t(i,k)-t0) 1541 alv = lv0 - clmcpv * (t(i, k) - 273.15) 1542 1543 ! First iteration. 1544 1545 ! ori s=cpd+alv*alv*qg/(rrv*t(i,k)*t(i,k)) 1546 s = cpd * (1. - qnk(i)) + cl * qnk(i) + & ! convect3 1547 alv * alv * qg / (rrv * t(i, k) * t(i, k)) ! convect3 1548 s = 1. / s 1549 ! ori ahg=cpd*tg+(cl-cpd)*qnk(i)*t(i,k)+alv*qg+gz(i,k) 1550 ahg = cpd * tg + (cl - cpd) * qnk(i) * tg + alv * qg + gz(i, k) ! convect3 1551 tg = tg + s * (ah0(i) - ahg) 1552 ! ori tg=max(tg,35.0) 1553 ! debug tc=tg-t0 1554 tc = tg - 273.15 1555 denom = 243.5 + tc 1556 denom = max(denom, 1.0) ! convect3 1557 ! ori IF(tc.ge.0.0)THEN 1558 es = 6.112 * exp(17.67 * tc / denom) 1559 ! ori else 1560 ! ori es=exp(23.33086-6111.72784/tg+0.15215*log(tg)) 1561 ! ori endif 1562 qg = eps * es / (p(i, k) - es * (1. - eps)) 1563 1564 ! Second iteration. 1565 1566 ! ori s=cpd+alv*alv*qg/(rrv*t(i,k)*t(i,k)) 1567 ! ori s=1./s 1568 ! ori ahg=cpd*tg+(cl-cpd)*qnk(i)*t(i,k)+alv*qg+gz(i,k) 1569 ahg = cpd * tg + (cl - cpd) * qnk(i) * tg + alv * qg + gz(i, k) ! convect3 1570 tg = tg + s * (ah0(i) - ahg) 1571 ! ori tg=max(tg,35.0) 1572 ! debug tc=tg-t0 1573 tc = tg - 273.15 1574 denom = 243.5 + tc 1575 denom = max(denom, 1.0) ! convect3 1576 ! ori IF(tc.ge.0.0)THEN 1577 es = 6.112 * exp(17.67 * tc / denom) 1578 ! ori else 1579 ! ori es=exp(23.33086-6111.72784/tg+0.15215*log(tg)) 1580 ! ori endif 1581 qg = eps * es / (p(i, k) - es * (1. - eps)) 1582 1583 ! debug alv=lv0-clmcpv*(t(i,k)-t0) 1584 alv = lv0 - clmcpv * (t(i, k) - 273.15) 1585 ! PRINT*,'cpd dans convect2 ',cpd 1586 ! PRINT*,'tp(i,k),ah0(i),cl,cpd,qnk(i),t(i,k),gz(i,k),alv,qg,cpd' 1587 ! PRINT*,tp(i,k),ah0(i),cl,cpd,qnk(i),t(i,k),gz(i,k),alv,qg,cpd 1588 1589 ! ori c approximation here: 1590 ! ori tp(i,k)=(ah0(i)-(cl-cpd)*qnk(i)*t(i,k)-gz(i,k)-alv*qg)/cpd 1591 1592 ! convect3: no approximation: 1593 IF (cvflag_ice) THEN 1594 tp(i, k) = max(0., (ah0(i) - gz(i, k) - alv * qg) / (cpd + (cl - cpd) * qnk(i))) 1595 ELSE 1596 tp(i, k) = (ah0(i) - gz(i, k) - alv * qg) / (cpd + (cl - cpd) * qnk(i)) 1625 1597 END IF 1626 END IF 1627 !jyg< 1628 !! END IF ! Endif moved to the end of the loop 1629 !>jyg 1630 1631 IF (cvflag_ice) THEN 1632 !CR:attention boucle en klon dans Icefrac 1633 ! Call Icefrac(t,clw,qi,nl,nloc) 1634 IF (t(i,k)>263.15) THEN 1635 qi(i, k) = 0. 1636 ELSE 1637 IF (t(i,k)<243.15) THEN 1638 qi(i, k) = clw(i, k) 1639 ELSE 1640 fracg = (263.15-t(i,k))/20 1641 qi(i, k) = clw(i, k)*fracg 1598 1599 clw(i, k) = qnk(i) - qg 1600 clw(i, k) = max(0.0, clw(i, k)) 1601 rg = qg / (1. - qnk(i)) 1602 ! ori tvp(i,k)=tp(i,k)*(1.+rg*epsi) 1603 ! convect3: (qg utilise au lieu du vrai mixing ratio rg): 1604 tvp(i, k) = tp(i, k) * (1. + qg / eps - qnk(i)) ! whole thing 1605 IF (cvflag_ice) THEN 1606 IF (clw(i, k)<1.E-11) THEN 1607 tp(i, k) = tv(i, k) 1608 tvp(i, k) = tv(i, k) 1609 END IF 1642 1610 END IF 1643 END IF 1644 !CR: fin test 1645 IF (t(i,k)<263.15) THEN 1646 !CR: on commente les calculs d'Arnaud car division par zero 1647 ! nouveau calcul propose par JYG 1648 ! alv=lv0-clmcpv*(t(i,k)-273.15) 1649 ! alf=lf0-clmci*(t(i,k)-273.15) 1650 ! tg=tp(i,k) 1651 ! tc=tp(i,k)-273.15 1652 ! denom=243.5+tc 1653 ! do j=1,3 1654 ! cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc 1655 ! il faudra que esi vienne en argument de la convection 1656 ! cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc 1657 ! tbis=t(i,k)+(tp(i,k)-tg) 1658 ! esi=exp(23.33086-(6111.72784/tbis) + & 1659 ! 0.15215*log(tbis)) 1660 ! qsat_new=eps*esi/(p(i,k)-esi*(1.-eps)) 1661 ! snew=cpd*(1.-qnk(i))+cl*qnk(i)+alv*alv*qsat_new/ & 1662 ! (rrv*tbis*tbis) 1663 ! snew=1./snew 1664 ! PRINT*,esi,qsat_new,snew,'esi,qsat,snew' 1665 ! tp(i,k)=tg+(alf*qi(i,k)+alv*qg*(1.-(esi/es)))*snew 1666 ! PRINT*,k,tp(i,k),qnk(i),'avec glace' 1667 ! PRINT*,'tpNAN',tg,alf,qi(i,k),alv,qg,esi,es,snew 1668 ! enddo 1669 1670 alv = lv0 - clmcpv*(t(i,k)-273.15) 1671 alf = lf0 + clmci*(t(i,k)-273.15) 1672 als = alf + alv 1673 tg = tp(i, k) 1674 tp(i, k) = t(i, k) 1675 DO j = 1, 3 1676 esi = exp(23.33086-(6111.72784/tp(i,k))+0.15215*log(tp(i,k))) 1677 qsat_new = eps*esi/(p(i,k)-esi*(1.-eps)) 1678 snew = cpd*(1.-qnk(i)) + cl*qnk(i) + alv*als*qsat_new/ & 1679 (rrv*tp(i,k)*tp(i,k)) 1680 snew = 1./snew 1681 ! c PRINT*,esi,qsat_new,snew,'esi,qsat,snew' 1682 tp(i, k) = tp(i, k) + & 1683 ((cpd*(1.-qnk(i))+cl*qnk(i))*(tg-tp(i,k)) + & 1684 alv*(qg-qsat_new)+alf*qi(i,k))*snew 1685 ! PRINT*,k,tp(i,k),qsat_new,qnk(i),qi(i,k), & 1686 ! 'k,tp,q,qt,qi avec glace' 1687 END DO 1688 1689 !CR:reprise du code AJ 1690 clw(i, k) = qnk(i) - qsat_new 1691 clw(i, k) = max(0.0, clw(i,k)) 1692 tvp(i, k) = max(0., tp(i,k)*(1.+qsat_new/eps-qnk(i))) 1693 ! PRINT*,tvp(i,k),'tvp' 1694 END IF 1695 IF (clw(i,k)<1.E-11) THEN 1696 tp(i, k) = tv(i, k) 1697 tvp(i, k) = tv(i, k) 1698 END IF 1699 END IF ! (cvflag_ice) 1700 !jyg< 1701 END IF ! (k>=(icbs(i)+1)) 1702 !>jyg 1703 END DO 1704 END DO 1705 1706 !---------------------------------------------------------------------------- 1611 !jyg< 1612 !! END IF ! Endif moved to the end of the loop 1613 !>jyg 1614 1615 IF (cvflag_ice) THEN 1616 !CR:attention boucle en klon dans Icefrac 1617 ! Call Icefrac(t,clw,qi,nl,nloc) 1618 IF (t(i, k)>263.15) THEN 1619 qi(i, k) = 0. 1620 ELSE 1621 IF (t(i, k)<243.15) THEN 1622 qi(i, k) = clw(i, k) 1623 ELSE 1624 fracg = (263.15 - t(i, k)) / 20 1625 qi(i, k) = clw(i, k) * fracg 1626 END IF 1627 END IF 1628 !CR: fin test 1629 IF (t(i, k)<263.15) THEN 1630 !CR: on commente les calculs d'Arnaud car division par zero 1631 ! nouveau calcul propose par JYG 1632 ! alv=lv0-clmcpv*(t(i,k)-273.15) 1633 ! alf=lf0-clmci*(t(i,k)-273.15) 1634 ! tg=tp(i,k) 1635 ! tc=tp(i,k)-273.15 1636 ! denom=243.5+tc 1637 ! do j=1,3 1638 ! cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc 1639 ! il faudra que esi vienne en argument de la convection 1640 ! cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc 1641 ! tbis=t(i,k)+(tp(i,k)-tg) 1642 ! esi=exp(23.33086-(6111.72784/tbis) + & 1643 ! 0.15215*log(tbis)) 1644 ! qsat_new=eps*esi/(p(i,k)-esi*(1.-eps)) 1645 ! snew=cpd*(1.-qnk(i))+cl*qnk(i)+alv*alv*qsat_new/ & 1646 ! (rrv*tbis*tbis) 1647 ! snew=1./snew 1648 ! PRINT*,esi,qsat_new,snew,'esi,qsat,snew' 1649 ! tp(i,k)=tg+(alf*qi(i,k)+alv*qg*(1.-(esi/es)))*snew 1650 ! PRINT*,k,tp(i,k),qnk(i),'avec glace' 1651 ! PRINT*,'tpNAN',tg,alf,qi(i,k),alv,qg,esi,es,snew 1652 ! enddo 1653 1654 alv = lv0 - clmcpv * (t(i, k) - 273.15) 1655 alf = lf0 + clmci * (t(i, k) - 273.15) 1656 als = alf + alv 1657 tg = tp(i, k) 1658 tp(i, k) = t(i, k) 1659 DO j = 1, 3 1660 esi = exp(23.33086 - (6111.72784 / tp(i, k)) + 0.15215 * log(tp(i, k))) 1661 qsat_new = eps * esi / (p(i, k) - esi * (1. - eps)) 1662 snew = cpd * (1. - qnk(i)) + cl * qnk(i) + alv * als * qsat_new / & 1663 (rrv * tp(i, k) * tp(i, k)) 1664 snew = 1. / snew 1665 ! c PRINT*,esi,qsat_new,snew,'esi,qsat,snew' 1666 tp(i, k) = tp(i, k) + & 1667 ((cpd * (1. - qnk(i)) + cl * qnk(i)) * (tg - tp(i, k)) + & 1668 alv * (qg - qsat_new) + alf * qi(i, k)) * snew 1669 ! PRINT*,k,tp(i,k),qsat_new,qnk(i),qi(i,k), & 1670 ! 'k,tp,q,qt,qi avec glace' 1671 END DO 1672 1673 !CR:reprise du code AJ 1674 clw(i, k) = qnk(i) - qsat_new 1675 clw(i, k) = max(0.0, clw(i, k)) 1676 tvp(i, k) = max(0., tp(i, k) * (1. + qsat_new / eps - qnk(i))) 1677 ! PRINT*,tvp(i,k),'tvp' 1678 END IF 1679 IF (clw(i, k)<1.E-11) THEN 1680 tp(i, k) = tv(i, k) 1681 tvp(i, k) = tv(i, k) 1682 END IF 1683 END IF ! (cvflag_ice) 1684 !jyg< 1685 END IF ! (k>=(icbs(i)+1)) 1686 !>jyg 1687 END DO 1688 END DO 1689 1690 !---------------------------------------------------------------------------- 1707 1691 1708 1692 ENDIF ! (icvflag_Tpa == 2) ELSEIF (icvflag_Tpa == 1) ELSE (icvflag_Tpa == 0) 1709 1693 1710 !----------------------------------------------------------------------------1711 1712 ! =====================================================================1713 ! --- SET THE PRECIPITATION EFFICIENCIES 1714 ! --- THESE MAY BE FUNCTIONS OF TP(I), P(I) AND CLW(I)1715 ! =====================================================================1694 !---------------------------------------------------------------------------- 1695 1696 ! ===================================================================== 1697 ! --- SET THE PRECIPITATION EFFICIENCIES 1698 ! --- THESE MAY BE FUNCTIONS OF TP(I), P(I) AND CLW(I) 1699 ! ===================================================================== 1716 1700 1717 1701 IF (flag_epkeorig/=1) THEN 1718 1702 DO k = 1, nl ! convect3 1719 1703 DO i = 1, ncum 1720 !jyg<1721 IF(k>=icb(i)) THEN1722 !>jyg1723 pden = ptcrit - pbcrit1724 ep(i, k) = (plcl(i)-p(i,k)-pbcrit)/pden*epmax1725 ep(i, k) = max(ep(i,k), 0.0)1726 ep(i, k) = min(ep(i,k), epmax)1727 !! sigp(i, k) = spfac ! jyg1704 !jyg< 1705 IF(k>=icb(i)) THEN 1706 !>jyg 1707 pden = ptcrit - pbcrit 1708 ep(i, k) = (plcl(i) - p(i, k) - pbcrit) / pden * epmax 1709 ep(i, k) = max(ep(i, k), 0.0) 1710 ep(i, k) = min(ep(i, k), epmax) 1711 !! sigp(i, k) = spfac ! jyg 1728 1712 ENDIF ! (k>=icb(i)) 1729 1713 END DO … … 1733 1717 DO i = 1, ncum 1734 1718 IF(k>=icb(i)) THEN 1735 !! IF (k>=(nk(i)+1)) THEN1736 !>jyg1719 !! IF (k>=(nk(i)+1)) THEN 1720 !>jyg 1737 1721 tca = tp(i, k) - t0 1738 1722 IF (tca>=0.0) THEN 1739 1723 elacrit = elcrit 1740 1724 ELSE 1741 elacrit = elcrit *(1.0-tca/tlcrit)1725 elacrit = elcrit * (1.0 - tca / tlcrit) 1742 1726 END IF 1743 1727 elacrit = max(elacrit, 0.0) 1744 ep(i, k) = 1.0 - elacrit /max(clw(i,k), 1.0E-8)1745 ep(i, k) = max(ep(i, k), 0.0)1746 ep(i, k) = min(ep(i, k), epmax)1747 !! sigp(i, k) = spfac ! jyg1728 ep(i, k) = 1.0 - elacrit / max(clw(i, k), 1.0E-8) 1729 ep(i, k) = max(ep(i, k), 0.0) 1730 ep(i, k) = min(ep(i, k), epmax) 1731 !! sigp(i, k) = spfac ! jyg 1748 1732 END IF ! (k>=icb(i)) 1749 1733 END DO … … 1751 1735 END IF 1752 1736 1753 ! =========================================================================1737 ! ========================================================================= 1754 1738 IF (prt_level >= 10) THEN 1755 print *, 'cv3_undilute2.1. tp(1,k), tvp(1,k) ', &1756 (k, tp(1,k), tvp(1,k), k = 1,nl)1739 print *, 'cv3_undilute2.1. tp(1,k), tvp(1,k) ', & 1740 (k, tp(1, k), tvp(1, k), k = 1, nl) 1757 1741 ENDIF 1758 1742 1759 ! =====================================================================1760 ! --- CALCULATE VIRTUAL TEMPERATURE AND LIFTED PARCEL1761 ! --- VIRTUAL TEMPERATURE1762 ! =====================================================================1763 1764 ! dans convect3, tvp est calcule en une seule fois, et sans retirer1765 ! l'eau condensee (~> reversible CAPE)1766 1767 ! ori do 340 k=minorig+1,nl1768 ! ori do 330 i=1,ncum1769 ! ori IF(k.ge.(icb(i)+1))THEN1770 ! ori tvp(i,k)=tvp(i,k)*(1.0-qnk(i)+ep(i,k)*clw(i,k))1771 ! oric PRINT*,'i,k,tvp(i,k),qnk(i),ep(i,k),clw(i,k)'1772 ! oric PRINT*, i,k,tvp(i,k),qnk(i),ep(i,k),clw(i,k)1773 ! ori endif1774 ! ori 330 continue1775 ! ori 340 continue1776 1777 ! ori do 350 i=1,ncum1778 ! ori tvp(i,nlp)=tvp(i,nl)-(gz(i,nlp)-gz(i,nl))/cpd1779 ! ori 350 continue1743 ! ===================================================================== 1744 ! --- CALCULATE VIRTUAL TEMPERATURE AND LIFTED PARCEL 1745 ! --- VIRTUAL TEMPERATURE 1746 ! ===================================================================== 1747 1748 ! dans convect3, tvp est calcule en une seule fois, et sans retirer 1749 ! l'eau condensee (~> reversible CAPE) 1750 1751 ! ori do 340 k=minorig+1,nl 1752 ! ori do 330 i=1,ncum 1753 ! ori IF(k.ge.(icb(i)+1))THEN 1754 ! ori tvp(i,k)=tvp(i,k)*(1.0-qnk(i)+ep(i,k)*clw(i,k)) 1755 ! oric PRINT*,'i,k,tvp(i,k),qnk(i),ep(i,k),clw(i,k)' 1756 ! oric PRINT*, i,k,tvp(i,k),qnk(i),ep(i,k),clw(i,k) 1757 ! ori endif 1758 ! ori 330 continue 1759 ! ori 340 continue 1760 1761 ! ori do 350 i=1,ncum 1762 ! ori tvp(i,nlp)=tvp(i,nl)-(gz(i,nlp)-gz(i,nl))/cpd 1763 ! ori 350 continue 1780 1764 1781 1765 DO i = 1, ncum ! convect3 … … 1783 1767 END DO ! convect3 1784 1768 1785 ! =====================================================================1786 ! --- EFFECTIVE VERTICAL PROFILE OF BUOYANCY (convect3 only):1787 ! =====================================================================1788 1789 ! -- this is for convect3 only:1790 1791 ! first estimate of buoyancy:1792 1793 !jyg : k-loop outside i-loop (07042015)1769 ! ===================================================================== 1770 ! --- EFFECTIVE VERTICAL PROFILE OF BUOYANCY (convect3 only): 1771 ! ===================================================================== 1772 1773 ! -- this is for convect3 only: 1774 1775 ! first estimate of buoyancy: 1776 1777 !jyg : k-loop outside i-loop (07042015) 1794 1778 DO k = 1, nl 1795 1779 DO i = 1, ncum … … 1798 1782 END DO 1799 1783 1800 ! set buoyancy=buoybase for all levels below base1801 ! for safety, set buoy(icb)=buoybase1802 1803 !jyg : k-loop outside i-loop (07042015)1784 ! set buoyancy=buoybase for all levels below base 1785 ! for safety, set buoy(icb)=buoybase 1786 1787 !jyg : k-loop outside i-loop (07042015) 1804 1788 DO k = 1, nl 1805 1789 DO i = 1, ncum 1806 IF ((k>=icb(i)) .AND. (k<=nl) .AND. (p(i, k)>=pbase(i))) THEN1790 IF ((k>=icb(i)) .AND. (k<=nl) .AND. (p(i, k)>=pbase(i))) THEN 1807 1791 buoy(i, k) = buoybase(i) 1808 1792 END IF … … 1810 1794 END DO 1811 1795 DO i = 1, ncum 1812 ! buoy(icb(i),k)=buoybase(i)1796 ! buoy(icb(i),k)=buoybase(i) 1813 1797 buoy(i, icb(i)) = buoybase(i) 1814 1798 END DO 1815 1799 1816 ! -- end convect31817 1818 ! =====================================================================1819 ! --- FIND THE FIRST MODEL LEVEL (INB) ABOVE THE PARCEL'S1820 ! --- LEVEL OF NEUTRAL BUOYANCY1821 ! =====================================================================1822 1823 ! -- this is for convect3 only:1800 ! -- end convect3 1801 1802 ! ===================================================================== 1803 ! --- FIND THE FIRST MODEL LEVEL (INB) ABOVE THE PARCEL'S 1804 ! --- LEVEL OF NEUTRAL BUOYANCY 1805 ! ===================================================================== 1806 1807 ! -- this is for convect3 only: 1824 1808 1825 1809 DO i = 1, ncum … … 1829 1813 1830 1814 1831 ! -- iposit(i) = first level, above icb, with positive buoyancy1815 ! -- iposit(i) = first level, above icb, with positive buoyancy 1832 1816 DO k = 1, nl - 1 1833 1817 DO i = 1, ncum 1834 IF (k>=icb(i) .AND. buoy(i, k)>0.) THEN1818 IF (k>=icb(i) .AND. buoy(i, k)>0.) THEN 1835 1819 iposit(i) = min(iposit(i), k) 1836 1820 END IF … … 1846 1830 DO k = 1, nl - 1 1847 1831 DO i = 1, ncum 1848 IF ((k>=iposit(i)) .AND. (buoy(i, k)<dtovsh)) THEN1832 IF ((k>=iposit(i)) .AND. (buoy(i, k)<dtovsh)) THEN 1849 1833 inb(i) = min(inb(i), k) 1850 1834 END IF … … 1852 1836 END DO 1853 1837 1854 !CR fix computation of inb1855 !keep flag or modify in all cases?1838 !CR fix computation of inb 1839 !keep flag or modify in all cases? 1856 1840 IF (iflag_mix_adiab==1) THEN 1841 DO i = 1, ncum 1842 cape(i) = 0. 1843 inb(i) = icb(i) + 1 1844 ENDDO 1845 1846 DO k = 2, nl 1847 DO i = 1, ncum 1848 IF ((k>=iposit(i))) THEN 1849 deltap = min(plcl(i), ph(i, k - 1)) - min(plcl(i), ph(i, k)) 1850 cape(i) = cape(i) + rrd * buoy(i, k - 1) * deltap / p(i, k - 1) 1851 IF (cape(i)>0.) THEN 1852 inb(i) = max(inb(i), k) 1853 END IF 1854 ENDIF 1855 ENDDO 1856 ENDDO 1857 1858 ! DO i = 1, ncum 1859 ! PRINT*,"inb",inb(i) 1860 ! ENDDO 1861 1862 ENDIF 1863 1864 ! -- end convect3 1865 1866 ! ori do 510 i=1,ncum 1867 ! ori cape(i)=0.0 1868 ! ori capem(i)=0.0 1869 ! ori inb(i)=icb(i)+1 1870 ! ori inb1(i)=inb(i) 1871 ! ori 510 continue 1872 1873 ! Originial Code 1874 1875 ! do 530 k=minorig+1,nl-1 1876 ! do 520 i=1,ncum 1877 ! IF(k.ge.(icb(i)+1))THEN 1878 ! by=(tvp(i,k)-tv(i,k))*dph(i,k)/p(i,k) 1879 ! byp=(tvp(i,k+1)-tv(i,k+1))*dph(i,k+1)/p(i,k+1) 1880 ! cape(i)=cape(i)+by 1881 ! IF(by.ge.0.0)inb1(i)=k+1 1882 ! IF(cape(i).gt.0.0)THEN 1883 ! inb(i)=k+1 1884 ! capem(i)=cape(i) 1885 ! endif 1886 ! endif 1887 !520 continue 1888 !530 continue 1889 ! do 540 i=1,ncum 1890 ! byp=(tvp(i,nl)-tv(i,nl))*dph(i,nl)/p(i,nl) 1891 ! cape(i)=capem(i)+byp 1892 ! defrac=capem(i)-cape(i) 1893 ! defrac=max(defrac,0.001) 1894 ! frac(i)=-cape(i)/defrac 1895 ! frac(i)=min(frac(i),1.0) 1896 ! frac(i)=max(frac(i),0.0) 1897 !540 continue 1898 1899 ! K Emanuel fix 1900 1901 ! CALL zilch(byp,ncum) 1902 ! do 530 k=minorig+1,nl-1 1903 ! do 520 i=1,ncum 1904 ! IF(k.ge.(icb(i)+1))THEN 1905 ! by=(tvp(i,k)-tv(i,k))*dph(i,k)/p(i,k) 1906 ! cape(i)=cape(i)+by 1907 ! IF(by.ge.0.0)inb1(i)=k+1 1908 ! IF(cape(i).gt.0.0)THEN 1909 ! inb(i)=k+1 1910 ! capem(i)=cape(i) 1911 ! byp(i)=(tvp(i,k+1)-tv(i,k+1))*dph(i,k+1)/p(i,k+1) 1912 ! endif 1913 ! endif 1914 !520 continue 1915 !530 continue 1916 ! do 540 i=1,ncum 1917 ! inb(i)=max(inb(i),inb1(i)) 1918 ! cape(i)=capem(i)+byp(i) 1919 ! defrac=capem(i)-cape(i) 1920 ! defrac=max(defrac,0.001) 1921 ! frac(i)=-cape(i)/defrac 1922 ! frac(i)=min(frac(i),1.0) 1923 ! frac(i)=max(frac(i),0.0) 1924 !540 continue 1925 1926 ! J Teixeira fix 1927 1928 ! ori CALL zilch(byp,ncum) 1929 ! ori do 515 i=1,ncum 1930 ! ori lcape(i)=.TRUE. 1931 ! ori 515 continue 1932 ! ori do 530 k=minorig+1,nl-1 1933 ! ori do 520 i=1,ncum 1934 ! ori IF(cape(i).lt.0.0)lcape(i)=.FALSE. 1935 ! ori if((k.ge.(icb(i)+1)).AND.lcape(i))THEN 1936 ! ori by=(tvp(i,k)-tv(i,k))*dph(i,k)/p(i,k) 1937 ! ori byp(i)=(tvp(i,k+1)-tv(i,k+1))*dph(i,k+1)/p(i,k+1) 1938 ! ori cape(i)=cape(i)+by 1939 ! ori IF(by.ge.0.0)inb1(i)=k+1 1940 ! ori IF(cape(i).gt.0.0)THEN 1941 ! ori inb(i)=k+1 1942 ! ori capem(i)=cape(i) 1943 ! ori endif 1944 ! ori endif 1945 ! ori 520 continue 1946 ! ori 530 continue 1947 ! ori do 540 i=1,ncum 1948 ! ori cape(i)=capem(i)+byp(i) 1949 ! ori defrac=capem(i)-cape(i) 1950 ! ori defrac=max(defrac,0.001) 1951 ! ori frac(i)=-cape(i)/defrac 1952 ! ori frac(i)=min(frac(i),1.0) 1953 ! ori frac(i)=max(frac(i),0.0) 1954 ! ori 540 continue 1955 1956 ! -------------------------------------------------------------------- 1957 ! Prevent convection when top is too hot 1958 ! -------------------------------------------------------------------- 1857 1959 DO i = 1, ncum 1858 cape(i)=0. 1859 inb(i)=icb(i)+1 1960 IF (t(i, inb(i)) > T_top_max) iflag(i) = 10 1860 1961 ENDDO 1861 1862 DO k = 2, nl 1863 DO i = 1, ncum 1864 IF ((k>=iposit(i))) THEN 1865 deltap = min(plcl(i), ph(i,k-1)) - min(plcl(i), ph(i,k)) 1866 cape(i) = cape(i) + rrd*buoy(i, k-1)*deltap/p(i, k-1) 1867 IF (cape(i)>0.) THEN 1868 inb(i) = max(inb(i), k) 1869 END IF 1870 ENDIF 1871 ENDDO 1872 ENDDO 1873 1874 ! DO i = 1, ncum 1875 ! PRINT*,"inb",inb(i) 1876 ! ENDDO 1877 1878 ENDIF 1879 1880 ! -- end convect3 1881 1882 ! ori do 510 i=1,ncum 1883 ! ori cape(i)=0.0 1884 ! ori capem(i)=0.0 1885 ! ori inb(i)=icb(i)+1 1886 ! ori inb1(i)=inb(i) 1887 ! ori 510 continue 1888 1889 ! Originial Code 1890 1891 ! do 530 k=minorig+1,nl-1 1892 ! do 520 i=1,ncum 1893 ! IF(k.ge.(icb(i)+1))THEN 1894 ! by=(tvp(i,k)-tv(i,k))*dph(i,k)/p(i,k) 1895 ! byp=(tvp(i,k+1)-tv(i,k+1))*dph(i,k+1)/p(i,k+1) 1896 ! cape(i)=cape(i)+by 1897 ! IF(by.ge.0.0)inb1(i)=k+1 1898 ! IF(cape(i).gt.0.0)THEN 1899 ! inb(i)=k+1 1900 ! capem(i)=cape(i) 1901 ! endif 1902 ! endif 1903 !520 continue 1904 !530 continue 1905 ! do 540 i=1,ncum 1906 ! byp=(tvp(i,nl)-tv(i,nl))*dph(i,nl)/p(i,nl) 1907 ! cape(i)=capem(i)+byp 1908 ! defrac=capem(i)-cape(i) 1909 ! defrac=max(defrac,0.001) 1910 ! frac(i)=-cape(i)/defrac 1911 ! frac(i)=min(frac(i),1.0) 1912 ! frac(i)=max(frac(i),0.0) 1913 !540 continue 1914 1915 ! K Emanuel fix 1916 1917 ! CALL zilch(byp,ncum) 1918 ! do 530 k=minorig+1,nl-1 1919 ! do 520 i=1,ncum 1920 ! IF(k.ge.(icb(i)+1))THEN 1921 ! by=(tvp(i,k)-tv(i,k))*dph(i,k)/p(i,k) 1922 ! cape(i)=cape(i)+by 1923 ! IF(by.ge.0.0)inb1(i)=k+1 1924 ! IF(cape(i).gt.0.0)THEN 1925 ! inb(i)=k+1 1926 ! capem(i)=cape(i) 1927 ! byp(i)=(tvp(i,k+1)-tv(i,k+1))*dph(i,k+1)/p(i,k+1) 1928 ! endif 1929 ! endif 1930 !520 continue 1931 !530 continue 1932 ! do 540 i=1,ncum 1933 ! inb(i)=max(inb(i),inb1(i)) 1934 ! cape(i)=capem(i)+byp(i) 1935 ! defrac=capem(i)-cape(i) 1936 ! defrac=max(defrac,0.001) 1937 ! frac(i)=-cape(i)/defrac 1938 ! frac(i)=min(frac(i),1.0) 1939 ! frac(i)=max(frac(i),0.0) 1940 !540 continue 1941 1942 ! J Teixeira fix 1943 1944 ! ori CALL zilch(byp,ncum) 1945 ! ori do 515 i=1,ncum 1946 ! ori lcape(i)=.TRUE. 1947 ! ori 515 continue 1948 ! ori do 530 k=minorig+1,nl-1 1949 ! ori do 520 i=1,ncum 1950 ! ori IF(cape(i).lt.0.0)lcape(i)=.FALSE. 1951 ! ori if((k.ge.(icb(i)+1)).AND.lcape(i))THEN 1952 ! ori by=(tvp(i,k)-tv(i,k))*dph(i,k)/p(i,k) 1953 ! ori byp(i)=(tvp(i,k+1)-tv(i,k+1))*dph(i,k+1)/p(i,k+1) 1954 ! ori cape(i)=cape(i)+by 1955 ! ori IF(by.ge.0.0)inb1(i)=k+1 1956 ! ori IF(cape(i).gt.0.0)THEN 1957 ! ori inb(i)=k+1 1958 ! ori capem(i)=cape(i) 1959 ! ori endif 1960 ! ori endif 1961 ! ori 520 continue 1962 ! ori 530 continue 1963 ! ori do 540 i=1,ncum 1964 ! ori cape(i)=capem(i)+byp(i) 1965 ! ori defrac=capem(i)-cape(i) 1966 ! ori defrac=max(defrac,0.001) 1967 ! ori frac(i)=-cape(i)/defrac 1968 ! ori frac(i)=min(frac(i),1.0) 1969 ! ori frac(i)=max(frac(i),0.0) 1970 ! ori 540 continue 1971 1972 ! -------------------------------------------------------------------- 1973 ! Prevent convection when top is too hot 1974 ! -------------------------------------------------------------------- 1975 DO i = 1,ncum 1976 IF (t(i,inb(i)) > T_top_max) iflag(i) = 10 1977 ENDDO 1978 1979 ! ===================================================================== 1980 ! --- CALCULATE LIQUID WATER STATIC ENERGY OF LIFTED PARCEL 1981 ! ===================================================================== 1962 1963 ! ===================================================================== 1964 ! --- CALCULATE LIQUID WATER STATIC ENERGY OF LIFTED PARCEL 1965 ! ===================================================================== 1982 1966 1983 1967 DO k = 1, nl … … 1987 1971 END DO 1988 1972 1989 !jyg : cvflag_ice test outside the loops (07042015)1973 !jyg : cvflag_ice test outside the loops (07042015) 1990 1974 1991 1975 IF (cvflag_ice) THEN 1992 1976 1993 IF (cvflag_prec_eject) THEN 1994 !! DO k = minorig + 1, nl 1995 !! DO i = 1, ncum 1996 !! IF ((k>=icb(i)) .AND. (k<=inb(i))) THEN 1997 !! frac_s(i,k) = qi(i,k)/max(clw(i,k),smallestreal) 1998 !! frac_s(i,k) = 1. - (qpl(i,k)+(1.-frac_s(i,k))*qcld(i,k))/max(clw(i,k),smallestreal) 1999 !! END IF 2000 !! END DO 2001 !! END DO 2002 ELSE ! (cvflag_prec_eject) 1977 IF (cvflag_prec_eject) THEN 1978 !! DO k = minorig + 1, nl 1979 !! DO i = 1, ncum 1980 !! IF ((k>=icb(i)) .AND. (k<=inb(i))) THEN 1981 !! frac_s(i,k) = qi(i,k)/max(clw(i,k),smallestreal) 1982 !! frac_s(i,k) = 1. - (qpl(i,k)+(1.-frac_s(i,k))*qcld(i,k))/max(clw(i,k),smallestreal) 1983 !! END IF 1984 !! END DO 1985 !! END DO 1986 ELSE ! (cvflag_prec_eject) 1987 DO k = minorig + 1, nl 1988 DO i = 1, ncum 1989 IF ((k>=icb(i)) .AND. (k<=inb(i))) THEN 1990 !jyg< frac computation moved to beginning of cv3_undilute2. 1991 ! kept here for compatibility test with CMip6 version 1992 frac_s(i, k) = 1. - (t(i, k) - 243.15) / (263.15 - 243.15) 1993 frac_s(i, k) = min(max(frac_s(i, k), 0.0), 1.0) 1994 END IF 1995 END DO 1996 END DO 1997 ENDIF ! (cvflag_prec_eject) ELSE 2003 1998 DO k = minorig + 1, nl 2004 1999 DO i = 1, ncum 2005 2000 IF ((k>=icb(i)) .AND. (k<=inb(i))) THEN 2006 !jyg< frac computation moved to beginning of cv3_undilute2. 2007 ! kept here for compatibility test with CMip6 version 2008 frac_s(i, k) = 1. - (t(i,k)-243.15)/(263.15-243.15)2009 frac_s(i, k) = min(max(frac_s(i,k),0.0), 1.0)2001 !! hp(i, k) = hnk(i) + (lv(i,k)+(cpd-cpv)*t(i,k)+frac_s(i,k)*lf(i,k))* & !!jygprl 2002 !! ep(i, k)*clw(i, k) !!jygprl 2003 hp(i, k) = hla(i, k - 1) + (lv(i, k) + (cpd - cpv) * t(i, k) + frac_s(i, k) * lf(i, k)) * & !!jygprl 2004 ep(i, k) * clw(i, k) !!jygprl 2010 2005 END IF 2011 2006 END DO 2012 2007 END DO 2013 ENDIF ! (cvflag_prec_eject) ELSE 2008 2009 ELSE ! (cvflag_ice) 2010 2014 2011 DO k = minorig + 1, nl 2015 2012 DO i = 1, ncum 2016 2013 IF ((k>=icb(i)) .AND. (k<=inb(i))) THEN 2017 !! hp(i, k) = hnk(i) + (lv(i,k)+(cpd-cpv)*t(i,k)+frac_s(i,k)*lf(i,k))* & !!jygprl 2018 !! ep(i, k)*clw(i, k) !!jygprl 2019 hp(i, k) = hla(i,k-1) + (lv(i,k)+(cpd-cpv)*t(i,k)+frac_s(i,k)*lf(i,k))* & !!jygprl 2020 ep(i, k)*clw(i, k) !!jygprl 2014 !jyg< (energy conservation tests) 2015 !! hp(i, k) = hnk(i) + (lv(i,k)+(cpd-cpv)*tp(i,k))*ep(i, k)*clw(i, k) 2016 !! hp(i, k) = ( hnk(i) + (lv(i,k)+(cpd-cpv)*t(i,k))*ep(i, k)*clw(i, k) ) / & 2017 !! (1. - ep(i,k)*clw(i,k)) 2018 !! hp(i, k) = ( hnk(i) + (lv(i,k)+(cpd-cl)*t(i,k))*ep(i, k)*clw(i, k) ) / & 2019 !! (1. - ep(i,k)*clw(i,k)) 2020 hp(i, k) = hnk(i) + (lv(i, k) + (cpd - cpv) * t(i, k)) * ep(i, k) * clw(i, k) 2021 2021 END IF 2022 2022 END DO 2023 2023 END DO 2024 2024 2025 ELSE ! (cvflag_ice)2026 2027 DO k = minorig + 1, nl2028 DO i = 1, ncum2029 IF ((k>=icb(i)) .AND. (k<=inb(i))) THEN2030 !jyg< (energy conservation tests)2031 !! hp(i, k) = hnk(i) + (lv(i,k)+(cpd-cpv)*tp(i,k))*ep(i, k)*clw(i, k)2032 !! hp(i, k) = ( hnk(i) + (lv(i,k)+(cpd-cpv)*t(i,k))*ep(i, k)*clw(i, k) ) / &2033 !! (1. - ep(i,k)*clw(i,k))2034 !! hp(i, k) = ( hnk(i) + (lv(i,k)+(cpd-cl)*t(i,k))*ep(i, k)*clw(i, k) ) / &2035 !! (1. - ep(i,k)*clw(i,k))2036 hp(i, k) = hnk(i) + (lv(i,k)+(cpd-cpv)*t(i,k))*ep(i, k)*clw(i, k)2037 END IF2038 END DO2039 END DO2040 2041 2025 END IF ! (cvflag_ice) 2042 2026 2043 2044 2027 END SUBROUTINE cv3_undilute2 2045 2028 2046 SUBROUTINE cv3_closure(nloc, ncum, nd, icb, inb, & 2047 pbase, p, ph, tv, buoy, & 2048 sig, w0, cape, m, iflag) 2029 SUBROUTINE cv3_closure(nloc, ncum, nd, icb, inb, pbase, p, ph, tv, buoy, & 2030 sig, w0, cape, m, iflag) 2031 USE lmdz_cvthermo 2032 USE lmdz_cv3param 2033 2049 2034 IMPLICIT NONE 2050 2035 2051 ! =================================================================== 2052 ! --- CLOSURE OF CONVECT3 2053 2054 ! vectorization: S. Bony 2055 ! =================================================================== 2056 2057 include "cvthermo.h" 2058 include "cv3param.h" 2059 2060 !input: 2036 ! =================================================================== 2037 ! --- CLOSURE OF CONVECT3 2038 2039 ! vectorization: S. Bony 2040 ! =================================================================== 2041 2042 !input: 2061 2043 INTEGER ncum, nd, nloc 2062 2044 INTEGER icb(nloc), inb(nloc) 2063 2045 REAL pbase(nloc) 2064 REAL p(nloc, nd), ph(nloc, nd +1)2046 REAL p(nloc, nd), ph(nloc, nd + 1) 2065 2047 REAL tv(nloc, nd), buoy(nloc, nd) 2066 2048 2067 !input/output:2049 !input/output: 2068 2050 REAL sig(nloc, nd), w0(nloc, nd) 2069 2051 INTEGER iflag(nloc) 2070 2052 2071 !output:2053 !output: 2072 2054 REAL cape(nloc) 2073 2055 REAL m(nloc, nd) 2074 2056 2075 !local variables:2057 !local variables: 2076 2058 INTEGER i, j, k, icbmax 2077 2059 REAL deltap, fac, w, amu … … 2080 2062 2081 2063 2082 ! -------------------------------------------------------2083 ! -- Initialization2084 ! -------------------------------------------------------2064 ! ------------------------------------------------------- 2065 ! -- Initialization 2066 ! ------------------------------------------------------- 2085 2067 2086 2068 DO k = 1, nl … … 2090 2072 END DO 2091 2073 2092 ! -------------------------------------------------------2093 ! -- Reset sig(i) and w0(i) for i>inb and i<icb2094 ! -------------------------------------------------------2095 2096 ! update sig and w0 above LNB:2074 ! ------------------------------------------------------- 2075 ! -- Reset sig(i) and w0(i) for i>inb and i<icb 2076 ! ------------------------------------------------------- 2077 2078 ! update sig and w0 above LNB: 2097 2079 2098 2080 DO k = 1, nl - 1 2099 2081 DO i = 1, ncum 2100 IF ((inb(i)<(nl -1)) .AND. (k>=(inb(i)+1))) THEN2101 sig(i, k) = beta *sig(i, k) + &2102 2.*alpha*buoy(i, inb(i))*abs(buoy(i,inb(i)))2103 sig(i, k) = amax1(sig(i, k), 0.0)2104 w0(i, k) = beta *w0(i, k)2082 IF ((inb(i)<(nl - 1)) .AND. (k>=(inb(i) + 1))) THEN 2083 sig(i, k) = beta * sig(i, k) + & 2084 2. * alpha * buoy(i, inb(i)) * abs(buoy(i, inb(i))) 2085 sig(i, k) = amax1(sig(i, k), 0.0) 2086 w0(i, k) = beta * w0(i, k) 2105 2087 END IF 2106 2088 END DO 2107 2089 END DO 2108 2090 2109 ! compute icbmax:2091 ! compute icbmax: 2110 2092 2111 2093 icbmax = 2 … … 2114 2096 END DO 2115 2097 2116 ! update sig and w0 below cloud base:2098 ! update sig and w0 below cloud base: 2117 2099 2118 2100 DO k = 1, icbmax 2119 2101 DO i = 1, ncum 2120 2102 IF (k<=icb(i)) THEN 2121 sig(i, k) = beta *sig(i, k) - &2122 2.*alpha*buoy(i, icb(i))*buoy(i, icb(i))2123 sig(i, k) = max(sig(i, k), 0.0)2124 w0(i, k) = beta *w0(i, k)2103 sig(i, k) = beta * sig(i, k) - & 2104 2. * alpha * buoy(i, icb(i)) * buoy(i, icb(i)) 2105 sig(i, k) = max(sig(i, k), 0.0) 2106 w0(i, k) = beta * w0(i, k) 2125 2107 END IF 2126 2108 END DO 2127 2109 END DO 2128 2110 2129 !! IF(inb.lt.(nl-1))THEN2130 !! do 85 i=inb+1,nl-12131 !! sig(i)=beta*sig(i)+2.*alpha*buoy(inb)*2132 !! 1 abs(buoy(inb))2133 !! sig(i)=max(sig(i),0.0)2134 !! w0(i)=beta*w0(i)2135 !! 85 continue2136 !! end if2137 2138 !! do 87 i=1,icb2139 !! sig(i)=beta*sig(i)-2.*alpha*buoy(icb)*buoy(icb)2140 !! sig(i)=max(sig(i),0.0)2141 !! w0(i)=beta*w0(i)2142 !! 87 continue2143 2144 ! -------------------------------------------------------------2145 ! -- Reset fractional areas of updrafts and w0 at initial time2146 ! -- and after 10 time steps of no convection2147 ! -------------------------------------------------------------2111 !! IF(inb.lt.(nl-1))THEN 2112 !! do 85 i=inb+1,nl-1 2113 !! sig(i)=beta*sig(i)+2.*alpha*buoy(inb)* 2114 !! 1 abs(buoy(inb)) 2115 !! sig(i)=max(sig(i),0.0) 2116 !! w0(i)=beta*w0(i) 2117 !! 85 continue 2118 !! end if 2119 2120 !! do 87 i=1,icb 2121 !! sig(i)=beta*sig(i)-2.*alpha*buoy(icb)*buoy(icb) 2122 !! sig(i)=max(sig(i),0.0) 2123 !! w0(i)=beta*w0(i) 2124 !! 87 continue 2125 2126 ! ------------------------------------------------------------- 2127 ! -- Reset fractional areas of updrafts and w0 at initial time 2128 ! -- and after 10 time steps of no convection 2129 ! ------------------------------------------------------------- 2148 2130 2149 2131 DO k = 1, nl - 1 2150 2132 DO i = 1, ncum 2151 IF (sig(i, nd)<1.5 .OR. sig(i,nd)>12.0) THEN2133 IF (sig(i, nd)<1.5 .OR. sig(i, nd)>12.0) THEN 2152 2134 sig(i, k) = 0.0 2153 2135 w0(i, k) = 0.0 … … 2156 2138 END DO 2157 2139 2158 ! -------------------------------------------------------------2159 ! -- Calculate convective available potential energy (cape),2160 ! -- vertical velocity (w), fractional area covered by2161 ! -- undilute updraft (sig), and updraft mass flux (m)2162 ! -------------------------------------------------------------2140 ! ------------------------------------------------------------- 2141 ! -- Calculate convective available potential energy (cape), 2142 ! -- vertical velocity (w), fractional area covered by 2143 ! -- undilute updraft (sig), and updraft mass flux (m) 2144 ! ------------------------------------------------------------- 2163 2145 2164 2146 DO i = 1, ncum … … 2166 2148 END DO 2167 2149 2168 ! compute dtmin (minimum buoyancy between ICB and given level k):2150 ! compute dtmin (minimum buoyancy between ICB and given level k): 2169 2151 2170 2152 DO i = 1, ncum … … 2177 2159 DO k = 1, nl 2178 2160 DO j = minorig, nl 2179 IF ((k>=(icb(i) +1)) .AND. (k<=inb(i)) .AND. (j>=icb(i)) .AND. (j<=(k-1))) THEN2180 dtmin(i, k) = amin1(dtmin(i, k), buoy(i,j))2161 IF ((k>=(icb(i) + 1)) .AND. (k<=inb(i)) .AND. (j>=icb(i)) .AND. (j<=(k - 1))) THEN 2162 dtmin(i, k) = amin1(dtmin(i, k), buoy(i, j)) 2181 2163 END IF 2182 2164 END DO … … 2184 2166 END DO 2185 2167 2186 ! the interval on which cape is computed starts at pbase :2168 ! the interval on which cape is computed starts at pbase : 2187 2169 2188 2170 DO k = 1, nl 2189 2171 DO i = 1, ncum 2190 2172 2191 IF ((k>=(icb(i) +1)) .AND. (k<=inb(i))) THEN2192 2193 deltap = min(pbase(i), ph(i, k-1)) - min(pbase(i), ph(i,k))2194 cape(i) = cape(i) + rrd *buoy(i, k-1)*deltap/p(i, k-1)2173 IF ((k>=(icb(i) + 1)) .AND. (k<=inb(i))) THEN 2174 2175 deltap = min(pbase(i), ph(i, k - 1)) - min(pbase(i), ph(i, k)) 2176 cape(i) = cape(i) + rrd * buoy(i, k - 1) * deltap / p(i, k - 1) 2195 2177 cape(i) = amax1(0.0, cape(i)) 2196 2178 sigold(i, k) = sig(i, k) 2197 2179 2198 ! dtmin(i,k)=100.02199 ! do 97 j=icb(i),k-1 ! mauvaise vectorisation2200 ! dtmin(i,k)=AMIN1(dtmin(i,k),buoy(i,j))2201 ! 97 continue2202 2203 sig(i, k) = beta *sig(i, k) + alpha*dtmin(i, k)*abs(dtmin(i,k))2204 sig(i, k) = max(sig(i, k), 0.0)2205 sig(i, k) = amin1(sig(i, k), 0.01)2206 fac = amin1(((dtcrit -dtmin(i,k))/dtcrit), 1.0)2207 w = (1. -beta)*fac*sqrt(cape(i)) + beta*w0(i, k)2208 amu = 0.5 *(sig(i,k)+sigold(i,k))*w2209 m(i, k) = amu *0.007*p(i, k)*(ph(i,k)-ph(i,k+1))/tv(i, k)2180 ! dtmin(i,k)=100.0 2181 ! do 97 j=icb(i),k-1 ! mauvaise vectorisation 2182 ! dtmin(i,k)=AMIN1(dtmin(i,k),buoy(i,j)) 2183 ! 97 continue 2184 2185 sig(i, k) = beta * sig(i, k) + alpha * dtmin(i, k) * abs(dtmin(i, k)) 2186 sig(i, k) = max(sig(i, k), 0.0) 2187 sig(i, k) = amin1(sig(i, k), 0.01) 2188 fac = amin1(((dtcrit - dtmin(i, k)) / dtcrit), 1.0) 2189 w = (1. - beta) * fac * sqrt(cape(i)) + beta * w0(i, k) 2190 amu = 0.5 * (sig(i, k) + sigold(i, k)) * w 2191 m(i, k) = amu * 0.007 * p(i, k) * (ph(i, k) - ph(i, k + 1)) / tv(i, k) 2210 2192 w0(i, k) = w 2211 2193 END IF … … 2215 2197 2216 2198 DO i = 1, ncum 2217 w0(i, icb(i)) = 0.5*w0(i, icb(i)+1) 2218 m(i, icb(i)) = 0.5*m(i, icb(i)+1)*(ph(i,icb(i))-ph(i,icb(i)+1))/(ph(i,icb(i)+1)-ph(i,icb(i)+2)) 2219 sig(i, icb(i)) = sig(i, icb(i)+1) 2220 sig(i, icb(i)-1) = sig(i, icb(i)) 2221 END DO 2222 2223 ! ccc 3. Compute final cloud base mass flux and set iflag to 3 if 2224 ! ccc cloud base mass flux is exceedingly small and is decreasing (i.e. if 2225 ! ccc the final mass flux (cbmflast) is greater than the target mass flux 2226 ! ccc (cbmf) ??). 2227 ! cc 2228 ! c do i = 1,ncum 2229 ! c cbmflast(i) = 0. 2230 ! c enddo 2231 ! cc 2232 ! c do k= 1,nl 2233 ! c do i = 1,ncum 2234 ! c IF (k .ge. icb(i) .AND. k .le. inb(i)) THEN 2235 ! c cbmflast(i) = cbmflast(i)+M(i,k) 2236 ! c ENDIF 2237 ! c enddo 2238 ! c enddo 2239 ! cc 2240 ! c do i = 1,ncum 2241 ! c IF (cbmflast(i) .lt. 1.e-6) THEN 2242 ! c iflag(i) = 3 2243 ! c ENDIF 2244 ! c enddo 2245 ! cc 2246 ! c do k= 1,nl 2247 ! c do i = 1,ncum 2248 ! c IF (iflag(i) .ge. 3) THEN 2249 ! c M(i,k) = 0. 2250 ! c sig(i,k) = 0. 2251 ! c w0(i,k) = 0. 2252 ! c ENDIF 2253 ! c enddo 2254 ! c enddo 2255 ! cc 2256 !! cape=0.0 2257 !! do 98 i=icb+1,inb 2258 !! deltap = min(pbase,ph(i-1))-min(pbase,ph(i)) 2259 !! cape=cape+rrd*buoy(i-1)*deltap/p(i-1) 2260 !! dcape=rrd*buoy(i-1)*deltap/p(i-1) 2261 !! dlnp=deltap/p(i-1) 2262 !! cape=max(0.0,cape) 2263 !! sigold=sig(i) 2264 2265 !! dtmin=100.0 2266 !! do 97 j=icb,i-1 2267 !! dtmin=amin1(dtmin,buoy(j)) 2268 !! 97 continue 2269 2270 !! sig(i)=beta*sig(i)+alpha*dtmin*abs(dtmin) 2271 !! sig(i)=max(sig(i),0.0) 2272 !! sig(i)=amin1(sig(i),0.01) 2273 !! fac=amin1(((dtcrit-dtmin)/dtcrit),1.0) 2274 !! w=(1.-beta)*fac*sqrt(cape)+beta*w0(i) 2275 !! amu=0.5*(sig(i)+sigold)*w 2276 !! m(i)=amu*0.007*p(i)*(ph(i)-ph(i+1))/tv(i) 2277 !! w0(i)=w 2278 !! 98 continue 2279 !! w0(icb)=0.5*w0(icb+1) 2280 !! m(icb)=0.5*m(icb+1)*(ph(icb)-ph(icb+1))/(ph(icb+1)-ph(icb+2)) 2281 !! sig(icb)=sig(icb+1) 2282 !! sig(icb-1)=sig(icb) 2283 2199 w0(i, icb(i)) = 0.5 * w0(i, icb(i) + 1) 2200 m(i, icb(i)) = 0.5 * m(i, icb(i) + 1) * (ph(i, icb(i)) - ph(i, icb(i) + 1)) / (ph(i, icb(i) + 1) - ph(i, icb(i) + 2)) 2201 sig(i, icb(i)) = sig(i, icb(i) + 1) 2202 sig(i, icb(i) - 1) = sig(i, icb(i)) 2203 END DO 2204 2205 ! ccc 3. Compute final cloud base mass flux and set iflag to 3 if 2206 ! ccc cloud base mass flux is exceedingly small and is decreasing (i.e. if 2207 ! ccc the final mass flux (cbmflast) is greater than the target mass flux 2208 ! ccc (cbmf) ??). 2209 ! cc 2210 ! c do i = 1,ncum 2211 ! c cbmflast(i) = 0. 2212 ! c enddo 2213 ! cc 2214 ! c do k= 1,nl 2215 ! c do i = 1,ncum 2216 ! c IF (k .ge. icb(i) .AND. k .le. inb(i)) THEN 2217 ! c cbmflast(i) = cbmflast(i)+M(i,k) 2218 ! c ENDIF 2219 ! c enddo 2220 ! c enddo 2221 ! cc 2222 ! c do i = 1,ncum 2223 ! c IF (cbmflast(i) .lt. 1.e-6) THEN 2224 ! c iflag(i) = 3 2225 ! c ENDIF 2226 ! c enddo 2227 ! cc 2228 ! c do k= 1,nl 2229 ! c do i = 1,ncum 2230 ! c IF (iflag(i) .ge. 3) THEN 2231 ! c M(i,k) = 0. 2232 ! c sig(i,k) = 0. 2233 ! c w0(i,k) = 0. 2234 ! c ENDIF 2235 ! c enddo 2236 ! c enddo 2237 ! cc 2238 !! cape=0.0 2239 !! do 98 i=icb+1,inb 2240 !! deltap = min(pbase,ph(i-1))-min(pbase,ph(i)) 2241 !! cape=cape+rrd*buoy(i-1)*deltap/p(i-1) 2242 !! dcape=rrd*buoy(i-1)*deltap/p(i-1) 2243 !! dlnp=deltap/p(i-1) 2244 !! cape=max(0.0,cape) 2245 !! sigold=sig(i) 2246 2247 !! dtmin=100.0 2248 !! do 97 j=icb,i-1 2249 !! dtmin=amin1(dtmin,buoy(j)) 2250 !! 97 continue 2251 2252 !! sig(i)=beta*sig(i)+alpha*dtmin*abs(dtmin) 2253 !! sig(i)=max(sig(i),0.0) 2254 !! sig(i)=amin1(sig(i),0.01) 2255 !! fac=amin1(((dtcrit-dtmin)/dtcrit),1.0) 2256 !! w=(1.-beta)*fac*sqrt(cape)+beta*w0(i) 2257 !! amu=0.5*(sig(i)+sigold)*w 2258 !! m(i)=amu*0.007*p(i)*(ph(i)-ph(i+1))/tv(i) 2259 !! w0(i)=w 2260 !! 98 continue 2261 !! w0(icb)=0.5*w0(icb+1) 2262 !! m(icb)=0.5*m(icb+1)*(ph(icb)-ph(icb+1))/(ph(icb+1)-ph(icb+2)) 2263 !! sig(icb)=sig(icb+1) 2264 !! sig(icb-1)=sig(icb) 2284 2265 2285 2266 END SUBROUTINE cv3_closure 2286 2267 2287 2268 SUBROUTINE cv3_mixing(nloc, ncum, nd, na, ntra, icb, nk, inb, & 2288 2289 2290 2269 ph, t, rr, rs, u, v, tra, h, lv, lf, frac, qnk, & 2270 unk, vnk, hp, tv, tvp, ep, clw, m, sig, & 2271 ment, qent, uent, vent, nent, sij, elij, ments, qents, traent) 2291 2272 USE lmdz_cvflag 2273 USE lmdz_cvthermo 2274 USE lmdz_cv3param 2292 2275 2293 2276 IMPLICIT NONE 2294 2277 2295 ! --------------------------------------------------------------------- 2296 ! a faire: 2297 ! - vectorisation de la partie normalisation des flux (do 789...) 2298 ! --------------------------------------------------------------------- 2299 2300 include "cvthermo.h" 2301 include "cv3param.h" 2302 2303 !inputs: 2304 INTEGER, INTENT (IN) :: ncum, nd, na, ntra, nloc 2305 INTEGER, DIMENSION (nloc), INTENT (IN) :: icb, inb, nk 2306 REAL, DIMENSION (nloc, nd), INTENT (IN) :: sig 2307 REAL, DIMENSION (nloc), INTENT (IN) :: qnk, unk, vnk 2308 REAL, DIMENSION (nloc, nd+1), INTENT (IN) :: ph 2309 REAL, DIMENSION (nloc, nd), INTENT (IN) :: t, rr, rs 2310 REAL, DIMENSION (nloc, nd), INTENT (IN) :: u, v 2311 REAL, DIMENSION (nloc, nd, ntra), INTENT (IN) :: tra ! input of convect3 2312 REAL, DIMENSION (nloc, na), INTENT (IN) :: lv, h, hp 2313 REAL, DIMENSION (nloc, na), INTENT (IN) :: lf, frac 2314 REAL, DIMENSION (nloc, na), INTENT (IN) :: tv, tvp, ep, clw 2315 REAL, DIMENSION (nloc, na), INTENT (IN) :: m ! input of convect3 2316 2317 !outputs: 2318 REAL, DIMENSION (nloc, na, na), INTENT (OUT) :: ment, qent 2319 REAL, DIMENSION (nloc, na, na), INTENT (OUT) :: uent, vent 2320 REAL, DIMENSION (nloc, na, na), INTENT (OUT) :: sij, elij 2321 REAL, DIMENSION (nloc, nd, nd, ntra), INTENT (OUT) :: traent 2322 REAL, DIMENSION (nloc, nd, nd), INTENT (OUT) :: ments, qents 2323 INTEGER, DIMENSION (nloc, nd), INTENT (OUT) :: nent 2324 2325 !local variables: 2278 ! --------------------------------------------------------------------- 2279 ! a faire: 2280 ! - vectorisation de la partie normalisation des flux (do 789...) 2281 ! --------------------------------------------------------------------- 2282 2283 !inputs: 2284 INTEGER, INTENT (IN) :: ncum, nd, na, ntra, nloc 2285 INTEGER, DIMENSION (nloc), INTENT (IN) :: icb, inb, nk 2286 REAL, DIMENSION (nloc, nd), INTENT (IN) :: sig 2287 REAL, DIMENSION (nloc), INTENT (IN) :: qnk, unk, vnk 2288 REAL, DIMENSION (nloc, nd + 1), INTENT (IN) :: ph 2289 REAL, DIMENSION (nloc, nd), INTENT (IN) :: t, rr, rs 2290 REAL, DIMENSION (nloc, nd), INTENT (IN) :: u, v 2291 REAL, DIMENSION (nloc, nd, ntra), INTENT (IN) :: tra ! input of convect3 2292 REAL, DIMENSION (nloc, na), INTENT (IN) :: lv, h, hp 2293 REAL, DIMENSION (nloc, na), INTENT (IN) :: lf, frac 2294 REAL, DIMENSION (nloc, na), INTENT (IN) :: tv, tvp, ep, clw 2295 REAL, DIMENSION (nloc, na), INTENT (IN) :: m ! input of convect3 2296 2297 !outputs: 2298 REAL, DIMENSION (nloc, na, na), INTENT (OUT) :: ment, qent 2299 REAL, DIMENSION (nloc, na, na), INTENT (OUT) :: uent, vent 2300 REAL, DIMENSION (nloc, na, na), INTENT (OUT) :: sij, elij 2301 REAL, DIMENSION (nloc, nd, nd, ntra), INTENT (OUT) :: traent 2302 REAL, DIMENSION (nloc, nd, nd), INTENT (OUT) :: ments, qents 2303 INTEGER, DIMENSION (nloc, nd), INTENT (OUT) :: nent 2304 2305 !local variables: 2326 2306 INTEGER i, j, k, il, im, jm 2327 2307 INTEGER num1, num2 … … 2335 2315 LOGICAL lwork(nloc) 2336 2316 2337 ! =====================================================================2338 ! --- INITIALIZE VARIOUS ARRAYS USED IN THE COMPUTATIONS2339 ! =====================================================================2340 2341 ! ori do 360 i=1,ncum*nlp2317 ! ===================================================================== 2318 ! --- INITIALIZE VARIOUS ARRAYS USED IN THE COMPUTATIONS 2319 ! ===================================================================== 2320 2321 ! ori do 360 i=1,ncum*nlp 2342 2322 DO j = 1, nl 2343 2323 DO i = 1, ncum 2344 2324 nent(i, j) = 0 2345 ! in convect3, m is computed in cv3_closure2346 ! ori m(i,1)=0.02347 END DO 2348 END DO 2349 2350 ! ori do 400 k=1,nlp2351 ! ori do 390 j=1,nlp2325 ! in convect3, m is computed in cv3_closure 2326 ! ori m(i,1)=0.0 2327 END DO 2328 END DO 2329 2330 ! ori do 400 k=1,nlp 2331 ! ori do 390 j=1,nlp 2352 2332 DO j = 1, nl 2353 2333 DO k = 1, nl … … 2357 2337 vent(i, k, j) = v(i, j) 2358 2338 elij(i, k, j) = 0.0 2359 !ym ment(i,k,j)=0.02360 !ym sij(i,k,j)=0.02339 !ym ment(i,k,j)=0.0 2340 !ym sij(i,k,j)=0.0 2361 2341 END DO 2362 2342 END DO 2363 2343 END DO 2364 2344 2365 !ym2345 !ym 2366 2346 ment(1:ncum, 1:nd, 1:nd) = 0.0 2367 2347 sij(1:ncum, 1:nd, 1:nd) = 0.0 2368 2348 2369 !AC! do k=1,ntra2370 !AC! do j=1,nd ! instead nlp2371 !AC! do i=1,nd ! instead nlp2372 !AC! do il=1,ncum2373 !AC! traent(il,i,j,k)=tra(il,j,k)2374 !AC! enddo2375 !AC! enddo2376 !AC! enddo2377 !AC! enddo2349 !AC! do k=1,ntra 2350 !AC! do j=1,nd ! instead nlp 2351 !AC! do i=1,nd ! instead nlp 2352 !AC! do il=1,ncum 2353 !AC! traent(il,i,j,k)=tra(il,j,k) 2354 !AC! enddo 2355 !AC! enddo 2356 !AC! enddo 2357 !AC! enddo 2378 2358 zm(:, :) = 0. 2379 2359 2380 ! =====================================================================2381 ! --- CALCULATE ENTRAINED AIR MASS FLUX (ment), TOTAL WATER MIXING2382 ! --- RATIO (QENT), TOTAL CONDENSED WATER (elij), AND MIXING2383 ! --- FRACTION (sij)2384 ! =====================================================================2360 ! ===================================================================== 2361 ! --- CALCULATE ENTRAINED AIR MASS FLUX (ment), TOTAL WATER MIXING 2362 ! --- RATIO (QENT), TOTAL CONDENSED WATER (elij), AND MIXING 2363 ! --- FRACTION (sij) 2364 ! ===================================================================== 2385 2365 2386 2366 DO i = minorig + 1, nl … … 2388 2368 DO j = minorig, nl 2389 2369 DO il = 1, ncum 2390 IF ((i>=icb(il)) .AND. (i<=inb(il)) .AND. (j>=(icb(il)-1)) .AND. (j<=inb(il))) THEN 2391 2392 rti = qnk(il) - ep(il, i)*clw(il, i) 2393 bf2 = 1. + lv(il, j)*lv(il, j)*rs(il, j)/(rrv*t(il,j)*t(il,j)*cpd) 2394 2370 IF ((i>=icb(il)) .AND. (i<=inb(il)) .AND. (j>=(icb(il) - 1)) .AND. (j<=inb(il))) THEN 2371 2372 rti = qnk(il) - ep(il, i) * clw(il, i) 2373 bf2 = 1. + lv(il, j) * lv(il, j) * rs(il, j) / (rrv * t(il, j) * t(il, j) * cpd) 2395 2374 2396 2375 IF (cvflag_ice) THEN 2397 ! PRINT*,cvflag_ice,'cvflag_ice dans do 700'2398 IF (t(il, j)<=263.15) THEN2399 bf2 = 1. + (lf(il, j)+lv(il,j))*(lv(il,j)+frac(il,j)* &2400 lf(il,j))*rs(il, j)/(rrv*t(il,j)*t(il,j)*cpd)2376 ! PRINT*,cvflag_ice,'cvflag_ice dans do 700' 2377 IF (t(il, j)<=263.15) THEN 2378 bf2 = 1. + (lf(il, j) + lv(il, j)) * (lv(il, j) + frac(il, j) * & 2379 lf(il, j)) * rs(il, j) / (rrv * t(il, j) * t(il, j) * cpd) 2401 2380 END IF 2402 2381 END IF 2403 2382 2404 anum = h(il, j) - hp(il, i) + (cpv -cpd)*t(il, j)*(rti-rr(il,j))2405 denom = h(il, i) - hp(il, i) + (cpd -cpv)*(rr(il,i)-rti)*t(il, j)2383 anum = h(il, j) - hp(il, i) + (cpv - cpd) * t(il, j) * (rti - rr(il, j)) 2384 denom = h(il, i) - hp(il, i) + (cpd - cpv) * (rr(il, i) - rti) * t(il, j) 2406 2385 dei = denom 2407 2386 IF (abs(dei)<0.01) dei = 0.01 2408 sij(il, i, j) = anum /dei2387 sij(il, i, j) = anum / dei 2409 2388 sij(il, i, i) = 1.0 2410 altem = sij(il, i, j) *rr(il, i) + (1.-sij(il,i,j))*rti - rs(il, j)2411 altem = altem /bf22412 cwat = clw(il, j) *(1.-ep(il,j))2389 altem = sij(il, i, j) * rr(il, i) + (1. - sij(il, i, j)) * rti - rs(il, j) 2390 altem = altem / bf2 2391 cwat = clw(il, j) * (1. - ep(il, j)) 2413 2392 stemp = sij(il, i, j) 2414 2393 IF ((stemp<0.0 .OR. stemp>1.0 .OR. altem>cwat) .AND. j>i) THEN 2415 2394 2416 2395 IF (cvflag_ice) THEN 2417 anum = anum - (lv(il, j)+frac(il,j)*lf(il,j))*(rti-rs(il,j)-cwat*bf2)2418 denom = denom + (lv(il, j)+frac(il,j)*lf(il,j))*(rr(il,i)-rti)2396 anum = anum - (lv(il, j) + frac(il, j) * lf(il, j)) * (rti - rs(il, j) - cwat * bf2) 2397 denom = denom + (lv(il, j) + frac(il, j) * lf(il, j)) * (rr(il, i) - rti) 2419 2398 ELSE 2420 anum = anum - lv(il, j) *(rti-rs(il,j)-cwat*bf2)2421 denom = denom + lv(il, j) *(rr(il,i)-rti)2399 anum = anum - lv(il, j) * (rti - rs(il, j) - cwat * bf2) 2400 denom = denom + lv(il, j) * (rr(il, i) - rti) 2422 2401 END IF 2423 2402 2424 2403 IF (abs(denom)<0.01) denom = 0.01 2425 sij(il, i, j) = anum /denom2426 altem = sij(il, i, j) *rr(il, i) + (1.-sij(il,i,j))*rti - rs(il, j)2427 altem = altem - (bf2 -1.)*cwat2404 sij(il, i, j) = anum / denom 2405 altem = sij(il, i, j) * rr(il, i) + (1. - sij(il, i, j)) * rti - rs(il, j) 2406 altem = altem - (bf2 - 1.) * cwat 2428 2407 END IF 2429 IF (sij(il, i,j)>0.0 .AND. sij(il,i,j)<0.95) THEN2430 qent(il, i, j) = sij(il, i, j) *rr(il, i) + (1.-sij(il,i,j))*rti2431 uent(il, i, j) = sij(il, i, j) *u(il, i) + (1.-sij(il,i,j))*unk(il)2432 vent(il, i, j) = sij(il, i, j) *v(il, i) + (1.-sij(il,i,j))*vnk(il)2433 !!!! do k=1,ntra2434 !!!! traent(il,i,j,k)=sij(il,i,j)*tra(il,i,k)2435 !!!! : +(1.-sij(il,i,j))*tra(il,nk(il),k)2436 !!!! END DO2408 IF (sij(il, i, j)>0.0 .AND. sij(il, i, j)<0.95) THEN 2409 qent(il, i, j) = sij(il, i, j) * rr(il, i) + (1. - sij(il, i, j)) * rti 2410 uent(il, i, j) = sij(il, i, j) * u(il, i) + (1. - sij(il, i, j)) * unk(il) 2411 vent(il, i, j) = sij(il, i, j) * v(il, i) + (1. - sij(il, i, j)) * vnk(il) 2412 !!!! do k=1,ntra 2413 !!!! traent(il,i,j,k)=sij(il,i,j)*tra(il,i,k) 2414 !!!! : +(1.-sij(il,i,j))*tra(il,nk(il),k) 2415 !!!! END DO 2437 2416 elij(il, i, j) = altem 2438 elij(il, i, j) = max(0.0, elij(il, i,j))2439 ment(il, i, j) = m(il, i) /(1.-sij(il,i,j))2417 elij(il, i, j) = max(0.0, elij(il, i, j)) 2418 ment(il, i, j) = m(il, i) / (1. - sij(il, i, j)) 2440 2419 nent(il, i) = nent(il, i) + 1 2441 2420 END IF 2442 sij(il, i, j) = max(0.0, sij(il, i,j))2443 sij(il, i, j) = amin1(1.0, sij(il, i,j))2421 sij(il, i, j) = max(0.0, sij(il, i, j)) 2422 sij(il, i, j) = amin1(1.0, sij(il, i, j)) 2444 2423 END IF ! new 2445 2424 END DO 2446 2425 END DO 2447 2426 2448 !AC! do k=1,ntra2449 !AC! do j=minorig,nl2450 !AC! do il=1,ncum2451 !AC! IF( (i.ge.icb(il)).AND.(i.le.inb(il)).AND.2452 !AC! : (j.ge.(icb(il)-1)).AND.(j.le.inb(il)))THEN2453 !AC! traent(il,i,j,k)=sij(il,i,j)*tra(il,i,k)2454 !AC! : +(1.-sij(il,i,j))*tra(il,nk(il),k)2455 !AC! endif2456 !AC! enddo2457 !AC! enddo2458 !AC! enddo2459 2460 2461 ! *** if no air can entrain at level i assume that updraft detrains ***2462 ! *** at that level and calculate detrained air flux and properties ***2463 2464 2465 ! @ do 170 i=icb(il),inb(il)2427 !AC! do k=1,ntra 2428 !AC! do j=minorig,nl 2429 !AC! do il=1,ncum 2430 !AC! IF( (i.ge.icb(il)).AND.(i.le.inb(il)).AND. 2431 !AC! : (j.ge.(icb(il)-1)).AND.(j.le.inb(il)))THEN 2432 !AC! traent(il,i,j,k)=sij(il,i,j)*tra(il,i,k) 2433 !AC! : +(1.-sij(il,i,j))*tra(il,nk(il),k) 2434 !AC! endif 2435 !AC! enddo 2436 !AC! enddo 2437 !AC! enddo 2438 2439 2440 ! *** if no air can entrain at level i assume that updraft detrains *** 2441 ! *** at that level and calculate detrained air flux and properties *** 2442 2443 2444 ! @ do 170 i=icb(il),inb(il) 2466 2445 2467 2446 DO il = 1, ncum 2468 IF ((i>=icb(il)) .AND. (i<=inb(il)) .AND. (nent(il, i)==0)) THEN2469 ! @ IF(nent(il,i).EQ.0)THEN2447 IF ((i>=icb(il)) .AND. (i<=inb(il)) .AND. (nent(il, i)==0)) THEN 2448 ! @ IF(nent(il,i).EQ.0)THEN 2470 2449 ment(il, i, i) = m(il, i) 2471 qent(il, i, i) = qnk(il) - ep(il, i) *clw(il, i)2450 qent(il, i, i) = qnk(il) - ep(il, i) * clw(il, i) 2472 2451 uent(il, i, i) = unk(il) 2473 2452 vent(il, i, i) = vnk(il) 2474 2453 elij(il, i, i) = clw(il, i) 2475 ! MAF sij(il,i,i)=1.02454 ! MAF sij(il,i,i)=1.0 2476 2455 sij(il, i, i) = 0.0 2477 2456 END IF … … 2479 2458 END DO 2480 2459 2481 !AC! do j=1,ntra2482 !AC! do i=minorig+1,nl2483 !AC! do il=1,ncum2484 !AC! if (i.ge.icb(il) .AND. i.le.inb(il) .AND. nent(il,i).EQ.0) THEN2485 !AC! traent(il,i,i,j)=tra(il,nk(il),j)2486 !AC! endif2487 !AC! enddo2488 !AC! enddo2489 !AC! enddo2460 !AC! do j=1,ntra 2461 !AC! do i=minorig+1,nl 2462 !AC! do il=1,ncum 2463 !AC! if (i.ge.icb(il) .AND. i.le.inb(il) .AND. nent(il,i).EQ.0) THEN 2464 !AC! traent(il,i,i,j)=tra(il,nk(il),j) 2465 !AC! endif 2466 !AC! enddo 2467 !AC! enddo 2468 !AC! enddo 2490 2469 2491 2470 DO j = minorig, nl 2492 2471 DO i = minorig, nl 2493 2472 DO il = 1, ncum 2494 IF ((j>=(icb(il) -1)) .AND. (j<=inb(il)) .AND. (i>=icb(il)) .AND. (i<=inb(il))) THEN2473 IF ((j>=(icb(il) - 1)) .AND. (j<=inb(il)) .AND. (i>=icb(il)) .AND. (i<=inb(il))) THEN 2495 2474 sigij(il, i, j) = sij(il, i, j) 2496 2475 END IF … … 2498 2477 END DO 2499 2478 END DO 2500 ! @ enddo2501 2502 ! @170 continue2503 2504 ! =====================================================================2505 ! --- NORMALIZE ENTRAINED AIR MASS FLUXES2506 ! --- TO REPRESENT EQUAL PROBABILITIES OF MIXING2507 ! =====================================================================2508 2509 CALL zilch(asum, nloc *nd)2510 CALL zilch(csum, nloc *nd)2511 CALL zilch(csum, nloc *nd)2479 ! @ enddo 2480 2481 ! @170 continue 2482 2483 ! ===================================================================== 2484 ! --- NORMALIZE ENTRAINED AIR MASS FLUXES 2485 ! --- TO REPRESENT EQUAL PROBABILITIES OF MIXING 2486 ! ===================================================================== 2487 2488 CALL zilch(asum, nloc * nd) 2489 CALL zilch(csum, nloc * nd) 2490 CALL zilch(csum, nloc * nd) 2512 2491 2513 2492 DO il = 1, ncum … … 2523 2502 IF (num1<=0) GO TO 789 2524 2503 2525 2526 2504 DO il = 1, ncum 2527 2505 IF (i>=icb(il) .AND. i<=inb(il)) THEN 2528 lwork(il) = (nent(il, i)/=0)2529 qp = qnk(il) - ep(il, i) *clw(il, i)2506 lwork(il) = (nent(il, i)/=0) 2507 qp = qnk(il) - ep(il, i) * clw(il, i) 2530 2508 2531 2509 IF (cvflag_ice) THEN 2532 2510 2533 anum = h(il, i) - hp(il, i) - (lv(il, i)+frac(il,i)*lf(il,i))* &2534 (qp-rs(il,i)) + (cpv-cpd)*t(il, i)*(qp-rr(il,i))2535 denom = h(il, i) - hp(il, i) + (lv(il, i)+frac(il,i)*lf(il,i))* &2536 (rr(il,i)-qp) + (cpd-cpv)*t(il, i)*(rr(il,i)-qp)2511 anum = h(il, i) - hp(il, i) - (lv(il, i) + frac(il, i) * lf(il, i)) * & 2512 (qp - rs(il, i)) + (cpv - cpd) * t(il, i) * (qp - rr(il, i)) 2513 denom = h(il, i) - hp(il, i) + (lv(il, i) + frac(il, i) * lf(il, i)) * & 2514 (rr(il, i) - qp) + (cpd - cpv) * t(il, i) * (rr(il, i) - qp) 2537 2515 ELSE 2538 2516 2539 anum = h(il, i) - hp(il, i) - lv(il, i) *(qp-rs(il,i)) + &2540 (cpv-cpd)*t(il, i)*(qp-rr(il,i))2541 denom = h(il, i) - hp(il, i) + lv(il, i) *(rr(il,i)-qp) + &2542 (cpd-cpv)*t(il, i)*(rr(il,i)-qp)2517 anum = h(il, i) - hp(il, i) - lv(il, i) * (qp - rs(il, i)) + & 2518 (cpv - cpd) * t(il, i) * (qp - rr(il, i)) 2519 denom = h(il, i) - hp(il, i) + lv(il, i) * (rr(il, i) - qp) + & 2520 (cpd - cpv) * t(il, i) * (rr(il, i) - qp) 2543 2521 END IF 2544 2522 2545 2523 IF (abs(denom)<0.01) denom = 0.01 2546 scrit(il) = anum /denom2547 alt = qp - rs(il, i) + scrit(il) *(rr(il,i)-qp)2524 scrit(il) = anum / denom 2525 alt = qp - rs(il, i) + scrit(il) * (rr(il, i) - qp) 2548 2526 IF (scrit(il)<=0.0 .OR. alt<=0.0) scrit(il) = 1.0 2549 2527 smax(il) = 0.0 … … 2557 2535 DO il = 1, ncum 2558 2536 IF (i>=icb(il) .AND. i<=inb(il) .AND. & 2559 j>=(icb(il)-1) .AND. j<=inb(il) .AND. &2560 lwork(il)) num2 = num2 + 12537 j>=(icb(il) - 1) .AND. j<=inb(il) .AND. & 2538 lwork(il)) num2 = num2 + 1 2561 2539 END DO 2562 2540 IF (num2<=0) GO TO 175 … … 2564 2542 DO il = 1, ncum 2565 2543 IF (i>=icb(il) .AND. i<=inb(il) .AND. & 2566 j>=(icb(il)-1) .AND. j<=inb(il) .AND. &2567 lwork(il)) THEN2568 2569 IF (sij(il, i,j)>1.0E-16 .AND. sij(il,i,j)<0.95) THEN2544 j>=(icb(il) - 1) .AND. j<=inb(il) .AND. & 2545 lwork(il)) THEN 2546 2547 IF (sij(il, i, j)>1.0E-16 .AND. sij(il, i, j)<0.95) THEN 2570 2548 wgh = 1.0 2571 2549 IF (j>i) THEN 2572 sjmax = max(sij(il, i,j+1), smax(il))2550 sjmax = max(sij(il, i, j + 1), smax(il)) 2573 2551 sjmax = amin1(sjmax, scrit(il)) 2574 smax(il) = max(sij(il, i,j), smax(il))2575 sjmin = max(sij(il, i,j-1), smax(il))2552 smax(il) = max(sij(il, i, j), smax(il)) 2553 sjmin = max(sij(il, i, j - 1), smax(il)) 2576 2554 sjmin = amin1(sjmin, scrit(il)) 2577 IF (sij(il, i,j)<(smax(il)-1.0E-16)) wgh = 0.02578 smid = amin1(sij(il, i,j), scrit(il))2555 IF (sij(il, i, j)<(smax(il) - 1.0E-16)) wgh = 0.0 2556 smid = amin1(sij(il, i, j), scrit(il)) 2579 2557 ELSE 2580 sjmax = max(sij(il, i,j+1), scrit(il))2581 smid = max(sij(il, i,j), scrit(il))2558 sjmax = max(sij(il, i, j + 1), scrit(il)) 2559 smid = max(sij(il, i, j), scrit(il)) 2582 2560 sjmin = 0.0 2583 IF (j>1) sjmin = sij(il, i, j -1)2561 IF (j>1) sjmin = sij(il, i, j - 1) 2584 2562 sjmin = max(sjmin, scrit(il)) 2585 2563 END IF 2586 delp = abs(sjmax -smid)2587 delm = abs(sjmin -smid)2588 asij(il) = asij(il) + wgh *(delp+delm)2589 ment(il, i, j) = ment(il, i, j) *(delp+delm)*wgh2564 delp = abs(sjmax - smid) 2565 delm = abs(sjmin - smid) 2566 asij(il) = asij(il) + wgh * (delp + delm) 2567 ment(il, i, j) = ment(il, i, j) * (delp + delm) * wgh 2590 2568 END IF 2591 2569 END IF 2592 2570 END DO 2593 2571 2594 175 END DO2572 175 END DO 2595 2573 2596 2574 DO il = 1, ncum 2597 2575 IF (i>=icb(il) .AND. i<=inb(il) .AND. lwork(il)) THEN 2598 2576 asij(il) = max(1.0E-16, asij(il)) 2599 asij(il) = 1.0 /asij(il)2577 asij(il) = 1.0 / asij(il) 2600 2578 asum(il, i) = 0.0 2601 2579 bsum(il, i) = 0.0 … … 2607 2585 DO il = 1, ncum 2608 2586 IF (i>=icb(il) .AND. i<=inb(il) .AND. lwork(il) .AND. & 2609 j>=(icb(il)-1) .AND. j<=inb(il)) THEN2610 ment(il, i, j) = ment(il, i, j) *asij(il)2587 j>=(icb(il) - 1) .AND. j<=inb(il)) THEN 2588 ment(il, i, j) = ment(il, i, j) * asij(il) 2611 2589 END IF 2612 2590 END DO … … 2616 2594 DO il = 1, ncum 2617 2595 IF (i>=icb(il) .AND. i<=inb(il) .AND. lwork(il) .AND. & 2618 j>=(icb(il)-1) .AND. j<=inb(il)) THEN2596 j>=(icb(il) - 1) .AND. j<=inb(il)) THEN 2619 2597 asum(il, i) = asum(il, i) + ment(il, i, j) 2620 ment(il, i, j) = ment(il, i, j) *sig(il, j)2598 ment(il, i, j) = ment(il, i, j) * sig(il, j) 2621 2599 bsum(il, i) = bsum(il, i) + ment(il, i, j) 2622 2600 END IF … … 2626 2604 DO il = 1, ncum 2627 2605 IF (i>=icb(il) .AND. i<=inb(il) .AND. lwork(il)) THEN 2628 bsum(il, i) = max(bsum(il, i), 1.0E-16)2629 bsum(il, i) = 1.0 /bsum(il, i)2606 bsum(il, i) = max(bsum(il, i), 1.0E-16) 2607 bsum(il, i) = 1.0 / bsum(il, i) 2630 2608 END IF 2631 2609 END DO … … 2634 2612 DO il = 1, ncum 2635 2613 IF (i>=icb(il) .AND. i<=inb(il) .AND. lwork(il) .AND. & 2636 j>=(icb(il)-1) .AND. j<=inb(il)) THEN2637 ment(il, i, j) = ment(il, i, j) *asum(il, i)*bsum(il, i)2614 j>=(icb(il) - 1) .AND. j<=inb(il)) THEN 2615 ment(il, i, j) = ment(il, i, j) * asum(il, i) * bsum(il, i) 2638 2616 END IF 2639 2617 END DO … … 2643 2621 DO il = 1, ncum 2644 2622 IF (i>=icb(il) .AND. i<=inb(il) .AND. lwork(il) .AND. & 2645 j>=(icb(il)-1) .AND. j<=inb(il)) THEN2623 j>=(icb(il) - 1) .AND. j<=inb(il)) THEN 2646 2624 csum(il, i) = csum(il, i) + ment(il, i, j) 2647 2625 END IF … … 2651 2629 DO il = 1, ncum 2652 2630 IF (i>=icb(il) .AND. i<=inb(il) .AND. lwork(il) .AND. & 2653 csum(il,i)<m(il,i)) THEN2631 csum(il, i)<m(il, i)) THEN 2654 2632 nent(il, i) = 0 2655 2633 ment(il, i, i) = m(il, i) 2656 qent(il, i, i) = qnk(il) - ep(il, i) *clw(il, i)2634 qent(il, i, i) = qnk(il) - ep(il, i) * clw(il, i) 2657 2635 uent(il, i, i) = unk(il) 2658 2636 vent(il, i, i) = vnk(il) 2659 2637 elij(il, i, i) = clw(il, i) 2660 ! MAF sij(il,i,i)=1.02638 ! MAF sij(il,i,i)=1.0 2661 2639 sij(il, i, i) = 0.0 2662 2640 END IF 2663 2641 END DO ! il 2664 2642 2665 !AC! do j=1,ntra2666 !AC! do il=1,ncum2667 !AC! if ( i.ge.icb(il) .AND. i.le.inb(il) .AND. lwork(il)2668 !AC! : .AND. csum(il,i).lt.m(il,i) ) THEN2669 !AC! traent(il,i,i,j)=tra(il,nk(il),j)2670 !AC! endif2671 !AC! enddo2672 !AC! enddo2673 789 END DO2674 2675 ! MAF: renormalisation de MENT2676 CALL zilch(zm, nloc *na)2643 !AC! do j=1,ntra 2644 !AC! do il=1,ncum 2645 !AC! if ( i.ge.icb(il) .AND. i.le.inb(il) .AND. lwork(il) 2646 !AC! : .AND. csum(il,i).lt.m(il,i) ) THEN 2647 !AC! traent(il,i,i,j)=tra(il,nk(il),j) 2648 !AC! endif 2649 !AC! enddo 2650 !AC! enddo 2651 789 END DO 2652 2653 ! MAF: renormalisation de MENT 2654 CALL zilch(zm, nloc * na) 2677 2655 DO jm = 1, nl 2678 2656 DO im = 1, nl 2679 2657 DO il = 1, ncum 2680 zm(il, im) = zm(il, im) + (1. -sij(il,im,jm))*ment(il, im, jm)2658 zm(il, im) = zm(il, im) + (1. - sij(il, im, jm)) * ment(il, im, jm) 2681 2659 END DO 2682 2660 END DO … … 2686 2664 DO im = 1, nl 2687 2665 DO il = 1, ncum 2688 IF (zm(il, im)/=0.) THEN2689 ment(il, im, jm) = ment(il, im, jm) *m(il, im)/zm(il, im)2666 IF (zm(il, im)/=0.) THEN 2667 ment(il, im, jm) = ment(il, im, jm) * m(il, im) / zm(il, im) 2690 2668 END IF 2691 2669 END DO … … 2702 2680 END DO 2703 2681 2704 2705 2682 END SUBROUTINE cv3_mixing 2706 2683 2707 2684 SUBROUTINE cv3_unsat(nloc, ncum, nd, na, ntra, icb, inb, iflag, & 2708 2709 th, tv, lv, lf, cpn, ep, sigp, clw, frac_s, qpreca, frac_a, qta, & !!jygprl2710 2711 2712 2713 2685 t, rr, rs, gz, u, v, tra, p, ph, & 2686 th, tv, lv, lf, cpn, ep, sigp, clw, frac_s, qpreca, frac_a, qta, & !!jygprl 2687 m, ment, elij, delt, plcl, coef_clos, & 2688 mp, rp, up, vp, trap, wt, water, evap, fondue, ice, & 2689 faci, b, sigd, & 2690 wdtrainA, wdtrainS, wdtrainM) ! RomP 2714 2691 USE lmdz_print_control, ONLY: prt_level, lunout 2715 2692 USE lmdz_nuage_params 2716 2693 USE lmdz_cvflag 2694 USE lmdz_cvthermo 2695 USE lmdz_cv3param 2717 2696 2718 2697 IMPLICIT NONE 2719 2698 2720 2721 include "cvthermo.h" 2722 include "cv3param.h" 2723 2724 !inputs: 2725 INTEGER, INTENT (IN) :: ncum, nd, na, ntra, nloc 2726 INTEGER, DIMENSION (nloc), INTENT (IN) :: icb, inb 2727 REAL, INTENT(IN) :: delt 2728 REAL, DIMENSION (nloc), INTENT (IN) :: plcl 2729 REAL, DIMENSION (nloc, nd), INTENT (IN) :: t, rr, rs 2730 REAL, DIMENSION (nloc, na), INTENT (IN) :: gz 2731 REAL, DIMENSION (nloc, nd), INTENT (IN) :: u, v 2732 REAL, DIMENSION (nloc, nd, ntra), INTENT(IN) :: tra 2733 REAL, DIMENSION (nloc, nd), INTENT (IN) :: p 2734 REAL, DIMENSION (nloc, nd+1), INTENT (IN) :: ph 2735 REAL, DIMENSION (nloc, na), INTENT (IN) :: ep, sigp, clw !adiab ascent shedding 2736 REAL, DIMENSION (nloc, na), INTENT (IN) :: frac_s !ice fraction in adiab ascent shedding !!jygprl 2737 REAL, DIMENSION (nloc, na), INTENT (IN) :: qpreca !adiab ascent precip !!jygprl 2738 REAL, DIMENSION (nloc, na), INTENT (IN) :: frac_a !ice fraction in adiab ascent precip !!jygprl 2739 REAL, DIMENSION (nloc, na), INTENT (IN) :: qta !adiab ascent specific total water !!jygprl 2740 REAL, DIMENSION (nloc, na), INTENT (IN) :: th, tv, lv, cpn 2741 REAL, DIMENSION (nloc, na), INTENT (IN) :: lf 2742 REAL, DIMENSION (nloc, na), INTENT (IN) :: m 2743 REAL, DIMENSION (nloc, na, na), INTENT (IN) :: ment, elij 2744 REAL, DIMENSION (nloc), INTENT (IN) :: coef_clos 2745 2746 !input/output 2747 INTEGER, DIMENSION (nloc), INTENT (INOUT) :: iflag(nloc) 2748 2749 !outputs: 2750 REAL, DIMENSION (nloc, na), INTENT (OUT) :: mp, rp, up, vp 2751 REAL, DIMENSION (nloc, na), INTENT (OUT) :: water, evap, wt 2752 REAL, DIMENSION (nloc, na), INTENT (OUT) :: ice, fondue 2753 REAL, DIMENSION (nloc, na), INTENT (OUT) :: faci ! ice fraction in precipitation 2754 REAL, DIMENSION (nloc, na, ntra), INTENT (OUT) :: trap 2755 REAL, DIMENSION (nloc, na), INTENT (OUT) :: b 2756 REAL, DIMENSION (nloc), INTENT (OUT) :: sigd 2757 ! 25/08/10 - RomP---- ajout des masses precipitantes ejectees 2758 ! de l ascendance adiabatique et des flux melanges Pa et Pm. 2759 ! Distinction des wdtrain 2760 ! Pa = wdtrainA Pm = wdtrainM 2761 REAL, DIMENSION (nloc, na), INTENT (OUT) :: wdtrainA, wdtrainS, wdtrainM 2762 2763 !local variables 2699 !inputs: 2700 INTEGER, INTENT (IN) :: ncum, nd, na, ntra, nloc 2701 INTEGER, DIMENSION (nloc), INTENT (IN) :: icb, inb 2702 REAL, INTENT(IN) :: delt 2703 REAL, DIMENSION (nloc), INTENT (IN) :: plcl 2704 REAL, DIMENSION (nloc, nd), INTENT (IN) :: t, rr, rs 2705 REAL, DIMENSION (nloc, na), INTENT (IN) :: gz 2706 REAL, DIMENSION (nloc, nd), INTENT (IN) :: u, v 2707 REAL, DIMENSION (nloc, nd, ntra), INTENT(IN) :: tra 2708 REAL, DIMENSION (nloc, nd), INTENT (IN) :: p 2709 REAL, DIMENSION (nloc, nd + 1), INTENT (IN) :: ph 2710 REAL, DIMENSION (nloc, na), INTENT (IN) :: ep, sigp, clw !adiab ascent shedding 2711 REAL, DIMENSION (nloc, na), INTENT (IN) :: frac_s !ice fraction in adiab ascent shedding !!jygprl 2712 REAL, DIMENSION (nloc, na), INTENT (IN) :: qpreca !adiab ascent precip !!jygprl 2713 REAL, DIMENSION (nloc, na), INTENT (IN) :: frac_a !ice fraction in adiab ascent precip !!jygprl 2714 REAL, DIMENSION (nloc, na), INTENT (IN) :: qta !adiab ascent specific total water !!jygprl 2715 REAL, DIMENSION (nloc, na), INTENT (IN) :: th, tv, lv, cpn 2716 REAL, DIMENSION (nloc, na), INTENT (IN) :: lf 2717 REAL, DIMENSION (nloc, na), INTENT (IN) :: m 2718 REAL, DIMENSION (nloc, na, na), INTENT (IN) :: ment, elij 2719 REAL, DIMENSION (nloc), INTENT (IN) :: coef_clos 2720 2721 !input/output 2722 INTEGER, DIMENSION (nloc), INTENT (INOUT) :: iflag(nloc) 2723 2724 !outputs: 2725 REAL, DIMENSION (nloc, na), INTENT (OUT) :: mp, rp, up, vp 2726 REAL, DIMENSION (nloc, na), INTENT (OUT) :: water, evap, wt 2727 REAL, DIMENSION (nloc, na), INTENT (OUT) :: ice, fondue 2728 REAL, DIMENSION (nloc, na), INTENT (OUT) :: faci ! ice fraction in precipitation 2729 REAL, DIMENSION (nloc, na, ntra), INTENT (OUT) :: trap 2730 REAL, DIMENSION (nloc, na), INTENT (OUT) :: b 2731 REAL, DIMENSION (nloc), INTENT (OUT) :: sigd 2732 ! 25/08/10 - RomP---- ajout des masses precipitantes ejectees 2733 ! de l ascendance adiabatique et des flux melanges Pa et Pm. 2734 ! Distinction des wdtrain 2735 ! Pa = wdtrainA Pm = wdtrainM 2736 REAL, DIMENSION (nloc, na), INTENT (OUT) :: wdtrainA, wdtrainS, wdtrainM 2737 2738 !local variables 2764 2739 INTEGER i, j, k, il, num1, ndp1 2765 2740 REAL smallestreal … … 2770 2745 REAL ampmax, thaw 2771 2746 REAL tevap(nloc) 2772 REAL, DIMENSION (nloc, na) 2773 REAL, DIMENSION (nloc, na) 2774 REAL, DIMENSION (nloc, na) 2775 REAL, DIMENSION (nloc, na) 2776 REAL, DIMENSION (nloc, na) 2777 REAL, DIMENSION (nloc, na) 2747 REAL, DIMENSION (nloc, na) :: lvcp, lfcp 2748 REAL, DIMENSION (nloc, na) :: h, hm 2749 REAL, DIMENSION (nloc, na) :: ma 2750 REAL, DIMENSION (nloc, na) :: frac ! ice fraction in precipitation source 2751 REAL, DIMENSION (nloc, na) :: fraci ! provisionnal ice fraction in precipitation 2752 REAL, DIMENSION (nloc, na) :: prec 2778 2753 REAL wdtrain(nloc) 2779 2754 LOGICAL lwork(nloc), mplus(nloc) 2780 2755 2781 2756 2782 ! ------------------------------------------------------2783 IF (prt_level >= 10) print *,' ->cv3_unsat, iflag(1) ', iflag(1)2784 2785 smallestreal=tiny(smallestreal)2786 2787 ! =============================2788 ! --- INITIALIZE OUTPUT ARRAYS 2789 ! =============================2790 ! (loops up to nl+1)2791 mp(:,:) = 0.2792 rp(:,:) = 0.2793 up(:,:) = 0.2794 vp(:,:) = 0.2795 water(:,:) = 0.2796 evap(:,:) = 0.2797 wt(:,:) = 0.2798 ice(:,:) = 0.2799 fondue(:,:) = 0.2800 faci(:,:) = 0.2801 b(:,:) = 0.2802 sigd(:) = 0.2803 !! RomP >>>2804 wdtrainA(:,:) = 0.2805 wdtrainS(:,:) = 0.2806 wdtrainM(:,:) = 0.2807 !! RomP <<<2757 ! ------------------------------------------------------ 2758 IF (prt_level >= 10) print *, ' ->cv3_unsat, iflag(1) ', iflag(1) 2759 2760 smallestreal = tiny(smallestreal) 2761 2762 ! ============================= 2763 ! --- INITIALIZE OUTPUT ARRAYS 2764 ! ============================= 2765 ! (loops up to nl+1) 2766 mp(:, :) = 0. 2767 rp(:, :) = 0. 2768 up(:, :) = 0. 2769 vp(:, :) = 0. 2770 water(:, :) = 0. 2771 evap(:, :) = 0. 2772 wt(:, :) = 0. 2773 ice(:, :) = 0. 2774 fondue(:, :) = 0. 2775 faci(:, :) = 0. 2776 b(:, :) = 0. 2777 sigd(:) = 0. 2778 !! RomP >>> 2779 wdtrainA(:, :) = 0. 2780 wdtrainS(:, :) = 0. 2781 wdtrainM(:, :) = 0. 2782 !! RomP <<< 2808 2783 2809 2784 DO i = 1, nlp … … 2816 2791 END DO 2817 2792 2818 ! *** Set the fractionnal area sigd of precipitating downdraughts2793 ! *** Set the fractionnal area sigd of precipitating downdraughts 2819 2794 DO il = 1, ncum 2820 sigd(il) = sigdz *coef_clos(il)2821 END DO 2822 2823 ! =====================================================================2824 ! --- INITIALIZE VARIOUS ARRAYS AND PARAMETERS USED IN THE COMPUTATIONS2825 ! =====================================================================2826 ! (loops up to nl+1)2827 2828 delti = 1. /delt2829 tinv = 1. /3.2795 sigd(il) = sigdz * coef_clos(il) 2796 END DO 2797 2798 ! ===================================================================== 2799 ! --- INITIALIZE VARIOUS ARRAYS AND PARAMETERS USED IN THE COMPUTATIONS 2800 ! ===================================================================== 2801 ! (loops up to nl+1) 2802 2803 delti = 1. / delt 2804 tinv = 1. / 3. 2830 2805 2831 2806 DO i = 1, nlp … … 2834 2809 fraci(il, i) = 0.0 2835 2810 prec(il, i) = 0.0 2836 lvcp(il, i) = lv(il, i)/cpn(il, i) 2837 lfcp(il, i) = lf(il, i)/cpn(il, i) 2838 END DO 2839 END DO 2840 2841 !AC! do k=1,ntra 2842 !AC! do i=1,nd 2843 !AC! do il=1,ncum 2844 !AC! trap(il,i,k)=tra(il,i,k) 2845 !AC! enddo 2846 !AC! enddo 2847 !AC! enddo 2848 2849 ! *** check whether ep(inb)=0, if so, skip precipitating *** 2850 ! *** downdraft calculation *** 2851 2811 lvcp(il, i) = lv(il, i) / cpn(il, i) 2812 lfcp(il, i) = lf(il, i) / cpn(il, i) 2813 END DO 2814 END DO 2815 2816 !AC! do k=1,ntra 2817 !AC! do i=1,nd 2818 !AC! do il=1,ncum 2819 !AC! trap(il,i,k)=tra(il,i,k) 2820 !AC! enddo 2821 !AC! enddo 2822 !AC! enddo 2823 2824 ! *** check whether ep(inb)=0, if so, skip precipitating *** 2825 ! *** downdraft calculation *** 2852 2826 2853 2827 DO il = 1, ncum 2854 !! lwork(il)=.TRUE.2855 !! IF(ep(il,inb(il)).lt.0.0001)lwork(il)=.FALSE.2856 !jyg<2857 !! lwork(il) = ep(il, inb(il)) >= 0.00012828 !! lwork(il)=.TRUE. 2829 !! IF(ep(il,inb(il)).lt.0.0001)lwork(il)=.FALSE. 2830 !jyg< 2831 !! lwork(il) = ep(il, inb(il)) >= 0.0001 2858 2832 lwork(il) = ep(il, inb(il)) >= 0.0001 .AND. iflag(il) <= 2 2859 2833 END DO 2860 2834 2861 ! Get adiabatic ascent mass flux 2862 2863 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!2835 ! Get adiabatic ascent mass flux 2836 2837 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 2864 2838 IF (adiab_ascent_mass_flux_depends_on_ejectliq) THEN 2865 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!2866 !!! Warning : this option leads to water conservation violation2867 !!! Expert only2868 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!2839 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 2840 !!! Warning : this option leads to water conservation violation 2841 !!! Expert only 2842 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 2869 2843 DO il = 1, ncum 2870 2844 ma(il, nlp) = 0. 2871 ma(il, 1) 2872 END DO 2873 2874 DO i = nl, 2, -12845 ma(il, 1) = 0. 2846 END DO 2847 2848 DO i = nl, 2, -1 2875 2849 DO il = 1, ncum 2876 ma(il, i) = ma(il, i +1)*(1.-qta(il,i))/(1.-qta(il,i-1)) + m(il, i)2850 ma(il, i) = ma(il, i + 1) * (1. - qta(il, i)) / (1. - qta(il, i - 1)) + m(il, i) 2877 2851 END DO 2878 END DO2879 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!2852 END DO 2853 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 2880 2854 ELSE ! (adiab_ascent_mass_flux_depends_on_ejectliq) 2881 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!2855 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 2882 2856 DO il = 1, ncum 2883 2857 ma(il, nlp) = 0. 2884 ma(il, 1) 2885 END DO 2886 2887 DO i = nl, 2, -12858 ma(il, 1) = 0. 2859 END DO 2860 2861 DO i = nl, 2, -1 2888 2862 DO il = 1, ncum 2889 ma(il, i) = ma(il, i +1) + m(il, i)2863 ma(il, i) = ma(il, i + 1) + m(il, i) 2890 2864 END DO 2891 END DO2865 END DO 2892 2866 2893 2867 ENDIF ! (adiab_ascent_mass_flux_depends_on_ejectliq) ELSE 2894 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!2895 2896 ! ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++2897 2898 ! *** begin downdraft loop ***2899 2900 ! ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++2868 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 2869 2870 ! ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2871 2872 ! *** begin downdraft loop *** 2873 2874 ! ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2901 2875 2902 2876 DO i = nl + 1, 1, -1 … … 2911 2885 2912 2886 2913 ! *** integrate liquid water equation to find condensed water *** 2914 ! *** and condensed water flux *** 2915 2916 2917 ! *** calculate detrained precipitation *** 2918 2919 2920 DO il = 1, ncum 2921 IF (i<=inb(il) .AND. lwork(il)) THEN 2922 wdtrain(il) = grav*ep(il, i)*m(il, i)*clw(il, i) 2923 wdtrainS(il, i) = wdtrain(il)/grav ! Ps jyg 2924 !! wdtrainA(il, i) = wdtrain(il)/grav ! Ps RomP 2925 END IF 2926 END DO 2887 ! *** integrate liquid water equation to find condensed water *** 2888 ! *** and condensed water flux *** 2889 2890 2891 ! *** calculate detrained precipitation *** 2892 2893 DO il = 1, ncum 2894 IF (i<=inb(il) .AND. lwork(il)) THEN 2895 wdtrain(il) = grav * ep(il, i) * m(il, i) * clw(il, i) 2896 wdtrainS(il, i) = wdtrain(il) / grav ! Ps jyg 2897 !! wdtrainA(il, i) = wdtrain(il)/grav ! Ps RomP 2898 END IF 2899 END DO 2927 2900 2928 2901 IF (i>1) THEN … … 2930 2903 DO il = 1, ncum 2931 2904 IF (i<=inb(il) .AND. lwork(il)) THEN 2932 awat = elij(il, j, i) - (1. -ep(il,i))*clw(il, i)2905 awat = elij(il, j, i) - (1. - ep(il, i)) * clw(il, i) 2933 2906 awat = max(awat, 0.0) 2934 wdtrain(il) = wdtrain(il) + grav *awat*ment(il, j, i)2935 wdtrainM(il, i) = wdtrain(il) /grav - wdtrainS(il, i) ! Pm jyg2936 !! wdtrainM(il, i) = wdtrain(il)/grav - wdtrainA(il, i) ! Pm RomP2907 wdtrain(il) = wdtrain(il) + grav * awat * ment(il, j, i) 2908 wdtrainM(il, i) = wdtrain(il) / grav - wdtrainS(il, i) ! Pm jyg 2909 !! wdtrainM(il, i) = wdtrain(il)/grav - wdtrainA(il, i) ! Pm RomP 2937 2910 END IF 2938 2911 END DO … … 2941 2914 2942 2915 IF (cvflag_prec_eject) THEN 2943 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!2916 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 2944 2917 IF (adiab_ascent_mass_flux_depends_on_ejectliq) THEN 2945 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!2946 !!! Warning : this option leads to water conservation violation2947 !!! Expert only2948 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!2949 IF (i > 1) THEN2950 2951 2952 wdtrainA(il,i) = ma(il, i+1)*(qta(il, i-1)-qta(il,i))/(1. - qta(il, i-1)) ! Pa jygprl2953 wdtrain(il) = wdtrain(il) + grav*wdtrainA(il,i)2954 2955 2956 2957 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!2918 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 2919 !!! Warning : this option leads to water conservation violation 2920 !!! Expert only 2921 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 2922 IF (i > 1) THEN 2923 DO il = 1, ncum 2924 IF (i<=inb(il) .AND. lwork(il)) THEN 2925 wdtrainA(il, i) = ma(il, i + 1) * (qta(il, i - 1) - qta(il, i)) / (1. - qta(il, i - 1)) ! Pa jygprl 2926 wdtrain(il) = wdtrain(il) + grav * wdtrainA(il, i) 2927 END IF 2928 END DO 2929 ENDIF ! ( i > 1) 2930 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 2958 2931 ELSE ! (adiab_ascent_mass_flux_depends_on_ejectliq) 2959 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!2960 IF (i > 1) THEN2961 2962 2963 wdtrainA(il,i) = ma(il, i+1)*(qta(il, i-1)-qta(il,i)) ! Pa jygprl2964 wdtrain(il) = wdtrain(il) + grav*wdtrainA(il,i)2965 2966 2967 2932 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 2933 IF (i > 1) THEN 2934 DO il = 1, ncum 2935 IF (i<=inb(il) .AND. lwork(il)) THEN 2936 wdtrainA(il, i) = ma(il, i + 1) * (qta(il, i - 1) - qta(il, i)) ! Pa jygprl 2937 wdtrain(il) = wdtrain(il) + grav * wdtrainA(il, i) 2938 END IF 2939 END DO 2940 ENDIF ! ( i > 1) 2968 2941 2969 2942 ENDIF ! (adiab_ascent_mass_flux_depends_on_ejectliq) ELSE 2970 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!2943 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 2971 2944 ENDIF ! (cvflag_prec_eject) 2972 2945 2973 2946 2974 ! *** find rain water and evaporation using provisional *** 2975 ! *** estimates of rp(i)and rp(i-1) *** 2976 2947 ! *** find rain water and evaporation using provisional *** 2948 ! *** estimates of rp(i)and rp(i-1) *** 2977 2949 2978 2950 IF (cvflag_ice) THEN !!jygprl … … 2980 2952 DO il = 1, ncum !!jygprl 2981 2953 IF (i<=inb(il) .AND. lwork(il)) THEN !!jygprl 2982 frac(il, i) = (frac_a(il, i)*wdtrainA(il,i)+frac_s(il,i)*(wdtrainS(il,i)+wdtrainM(il,i))) / & !!jygprl2983 max(wdtrainA(il,i)+wdtrainS(il,i)+wdtrainM(il,i),smallestreal) !!jygprl2954 frac(il, i) = (frac_a(il, i) * wdtrainA(il, i) + frac_s(il, i) * (wdtrainS(il, i) + wdtrainM(il, i))) / & !!jygprl 2955 max(wdtrainA(il, i) + wdtrainS(il, i) + wdtrainM(il, i), smallestreal) !!jygprl 2984 2956 fraci(il, i) = frac(il, i) !!jygprl 2985 2957 END IF !!jygprl … … 2988 2960 DO il = 1, ncum !!jygprl 2989 2961 IF (i<=inb(il) .AND. lwork(il)) THEN !!jygprl 2990 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!2962 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 2991 2963 IF (keepbug_ice_frac) THEN 2992 2964 frac(il, i) = frac_s(il, i) 2993 ! Ice fraction computed again here as a function of the temperature seen by unsaturated downdraughts2994 ! (i.e. the cold pool temperature) for compatibility with earlier versions.2995 fraci(il, i) = 1. - (t(il, i)-243.15)/(263.15-243.15)2996 fraci(il, i) = min(max(fraci(il, i),0.0), 1.0)2997 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!2965 ! Ice fraction computed again here as a function of the temperature seen by unsaturated downdraughts 2966 ! (i.e. the cold pool temperature) for compatibility with earlier versions. 2967 fraci(il, i) = 1. - (t(il, i) - 243.15) / (263.15 - 243.15) 2968 fraci(il, i) = min(max(fraci(il, i), 0.0), 1.0) 2969 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 2998 2970 ELSE ! (keepbug_ice_frac) 2999 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!2971 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 3000 2972 frac(il, i) = frac_s(il, i) 3001 2973 fraci(il, i) = frac(il, i) !!jygprl 3002 2974 ENDIF ! (keepbug_ice_frac) 3003 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!2975 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 3004 2976 END IF !!jygprl 3005 2977 END DO !!jygprl … … 3007 2979 END IF !!jygprl 3008 2980 3009 3010 2981 DO il = 1, ncum 3011 2982 IF (i<=inb(il) .AND. lwork(il)) THEN … … 3014 2985 3015 2986 IF (i<inb(il)) THEN 3016 rp(il, i) = rp(il, i +1) + &3017 (cpd*(t(il,i+1)-t(il,i))+gz(il,i+1)-gz(il,i))/lv(il, i)3018 rp(il, i) = 0.5 *(rp(il,i)+rr(il,i))2987 rp(il, i) = rp(il, i + 1) + & 2988 (cpd * (t(il, i + 1) - t(il, i)) + gz(il, i + 1) - gz(il, i)) / lv(il, i) 2989 rp(il, i) = 0.5 * (rp(il, i) + rr(il, i)) 3019 2990 END IF 3020 rp(il, i) = max(rp(il, i), 0.0)3021 rp(il, i) = amin1(rp(il, i), rs(il,i))2991 rp(il, i) = max(rp(il, i), 0.0) 2992 rp(il, i) = amin1(rp(il, i), rs(il, i)) 3022 2993 rp(il, inb(il)) = rr(il, inb(il)) 3023 2994 3024 2995 IF (i==1) THEN 3025 afac = p(il, 1) *(rs(il,1)-rp(il,1))/(1.0E4+2000.0*p(il,1)*rs(il,1))2996 afac = p(il, 1) * (rs(il, 1) - rp(il, 1)) / (1.0E4 + 2000.0 * p(il, 1) * rs(il, 1)) 3026 2997 IF (cvflag_ice) THEN 3027 afac1 = p(il, i) *(rs(il,1)-rp(il,1))/(1.0E4+2000.0*p(il,1)*rs(il,1))2998 afac1 = p(il, i) * (rs(il, 1) - rp(il, 1)) / (1.0E4 + 2000.0 * p(il, 1) * rs(il, 1)) 3028 2999 END IF 3029 3000 ELSE 3030 rp(il, i -1) = rp(il, i) + (cpd*(t(il,i)-t(il,i-1))+gz(il,i)-gz(il,i-1))/lv(il, i)3031 rp(il, i -1) = 0.5*(rp(il,i-1)+rr(il,i-1))3032 rp(il, i -1) = amin1(rp(il,i-1), rs(il,i-1))3033 rp(il, i -1) = max(rp(il,i-1), 0.0)3034 afac1 = p(il, i) *(rs(il,i)-rp(il,i))/(1.0E4+2000.0*p(il,i)*rs(il,i))3035 afac2 = p(il, i -1)*(rs(il,i-1)-rp(il,i-1))/(1.0E4+2000.0*p(il,i-1)*rs(il,i-1))3036 afac = 0.5 *(afac1+afac2)3001 rp(il, i - 1) = rp(il, i) + (cpd * (t(il, i) - t(il, i - 1)) + gz(il, i) - gz(il, i - 1)) / lv(il, i) 3002 rp(il, i - 1) = 0.5 * (rp(il, i - 1) + rr(il, i - 1)) 3003 rp(il, i - 1) = amin1(rp(il, i - 1), rs(il, i - 1)) 3004 rp(il, i - 1) = max(rp(il, i - 1), 0.0) 3005 afac1 = p(il, i) * (rs(il, i) - rp(il, i)) / (1.0E4 + 2000.0 * p(il, i) * rs(il, i)) 3006 afac2 = p(il, i - 1) * (rs(il, i - 1) - rp(il, i - 1)) / (1.0E4 + 2000.0 * p(il, i - 1) * rs(il, i - 1)) 3007 afac = 0.5 * (afac1 + afac2) 3037 3008 END IF 3038 3009 IF (i==inb(il)) afac = 0.0 3039 3010 afac = max(afac, 0.0) 3040 bfac = 1. /(sigd(il)*wt(il,i))3041 3042 IF (prt_level >= 20) THEN3043 Print*, 'cv3_unsat after provisional rp estimate: rp, afac, bfac ', &3044 i, rp(1, i), afac,bfac3045 ENDIF3046 3047 !JYG13048 ! cc sigt=1.03049 ! cc IF(i.ge.icb)sigt=sigp(i)3050 ! prise en compte de la variation progressive de sigt dans3051 ! les couches icb et icb-1:3052 ! pour plcl<ph(i+1), pr1=0 & pr2=13053 ! pour plcl>ph(i), pr1=1 & pr2=03054 ! pour ph(i+1)<plcl<ph(i), pr1 est la proportion a cheval3055 ! sur le nuage, et pr2 est la proportion sous la base du3056 ! nuage.3057 pr1 = (plcl(il) -ph(il,i+1))/(ph(il,i)-ph(il,i+1))3058 pr1 = max(0., min(1., pr1))3059 pr2 = (ph(il, i)-plcl(il))/(ph(il,i)-ph(il,i+1))3060 pr2 = max(0., min(1., pr2))3061 sigt = sigp(il, i) *pr1 + pr23062 !JYG23063 3064 !JYG----3065 ! b6 = bfac*100.*sigd(il)*(ph(il,i)-ph(il,i+1))*sigt*afac3066 ! c6 = water(il,i+1) + wdtrain(il)*bfac3067 ! c6 = prec(il,i+1) + wdtrain(il)*bfac3068 ! revap=0.5*(-b6+sqrt(b6*b6+4.*c6))3069 ! evap(il,i)=sigt*afac*revap3070 ! water(il,i)=revap*revap3071 ! prec(il,i)=revap*revap3072 !! print *,' i,b6,c6,revap,evap(il,i),water(il,i),wdtrain(il) ', &3073 !! i,b6,c6,revap,evap(il,i),water(il,i),wdtrain(il)3074 !!---end jyg---3075 3076 ! --------retour à la formulation originale d'Emanuel.3011 bfac = 1. / (sigd(il) * wt(il, i)) 3012 3013 IF (prt_level >= 20) THEN 3014 Print*, 'cv3_unsat after provisional rp estimate: rp, afac, bfac ', & 3015 i, rp(1, i), afac, bfac 3016 ENDIF 3017 3018 !JYG1 3019 ! cc sigt=1.0 3020 ! cc IF(i.ge.icb)sigt=sigp(i) 3021 ! prise en compte de la variation progressive de sigt dans 3022 ! les couches icb et icb-1: 3023 ! pour plcl<ph(i+1), pr1=0 & pr2=1 3024 ! pour plcl>ph(i), pr1=1 & pr2=0 3025 ! pour ph(i+1)<plcl<ph(i), pr1 est la proportion a cheval 3026 ! sur le nuage, et pr2 est la proportion sous la base du 3027 ! nuage. 3028 pr1 = (plcl(il) - ph(il, i + 1)) / (ph(il, i) - ph(il, i + 1)) 3029 pr1 = max(0., min(1., pr1)) 3030 pr2 = (ph(il, i) - plcl(il)) / (ph(il, i) - ph(il, i + 1)) 3031 pr2 = max(0., min(1., pr2)) 3032 sigt = sigp(il, i) * pr1 + pr2 3033 !JYG2 3034 3035 !JYG---- 3036 ! b6 = bfac*100.*sigd(il)*(ph(il,i)-ph(il,i+1))*sigt*afac 3037 ! c6 = water(il,i+1) + wdtrain(il)*bfac 3038 ! c6 = prec(il,i+1) + wdtrain(il)*bfac 3039 ! revap=0.5*(-b6+sqrt(b6*b6+4.*c6)) 3040 ! evap(il,i)=sigt*afac*revap 3041 ! water(il,i)=revap*revap 3042 ! prec(il,i)=revap*revap 3043 !! print *,' i,b6,c6,revap,evap(il,i),water(il,i),wdtrain(il) ', & 3044 !! i,b6,c6,revap,evap(il,i),water(il,i),wdtrain(il) 3045 !!---end jyg--- 3046 3047 ! --------retour à la formulation originale d'Emanuel. 3077 3048 IF (cvflag_ice) THEN 3078 3049 3079 ! b6=bfac*50.*sigd(il)*(ph(il,i)-ph(il,i+1))*sigt*afac3080 ! c6=prec(il,i+1)+bfac*wdtrain(il) &3081 ! -50.*sigd(il)*bfac*(ph(il,i)-ph(il,i+1))*evap(il,i+1)3082 ! IF(c6.gt.0.0)THEN3083 ! revap=0.5*(-b6+sqrt(b6*b6+4.*c6))3084 3085 !JAM Attention: evap=sigt*E3086 ! Modification: evap devient l'évaporation en milieu de couche3087 ! car nécessaire dans cv3_yield3088 ! Du coup, il faut modifier pas mal d'équations...3089 ! et l'expression de afac qui devient afac13090 ! revap=sqrt((prec(i+1)+prec(i))/2)3091 3092 b6 = bfac *50.*sigd(il)*(ph(il,i)-ph(il,i+1))*sigt*afac13093 c6 = prec(il, i +1) + 0.5*bfac*wdtrain(il)3094 ! print *,'bfac,sigd(il),sigt,afac1 ',bfac,sigd(il),sigt,afac13095 ! print *,'prec(il,i+1),wdtrain(il) ',prec(il,i+1),wdtrain(il)3096 ! print *,'b6,c6,b6*b6+4.*c6 ',b6,c6,b6*b6+4.*c63097 IF (c6>b6 *b6+1.E-20) THEN3098 revap = 2. *c6/(b6+sqrt(b6*b6+4.*c6))3050 ! b6=bfac*50.*sigd(il)*(ph(il,i)-ph(il,i+1))*sigt*afac 3051 ! c6=prec(il,i+1)+bfac*wdtrain(il) & 3052 ! -50.*sigd(il)*bfac*(ph(il,i)-ph(il,i+1))*evap(il,i+1) 3053 ! IF(c6.gt.0.0)THEN 3054 ! revap=0.5*(-b6+sqrt(b6*b6+4.*c6)) 3055 3056 !JAM Attention: evap=sigt*E 3057 ! Modification: evap devient l'évaporation en milieu de couche 3058 ! car nécessaire dans cv3_yield 3059 ! Du coup, il faut modifier pas mal d'équations... 3060 ! et l'expression de afac qui devient afac1 3061 ! revap=sqrt((prec(i+1)+prec(i))/2) 3062 3063 b6 = bfac * 50. * sigd(il) * (ph(il, i) - ph(il, i + 1)) * sigt * afac1 3064 c6 = prec(il, i + 1) + 0.5 * bfac * wdtrain(il) 3065 ! print *,'bfac,sigd(il),sigt,afac1 ',bfac,sigd(il),sigt,afac1 3066 ! print *,'prec(il,i+1),wdtrain(il) ',prec(il,i+1),wdtrain(il) 3067 ! print *,'b6,c6,b6*b6+4.*c6 ',b6,c6,b6*b6+4.*c6 3068 IF (c6>b6 * b6 + 1.E-20) THEN 3069 revap = 2. * c6 / (b6 + sqrt(b6 * b6 + 4. * c6)) 3099 3070 ELSE 3100 revap = (-b6 +sqrt(b6*b6+4.*c6))/2.3071 revap = (-b6 + sqrt(b6 * b6 + 4. * c6)) / 2. 3101 3072 END IF 3102 prec(il, i) = max(0., 2. *revap*revap-prec(il,i+1))3103 ! PRINT*,prec(il,i),'neige'3104 3105 !JYG Dans sa formulation originale, Emanuel calcule l'evaporation par:3106 ! c evap(il,i)=sigt*afac*revap3107 ! ce qui n'est pas correct. Dans cv_routines, la formulation a été modifiee.3108 ! Ici,l'evaporation evap est simplement calculee par l'equation de3109 ! conservation.3110 ! prec(il,i)=revap*revap3111 ! else3112 !JYG---- Correction : si c6 <= 0, water(il,i)=0.3113 ! prec(il,i)=0.3114 ! END IF3115 3116 !JYG--- Dans tous les cas, evaporation = [tt ce qui entre dans la couche i]3117 ! moins [tt ce qui sort de la couche i]3118 ! print *, 'evap avec ice'3119 evap(il, i) = (wdtrain(il) +sigd(il)*wt(il,i)*(prec(il,i+1)-prec(il,i))) / &3120 (sigd(il)*(ph(il,i)-ph(il,i+1))*100.)3121 3122 IF (prt_level >= 20) THEN3123 Print*, 'cv3_unsat after evap computation: wdtrain, sigd, wt, prec(i+1),prec(i) ', &3124 i, wdtrain(1), sigd(1), wt(1,i), prec(1,i+1),prec(1,i)3125 ENDIF3126 3127 !jyg<3128 d6 = prec(il, i)-prec(il,i+1)3129 3130 !! d6 = bfac*wdtrain(il) - 100.*sigd(il)*bfac*(ph(il,i)-ph(il,i+1))*evap(il, i)3131 !! e6 = bfac*wdtrain(il)3132 !! f6 = -100.*sigd(il)*bfac*(ph(il,i)-ph(il,i+1))*evap(il, i)3133 !>jyg3134 !CR:tmax_fonte_cv: T for which ice is totally melted (used to be 275.15)3135 thaw = (t(il, i)-273.15)/(tmax_fonte_cv-273.15)3136 thaw = min(max(thaw, 0.0), 1.0)3137 !jyg<3138 water(il, i) = water(il, i +1) + (1-fraci(il,i))*d63139 ice(il, i) = ice(il, i+1) + fraci(il, i)*d63140 water(il, i) = min(prec(il, i), max(water(il,i), 0.))3141 ice(il, i) = min(prec(il,i), max(ice(il,i),0.))3142 3143 !! water(il, i) = water(il, i+1) + (1-fraci(il,i))*d63144 !! water(il, i) = max(water(il,i), 0.)3145 !! ice(il, i) = ice(il, i+1) + fraci(il, i)*d63146 !! ice(il, i) = max(ice(il,i), 0.)3147 !>jyg3148 fondue(il, i) = ice(il, i) *thaw3073 prec(il, i) = max(0., 2. * revap * revap - prec(il, i + 1)) 3074 ! PRINT*,prec(il,i),'neige' 3075 3076 !JYG Dans sa formulation originale, Emanuel calcule l'evaporation par: 3077 ! c evap(il,i)=sigt*afac*revap 3078 ! ce qui n'est pas correct. Dans cv_routines, la formulation a été modifiee. 3079 ! Ici,l'evaporation evap est simplement calculee par l'equation de 3080 ! conservation. 3081 ! prec(il,i)=revap*revap 3082 ! else 3083 !JYG---- Correction : si c6 <= 0, water(il,i)=0. 3084 ! prec(il,i)=0. 3085 ! END IF 3086 3087 !JYG--- Dans tous les cas, evaporation = [tt ce qui entre dans la couche i] 3088 ! moins [tt ce qui sort de la couche i] 3089 ! print *, 'evap avec ice' 3090 evap(il, i) = (wdtrain(il) + sigd(il) * wt(il, i) * (prec(il, i + 1) - prec(il, i))) / & 3091 (sigd(il) * (ph(il, i) - ph(il, i + 1)) * 100.) 3092 3093 IF (prt_level >= 20) THEN 3094 Print*, 'cv3_unsat after evap computation: wdtrain, sigd, wt, prec(i+1),prec(i) ', & 3095 i, wdtrain(1), sigd(1), wt(1, i), prec(1, i + 1), prec(1, i) 3096 ENDIF 3097 3098 !jyg< 3099 d6 = prec(il, i) - prec(il, i + 1) 3100 3101 !! d6 = bfac*wdtrain(il) - 100.*sigd(il)*bfac*(ph(il,i)-ph(il,i+1))*evap(il, i) 3102 !! e6 = bfac*wdtrain(il) 3103 !! f6 = -100.*sigd(il)*bfac*(ph(il,i)-ph(il,i+1))*evap(il, i) 3104 !>jyg 3105 !CR:tmax_fonte_cv: T for which ice is totally melted (used to be 275.15) 3106 thaw = (t(il, i) - 273.15) / (tmax_fonte_cv - 273.15) 3107 thaw = min(max(thaw, 0.0), 1.0) 3108 !jyg< 3109 water(il, i) = water(il, i + 1) + (1 - fraci(il, i)) * d6 3110 ice(il, i) = ice(il, i + 1) + fraci(il, i) * d6 3111 water(il, i) = min(prec(il, i), max(water(il, i), 0.)) 3112 ice(il, i) = min(prec(il, i), max(ice(il, i), 0.)) 3113 3114 !! water(il, i) = water(il, i+1) + (1-fraci(il,i))*d6 3115 !! water(il, i) = max(water(il,i), 0.) 3116 !! ice(il, i) = ice(il, i+1) + fraci(il, i)*d6 3117 !! ice(il, i) = max(ice(il,i), 0.) 3118 !>jyg 3119 fondue(il, i) = ice(il, i) * thaw 3149 3120 water(il, i) = water(il, i) + fondue(il, i) 3150 3121 ice(il, i) = ice(il, i) - fondue(il, i) 3151 3122 3152 IF (water(il, i)+ice(il,i)<1.E-30) THEN3123 IF (water(il, i) + ice(il, i)<1.E-30) THEN 3153 3124 faci(il, i) = 0. 3154 3125 ELSE 3155 faci(il, i) = ice(il, i) /(water(il,i)+ice(il,i))3126 faci(il, i) = ice(il, i) / (water(il, i) + ice(il, i)) 3156 3127 END IF 3157 3128 3158 ! water(il,i)=water(il,i+1)+(1.-fraci(il,i))*e6+(1.-faci(il,i))*f63159 ! water(il,i)=max(water(il,i),0.)3160 ! ice(il,i)=ice(il,i+1)+fraci(il,i)*e6+faci(il,i)*f63161 ! ice(il,i)=max(ice(il,i),0.)3162 ! fondue(il,i)=ice(il,i)*thaw3163 ! water(il,i)=water(il,i)+fondue(il,i)3164 ! ice(il,i)=ice(il,i)-fondue(il,i)3165 3166 ! if((water(il,i)+ice(il,i)).lt.1.e-30)THEN3167 ! faci(il,i)=0.3168 ! else3169 ! faci(il,i)=ice(il,i)/(water(il,i)+ice(il,i))3170 ! endif3129 ! water(il,i)=water(il,i+1)+(1.-fraci(il,i))*e6+(1.-faci(il,i))*f6 3130 ! water(il,i)=max(water(il,i),0.) 3131 ! ice(il,i)=ice(il,i+1)+fraci(il,i)*e6+faci(il,i)*f6 3132 ! ice(il,i)=max(ice(il,i),0.) 3133 ! fondue(il,i)=ice(il,i)*thaw 3134 ! water(il,i)=water(il,i)+fondue(il,i) 3135 ! ice(il,i)=ice(il,i)-fondue(il,i) 3136 3137 ! if((water(il,i)+ice(il,i)).lt.1.e-30)THEN 3138 ! faci(il,i)=0. 3139 ! else 3140 ! faci(il,i)=ice(il,i)/(water(il,i)+ice(il,i)) 3141 ! endif 3171 3142 3172 3143 ELSE 3173 b6 = bfac *50.*sigd(il)*(ph(il,i)-ph(il,i+1))*sigt*afac3174 c6 = water(il, i +1) + bfac*wdtrain(il) - &3175 50.*sigd(il)*bfac*(ph(il,i)-ph(il,i+1))*evap(il, i+1)3144 b6 = bfac * 50. * sigd(il) * (ph(il, i) - ph(il, i + 1)) * sigt * afac 3145 c6 = water(il, i + 1) + bfac * wdtrain(il) - & 3146 50. * sigd(il) * bfac * (ph(il, i) - ph(il, i + 1)) * evap(il, i + 1) 3176 3147 IF (c6>0.0) THEN 3177 revap = 0.5 *(-b6+sqrt(b6*b6+4.*c6))3178 water(il, i) = revap *revap3148 revap = 0.5 * (-b6 + sqrt(b6 * b6 + 4. * c6)) 3149 water(il, i) = revap * revap 3179 3150 ELSE 3180 3151 water(il, i) = 0. 3181 3152 END IF 3182 ! print *, 'evap sans ice'3183 evap(il, i) = (wdtrain(il) +sigd(il)*wt(il,i)*(water(il,i+1)-water(il,i)))/ &3184 (sigd(il)*(ph(il,i)-ph(il,i+1))*100.)3153 ! print *, 'evap sans ice' 3154 evap(il, i) = (wdtrain(il) + sigd(il) * wt(il, i) * (water(il, i + 1) - water(il, i))) / & 3155 (sigd(il) * (ph(il, i) - ph(il, i + 1)) * 100.) 3185 3156 3186 3157 END IF 3187 3158 END IF !(i.le.inb(il) .AND. lwork(il)) 3188 3159 END DO 3189 ! ----------------------------------------------------------------3190 3191 ! cc3192 ! *** calculate precipitating downdraft mass flux under ***3193 ! *** hydrostatic approximation ***3160 ! ---------------------------------------------------------------- 3161 3162 ! cc 3163 ! *** calculate precipitating downdraft mass flux under *** 3164 ! *** hydrostatic approximation *** 3194 3165 3195 3166 DO il = 1, ncum 3196 3167 IF (i<=inb(il) .AND. lwork(il) .AND. i/=1) THEN 3197 3168 3198 tevap(il) = max(0.0, evap(il, i))3199 delth = max(0.001, (th(il, i)-th(il,i-1)))3169 tevap(il) = max(0.0, evap(il, i)) 3170 delth = max(0.001, (th(il, i) - th(il, i - 1))) 3200 3171 IF (cvflag_ice) THEN 3201 3172 IF (cvflag_grav) THEN 3202 mp(il, i) = 100. *ginv*(lvcp(il,i)*sigd(il)*tevap(il)* &3203 (p(il,i-1)-p(il,i))/delth + &3204 lfcp(il,i)*sigd(il)*faci(il,i)*tevap(il)* &3205 (p(il,i-1)-p(il,i))/delth + &3206 lfcp(il,i)*sigd(il)*wt(il,i)/100.*fondue(il,i)* &3207 (p(il,i-1)-p(il,i))/delth/(ph(il,i)-ph(il,i+1)))3173 mp(il, i) = 100. * ginv * (lvcp(il, i) * sigd(il) * tevap(il) * & 3174 (p(il, i - 1) - p(il, i)) / delth + & 3175 lfcp(il, i) * sigd(il) * faci(il, i) * tevap(il) * & 3176 (p(il, i - 1) - p(il, i)) / delth + & 3177 lfcp(il, i) * sigd(il) * wt(il, i) / 100. * fondue(il, i) * & 3178 (p(il, i - 1) - p(il, i)) / delth / (ph(il, i) - ph(il, i + 1))) 3208 3179 ELSE 3209 mp(il, i) = 10. *(lvcp(il,i)*sigd(il)*tevap(il)* &3210 (p(il,i-1)-p(il,i))/delth + &3211 lfcp(il,i)*sigd(il)*faci(il,i)*tevap(il)* &3212 (p(il,i-1)-p(il,i))/delth + &3213 lfcp(il,i)*sigd(il)*wt(il,i)/100.*fondue(il,i)* &3214 (p(il,i-1)-p(il,i))/delth/(ph(il,i)-ph(il,i+1)))3180 mp(il, i) = 10. * (lvcp(il, i) * sigd(il) * tevap(il) * & 3181 (p(il, i - 1) - p(il, i)) / delth + & 3182 lfcp(il, i) * sigd(il) * faci(il, i) * tevap(il) * & 3183 (p(il, i - 1) - p(il, i)) / delth + & 3184 lfcp(il, i) * sigd(il) * wt(il, i) / 100. * fondue(il, i) * & 3185 (p(il, i - 1) - p(il, i)) / delth / (ph(il, i) - ph(il, i + 1))) 3215 3186 3216 3187 END IF 3217 3188 ELSE 3218 3189 IF (cvflag_grav) THEN 3219 mp(il, i) = 100. *ginv*lvcp(il, i)*sigd(il)*tevap(il)* &3220 (p(il,i-1)-p(il,i))/delth3190 mp(il, i) = 100. * ginv * lvcp(il, i) * sigd(il) * tevap(il) * & 3191 (p(il, i - 1) - p(il, i)) / delth 3221 3192 ELSE 3222 mp(il, i) = 10. *lvcp(il, i)*sigd(il)*tevap(il)* &3223 (p(il,i-1)-p(il,i))/delth3193 mp(il, i) = 10. * lvcp(il, i) * sigd(il) * tevap(il) * & 3194 (p(il, i - 1) - p(il, i)) / delth 3224 3195 END IF 3225 3196 … … 3228 3199 END IF !(i.le.inb(il) .AND. lwork(il) .AND. i.NE.1) 3229 3200 IF (prt_level >= 20) THEN 3230 PRINT *, 'cv3_unsat, mp hydrostatic ', i, mp(il,i)3201 PRINT *, 'cv3_unsat, mp hydrostatic ', i, mp(il, i) 3231 3202 ENDIF 3232 3203 END DO 3233 ! ----------------------------------------------------------------3234 3235 ! *** if hydrostatic assumption fails, ***3236 ! *** solve cubic difference equation for downdraft theta ***3237 ! *** and mass flux from two simultaneous differential eqns ***3204 ! ---------------------------------------------------------------- 3205 3206 ! *** if hydrostatic assumption fails, *** 3207 ! *** solve cubic difference equation for downdraft theta *** 3208 ! *** and mass flux from two simultaneous differential eqns *** 3238 3209 3239 3210 DO il = 1, ncum 3240 3211 IF (i<=inb(il) .AND. lwork(il) .AND. i/=1) THEN 3241 3212 3242 amfac = sigd(il) *sigd(il)*70.0*ph(il, i)*(p(il,i-1)-p(il,i))* &3243 (th(il,i)-th(il,i-1))/(tv(il,i)*th(il,i))3244 amp2 = abs(mp(il, i+1)*mp(il,i+1)-mp(il,i)*mp(il,i))3245 3246 IF (amp2>(0.1 *amfac)) THEN3247 xf = 100.0 *sigd(il)*sigd(il)*sigd(il)*(ph(il,i)-ph(il,i+1))3248 tf = b(il, i) - 5.0 *(th(il,i)-th(il,i-1))*t(il, i) / &3249 (lvcp(il,i)*sigd(il)*th(il,i))3250 af = xf *tf + mp(il, i+1)*mp(il, i+1)*tinv3213 amfac = sigd(il) * sigd(il) * 70.0 * ph(il, i) * (p(il, i - 1) - p(il, i)) * & 3214 (th(il, i) - th(il, i - 1)) / (tv(il, i) * th(il, i)) 3215 amp2 = abs(mp(il, i + 1) * mp(il, i + 1) - mp(il, i) * mp(il, i)) 3216 3217 IF (amp2>(0.1 * amfac)) THEN 3218 xf = 100.0 * sigd(il) * sigd(il) * sigd(il) * (ph(il, i) - ph(il, i + 1)) 3219 tf = b(il, i) - 5.0 * (th(il, i) - th(il, i - 1)) * t(il, i) / & 3220 (lvcp(il, i) * sigd(il) * th(il, i)) 3221 af = xf * tf + mp(il, i + 1) * mp(il, i + 1) * tinv 3251 3222 3252 3223 IF (cvflag_ice) THEN 3253 bf = 2. *(tinv*mp(il,i+1))**3 + tinv*mp(il, i+1)*xf*tf + &3254 50.*(p(il,i-1)-p(il,i))*xf*(tevap(il)*(1.+(lf(il,i)/lv(il,i))*faci(il,i)) + &3255 (lf(il,i)/lv(il,i))*wt(il,i)/100.*fondue(il,i)/(ph(il,i)-ph(il,i+1)))3224 bf = 2. * (tinv * mp(il, i + 1))**3 + tinv * mp(il, i + 1) * xf * tf + & 3225 50. * (p(il, i - 1) - p(il, i)) * xf * (tevap(il) * (1. + (lf(il, i) / lv(il, i)) * faci(il, i)) + & 3226 (lf(il, i) / lv(il, i)) * wt(il, i) / 100. * fondue(il, i) / (ph(il, i) - ph(il, i + 1))) 3256 3227 ELSE 3257 3228 3258 bf = 2. *(tinv*mp(il,i+1))**3 + tinv*mp(il, i+1)*xf*tf + &3259 50.*(p(il,i-1)-p(il,i))*xf*tevap(il)3229 bf = 2. * (tinv * mp(il, i + 1))**3 + tinv * mp(il, i + 1) * xf * tf + & 3230 50. * (p(il, i - 1) - p(il, i)) * xf * tevap(il) 3260 3231 END IF 3261 3232 … … 3263 3234 IF (bf<0.0) fac2 = -1.0 3264 3235 bf = abs(bf) 3265 ur = 0.25 *bf*bf - af*af*af*tinv*tinv*tinv3236 ur = 0.25 * bf * bf - af * af * af * tinv * tinv * tinv 3266 3237 IF (ur>=0.0) THEN 3267 3238 sru = sqrt(ur) 3268 3239 fac = 1.0 3269 IF ((0.5 *bf-sru)<0.0) fac = -1.03270 mp(il, i) = mp(il, i +1)*tinv + (0.5*bf+sru)**tinv + &3271 fac*(abs(0.5*bf-sru))**tinv3240 IF ((0.5 * bf - sru)<0.0) fac = -1.0 3241 mp(il, i) = mp(il, i + 1) * tinv + (0.5 * bf + sru)**tinv + & 3242 fac * (abs(0.5 * bf - sru))**tinv 3272 3243 ELSE 3273 d = atan(2. *sqrt(-ur)/(bf+1.0E-28))3244 d = atan(2. * sqrt(-ur) / (bf + 1.0E-28)) 3274 3245 IF (fac2<0.0) d = 3.14159 - d 3275 mp(il, i) = mp(il, i +1)*tinv + 2.*sqrt(af*tinv)*cos(d*tinv)3246 mp(il, i) = mp(il, i + 1) * tinv + 2. * sqrt(af * tinv) * cos(d * tinv) 3276 3247 END IF 3277 mp(il, i) = max(0.0, mp(il, i))3248 mp(il, i) = max(0.0, mp(il, i)) 3278 3249 IF (prt_level >= 20) THEN 3279 PRINT *, 'cv3_unsat, mp cubic ', i, mp(il,i)3250 PRINT *, 'cv3_unsat, mp cubic ', i, mp(il, i) 3280 3251 ENDIF 3281 3252 3282 3253 IF (cvflag_ice) THEN 3283 3254 IF (cvflag_grav) THEN 3284 !JYG : il y a vraisemblablement une erreur dans la ligne 2 suivante:3285 ! il faut diviser par (mp(il,i)*sigd(il)*grav) et non par (mp(il,i)+sigd(il)*0.1).3286 ! Et il faut bien revoir les facteurs 100.3287 b(il, i -1) = b(il, i) + 100.0*(p(il,i-1)-p(il,i))* &3288 (tevap(il)*(1.+(lf(il,i)/lv(il,i))*faci(il,i)) + &3289 (lf(il,i)/lv(il,i))*wt(il,i)/100.*fondue(il,i) / &3290 (ph(il,i)-ph(il,i+1))) / &3291 (mp(il,i)+sigd(il)*0.1) - &3292 10.0*(th(il,i)-th(il,i-1))*t(il, i) / &3293 (lvcp(il,i)*sigd(il)*th(il,i))3255 !JYG : il y a vraisemblablement une erreur dans la ligne 2 suivante: 3256 ! il faut diviser par (mp(il,i)*sigd(il)*grav) et non par (mp(il,i)+sigd(il)*0.1). 3257 ! Et il faut bien revoir les facteurs 100. 3258 b(il, i - 1) = b(il, i) + 100.0 * (p(il, i - 1) - p(il, i)) * & 3259 (tevap(il) * (1. + (lf(il, i) / lv(il, i)) * faci(il, i)) + & 3260 (lf(il, i) / lv(il, i)) * wt(il, i) / 100. * fondue(il, i) / & 3261 (ph(il, i) - ph(il, i + 1))) / & 3262 (mp(il, i) + sigd(il) * 0.1) - & 3263 10.0 * (th(il, i) - th(il, i - 1)) * t(il, i) / & 3264 (lvcp(il, i) * sigd(il) * th(il, i)) 3294 3265 ELSE 3295 b(il, i -1) = b(il, i) + 100.0*(p(il,i-1)-p(il,i))*&3296 (tevap(il)*(1.+(lf(il,i)/lv(il,i))*faci(il,i)) + &3297 (lf(il,i)/lv(il,i))*wt(il,i)/100.*fondue(il,i) / &3298 (ph(il,i)-ph(il,i+1))) / &3299 (mp(il,i)+sigd(il)*0.1) - &3300 10.0*(th(il,i)-th(il,i-1))*t(il, i) / &3301 (lvcp(il,i)*sigd(il)*th(il,i))3266 b(il, i - 1) = b(il, i) + 100.0 * (p(il, i - 1) - p(il, i)) * & 3267 (tevap(il) * (1. + (lf(il, i) / lv(il, i)) * faci(il, i)) + & 3268 (lf(il, i) / lv(il, i)) * wt(il, i) / 100. * fondue(il, i) / & 3269 (ph(il, i) - ph(il, i + 1))) / & 3270 (mp(il, i) + sigd(il) * 0.1) - & 3271 10.0 * (th(il, i) - th(il, i - 1)) * t(il, i) / & 3272 (lvcp(il, i) * sigd(il) * th(il, i)) 3302 3273 END IF 3303 3274 ELSE 3304 3275 IF (cvflag_grav) THEN 3305 b(il, i -1) = b(il, i) + 100.0*(p(il,i-1)-p(il,i))*tevap(il) / &3306 (mp(il,i)+sigd(il)*0.1) - &3307 10.0*(th(il,i)-th(il,i-1))*t(il, i) / &3308 (lvcp(il,i)*sigd(il)*th(il,i))3276 b(il, i - 1) = b(il, i) + 100.0 * (p(il, i - 1) - p(il, i)) * tevap(il) / & 3277 (mp(il, i) + sigd(il) * 0.1) - & 3278 10.0 * (th(il, i) - th(il, i - 1)) * t(il, i) / & 3279 (lvcp(il, i) * sigd(il) * th(il, i)) 3309 3280 ELSE 3310 b(il, i -1) = b(il, i) + 100.0*(p(il,i-1)-p(il,i))*tevap(il) / &3311 (mp(il,i)+sigd(il)*0.1) - &3312 10.0*(th(il,i)-th(il,i-1))*t(il, i) / &3313 (lvcp(il,i)*sigd(il)*th(il,i))3281 b(il, i - 1) = b(il, i) + 100.0 * (p(il, i - 1) - p(il, i)) * tevap(il) / & 3282 (mp(il, i) + sigd(il) * 0.1) - & 3283 10.0 * (th(il, i) - th(il, i - 1)) * t(il, i) / & 3284 (lvcp(il, i) * sigd(il) * th(il, i)) 3314 3285 END IF 3315 3286 END IF 3316 b(il, i -1) = max(b(il,i-1), 0.0)3287 b(il, i - 1) = max(b(il, i - 1), 0.0) 3317 3288 3318 3289 END IF !(amp2.gt.(0.1*amfac)) 3319 3290 3320 !jyg< This part shifted 10 lines farther3321 !!! *** limit magnitude of mp(i) to meet cfl condition ***3322 !!3323 !! ampmax = 2.0*(ph(il,i)-ph(il,i+1))*delti3324 !! amp2 = 2.0*(ph(il,i-1)-ph(il,i))*delti3325 !! ampmax = min(ampmax, amp2)3326 !! mp(il, i) = min(mp(il,i), ampmax)3327 !>jyg3328 3329 ! *** force mp to decrease linearly to zero ***3330 ! *** between cloud base and the surface ***3331 3332 3333 ! c IF(p(il,i).gt.p(il,icb(il)))THEN3334 ! c mp(il,i)=mp(il,icb(il))*(p(il,1)-p(il,i))/(p(il,1)-p(il,icb(il)))3335 ! c endif3336 IF (ph(il, i)>0.9*plcl(il)) THEN3337 mp(il, i) = mp(il, i) *(ph(il,1)-ph(il,i))/(ph(il,1)-0.9*plcl(il))3291 !jyg< This part shifted 10 lines farther 3292 !!! *** limit magnitude of mp(i) to meet cfl condition *** 3293 !! 3294 !! ampmax = 2.0*(ph(il,i)-ph(il,i+1))*delti 3295 !! amp2 = 2.0*(ph(il,i-1)-ph(il,i))*delti 3296 !! ampmax = min(ampmax, amp2) 3297 !! mp(il, i) = min(mp(il,i), ampmax) 3298 !>jyg 3299 3300 ! *** force mp to decrease linearly to zero *** 3301 ! *** between cloud base and the surface *** 3302 3303 3304 ! c IF(p(il,i).gt.p(il,icb(il)))THEN 3305 ! c mp(il,i)=mp(il,icb(il))*(p(il,1)-p(il,i))/(p(il,1)-p(il,icb(il))) 3306 ! c endif 3307 IF (ph(il, i)>0.9 * plcl(il)) THEN 3308 mp(il, i) = mp(il, i) * (ph(il, 1) - ph(il, i)) / (ph(il, 1) - 0.9 * plcl(il)) 3338 3309 END IF 3339 3310 3340 !jyg< Shifted part3341 ! *** limit magnitude of mp(i) to meet cfl condition ***3342 3343 ampmax = 2.0 *(ph(il,i)-ph(il,i+1))*delti3344 amp2 = 2.0 *(ph(il,i-1)-ph(il,i))*delti3311 !jyg< Shifted part 3312 ! *** limit magnitude of mp(i) to meet cfl condition *** 3313 3314 ampmax = 2.0 * (ph(il, i) - ph(il, i + 1)) * delti 3315 amp2 = 2.0 * (ph(il, i - 1) - ph(il, i)) * delti 3345 3316 ampmax = min(ampmax, amp2) 3346 mp(il, i) = min(mp(il, i), ampmax)3347 !>jyg3317 mp(il, i) = min(mp(il, i), ampmax) 3318 !>jyg 3348 3319 3349 3320 END IF ! (i.le.inb(il) .AND. lwork(il) .AND. i.NE.1) 3350 3321 END DO 3351 ! ----------------------------------------------------------------3322 ! ---------------------------------------------------------------- 3352 3323 3353 3324 IF (prt_level >= 20) THEN 3354 3325 Print*, 'cv3_unsat after mp computation: mp, b(i), b(i-1) ', & 3355 i, mp(1, i), b(1,i), b(1,max(i-1,1))3326 i, mp(1, i), b(1, i), b(1, max(i - 1, 1)) 3356 3327 ENDIF 3357 3328 3358 ! *** find mixing ratio of precipitating downdraft ***3329 ! *** find mixing ratio of precipitating downdraft *** 3359 3330 3360 3331 DO il = 1, ncum 3361 3332 IF (i<inb(il) .AND. lwork(il)) THEN 3362 mplus(il) = mp(il, i) > mp(il, i +1)3333 mplus(il) = mp(il, i) > mp(il, i + 1) 3363 3334 END IF ! (i.lt.inb(il) .AND. lwork(il)) 3364 3335 END DO … … 3372 3343 3373 3344 IF (cvflag_grav) THEN 3374 rp(il, i) = rp(il, i +1)*mp(il, i+1) + rr(il, i)*(mp(il,i)-mp(il,i+1)) + &3375 100.*ginv*0.5*sigd(il)*(ph(il,i)-ph(il,i+1))*(evap(il,i+1)+evap(il,i))3345 rp(il, i) = rp(il, i + 1) * mp(il, i + 1) + rr(il, i) * (mp(il, i) - mp(il, i + 1)) + & 3346 100. * ginv * 0.5 * sigd(il) * (ph(il, i) - ph(il, i + 1)) * (evap(il, i + 1) + evap(il, i)) 3376 3347 ELSE 3377 rp(il, i) = rp(il, i +1)*mp(il, i+1) + rr(il, i)*(mp(il,i)-mp(il,i+1)) + &3378 5.*sigd(il)*(ph(il,i)-ph(il,i+1))*(evap(il,i+1)+evap(il,i))3348 rp(il, i) = rp(il, i + 1) * mp(il, i + 1) + rr(il, i) * (mp(il, i) - mp(il, i + 1)) + & 3349 5. * sigd(il) * (ph(il, i) - ph(il, i + 1)) * (evap(il, i + 1) + evap(il, i)) 3379 3350 END IF 3380 rp(il, i) = rp(il, i) /mp(il, i)3381 up(il, i) = up(il, i +1)*mp(il, i+1) + u(il, i)*(mp(il,i)-mp(il,i+1))3382 up(il, i) = up(il, i) /mp(il, i)3383 vp(il, i) = vp(il, i +1)*mp(il, i+1) + v(il, i)*(mp(il,i)-mp(il,i+1))3384 vp(il, i) = vp(il, i) /mp(il, i)3351 rp(il, i) = rp(il, i) / mp(il, i) 3352 up(il, i) = up(il, i + 1) * mp(il, i + 1) + u(il, i) * (mp(il, i) - mp(il, i + 1)) 3353 up(il, i) = up(il, i) / mp(il, i) 3354 vp(il, i) = vp(il, i + 1) * mp(il, i + 1) + v(il, i) * (mp(il, i) - mp(il, i + 1)) 3355 vp(il, i) = vp(il, i) / mp(il, i) 3385 3356 3386 3357 ELSE ! if (mplus(il)) 3387 3358 3388 IF (mp(il, i+1)>1.0E-16) THEN3359 IF (mp(il, i + 1)>1.0E-16) THEN 3389 3360 IF (cvflag_grav) THEN 3390 rp(il, i) = rp(il, i+1) + 100.*ginv*0.5*sigd(il)*(ph(il,i)-ph(il,i+1)) * &3391 (evap(il,i+1)+evap(il,i))/mp(il,i+1)3361 rp(il, i) = rp(il, i + 1) + 100. * ginv * 0.5 * sigd(il) * (ph(il, i) - ph(il, i + 1)) * & 3362 (evap(il, i + 1) + evap(il, i)) / mp(il, i + 1) 3392 3363 ELSE 3393 rp(il, i) = rp(il, i+1) + 5.*sigd(il)*(ph(il,i)-ph(il,i+1)) * &3394 (evap(il,i+1)+evap(il,i))/mp(il, i+1)3364 rp(il, i) = rp(il, i + 1) + 5. * sigd(il) * (ph(il, i) - ph(il, i + 1)) * & 3365 (evap(il, i + 1) + evap(il, i)) / mp(il, i + 1) 3395 3366 END IF 3396 up(il, i) = up(il, i +1)3397 vp(il, i) = vp(il, i +1)3367 up(il, i) = up(il, i + 1) 3368 vp(il, i) = vp(il, i + 1) 3398 3369 END IF ! (mp(il,i+1).gt.1.0e-16) 3399 3370 END IF ! (mplus(il)) ELSE IF (.NOT.mplus(il)) 3400 3371 3401 rp(il, i) = amin1(rp(il, i), rs(il,i))3402 rp(il, i) = max(rp(il, i), 0.0)3372 rp(il, i) = amin1(rp(il, i), rs(il, i)) 3373 rp(il, i) = max(rp(il, i), 0.0) 3403 3374 3404 3375 END IF ! (i.lt.inb(il) .AND. lwork(il)) 3405 3376 END DO 3406 ! ---------------------------------------------------------------- 3407 3408 ! *** find tracer concentrations in precipitating downdraft *** 3409 3410 !AC! do j=1,ntra 3411 !AC! do il = 1,ncum 3412 !AC! if (i.lt.inb(il) .AND. lwork(il)) THEN 3413 !AC!c 3414 !AC! IF(mplus(il))THEN 3415 !AC! trap(il,i,j)=trap(il,i+1,j)*mp(il,i+1) 3416 !AC! : +trap(il,i,j)*(mp(il,i)-mp(il,i+1)) 3417 !AC! trap(il,i,j)=trap(il,i,j)/mp(il,i) 3418 !AC! else ! if (mplus(il)) 3419 !AC! IF(mp(il,i+1).gt.1.0e-16)THEN 3420 !AC! trap(il,i,j)=trap(il,i+1,j) 3421 !AC! endif 3422 !AC! endif ! (mplus(il)) ELSE IF (.NOT.mplus(il)) 3423 !AC!c 3424 !AC! endif ! (i.lt.inb(il) .AND. lwork(il)) 3425 !AC! enddo 3426 !AC! END DO 3427 3428 400 END DO 3429 ! ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3430 3431 ! *** end of downdraft loop *** 3432 3433 ! ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3434 3435 3436 3377 ! ---------------------------------------------------------------- 3378 3379 ! *** find tracer concentrations in precipitating downdraft *** 3380 3381 !AC! do j=1,ntra 3382 !AC! do il = 1,ncum 3383 !AC! if (i.lt.inb(il) .AND. lwork(il)) THEN 3384 !AC!c 3385 !AC! IF(mplus(il))THEN 3386 !AC! trap(il,i,j)=trap(il,i+1,j)*mp(il,i+1) 3387 !AC! : +trap(il,i,j)*(mp(il,i)-mp(il,i+1)) 3388 !AC! trap(il,i,j)=trap(il,i,j)/mp(il,i) 3389 !AC! else ! if (mplus(il)) 3390 !AC! IF(mp(il,i+1).gt.1.0e-16)THEN 3391 !AC! trap(il,i,j)=trap(il,i+1,j) 3392 !AC! endif 3393 !AC! endif ! (mplus(il)) ELSE IF (.NOT.mplus(il)) 3394 !AC!c 3395 !AC! endif ! (i.lt.inb(il) .AND. lwork(il)) 3396 !AC! enddo 3397 !AC! END DO 3398 3399 400 END DO 3400 ! ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3401 3402 ! *** end of downdraft loop *** 3403 3404 ! ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3437 3405 3438 3406 END SUBROUTINE cv3_unsat 3439 3407 3440 3408 SUBROUTINE cv3_yield(nloc, ncum, nd, na, ntra, ok_conserv_q, & 3441 icb, inb, delt, & 3442 t, rr, t_wake, rr_wake, s_wake, u, v, tra, & 3443 gz, p, ph, h, hp, lv, lf, cpn, th, th_wake, & 3444 ep, clw, qpreca, m, tp, mp, rp, up, vp, trap, & 3445 wt, water, ice, evap, fondue, faci, b, sigd, & 3446 ment, qent, hent, iflag_mix, uent, vent, & 3447 nent, elij, traent, sig, & 3448 tv, tvp, wghti, & 3449 iflag, precip, Vprecip, Vprecipi, & ! jyg: Vprecipi 3450 ft, fr, fr_comp, fu, fv, ftra, & ! jyg 3451 cbmf, upwd, dnwd, dnwd0, ma, mip, & 3452 !! tls, tps, ! useless . jyg 3453 qcondc, wd, & 3454 ftd, fqd, qta, qtc, sigt, detrain, tau_cld_cv, coefw_cld_cv) 3455 3456 USE lmdz_print_control, ONLY: lunout, prt_level 3457 USE add_phys_tend_mod, ONLY: fl_cor_ebil 3458 USE lmdz_conema3 3459 USE lmdz_cvflag 3409 icb, inb, delt, & 3410 t, rr, t_wake, rr_wake, s_wake, u, v, tra, & 3411 gz, p, ph, h, hp, lv, lf, cpn, th, th_wake, & 3412 ep, clw, qpreca, m, tp, mp, rp, up, vp, trap, & 3413 wt, water, ice, evap, fondue, faci, b, sigd, & 3414 ment, qent, hent, iflag_mix, uent, vent, & 3415 nent, elij, traent, sig, & 3416 tv, tvp, wghti, & 3417 iflag, precip, Vprecip, Vprecipi, & ! jyg: Vprecipi 3418 ft, fr, fr_comp, fu, fv, ftra, & ! jyg 3419 cbmf, upwd, dnwd, dnwd0, ma, mip, & 3420 !! tls, tps, ! useless . jyg 3421 qcondc, wd, & 3422 ftd, fqd, qta, qtc, sigt, detrain, tau_cld_cv, coefw_cld_cv) 3423 3424 USE lmdz_print_control, ONLY: lunout, prt_level 3425 USE add_phys_tend_mod, ONLY: fl_cor_ebil 3426 USE lmdz_conema3 3427 USE lmdz_cvflag 3428 USE lmdz_cvthermo 3429 USE lmdz_cv3param 3460 3430 3461 3431 IMPLICIT NONE 3462 3432 3463 include "cvthermo.h" 3464 include "cv3param.h" 3465 3466 !inputs: 3467 INTEGER, INTENT (IN) :: iflag_mix 3468 INTEGER, INTENT (IN) :: ncum, nd, na, ntra, nloc 3469 LOGICAL, INTENT (IN) :: ok_conserv_q 3470 INTEGER, DIMENSION (nloc), INTENT (IN) :: icb, inb 3471 REAL, INTENT (IN) :: delt 3472 REAL, DIMENSION (nloc, nd), INTENT (IN) :: t, rr, u, v 3473 REAL, DIMENSION (nloc, nd), INTENT (IN) :: t_wake, rr_wake 3474 REAL, DIMENSION (nloc), INTENT (IN) :: s_wake 3475 REAL, DIMENSION (nloc, nd, ntra), INTENT (IN) :: tra 3476 REAL, DIMENSION (nloc, nd), INTENT (IN) :: p 3477 REAL, DIMENSION (nloc, nd+1), INTENT (IN) :: ph 3478 REAL, DIMENSION (nloc, na), INTENT (IN) :: gz, h, hp 3479 REAL, DIMENSION (nloc, na), INTENT (IN) :: th, tp 3480 REAL, DIMENSION (nloc, na), INTENT (IN) :: lv, cpn, ep, clw 3481 REAL, DIMENSION (nloc, na), INTENT (IN) :: lf 3482 REAL, DIMENSION (nloc, na), INTENT (IN) :: rp, up 3483 REAL, DIMENSION (nloc, na), INTENT (IN) :: vp 3484 REAL, DIMENSION (nloc, nd), INTENT (IN) :: wt 3485 REAL, DIMENSION (nloc, nd, ntra), INTENT (IN) :: trap 3486 REAL, DIMENSION (nloc, na), INTENT (IN) :: water, evap, b 3487 REAL, DIMENSION (nloc, na), INTENT (IN) :: fondue, faci, ice 3488 REAL, DIMENSION (nloc, na, na), INTENT (IN) :: qent, uent 3489 REAL, DIMENSION (nloc, na, na), INTENT (IN) :: hent 3490 REAL, DIMENSION (nloc, na, na), INTENT (IN) :: vent, elij 3491 INTEGER, DIMENSION (nloc, nd), INTENT (IN) :: nent 3492 REAL, DIMENSION (nloc, na, na, ntra), INTENT (IN) :: traent 3493 REAL, DIMENSION (nloc, nd), INTENT (IN) :: tv, tvp, wghti 3494 REAL, DIMENSION (nloc, nd), INTENT (IN) :: qta 3495 REAL, DIMENSION (nloc, na),INTENT(IN) :: qpreca 3496 REAL, INTENT(IN) :: tau_cld_cv, coefw_cld_cv 3497 3498 !input/output: 3499 REAL, DIMENSION (nloc, na), INTENT (INOUT) :: m, mp 3500 REAL, DIMENSION (nloc, na, na), INTENT (INOUT) :: ment 3501 INTEGER, DIMENSION (nloc), INTENT (INOUT) :: iflag 3502 REAL, DIMENSION (nloc, nd), INTENT (INOUT) :: sig 3503 REAL, DIMENSION (nloc), INTENT (INOUT) :: sigd 3504 3505 !outputs: 3506 REAL, DIMENSION (nloc), INTENT (OUT) :: precip 3507 REAL, DIMENSION (nloc, nd), INTENT (OUT) :: ft, fr, fu, fv , fr_comp 3508 REAL, DIMENSION (nloc, nd), INTENT (OUT) :: ftd, fqd 3509 REAL, DIMENSION (nloc, nd, ntra), INTENT (OUT) :: ftra 3510 REAL, DIMENSION (nloc, nd), INTENT (OUT) :: upwd, dnwd, ma 3511 REAL, DIMENSION (nloc, nd), INTENT (OUT) :: dnwd0, mip 3512 REAL, DIMENSION (nloc, nd+1), INTENT (OUT) :: Vprecip 3513 REAL, DIMENSION (nloc, nd+1), INTENT (OUT) :: Vprecipi 3514 !! REAL tls(nloc, nd), tps(nloc, nd) ! useless . jyg 3515 REAL, DIMENSION (nloc, nd), INTENT (OUT) :: qcondc ! cld 3516 REAL, DIMENSION (nloc, nd), INTENT (OUT) :: qtc, sigt ! cld 3517 REAL, DIMENSION (nloc, nd), INTENT (OUT) :: detrain ! Louis : pour le calcul de Klein du terme de variance qui détraine dans lenvironnement 3518 REAL, DIMENSION (nloc), INTENT (OUT) :: wd ! gust 3519 REAL, DIMENSION (nloc), INTENT (OUT) :: cbmf 3520 3521 !local variables: 3522 INTEGER :: i, k, il, n, j, num1 3523 REAL :: rat, delti 3524 REAL :: ax, bx, cx, dx, ex 3525 REAL :: cpinv, rdcp, dpinv 3526 REAL :: sigaq 3527 REAL, DIMENSION (nloc) :: awat 3528 REAL, DIMENSION (nloc, nd) :: lvcp, lfcp ! , mke ! unused . jyg 3529 REAL, DIMENSION (nloc) :: am, work, ad, amp1 3530 !! real up1(nloc), dn1(nloc) 3531 REAL, DIMENSION (nloc, nd, nd) :: up1, dn1 3532 !jyg< 3533 REAL, DIMENSION (nloc, nd) :: up_to, up_from 3534 REAL, DIMENSION (nloc, nd) :: dn_to, dn_from 3535 !>jyg 3536 REAL, DIMENSION (nloc) :: asum, bsum, csum, dsum 3537 REAL, DIMENSION (nloc) :: esum, fsum, gsum, hsum 3538 REAL, DIMENSION (nloc, nd) :: th_wake 3539 REAL, DIMENSION (nloc) :: alpha_qpos, alpha_qpos1 3540 REAL, DIMENSION (nloc, nd) :: qcond, nqcond, wa ! cld 3541 REAL, DIMENSION (nloc, nd) :: siga, sax, mac ! cld 3542 REAL, DIMENSION (nloc) :: sument 3543 REAL, DIMENSION (nloc, nd) :: sigment, qtment ! cld 3544 REAL, DIMENSION (nloc, nd, nd) :: qdet 3545 REAL sumdq !jyg 3546 3547 ! ------------------------------------------------------------- 3548 3549 ! initialization: 3550 3551 delti = 1.0/delt 3552 ! PRINT*,'cv3_yield initialisation delt', delt 3433 !inputs: 3434 INTEGER, INTENT (IN) :: iflag_mix 3435 INTEGER, INTENT (IN) :: ncum, nd, na, ntra, nloc 3436 LOGICAL, INTENT (IN) :: ok_conserv_q 3437 INTEGER, DIMENSION (nloc), INTENT (IN) :: icb, inb 3438 REAL, INTENT (IN) :: delt 3439 REAL, DIMENSION (nloc, nd), INTENT (IN) :: t, rr, u, v 3440 REAL, DIMENSION (nloc, nd), INTENT (IN) :: t_wake, rr_wake 3441 REAL, DIMENSION (nloc), INTENT (IN) :: s_wake 3442 REAL, DIMENSION (nloc, nd, ntra), INTENT (IN) :: tra 3443 REAL, DIMENSION (nloc, nd), INTENT (IN) :: p 3444 REAL, DIMENSION (nloc, nd + 1), INTENT (IN) :: ph 3445 REAL, DIMENSION (nloc, na), INTENT (IN) :: gz, h, hp 3446 REAL, DIMENSION (nloc, na), INTENT (IN) :: th, tp 3447 REAL, DIMENSION (nloc, na), INTENT (IN) :: lv, cpn, ep, clw 3448 REAL, DIMENSION (nloc, na), INTENT (IN) :: lf 3449 REAL, DIMENSION (nloc, na), INTENT (IN) :: rp, up 3450 REAL, DIMENSION (nloc, na), INTENT (IN) :: vp 3451 REAL, DIMENSION (nloc, nd), INTENT (IN) :: wt 3452 REAL, DIMENSION (nloc, nd, ntra), INTENT (IN) :: trap 3453 REAL, DIMENSION (nloc, na), INTENT (IN) :: water, evap, b 3454 REAL, DIMENSION (nloc, na), INTENT (IN) :: fondue, faci, ice 3455 REAL, DIMENSION (nloc, na, na), INTENT (IN) :: qent, uent 3456 REAL, DIMENSION (nloc, na, na), INTENT (IN) :: hent 3457 REAL, DIMENSION (nloc, na, na), INTENT (IN) :: vent, elij 3458 INTEGER, DIMENSION (nloc, nd), INTENT (IN) :: nent 3459 REAL, DIMENSION (nloc, na, na, ntra), INTENT (IN) :: traent 3460 REAL, DIMENSION (nloc, nd), INTENT (IN) :: tv, tvp, wghti 3461 REAL, DIMENSION (nloc, nd), INTENT (IN) :: qta 3462 REAL, DIMENSION (nloc, na), INTENT(IN) :: qpreca 3463 REAL, INTENT(IN) :: tau_cld_cv, coefw_cld_cv 3464 3465 !input/output: 3466 REAL, DIMENSION (nloc, na), INTENT (INOUT) :: m, mp 3467 REAL, DIMENSION (nloc, na, na), INTENT (INOUT) :: ment 3468 INTEGER, DIMENSION (nloc), INTENT (INOUT) :: iflag 3469 REAL, DIMENSION (nloc, nd), INTENT (INOUT) :: sig 3470 REAL, DIMENSION (nloc), INTENT (INOUT) :: sigd 3471 3472 !outputs: 3473 REAL, DIMENSION (nloc), INTENT (OUT) :: precip 3474 REAL, DIMENSION (nloc, nd), INTENT (OUT) :: ft, fr, fu, fv, fr_comp 3475 REAL, DIMENSION (nloc, nd), INTENT (OUT) :: ftd, fqd 3476 REAL, DIMENSION (nloc, nd, ntra), INTENT (OUT) :: ftra 3477 REAL, DIMENSION (nloc, nd), INTENT (OUT) :: upwd, dnwd, ma 3478 REAL, DIMENSION (nloc, nd), INTENT (OUT) :: dnwd0, mip 3479 REAL, DIMENSION (nloc, nd + 1), INTENT (OUT) :: Vprecip 3480 REAL, DIMENSION (nloc, nd + 1), INTENT (OUT) :: Vprecipi 3481 !! REAL tls(nloc, nd), tps(nloc, nd) ! useless . jyg 3482 REAL, DIMENSION (nloc, nd), INTENT (OUT) :: qcondc ! cld 3483 REAL, DIMENSION (nloc, nd), INTENT (OUT) :: qtc, sigt ! cld 3484 REAL, DIMENSION (nloc, nd), INTENT (OUT) :: detrain ! Louis : pour le calcul de Klein du terme de variance qui détraine dans lenvironnement 3485 REAL, DIMENSION (nloc), INTENT (OUT) :: wd ! gust 3486 REAL, DIMENSION (nloc), INTENT (OUT) :: cbmf 3487 3488 !local variables: 3489 INTEGER :: i, k, il, n, j, num1 3490 REAL :: rat, delti 3491 REAL :: ax, bx, cx, dx, ex 3492 REAL :: cpinv, rdcp, dpinv 3493 REAL :: sigaq 3494 REAL, DIMENSION (nloc) :: awat 3495 REAL, DIMENSION (nloc, nd) :: lvcp, lfcp ! , mke ! unused . jyg 3496 REAL, DIMENSION (nloc) :: am, work, ad, amp1 3497 !! real up1(nloc), dn1(nloc) 3498 REAL, DIMENSION (nloc, nd, nd) :: up1, dn1 3499 !jyg< 3500 REAL, DIMENSION (nloc, nd) :: up_to, up_from 3501 REAL, DIMENSION (nloc, nd) :: dn_to, dn_from 3502 !>jyg 3503 REAL, DIMENSION (nloc) :: asum, bsum, csum, dsum 3504 REAL, DIMENSION (nloc) :: esum, fsum, gsum, hsum 3505 REAL, DIMENSION (nloc, nd) :: th_wake 3506 REAL, DIMENSION (nloc) :: alpha_qpos, alpha_qpos1 3507 REAL, DIMENSION (nloc, nd) :: qcond, nqcond, wa ! cld 3508 REAL, DIMENSION (nloc, nd) :: siga, sax, mac ! cld 3509 REAL, DIMENSION (nloc) :: sument 3510 REAL, DIMENSION (nloc, nd) :: sigment, qtment ! cld 3511 REAL, DIMENSION (nloc, nd, nd) :: qdet 3512 REAL sumdq !jyg 3513 3514 ! ------------------------------------------------------------- 3515 3516 ! initialization: 3517 3518 delti = 1.0 / delt 3519 ! PRINT*,'cv3_yield initialisation delt', delt 3553 3520 3554 3521 DO il = 1, ncum … … 3557 3524 END DO 3558 3525 3559 ! Fluxes are on a staggered grid : loops extend up to nl+13526 ! Fluxes are on a staggered grid : loops extend up to nl+1 3560 3527 DO i = 1, nlp 3561 3528 DO il = 1, ncum … … 3572 3539 ft(il, i) = 0.0 3573 3540 fr(il, i) = 0.0 3574 fr_comp(il, i) = 0.03541 fr_comp(il, i) = 0.0 3575 3542 fu(il, i) = 0.0 3576 3543 fv(il, i) = 0.0 … … 3583 3550 sigment(il, i) = 0.0 ! cld 3584 3551 sigt(il, i) = 0.0 ! cld 3585 qdet(il, i,:) = 0.0 ! cld3552 qdet(il, i, :) = 0.0 ! cld 3586 3553 detrain(il, i) = 0.0 ! cld 3587 3554 nqcond(il, i) = 0.0 ! cld 3588 3555 END DO 3589 3556 END DO 3590 ! PRINT*,'cv3_yield initialisation 2'3591 !AC! do j=1,ntra3592 !AC! do i=1,nd3593 !AC! do il=1,ncum3594 !AC! ftra(il,i,j)=0.03595 !AC! enddo3596 !AC! enddo3597 !AC! enddo3598 ! PRINT*,'cv3_yield initialisation 3'3557 ! PRINT*,'cv3_yield initialisation 2' 3558 !AC! do j=1,ntra 3559 !AC! do i=1,nd 3560 !AC! do il=1,ncum 3561 !AC! ftra(il,i,j)=0.0 3562 !AC! enddo 3563 !AC! enddo 3564 !AC! enddo 3565 ! PRINT*,'cv3_yield initialisation 3' 3599 3566 DO i = 1, nl 3600 3567 DO il = 1, ncum 3601 lvcp(il, i) = lv(il, i) /cpn(il, i)3602 lfcp(il, i) = lf(il, i) /cpn(il, i)3603 END DO 3604 END DO 3605 3606 3607 3608 ! *** calculate surface precipitation in mm/day ***3568 lvcp(il, i) = lv(il, i) / cpn(il, i) 3569 lfcp(il, i) = lf(il, i) / cpn(il, i) 3570 END DO 3571 END DO 3572 3573 3574 3575 ! *** calculate surface precipitation in mm/day *** 3609 3576 3610 3577 DO il = 1, ncum 3611 IF (ep(il, inb(il))>=0.0001 .AND. iflag(il)<=1) THEN3578 IF (ep(il, inb(il))>=0.0001 .AND. iflag(il)<=1) THEN 3612 3579 IF (cvflag_ice) THEN 3613 precip(il) = wt(il, 1) *sigd(il)*(water(il,1)+ice(il,1)) &3614 *86400.*1000./(rowl*grav)3580 precip(il) = wt(il, 1) * sigd(il) * (water(il, 1) + ice(il, 1)) & 3581 * 86400. * 1000. / (rowl * grav) 3615 3582 ELSE 3616 precip(il) = wt(il, 1) *sigd(il)*water(il, 1) &3617 *86400.*1000./(rowl*grav)3583 precip(il) = wt(il, 1) * sigd(il) * water(il, 1) & 3584 * 86400. * 1000. / (rowl * grav) 3618 3585 END IF 3619 3586 END IF 3620 3587 END DO 3621 ! PRINT*,'cv3_yield apres calcul precip'3622 3623 3624 ! === calculate vertical profile of precipitation in kg/m2/s ===3588 ! PRINT*,'cv3_yield apres calcul precip' 3589 3590 3591 ! === calculate vertical profile of precipitation in kg/m2/s === 3625 3592 3626 3593 DO i = 1, nl 3627 3594 DO il = 1, ncum 3628 IF (ep(il, inb(il))>=0.0001 .AND. i<=inb(il) .AND. iflag(il)<=1) THEN3595 IF (ep(il, inb(il))>=0.0001 .AND. i<=inb(il) .AND. iflag(il)<=1) THEN 3629 3596 IF (cvflag_ice) THEN 3630 Vprecip(il, i) = wt(il, i) *sigd(il)*(water(il,i)+ice(il,i))/grav3631 Vprecipi(il, i) = wt(il, i) *sigd(il)*ice(il,i)/grav ! jyg3597 Vprecip(il, i) = wt(il, i) * sigd(il) * (water(il, i) + ice(il, i)) / grav 3598 Vprecipi(il, i) = wt(il, i) * sigd(il) * ice(il, i) / grav ! jyg 3632 3599 ELSE 3633 Vprecip(il, i) = wt(il, i) *sigd(il)*water(il, i)/grav3600 Vprecip(il, i) = wt(il, i) * sigd(il) * water(il, i) / grav 3634 3601 Vprecipi(il, i) = 0. ! jyg 3635 3602 END IF … … 3639 3606 3640 3607 3641 ! *** Calculate downdraft velocity scale ***3642 ! *** NE PAS UTILISER POUR L'INSTANT ***3643 3644 !! do il=1,ncum3645 !! wd(il)=betad*abs(mp(il,icb(il)))*0.01*rrd*t(il,icb(il)) &3646 !! /(sigd(il)*p(il,icb(il)))3647 !! enddo3648 3649 3650 ! *** calculate tendencies of lowest level potential temperature ***3651 ! *** and mixing ratio ***3608 ! *** Calculate downdraft velocity scale *** 3609 ! *** NE PAS UTILISER POUR L'INSTANT *** 3610 3611 !! do il=1,ncum 3612 !! wd(il)=betad*abs(mp(il,icb(il)))*0.01*rrd*t(il,icb(il)) & 3613 !! /(sigd(il)*p(il,icb(il))) 3614 !! enddo 3615 3616 3617 ! *** calculate tendencies of lowest level potential temperature *** 3618 ! *** and mixing ratio *** 3652 3619 3653 3620 DO il = 1, ncum 3654 work(il) = 1.0 /(ph(il,1)-ph(il,2))3621 work(il) = 1.0 / (ph(il, 1) - ph(il, 2)) 3655 3622 cbmf(il) = 0.0 3656 3623 END DO 3657 3624 3658 ! - Adiabatic ascent mass flux "ma" and cloud base mass flux "cbmf"3659 !-----------------------------------------------------------------3660 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!3625 ! - Adiabatic ascent mass flux "ma" and cloud base mass flux "cbmf" 3626 !----------------------------------------------------------------- 3627 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 3661 3628 IF (adiab_ascent_mass_flux_depends_on_ejectliq) THEN 3662 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 3663 !!! Warning : this option leads to water conservation violation 3664 !!! Expert only 3665 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 3629 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 3630 !!! Warning : this option leads to water conservation violation 3631 !!! Expert only 3632 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 3633 DO il = 1, ncum 3634 ma(il, nlp) = 0. 3635 ma(il, 1) = 0. 3636 END DO 3637 DO k = nl, 2, -1 3638 DO il = 1, ncum 3639 ma(il, k) = ma(il, k + 1) * (1. - qta(il, k)) / (1. - qta(il, k - 1)) + m(il, k) 3640 cbmf(il) = max(cbmf(il), ma(il, k)) 3641 END DO 3642 END DO 3643 DO k = 2, nl 3644 DO il = 1, ncum 3645 IF (k <icb(il)) THEN 3646 ma(il, k) = ma(il, k - 1) + wghti(il, k - 1) * cbmf(il) 3647 ENDIF 3648 END DO 3649 END DO 3650 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 3651 ELSE ! (adiab_ascent_mass_flux_depends_on_ejectliq) 3652 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 3653 !! Line kept for compatibility with earlier versions 3654 DO k = 2, nl 3655 DO il = 1, ncum 3656 IF (k>=icb(il)) THEN 3657 cbmf(il) = cbmf(il) + m(il, k) 3658 END IF 3659 END DO 3660 END DO 3661 3662 DO il = 1, ncum 3663 ma(il, nlp) = 0. 3664 ma(il, 1) = 0. 3665 END DO 3666 DO k = nl, 2, -1 3667 DO il = 1, ncum 3668 ma(il, k) = ma(il, k + 1) + m(il, k) 3669 END DO 3670 END DO 3671 DO k = 2, nl 3672 DO il = 1, ncum 3673 IF (k <icb(il)) THEN 3674 ma(il, k) = ma(il, k - 1) + wghti(il, k - 1) * cbmf(il) 3675 ENDIF 3676 END DO 3677 END DO 3678 3679 ENDIF ! (adiab_ascent_mass_flux_depends_on_ejectliq) ELSE 3680 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 3681 3682 ! PRINT*,'cv3_yield avant ft' 3683 ! am is the part of cbmf taken from the first level 3666 3684 DO il = 1, ncum 3667 ma(il, nlp) = 0. 3668 ma(il, 1) = 0. 3669 END DO 3670 DO k = nl, 2, -1 3671 DO il = 1, ncum 3672 ma(il, k) = ma(il, k+1)*(1.-qta(il, k))/(1.-qta(il, k-1)) + m(il, k) 3673 cbmf(il) = max(cbmf(il), ma(il,k)) 3674 END DO 3675 END DO 3676 DO k = 2,nl 3677 DO il = 1, ncum 3678 IF (k <icb(il)) THEN 3679 ma(il, k) = ma(il, k-1) + wghti(il,k-1)*cbmf(il) 3680 ENDIF 3681 END DO 3682 END DO 3683 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 3684 ELSE ! (adiab_ascent_mass_flux_depends_on_ejectliq) 3685 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 3686 !! Line kept for compatibility with earlier versions 3687 DO k = 2, nl 3688 DO il = 1, ncum 3689 IF (k>=icb(il)) THEN 3690 cbmf(il) = cbmf(il) + m(il, k) 3691 END IF 3692 END DO 3693 END DO 3694 3695 DO il = 1, ncum 3696 ma(il, nlp) = 0. 3697 ma(il, 1) = 0. 3698 END DO 3699 DO k = nl, 2, -1 3700 DO il = 1, ncum 3701 ma(il, k) = ma(il, k+1) + m(il, k) 3702 END DO 3703 END DO 3704 DO k = 2,nl 3705 DO il = 1, ncum 3706 IF (k <icb(il)) THEN 3707 ma(il, k) = ma(il, k-1) + wghti(il,k-1)*cbmf(il) 3708 ENDIF 3709 END DO 3710 END DO 3711 3712 ENDIF ! (adiab_ascent_mass_flux_depends_on_ejectliq) ELSE 3713 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 3714 3715 ! PRINT*,'cv3_yield avant ft' 3716 ! am is the part of cbmf taken from the first level 3717 DO il = 1, ncum 3718 am(il) = cbmf(il)*wghti(il, 1) 3685 am(il) = cbmf(il) * wghti(il, 1) 3719 3686 END DO 3720 3687 3721 3688 DO il = 1, ncum 3722 3689 IF (iflag(il)<=1) THEN 3723 ! convect3 if((0.1*dpinv*am).ge.delti)iflag(il)=43724 !JYG Correction pour conserver l'eau3725 ! cc ft(il,1)=-0.5*lvcp(il,1)*sigd(il)*(evap(il,1)+evap(il,2)) !precip3690 ! convect3 if((0.1*dpinv*am).ge.delti)iflag(il)=4 3691 !JYG Correction pour conserver l'eau 3692 ! cc ft(il,1)=-0.5*lvcp(il,1)*sigd(il)*(evap(il,1)+evap(il,2)) !precip 3726 3693 IF (cvflag_ice) THEN 3727 ft(il, 1) = -lvcp(il, 1) *sigd(il)*evap(il, 1) - &3728 lfcp(il, 1)*sigd(il)*evap(il, 1)*faci(il, 1) - &3729 lfcp(il, 1)*sigd(il)*(fondue(il,1)*wt(il,1)) / &3730 (100.*(ph(il,1)-ph(il,2))) !precip3694 ft(il, 1) = -lvcp(il, 1) * sigd(il) * evap(il, 1) - & 3695 lfcp(il, 1) * sigd(il) * evap(il, 1) * faci(il, 1) - & 3696 lfcp(il, 1) * sigd(il) * (fondue(il, 1) * wt(il, 1)) / & 3697 (100. * (ph(il, 1) - ph(il, 2))) !precip 3731 3698 ELSE 3732 ft(il, 1) = -lvcp(il, 1) *sigd(il)*evap(il, 1)3699 ft(il, 1) = -lvcp(il, 1) * sigd(il) * evap(il, 1) 3733 3700 END IF 3734 3701 3735 ft(il, 1) = ft(il, 1) - 0.009 *grav*sigd(il)*mp(il, 2)*t_wake(il, 1)*b(il, 1)*work(il)3702 ft(il, 1) = ft(il, 1) - 0.009 * grav * sigd(il) * mp(il, 2) * t_wake(il, 1) * b(il, 1) * work(il) 3736 3703 3737 3704 IF (cvflag_ice) THEN 3738 ft(il, 1) = ft(il, 1) + 0.01 *sigd(il)*wt(il, 1)*(cl-cpd)*water(il, 2) * &3739 (t_wake(il,2)-t_wake(il,1))*work(il)/cpn(il, 1) + &3740 0.01*sigd(il)*wt(il, 1)*(ci-cpd)*ice(il, 2) * &3741 (t_wake(il,2)-t_wake(il,1))*work(il)/cpn(il, 1)3705 ft(il, 1) = ft(il, 1) + 0.01 * sigd(il) * wt(il, 1) * (cl - cpd) * water(il, 2) * & 3706 (t_wake(il, 2) - t_wake(il, 1)) * work(il) / cpn(il, 1) + & 3707 0.01 * sigd(il) * wt(il, 1) * (ci - cpd) * ice(il, 2) * & 3708 (t_wake(il, 2) - t_wake(il, 1)) * work(il) / cpn(il, 1) 3742 3709 ELSE 3743 ft(il, 1) = ft(il, 1) + 0.01 *sigd(il)*wt(il, 1)*(cl-cpd)*water(il, 2) * &3744 (t_wake(il,2)-t_wake(il,1))*work(il)/cpn(il, 1)3710 ft(il, 1) = ft(il, 1) + 0.01 * sigd(il) * wt(il, 1) * (cl - cpd) * water(il, 2) * & 3711 (t_wake(il, 2) - t_wake(il, 1)) * work(il) / cpn(il, 1) 3745 3712 END IF 3746 3713 3747 3714 ftd(il, 1) = ft(il, 1) ! fin precip 3748 3715 3749 IF ((0.01 *grav*work(il)*am(il))>=delti) iflag(il) = 1 !consist vect3750 !jyg<3751 3752 ft(il, 1) = ft(il, 1) + 0.01*grav*work(il)*am(il) * &3753 ((t(il,2)-t(il,1))*cpn(il,2)+gz(il,2)-gz(il,1))/cpn(il,1)3754 3755 ft(il, 1) = ft(il, 1) + 0.01*grav*work(il)*am(il) * &3756 (t(il,2)-t(il,1)+(gz(il,2)-gz(il,1))/cpn(il,1))3757 3758 !>jyg3716 IF ((0.01 * grav * work(il) * am(il))>=delti) iflag(il) = 1 !consist vect 3717 !jyg< 3718 IF (fl_cor_ebil >= 2) THEN 3719 ft(il, 1) = ft(il, 1) + 0.01 * grav * work(il) * am(il) * & 3720 ((t(il, 2) - t(il, 1)) * cpn(il, 2) + gz(il, 2) - gz(il, 1)) / cpn(il, 1) 3721 ELSE 3722 ft(il, 1) = ft(il, 1) + 0.01 * grav * work(il) * am(il) * & 3723 (t(il, 2) - t(il, 1) + (gz(il, 2) - gz(il, 1)) / cpn(il, 1)) 3724 ENDIF 3725 !>jyg 3759 3726 END IF ! iflag 3760 3727 END DO 3761 3762 3728 3763 3729 DO j = 2, nl 3764 3730 IF (iflag_mix>0) THEN 3765 3731 DO il = 1, ncum 3766 ! FH WARNING a modifier :3732 ! FH WARNING a modifier : 3767 3733 cpinv = 0. 3768 ! cpinv=1.0/cpn(il,1)3734 ! cpinv=1.0/cpn(il,1) 3769 3735 IF (j<=inb(il) .AND. iflag(il)<=1) THEN 3770 ft(il, 1) = ft(il, 1) + 0.01 *grav*work(il)*ment(il, j, 1) * &3771 (hent(il,j,1)-h(il,1)+t(il,1)*(cpv-cpd)*(rr(il,1)-qent(il,j,1)))*cpinv3736 ft(il, 1) = ft(il, 1) + 0.01 * grav * work(il) * ment(il, j, 1) * & 3737 (hent(il, j, 1) - h(il, 1) + t(il, 1) * (cpv - cpd) * (rr(il, 1) - qent(il, j, 1))) * cpinv 3772 3738 END IF ! j 3773 3739 END DO 3774 3740 END IF 3775 3741 END DO 3776 ! fin sature 3777 3742 ! fin sature 3778 3743 3779 3744 DO il = 1, ncum 3780 3745 IF (iflag(il)<=1) THEN 3781 !JYG1 Correction pour mieux conserver l'eau (conformite avec CONVECT4.3)3782 fr(il, 1) = 0.01 *grav*mp(il, 2)*(rp(il,2)-rr_wake(il,1))*work(il) + &3783 sigd(il)*evap(il, 1)3784 !!! sigd(il)*0.5*(evap(il,1)+evap(il,2))3746 !JYG1 Correction pour mieux conserver l'eau (conformite avec CONVECT4.3) 3747 fr(il, 1) = 0.01 * grav * mp(il, 2) * (rp(il, 2) - rr_wake(il, 1)) * work(il) + & 3748 sigd(il) * evap(il, 1) 3749 !!! sigd(il)*0.5*(evap(il,1)+evap(il,2)) 3785 3750 3786 3751 fqd(il, 1) = fr(il, 1) !precip 3787 3752 3788 fr(il, 1) = fr(il, 1) + 0.01 *grav*am(il)*(rr(il,2)-rr(il,1))*work(il) !sature3789 3790 fu(il, 1) = fu(il, 1) + 0.01 *grav*work(il)*(mp(il,2)*(up(il,2)-u(il,1)) + &3791 am(il)*(u(il,2)-u(il,1)))3792 fv(il, 1) = fv(il, 1) + 0.01 *grav*work(il)*(mp(il,2)*(vp(il,2)-v(il,1)) + &3793 am(il)*(v(il,2)-v(il,1)))3753 fr(il, 1) = fr(il, 1) + 0.01 * grav * am(il) * (rr(il, 2) - rr(il, 1)) * work(il) !sature 3754 3755 fu(il, 1) = fu(il, 1) + 0.01 * grav * work(il) * (mp(il, 2) * (up(il, 2) - u(il, 1)) + & 3756 am(il) * (u(il, 2) - u(il, 1))) 3757 fv(il, 1) = fv(il, 1) + 0.01 * grav * work(il) * (mp(il, 2) * (vp(il, 2) - v(il, 1)) + & 3758 am(il) * (v(il, 2) - v(il, 1))) 3794 3759 END IF ! iflag 3795 3760 END DO ! il 3796 3761 3797 3762 3798 !AC! do j=1,ntra3799 !AC! do il=1,ncum3800 !AC! if (iflag(il) .le. 1) THEN3801 !AC! if (cvflag_grav) THEN3802 !AC! ftra(il,1,j)=ftra(il,1,j)+0.01*grav*work(il)3803 !AC! : *(mp(il,2)*(trap(il,2,j)-tra(il,1,j))3804 !AC! : +am(il)*(tra(il,2,j)-tra(il,1,j)))3805 !AC! else3806 !AC! ftra(il,1,j)=ftra(il,1,j)+0.1*work(il)3807 !AC! : *(mp(il,2)*(trap(il,2,j)-tra(il,1,j))3808 !AC! : +am(il)*(tra(il,2,j)-tra(il,1,j)))3809 !AC! endif3810 !AC! endif ! iflag3811 !AC! enddo3812 !AC! enddo3763 !AC! do j=1,ntra 3764 !AC! do il=1,ncum 3765 !AC! if (iflag(il) .le. 1) THEN 3766 !AC! if (cvflag_grav) THEN 3767 !AC! ftra(il,1,j)=ftra(il,1,j)+0.01*grav*work(il) 3768 !AC! : *(mp(il,2)*(trap(il,2,j)-tra(il,1,j)) 3769 !AC! : +am(il)*(tra(il,2,j)-tra(il,1,j))) 3770 !AC! else 3771 !AC! ftra(il,1,j)=ftra(il,1,j)+0.1*work(il) 3772 !AC! : *(mp(il,2)*(trap(il,2,j)-tra(il,1,j)) 3773 !AC! : +am(il)*(tra(il,2,j)-tra(il,1,j))) 3774 !AC! endif 3775 !AC! endif ! iflag 3776 !AC! enddo 3777 !AC! enddo 3813 3778 3814 3779 DO j = 2, nl 3815 3780 DO il = 1, ncum 3816 3781 IF (j<=inb(il) .AND. iflag(il)<=1) THEN 3817 fr(il, 1) = fr(il, 1) + 0.01 *grav*work(il)*ment(il, j, 1)*(qent(il,j,1)-rr(il,1))3818 fr_comp(il, 1) = fr_comp(il,1) + 0.01*grav*work(il)*ment(il, j, 1)*(qent(il,j,1)-rr(il,1))3819 fu(il, 1) = fu(il, 1) + 0.01 *grav*work(il)*ment(il, j, 1)*(uent(il,j,1)-u(il,1))3820 fv(il, 1) = fv(il, 1) + 0.01 *grav*work(il)*ment(il, j, 1)*(vent(il,j,1)-v(il,1))3782 fr(il, 1) = fr(il, 1) + 0.01 * grav * work(il) * ment(il, j, 1) * (qent(il, j, 1) - rr(il, 1)) 3783 fr_comp(il, 1) = fr_comp(il, 1) + 0.01 * grav * work(il) * ment(il, j, 1) * (qent(il, j, 1) - rr(il, 1)) 3784 fu(il, 1) = fu(il, 1) + 0.01 * grav * work(il) * ment(il, j, 1) * (uent(il, j, 1) - u(il, 1)) 3785 fv(il, 1) = fv(il, 1) + 0.01 * grav * work(il) * ment(il, j, 1) * (vent(il, j, 1) - v(il, 1)) 3821 3786 END IF ! j 3822 3787 END DO 3823 3788 END DO 3824 3789 3825 !AC! do k=1,ntra 3826 !AC! do j=2,nl 3827 !AC! do il=1,ncum 3828 !AC! if (j.le.inb(il) .AND. iflag(il) .le. 1) THEN 3829 !AC! 3830 !AC! if (cvflag_grav) THEN 3831 !AC! ftra(il,1,k)=ftra(il,1,k)+0.01*grav*work(il)*ment(il,j,1) 3832 !AC! : *(traent(il,j,1,k)-tra(il,1,k)) 3833 !AC! else 3834 !AC! ftra(il,1,k)=ftra(il,1,k)+0.1*work(il)*ment(il,j,1) 3835 !AC! : *(traent(il,j,1,k)-tra(il,1,k)) 3836 !AC! endif 3837 !AC! 3838 !AC! endif 3839 !AC! enddo 3840 !AC! enddo 3841 !AC! enddo 3842 ! PRINT*,'cv3_yield apres ft' 3843 3844 !jyg< 3845 !----------------------------------------------------------- 3846 IF (ok_optim_yield) THEN !| 3847 !----------------------------------------------------------- 3848 3849 !*** *** 3850 !*** Compute convective mass fluxes upwd and dnwd *** 3851 3852 ! ================================================= 3853 ! upward fluxes | 3854 ! ------------------------------------------------ 3855 3856 upwd(:,:) = 0. 3857 up_to(:,:) = 0. 3858 up_from(:,:) = 0. 3859 3860 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 3861 IF (adiab_ascent_mass_flux_depends_on_ejectliq) THEN 3862 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 3863 !! The decrease of the adiabatic ascent mass flux due to ejection of precipitation 3864 !! is taken into account. 3865 !! WARNING : in the present version, taking into account the mass-flux decrease due to 3866 !! precipitation ejection leads to water conservation violation. 3867 3868 ! - Upward mass flux of mixed draughts 3869 !--------------------------------------- 3870 DO i = 2, nl 3871 DO j = 1, i-1 3872 DO il = 1, ncum 3873 IF (i<=inb(il)) THEN 3874 up_to(il,i) = up_to(il,i) + ment(il,j,i) 3875 ENDIF 3790 !AC! do k=1,ntra 3791 !AC! do j=2,nl 3792 !AC! do il=1,ncum 3793 !AC! if (j.le.inb(il) .AND. iflag(il) .le. 1) THEN 3794 !AC! 3795 !AC! if (cvflag_grav) THEN 3796 !AC! ftra(il,1,k)=ftra(il,1,k)+0.01*grav*work(il)*ment(il,j,1) 3797 !AC! : *(traent(il,j,1,k)-tra(il,1,k)) 3798 !AC! else 3799 !AC! ftra(il,1,k)=ftra(il,1,k)+0.1*work(il)*ment(il,j,1) 3800 !AC! : *(traent(il,j,1,k)-tra(il,1,k)) 3801 !AC! endif 3802 !AC! 3803 !AC! endif 3804 !AC! enddo 3805 !AC! enddo 3806 !AC! enddo 3807 ! PRINT*,'cv3_yield apres ft' 3808 3809 !jyg< 3810 !----------------------------------------------------------- 3811 IF (ok_optim_yield) THEN !| 3812 !----------------------------------------------------------- 3813 3814 !*** *** 3815 !*** Compute convective mass fluxes upwd and dnwd *** 3816 3817 ! ================================================= 3818 ! upward fluxes | 3819 ! ------------------------------------------------ 3820 3821 upwd(:, :) = 0. 3822 up_to(:, :) = 0. 3823 up_from(:, :) = 0. 3824 3825 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 3826 IF (adiab_ascent_mass_flux_depends_on_ejectliq) THEN 3827 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 3828 !! The decrease of the adiabatic ascent mass flux due to ejection of precipitation 3829 !! is taken into account. 3830 !! WARNING : in the present version, taking into account the mass-flux decrease due to 3831 !! precipitation ejection leads to water conservation violation. 3832 3833 ! - Upward mass flux of mixed draughts 3834 !--------------------------------------- 3835 DO i = 2, nl 3836 DO j = 1, i - 1 3837 DO il = 1, ncum 3838 IF (i<=inb(il)) THEN 3839 up_to(il, i) = up_to(il, i) + ment(il, j, i) 3840 ENDIF 3841 ENDDO 3842 ENDDO 3843 ENDDO 3844 3845 DO j = 3, nl 3846 DO i = 2, j - 1 3847 DO il = 1, ncum 3848 IF (j<=inb(il)) THEN 3849 up_from(il, i) = up_from(il, i) + ment(il, i, j) 3850 ENDIF 3851 ENDDO 3852 ENDDO 3853 ENDDO 3854 3855 ! The difference between upwd(il,i) and upwd(il,i-1) is due to updrafts ending in layer 3856 !(i-1) (theses drafts cross interface (i-1) but not interface(i)) and to updrafts starting 3857 !from layer (i-1) (theses drafts cross interface (i) but not interface(i-1)): 3858 3859 DO i = 2, nlp 3860 DO il = 1, ncum 3861 IF (i<=inb(il) + 1) THEN 3862 upwd(il, i) = max(0., upwd(il, i - 1) - up_to(il, i - 1) + up_from(il, i - 1)) 3863 ENDIF 3864 ENDDO 3865 ENDDO 3866 3867 ! - Total upward mass flux 3868 !--------------------------- 3869 DO i = 2, nlp 3870 DO il = 1, ncum 3871 IF (i<=inb(il) + 1) THEN 3872 upwd(il, i) = upwd(il, i) + ma(il, i) 3873 ENDIF 3874 ENDDO 3875 ENDDO 3876 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 3877 ELSE ! (adiab_ascent_mass_flux_depends_on_ejectliq) 3878 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 3879 !! The decrease of the adiabatic ascent mass flux due to ejection of precipitation 3880 !! is not taken into account. 3881 3882 ! - Upward mass flux 3883 !------------------- 3884 DO i = 2, nl 3885 DO il = 1, ncum 3886 IF (i<=inb(il)) THEN 3887 up_to(il, i) = m(il, i) 3888 ENDIF 3889 ENDDO 3890 DO j = 1, i - 1 3891 DO il = 1, ncum 3892 IF (i<=inb(il)) THEN 3893 up_to(il, i) = up_to(il, i) + ment(il, j, i) 3894 ENDIF 3895 ENDDO 3896 ENDDO 3897 ENDDO 3898 3899 DO i = 1, nl 3900 DO il = 1, ncum 3901 IF (i<=inb(il)) THEN 3902 up_from(il, i) = cbmf(il) * wghti(il, i) 3903 ENDIF 3904 ENDDO 3905 ENDDO 3906 3907 DO j = 3, nl 3908 DO i = 2, j - 1 3909 DO il = 1, ncum 3910 IF (j<=inb(il)) THEN 3911 up_from(il, i) = up_from(il, i) + ment(il, i, j) 3912 ENDIF 3913 ENDDO 3914 ENDDO 3915 ENDDO 3916 3917 ! The difference between upwd(il,i) and upwd(il,i-1) is due to updrafts ending in layer 3918 !(i-1) (theses drafts cross interface (i-1) but not interface(i)) and to updrafts starting 3919 !from layer (i-1) (theses drafts cross interface (i) but not interface(i-1)): 3920 3921 DO i = 2, nlp 3922 DO il = 1, ncum 3923 IF (i<=inb(il) + 1) THEN 3924 upwd(il, i) = max(0., upwd(il, i - 1) - up_to(il, i - 1) + up_from(il, i - 1)) 3925 ENDIF 3926 ENDDO 3927 ENDDO 3928 3929 ENDIF ! (adiab_ascent_mass_flux_depends_on_ejectliq) ELSE 3930 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 3931 3932 ! ================================================= 3933 ! downward fluxes | 3934 ! ------------------------------------------------ 3935 dnwd(:, :) = 0. 3936 dn_to(:, :) = 0. 3937 dn_from(:, :) = 0. 3938 DO i = 1, nl 3939 DO j = i + 1, nl 3940 DO il = 1, ncum 3941 IF (j<=inb(il)) THEN 3942 !! dn_to(il,i) = dn_to(il,i) + ment(il,j,i) !jyg,20220202 3943 dn_to(il, i) = dn_to(il, i) - ment(il, j, i) 3944 ENDIF 3945 ENDDO 3946 ENDDO 3876 3947 ENDDO 3877 ENDDO 3878 ENDDO 3879 3880 DO j = 3, nl 3881 DO i = 2, j-1 3882 DO il = 1, ncum 3883 IF (j<=inb(il)) THEN 3884 up_from(il,i) = up_from(il,i) + ment(il,i,j) 3885 ENDIF 3948 3949 DO j = 1, nl 3950 DO i = j + 1, nl 3951 DO il = 1, ncum 3952 IF (i<=inb(il)) THEN 3953 !! dn_from(il,i) = dn_from(il,i) + ment(il,i,j) !jyg,20220202 3954 dn_from(il, i) = dn_from(il, i) - ment(il, i, j) 3955 ENDIF 3956 ENDDO 3957 ENDDO 3886 3958 ENDDO 3887 ENDDO 3888 ENDDO 3889 3890 ! The difference between upwd(il,i) and upwd(il,i-1) is due to updrafts ending in layer 3891 !(i-1) (theses drafts cross interface (i-1) but not interface(i)) and to updrafts starting 3892 !from layer (i-1) (theses drafts cross interface (i) but not interface(i-1)): 3893 3894 DO i = 2, nlp 3895 DO il = 1, ncum 3896 IF (i<=inb(il)+1) THEN 3897 upwd(il,i) = max(0., upwd(il,i-1) - up_to(il,i-1) + up_from(il,i-1)) 3898 ENDIF 3899 ENDDO 3900 ENDDO 3901 3902 ! - Total upward mass flux 3903 !--------------------------- 3904 DO i = 2, nlp 3905 DO il = 1, ncum 3906 IF (i<=inb(il)+1) THEN 3907 upwd(il,i) = upwd(il,i) + ma(il,i) 3908 ENDIF 3909 ENDDO 3910 ENDDO 3911 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 3912 ELSE ! (adiab_ascent_mass_flux_depends_on_ejectliq) 3913 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 3914 !! The decrease of the adiabatic ascent mass flux due to ejection of precipitation 3915 !! is not taken into account. 3916 3917 ! - Upward mass flux 3918 !------------------- 3919 DO i = 2, nl 3920 DO il = 1, ncum 3921 IF (i<=inb(il)) THEN 3922 up_to(il,i) = m(il,i) 3923 ENDIF 3924 ENDDO 3925 DO j = 1, i-1 3926 DO il = 1, ncum 3927 IF (i<=inb(il)) THEN 3928 up_to(il,i) = up_to(il,i) + ment(il,j,i) 3929 ENDIF 3959 3960 ! The difference between dnwd(il,i) and dnwd(il,i+1) is due to downdrafts ending in layer 3961 !(i) (theses drafts cross interface (i+1) but not interface(i)) and to downdrafts 3962 !starting from layer (i) (theses drafts cross interface (i) but not interface(i+1)): 3963 3964 DO i = nl - 1, 1, -1 3965 DO il = 1, ncum 3966 !! dnwd(il,i) = max(0., dnwd(il,i+1) - dn_to(il,i) + dn_from(il,i)) !jyg,20220202 3967 dnwd(il, i) = min(0., dnwd(il, i + 1) - dn_to(il, i) + dn_from(il, i)) 3968 ENDDO 3930 3969 ENDDO 3931 ENDDO 3932 ENDDO 3933 3934 DO i = 1, nl 3935 DO il = 1, ncum 3936 IF (i<=inb(il)) THEN 3937 up_from(il,i) = cbmf(il)*wghti(il,i) 3938 ENDIF 3939 ENDDO 3940 ENDDO 3941 3942 DO j = 3, nl 3943 DO i = 2, j-1 3944 DO il = 1, ncum 3945 IF (j<=inb(il)) THEN 3946 up_from(il,i) = up_from(il,i) + ment(il,i,j) 3947 ENDIF 3948 ENDDO 3949 ENDDO 3950 ENDDO 3951 3952 ! The difference between upwd(il,i) and upwd(il,i-1) is due to updrafts ending in layer 3953 !(i-1) (theses drafts cross interface (i-1) but not interface(i)) and to updrafts starting 3954 !from layer (i-1) (theses drafts cross interface (i) but not interface(i-1)): 3955 3956 DO i = 2, nlp 3957 DO il = 1, ncum 3958 IF (i<=inb(il)+1) THEN 3959 upwd(il,i) = max(0., upwd(il,i-1) - up_to(il,i-1) + up_from(il,i-1)) 3960 ENDIF 3961 ENDDO 3962 ENDDO 3963 3964 3965 ENDIF ! (adiab_ascent_mass_flux_depends_on_ejectliq) ELSE 3966 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 3967 3968 ! ================================================= 3969 ! downward fluxes | 3970 ! ------------------------------------------------ 3971 dnwd(:,:) = 0. 3972 dn_to(:,:) = 0. 3973 dn_from(:,:) = 0. 3974 DO i = 1, nl 3975 DO j = i+1, nl 3976 DO il = 1, ncum 3977 IF (j<=inb(il)) THEN 3978 !! dn_to(il,i) = dn_to(il,i) + ment(il,j,i) !jyg,20220202 3979 dn_to(il,i) = dn_to(il,i) - ment(il,j,i) 3980 ENDIF 3981 ENDDO 3982 ENDDO 3983 ENDDO 3984 3985 DO j = 1, nl 3986 DO i = j+1, nl 3987 DO il = 1, ncum 3988 IF (i<=inb(il)) THEN 3989 !! dn_from(il,i) = dn_from(il,i) + ment(il,i,j) !jyg,20220202 3990 dn_from(il,i) = dn_from(il,i) - ment(il,i,j) 3991 ENDIF 3992 ENDDO 3993 ENDDO 3994 ENDDO 3995 3996 ! The difference between dnwd(il,i) and dnwd(il,i+1) is due to downdrafts ending in layer 3997 !(i) (theses drafts cross interface (i+1) but not interface(i)) and to downdrafts 3998 !starting from layer (i) (theses drafts cross interface (i) but not interface(i+1)): 3999 4000 DO i = nl-1, 1, -1 4001 DO il = 1, ncum 4002 !! dnwd(il,i) = max(0., dnwd(il,i+1) - dn_to(il,i) + dn_from(il,i)) !jyg,20220202 4003 dnwd(il,i) = min(0., dnwd(il,i+1) - dn_to(il,i) + dn_from(il,i)) 4004 ENDDO 4005 ENDDO 4006 ! ================================================= 4007 4008 !----------------------------------------------------------- 4009 ENDIF !(ok_optim_yield) !| 4010 !----------------------------------------------------------- 4011 !>jyg 4012 4013 ! *** calculate tendencies of potential temperature and mixing ratio *** 4014 ! *** at levels above the lowest level *** 4015 4016 ! *** first find the net saturated updraft and downdraft mass fluxes *** 4017 ! *** through each level *** 4018 4019 4020 !jyg< 4021 !! DO i = 2, nl + 1 ! newvecto: mettre nl au lieu nl+1? 3970 ! ================================================= 3971 3972 !----------------------------------------------------------- 3973 ENDIF !(ok_optim_yield) !| 3974 !----------------------------------------------------------- 3975 !>jyg 3976 3977 ! *** calculate tendencies of potential temperature and mixing ratio *** 3978 ! *** at levels above the lowest level *** 3979 3980 ! *** first find the net saturated updraft and downdraft mass fluxes *** 3981 ! *** through each level *** 3982 3983 3984 !jyg< 3985 !! DO i = 2, nl + 1 ! newvecto: mettre nl au lieu nl+1? 4022 3986 DO i = 2, nl 4023 !>jyg 3987 !>jyg 4024 3988 4025 3989 num1 = 0 … … 4029 3993 IF (num1<=0) GO TO 500 4030 3994 4031 !jyg< 4032 !----------------------------------------------------------- 4033 IF (ok_optim_yield) THEN !| 4034 !----------------------------------------------------------- 4035 DO il = 1, ncum 4036 amp1(il) = upwd(il,i+1) 4037 ad(il) = dnwd(il,i) 4038 ENDDO 4039 !----------------------------------------------------------- 4040 ELSE !(ok_optim_yield) !| 4041 !----------------------------------------------------------- 4042 !>jyg 4043 DO il = 1,ncum 4044 amp1(il) = 0. 4045 ad(il) = 0. 4046 ENDDO 4047 4048 DO k = 1, nl + 1 3995 !jyg< 3996 !----------------------------------------------------------- 3997 IF (ok_optim_yield) THEN !| 3998 !----------------------------------------------------------- 4049 3999 DO il = 1, ncum 4050 IF (i>=icb(il)) THEN 4051 IF (k>=i+1 .AND. k<=(inb(il)+1)) THEN 4052 amp1(il) = amp1(il) + m(il, k) 4053 END IF 4054 ELSE 4055 ! AMP1 is the part of cbmf taken from layers I and lower 4056 IF (k<=i) THEN 4057 amp1(il) = amp1(il) + cbmf(il)*wghti(il, k) 4058 END IF 4059 END IF 4060 END DO 4061 END DO 4062 4063 DO j = i + 1, nl + 1 4064 DO k = 1, i 4065 !yor! reverted j and k loops 4066 DO il = 1, ncum 4067 !yor! IF (i<=inb(il) .AND. j<=(inb(il)+1)) THEN ! the second condition implies the first ! 4068 IF (j<=(inb(il)+1)) THEN 4069 amp1(il) = amp1(il) + ment(il, k, j) 4070 END IF 4071 END DO 4072 END DO 4073 END DO 4074 4075 DO k = 1, i - 1 4076 !jyg< 4077 !! DO j = i, nl + 1 ! newvecto: nl au lieu nl+1? 4078 DO j = i, nl 4079 !>jyg 4000 amp1(il) = upwd(il, i + 1) 4001 ad(il) = dnwd(il, i) 4002 ENDDO 4003 !----------------------------------------------------------- 4004 ELSE !(ok_optim_yield) !| 4005 !----------------------------------------------------------- 4006 !>jyg 4007 DO il = 1, ncum 4008 amp1(il) = 0. 4009 ad(il) = 0. 4010 ENDDO 4011 4012 DO k = 1, nl + 1 4080 4013 DO il = 1, ncum 4081 !yor! IF (i<=inb(il) .AND. j<=inb(il)) THEN ! the second condition implies the 1st ! 4082 IF (j<=inb(il)) THEN 4083 ad(il) = ad(il) + ment(il, j, k) 4014 IF (i>=icb(il)) THEN 4015 IF (k>=i + 1 .AND. k<=(inb(il) + 1)) THEN 4016 amp1(il) = amp1(il) + m(il, k) 4017 END IF 4018 ELSE 4019 ! AMP1 is the part of cbmf taken from layers I and lower 4020 IF (k<=i) THEN 4021 amp1(il) = amp1(il) + cbmf(il) * wghti(il, k) 4022 END IF 4084 4023 END IF 4085 4024 END DO 4086 4025 END DO 4087 END DO 4088 4089 !----------------------------------------------------------- 4090 ENDIF !(ok_optim_yield) !| 4091 !----------------------------------------------------------- 4092 4093 !! print *,'yield, i, amp1, ad', i, amp1(1), ad(1) 4026 4027 DO j = i + 1, nl + 1 4028 DO k = 1, i 4029 !yor! reverted j and k loops 4030 DO il = 1, ncum 4031 !yor! IF (i<=inb(il) .AND. j<=(inb(il)+1)) THEN ! the second condition implies the first ! 4032 IF (j<=(inb(il) + 1)) THEN 4033 amp1(il) = amp1(il) + ment(il, k, j) 4034 END IF 4035 END DO 4036 END DO 4037 END DO 4038 4039 DO k = 1, i - 1 4040 !jyg< 4041 !! DO j = i, nl + 1 ! newvecto: nl au lieu nl+1? 4042 DO j = i, nl 4043 !>jyg 4044 DO il = 1, ncum 4045 !yor! IF (i<=inb(il) .AND. j<=inb(il)) THEN ! the second condition implies the 1st ! 4046 IF (j<=inb(il)) THEN 4047 ad(il) = ad(il) + ment(il, j, k) 4048 END IF 4049 END DO 4050 END DO 4051 END DO 4052 4053 !----------------------------------------------------------- 4054 ENDIF !(ok_optim_yield) !| 4055 !----------------------------------------------------------- 4056 4057 !! print *,'yield, i, amp1, ad', i, amp1(1), ad(1) 4094 4058 4095 4059 DO il = 1, ncum 4096 4060 IF (i<=inb(il) .AND. iflag(il)<=1) THEN 4097 dpinv = 1.0 /(ph(il,i)-ph(il,i+1))4098 cpinv = 1.0 /cpn(il, i)4099 4100 ! convect3 if((0.1*dpinv*amp1).ge.delti)iflag(il)=44101 IF ((0.01 *grav*dpinv*amp1(il))>=delti) iflag(il) = 1 ! vecto4102 4103 ! precip4104 ! cc ft(il,i)= -0.5*sigd(il)*lvcp(il,i)*(evap(il,i)+evap(il,i+1))4061 dpinv = 1.0 / (ph(il, i) - ph(il, i + 1)) 4062 cpinv = 1.0 / cpn(il, i) 4063 4064 ! convect3 if((0.1*dpinv*amp1).ge.delti)iflag(il)=4 4065 IF ((0.01 * grav * dpinv * amp1(il))>=delti) iflag(il) = 1 ! vecto 4066 4067 ! precip 4068 ! cc ft(il,i)= -0.5*sigd(il)*lvcp(il,i)*(evap(il,i)+evap(il,i+1)) 4105 4069 IF (cvflag_ice) THEN 4106 ft(il, i) = -sigd(il) *lvcp(il, i)*evap(il, i) - &4107 sigd(il)*lfcp(il, i)*evap(il, i)*faci(il, i) - &4108 sigd(il)*lfcp(il, i)*fondue(il, i)*wt(il, i)/(100.*(p(il,i-1)-p(il,i)))4070 ft(il, i) = -sigd(il) * lvcp(il, i) * evap(il, i) - & 4071 sigd(il) * lfcp(il, i) * evap(il, i) * faci(il, i) - & 4072 sigd(il) * lfcp(il, i) * fondue(il, i) * wt(il, i) / (100. * (p(il, i - 1) - p(il, i))) 4109 4073 ELSE 4110 ft(il, i) = -sigd(il) *lvcp(il, i)*evap(il, i)4074 ft(il, i) = -sigd(il) * lvcp(il, i) * evap(il, i) 4111 4075 END IF 4112 4076 4113 rat = cpn(il, i -1)*cpinv4114 4115 ft(il, i) = ft(il, i) - 0.009 *grav*sigd(il) * &4116 (mp(il,i+1)*t_wake(il,i)*b(il,i)-mp(il,i)*t_wake(il,i-1)*rat*b(il,i-1))*dpinv4077 rat = cpn(il, i - 1) * cpinv 4078 4079 ft(il, i) = ft(il, i) - 0.009 * grav * sigd(il) * & 4080 (mp(il, i + 1) * t_wake(il, i) * b(il, i) - mp(il, i) * t_wake(il, i - 1) * rat * b(il, i - 1)) * dpinv 4117 4081 IF (cvflag_ice) THEN 4118 ft(il, i) = ft(il, i) + 0.01 *sigd(il)*wt(il, i)*(cl-cpd)*water(il, i+1) * &4119 (t_wake(il,i+1)-t_wake(il,i))*dpinv*cpinv + &4120 0.01*sigd(il)*wt(il, i)*(ci-cpd)*ice(il, i+1) * &4121 (t_wake(il,i+1)-t_wake(il,i))*dpinv*cpinv4082 ft(il, i) = ft(il, i) + 0.01 * sigd(il) * wt(il, i) * (cl - cpd) * water(il, i + 1) * & 4083 (t_wake(il, i + 1) - t_wake(il, i)) * dpinv * cpinv + & 4084 0.01 * sigd(il) * wt(il, i) * (ci - cpd) * ice(il, i + 1) * & 4085 (t_wake(il, i + 1) - t_wake(il, i)) * dpinv * cpinv 4122 4086 ELSE 4123 ft(il, i) = ft(il, i) + 0.01 *sigd(il)*wt(il, i)*(cl-cpd)*water(il, i+1) * &4124 (t_wake(il,i+1)-t_wake(il,i))*dpinv* &4125 cpinv4087 ft(il, i) = ft(il, i) + 0.01 * sigd(il) * wt(il, i) * (cl - cpd) * water(il, i + 1) * & 4088 (t_wake(il, i + 1) - t_wake(il, i)) * dpinv * & 4089 cpinv 4126 4090 END IF 4127 4091 4128 4092 ftd(il, i) = ft(il, i) 4129 ! fin precip4130 4131 ! sature4132 !jyg<4093 ! fin precip 4094 4095 ! sature 4096 !jyg< 4133 4097 IF (fl_cor_ebil >= 2) THEN 4134 ft(il, i) = ft(il, i) + 0.01 *grav*dpinv * &4135 ( amp1(il)*( (t(il,i+1)-t(il,i))*cpn(il,i+1) + gz(il,i+1)-gz(il,i))*cpinv - &4136 ad(il)*( (t(il,i)-t(il,i-1))*cpn(il,i-1) + gz(il,i)-gz(il,i-1))*cpinv)4098 ft(il, i) = ft(il, i) + 0.01 * grav * dpinv * & 4099 (amp1(il) * ((t(il, i + 1) - t(il, i)) * cpn(il, i + 1) + gz(il, i + 1) - gz(il, i)) * cpinv - & 4100 ad(il) * ((t(il, i) - t(il, i - 1)) * cpn(il, i - 1) + gz(il, i) - gz(il, i - 1)) * cpinv) 4137 4101 ELSE 4138 ft(il, i) = ft(il, i) + 0.01 *grav*dpinv * &4139 (amp1(il)*(t(il,i+1)-t(il,i) + (gz(il,i+1)-gz(il,i))*cpinv) - &4140 ad(il)*(t(il,i)-t(il,i-1)+(gz(il,i)-gz(il,i-1))*cpinv))4102 ft(il, i) = ft(il, i) + 0.01 * grav * dpinv * & 4103 (amp1(il) * (t(il, i + 1) - t(il, i) + (gz(il, i + 1) - gz(il, i)) * cpinv) - & 4104 ad(il) * (t(il, i) - t(il, i - 1) + (gz(il, i) - gz(il, i - 1)) * cpinv)) 4141 4105 ENDIF 4142 !>jyg 4143 4106 !>jyg 4144 4107 4145 4108 IF (iflag_mix==0) THEN 4146 ft(il, i) = ft(il, i) + 0.01 *grav*dpinv*ment(il, i, i)*(hp(il,i)-h(il,i) + &4147 t(il,i)*(cpv-cpd)*(rr(il,i)-qent(il,i,i)))*cpinv4109 ft(il, i) = ft(il, i) + 0.01 * grav * dpinv * ment(il, i, i) * (hp(il, i) - h(il, i) + & 4110 t(il, i) * (cpv - cpd) * (rr(il, i) - qent(il, i, i))) * cpinv 4148 4111 END IF 4149 4112 4150 ! sb: on ne fait pas encore la correction permettant de mieux4151 ! conserver l'eau:4152 !JYG: correction permettant de mieux conserver l'eau:4153 ! cc fr(il,i)=0.5*sigd(il)*(evap(il,i)+evap(il,i+1))4154 fr(il, i) = sigd(il) *evap(il, i) + 0.01*grav*(mp(il,i+1)*(rp(il,i+1)-rr_wake(il,i)) - &4155 mp(il,i)*(rp(il,i)-rr_wake(il,i-1)))*dpinv4113 ! sb: on ne fait pas encore la correction permettant de mieux 4114 ! conserver l'eau: 4115 !JYG: correction permettant de mieux conserver l'eau: 4116 ! cc fr(il,i)=0.5*sigd(il)*(evap(il,i)+evap(il,i+1)) 4117 fr(il, i) = sigd(il) * evap(il, i) + 0.01 * grav * (mp(il, i + 1) * (rp(il, i + 1) - rr_wake(il, i)) - & 4118 mp(il, i) * (rp(il, i) - rr_wake(il, i - 1))) * dpinv 4156 4119 fqd(il, i) = fr(il, i) ! precip 4157 4120 4158 fu(il, i) = 0.01*grav*(mp(il,i+1)*(up(il,i+1)-u(il,i)) - & 4159 mp(il,i)*(up(il,i)-u(il,i-1)))*dpinv 4160 fv(il, i) = 0.01*grav*(mp(il,i+1)*(vp(il,i+1)-v(il,i)) - & 4161 mp(il,i)*(vp(il,i)-v(il,i-1)))*dpinv 4162 4163 4164 fr(il, i) = fr(il, i) + 0.01*grav*dpinv*(amp1(il)*(rr(il,i+1)-rr(il,i)) - & 4165 ad(il)*(rr(il,i)-rr(il,i-1))) 4166 fu(il, i) = fu(il, i) + 0.01*grav*dpinv*(amp1(il)*(u(il,i+1)-u(il,i)) - & 4167 ad(il)*(u(il,i)-u(il,i-1))) 4168 fv(il, i) = fv(il, i) + 0.01*grav*dpinv*(amp1(il)*(v(il,i+1)-v(il,i)) - & 4169 ad(il)*(v(il,i)-v(il,i-1))) 4121 fu(il, i) = 0.01 * grav * (mp(il, i + 1) * (up(il, i + 1) - u(il, i)) - & 4122 mp(il, i) * (up(il, i) - u(il, i - 1))) * dpinv 4123 fv(il, i) = 0.01 * grav * (mp(il, i + 1) * (vp(il, i + 1) - v(il, i)) - & 4124 mp(il, i) * (vp(il, i) - v(il, i - 1))) * dpinv 4125 4126 fr(il, i) = fr(il, i) + 0.01 * grav * dpinv * (amp1(il) * (rr(il, i + 1) - rr(il, i)) - & 4127 ad(il) * (rr(il, i) - rr(il, i - 1))) 4128 fu(il, i) = fu(il, i) + 0.01 * grav * dpinv * (amp1(il) * (u(il, i + 1) - u(il, i)) - & 4129 ad(il) * (u(il, i) - u(il, i - 1))) 4130 fv(il, i) = fv(il, i) + 0.01 * grav * dpinv * (amp1(il) * (v(il, i + 1) - v(il, i)) - & 4131 ad(il) * (v(il, i) - v(il, i - 1))) 4170 4132 4171 4133 END IF ! i 4172 4134 END DO 4173 4135 4174 !AC! do k=1,ntra4175 !AC! do il=1,ncum4176 !AC! if (i.le.inb(il) .AND. iflag(il) .le. 1) THEN4177 !AC! dpinv=1.0/(ph(il,i)-ph(il,i+1))4178 !AC! cpinv=1.0/cpn(il,i)4179 !AC! if (cvflag_grav) THEN4180 !AC! ftra(il,i,k)=ftra(il,i,k)+0.01*grav*dpinv4181 !AC! : *(amp1(il)*(tra(il,i+1,k)-tra(il,i,k))4182 !AC! : -ad(il)*(tra(il,i,k)-tra(il,i-1,k)))4183 !AC! else4184 !AC! ftra(il,i,k)=ftra(il,i,k)+0.1*dpinv4185 !AC! : *(amp1(il)*(tra(il,i+1,k)-tra(il,i,k))4186 !AC! : -ad(il)*(tra(il,i,k)-tra(il,i-1,k)))4187 !AC! endif4188 !AC! endif4189 !AC! enddo4190 !AC! enddo4136 !AC! do k=1,ntra 4137 !AC! do il=1,ncum 4138 !AC! if (i.le.inb(il) .AND. iflag(il) .le. 1) THEN 4139 !AC! dpinv=1.0/(ph(il,i)-ph(il,i+1)) 4140 !AC! cpinv=1.0/cpn(il,i) 4141 !AC! if (cvflag_grav) THEN 4142 !AC! ftra(il,i,k)=ftra(il,i,k)+0.01*grav*dpinv 4143 !AC! : *(amp1(il)*(tra(il,i+1,k)-tra(il,i,k)) 4144 !AC! : -ad(il)*(tra(il,i,k)-tra(il,i-1,k))) 4145 !AC! else 4146 !AC! ftra(il,i,k)=ftra(il,i,k)+0.1*dpinv 4147 !AC! : *(amp1(il)*(tra(il,i+1,k)-tra(il,i,k)) 4148 !AC! : -ad(il)*(tra(il,i,k)-tra(il,i-1,k))) 4149 !AC! endif 4150 !AC! endif 4151 !AC! enddo 4152 !AC! enddo 4191 4153 4192 4154 DO k = 1, i - 1 4193 4155 4194 4156 DO il = 1, ncum 4195 awat(il) = elij(il, k, i) - (1. -ep(il,i))*clw(il, i)4157 awat(il) = elij(il, k, i) - (1. - ep(il, i)) * clw(il, i) 4196 4158 awat(il) = max(awat(il), 0.0) 4197 4159 END DO … … 4200 4162 DO il = 1, ncum 4201 4163 IF (i<=inb(il) .AND. iflag(il)<=1) THEN 4202 dpinv = 1.0/(ph(il,i)-ph(il,i+1)) 4203 cpinv = 1.0/cpn(il, i) 4204 ft(il, i) = ft(il, i) + 0.01*grav*dpinv*ment(il, k, i) * & 4205 (hent(il,k,i)-h(il,i)+t(il,i)*(cpv-cpd)*(rr(il,i)+awat(il)-qent(il,k,i)))*cpinv 4206 4164 dpinv = 1.0 / (ph(il, i) - ph(il, i + 1)) 4165 cpinv = 1.0 / cpn(il, i) 4166 ft(il, i) = ft(il, i) + 0.01 * grav * dpinv * ment(il, k, i) * & 4167 (hent(il, k, i) - h(il, i) + t(il, i) * (cpv - cpd) * (rr(il, i) + awat(il) - qent(il, k, i))) * cpinv 4207 4168 4208 4169 END IF ! i … … 4212 4173 DO il = 1, ncum 4213 4174 IF (i<=inb(il) .AND. iflag(il)<=1) THEN 4214 dpinv = 1.0 /(ph(il,i)-ph(il,i+1))4215 cpinv = 1.0 /cpn(il, i)4216 fr(il, i) = fr(il, i) + 0.01 *grav*dpinv*ment(il, k, i) * &4217 (qent(il,k,i)-awat(il)-rr(il,i))4218 fr_comp(il, i) = fr_comp(il,i) + 0.01*grav*dpinv*ment(il, k, i)*(qent(il,k,i)-awat(il)-rr(il,i))4219 fu(il, i) = fu(il, i) + 0.01 *grav*dpinv*ment(il, k, i)*(uent(il,k,i)-u(il,i))4220 fv(il, i) = fv(il, i) + 0.01 *grav*dpinv*ment(il, k, i)*(vent(il,k,i)-v(il,i))4221 4222 ! (saturated updrafts resulting from mixing) ! cld4223 qcond(il, i) = qcond(il, i) + (elij(il, k,i)-awat(il)) ! cld4224 qdet(il, k,i) = (qent(il,k,i)-awat(il)) ! cld Louis : specific humidity in detraining water4225 qtment(il, i) = qtment(il, i) + qent(il, k,i) ! cld4175 dpinv = 1.0 / (ph(il, i) - ph(il, i + 1)) 4176 cpinv = 1.0 / cpn(il, i) 4177 fr(il, i) = fr(il, i) + 0.01 * grav * dpinv * ment(il, k, i) * & 4178 (qent(il, k, i) - awat(il) - rr(il, i)) 4179 fr_comp(il, i) = fr_comp(il, i) + 0.01 * grav * dpinv * ment(il, k, i) * (qent(il, k, i) - awat(il) - rr(il, i)) 4180 fu(il, i) = fu(il, i) + 0.01 * grav * dpinv * ment(il, k, i) * (uent(il, k, i) - u(il, i)) 4181 fv(il, i) = fv(il, i) + 0.01 * grav * dpinv * ment(il, k, i) * (vent(il, k, i) - v(il, i)) 4182 4183 ! (saturated updrafts resulting from mixing) ! cld 4184 qcond(il, i) = qcond(il, i) + (elij(il, k, i) - awat(il)) ! cld 4185 qdet(il, k, i) = (qent(il, k, i) - awat(il)) ! cld Louis : specific humidity in detraining water 4186 qtment(il, i) = qtment(il, i) + qent(il, k, i) ! cld 4226 4187 nqcond(il, i) = nqcond(il, i) + 1. ! cld 4227 4188 END IF ! i … … 4229 4190 END DO 4230 4191 4231 !AC! do j=1,ntra4232 !AC! do k=1,i-14233 !AC! do il=1,ncum4234 !AC! if (i.le.inb(il) .AND. iflag(il) .le. 1) THEN4235 !AC! dpinv=1.0/(ph(il,i)-ph(il,i+1))4236 !AC! cpinv=1.0/cpn(il,i)4237 !AC! if (cvflag_grav) THEN4238 !AC! ftra(il,i,j)=ftra(il,i,j)+0.01*grav*dpinv*ment(il,k,i)4239 !AC! : *(traent(il,k,i,j)-tra(il,i,j))4240 !AC! else4241 !AC! ftra(il,i,j)=ftra(il,i,j)+0.1*dpinv*ment(il,k,i)4242 !AC! : *(traent(il,k,i,j)-tra(il,i,j))4243 !AC! endif4244 !AC! endif4245 !AC! enddo4246 !AC! enddo4247 !AC! enddo4248 4249 !jyg<4250 !! DO k = i, nl + 14192 !AC! do j=1,ntra 4193 !AC! do k=1,i-1 4194 !AC! do il=1,ncum 4195 !AC! if (i.le.inb(il) .AND. iflag(il) .le. 1) THEN 4196 !AC! dpinv=1.0/(ph(il,i)-ph(il,i+1)) 4197 !AC! cpinv=1.0/cpn(il,i) 4198 !AC! if (cvflag_grav) THEN 4199 !AC! ftra(il,i,j)=ftra(il,i,j)+0.01*grav*dpinv*ment(il,k,i) 4200 !AC! : *(traent(il,k,i,j)-tra(il,i,j)) 4201 !AC! else 4202 !AC! ftra(il,i,j)=ftra(il,i,j)+0.1*dpinv*ment(il,k,i) 4203 !AC! : *(traent(il,k,i,j)-tra(il,i,j)) 4204 !AC! endif 4205 !AC! endif 4206 !AC! enddo 4207 !AC! enddo 4208 !AC! enddo 4209 4210 !jyg< 4211 !! DO k = i, nl + 1 4251 4212 DO k = i, nl 4252 !>jyg4213 !>jyg 4253 4214 4254 4215 IF (iflag_mix/=0) THEN 4255 4216 DO il = 1, ncum 4256 4217 IF (i<=inb(il) .AND. k<=inb(il) .AND. iflag(il)<=1) THEN 4257 dpinv = 1.0/(ph(il,i)-ph(il,i+1)) 4258 cpinv = 1.0/cpn(il, i) 4259 ft(il, i) = ft(il, i) + 0.01*grav*dpinv*ment(il, k, i) * & 4260 (hent(il,k,i)-h(il,i)+t(il,i)*(cpv-cpd)*(rr(il,i)-qent(il,k,i)))*cpinv 4261 4218 dpinv = 1.0 / (ph(il, i) - ph(il, i + 1)) 4219 cpinv = 1.0 / cpn(il, i) 4220 ft(il, i) = ft(il, i) + 0.01 * grav * dpinv * ment(il, k, i) * & 4221 (hent(il, k, i) - h(il, i) + t(il, i) * (cpv - cpd) * (rr(il, i) - qent(il, k, i))) * cpinv 4262 4222 4263 4223 END IF ! i … … 4267 4227 DO il = 1, ncum 4268 4228 IF (i<=inb(il) .AND. k<=inb(il) .AND. iflag(il)<=1) THEN 4269 dpinv = 1.0 /(ph(il,i)-ph(il,i+1))4270 cpinv = 1.0 /cpn(il, i)4271 4272 fr(il, i) = fr(il, i) + 0.01 *grav*dpinv*ment(il, k, i)*(qent(il,k,i)-rr(il,i))4273 fu(il, i) = fu(il, i) + 0.01 *grav*dpinv*ment(il, k, i)*(uent(il,k,i)-u(il,i))4274 fv(il, i) = fv(il, i) + 0.01 *grav*dpinv*ment(il, k, i)*(vent(il,k,i)-v(il,i))4229 dpinv = 1.0 / (ph(il, i) - ph(il, i + 1)) 4230 cpinv = 1.0 / cpn(il, i) 4231 4232 fr(il, i) = fr(il, i) + 0.01 * grav * dpinv * ment(il, k, i) * (qent(il, k, i) - rr(il, i)) 4233 fu(il, i) = fu(il, i) + 0.01 * grav * dpinv * ment(il, k, i) * (uent(il, k, i) - u(il, i)) 4234 fv(il, i) = fv(il, i) + 0.01 * grav * dpinv * ment(il, k, i) * (vent(il, k, i) - v(il, i)) 4275 4235 END IF ! i and k 4276 4236 END DO 4277 4237 END DO 4278 4238 4279 !AC! do j=1,ntra4280 !AC! do k=i,nl+14281 !AC! do il=1,ncum4282 !AC! if (i.le.inb(il) .AND. k.le.inb(il)4283 !AC! $ .AND. iflag(il) .le. 1) THEN4284 !AC! dpinv=1.0/(ph(il,i)-ph(il,i+1))4285 !AC! cpinv=1.0/cpn(il,i)4286 !AC! if (cvflag_grav) THEN4287 !AC! ftra(il,i,j)=ftra(il,i,j)+0.01*grav*dpinv*ment(il,k,i)4288 !AC! : *(traent(il,k,i,j)-tra(il,i,j))4289 !AC! else4290 !AC! ftra(il,i,j)=ftra(il,i,j)+0.1*dpinv*ment(il,k,i)4291 !AC! : *(traent(il,k,i,j)-tra(il,i,j))4292 !AC! endif4293 !AC! endif ! i and k4294 !AC! enddo4295 !AC! enddo4296 !AC! enddo4297 4298 ! sb: interface with the cloud parameterization: ! cld4239 !AC! do j=1,ntra 4240 !AC! do k=i,nl+1 4241 !AC! do il=1,ncum 4242 !AC! if (i.le.inb(il) .AND. k.le.inb(il) 4243 !AC! $ .AND. iflag(il) .le. 1) THEN 4244 !AC! dpinv=1.0/(ph(il,i)-ph(il,i+1)) 4245 !AC! cpinv=1.0/cpn(il,i) 4246 !AC! if (cvflag_grav) THEN 4247 !AC! ftra(il,i,j)=ftra(il,i,j)+0.01*grav*dpinv*ment(il,k,i) 4248 !AC! : *(traent(il,k,i,j)-tra(il,i,j)) 4249 !AC! else 4250 !AC! ftra(il,i,j)=ftra(il,i,j)+0.1*dpinv*ment(il,k,i) 4251 !AC! : *(traent(il,k,i,j)-tra(il,i,j)) 4252 !AC! endif 4253 !AC! endif ! i and k 4254 !AC! enddo 4255 !AC! enddo 4256 !AC! enddo 4257 4258 ! sb: interface with the cloud parameterization: ! cld 4299 4259 4300 4260 DO k = i + 1, nl 4301 4261 DO il = 1, ncum 4302 4262 IF (k<=inb(il) .AND. i<=inb(il) .AND. iflag(il)<=1) THEN ! cld 4303 ! (saturated downdrafts resulting from mixing) ! cld4263 ! (saturated downdrafts resulting from mixing) ! cld 4304 4264 qcond(il, i) = qcond(il, i) + elij(il, k, i) ! cld 4305 qdet(il, k,i) = qent(il,k,i) ! cld Louis : specific humidity in detraining water4306 qtment(il, i) = qent(il, k,i) + qtment(il,i) ! cld4265 qdet(il, k, i) = qent(il, k, i) ! cld Louis : specific humidity in detraining water 4266 qtment(il, i) = qent(il, k, i) + qtment(il, i) ! cld 4307 4267 nqcond(il, i) = nqcond(il, i) + 1. ! cld 4308 4268 END IF ! cld … … 4310 4270 END DO ! cld 4311 4271 4312 !ym BIG Warning : it seems that the k loop is missing !!!4313 !ym Strong advice to check this4314 !ym add a k loop temporary 4315 4316 ! (particular case: no detraining level is found) ! cld4317 ! Verif merge Dynamico<<<<<<< .working4272 !ym BIG Warning : it seems that the k loop is missing !!! 4273 !ym Strong advice to check this 4274 !ym add a k loop temporary 4275 4276 ! (particular case: no detraining level is found) ! cld 4277 ! Verif merge Dynamico<<<<<<< .working 4318 4278 DO il = 1, ncum ! cld 4319 IF (i<=inb(il) .AND. nent(il, i)==0 .AND. iflag(il)<=1) THEN ! cld4320 qcond(il, i) = qcond(il, i) + (1. -ep(il,i))*clw(il, i) ! cld4321 !jyg< Bug correction 201806204322 ! PROBLEM: Should not qent(il,i,i) be taken into account even if nent(il,i)/=0?4323 !! qtment(il, i) = qent(il,k,i) + qtment(il,i) ! cld4324 qdet(il, i,i) = qent(il,i,i) ! cld Louis : specific humidity in detraining water4325 qtment(il, i) = qent(il, i,i) + qtment(il,i) ! cld4326 !>jyg4279 IF (i<=inb(il) .AND. nent(il, i)==0 .AND. iflag(il)<=1) THEN ! cld 4280 qcond(il, i) = qcond(il, i) + (1. - ep(il, i)) * clw(il, i) ! cld 4281 !jyg< Bug correction 20180620 4282 ! PROBLEM: Should not qent(il,i,i) be taken into account even if nent(il,i)/=0? 4283 !! qtment(il, i) = qent(il,k,i) + qtment(il,i) ! cld 4284 qdet(il, i, i) = qent(il, i, i) ! cld Louis : specific humidity in detraining water 4285 qtment(il, i) = qent(il, i, i) + qtment(il, i) ! cld 4286 !>jyg 4327 4287 nqcond(il, i) = nqcond(il, i) + 1. ! cld 4328 4288 END IF ! cld 4329 4289 END DO ! cld 4330 ! Verif merge Dynamico =======4331 ! Verif merge Dynamico DO k = i + 1, nl4332 ! Verif merge Dynamico DO il = 1, ncum !ym k loop added ! cld4333 ! Verif merge Dynamico IF (i<=inb(il) .AND. nent(il,i)==0 .AND. iflag(il)<=1) THEN ! cld4334 ! Verif merge Dynamico qcond(il, i) = qcond(il, i) + (1.-ep(il,i))*clw(il, i) ! cld4335 ! Verif merge Dynamico qtment(il, i) = qent(il,k,i) + qtment(il,i) ! cld4336 ! Verif merge Dynamico nqcond(il, i) = nqcond(il, i) + 1. ! cld4337 ! Verif merge Dynamico END IF ! cld4338 ! Verif merge Dynamico END DO4339 ! Verif merge Dynamico ENDDO ! cld4340 ! Verif merge Dynamico >>>>>>> .merge-right.r34134290 ! Verif merge Dynamico ======= 4291 ! Verif merge Dynamico DO k = i + 1, nl 4292 ! Verif merge Dynamico DO il = 1, ncum !ym k loop added ! cld 4293 ! Verif merge Dynamico IF (i<=inb(il) .AND. nent(il,i)==0 .AND. iflag(il)<=1) THEN ! cld 4294 ! Verif merge Dynamico qcond(il, i) = qcond(il, i) + (1.-ep(il,i))*clw(il, i) ! cld 4295 ! Verif merge Dynamico qtment(il, i) = qent(il,k,i) + qtment(il,i) ! cld 4296 ! Verif merge Dynamico nqcond(il, i) = nqcond(il, i) + 1. ! cld 4297 ! Verif merge Dynamico END IF ! cld 4298 ! Verif merge Dynamico END DO 4299 ! Verif merge Dynamico ENDDO ! cld 4300 ! Verif merge Dynamico >>>>>>> .merge-right.r3413 4341 4301 4342 4302 DO il = 1, ncum ! cld 4343 IF (i<=inb(il) .AND. nqcond(il, i)/=0 .AND. iflag(il)<=1) THEN ! cld4344 qcond(il, i) = qcond(il, i) /nqcond(il, i) ! cld4345 qtment(il, i) = qtment(il, i)/nqcond(il, i) ! cld4303 IF (i<=inb(il) .AND. nqcond(il, i)/=0 .AND. iflag(il)<=1) THEN ! cld 4304 qcond(il, i) = qcond(il, i) / nqcond(il, i) ! cld 4305 qtment(il, i) = qtment(il, i) / nqcond(il, i) ! cld 4346 4306 END IF ! cld 4347 4307 END DO 4348 4308 4349 !AC! do j=1,ntra 4350 !AC! do il=1,ncum 4351 !AC! if (i.le.inb(il) .AND. iflag(il) .le. 1) THEN 4352 !AC! dpinv=1.0/(ph(il,i)-ph(il,i+1)) 4353 !AC! cpinv=1.0/cpn(il,i) 4354 !AC! 4355 !AC! if (cvflag_grav) THEN 4356 !AC! ftra(il,i,j)=ftra(il,i,j)+0.01*grav*dpinv 4357 !AC! : *(mp(il,i+1)*(trap(il,i+1,j)-tra(il,i,j)) 4358 !AC! : -mp(il,i)*(trap(il,i,j)-trap(il,i-1,j))) 4359 !AC! else 4360 !AC! ftra(il,i,j)=ftra(il,i,j)+0.1*dpinv 4361 !AC! : *(mp(il,i+1)*(trap(il,i+1,j)-tra(il,i,j)) 4362 !AC! : -mp(il,i)*(trap(il,i,j)-trap(il,i-1,j))) 4363 !AC! endif 4364 !AC! endif ! i 4365 !AC! enddo 4366 !AC! enddo 4367 4368 4369 500 END DO 4370 4371 !JYG< 4372 !Conservation de l'eau 4373 ! sumdq = 0. 4374 ! DO k = 1, nl 4375 ! sumdq = sumdq + fr(1, k)*100.*(ph(1,k)-ph(1,k+1))/grav 4376 ! END DO 4377 ! PRINT *, 'cv3_yield, apres 500, sum(dq), precip, somme ', sumdq, Vprecip(1, 1), sumdq + vprecip(1, 1) 4378 !JYG> 4379 ! *** move the detrainment at level inb down to level inb-1 *** 4380 ! *** in such a way as to preserve the vertically *** 4381 ! *** integrated enthalpy and water tendencies *** 4382 4383 ! Correction bug le 18-03-09 4309 !AC! do j=1,ntra 4310 !AC! do il=1,ncum 4311 !AC! if (i.le.inb(il) .AND. iflag(il) .le. 1) THEN 4312 !AC! dpinv=1.0/(ph(il,i)-ph(il,i+1)) 4313 !AC! cpinv=1.0/cpn(il,i) 4314 !AC! 4315 !AC! if (cvflag_grav) THEN 4316 !AC! ftra(il,i,j)=ftra(il,i,j)+0.01*grav*dpinv 4317 !AC! : *(mp(il,i+1)*(trap(il,i+1,j)-tra(il,i,j)) 4318 !AC! : -mp(il,i)*(trap(il,i,j)-trap(il,i-1,j))) 4319 !AC! else 4320 !AC! ftra(il,i,j)=ftra(il,i,j)+0.1*dpinv 4321 !AC! : *(mp(il,i+1)*(trap(il,i+1,j)-tra(il,i,j)) 4322 !AC! : -mp(il,i)*(trap(il,i,j)-trap(il,i-1,j))) 4323 !AC! endif 4324 !AC! endif ! i 4325 !AC! enddo 4326 !AC! enddo 4327 4328 500 END DO 4329 4330 !JYG< 4331 !Conservation de l'eau 4332 ! sumdq = 0. 4333 ! DO k = 1, nl 4334 ! sumdq = sumdq + fr(1, k)*100.*(ph(1,k)-ph(1,k+1))/grav 4335 ! END DO 4336 ! PRINT *, 'cv3_yield, apres 500, sum(dq), precip, somme ', sumdq, Vprecip(1, 1), sumdq + vprecip(1, 1) 4337 !JYG> 4338 ! *** move the detrainment at level inb down to level inb-1 *** 4339 ! *** in such a way as to preserve the vertically *** 4340 ! *** integrated enthalpy and water tendencies *** 4341 4342 ! Correction bug le 18-03-09 4384 4343 DO il = 1, ncum 4385 4344 IF (iflag(il)<=1) THEN 4386 ax = 0.01 *grav*ment(il, inb(il), inb(il))* &4387 (hp(il,inb(il))-h(il,inb(il))+t(il,inb(il))*(cpv-cpd)*(rr(il,inb(il))-qent(il,inb(il),inb(il))))/ &4388 (cpn(il,inb(il))*(ph(il,inb(il))-ph(il,inb(il)+1)))4345 ax = 0.01 * grav * ment(il, inb(il), inb(il)) * & 4346 (hp(il, inb(il)) - h(il, inb(il)) + t(il, inb(il)) * (cpv - cpd) * (rr(il, inb(il)) - qent(il, inb(il), inb(il)))) / & 4347 (cpn(il, inb(il)) * (ph(il, inb(il)) - ph(il, inb(il) + 1))) 4389 4348 ft(il, inb(il)) = ft(il, inb(il)) - ax 4390 ft(il, inb(il) -1) = ft(il, inb(il)-1) + ax*cpn(il, inb(il))*(ph(il,inb(il))-ph(il,inb(il)+1))/ &4391 (cpn(il,inb(il)-1)*(ph(il,inb(il)-1)-ph(il,inb(il))))4392 4393 bx = 0.01 *grav*ment(il, inb(il), inb(il))*(qent(il,inb(il),inb(il))-rr(il,inb(il)))/ &4394 (ph(il,inb(il))-ph(il,inb(il)+1))4349 ft(il, inb(il) - 1) = ft(il, inb(il) - 1) + ax * cpn(il, inb(il)) * (ph(il, inb(il)) - ph(il, inb(il) + 1)) / & 4350 (cpn(il, inb(il) - 1) * (ph(il, inb(il) - 1) - ph(il, inb(il)))) 4351 4352 bx = 0.01 * grav * ment(il, inb(il), inb(il)) * (qent(il, inb(il), inb(il)) - rr(il, inb(il))) / & 4353 (ph(il, inb(il)) - ph(il, inb(il) + 1)) 4395 4354 fr(il, inb(il)) = fr(il, inb(il)) - bx 4396 fr(il, inb(il) -1) = fr(il, inb(il)-1) + bx*(ph(il,inb(il))-ph(il,inb(il)+1))/ &4397 (ph(il,inb(il)-1)-ph(il,inb(il)))4398 4399 cx = 0.01 *grav*ment(il, inb(il), inb(il))*(uent(il,inb(il),inb(il))-u(il,inb(il)))/ &4400 (ph(il,inb(il))-ph(il,inb(il)+1))4355 fr(il, inb(il) - 1) = fr(il, inb(il) - 1) + bx * (ph(il, inb(il)) - ph(il, inb(il) + 1)) / & 4356 (ph(il, inb(il) - 1) - ph(il, inb(il))) 4357 4358 cx = 0.01 * grav * ment(il, inb(il), inb(il)) * (uent(il, inb(il), inb(il)) - u(il, inb(il))) / & 4359 (ph(il, inb(il)) - ph(il, inb(il) + 1)) 4401 4360 fu(il, inb(il)) = fu(il, inb(il)) - cx 4402 fu(il, inb(il) -1) = fu(il, inb(il)-1) + cx*(ph(il,inb(il))-ph(il,inb(il)+1))/ &4403 (ph(il,inb(il)-1)-ph(il,inb(il)))4404 4405 dx = 0.01 *grav*ment(il, inb(il), inb(il))*(vent(il,inb(il),inb(il))-v(il,inb(il)))/ &4406 (ph(il,inb(il))-ph(il,inb(il)+1))4361 fu(il, inb(il) - 1) = fu(il, inb(il) - 1) + cx * (ph(il, inb(il)) - ph(il, inb(il) + 1)) / & 4362 (ph(il, inb(il) - 1) - ph(il, inb(il))) 4363 4364 dx = 0.01 * grav * ment(il, inb(il), inb(il)) * (vent(il, inb(il), inb(il)) - v(il, inb(il))) / & 4365 (ph(il, inb(il)) - ph(il, inb(il) + 1)) 4407 4366 fv(il, inb(il)) = fv(il, inb(il)) - dx 4408 fv(il, inb(il) -1) = fv(il, inb(il)-1) + dx*(ph(il,inb(il))-ph(il,inb(il)+1))/ &4409 (ph(il,inb(il)-1)-ph(il,inb(il)))4367 fv(il, inb(il) - 1) = fv(il, inb(il) - 1) + dx * (ph(il, inb(il)) - ph(il, inb(il) + 1)) / & 4368 (ph(il, inb(il) - 1) - ph(il, inb(il))) 4410 4369 END IF !iflag 4411 4370 END DO 4412 4371 4413 !JYG< 4414 !Conservation de l'eau 4415 ! sumdq = 0. 4416 ! DO k = 1, nl 4417 ! sumdq = sumdq + fr(1, k)*100.*(ph(1,k)-ph(1,k+1))/grav 4418 ! END DO 4419 ! PRINT *, 'cv3_yield, apres 503, sum(dq), precip, somme ', sumdq, Vprecip(1, 1), sumdq + vprecip(1, 1) 4420 !JYG> 4421 4422 !AC! do j=1,ntra 4423 !AC! do il=1,ncum 4424 !AC! IF (iflag(il) .le. 1) THEN 4425 !AC! IF (cvflag_grav) THEN 4426 !AC! ex=0.01*grav*ment(il,inb(il),inb(il)) 4427 !AC! : *(traent(il,inb(il),inb(il),j)-tra(il,inb(il),j)) 4428 !AC! : /(ph(i l,inb(il))-ph(il,inb(il)+1)) 4429 !AC! ftra(il,inb(il),j)=ftra(il,inb(il),j)-ex 4430 !AC! ftra(il,inb(il)-1,j)=ftra(il,inb(il)-1,j) 4431 !AC! : +ex*(ph(il,inb(il))-ph(il,inb(il)+1)) 4432 !AC! : /(ph(il,inb(il)-1)-ph(il,inb(il))) 4433 !AC! else 4434 !AC! ex=0.1*ment(il,inb(il),inb(il)) 4435 !AC! : *(traent(il,inb(il),inb(il),j)-tra(il,inb(il),j)) 4436 !AC! : /(ph(i l,inb(il))-ph(il,inb(il)+1)) 4437 !AC! ftra(il,inb(il),j)=ftra(il,inb(il),j)-ex 4438 !AC! ftra(il,inb(il)-1,j)=ftra(il,inb(il)-1,j) 4439 !AC! : +ex*(ph(il,inb(il))-ph(il,inb(il)+1)) 4440 !AC! : /(ph(il,inb(il)-1)-ph(il,inb(il))) 4441 !AC! ENDIF !cvflag grav 4442 !AC! ENDIF !iflag 4443 !AC! enddo 4444 !AC! enddo 4445 4446 4447 ! *** homogenize tendencies below cloud base *** 4448 4372 !JYG< 4373 !Conservation de l'eau 4374 ! sumdq = 0. 4375 ! DO k = 1, nl 4376 ! sumdq = sumdq + fr(1, k)*100.*(ph(1,k)-ph(1,k+1))/grav 4377 ! END DO 4378 ! PRINT *, 'cv3_yield, apres 503, sum(dq), precip, somme ', sumdq, Vprecip(1, 1), sumdq + vprecip(1, 1) 4379 !JYG> 4380 4381 !AC! do j=1,ntra 4382 !AC! do il=1,ncum 4383 !AC! IF (iflag(il) .le. 1) THEN 4384 !AC! IF (cvflag_grav) THEN 4385 !AC! ex=0.01*grav*ment(il,inb(il),inb(il)) 4386 !AC! : *(traent(il,inb(il),inb(il),j)-tra(il,inb(il),j)) 4387 !AC! : /(ph(i l,inb(il))-ph(il,inb(il)+1)) 4388 !AC! ftra(il,inb(il),j)=ftra(il,inb(il),j)-ex 4389 !AC! ftra(il,inb(il)-1,j)=ftra(il,inb(il)-1,j) 4390 !AC! : +ex*(ph(il,inb(il))-ph(il,inb(il)+1)) 4391 !AC! : /(ph(il,inb(il)-1)-ph(il,inb(il))) 4392 !AC! else 4393 !AC! ex=0.1*ment(il,inb(il),inb(il)) 4394 !AC! : *(traent(il,inb(il),inb(il),j)-tra(il,inb(il),j)) 4395 !AC! : /(ph(i l,inb(il))-ph(il,inb(il)+1)) 4396 !AC! ftra(il,inb(il),j)=ftra(il,inb(il),j)-ex 4397 !AC! ftra(il,inb(il)-1,j)=ftra(il,inb(il)-1,j) 4398 !AC! : +ex*(ph(il,inb(il))-ph(il,inb(il)+1)) 4399 !AC! : /(ph(il,inb(il)-1)-ph(il,inb(il))) 4400 !AC! ENDIF !cvflag grav 4401 !AC! ENDIF !iflag 4402 !AC! enddo 4403 !AC! enddo 4404 4405 4406 ! *** homogenize tendencies below cloud base *** 4449 4407 4450 4408 DO il = 1, ncum … … 4459 4417 END DO 4460 4418 4461 !do i=1,nl4462 !do il=1,ncum4463 !th_wake(il,i)=t_wake(il,i)*(1000.0/p(il,i))**rdcp4464 !enddo4465 !enddo4419 !do i=1,nl 4420 !do il=1,ncum 4421 !th_wake(il,i)=t_wake(il,i)*(1000.0/p(il,i))**rdcp 4422 !enddo 4423 !enddo 4466 4424 4467 4425 DO i = 1, nl 4468 4426 DO il = 1, ncum 4469 IF (i<=(icb(il) -1) .AND. iflag(il)<=1) THEN4470 !jyg Saturated part : use T profile4471 asum(il) = asum(il) + (ft(il, i)-ftd(il,i))*(ph(il,i)-ph(il,i+1))4472 !jyg<201403114473 !Correction pour conserver l eau4427 IF (i<=(icb(il) - 1) .AND. iflag(il)<=1) THEN 4428 !jyg Saturated part : use T profile 4429 asum(il) = asum(il) + (ft(il, i) - ftd(il, i)) * (ph(il, i) - ph(il, i + 1)) 4430 !jyg<20140311 4431 !Correction pour conserver l eau 4474 4432 IF (ok_conserv_q) THEN 4475 bsum(il) = bsum(il) + (fr(il, i)-fqd(il,i))*(ph(il,i)-ph(il,i+1))4476 csum(il) = csum(il) + (ph(il, i)-ph(il,i+1))4433 bsum(il) = bsum(il) + (fr(il, i) - fqd(il, i)) * (ph(il, i) - ph(il, i + 1)) 4434 csum(il) = csum(il) + (ph(il, i) - ph(il, i + 1)) 4477 4435 4478 4436 ELSE 4479 bsum(il) =bsum(il)+(fr(il,i)-fqd(il,i))*(lv(il,i)+(cl-cpd)*(t(il,i)-t(il,1)))* &4480 (ph(il,i)-ph(il,i+1))4481 csum(il) =csum(il)+(lv(il,i)+(cl-cpd)*(t(il,i)-t(il,1)))* &4482 (ph(il,i)-ph(il,i+1))4437 bsum(il) = bsum(il) + (fr(il, i) - fqd(il, i)) * (lv(il, i) + (cl - cpd) * (t(il, i) - t(il, 1))) * & 4438 (ph(il, i) - ph(il, i + 1)) 4439 csum(il) = csum(il) + (lv(il, i) + (cl - cpd) * (t(il, i) - t(il, 1))) * & 4440 (ph(il, i) - ph(il, i + 1)) 4483 4441 ENDIF ! (ok_conserv_q) 4484 !jyg>4485 dsum(il) = dsum(il) + t(il, i) *(ph(il,i)-ph(il,i+1))/th(il, i)4486 !jyg Unsaturated part : use T_wake profile4487 esum(il) = esum(il) + ftd(il, i) *(ph(il,i)-ph(il,i+1))4488 !jyg<201403114489 !Correction pour conserver l eau4442 !jyg> 4443 dsum(il) = dsum(il) + t(il, i) * (ph(il, i) - ph(il, i + 1)) / th(il, i) 4444 !jyg Unsaturated part : use T_wake profile 4445 esum(il) = esum(il) + ftd(il, i) * (ph(il, i) - ph(il, i + 1)) 4446 !jyg<20140311 4447 !Correction pour conserver l eau 4490 4448 IF (ok_conserv_q) THEN 4491 fsum(il) = fsum(il) + fqd(il, i) *(ph(il,i)-ph(il,i+1))4492 gsum(il) = gsum(il) + (ph(il, i)-ph(il,i+1))4449 fsum(il) = fsum(il) + fqd(il, i) * (ph(il, i) - ph(il, i + 1)) 4450 gsum(il) = gsum(il) + (ph(il, i) - ph(il, i + 1)) 4493 4451 ELSE 4494 fsum(il) =fsum(il)+fqd(il,i)*(lv(il,i)+(cl-cpd)*(t_wake(il,i)-t_wake(il,1)))* &4495 (ph(il,i)-ph(il,i+1))4496 gsum(il) =gsum(il)+(lv(il,i)+(cl-cpd)*(t_wake(il,i)-t_wake(il,1)))* &4497 (ph(il,i)-ph(il,i+1))4452 fsum(il) = fsum(il) + fqd(il, i) * (lv(il, i) + (cl - cpd) * (t_wake(il, i) - t_wake(il, 1))) * & 4453 (ph(il, i) - ph(il, i + 1)) 4454 gsum(il) = gsum(il) + (lv(il, i) + (cl - cpd) * (t_wake(il, i) - t_wake(il, 1))) * & 4455 (ph(il, i) - ph(il, i + 1)) 4498 4456 ENDIF ! (ok_conserv_q) 4499 !jyg>4500 hsum(il) = hsum(il) + t_wake(il, i) *(ph(il,i)-ph(il,i+1))/th_wake(il, i)4457 !jyg> 4458 hsum(il) = hsum(il) + t_wake(il, i) * (ph(il, i) - ph(il, i + 1)) / th_wake(il, i) 4501 4459 END IF 4502 4460 END DO 4503 4461 END DO 4504 4462 4505 !!!! do 700 i=1,icb(il)-14463 !!!! do 700 i=1,icb(il)-1 4506 4464 IF (ok_homo_tend) THEN 4507 4465 DO i = 1, nl 4508 4466 DO il = 1, ncum 4509 IF (i<=(icb(il) -1) .AND. iflag(il)<=1) THEN4510 ftd(il, i) = esum(il) *t_wake(il, i)/(th_wake(il,i)*hsum(il))4511 fqd(il, i) = fsum(il) /gsum(il)4512 ft(il, i) = ftd(il, i) + asum(il) *t(il, i)/(th(il,i)*dsum(il))4513 fr(il, i) = fqd(il, i) + bsum(il) /csum(il)4467 IF (i<=(icb(il) - 1) .AND. iflag(il)<=1) THEN 4468 ftd(il, i) = esum(il) * t_wake(il, i) / (th_wake(il, i) * hsum(il)) 4469 fqd(il, i) = fsum(il) / gsum(il) 4470 ft(il, i) = ftd(il, i) + asum(il) * t(il, i) / (th(il, i) * dsum(il)) 4471 fr(il, i) = fqd(il, i) + bsum(il) / csum(il) 4514 4472 END IF 4515 4473 END DO … … 4517 4475 ENDIF 4518 4476 4519 !jyg<4520 !Conservation de l'eau4521 !! sumdq = 0.4522 !! DO k = 1, nl4523 !! sumdq = sumdq + fr(1, k)*100.*(ph(1,k)-ph(1,k+1))/grav4524 !! END DO4525 !! PRINT *, 'cv3_yield, apres hom, sum(dq), precip, somme ', sumdq, Vprecip(1, 1), sumdq + vprecip(1, 1)4526 !jyg>4527 4528 4529 ! *** Check that moisture stays positive. If not, scale tendencies4530 ! in order to ensure moisture positivity4477 !jyg< 4478 !Conservation de l'eau 4479 !! sumdq = 0. 4480 !! DO k = 1, nl 4481 !! sumdq = sumdq + fr(1, k)*100.*(ph(1,k)-ph(1,k+1))/grav 4482 !! END DO 4483 !! PRINT *, 'cv3_yield, apres hom, sum(dq), precip, somme ', sumdq, Vprecip(1, 1), sumdq + vprecip(1, 1) 4484 !jyg> 4485 4486 4487 ! *** Check that moisture stays positive. If not, scale tendencies 4488 ! in order to ensure moisture positivity 4531 4489 DO il = 1, ncum 4532 4490 alpha_qpos(il) = 1. 4533 4491 IF (iflag(il)<=1) THEN 4534 IF (fr(il, 1)<=0.) THEN4535 alpha_qpos(il) = max(alpha_qpos(il), (-delt *fr(il,1))/(s_wake(il)*rr_wake(il,1)+(1.-s_wake(il))*rr(il,1)))4492 IF (fr(il, 1)<=0.) THEN 4493 alpha_qpos(il) = max(alpha_qpos(il), (-delt * fr(il, 1)) / (s_wake(il) * rr_wake(il, 1) + (1. - s_wake(il)) * rr(il, 1))) 4536 4494 END IF 4537 4495 END IF … … 4540 4498 DO il = 1, ncum 4541 4499 IF (iflag(il)<=1) THEN 4542 IF (fr(il, i)<=0.) THEN4543 alpha_qpos1(il) = max(1., (-delt *fr(il,i))/(s_wake(il)*rr_wake(il,i)+(1.-s_wake(il))*rr(il,i)))4500 IF (fr(il, i)<=0.) THEN 4501 alpha_qpos1(il) = max(1., (-delt * fr(il, i)) / (s_wake(il) * rr_wake(il, i) + (1. - s_wake(il)) * rr(il, i))) 4544 4502 IF (alpha_qpos1(il)>=alpha_qpos(il)) alpha_qpos(il) = alpha_qpos1(il) 4545 4503 END IF … … 4549 4507 DO il = 1, ncum 4550 4508 IF (iflag(il)<=1 .AND. alpha_qpos(il)>1.001) THEN 4551 alpha_qpos(il) = alpha_qpos(il) *1.14509 alpha_qpos(il) = alpha_qpos(il) * 1.1 4552 4510 END IF 4553 4511 END DO 4554 4512 4555 4556 print *,' CV3_YIELD : alpha_qpos ',alpha_qpos(1)4557 4513 IF (prt_level >= 5) THEN 4514 print *, ' CV3_YIELD : alpha_qpos ', alpha_qpos(1) 4515 ENDIF 4558 4516 4559 4517 DO il = 1, ncum 4560 4518 IF (iflag(il)<=1) THEN 4561 sigd(il) = sigd(il) /alpha_qpos(il)4562 precip(il) = precip(il) /alpha_qpos(il)4563 cbmf(il) = cbmf(il) /alpha_qpos(il)4519 sigd(il) = sigd(il) / alpha_qpos(il) 4520 precip(il) = precip(il) / alpha_qpos(il) 4521 cbmf(il) = cbmf(il) / alpha_qpos(il) 4564 4522 END IF 4565 4523 END DO … … 4567 4525 DO il = 1, ncum 4568 4526 IF (iflag(il)<=1) THEN 4569 fr(il, i) = fr(il, i) /alpha_qpos(il)4570 ft(il, i) = ft(il, i) /alpha_qpos(il)4571 fqd(il, i) = fqd(il, i) /alpha_qpos(il)4572 ftd(il, i) = ftd(il, i) /alpha_qpos(il)4573 fu(il, i) = fu(il, i) /alpha_qpos(il)4574 fv(il, i) = fv(il, i) /alpha_qpos(il)4575 m(il, i) = m(il, i) /alpha_qpos(il)4576 mp(il, i) = mp(il, i) /alpha_qpos(il)4577 Vprecip(il, i) = Vprecip(il, i) /alpha_qpos(il)4578 Vprecipi(il, i) = Vprecipi(il, i) /alpha_qpos(il) ! jyg4527 fr(il, i) = fr(il, i) / alpha_qpos(il) 4528 ft(il, i) = ft(il, i) / alpha_qpos(il) 4529 fqd(il, i) = fqd(il, i) / alpha_qpos(il) 4530 ftd(il, i) = ftd(il, i) / alpha_qpos(il) 4531 fu(il, i) = fu(il, i) / alpha_qpos(il) 4532 fv(il, i) = fv(il, i) / alpha_qpos(il) 4533 m(il, i) = m(il, i) / alpha_qpos(il) 4534 mp(il, i) = mp(il, i) / alpha_qpos(il) 4535 Vprecip(il, i) = Vprecip(il, i) / alpha_qpos(il) 4536 Vprecipi(il, i) = Vprecipi(il, i) / alpha_qpos(il) ! jyg 4579 4537 END IF 4580 4538 END DO 4581 4539 END DO 4582 !jyg< 4583 !----------------------------------------------------------- 4584 IF (ok_optim_yield) THEN !| 4585 !----------------------------------------------------------- 4586 DO i = 1, nl 4587 DO il = 1, ncum 4588 IF (iflag(il)<=1) THEN 4589 upwd(il, i) = upwd(il, i)/alpha_qpos(il) 4590 dnwd(il, i) = dnwd(il, i)/alpha_qpos(il) 4591 END IF 4592 END DO 4593 END DO 4594 !----------------------------------------------------------- 4595 ENDIF !(ok_optim_yield) !| 4596 !----------------------------------------------------------- 4597 !>jyg 4598 DO j = 1, nl !yor! inverted i and j loops 4599 DO i = 1, nl 4540 !jyg< 4541 !----------------------------------------------------------- 4542 IF (ok_optim_yield) THEN !| 4543 !----------------------------------------------------------- 4544 DO i = 1, nl 4600 4545 DO il = 1, ncum 4601 4546 IF (iflag(il)<=1) THEN 4602 ment(il, i, j) = ment(il, i, j)/alpha_qpos(il) 4547 upwd(il, i) = upwd(il, i) / alpha_qpos(il) 4548 dnwd(il, i) = dnwd(il, i) / alpha_qpos(il) 4603 4549 END IF 4604 4550 END DO 4605 4551 END DO 4606 END DO 4607 4608 !AC! DO j = 1,ntra 4609 !AC! DO i = 1,nl 4610 !AC! DO il = 1,ncum 4611 !AC! IF (iflag(il) .le. 1) THEN 4612 !AC! ftra(il,i,j) = ftra(il,i,j)/alpha_qpos(il) 4613 !AC! ENDIF 4614 !AC! ENDDO 4615 !AC! ENDDO 4616 !AC! ENDDO 4617 4618 4619 ! *** reset counter and return *** 4620 4621 ! Reset counter only for points actually convective (jyg) 4622 ! In order take into account the possibility of changing the compression, 4623 ! reset m, sig and w0 to zero for non-convecting points. 4552 !----------------------------------------------------------- 4553 ENDIF !(ok_optim_yield) !| 4554 !----------------------------------------------------------- 4555 !>jyg 4556 DO j = 1, nl !yor! inverted i and j loops 4557 DO i = 1, nl 4558 DO il = 1, ncum 4559 IF (iflag(il)<=1) THEN 4560 ment(il, i, j) = ment(il, i, j) / alpha_qpos(il) 4561 END IF 4562 END DO 4563 END DO 4564 END DO 4565 4566 !AC! DO j = 1,ntra 4567 !AC! DO i = 1,nl 4568 !AC! DO il = 1,ncum 4569 !AC! IF (iflag(il) .le. 1) THEN 4570 !AC! ftra(il,i,j) = ftra(il,i,j)/alpha_qpos(il) 4571 !AC! ENDIF 4572 !AC! ENDDO 4573 !AC! ENDDO 4574 !AC! ENDDO 4575 4576 4577 ! *** reset counter and return *** 4578 4579 ! Reset counter only for points actually convective (jyg) 4580 ! In order take into account the possibility of changing the compression, 4581 ! reset m, sig and w0 to zero for non-convecting points. 4624 4582 DO il = 1, ncum 4625 4583 IF (iflag(il) < 3) THEN … … 4628 4586 END DO 4629 4587 4630 4631 4588 DO i = 1, nl 4632 4589 DO il = 1, ncum … … 4634 4591 END DO 4635 4592 END DO 4636 !jyg< (loops stop at nl) 4637 !! DO i = nl + 1, nd 4638 !! DO il = 1, ncum 4639 !! dnwd0(il, i) = 0. 4640 !! END DO 4641 !! END DO 4642 !>jyg 4643 4644 4645 !jyg< 4646 !----------------------------------------------------------- 4647 IF (.NOT.ok_optim_yield) THEN !| 4648 !----------------------------------------------------------- 4649 DO i = 1, nl 4650 DO il = 1, ncum 4651 upwd(il, i) = 0.0 4652 dnwd(il, i) = 0.0 4653 END DO 4654 END DO 4655 4656 !! DO i = 1, nl ! useless; jyg 4657 !! DO il = 1, ncum ! useless; jyg 4658 !! IF (i>=icb(il) .AND. i<=inb(il)) THEN ! useless; jyg 4659 !! upwd(il, i) = 0.0 ! useless; jyg 4660 !! dnwd(il, i) = 0.0 ! useless; jyg 4661 !! END IF ! useless; jyg 4662 !! END DO ! useless; jyg 4663 !! END DO ! useless; jyg 4664 4665 DO i = 1, nl 4666 DO k = 1, nl 4593 !jyg< (loops stop at nl) 4594 !! DO i = nl + 1, nd 4595 !! DO il = 1, ncum 4596 !! dnwd0(il, i) = 0. 4597 !! END DO 4598 !! END DO 4599 !>jyg 4600 4601 4602 !jyg< 4603 !----------------------------------------------------------- 4604 IF (.NOT.ok_optim_yield) THEN !| 4605 !----------------------------------------------------------- 4606 DO i = 1, nl 4667 4607 DO il = 1, ncum 4668 up 1(il, k, i) = 0.04669 dn 1(il, k, i) = 0.04608 upwd(il, i) = 0.0 4609 dnwd(il, i) = 0.0 4670 4610 END DO 4671 4611 END DO 4672 END DO 4673 4674 !yor! commented original 4675 ! DO i = 1, nl 4676 ! DO k = i, nl 4677 ! DO n = 1, i - 1 4678 ! DO il = 1, ncum 4679 ! IF (i>=icb(il) .AND. i<=inb(il) .AND. k<=inb(il)) THEN 4680 ! up1(il, k, i) = up1(il, k, i) + ment(il, n, k) 4681 ! dn1(il, k, i) = dn1(il, k, i) - ment(il, k, n) 4682 ! END IF 4683 ! END DO 4684 ! END DO 4685 ! END DO 4686 ! END DO 4687 !yor! replaced with 4688 DO i = 1, nl 4689 DO k = i, nl 4690 DO n = 1, i - 1 4612 4613 !! DO i = 1, nl ! useless; jyg 4614 !! DO il = 1, ncum ! useless; jyg 4615 !! IF (i>=icb(il) .AND. i<=inb(il)) THEN ! useless; jyg 4616 !! upwd(il, i) = 0.0 ! useless; jyg 4617 !! dnwd(il, i) = 0.0 ! useless; jyg 4618 !! END IF ! useless; jyg 4619 !! END DO ! useless; jyg 4620 !! END DO ! useless; jyg 4621 4622 DO i = 1, nl 4623 DO k = 1, nl 4691 4624 DO il = 1, ncum 4692 IF (i>=icb(il) .AND. k<=inb(il)) THEN ! yor ! as i always <= k 4693 up1(il, k, i) = up1(il, k, i) + ment(il, n, k) 4694 END IF 4625 up1(il, k, i) = 0.0 4626 dn1(il, k, i) = 0.0 4695 4627 END DO 4696 4628 END DO 4697 4629 END DO 4698 END DO 4699 DO i = 1, nl 4700 DO n = 1, i - 1 4630 4631 !yor! commented original 4632 ! DO i = 1, nl 4633 ! DO k = i, nl 4634 ! DO n = 1, i - 1 4635 ! DO il = 1, ncum 4636 ! IF (i>=icb(il) .AND. i<=inb(il) .AND. k<=inb(il)) THEN 4637 ! up1(il, k, i) = up1(il, k, i) + ment(il, n, k) 4638 ! dn1(il, k, i) = dn1(il, k, i) - ment(il, k, n) 4639 ! END IF 4640 ! END DO 4641 ! END DO 4642 ! END DO 4643 ! END DO 4644 !yor! replaced with 4645 DO i = 1, nl 4646 DO k = i, nl 4647 DO n = 1, i - 1 4648 DO il = 1, ncum 4649 IF (i>=icb(il) .AND. k<=inb(il)) THEN ! yor ! as i always <= k 4650 up1(il, k, i) = up1(il, k, i) + ment(il, n, k) 4651 END IF 4652 END DO 4653 END DO 4654 END DO 4655 END DO 4656 DO i = 1, nl 4657 DO n = 1, i - 1 4658 DO k = i, nl 4659 DO il = 1, ncum 4660 IF (i>=icb(il) .AND. k<=inb(il)) THEN ! yor ! i always <= k 4661 dn1(il, k, i) = dn1(il, k, i) - ment(il, k, n) 4662 END IF 4663 END DO 4664 END DO 4665 END DO 4666 END DO 4667 !yor! end replace 4668 4669 DO i = 1, nl 4670 DO k = 1, nl 4671 DO il = 1, ncum 4672 IF (i>=icb(il)) THEN 4673 IF (k>=i .AND. k<=(inb(il))) THEN 4674 upwd(il, i) = upwd(il, i) + m(il, k) 4675 END IF 4676 ELSE 4677 IF (k<i) THEN 4678 upwd(il, i) = upwd(il, i) + cbmf(il) * wghti(il, k) 4679 END IF 4680 END IF 4681 ! c print *,'cbmf',il,i,k,cbmf(il),wghti(il,k) 4682 END DO 4683 END DO 4684 END DO 4685 4686 DO i = 2, nl 4701 4687 DO k = i, nl 4702 4688 DO il = 1, ncum 4703 IF (i>=icb(il) .AND. k<=inb(il)) THEN ! yor ! i always <= k 4704 dn1(il, k, i) = dn1(il, k, i) - ment(il, k, n) 4689 ! test if (i.ge.icb(il).AND.i.le.inb(il).AND.k.le.inb(il)) THEN 4690 IF (i<=inb(il) .AND. k<=inb(il)) THEN 4691 upwd(il, i) = upwd(il, i) + up1(il, k, i) 4692 dnwd(il, i) = dnwd(il, i) + dn1(il, k, i) 4705 4693 END IF 4694 ! c print *,'upwd',il,i,k,inb(il),upwd(il,i),m(il,k),up1(il,k,i) 4706 4695 END DO 4707 4696 END DO 4708 4697 END DO 4709 END DO 4710 !yor! end replace 4711 4712 DO i = 1, nl 4713 DO k = 1, nl 4714 DO il = 1, ncum 4715 IF (i>=icb(il)) THEN 4716 IF (k>=i .AND. k<=(inb(il))) THEN 4717 upwd(il, i) = upwd(il, i) + m(il, k) 4718 END IF 4719 ELSE 4720 IF (k<i) THEN 4721 upwd(il, i) = upwd(il, i) + cbmf(il)*wghti(il, k) 4722 END IF 4723 END IF 4724 ! c print *,'cbmf',il,i,k,cbmf(il),wghti(il,k) 4725 END DO 4726 END DO 4727 END DO 4728 4729 DO i = 2, nl 4730 DO k = i, nl 4731 DO il = 1, ncum 4732 ! test if (i.ge.icb(il).AND.i.le.inb(il).AND.k.le.inb(il)) THEN 4733 IF (i<=inb(il) .AND. k<=inb(il)) THEN 4734 upwd(il, i) = upwd(il, i) + up1(il, k, i) 4735 dnwd(il, i) = dnwd(il, i) + dn1(il, k, i) 4736 END IF 4737 ! c print *,'upwd',il,i,k,inb(il),upwd(il,i),m(il,k),up1(il,k,i) 4738 END DO 4739 END DO 4740 END DO 4741 4742 4743 !!!! DO il=1,ncum 4744 !!!! do i=icb(il),inb(il) 4745 !!!! 4746 !!!! upwd(il,i)=0.0 4747 !!!! dnwd(il,i)=0.0 4748 !!!! do k=i,inb(il) 4749 !!!! up1=0.0 4750 !!!! dn1=0.0 4751 !!!! do n=1,i-1 4752 !!!! up1=up1+ment(il,n,k) 4753 !!!! dn1=dn1-ment(il,k,n) 4754 !!!! enddo 4755 !!!! upwd(il,i)=upwd(il,i)+m(il,k)+up1 4756 !!!! dnwd(il,i)=dnwd(il,i)+dn1 4757 !!!! enddo 4758 !!!! enddo 4759 !!!! 4760 !!!! ENDDO 4761 4762 !! DO i = 1, nlp 4763 !! DO il = 1, ncum 4764 !! ma(il, i) = 0 4765 !! END DO 4766 !! END DO 4767 !! 4768 !! DO i = 1, nl 4769 !! DO j = i, nl 4770 !! DO il = 1, ncum 4771 !! ma(il, i) = ma(il, i) + m(il, j) 4772 !! END DO 4773 !! END DO 4774 !! END DO 4775 4776 !jyg< (loops stop at nl) 4777 !! DO i = nl + 1, nd 4778 !! DO il = 1, ncum 4779 !! ma(il, i) = 0. 4780 !! END DO 4781 !! END DO 4782 !>jyg 4783 4784 !! DO i = 1, nl 4785 !! DO il = 1, ncum 4786 !! IF (i<=(icb(il)-1)) THEN 4787 !! ma(il, i) = 0 4788 !! END IF 4789 !! END DO 4790 !! END DO 4791 4792 !----------------------------------------------------------- 4793 ENDIF !(.NOT.ok_optim_yield) !| 4794 !----------------------------------------------------------- 4795 !>jyg 4796 4797 ! ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc 4798 ! determination de la variation de flux ascendant entre 4799 ! deux niveau non dilue mip 4800 ! ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc 4698 4699 4700 !!!! DO il=1,ncum 4701 !!!! do i=icb(il),inb(il) 4702 !!!! 4703 !!!! upwd(il,i)=0.0 4704 !!!! dnwd(il,i)=0.0 4705 !!!! do k=i,inb(il) 4706 !!!! up1=0.0 4707 !!!! dn1=0.0 4708 !!!! do n=1,i-1 4709 !!!! up1=up1+ment(il,n,k) 4710 !!!! dn1=dn1-ment(il,k,n) 4711 !!!! enddo 4712 !!!! upwd(il,i)=upwd(il,i)+m(il,k)+up1 4713 !!!! dnwd(il,i)=dnwd(il,i)+dn1 4714 !!!! enddo 4715 !!!! enddo 4716 !!!! 4717 !!!! ENDDO 4718 4719 !! DO i = 1, nlp 4720 !! DO il = 1, ncum 4721 !! ma(il, i) = 0 4722 !! END DO 4723 !! END DO 4724 !! 4725 !! DO i = 1, nl 4726 !! DO j = i, nl 4727 !! DO il = 1, ncum 4728 !! ma(il, i) = ma(il, i) + m(il, j) 4729 !! END DO 4730 !! END DO 4731 !! END DO 4732 4733 !jyg< (loops stop at nl) 4734 !! DO i = nl + 1, nd 4735 !! DO il = 1, ncum 4736 !! ma(il, i) = 0. 4737 !! END DO 4738 !! END DO 4739 !>jyg 4740 4741 !! DO i = 1, nl 4742 !! DO il = 1, ncum 4743 !! IF (i<=(icb(il)-1)) THEN 4744 !! ma(il, i) = 0 4745 !! END IF 4746 !! END DO 4747 !! END DO 4748 4749 !----------------------------------------------------------- 4750 ENDIF !(.NOT.ok_optim_yield) !| 4751 !----------------------------------------------------------- 4752 !>jyg 4753 4754 ! ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc 4755 ! determination de la variation de flux ascendant entre 4756 ! deux niveau non dilue mip 4757 ! ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc 4801 4758 4802 4759 DO i = 1, nl … … 4806 4763 END DO 4807 4764 4808 !jyg< (loops stop at nl)4809 !! DO i = nl + 1, nd4810 !! DO il = 1, ncum4811 !! mip(il, i) = 0.4812 !! END DO4813 !! END DO4814 !>jyg4815 4816 4817 ! cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc4818 ! icb represente de niveau ou se trouve la4819 ! base du nuage , et inb le top du nuage4820 ! ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc4821 4822 !! DO i = 1, nd ! unused . jyg4823 !! DO il = 1, ncum ! unused . jyg4824 !! mke(il, i) = upwd(il, i) + dnwd(il, i) ! unused . jyg4825 !! END DO ! unused . jyg4826 !! END DO ! unused . jyg4827 4828 !! DO i = 1, nd ! unused . jyg4829 !! DO il = 1, ncum ! unused . jyg4830 !! rdcp = (rrd*(1.-rr(il,i))-rr(il,i)*rrv)/(cpd*(1.-rr(il,i))+rr(il,i)*cpv) ! unused . jyg4831 !! tls(il, i) = t(il, i)*(1000.0/p(il,i))**rdcp ! unused . jyg4832 !! tps(il, i) = tp(il, i) ! unused . jyg4833 !! END DO ! unused . jyg4834 !! END DO ! unused . jyg4835 4836 4837 ! *** diagnose the in-cloud mixing ratio *** ! cld4838 ! *** of condensed water *** ! cld4839 !! cld 4840 4841 DO i = 1, nl +1 ! cld4765 !jyg< (loops stop at nl) 4766 !! DO i = nl + 1, nd 4767 !! DO il = 1, ncum 4768 !! mip(il, i) = 0. 4769 !! END DO 4770 !! END DO 4771 !>jyg 4772 4773 4774 ! cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc 4775 ! icb represente de niveau ou se trouve la 4776 ! base du nuage , et inb le top du nuage 4777 ! ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc 4778 4779 !! DO i = 1, nd ! unused . jyg 4780 !! DO il = 1, ncum ! unused . jyg 4781 !! mke(il, i) = upwd(il, i) + dnwd(il, i) ! unused . jyg 4782 !! END DO ! unused . jyg 4783 !! END DO ! unused . jyg 4784 4785 !! DO i = 1, nd ! unused . jyg 4786 !! DO il = 1, ncum ! unused . jyg 4787 !! rdcp = (rrd*(1.-rr(il,i))-rr(il,i)*rrv)/(cpd*(1.-rr(il,i))+rr(il,i)*cpv) ! unused . jyg 4788 !! tls(il, i) = t(il, i)*(1000.0/p(il,i))**rdcp ! unused . jyg 4789 !! tps(il, i) = tp(il, i) ! unused . jyg 4790 !! END DO ! unused . jyg 4791 !! END DO ! unused . jyg 4792 4793 4794 ! *** diagnose the in-cloud mixing ratio *** ! cld 4795 ! *** of condensed water *** ! cld 4796 !! cld 4797 4798 DO i = 1, nl + 1 ! cld 4842 4799 DO il = 1, ncum ! cld 4843 4800 mac(il, i) = 0.0 ! cld … … 4847 4804 END DO ! cld 4848 4805 END DO ! cld 4849 4806 4850 4807 DO i = minorig, nl ! cld 4851 4808 DO k = i + 1, nl + 1 ! cld 4852 4809 DO il = 1, ncum ! cld 4853 IF (i<=inb(il) .AND. k<=(inb(il) +1) .AND. iflag(il)<=1) THEN ! cld4810 IF (i<=inb(il) .AND. k<=(inb(il) + 1) .AND. iflag(il)<=1) THEN ! cld 4854 4811 mac(il, i) = mac(il, i) + m(il, k) ! cld 4855 4812 END IF ! cld … … 4861 4818 DO j = 1, i ! cld 4862 4819 DO il = 1, ncum ! cld 4863 IF (i>=icb(il) .AND. i<=(inb(il) -1) & ! cld4864 .AND. j>=icb(il) .AND. iflag(il)<=1) THEN ! cld4865 sax(il, i) = sax(il, i) + rrd *(tvp(il,j)-tv(il,j)) & ! cld4866 *(ph(il,j)-ph(il,j+1))/p(il, j) ! cld4820 IF (i>=icb(il) .AND. i<=(inb(il) - 1) & ! cld 4821 .AND. j>=icb(il) .AND. iflag(il)<=1) THEN ! cld 4822 sax(il, i) = sax(il, i) + rrd * (tvp(il, j) - tv(il, j)) & ! cld 4823 * (ph(il, j) - ph(il, j + 1)) / p(il, j) ! cld 4867 4824 END IF ! cld 4868 4825 END DO ! cld … … 4872 4829 DO i = 1, nl ! cld 4873 4830 DO il = 1, ncum ! cld 4874 IF (i>=icb(il) .AND. i<=(inb(il) -1) & ! cld4875 .AND. sax(il,i)>0.0 .AND. iflag(il)<=1) THEN ! cld4876 wa(il, i) = sqrt(2. *sax(il,i)) ! cld4831 IF (i>=icb(il) .AND. i<=(inb(il) - 1) & ! cld 4832 .AND. sax(il, i)>0.0 .AND. iflag(il)<=1) THEN ! cld 4833 wa(il, i) = sqrt(2. * sax(il, i)) ! cld 4877 4834 END IF ! cld 4878 4835 END DO ! cld 4879 END DO 4880 4881 DO i = 1, nl 4882 4883 ! 14/01/15 AJ je remets les parties manquantes cf JYG4884 ! Initialize sument to 04885 4886 DO il = 1, ncum4887 sument(il) = 0.4836 END DO 4837 ! cld 4838 DO i = 1, nl 4839 4840 ! 14/01/15 AJ je remets les parties manquantes cf JYG 4841 ! Initialize sument to 0 4842 4843 DO il = 1, ncum 4844 sument(il) = 0. 4888 4845 ENDDO 4889 4846 4890 ! Sum mixed mass fluxes in sument4891 4892 DO k = 1, nl4893 DO il = 1, ncum4847 ! Sum mixed mass fluxes in sument 4848 4849 DO k = 1, nl 4850 DO il = 1, ncum 4894 4851 IF (k<=inb(il) .AND. i<=inb(il) .AND. iflag(il)<=1) THEN ! cld 4895 sument(il) = sument(il) + abs(ment(il,k,i))4896 detrain(il, i) = detrain(il,i) + abs(ment(il,k,i))*(qdet(il,k,i) - rr(il,i))*(qdet(il,k,i) - rr(il,i)) ! Louis terme de détrainement dans le bilan de variance4852 sument(il) = sument(il) + abs(ment(il, k, i)) 4853 detrain(il, i) = detrain(il, i) + abs(ment(il, k, i)) * (qdet(il, k, i) - rr(il, i)) * (qdet(il, k, i) - rr(il, i)) ! Louis terme de détrainement dans le bilan de variance 4897 4854 ENDIF 4898 4855 ENDDO ! il 4899 4856 ENDDO ! k 4900 4857 4901 ! 14/01/15 AJ delta n'a rien à faire là...4858 ! 14/01/15 AJ delta n'a rien à faire là... 4902 4859 DO il = 1, ncum ! cld 4903 !! IF (wa(il,i)>0.0 .AND. iflag(il)<=1) & ! cld4904 !! siga(il, i) = mac(il, i)/(coefw_cld_cv*wa(il, i)) & ! cld4905 !! *rrd*tvp(il, i)/p(il, i)/100. ! cld4906 !!4907 !! siga(il, i) = min(siga(il,i), 1.0) ! cld4860 !! IF (wa(il,i)>0.0 .AND. iflag(il)<=1) & ! cld 4861 !! siga(il, i) = mac(il, i)/(coefw_cld_cv*wa(il, i)) & ! cld 4862 !! *rrd*tvp(il, i)/p(il, i)/100. ! cld 4863 !! 4864 !! siga(il, i) = min(siga(il,i), 1.0) ! cld 4908 4865 sigaq = 0. 4909 IF (wa(il, i)>0.0 .AND. iflag(il)<=1) THEN ! cld4910 siga(il, i) = mac(il, i) /(coefw_cld_cv*wa(il, i)) & ! cld4911 *rrd*tvp(il, i)/p(il, i)/100. ! cld4912 siga(il, i) = min(siga(il, i), 1.0) ! cld4913 sigaq = siga(il, i)*qta(il,i-1) ! cld4866 IF (wa(il, i)>0.0 .AND. iflag(il)<=1) THEN ! cld 4867 siga(il, i) = mac(il, i) / (coefw_cld_cv * wa(il, i)) & ! cld 4868 * rrd * tvp(il, i) / p(il, i) / 100. ! cld 4869 siga(il, i) = min(siga(il, i), 1.0) ! cld 4870 sigaq = siga(il, i) * qta(il, i - 1) ! cld 4914 4871 ENDIF 4915 4872 4916 ! IM cf. FH 4917 ! 14/01/15 AJ ne correspond pas à ce qui a été codé par JYG et SB4918 4873 ! IM cf. FH 4874 ! 14/01/15 AJ ne correspond pas à ce qui a été codé par JYG et SB 4875 4919 4876 IF (iflag_clw==0) THEN ! cld 4920 qcondc(il, i) = siga(il, i)*clw(il, i)*(1.-ep(il,i)) & ! cld 4921 +(1.-siga(il,i))*qcond(il, i) ! cld 4922 4923 4924 sigment(il,i)=sument(il)*tau_cld_cv/(ph(il,i)-ph(il,i+1)) ! cld 4925 sigment(il, i) = min(1.e-4+sigment(il,i), 1.0 - siga(il,i)) ! cld 4926 !! qtc(il, i) = (siga(il,i)*qta(il,i-1)+sigment(il,i)*qtment(il,i)) & ! cld 4927 qtc(il, i) = (sigaq+sigment(il,i)*qtment(il,i)) & ! cld 4928 /(siga(il,i)+sigment(il,i)) ! cld 4929 sigt(il,i) = sigment(il, i) + siga(il, i) 4930 4931 ! qtc(il, i) = siga(il,i)*qta(il,i-1)+(1.-siga(il,i))*qtment(il,i) ! cld 4932 ! PRINT*,'BIGAUSSIAN CONV',siga(il,i),sigment(il,i),qtc(il,i) 4933 4877 qcondc(il, i) = siga(il, i) * clw(il, i) * (1. - ep(il, i)) & ! cld 4878 + (1. - siga(il, i)) * qcond(il, i) ! cld 4879 4880 sigment(il, i) = sument(il) * tau_cld_cv / (ph(il, i) - ph(il, i + 1)) ! cld 4881 sigment(il, i) = min(1.e-4 + sigment(il, i), 1.0 - siga(il, i)) ! cld 4882 !! qtc(il, i) = (siga(il,i)*qta(il,i-1)+sigment(il,i)*qtment(il,i)) & ! cld 4883 qtc(il, i) = (sigaq + sigment(il, i) * qtment(il, i)) & ! cld 4884 / (siga(il, i) + sigment(il, i)) ! cld 4885 sigt(il, i) = sigment(il, i) + siga(il, i) 4886 4887 ! qtc(il, i) = siga(il,i)*qta(il,i-1)+(1.-siga(il,i))*qtment(il,i) ! cld 4888 ! PRINT*,'BIGAUSSIAN CONV',siga(il,i),sigment(il,i),qtc(il,i) 4889 4934 4890 ELSE IF (iflag_clw==1) THEN ! cld 4935 4891 qcondc(il, i) = qcond(il, i) ! cld 4936 qtc(il, i) = qtment(il,i) ! cld4892 qtc(il, i) = qtment(il, i) ! cld 4937 4893 END IF ! cld 4938 4894 4939 4895 END DO ! cld 4940 4896 END DO 4941 ! PRINT*,'cv3_yield fin' 4942 4897 ! PRINT*,'cv3_yield fin' 4943 4898 4944 4899 END SUBROUTINE cv3_yield … … 4946 4901 !AC! et !RomP >>> 4947 4902 SUBROUTINE cv3_tracer(nloc, len, ncum, nd, na, & 4948 ment, sigij, da, phi, phi2, d1a, dam, & 4949 ep, Vprecip, elij, clw, epmlmMm, eplaMm, & 4950 icb, inb) 4903 ment, sigij, da, phi, phi2, d1a, dam, & 4904 ep, Vprecip, elij, clw, epmlmMm, eplaMm, & 4905 icb, inb) 4906 4907 USE lmdz_cv3param 4908 4951 4909 IMPLICIT NONE 4952 4910 4953 include "cv3param.h" 4954 4955 !inputs: 4956 INTEGER, INTENT (IN) :: ncum, nd, na, nloc, len 4957 INTEGER, DIMENSION (len), INTENT (IN) :: icb, inb 4958 REAL, DIMENSION (len, na, na), INTENT (IN) :: ment, sigij, elij 4959 REAL, DIMENSION (len, nd), INTENT (IN) :: clw 4960 REAL, DIMENSION (len, na), INTENT (IN) :: ep 4961 REAL, DIMENSION (len, nd+1), INTENT (IN) :: Vprecip 4962 !ouputs: 4963 REAL, DIMENSION (len, na, na), INTENT (OUT) :: phi, phi2, epmlmMm 4964 REAL, DIMENSION (len, na), INTENT (OUT) :: da, d1a, dam, eplaMm 4965 4966 ! variables pour tracer dans precip de l'AA et des mel 4967 !local variables: 4911 4912 !inputs: 4913 INTEGER, INTENT (IN) :: ncum, nd, na, nloc, len 4914 INTEGER, DIMENSION (len), INTENT (IN) :: icb, inb 4915 REAL, DIMENSION (len, na, na), INTENT (IN) :: ment, sigij, elij 4916 REAL, DIMENSION (len, nd), INTENT (IN) :: clw 4917 REAL, DIMENSION (len, na), INTENT (IN) :: ep 4918 REAL, DIMENSION (len, nd + 1), INTENT (IN) :: Vprecip 4919 !ouputs: 4920 REAL, DIMENSION (len, na, na), INTENT (OUT) :: phi, phi2, epmlmMm 4921 REAL, DIMENSION (len, na), INTENT (OUT) :: da, d1a, dam, eplaMm 4922 4923 ! variables pour tracer dans precip de l'AA et des mel 4924 !local variables: 4968 4925 INTEGER i, j, k 4969 4926 REAL epm(nloc, na, na) 4970 4927 4971 ! variables d'Emanuel : du second indice au troisieme4972 ! ---> tab(i,k,j) -> de l origine k a l arrivee j4973 ! ment, sigij, elij4974 ! variables personnelles : du troisieme au second indice4975 ! ---> tab(i,j,k) -> de k a j4976 ! phi, phi24977 4978 ! initialisations4928 ! variables d'Emanuel : du second indice au troisieme 4929 ! ---> tab(i,k,j) -> de l origine k a l arrivee j 4930 ! ment, sigij, elij 4931 ! variables personnelles : du troisieme au second indice 4932 ! ---> tab(i,j,k) -> de k a j 4933 ! phi, phi2 4934 4935 ! initialisations 4979 4936 4980 4937 da(:, :) = 0. … … 4987 4944 phi2(:, :, :) = 0. 4988 4945 4989 ! fraction deau condensee dans les melanges convertie en precip : epm4990 ! et eau condensée précipitée dans masse d'air saturé : l_m*dM_m/dzdz.dzdz4946 ! fraction deau condensee dans les melanges convertie en precip : epm 4947 ! et eau condensée précipitée dans masse d'air saturé : l_m*dM_m/dzdz.dzdz 4991 4948 DO j = 1, nl 4992 4949 DO k = 1, nl 4993 4950 DO i = 1, ncum 4994 IF (k>=icb(i) .AND. k<=inb(i) .AND. & 4995 !!jyg j.ge.k.AND.j.le.inb(i)) THEN4996 !!jyg epm(i,j,k)=1.-(1.-ep(i,j))*clw(i,j)/elij(i,k,j)4997 j>k .AND. j<=inb(i)) THEN4998 epm(i, j, k) = 1. - (1. -ep(i,j))*clw(i, j)/max(elij(i,k,j), 1.E-16)4999 !!5000 epm(i, j, k) = max(epm(i, j,k), 0.0)4951 IF (k>=icb(i) .AND. k<=inb(i) .AND. & 4952 !!jyg j.ge.k.AND.j.le.inb(i)) THEN 4953 !!jyg epm(i,j,k)=1.-(1.-ep(i,j))*clw(i,j)/elij(i,k,j) 4954 j>k .AND. j<=inb(i)) THEN 4955 epm(i, j, k) = 1. - (1. - ep(i, j)) * clw(i, j) / max(elij(i, k, j), 1.E-16) 4956 !! 4957 epm(i, j, k) = max(epm(i, j, k), 0.0) 5001 4958 END IF 5002 4959 END DO 5003 4960 END DO 5004 4961 END DO 5005 5006 4962 5007 4963 DO j = 1, nl … … 5010 4966 IF (k>=icb(i) .AND. k<=inb(i)) THEN 5011 4967 eplaMm(i, j) = eplamm(i, j) + & 5012 ep(i, j)*clw(i, j)*ment(i, j, k)*(1.-sigij(i,j,k))4968 ep(i, j) * clw(i, j) * ment(i, j, k) * (1. - sigij(i, j, k)) 5013 4969 END IF 5014 4970 END DO … … 5020 4976 DO i = 1, ncum 5021 4977 IF (k>=icb(i) .AND. k<=inb(i) .AND. j<=inb(i)) THEN 5022 epmlmMm(i, j, k) = epm(i, j, k) *elij(i, k, j)*ment(i, k, j)4978 epmlmMm(i, j, k) = epm(i, j, k) * elij(i, k, j) * ment(i, k, j) 5023 4979 END IF 5024 4980 END DO … … 5026 4982 END DO 5027 4983 5028 ! matrices pour calculer la tendance des concentrations dans cvltr.F904984 ! matrices pour calculer la tendance des concentrations dans cvltr.F90 5029 4985 DO j = 1, nl 5030 4986 DO k = 1, nl 5031 4987 DO i = 1, ncum 5032 da(i, j) = da(i, j) + (1. -sigij(i,k,j))*ment(i, k, j)5033 phi(i, j, k) = sigij(i, k, j) *ment(i, k, j)5034 d1a(i, j) = d1a(i, j) + ment(i, k, j) *ep(i, k)*(1.-sigij(i,k,j))4988 da(i, j) = da(i, j) + (1. - sigij(i, k, j)) * ment(i, k, j) 4989 phi(i, j, k) = sigij(i, k, j) * ment(i, k, j) 4990 d1a(i, j) = d1a(i, j) + ment(i, k, j) * ep(i, k) * (1. - sigij(i, k, j)) 5035 4991 IF (k<=j) THEN 5036 dam(i, j) = dam(i, j) + ment(i, k, j) *epm(i, k, j)*(1.-ep(i,k))*(1.-sigij(i,k,j))5037 phi2(i, j, k) = phi(i, j, k) *epm(i, j, k)4992 dam(i, j) = dam(i, j) + ment(i, k, j) * epm(i, k, j) * (1. - ep(i, k)) * (1. - sigij(i, k, j)) 4993 phi2(i, j, k) = phi(i, j, k) * epm(i, j, k) 5038 4994 END IF 5039 4995 END DO … … 5041 4997 END DO 5042 4998 5043 5044 4999 END SUBROUTINE cv3_tracer 5045 5000 !AC! et !RomP <<< 5046 5001 5047 5002 SUBROUTINE cv3_uncompress(nloc, len, ncum, nd, ntra, idcum, & 5048 iflag, & 5049 precip, sig, w0, & 5050 ft, fq, fu, fv, ftra, & 5051 Ma, upwd, dnwd, dnwd0, qcondc, wd, cape, & 5052 epmax_diag, & ! epmax_cape 5053 iflag1, & 5054 precip1, sig1, w01, & 5055 ft1, fq1, fu1, fv1, ftra1, & 5056 Ma1, upwd1, dnwd1, dnwd01, qcondc1, wd1, cape1, & 5057 epmax_diag1) ! epmax_cape 5003 iflag, & 5004 precip, sig, w0, & 5005 ft, fq, fu, fv, ftra, & 5006 Ma, upwd, dnwd, dnwd0, qcondc, wd, cape, & 5007 epmax_diag, & ! epmax_cape 5008 iflag1, & 5009 precip1, sig1, w01, & 5010 ft1, fq1, fu1, fv1, ftra1, & 5011 Ma1, upwd1, dnwd1, dnwd01, qcondc1, wd1, cape1, & 5012 epmax_diag1) ! epmax_cape 5013 5014 USE lmdz_cv3param 5015 5058 5016 IMPLICIT NONE 5059 5017 5060 include "cv3param.h" 5061 5062 !inputs: 5018 !inputs: 5063 5019 INTEGER len, ncum, nd, ntra, nloc 5064 5020 INTEGER idcum(nloc) … … 5074 5030 REAL epmax_diag(nloc) 5075 5031 5076 !outputs:5032 !outputs: 5077 5033 INTEGER iflag1(len) 5078 5034 REAL precip1(len) … … 5086 5042 REAL epmax_diag1(len) ! epmax_cape 5087 5043 5088 !local variables:5044 !local variables: 5089 5045 INTEGER i, k, j 5090 5046 … … 5094 5050 wd1(idcum(i)) = wd(i) 5095 5051 cape1(idcum(i)) = cape(i) 5096 epmax_diag1(idcum(i)) =epmax_diag(i) ! epmax_cape5052 epmax_diag1(idcum(i)) = epmax_diag(i) ! epmax_cape 5097 5053 END DO 5098 5054 … … 5118 5074 5119 5075 5120 !AC! do 2100 j=1,ntra 5121 !AC!c oct3 do 2110 k=1,nl 5122 !AC! do 2110 k=1,nd ! oct3 5123 !AC! do 2120 i=1,ncum 5124 !AC! ftra1(idcum(i),k,j)=ftra(i,k,j) 5125 !AC! 2120 continue 5126 !AC! 2110 continue 5127 !AC! 2100 continue 5128 5076 !AC! do 2100 j=1,ntra 5077 !AC!c oct3 do 2110 k=1,nl 5078 !AC! do 2110 k=1,nd ! oct3 5079 !AC! do 2120 i=1,ncum 5080 !AC! ftra1(idcum(i),k,j)=ftra(i,k,j) 5081 !AC! 2120 continue 5082 !AC! 2110 continue 5083 !AC! 2100 continue 5129 5084 5130 5085 END SUBROUTINE cv3_uncompress 5131 5086 5132 5087 5133 SUBROUTINE cv3_epmax_fn_cape(nloc,ncum,nd & 5134 , ep,hp,icb,inb,clw,nk,t,h,hnk,lv,lf,frac & 5135 , pbase, p, ph, tv, buoy, sig, w0,iflag & 5136 , epmax_diag) 5137 USE lmdz_conema3 5138 USE lmdz_cvflag 5139 5140 IMPLICIT NONE 5141 5142 ! On fait varier epmax en fn de la cape 5143 ! Il faut donc recalculer ep, et hp qui a déjà été calculé et 5144 ! qui en dépend 5145 ! Toutes les autres variables fn de ep sont calculées plus bas. 5146 5147 include "cvthermo.h" 5148 include "cv3param.h" 5149 5150 ! inputs: 5151 INTEGER, INTENT (IN) :: ncum, nd, nloc 5152 INTEGER, DIMENSION (nloc), INTENT (IN) :: icb, inb, nk 5153 REAL, DIMENSION (nloc), INTENT (IN) :: hnk,pbase 5154 REAL, DIMENSION (nloc, nd), INTENT (IN) :: t, lv, lf, tv, h 5155 REAL, DIMENSION (nloc, nd), INTENT (IN) :: clw, buoy,frac 5156 REAL, DIMENSION (nloc, nd), INTENT (IN) :: sig,w0 5157 INTEGER, DIMENSION (nloc), INTENT (IN) :: iflag(nloc) 5158 REAL, DIMENSION (nloc, nd), INTENT (IN) :: p 5159 REAL, DIMENSION (nloc, nd+1), INTENT (IN) :: ph 5160 ! inouts: 5161 REAL, DIMENSION (nloc, nd), INTENT (INOUT) :: ep,hp 5162 ! outputs 5163 REAL, DIMENSION (nloc), INTENT (OUT) :: epmax_diag 5164 5165 ! local 5166 INTEGER i,k 5167 ! real hp_bak(nloc,nd) 5168 ! real ep_bak(nloc,nd) 5169 REAL m_loc(nloc,nd) 5170 REAL sig_loc(nloc,nd) 5171 REAL w0_loc(nloc,nd) 5172 INTEGER iflag_loc(nloc) 5173 REAL cape(nloc) 5174 5175 IF (coef_epmax_cape>1e-12) THEN 5176 ! il faut calculer la cape: on fait un calcule simple car tant qu'on ne 5177 ! connait pas ep, on ne connait pas les mélanges, ddfts etc... qui sont 5178 ! necessaires au calcul de la cape dans la nouvelle physique 5179 5180 ! WRITE(*,*) 'cv3_routines check 4303' 5181 do i=1,ncum 5182 do k=1,nd 5183 sig_loc(i,k)=sig(i,k) 5184 w0_loc(i,k)=w0(i,k) 5185 iflag_loc(i)=iflag(i) 5186 ! ep_bak(i,k)=ep(i,k) 5187 enddo ! do k=1,nd 5188 enddo !do i=1,ncum 5189 5190 ! WRITE(*,*) 'cv3_routines check 4311' 5191 ! WRITE(*,*) 'nl=',nl 5192 CALL cv3_closure(nloc, ncum, nd, icb, inb, & ! na->nd 5193 pbase, p, ph, tv, buoy, & 5194 sig_loc, w0_loc, cape, m_loc,iflag_loc) 5195 5196 ! WRITE(*,*) 'cv3_routines check 4316' 5197 ! WRITE(*,*) 'ep(1,:)=',ep(1,:) 5198 do i=1,ncum 5199 epmax_diag(i)=epmax-coef_epmax_cape*sqrt(cape(i)) 5200 epmax_diag(i)=amax1(epmax_diag(i),0.0) 5201 ! WRITE(*,*) 'i,icb,inb,cape,epmax_diag=', & 5202 ! i,icb(i),inb(i),cape(i),epmax_diag(i) 5203 do k=1,nl 5204 ep(i,k)=ep(i,k)/epmax*epmax_diag(i) 5205 ep(i,k)=amax1(ep(i,k),0.0) 5206 ep(i,k)=amin1(ep(i,k),epmax_diag(i)) 5207 enddo 5088 SUBROUTINE cv3_epmax_fn_cape(nloc, ncum, nd, ep, hp, icb, inb, clw, nk, t, h, hnk, lv, lf, frac & 5089 , pbase, p, ph, tv, buoy, sig, w0, iflag, epmax_diag) 5090 USE lmdz_conema3 5091 USE lmdz_cvflag 5092 USE lmdz_cvthermo 5093 USE lmdz_cv3param 5094 5095 IMPLICIT NONE 5096 5097 ! On fait varier epmax en fn de la cape 5098 ! Il faut donc recalculer ep, et hp qui a déjà été calculé et 5099 ! qui en dépend 5100 ! Toutes les autres variables fn de ep sont calculées plus bas. 5101 5102 ! inputs: 5103 INTEGER, INTENT (IN) :: ncum, nd, nloc 5104 INTEGER, DIMENSION (nloc), INTENT (IN) :: icb, inb, nk 5105 REAL, DIMENSION (nloc), INTENT (IN) :: hnk, pbase 5106 REAL, DIMENSION (nloc, nd), INTENT (IN) :: t, lv, lf, tv, h 5107 REAL, DIMENSION (nloc, nd), INTENT (IN) :: clw, buoy, frac 5108 REAL, DIMENSION (nloc, nd), INTENT (IN) :: sig, w0 5109 INTEGER, DIMENSION (nloc), INTENT (IN) :: iflag(nloc) 5110 REAL, DIMENSION (nloc, nd), INTENT (IN) :: p 5111 REAL, DIMENSION (nloc, nd + 1), INTENT (IN) :: ph 5112 ! inouts: 5113 REAL, DIMENSION (nloc, nd), INTENT (INOUT) :: ep, hp 5114 ! outputs 5115 REAL, DIMENSION (nloc), INTENT (OUT) :: epmax_diag 5116 5117 ! local 5118 INTEGER i, k 5119 ! real hp_bak(nloc,nd) 5120 ! real ep_bak(nloc,nd) 5121 REAL m_loc(nloc, nd) 5122 REAL sig_loc(nloc, nd) 5123 REAL w0_loc(nloc, nd) 5124 INTEGER iflag_loc(nloc) 5125 REAL cape(nloc) 5126 5127 IF (coef_epmax_cape>1e-12) THEN 5128 ! il faut calculer la cape: on fait un calcule simple car tant qu'on ne 5129 ! connait pas ep, on ne connait pas les mélanges, ddfts etc... qui sont 5130 ! necessaires au calcul de la cape dans la nouvelle physique 5131 5132 ! WRITE(*,*) 'cv3_routines check 4303' 5133 do i = 1, ncum 5134 do k = 1, nd 5135 sig_loc(i, k) = sig(i, k) 5136 w0_loc(i, k) = w0(i, k) 5137 iflag_loc(i) = iflag(i) 5138 ! ep_bak(i,k)=ep(i,k) 5139 enddo ! do k=1,nd 5140 enddo !do i=1,ncum 5141 5142 ! WRITE(*,*) 'cv3_routines check 4311' 5143 ! WRITE(*,*) 'nl=',nl 5144 CALL cv3_closure(nloc, ncum, nd, icb, inb, & ! na->nd 5145 pbase, p, ph, tv, buoy, & 5146 sig_loc, w0_loc, cape, m_loc, iflag_loc) 5147 5148 ! WRITE(*,*) 'cv3_routines check 4316' 5149 ! WRITE(*,*) 'ep(1,:)=',ep(1,:) 5150 do i = 1, ncum 5151 epmax_diag(i) = epmax - coef_epmax_cape * sqrt(cape(i)) 5152 epmax_diag(i) = amax1(epmax_diag(i), 0.0) 5153 ! WRITE(*,*) 'i,icb,inb,cape,epmax_diag=', & 5154 ! i,icb(i),inb(i),cape(i),epmax_diag(i) 5155 do k = 1, nl 5156 ep(i, k) = ep(i, k) / epmax * epmax_diag(i) 5157 ep(i, k) = amax1(ep(i, k), 0.0) 5158 ep(i, k) = amin1(ep(i, k), epmax_diag(i)) 5159 enddo 5160 enddo 5161 ! WRITE(*,*) 'ep(1,:)=',ep(1,:) 5162 5163 !WRITE(*,*) 'cv3_routines check 4326' 5164 ! On recalcule hp: 5165 ! do k=1,nl 5166 ! do i=1,ncum 5167 ! hp_bak(i,k)=hp(i,k) 5168 ! enddo 5169 ! enddo 5170 do k = 1, nl 5171 do i = 1, ncum 5172 hp(i, k) = h(i, k) 5173 enddo 5174 enddo 5175 5176 IF (cvflag_ice) THEN 5177 5178 do k = minorig + 1, nl 5179 do i = 1, ncum 5180 IF((k>=icb(i)).AND.(k<=inb(i)))THEN 5181 hp(i, k) = hnk(i) + (lv(i, k) + (cpd - cpv) * t(i, k) + frac(i, k) * lf(i, k)) * & 5182 ep(i, k) * clw(i, k) 5183 endif 5208 5184 enddo 5209 ! WRITE(*,*) 'ep(1,:)=',ep(1,:) 5210 5211 !WRITE(*,*) 'cv3_routines check 4326' 5212 ! On recalcule hp: 5213 ! do k=1,nl 5214 ! do i=1,ncum 5215 ! hp_bak(i,k)=hp(i,k) 5216 ! enddo 5217 ! enddo 5218 do k=1,nl 5219 do i=1,ncum 5220 hp(i,k)=h(i,k) 5185 enddo !do k=minorig+1,n 5186 ELSE !IF (cvflag_ice) THEN 5187 5188 DO k = minorig + 1, nl 5189 DO i = 1, ncum 5190 IF ((k>=icb(i)) .AND. (k<=inb(i))) THEN 5191 hp(i, k) = hnk(i) + (lv(i, k) + (cpd - cpv) * t(i, k)) * ep(i, k) * clw(i, k) 5192 endif 5221 5193 enddo 5222 enddo5223 5224 IF (cvflag_ice) THEN5225 5226 do k=minorig+1,nl5227 do i=1,ncum5228 IF((k>=icb(i)).AND.(k<=inb(i)))THEN5229 hp(i, k) = hnk(i) + (lv(i,k)+(cpd-cpv)*t(i,k)+frac(i,k)*lf(i,k))* &5230 ep(i, k)*clw(i, k)5231 endif5232 enddo5233 5194 enddo !do k=minorig+1,n 5234 ELSE !IF (cvflag_ice) THEN 5235 5236 DO k = minorig + 1, nl 5237 DO i = 1, ncum 5238 IF ((k>=icb(i)) .AND. (k<=inb(i))) THEN 5239 hp(i,k)=hnk(i)+(lv(i,k)+(cpd-cpv)*t(i,k))*ep(i,k)*clw(i,k) 5240 endif 5241 enddo 5242 enddo !do k=minorig+1,n 5243 5244 ENDIF !IF (cvflag_ice) THEN 5245 !WRITE(*,*) 'cv3_routines check 4345' 5246 ! do i=1,ncum 5247 ! do k=1,nl 5248 ! if ((abs(hp_bak(i,k)-hp(i,k))/hp_bak(i,k).gt.1e-1).OR. & 5249 ! ((abs(hp_bak(i,k)-hp(i,k))/hp_bak(i,k).gt.1e-4).AND. & 5250 ! (ep(i,k)-ep_bak(i,k).lt.1e-4))) THEN 5251 ! WRITE(*,*) 'i,k=',i,k 5252 ! WRITE(*,*) 'coef_epmax_cape=',coef_epmax_cape 5253 ! WRITE(*,*) 'epmax_diag(i)=',epmax_diag(i) 5254 ! WRITE(*,*) 'ep(i,k)=',ep(i,k) 5255 ! WRITE(*,*) 'ep_bak(i,k)=',ep_bak(i,k) 5256 ! WRITE(*,*) 'hp(i,k)=',hp(i,k) 5257 ! WRITE(*,*) 'hp_bak(i,k)=',hp_bak(i,k) 5258 ! WRITE(*,*) 'h(i,k)=',h(i,k) 5259 ! WRITE(*,*) 'nk(i)=',nk(i) 5260 ! WRITE(*,*) 'h(i,nk(i))=',h(i,nk(i)) 5261 ! WRITE(*,*) 'lv(i,k)=',lv(i,k) 5262 ! WRITE(*,*) 't(i,k)=',t(i,k) 5263 ! WRITE(*,*) 'clw(i,k)=',clw(i,k) 5264 ! WRITE(*,*) 'cpd,cpv=',cpd,cpv 5265 ! stop 5266 ! endif 5267 ! enddo !do k=1,nl 5268 ! enddo !do i=1,ncum 5269 endif !if (coef_epmax_cape.gt.1e-12) THEN 5270 !WRITE(*,*) 'cv3_routines check 4367' 5271 5272 5273 END SUBROUTINE cv3_epmax_fn_cape 5274 5275 5276 5195 5196 ENDIF !IF (cvflag_ice) THEN 5197 !WRITE(*,*) 'cv3_routines check 4345' 5198 ! do i=1,ncum 5199 ! do k=1,nl 5200 ! if ((abs(hp_bak(i,k)-hp(i,k))/hp_bak(i,k).gt.1e-1).OR. & 5201 ! ((abs(hp_bak(i,k)-hp(i,k))/hp_bak(i,k).gt.1e-4).AND. & 5202 ! (ep(i,k)-ep_bak(i,k).lt.1e-4))) THEN 5203 ! WRITE(*,*) 'i,k=',i,k 5204 ! WRITE(*,*) 'coef_epmax_cape=',coef_epmax_cape 5205 ! WRITE(*,*) 'epmax_diag(i)=',epmax_diag(i) 5206 ! WRITE(*,*) 'ep(i,k)=',ep(i,k) 5207 ! WRITE(*,*) 'ep_bak(i,k)=',ep_bak(i,k) 5208 ! WRITE(*,*) 'hp(i,k)=',hp(i,k) 5209 ! WRITE(*,*) 'hp_bak(i,k)=',hp_bak(i,k) 5210 ! WRITE(*,*) 'h(i,k)=',h(i,k) 5211 ! WRITE(*,*) 'nk(i)=',nk(i) 5212 ! WRITE(*,*) 'h(i,nk(i))=',h(i,nk(i)) 5213 ! WRITE(*,*) 'lv(i,k)=',lv(i,k) 5214 ! WRITE(*,*) 't(i,k)=',t(i,k) 5215 ! WRITE(*,*) 'clw(i,k)=',clw(i,k) 5216 ! WRITE(*,*) 'cpd,cpv=',cpd,cpv 5217 ! stop 5218 ! endif 5219 ! enddo !do k=1,nl 5220 ! enddo !do i=1,ncum 5221 endif !if (coef_epmax_cape.gt.1e-12) THEN 5222 !WRITE(*,*) 'cv3_routines check 4367' 5223 5224 END SUBROUTINE cv3_epmax_fn_cape 5225 5226 5227 -
LMDZ6/branches/Amaury_dev/libf/phylmd/cv3a_compress.F90
r5117 r5141 29 29 ! ************************************************************** 30 30 USE lmdz_abort_physic, ONLY: abort_physic 31 USE lmdz_cv3param 32 31 33 IMPLICIT NONE 32 33 include "cv3param.h"34 34 35 35 ! inputs: -
LMDZ6/branches/Amaury_dev/libf/phylmd/cv3a_uncompress.F90
r5105 r5141 38 38 ! ************************************************************** 39 39 40 USE lmdz_cv3param 41 40 42 IMPLICIT NONE 41 42 include "cv3param.h"43 43 44 44 ! inputs: -
LMDZ6/branches/Amaury_dev/libf/phylmd/cv3p1_closure.F90
r5140 r5141 22 22 USE lmdz_abort_physic, ONLY: abort_physic 23 23 USE lmdz_conema3 24 USE lmdz_cvthermo 25 USE lmdz_cv3param 24 26 25 27 IMPLICIT NONE 26 28 27 include "cvthermo.h"28 include "cv3param.h"29 29 include "YOMCST2.h" 30 30 include "YOMCST.h" -
LMDZ6/branches/Amaury_dev/libf/phylmd/cv3p2_closure.F90
r5140 r5141 22 22 USE lmdz_conema3 23 23 USE lmdz_cvflag 24 USE lmdz_cvthermo 25 USE lmdz_cv3param 24 26 25 27 IMPLICIT NONE 26 28 27 include "cvthermo.h"28 include "cv3param.h"29 29 include "YOMCST2.h" 30 30 include "YOMCST.h" -
LMDZ6/branches/Amaury_dev/libf/phylmd/cv3p_mixing.F90
r5140 r5141 17 17 USE add_phys_tend_mod, ONLY: fl_cor_ebil 18 18 USE lmdz_cvflag 19 USE lmdz_cvthermo 20 USE lmdz_cv3param 19 21 20 22 IMPLICIT NONE 21 23 22 include "cvthermo.h"23 include "cv3param.h"24 24 include "YOMCST2.h" 25 25 -
LMDZ6/branches/Amaury_dev/libf/phylmd/cv_driver.F90
r5140 r5141 12 12 13 13 USE dimphy 14 USE lmdz_cv30, ONLY: cv30_param, cv30_prelim, cv30_feed, cv30_undilute1, cv30_trigger, cv30_compress, cv30_undilute2, & 15 cv30_closure, cv30_epmax_fn_cape, cv30_mixing, cv30_unsat, cv30_yield, cv30_tracer, cv30_uncompress 16 14 17 IMPLICIT NONE 15 18 … … 714 717 ! ================================================================== 715 718 SUBROUTINE cv_thermo(iflag_con) 719 USE lmdz_cvthermo 720 716 721 IMPLICIT NONE 717 722 … … 721 726 722 727 include "YOMCST.h" 723 include "cvthermo.h"724 728 725 729 INTEGER iflag_con -
LMDZ6/branches/Amaury_dev/libf/phylmd/cv_routines.F90
r5117 r5141 1 2 1 ! $Id$ 3 2 … … 38 37 include "cvparam.h" 39 38 INTEGER nd 40 CHARACTER (LEN =20) :: modname = 'cv_routines'41 CHARACTER (LEN =80) :: abort_message39 CHARACTER (LEN = 20) :: modname = 'cv_routines' 40 CHARACTER (LEN = 80) :: abort_message 42 41 43 42 ! noff: integer limit for convection (nd-noff) … … 71 70 delta = 0.01 ! cld 72 71 73 74 72 END SUBROUTINE cv_param 75 73 76 74 SUBROUTINE cv_prelim(len, nd, ndp1, t, q, p, ph, lv, cpn, tv, gz, h, hm) 75 USE lmdz_cvthermo 76 77 77 IMPLICIT NONE 78 78 … … 93 93 REAL cpx(len, nd) 94 94 95 include "cvthermo.h"96 95 include "cvparam.h" 97 98 96 99 97 DO k = 1, nlp 100 98 DO i = 1, len 101 lv(i, k) = lv0 - clmcpv *(t(i,k)-t0)102 cpn(i, k) = cpd *(1.0-q(i,k)) + cpv*q(i, k)103 cpx(i, k) = cpd *(1.0-q(i,k)) + cl*q(i, k)104 tv(i, k) = t(i, k) *(1.0+q(i,k)*epsim1)99 lv(i, k) = lv0 - clmcpv * (t(i, k) - t0) 100 cpn(i, k) = cpd * (1.0 - q(i, k)) + cpv * q(i, k) 101 cpx(i, k) = cpd * (1.0 - q(i, k)) + cl * q(i, k) 102 tv(i, k) = t(i, k) * (1.0 + q(i, k) * epsim1) 105 103 END DO 106 104 END DO … … 113 111 DO k = 2, nlp 114 112 DO i = 1, len 115 gz(i, k) = gz(i, k -1) + hrd*(tv(i,k-1)+tv(i,k))*(p(i,k-1)-p(i,k))/ph(i, &116 k)113 gz(i, k) = gz(i, k - 1) + hrd * (tv(i, k - 1) + tv(i, k)) * (p(i, k - 1) - p(i, k)) / ph(i, & 114 k) 117 115 END DO 118 116 END DO … … 123 121 DO k = 1, nlp 124 122 DO i = 1, len 125 h(i, k) = gz(i, k) + cpn(i, k)*t(i, k) 126 hm(i, k) = gz(i, k) + cpx(i, k)*(t(i,k)-t(i,1)) + lv(i, k)*q(i, k) 127 END DO 128 END DO 129 123 h(i, k) = gz(i, k) + cpn(i, k) * t(i, k) 124 hm(i, k) = gz(i, k) + cpx(i, k) * (t(i, k) - t(i, 1)) + lv(i, k) * q(i, k) 125 END DO 126 END DO 130 127 131 128 END SUBROUTINE cv_prelim 132 129 133 130 SUBROUTINE cv_feed(len, nd, t, q, qs, p, hm, gz, nk, icb, icbmax, iflag, tnk, & 134 qnk, gznk, plcl)131 qnk, gznk, plcl) 135 132 IMPLICIT NONE 136 133 … … 169 166 DO k = 2, nlp 170 167 DO i = 1, len 171 IF ((hm(i, k)<work(i)) .AND. (hm(i,k)<hm(i,k-1))) THEN168 IF ((hm(i, k)<work(i)) .AND. (hm(i, k)<hm(i, k - 1))) THEN 172 169 work(i) = hm(i, k) 173 170 ihmin(i) = k … … 193 190 DO k = minorig + 1, nl 194 191 DO i = 1, len 195 IF ((hm(i, k)>work(i)) .AND. (k<=ihmin(i))) THEN192 IF ((hm(i, k)>work(i)) .AND. (k<=ihmin(i))) THEN 196 193 work(i) = hm(i, k) 197 194 nk(i) = k … … 204 201 ! ------------------------------------------------------------------- 205 202 DO i = 1, len 206 IF (((t(i, nk(i))<250.0) .OR. (q(i,nk(i))<=0.0) .OR. (p(i,ihmin(i))< &207 400.0)) .AND. (iflag(i)==0)) iflag(i) = 7203 IF (((t(i, nk(i))<250.0) .OR. (q(i, nk(i))<=0.0) .OR. (p(i, ihmin(i))< & 204 400.0)) .AND. (iflag(i)==0)) iflag(i) = 7 208 205 END DO 209 206 ! ------------------------------------------------------------------- … … 218 215 qsnk(i) = qs(i, nk(i)) 219 216 220 rh(i) = qnk(i) /qsnk(i)217 rh(i) = qnk(i) / qsnk(i) 221 218 rh(i) = min(1.0, rh(i)) 222 chi(i) = tnk(i) /(1669.0-122.0*rh(i)-tnk(i))223 plcl(i) = pnk(i) *(rh(i)**chi(i))219 chi(i) = tnk(i) / (1669.0 - 122.0 * rh(i) - tnk(i)) 220 plcl(i) = pnk(i) * (rh(i)**chi(i)) 224 221 IF (((plcl(i)<200.0) .OR. (plcl(i)>=2000.0)) .AND. (iflag(i)==0)) iflag(i & 225 ) = 8222 ) = 8 226 223 END DO 227 224 ! ------------------------------------------------------------------- … … 234 231 DO k = minorig, nl 235 232 DO i = 1, len 236 IF ((k>=(nk(i) +1)) .AND. (p(i,k)<plcl(i))) icb(i) = min(icb(i), k)233 IF ((k>=(nk(i) + 1)) .AND. (p(i, k)<plcl(i))) icb(i) = min(icb(i), k) 237 234 END DO 238 235 END DO … … 249 246 END DO 250 247 251 252 248 END SUBROUTINE cv_feed 253 249 254 250 SUBROUTINE cv_undilute1(len, nd, t, q, qs, gz, p, nk, icb, icbmax, tp, tvp, & 255 clw) 251 clw) 252 USE lmdz_cvthermo 253 256 254 IMPLICIT NONE 257 255 258 include "cvthermo.h"259 256 include "cvparam.h" 260 257 … … 292 289 293 290 DO i = 1, len 294 ah0(i) = (cpd *(1.-qnk(i))+cl*qnk(i))*tnk(i) + qnk(i)*(lv0-clmcpv*(tnk(i)- &295 273.15)) + gznk(i)296 cpp(i) = cpd *(1.-qnk(i)) + qnk(i)*cpv291 ah0(i) = (cpd * (1. - qnk(i)) + cl * qnk(i)) * tnk(i) + qnk(i) * (lv0 - clmcpv * (tnk(i) - & 292 273.15)) + gznk(i) 293 cpp(i) = cpd * (1. - qnk(i)) + qnk(i) * cpv 297 294 END DO 298 295 … … 301 298 DO k = minorig, icbmax - 1 302 299 DO i = 1, len 303 tp(i, k) = tnk(i) - (gz(i, k)-gznk(i))/cpp(i)304 tvp(i, k) = tp(i, k) *(1.+qnk(i)*epsi)300 tp(i, k) = tnk(i) - (gz(i, k) - gznk(i)) / cpp(i) 301 tvp(i, k) = tp(i, k) * (1. + qnk(i) * epsi) 305 302 END DO 306 303 END DO … … 311 308 tg = ticb(i) 312 309 qg = qs(i, icb(i)) 313 alv = lv0 - clmcpv *(ticb(i)-t0)310 alv = lv0 - clmcpv * (ticb(i) - t0) 314 311 315 312 ! First iteration. 316 313 317 s = cpd + alv *alv*qg/(rrv*ticb(i)*ticb(i))318 s = 1. /s319 ahg = cpd *tg + (cl-cpd)*qnk(i)*ticb(i) + alv*qg + gzicb(i)320 tg = tg + s *(ah0(i)-ahg)314 s = cpd + alv * alv * qg / (rrv * ticb(i) * ticb(i)) 315 s = 1. / s 316 ahg = cpd * tg + (cl - cpd) * qnk(i) * ticb(i) + alv * qg + gzicb(i) 317 tg = tg + s * (ah0(i) - ahg) 321 318 tg = max(tg, 35.0) 322 319 tc = tg - t0 323 320 denom = 243.5 + tc 324 321 IF (tc>=0.0) THEN 325 es = 6.112 *exp(17.67*tc/denom)322 es = 6.112 * exp(17.67 * tc / denom) 326 323 ELSE 327 es = exp(23.33086 -6111.72784/tg+0.15215*log(tg))324 es = exp(23.33086 - 6111.72784 / tg + 0.15215 * log(tg)) 328 325 END IF 329 qg = eps *es/(p(i,icb(i))-es*(1.-eps))326 qg = eps * es / (p(i, icb(i)) - es * (1. - eps)) 330 327 331 328 ! Second iteration. 332 329 333 s = cpd + alv *alv*qg/(rrv*ticb(i)*ticb(i))334 s = 1. /s335 ahg = cpd *tg + (cl-cpd)*qnk(i)*ticb(i) + alv*qg + gzicb(i)336 tg = tg + s *(ah0(i)-ahg)330 s = cpd + alv * alv * qg / (rrv * ticb(i) * ticb(i)) 331 s = 1. / s 332 ahg = cpd * tg + (cl - cpd) * qnk(i) * ticb(i) + alv * qg + gzicb(i) 333 tg = tg + s * (ah0(i) - ahg) 337 334 tg = max(tg, 35.0) 338 335 tc = tg - t0 339 336 denom = 243.5 + tc 340 337 IF (tc>=0.0) THEN 341 es = 6.112 *exp(17.67*tc/denom)338 es = 6.112 * exp(17.67 * tc / denom) 342 339 ELSE 343 es = exp(23.33086 -6111.72784/tg+0.15215*log(tg))340 es = exp(23.33086 - 6111.72784 / tg + 0.15215 * log(tg)) 344 341 END IF 345 qg = eps *es/(p(i,icb(i))-es*(1.-eps))346 347 alv = lv0 - clmcpv *(ticb(i)-273.15)348 tp(i, icb(i)) = (ah0(i) -(cl-cpd)*qnk(i)*ticb(i)-gz(i,icb(i))-alv*qg)/cpd342 qg = eps * es / (p(i, icb(i)) - es * (1. - eps)) 343 344 alv = lv0 - clmcpv * (ticb(i) - 273.15) 345 tp(i, icb(i)) = (ah0(i) - (cl - cpd) * qnk(i) * ticb(i) - gz(i, icb(i)) - alv * qg) / cpd 349 346 clw(i, icb(i)) = qnk(i) - qg 350 clw(i, icb(i)) = max(0.0, clw(i, icb(i)))351 rg = qg /(1.-qnk(i))352 tvp(i, icb(i)) = tp(i, icb(i)) *(1.+rg*epsi)347 clw(i, icb(i)) = max(0.0, clw(i, icb(i))) 348 rg = qg / (1. - qnk(i)) 349 tvp(i, icb(i)) = tp(i, icb(i)) * (1. + rg * epsi) 353 350 END DO 354 351 355 352 DO k = minorig, icbmax 356 353 DO i = 1, len 357 tvp(i, k) = tvp(i, k) - tp(i, k)*qnk(i) 358 END DO 359 END DO 360 354 tvp(i, k) = tvp(i, k) - tp(i, k) * qnk(i) 355 END DO 356 END DO 361 357 362 358 END SUBROUTINE cv_undilute1 … … 383 379 INTEGER i 384 380 385 386 381 DO i = 1, len 387 382 IF ((cbmf(i)==0.0) .AND. (iflag(i)==0) .AND. (tvp(i, & 388 icb(i))<=(tv(i,icb(i))-dtmax))) iflag(i) = 4 389 END DO 390 383 icb(i))<=(tv(i, icb(i)) - dtmax))) iflag(i) = 4 384 END DO 391 385 392 386 END SUBROUTINE cv_trigger 393 387 394 388 SUBROUTINE cv_compress(len, nloc, ncum, nd, iflag1, nk1, icb1, cbmf1, plcl1, & 395 tnk1, qnk1, gznk1, t1, q1, qs1, u1, v1, gz1, h1, lv1, cpn1, p1, ph1, tv1, &396 tp1, tvp1, clw1, iflag, nk, icb, cbmf, plcl, tnk, qnk, gznk, t, q, qs, u, &397 v, gz, h, lv, cpn, p, ph, tv, tp, tvp, clw, dph)389 tnk1, qnk1, gznk1, t1, q1, qs1, u1, v1, gz1, h1, lv1, cpn1, p1, ph1, tv1, & 390 tp1, tvp1, clw1, iflag, nk, icb, cbmf, plcl, tnk, qnk, gznk, t, q, qs, u, & 391 v, gz, h, lv, cpn, p, ph, tv, tp, tvp, clw, dph) 398 392 USE lmdz_print_control, ONLY: lunout 399 393 USE lmdz_abort_physic, ONLY: abort_physic … … 408 402 REAL t1(len, nd), q1(len, nd), qs1(len, nd), u1(len, nd), v1(len, nd) 409 403 REAL gz1(len, nd), h1(len, nd), lv1(len, nd), cpn1(len, nd) 410 REAL p1(len, nd), ph1(len, nd +1), tv1(len, nd), tp1(len, nd)404 REAL p1(len, nd), ph1(len, nd + 1), tv1(len, nd), tp1(len, nd) 411 405 REAL tvp1(len, nd), clw1(len, nd) 412 406 … … 416 410 REAL t(nloc, nd), q(nloc, nd), qs(nloc, nd), u(nloc, nd), v(nloc, nd) 417 411 REAL gz(nloc, nd), h(nloc, nd), lv(nloc, nd), cpn(nloc, nd) 418 REAL p(nloc, nd), ph(nloc, nd +1), tv(nloc, nd), tp(nloc, nd)412 REAL p(nloc, nd), ph(nloc, nd + 1), tv(nloc, nd), tp(nloc, nd) 419 413 REAL tvp(nloc, nd), clw(nloc, nd) 420 414 REAL dph(nloc, nd) … … 422 416 ! local variables: 423 417 INTEGER i, k, nn 424 CHARACTER (LEN=20) :: modname = 'cv_compress' 425 CHARACTER (LEN=80) :: abort_message 426 418 CHARACTER (LEN = 20) :: modname = 'cv_compress' 419 CHARACTER (LEN = 80) :: abort_message 427 420 428 421 DO k = 1, nl + 1 … … 473 466 DO k = 1, nl 474 467 DO i = 1, ncum 475 dph(i, k) = ph(i, k) - ph(i, k+1) 476 END DO 477 END DO 478 468 dph(i, k) = ph(i, k) - ph(i, k + 1) 469 END DO 470 END DO 479 471 480 472 END SUBROUTINE cv_compress 481 473 482 474 SUBROUTINE cv_undilute2(nloc, ncum, nd, icb, nk, tnk, qnk, gznk, t, q, qs, & 483 gz, p, dph, h, tv, lv, inb, inb1, tp, tvp, clw, hp, ep, sigp, frac) 475 gz, p, dph, h, tv, lv, inb, inb1, tp, tvp, clw, hp, ep, sigp, frac) 476 USE lmdz_cvthermo 477 484 478 IMPLICIT NONE 485 479 … … 494 488 ! --------------------------------------------------------------------- 495 489 496 include "cvthermo.h"497 490 include "cvparam.h" 498 491 … … 538 531 ! *** Calculate certain parcel quantities, including static energy *** 539 532 540 541 DO i = 1, ncum 542 ah0(i) = (cpd*(1.-qnk(i))+cl*qnk(i))*tnk(i) + qnk(i)*(lv0-clmcpv*(tnk(i)- & 543 t0)) + gznk(i) 533 DO i = 1, ncum 534 ah0(i) = (cpd * (1. - qnk(i)) + cl * qnk(i)) * tnk(i) + qnk(i) * (lv0 - clmcpv * (tnk(i) - & 535 t0)) + gznk(i) 544 536 END DO 545 537 … … 547 539 ! *** Find lifted parcel quantities above cloud base *** 548 540 549 550 541 DO k = minorig + 1, nl 551 542 DO i = 1, ncum 552 IF (k>=(icb(i) +1)) THEN543 IF (k>=(icb(i) + 1)) THEN 553 544 tg = t(i, k) 554 545 qg = qs(i, k) 555 alv = lv0 - clmcpv *(t(i,k)-t0)546 alv = lv0 - clmcpv * (t(i, k) - t0) 556 547 557 548 ! First iteration. 558 549 559 s = cpd + alv *alv*qg/(rrv*t(i,k)*t(i,k))560 s = 1. /s561 ahg = cpd *tg + (cl-cpd)*qnk(i)*t(i, k) + alv*qg + gz(i, k)562 tg = tg + s *(ah0(i)-ahg)550 s = cpd + alv * alv * qg / (rrv * t(i, k) * t(i, k)) 551 s = 1. / s 552 ahg = cpd * tg + (cl - cpd) * qnk(i) * t(i, k) + alv * qg + gz(i, k) 553 tg = tg + s * (ah0(i) - ahg) 563 554 tg = max(tg, 35.0) 564 555 tc = tg - t0 565 556 denom = 243.5 + tc 566 557 IF (tc>=0.0) THEN 567 es = 6.112 *exp(17.67*tc/denom)558 es = 6.112 * exp(17.67 * tc / denom) 568 559 ELSE 569 es = exp(23.33086 -6111.72784/tg+0.15215*log(tg))560 es = exp(23.33086 - 6111.72784 / tg + 0.15215 * log(tg)) 570 561 END IF 571 qg = eps *es/(p(i,k)-es*(1.-eps))562 qg = eps * es / (p(i, k) - es * (1. - eps)) 572 563 573 564 ! Second iteration. 574 565 575 s = cpd + alv *alv*qg/(rrv*t(i,k)*t(i,k))576 s = 1. /s577 ahg = cpd *tg + (cl-cpd)*qnk(i)*t(i, k) + alv*qg + gz(i, k)578 tg = tg + s *(ah0(i)-ahg)566 s = cpd + alv * alv * qg / (rrv * t(i, k) * t(i, k)) 567 s = 1. / s 568 ahg = cpd * tg + (cl - cpd) * qnk(i) * t(i, k) + alv * qg + gz(i, k) 569 tg = tg + s * (ah0(i) - ahg) 579 570 tg = max(tg, 35.0) 580 571 tc = tg - t0 581 572 denom = 243.5 + tc 582 573 IF (tc>=0.0) THEN 583 es = 6.112 *exp(17.67*tc/denom)574 es = 6.112 * exp(17.67 * tc / denom) 584 575 ELSE 585 es = exp(23.33086 -6111.72784/tg+0.15215*log(tg))576 es = exp(23.33086 - 6111.72784 / tg + 0.15215 * log(tg)) 586 577 END IF 587 qg = eps *es/(p(i,k)-es*(1.-eps))588 589 alv = lv0 - clmcpv *(t(i,k)-t0)578 qg = eps * es / (p(i, k) - es * (1. - eps)) 579 580 alv = lv0 - clmcpv * (t(i, k) - t0) 590 581 ! PRINT*,'cpd dans convect2 ',cpd 591 582 ! PRINT*,'tp(i,k),ah0(i),cl,cpd,qnk(i),t(i,k),gz(i,k),alv,qg,cpd' 592 583 ! PRINT*,tp(i,k),ah0(i),cl,cpd,qnk(i),t(i,k),gz(i,k),alv,qg,cpd 593 tp(i, k) = (ah0(i) -(cl-cpd)*qnk(i)*t(i,k)-gz(i,k)-alv*qg)/cpd584 tp(i, k) = (ah0(i) - (cl - cpd) * qnk(i) * t(i, k) - gz(i, k) - alv * qg) / cpd 594 585 ! if (.NOT.cpd.gt.1000.) THEN 595 586 ! PRINT*,'CPD=',cpd … … 597 588 ! END IF 598 589 clw(i, k) = qnk(i) - qg 599 clw(i, k) = max(0.0, clw(i, k))600 rg = qg /(1.-qnk(i))601 tvp(i, k) = tp(i, k) *(1.+rg*epsi)590 clw(i, k) = max(0.0, clw(i, k)) 591 rg = qg / (1. - qnk(i)) 592 tvp(i, k) = tp(i, k) * (1. + rg * epsi) 602 593 END IF 603 594 END DO … … 612 603 DO k = minorig + 1, nl 613 604 DO i = 1, ncum 614 IF (k>=(nk(i) +1)) THEN605 IF (k>=(nk(i) + 1)) THEN 615 606 tca = tp(i, k) - t0 616 607 IF (tca>=0.0) THEN 617 608 elacrit = elcrit 618 609 ELSE 619 elacrit = elcrit *(1.0-tca/tlcrit)610 elacrit = elcrit * (1.0 - tca / tlcrit) 620 611 END IF 621 612 elacrit = max(elacrit, 0.0) 622 ep(i, k) = 1.0 - elacrit /max(clw(i,k), 1.0E-8)623 ep(i, k) = max(ep(i, k), 0.0)624 ep(i, k) = min(ep(i, k), 1.0)613 ep(i, k) = 1.0 - elacrit / max(clw(i, k), 1.0E-8) 614 ep(i, k) = max(ep(i, k), 0.0) 615 ep(i, k) = min(ep(i, k), 1.0) 625 616 sigp(i, k) = sigs 626 617 END IF … … 635 626 DO k = minorig + 1, nl 636 627 DO i = 1, ncum 637 IF (k>=(icb(i) +1)) THEN638 tvp(i, k) = tvp(i, k) *(1.0-qnk(i)+ep(i,k)*clw(i,k))628 IF (k>=(icb(i) + 1)) THEN 629 tvp(i, k) = tvp(i, k) * (1.0 - qnk(i) + ep(i, k) * clw(i, k)) 639 630 ! PRINT*,'i,k,tvp(i,k),qnk(i),ep(i,k),clw(i,k)' 640 631 ! PRINT*, i,k,tvp(i,k),qnk(i),ep(i,k),clw(i,k) … … 643 634 END DO 644 635 DO i = 1, ncum 645 tvp(i, nlp) = tvp(i, nl) - (gz(i, nlp)-gz(i,nl))/cpd636 tvp(i, nlp) = tvp(i, nl) - (gz(i, nlp) - gz(i, nl)) / cpd 646 637 END DO 647 638 … … 721 712 DO i = 1, ncum 722 713 IF (cape(i)<0.0) lcape(i) = .FALSE. 723 IF ((k>=(icb(i) +1)) .AND. lcape(i)) THEN724 by = (tvp(i, k)-tv(i,k))*dph(i, k)/p(i, k)725 byp(i) = (tvp(i, k+1)-tv(i,k+1))*dph(i, k+1)/p(i, k+1)714 IF ((k>=(icb(i) + 1)) .AND. lcape(i)) THEN 715 by = (tvp(i, k) - tv(i, k)) * dph(i, k) / p(i, k) 716 byp(i) = (tvp(i, k + 1) - tv(i, k + 1)) * dph(i, k + 1) / p(i, k + 1) 726 717 cape(i) = cape(i) + by 727 718 IF (by>=0.0) inb1(i) = k + 1 … … 737 728 defrac = capem(i) - cape(i) 738 729 defrac = max(defrac, 0.001) 739 frac(i) = -cape(i) /defrac730 frac(i) = -cape(i) / defrac 740 731 frac(i) = min(frac(i), 1.0) 741 732 frac(i) = max(frac(i), 0.0) … … 747 738 748 739 ! initialization: 749 DO i = 1, ncum *nlp740 DO i = 1, ncum * nlp 750 741 hp(i, 1) = h(i, 1) 751 742 END DO … … 754 745 DO i = 1, ncum 755 746 IF ((k>=icb(i)) .AND. (k<=inb(i))) THEN 756 hp(i, k) = h(i, nk(i)) + (lv(i,k)+(cpd-cpv)*t(i,k))*ep(i, k)*clw(i, k & 757 ) 758 END IF 759 END DO 760 END DO 761 747 hp(i, k) = h(i, nk(i)) + (lv(i, k) + (cpd - cpv) * t(i, k)) * ep(i, k) * clw(i, k & 748 ) 749 END IF 750 END DO 751 END DO 762 752 763 753 END SUBROUTINE cv_undilute2 764 754 765 755 SUBROUTINE cv_closure(nloc, ncum, nd, nk, icb, tv, tvp, p, ph, dph, plcl, & 766 cpn, iflag, cbmf) 756 cpn, iflag, cbmf) 757 USE lmdz_cvthermo 758 767 759 IMPLICIT NONE 768 760 … … 771 763 INTEGER nk(nloc), icb(nloc) 772 764 REAL tv(nloc, nd), tvp(nloc, nd), p(nloc, nd), dph(nloc, nd) 773 REAL ph(nloc, nd +1) ! caution nd instead ndp1 to be consistent...765 REAL ph(nloc, nd + 1) ! caution nd instead ndp1 to be consistent... 774 766 REAL plcl(nloc), cpn(nloc, nd) 775 767 … … 783 775 REAL work(nloc) 784 776 785 include "cvthermo.h"786 777 include "cvparam.h" 787 778 … … 805 796 DO i = 1, ncum 806 797 dtpbl(i) = 0.0 807 tvpplcl(i) = tvp(i, icb(i) -1) - rrd*tvp(i, icb(i)-1)*(p(i,icb(i)-1)-plcl(&808 i))/(cpn(i,icb(i)-1)*p(i,icb(i)-1))809 tvaplcl(i) = tv(i, icb(i)) + (tvp(i, icb(i))-tvp(i,icb(i)+1))*(plcl(i)-p(i &810 ,icb(i)))/(p(i,icb(i))-p(i,icb(i)+1))798 tvpplcl(i) = tvp(i, icb(i) - 1) - rrd * tvp(i, icb(i) - 1) * (p(i, icb(i) - 1) - plcl(& 799 i)) / (cpn(i, icb(i) - 1) * p(i, icb(i) - 1)) 800 tvaplcl(i) = tv(i, icb(i)) + (tvp(i, icb(i)) - tvp(i, icb(i) + 1)) * (plcl(i) - p(i & 801 , icb(i))) / (p(i, icb(i)) - p(i, icb(i) + 1)) 811 802 END DO 812 803 … … 820 811 DO k = minorig, icbmax 821 812 DO i = 1, ncum 822 IF ((k>=nk(i)) .AND. (k<=(icb(i) -1))) THEN823 dtpbl(i) = dtpbl(i) + (tvp(i, k)-tv(i,k))*dph(i, k)824 END IF 825 END DO 826 END DO 827 DO i = 1, ncum 828 dtpbl(i) = dtpbl(i) /(ph(i,nk(i))-ph(i,icb(i)))813 IF ((k>=nk(i)) .AND. (k<=(icb(i) - 1))) THEN 814 dtpbl(i) = dtpbl(i) + (tvp(i, k) - tv(i, k)) * dph(i, k) 815 END IF 816 END DO 817 END DO 818 DO i = 1, ncum 819 dtpbl(i) = dtpbl(i) / (ph(i, nk(i)) - ph(i, icb(i))) 829 820 dtmin(i) = tvpplcl(i) - tvaplcl(i) + dtmax + dtpbl(i) 830 821 END DO … … 836 827 DO i = 1, ncum 837 828 work(i) = cbmf(i) 838 cbmf(i) = max(0.0, (1.0 -damp)*cbmf(i)+0.1*alpha*dtmin(i))829 cbmf(i) = max(0.0, (1.0 - damp) * cbmf(i) + 0.1 * alpha * dtmin(i)) 839 830 IF ((work(i)==0.0) .AND. (cbmf(i)==0.0)) THEN 840 831 iflag(i) = 3 … … 842 833 END DO 843 834 844 845 835 END SUBROUTINE cv_closure 846 836 847 837 SUBROUTINE cv_mixing(nloc, ncum, nd, icb, nk, inb, inb1, ph, t, q, qs, u, v, & 848 h, lv, qnk, hp, tv, tvp, ep, clw, cbmf, m, ment, qent, uent, vent, nent, & 849 sij, elij) 838 h, lv, qnk, hp, tv, tvp, ep, clw, cbmf, m, ment, qent, uent, vent, nent, & 839 sij, elij) 840 USE lmdz_cvthermo 841 850 842 IMPLICIT NONE 851 843 852 include "cvthermo.h"853 844 include "cvparam.h" 854 845 … … 857 848 INTEGER icb(nloc), inb(nloc), inb1(nloc), nk(nloc) 858 849 REAL cbmf(nloc), qnk(nloc) 859 REAL ph(nloc, nd +1)850 REAL ph(nloc, nd + 1) 860 851 REAL t(nloc, nd), q(nloc, nd), qs(nloc, nd), lv(nloc, nd) 861 852 REAL u(nloc, nd), v(nloc, nd), h(nloc, nd), hp(nloc, nd) … … 881 872 ! ===================================================================== 882 873 883 DO i = 1, ncum *nlp874 DO i = 1, ncum * nlp 884 875 nent(i, 1) = 0 885 876 m(i, 1) = 0.0 … … 907 898 DO j = minorig + 1, nl 908 899 DO i = 1, ncum 909 IF ((j>=(icb(i) +1)) .AND. (j<=inb(i))) THEN900 IF ((j>=(icb(i) + 1)) .AND. (j<=inb(i))) THEN 910 901 k = min(j, inb1(i)) 911 dbo = abs(tv(i, k+1)-tvp(i,k+1)-tv(i,k-1)+tvp(i,k-1)) + &912 entp*0.04*(ph(i,k)-ph(i,k+1))902 dbo = abs(tv(i, k + 1) - tvp(i, k + 1) - tv(i, k - 1) + tvp(i, k - 1)) + & 903 entp * 0.04 * (ph(i, k) - ph(i, k + 1)) 913 904 work(i) = work(i) + dbo 914 m(i, j) = cbmf(i) *dbo905 m(i, j) = cbmf(i) * dbo 915 906 END IF 916 907 END DO … … 918 909 DO k = minorig + 1, nl 919 910 DO i = 1, ncum 920 IF ((k>=(icb(i) +1)) .AND. (k<=inb(i))) THEN921 m(i, k) = m(i, k) /work(i)911 IF ((k>=(icb(i) + 1)) .AND. (k<=inb(i))) THEN 912 m(i, k) = m(i, k) / work(i) 922 913 END IF 923 914 END DO … … 931 922 ! ===================================================================== 932 923 933 934 924 DO i = minorig + 1, nl 935 925 DO j = minorig + 1, nl 936 926 DO ij = 1, ncum 937 IF ((i>=(icb(ij) +1)) .AND. (j>=icb(ij)) .AND. (i<=inb(ij)) .AND. (j<= &938 inb(ij))) THEN939 qti = qnk(ij) - ep(ij, i) *clw(ij, i)940 bf2 = 1. + lv(ij, j) *lv(ij, j)*qs(ij, j)/(rrv*t(ij,j)*t(ij,j)*cpd)941 anum = h(ij, j) - hp(ij, i) + (cpv -cpd)*t(ij, j)*(qti-q(ij,j))942 denom = h(ij, i) - hp(ij, i) + (cpd -cpv)*(q(ij,i)-qti)*t(ij, j)927 IF ((i>=(icb(ij) + 1)) .AND. (j>=icb(ij)) .AND. (i<=inb(ij)) .AND. (j<= & 928 inb(ij))) THEN 929 qti = qnk(ij) - ep(ij, i) * clw(ij, i) 930 bf2 = 1. + lv(ij, j) * lv(ij, j) * qs(ij, j) / (rrv * t(ij, j) * t(ij, j) * cpd) 931 anum = h(ij, j) - hp(ij, i) + (cpv - cpd) * t(ij, j) * (qti - q(ij, j)) 932 denom = h(ij, i) - hp(ij, i) + (cpd - cpv) * (q(ij, i) - qti) * t(ij, j) 943 933 dei = denom 944 934 IF (abs(dei)<0.01) dei = 0.01 945 sij(ij, i, j) = anum /dei935 sij(ij, i, j) = anum / dei 946 936 sij(ij, i, i) = 1.0 947 altem = sij(ij, i, j) *q(ij, i) + (1.-sij(ij,i,j))*qti - qs(ij, j)948 altem = altem /bf2949 cwat = clw(ij, j) *(1.-ep(ij,j))937 altem = sij(ij, i, j) * q(ij, i) + (1. - sij(ij, i, j)) * qti - qs(ij, j) 938 altem = altem / bf2 939 cwat = clw(ij, j) * (1. - ep(ij, j)) 950 940 stemp = sij(ij, i, j) 951 941 IF ((stemp<0.0 .OR. stemp>1.0 .OR. altem>cwat) .AND. j>i) THEN 952 anum = anum - lv(ij, j) *(qti-qs(ij,j)-cwat*bf2)953 denom = denom + lv(ij, j) *(q(ij,i)-qti)942 anum = anum - lv(ij, j) * (qti - qs(ij, j) - cwat * bf2) 943 denom = denom + lv(ij, j) * (q(ij, i) - qti) 954 944 IF (abs(denom)<0.01) denom = 0.01 955 sij(ij, i, j) = anum /denom956 altem = sij(ij, i, j) *q(ij, i) + (1.-sij(ij,i,j))*qti - qs(ij, j)957 altem = altem - (bf2 -1.)*cwat945 sij(ij, i, j) = anum / denom 946 altem = sij(ij, i, j) * q(ij, i) + (1. - sij(ij, i, j)) * qti - qs(ij, j) 947 altem = altem - (bf2 - 1.) * cwat 958 948 END IF 959 IF (sij(ij, i,j)>0.0 .AND. sij(ij,i,j)<0.9) THEN960 qent(ij, i, j) = sij(ij, i, j) *q(ij, i) + (1.-sij(ij,i,j))*qti961 uent(ij, i, j) = sij(ij, i, j) *u(ij, i) + &962 (1.-sij(ij,i,j))*u(ij, nk(ij))963 vent(ij, i, j) = sij(ij, i, j) *v(ij, i) + &964 (1.-sij(ij,i,j))*v(ij, nk(ij))949 IF (sij(ij, i, j)>0.0 .AND. sij(ij, i, j)<0.9) THEN 950 qent(ij, i, j) = sij(ij, i, j) * q(ij, i) + (1. - sij(ij, i, j)) * qti 951 uent(ij, i, j) = sij(ij, i, j) * u(ij, i) + & 952 (1. - sij(ij, i, j)) * u(ij, nk(ij)) 953 vent(ij, i, j) = sij(ij, i, j) * v(ij, i) + & 954 (1. - sij(ij, i, j)) * v(ij, nk(ij)) 965 955 elij(ij, i, j) = altem 966 elij(ij, i, j) = max(0.0, elij(ij, i,j))967 ment(ij, i, j) = m(ij, i) /(1.-sij(ij,i,j))956 elij(ij, i, j) = max(0.0, elij(ij, i, j)) 957 ment(ij, i, j) = m(ij, i) / (1. - sij(ij, i, j)) 968 958 nent(ij, i) = nent(ij, i) + 1 969 959 END IF 970 sij(ij, i, j) = max(0.0, sij(ij, i,j))971 sij(ij, i, j) = min(1.0, sij(ij, i,j))960 sij(ij, i, j) = max(0.0, sij(ij, i, j)) 961 sij(ij, i, j) = min(1.0, sij(ij, i, j)) 972 962 END IF 973 963 END DO … … 980 970 981 971 DO ij = 1, ncum 982 IF ((i>=(icb(ij) +1)) .AND. (i<=inb(ij)) .AND. (nent(ij,i)==0)) THEN972 IF ((i>=(icb(ij) + 1)) .AND. (i<=inb(ij)) .AND. (nent(ij, i)==0)) THEN 983 973 ment(ij, i, i) = m(ij, i) 984 qent(ij, i, i) = q(ij, nk(ij)) - ep(ij, i) *clw(ij, i)974 qent(ij, i, i) = q(ij, nk(ij)) - ep(ij, i) * clw(ij, i) 985 975 uent(ij, i, i) = u(ij, nk(ij)) 986 976 vent(ij, i, i) = v(ij, nk(ij)) … … 1000 990 ! ===================================================================== 1001 991 1002 CALL zilch(bsum, ncum *nlp)992 CALL zilch(bsum, ncum * nlp) 1003 993 DO ij = 1, ncum 1004 994 lwork(ij) = .FALSE. … … 1008 998 num1 = 0 1009 999 DO ij = 1, ncum 1010 IF ((i>=icb(ij) +1) .AND. (i<=inb(ij))) num1 = num1 + 11000 IF ((i>=icb(ij) + 1) .AND. (i<=inb(ij))) num1 = num1 + 1 1011 1001 END DO 1012 1002 IF (num1<=0) GO TO 789 1013 1003 1014 1004 DO ij = 1, ncum 1015 IF ((i>=icb(ij) +1) .AND. (i<=inb(ij))) THEN1016 lwork(ij) = (nent(ij, i)/=0)1017 qp1 = q(ij, nk(ij)) - ep(ij, i) *clw(ij, i)1018 anum = h(ij, i) - hp(ij, i) - lv(ij, i) *(qp1-qs(ij,i))1019 denom = h(ij, i) - hp(ij, i) + lv(ij, i) *(q(ij,i)-qp1)1005 IF ((i>=icb(ij) + 1) .AND. (i<=inb(ij))) THEN 1006 lwork(ij) = (nent(ij, i)/=0) 1007 qp1 = q(ij, nk(ij)) - ep(ij, i) * clw(ij, i) 1008 anum = h(ij, i) - hp(ij, i) - lv(ij, i) * (qp1 - qs(ij, i)) 1009 denom = h(ij, i) - hp(ij, i) + lv(ij, i) * (q(ij, i) - qp1) 1020 1010 IF (abs(denom)<0.01) denom = 0.01 1021 scrit(ij) = anum /denom1022 alt = qp1 - qs(ij, i) + scrit(ij) *(q(ij,i)-qp1)1011 scrit(ij) = anum / denom 1012 alt = qp1 - qs(ij, i) + scrit(ij) * (q(ij, i) - qp1) 1023 1013 IF (scrit(ij)<0.0 .OR. alt<0.0) scrit(ij) = 1.0 1024 1014 asij(ij) = 0.0 … … 1030 1020 num2 = 0 1031 1021 DO ij = 1, ncum 1032 IF ((i>=icb(ij) +1) .AND. (i<=inb(ij)) .AND. (j>=icb(&1033 ij)) .AND. (j<=inb(ij)) .AND. lwork(ij)) num2 = num2 + 11022 IF ((i>=icb(ij) + 1) .AND. (i<=inb(ij)) .AND. (j>=icb(& 1023 ij)) .AND. (j<=inb(ij)) .AND. lwork(ij)) num2 = num2 + 1 1034 1024 END DO 1035 1025 IF (num2<=0) GO TO 783 1036 1026 1037 1027 DO ij = 1, ncum 1038 IF ((i>=icb(ij) +1) .AND. (i<=inb(ij)) .AND. (j>=icb(&1039 ij)) .AND. (j<=inb(ij)) .AND. lwork(ij)) THEN1040 IF (sij(ij, i,j)>0.0 .AND. sij(ij,i,j)<0.9) THEN1028 IF ((i>=icb(ij) + 1) .AND. (i<=inb(ij)) .AND. (j>=icb(& 1029 ij)) .AND. (j<=inb(ij)) .AND. lwork(ij)) THEN 1030 IF (sij(ij, i, j)>0.0 .AND. sij(ij, i, j)<0.9) THEN 1041 1031 IF (j>i) THEN 1042 smid = min(sij(ij, i,j), scrit(ij))1032 smid = min(sij(ij, i, j), scrit(ij)) 1043 1033 sjmax = smid 1044 1034 sjmin = smid 1045 IF (smid<smin(ij) .AND. sij(ij, i,j+1)<smid) THEN1035 IF (smid<smin(ij) .AND. sij(ij, i, j + 1)<smid) THEN 1046 1036 smin(ij) = smid 1047 sjmax = min(sij(ij, i,j+1), sij(ij,i,j), scrit(ij))1048 sjmin = max(sij(ij, i,j-1), sij(ij,i,j))1037 sjmax = min(sij(ij, i, j + 1), sij(ij, i, j), scrit(ij)) 1038 sjmin = max(sij(ij, i, j - 1), sij(ij, i, j)) 1049 1039 sjmin = min(sjmin, scrit(ij)) 1050 1040 END IF 1051 1041 ELSE 1052 sjmax = max(sij(ij, i,j+1), scrit(ij))1053 smid = max(sij(ij, i,j), scrit(ij))1042 sjmax = max(sij(ij, i, j + 1), scrit(ij)) 1043 smid = max(sij(ij, i, j), scrit(ij)) 1054 1044 sjmin = 0.0 1055 IF (j>1) sjmin = sij(ij, i, j -1)1045 IF (j>1) sjmin = sij(ij, i, j - 1) 1056 1046 sjmin = max(sjmin, scrit(ij)) 1057 1047 END IF 1058 delp = abs(sjmax -smid)1059 delm = abs(sjmin -smid)1060 asij(ij) = asij(ij) + (delp +delm)*(ph(ij,j)-ph(ij,j+1))1061 ment(ij, i, j) = ment(ij, i, j) *(delp+delm)*(ph(ij,j)-ph(ij,j+1))1048 delp = abs(sjmax - smid) 1049 delm = abs(sjmin - smid) 1050 asij(ij) = asij(ij) + (delp + delm) * (ph(ij, j) - ph(ij, j + 1)) 1051 ment(ij, i, j) = ment(ij, i, j) * (delp + delm) * (ph(ij, j) - ph(ij, j + 1)) 1062 1052 END IF 1063 1053 END IF 1064 1054 END DO 1065 783 END DO1055 783 END DO 1066 1056 DO ij = 1, ncum 1067 IF ((i>=icb(ij) +1) .AND. (i<=inb(ij)) .AND. lwork(ij)) THEN1057 IF ((i>=icb(ij) + 1) .AND. (i<=inb(ij)) .AND. lwork(ij)) THEN 1068 1058 asij(ij) = max(1.0E-21, asij(ij)) 1069 asij(ij) = 1.0 /asij(ij)1059 asij(ij) = 1.0 / asij(ij) 1070 1060 bsum(ij, i) = 0.0 1071 1061 END IF … … 1073 1063 DO j = minorig, nl + 1 1074 1064 DO ij = 1, ncum 1075 IF ((i>=icb(ij) +1) .AND. (i<=inb(ij)) .AND. (j>=icb(&1076 ij)) .AND. (j<=inb(ij)) .AND. lwork(ij)) THEN1077 ment(ij, i, j) = ment(ij, i, j) *asij(ij)1065 IF ((i>=icb(ij) + 1) .AND. (i<=inb(ij)) .AND. (j>=icb(& 1066 ij)) .AND. (j<=inb(ij)) .AND. lwork(ij)) THEN 1067 ment(ij, i, j) = ment(ij, i, j) * asij(ij) 1078 1068 bsum(ij, i) = bsum(ij, i) + ment(ij, i, j) 1079 1069 END IF … … 1081 1071 END DO 1082 1072 DO ij = 1, ncum 1083 IF ((i>=icb(ij) +1) .AND. (i<=inb(ij)) .AND. (bsum(ij, &1084 i)<1.0E-18) .AND. lwork(ij)) THEN1073 IF ((i>=icb(ij) + 1) .AND. (i<=inb(ij)) .AND. (bsum(ij, & 1074 i)<1.0E-18) .AND. lwork(ij)) THEN 1085 1075 nent(ij, i) = 0 1086 1076 ment(ij, i, i) = m(ij, i) 1087 qent(ij, i, i) = q(ij, nk(ij)) - ep(ij, i) *clw(ij, i)1077 qent(ij, i, i) = q(ij, nk(ij)) - ep(ij, i) * clw(ij, i) 1088 1078 uent(ij, i, i) = u(ij, nk(ij)) 1089 1079 vent(ij, i, i) = v(ij, nk(ij)) … … 1092 1082 END IF 1093 1083 END DO 1094 789 END DO 1095 1084 789 END DO 1096 1085 1097 1086 END SUBROUTINE cv_mixing 1098 1087 1099 1088 SUBROUTINE cv_unsat(nloc, ncum, nd, inb, t, q, qs, gz, u, v, p, ph, h, lv, & 1100 ep, sigp, clw, m, ment, elij, iflag, mp, qp, up, vp, wt, water, evap) 1089 ep, sigp, clw, m, ment, elij, iflag, mp, qp, up, vp, wt, water, evap) 1090 USE lmdz_cvthermo 1091 1101 1092 IMPLICIT NONE 1102 1093 1103 1104 include "cvthermo.h"1105 1094 include "cvparam.h" 1106 1095 … … 1110 1099 REAL t(nloc, nd), q(nloc, nd), qs(nloc, nd) 1111 1100 REAL gz(nloc, nd), u(nloc, nd), v(nloc, nd) 1112 REAL p(nloc, nd), ph(nloc, nd +1), h(nloc, nd)1101 REAL p(nloc, nd), ph(nloc, nd + 1), h(nloc, nd) 1113 1102 REAL lv(nloc, nd), ep(nloc, nd), sigp(nloc, nd), clw(nloc, nd) 1114 1103 REAL m(nloc, nd), ment(nloc, nd, nd), elij(nloc, nd, nd) … … 1150 1139 DO k = 2, nl + 1 1151 1140 DO i = 1, ncum 1152 qp(i, k) = q(i, k -1)1153 up(i, k) = u(i, k -1)1154 vp(i, k) = v(i, k -1)1141 qp(i, k) = q(i, k - 1) 1142 up(i, k) = u(i, k - 1) 1143 vp(i, k) = v(i, k - 1) 1155 1144 END DO 1156 1145 END DO … … 1164 1153 ! *** and condensed water flux *** 1165 1154 1166 1167 1155 DO i = 1, ncum 1168 1156 jtt(i) = 2 1169 IF (ep(i, inb(i))<=0.0001) iflag(i) = 21157 IF (ep(i, inb(i))<=0.0001) iflag(i) = 2 1170 1158 IF (iflag(i)==0) THEN 1171 1159 lwork(i) = .TRUE. … … 1177 1165 ! *** Begin downdraft loop *** 1178 1166 1179 1180 1167 CALL zilch(wdtrain, ncum) 1181 1168 DO i = nl + 1, 1, -1 … … 1192 1179 DO ij = 1, ncum 1193 1180 IF ((i<=inb(ij)) .AND. (lwork(ij))) THEN 1194 wdtrain(ij) = g *ep(ij, i)*m(ij, i)*clw(ij, i)1181 wdtrain(ij) = g * ep(ij, i) * m(ij, i) * clw(ij, i) 1195 1182 END IF 1196 1183 END DO … … 1200 1187 DO ij = 1, ncum 1201 1188 IF ((i<=inb(ij)) .AND. (lwork(ij))) THEN 1202 awat = elij(ij, j, i) - (1. -ep(ij,i))*clw(ij, i)1189 awat = elij(ij, j, i) - (1. - ep(ij, i)) * clw(ij, i) 1203 1190 awat = max(0.0, awat) 1204 wdtrain(ij) = wdtrain(ij) + g *awat*ment(ij, j, i)1191 wdtrain(ij) = wdtrain(ij) + g * awat * ment(ij, j, i) 1205 1192 END IF 1206 1193 END DO … … 1223 1210 ! rain *** 1224 1211 1225 IF (t(ij, i)>273.0) THEN1212 IF (t(ij, i)>273.0) THEN 1226 1213 coeff = coeffr 1227 1214 wt(ij, i) = omtrain 1228 1215 END IF 1229 qsm = 0.5 *(q(ij,i)+qp(ij,i+1))1230 afac = coeff *ph(ij, i)*(qs(ij,i)-qsm)/(1.0E4+2.0E3*ph(ij,i)*qs(ij,i))1216 qsm = 0.5 * (q(ij, i) + qp(ij, i + 1)) 1217 afac = coeff * ph(ij, i) * (qs(ij, i) - qsm) / (1.0E4 + 2.0E3 * ph(ij, i) * qs(ij, i)) 1231 1218 afac = max(afac, 0.0) 1232 1219 sigt = sigp(ij, i) 1233 1220 sigt = max(0.0, sigt) 1234 1221 sigt = min(1.0, sigt) 1235 b6 = 100. *(ph(ij,i)-ph(ij,i+1))*sigt*afac/wt(ij, i)1236 c6 = (water(ij, i+1)*wt(ij,i+1)+wdtrain(ij)/sigd)/wt(ij, i)1237 revap = 0.5 *(-b6+sqrt(b6*b6+4.*c6))1238 evap(ij, i) = sigt *afac*revap1239 water(ij, i) = revap *revap1222 b6 = 100. * (ph(ij, i) - ph(ij, i + 1)) * sigt * afac / wt(ij, i) 1223 c6 = (water(ij, i + 1) * wt(ij, i + 1) + wdtrain(ij) / sigd) / wt(ij, i) 1224 revap = 0.5 * (-b6 + sqrt(b6 * b6 + 4. * c6)) 1225 evap(ij, i) = sigt * afac * revap 1226 water(ij, i) = revap * revap 1240 1227 1241 1228 ! *** Calculate precipitating downdraft mass flux under *** … … 1243 1230 1244 1231 IF (i>1) THEN 1245 dhdp = (h(ij, i)-h(ij,i-1))/(p(ij,i-1)-p(ij,i))1232 dhdp = (h(ij, i) - h(ij, i - 1)) / (p(ij, i - 1) - p(ij, i)) 1246 1233 dhdp = max(dhdp, 10.0) 1247 mp(ij, i) = 100. *ginv*lv(ij, i)*sigd*evap(ij, i)/dhdp1248 mp(ij, i) = max(mp(ij, i), 0.0)1234 mp(ij, i) = 100. * ginv * lv(ij, i) * sigd * evap(ij, i) / dhdp 1235 mp(ij, i) = max(mp(ij, i), 0.0) 1249 1236 1250 1237 ! *** Add small amount of inertia to downdraft *** 1251 1238 1252 fac = 20.0 /(ph(ij,i-1)-ph(ij,i))1253 mp(ij, i) = (fac *mp(ij,i+1)+mp(ij,i))/(1.+fac)1239 fac = 20.0 / (ph(ij, i - 1) - ph(ij, i)) 1240 mp(ij, i) = (fac * mp(ij, i + 1) + mp(ij, i)) / (1. + fac) 1254 1241 1255 1242 ! *** Force mp to decrease linearly to zero … … 1258 1245 ! *** 1259 1246 1260 IF (p(ij, i)>(0.949*p(ij,1))) THEN1247 IF (p(ij, i)>(0.949 * p(ij, 1))) THEN 1261 1248 jtt(ij) = max(jtt(ij), i) 1262 mp(ij, i) = mp(ij, jtt(ij)) *(p(ij,1)-p(ij,i))/ &1263 (p(ij,1)-p(ij,jtt(ij)))1249 mp(ij, i) = mp(ij, jtt(ij)) * (p(ij, 1) - p(ij, i)) / & 1250 (p(ij, 1) - p(ij, jtt(ij))) 1264 1251 END IF 1265 1252 END IF … … 1271 1258 qstm = qs(ij, 1) 1272 1259 ELSE 1273 qstm = qs(ij, i -1)1260 qstm = qs(ij, i - 1) 1274 1261 END IF 1275 IF (mp(ij, i)>mp(ij,i+1)) THEN1276 rat = mp(ij, i +1)/mp(ij, i)1277 qp(ij, i) = qp(ij, i +1)*rat + q(ij, i)*(1.0-rat) + &1278 100.*ginv*sigd*(ph(ij,i)-ph(ij,i+1))*(evap(ij,i)/mp(ij,i))1279 up(ij, i) = up(ij, i +1)*rat + u(ij, i)*(1.-rat)1280 vp(ij, i) = vp(ij, i +1)*rat + v(ij, i)*(1.-rat)1262 IF (mp(ij, i)>mp(ij, i + 1)) THEN 1263 rat = mp(ij, i + 1) / mp(ij, i) 1264 qp(ij, i) = qp(ij, i + 1) * rat + q(ij, i) * (1.0 - rat) + & 1265 100. * ginv * sigd * (ph(ij, i) - ph(ij, i + 1)) * (evap(ij, i) / mp(ij, i)) 1266 up(ij, i) = up(ij, i + 1) * rat + u(ij, i) * (1. - rat) 1267 vp(ij, i) = vp(ij, i + 1) * rat + v(ij, i) * (1. - rat) 1281 1268 ELSE 1282 IF (mp(ij, i+1)>0.0) THEN1283 qp(ij, i) = (gz(ij, i+1)-gz(ij,i)+qp(ij,i+1)*(lv(ij,i+1)+t(ij, &1284 i+1)*(cl-cpd))+cpd*(t(ij,i+1)-t(ij, &1285 i)))/(lv(ij,i)+t(ij,i)*(cl-cpd))1286 up(ij, i) = up(ij, i +1)1287 vp(ij, i) = vp(ij, i +1)1269 IF (mp(ij, i + 1)>0.0) THEN 1270 qp(ij, i) = (gz(ij, i + 1) - gz(ij, i) + qp(ij, i + 1) * (lv(ij, i + 1) + t(ij, & 1271 i + 1) * (cl - cpd)) + cpd * (t(ij, i + 1) - t(ij, & 1272 i))) / (lv(ij, i) + t(ij, i) * (cl - cpd)) 1273 up(ij, i) = up(ij, i + 1) 1274 vp(ij, i) = vp(ij, i + 1) 1288 1275 END IF 1289 1276 END IF 1290 qp(ij, i) = min(qp(ij, i), qstm)1291 qp(ij, i) = max(qp(ij, i), 0.0)1277 qp(ij, i) = min(qp(ij, i), qstm) 1278 qp(ij, i) = max(qp(ij, i), 0.0) 1292 1279 END IF 1293 1280 END IF 1294 1281 END DO 1295 899 END DO 1296 1282 899 END DO 1297 1283 1298 1284 END SUBROUTINE cv_unsat 1299 1285 1300 1286 SUBROUTINE cv_yield(nloc, ncum, nd, nk, icb, inb, delt, t, q, u, v, gz, p, & 1301 ph, h, hp, lv, cpn, ep, clw, frac, m, mp, qp, up, vp, wt, water, evap, & 1302 ment, qent, uent, vent, nent, elij, tv, tvp, iflag, wd, qprime, tprime, & 1303 precip, cbmf, ft, fq, fu, fv, ma, qcondc) 1287 ph, h, hp, lv, cpn, ep, clw, frac, m, mp, qp, up, vp, wt, water, evap, & 1288 ment, qent, uent, vent, nent, elij, tv, tvp, iflag, wd, qprime, tprime, & 1289 precip, cbmf, ft, fq, fu, fv, ma, qcondc) 1290 USE lmdz_cvthermo 1291 1304 1292 IMPLICIT NONE 1305 1293 1306 include "cvthermo.h"1307 1294 include "cvparam.h" 1308 1295 … … 1314 1301 REAL t(nloc, nd), q(nloc, nd), u(nloc, nd), v(nloc, nd) 1315 1302 REAL gz(nloc, nd) 1316 REAL p(nloc, nd), ph(nloc, nd +1), h(nloc, nd)1303 REAL p(nloc, nd), ph(nloc, nd + 1), h(nloc, nd) 1317 1304 REAL hp(nloc, nd), lv(nloc, nd) 1318 1305 REAL cpn(nloc, nd), ep(nloc, nd), clw(nloc, nd), frac(nloc) … … 1344 1331 ! -- initializations: 1345 1332 1346 delti = 1.0 /delt1333 delti = 1.0 / delt 1347 1334 1348 1335 DO i = 1, ncum … … 1356 1343 fv(i, k) = 0.0 1357 1344 fq(i, k) = 0.0 1358 lvcp(i, k) = lv(i, k) /cpn(i, k)1345 lvcp(i, k) = lv(i, k) / cpn(i, k) 1359 1346 qcondc(i, k) = 0.0 ! cld 1360 1347 qcond(i, k) = 0.0 ! cld … … 1371 1358 ! c & /(rowl*g) 1372 1359 ! c precip(i)=precip(i)*delt/86400. 1373 precip(i) = wt(i, 1) *sigd*water(i, 1)*86400/g1360 precip(i) = wt(i, 1) * sigd * water(i, 1) * 86400 / g 1374 1361 END IF 1375 1362 END DO … … 1380 1367 1381 1368 DO i = 1, ncum 1382 wd(i) = betad *abs(mp(i,icb(i)))*0.01*rrd*t(i, icb(i))/(sigd*p(i,icb(i)))1383 qprime(i) = 0.5 *(qp(i,1)-q(i,1))1384 tprime(i) = lv0 *qprime(i)/cpd1369 wd(i) = betad * abs(mp(i, icb(i))) * 0.01 * rrd * t(i, icb(i)) / (sigd * p(i, icb(i))) 1370 qprime(i) = 0.5 * (qp(i, 1) - q(i, 1)) 1371 tprime(i) = lv0 * qprime(i) / cpd 1385 1372 END DO 1386 1373 … … 1389 1376 1390 1377 DO i = 1, ncum 1391 work(i) = 0.01 /(ph(i,1)-ph(i,2))1378 work(i) = 0.01 / (ph(i, 1) - ph(i, 2)) 1392 1379 am(i) = 0.0 1393 1380 END DO … … 1400 1387 END DO 1401 1388 DO i = 1, ncum 1402 IF ((g *work(i)*am(i))>=delti) iflag(i) = 11403 ft(i, 1) = ft(i, 1) + g *work(i)*am(i)*(t(i,2)-t(i,1)+(gz(i,2)-gz(i, &1404 1))/cpn(i,1))1405 ft(i, 1) = ft(i, 1) - lvcp(i, 1) *sigd*evap(i, 1)1406 ft(i, 1) = ft(i, 1) + sigd *wt(i, 2)*(cl-cpd)*water(i, 2)*(t(i,2)-t(i,1))* &1407 work(i)/cpn(i, 1)1408 fq(i, 1) = fq(i, 1) + g *mp(i, 2)*(qp(i,2)-q(i,1))*work(i) + &1409 sigd*evap(i, 1)1410 fq(i, 1) = fq(i, 1) + g *am(i)*(q(i,2)-q(i,1))*work(i)1411 fu(i, 1) = fu(i, 1) + g *work(i)*(mp(i,2)*(up(i,2)-u(i,1))+am(i)*(u(i, &1412 2)-u(i,1)))1413 fv(i, 1) = fv(i, 1) + g *work(i)*(mp(i,2)*(vp(i,2)-v(i,1))+am(i)*(v(i, &1414 2)-v(i,1)))1389 IF ((g * work(i) * am(i))>=delti) iflag(i) = 1 1390 ft(i, 1) = ft(i, 1) + g * work(i) * am(i) * (t(i, 2) - t(i, 1) + (gz(i, 2) - gz(i, & 1391 1)) / cpn(i, 1)) 1392 ft(i, 1) = ft(i, 1) - lvcp(i, 1) * sigd * evap(i, 1) 1393 ft(i, 1) = ft(i, 1) + sigd * wt(i, 2) * (cl - cpd) * water(i, 2) * (t(i, 2) - t(i, 1)) * & 1394 work(i) / cpn(i, 1) 1395 fq(i, 1) = fq(i, 1) + g * mp(i, 2) * (qp(i, 2) - q(i, 1)) * work(i) + & 1396 sigd * evap(i, 1) 1397 fq(i, 1) = fq(i, 1) + g * am(i) * (q(i, 2) - q(i, 1)) * work(i) 1398 fu(i, 1) = fu(i, 1) + g * work(i) * (mp(i, 2) * (up(i, 2) - u(i, 1)) + am(i) * (u(i, & 1399 2) - u(i, 1))) 1400 fv(i, 1) = fv(i, 1) + g * work(i) * (mp(i, 2) * (vp(i, 2) - v(i, 1)) + am(i) * (v(i, & 1401 2) - v(i, 1))) 1415 1402 END DO 1416 1403 DO j = 2, nl 1417 1404 DO i = 1, ncum 1418 1405 IF (j<=inb(i)) THEN 1419 fq(i, 1) = fq(i, 1) + g *work(i)*ment(i, j, 1)*(qent(i,j,1)-q(i,1))1420 fu(i, 1) = fu(i, 1) + g *work(i)*ment(i, j, 1)*(uent(i,j,1)-u(i,1))1421 fv(i, 1) = fv(i, 1) + g *work(i)*ment(i, j, 1)*(vent(i,j,1)-v(i,1))1406 fq(i, 1) = fq(i, 1) + g * work(i) * ment(i, j, 1) * (qent(i, j, 1) - q(i, 1)) 1407 fu(i, 1) = fu(i, 1) + g * work(i) * ment(i, j, 1) * (uent(i, j, 1) - u(i, 1)) 1408 fv(i, 1) = fv(i, 1) + g * work(i) * ment(i, j, 1) * (vent(i, j, 1) - v(i, 1)) 1422 1409 END IF 1423 1410 END DO … … 1443 1430 DO k = i + 1, nl + 1 1444 1431 DO ij = 1, ncum 1445 IF ((i>=nk(ij)) .AND. (i<=inb(ij)) .AND. (k<=(inb(ij) +1))) THEN1432 IF ((i>=nk(ij)) .AND. (i<=inb(ij)) .AND. (k<=(inb(ij) + 1))) THEN 1446 1433 amp1(ij) = amp1(ij) + m(ij, k) 1447 1434 END IF … … 1452 1439 DO j = i + 1, nl + 1 1453 1440 DO ij = 1, ncum 1454 IF ((j<=(inb(ij) +1)) .AND. (i<=inb(ij))) THEN1441 IF ((j<=(inb(ij) + 1)) .AND. (i<=inb(ij))) THEN 1455 1442 amp1(ij) = amp1(ij) + ment(ij, k, j) 1456 1443 END IF … … 1470 1457 DO ij = 1, ncum 1471 1458 IF (i<=inb(ij)) THEN 1472 dpinv = 0.01 /(ph(ij,i)-ph(ij,i+1))1473 cpinv = 1.0 /cpn(ij, i)1474 1475 ft(ij, i) = ft(ij, i) + g *dpinv*(amp1(ij)*(t(ij,i+1)-t(ij, &1476 i)+(gz(ij,i+1)-gz(ij,i))*cpinv)-ad(ij)*(t(ij,i)-t(ij, &1477 i-1)+(gz(ij,i)-gz(ij,i-1))*cpinv)) - sigd*lvcp(ij, i)*evap(ij, i)1478 ft(ij, i) = ft(ij, i) + g *dpinv*ment(ij, i, i)*(hp(ij,i)-h(ij,i)+t(ij &1479 ,i)*(cpv-cpd)*(q(ij,i)-qent(ij,i,i)))*cpinv1480 ft(ij, i) = ft(ij, i) + sigd *wt(ij, i+1)*(cl-cpd)*water(ij, i+1)*(t(&1481 ij,i+1)-t(ij,i))*dpinv*cpinv1482 fq(ij, i) = fq(ij, i) + g *dpinv*(amp1(ij)*(q(ij,i+1)-q(ij, &1483 i))-ad(ij)*(q(ij,i)-q(ij,i-1)))1484 fu(ij, i) = fu(ij, i) + g *dpinv*(amp1(ij)*(u(ij,i+1)-u(ij, &1485 i))-ad(ij)*(u(ij,i)-u(ij,i-1)))1486 fv(ij, i) = fv(ij, i) + g *dpinv*(amp1(ij)*(v(ij,i+1)-v(ij, &1487 i))-ad(ij)*(v(ij,i)-v(ij,i-1)))1459 dpinv = 0.01 / (ph(ij, i) - ph(ij, i + 1)) 1460 cpinv = 1.0 / cpn(ij, i) 1461 1462 ft(ij, i) = ft(ij, i) + g * dpinv * (amp1(ij) * (t(ij, i + 1) - t(ij, & 1463 i) + (gz(ij, i + 1) - gz(ij, i)) * cpinv) - ad(ij) * (t(ij, i) - t(ij, & 1464 i - 1) + (gz(ij, i) - gz(ij, i - 1)) * cpinv)) - sigd * lvcp(ij, i) * evap(ij, i) 1465 ft(ij, i) = ft(ij, i) + g * dpinv * ment(ij, i, i) * (hp(ij, i) - h(ij, i) + t(ij & 1466 , i) * (cpv - cpd) * (q(ij, i) - qent(ij, i, i))) * cpinv 1467 ft(ij, i) = ft(ij, i) + sigd * wt(ij, i + 1) * (cl - cpd) * water(ij, i + 1) * (t(& 1468 ij, i + 1) - t(ij, i)) * dpinv * cpinv 1469 fq(ij, i) = fq(ij, i) + g * dpinv * (amp1(ij) * (q(ij, i + 1) - q(ij, & 1470 i)) - ad(ij) * (q(ij, i) - q(ij, i - 1))) 1471 fu(ij, i) = fu(ij, i) + g * dpinv * (amp1(ij) * (u(ij, i + 1) - u(ij, & 1472 i)) - ad(ij) * (u(ij, i) - u(ij, i - 1))) 1473 fv(ij, i) = fv(ij, i) + g * dpinv * (amp1(ij) * (v(ij, i + 1) - v(ij, & 1474 i)) - ad(ij) * (v(ij, i) - v(ij, i - 1))) 1488 1475 END IF 1489 1476 END DO … … 1491 1478 DO ij = 1, ncum 1492 1479 IF (i<=inb(ij)) THEN 1493 awat = elij(ij, k, i) - (1. -ep(ij,i))*clw(ij, i)1480 awat = elij(ij, k, i) - (1. - ep(ij, i)) * clw(ij, i) 1494 1481 awat = max(awat, 0.0) 1495 fq(ij, i) = fq(ij, i) + g *dpinv*ment(ij, k, i)*(qent(ij,k,i)-awat-q &1496 (ij,i))1497 fu(ij, i) = fu(ij, i) + g *dpinv*ment(ij, k, i)*(uent(ij,k,i)-u(ij,i &1498 ))1499 fv(ij, i) = fv(ij, i) + g *dpinv*ment(ij, k, i)*(vent(ij,k,i)-v(ij,i &1500 ))1482 fq(ij, i) = fq(ij, i) + g * dpinv * ment(ij, k, i) * (qent(ij, k, i) - awat - q & 1483 (ij, i)) 1484 fu(ij, i) = fu(ij, i) + g * dpinv * ment(ij, k, i) * (uent(ij, k, i) - u(ij, i & 1485 )) 1486 fv(ij, i) = fv(ij, i) + g * dpinv * ment(ij, k, i) * (vent(ij, k, i) - v(ij, i & 1487 )) 1501 1488 ! (saturated updrafts resulting from mixing) ! cld 1502 qcond(ij, i) = qcond(ij, i) + (elij(ij, k,i)-awat) ! cld1489 qcond(ij, i) = qcond(ij, i) + (elij(ij, k, i) - awat) ! cld 1503 1490 nqcond(ij, i) = nqcond(ij, i) + 1. ! cld 1504 1491 END IF … … 1508 1495 DO ij = 1, ncum 1509 1496 IF ((i<=inb(ij)) .AND. (k<=inb(ij))) THEN 1510 fq(ij, i) = fq(ij, i) + g *dpinv*ment(ij, k, i)*(qent(ij,k,i)-q(ij,i &1511 ))1512 fu(ij, i) = fu(ij, i) + g *dpinv*ment(ij, k, i)*(uent(ij,k,i)-u(ij,i &1513 ))1514 fv(ij, i) = fv(ij, i) + g *dpinv*ment(ij, k, i)*(vent(ij,k,i)-v(ij,i &1515 ))1497 fq(ij, i) = fq(ij, i) + g * dpinv * ment(ij, k, i) * (qent(ij, k, i) - q(ij, i & 1498 )) 1499 fu(ij, i) = fu(ij, i) + g * dpinv * ment(ij, k, i) * (uent(ij, k, i) - u(ij, i & 1500 )) 1501 fv(ij, i) = fv(ij, i) + g * dpinv * ment(ij, k, i) * (vent(ij, k, i) - v(ij, i & 1502 )) 1516 1503 END IF 1517 1504 END DO … … 1519 1506 DO ij = 1, ncum 1520 1507 IF (i<=inb(ij)) THEN 1521 fq(ij, i) = fq(ij, i) + sigd *evap(ij, i) + g*(mp(ij,i+1)*(qp(ij, &1522 i+1)-q(ij,i))-mp(ij,i)*(qp(ij,i)-q(ij,i-1)))*dpinv1523 fu(ij, i) = fu(ij, i) + g *(mp(ij,i+1)*(up(ij,i+1)-u(ij, &1524 i))-mp(ij,i)*(up(ij,i)-u(ij,i-1)))*dpinv1525 fv(ij, i) = fv(ij, i) + g *(mp(ij,i+1)*(vp(ij,i+1)-v(ij, &1526 i))-mp(ij,i)*(vp(ij,i)-v(ij,i-1)))*dpinv1508 fq(ij, i) = fq(ij, i) + sigd * evap(ij, i) + g * (mp(ij, i + 1) * (qp(ij, & 1509 i + 1) - q(ij, i)) - mp(ij, i) * (qp(ij, i) - q(ij, i - 1))) * dpinv 1510 fu(ij, i) = fu(ij, i) + g * (mp(ij, i + 1) * (up(ij, i + 1) - u(ij, & 1511 i)) - mp(ij, i) * (up(ij, i) - u(ij, i - 1))) * dpinv 1512 fv(ij, i) = fv(ij, i) + g * (mp(ij, i + 1) * (vp(ij, i + 1) - v(ij, & 1513 i)) - mp(ij, i) * (vp(ij, i) - v(ij, i - 1))) * dpinv 1527 1514 ! (saturated downdrafts resulting from mixing) ! cld 1528 1515 DO k = i + 1, inb(ij) ! cld … … 1531 1518 END DO ! cld 1532 1519 ! (particular case: no detraining level is found) ! cld 1533 IF (nent(ij, i)==0) THEN ! cld1534 qcond(ij, i) = qcond(ij, i) + (1. -ep(ij,i))*clw(ij, i) ! cld1520 IF (nent(ij, i)==0) THEN ! cld 1521 qcond(ij, i) = qcond(ij, i) + (1. - ep(ij, i)) * clw(ij, i) ! cld 1535 1522 nqcond(ij, i) = nqcond(ij, i) + 1. ! cld 1536 1523 END IF ! cld 1537 IF (nqcond(ij, i)/=0.) THEN ! cld1538 qcond(ij, i) = qcond(ij, i) /nqcond(ij, i) ! cld1524 IF (nqcond(ij, i)/=0.) THEN ! cld 1525 qcond(ij, i) = qcond(ij, i) / nqcond(ij, i) ! cld 1539 1526 END IF ! cld 1540 1527 END IF 1541 1528 END DO 1542 1500 END DO1529 1500 END DO 1543 1530 1544 1531 ! *** Adjust tendencies at top of convection layer to reflect *** … … 1547 1534 DO ij = 1, ncum 1548 1535 fqold = fq(ij, inb(ij)) 1549 fq(ij, inb(ij)) = fq(ij, inb(ij)) *(1.-frac(ij))1550 fq(ij, inb(ij) -1) = fq(ij, inb(ij)-1) + frac(ij)*fqold*((ph(ij, &1551 inb(ij))-ph(ij,inb(ij)+1))/(ph(ij,inb(ij)-1)-ph(ij, &1552 inb(ij))))*lv(ij, inb(ij))/lv(ij, inb(ij)-1)1536 fq(ij, inb(ij)) = fq(ij, inb(ij)) * (1. - frac(ij)) 1537 fq(ij, inb(ij) - 1) = fq(ij, inb(ij) - 1) + frac(ij) * fqold * ((ph(ij, & 1538 inb(ij)) - ph(ij, inb(ij) + 1)) / (ph(ij, inb(ij) - 1) - ph(ij, & 1539 inb(ij)))) * lv(ij, inb(ij)) / lv(ij, inb(ij) - 1) 1553 1540 ftold = ft(ij, inb(ij)) 1554 ft(ij, inb(ij)) = ft(ij, inb(ij)) *(1.-frac(ij))1555 ft(ij, inb(ij) -1) = ft(ij, inb(ij)-1) + frac(ij)*ftold*((ph(ij, &1556 inb(ij))-ph(ij,inb(ij)+1))/(ph(ij,inb(ij)-1)-ph(ij, &1557 inb(ij))))*cpn(ij, inb(ij))/cpn(ij, inb(ij)-1)1541 ft(ij, inb(ij)) = ft(ij, inb(ij)) * (1. - frac(ij)) 1542 ft(ij, inb(ij) - 1) = ft(ij, inb(ij) - 1) + frac(ij) * ftold * ((ph(ij, & 1543 inb(ij)) - ph(ij, inb(ij) + 1)) / (ph(ij, inb(ij) - 1) - ph(ij, & 1544 inb(ij)))) * cpn(ij, inb(ij)) / cpn(ij, inb(ij) - 1) 1558 1545 fuold = fu(ij, inb(ij)) 1559 fu(ij, inb(ij)) = fu(ij, inb(ij)) *(1.-frac(ij))1560 fu(ij, inb(ij) -1) = fu(ij, inb(ij)-1) + frac(ij)*fuold*((ph(ij, &1561 inb(ij))-ph(ij,inb(ij)+1))/(ph(ij,inb(ij)-1)-ph(ij,inb(ij))))1546 fu(ij, inb(ij)) = fu(ij, inb(ij)) * (1. - frac(ij)) 1547 fu(ij, inb(ij) - 1) = fu(ij, inb(ij) - 1) + frac(ij) * fuold * ((ph(ij, & 1548 inb(ij)) - ph(ij, inb(ij) + 1)) / (ph(ij, inb(ij) - 1) - ph(ij, inb(ij)))) 1562 1549 fvold = fv(ij, inb(ij)) 1563 fv(ij, inb(ij)) = fv(ij, inb(ij)) *(1.-frac(ij))1564 fv(ij, inb(ij) -1) = fv(ij, inb(ij)-1) + frac(ij)*fvold*((ph(ij, &1565 inb(ij))-ph(ij,inb(ij)+1))/(ph(ij,inb(ij)-1)-ph(ij,inb(ij))))1550 fv(ij, inb(ij)) = fv(ij, inb(ij)) * (1. - frac(ij)) 1551 fv(ij, inb(ij) - 1) = fv(ij, inb(ij) - 1) + frac(ij) * fvold * ((ph(ij, & 1552 inb(ij)) - ph(ij, inb(ij) + 1)) / (ph(ij, inb(ij) - 1) - ph(ij, inb(ij)))) 1566 1553 END DO 1567 1554 … … 1574 1561 vav(ij) = 0.0 1575 1562 DO i = 1, inb(ij) 1576 ents(ij) = ents(ij) + (cpn(ij, i)*ft(ij,i)+lv(ij,i)*fq(ij,i))*(ph(ij,i)- &1577 ph(ij,i+1))1578 uav(ij) = uav(ij) + fu(ij, i) *(ph(ij,i)-ph(ij,i+1))1579 vav(ij) = vav(ij) + fv(ij, i) *(ph(ij,i)-ph(ij,i+1))1563 ents(ij) = ents(ij) + (cpn(ij, i) * ft(ij, i) + lv(ij, i) * fq(ij, i)) * (ph(ij, i) - & 1564 ph(ij, i + 1)) 1565 uav(ij) = uav(ij) + fu(ij, i) * (ph(ij, i) - ph(ij, i + 1)) 1566 vav(ij) = vav(ij) + fv(ij, i) * (ph(ij, i) - ph(ij, i + 1)) 1580 1567 END DO 1581 1568 END DO 1582 1569 DO ij = 1, ncum 1583 ents(ij) = ents(ij) /(ph(ij,1)-ph(ij,inb(ij)+1))1584 uav(ij) = uav(ij) /(ph(ij,1)-ph(ij,inb(ij)+1))1585 vav(ij) = vav(ij) /(ph(ij,1)-ph(ij,inb(ij)+1))1570 ents(ij) = ents(ij) / (ph(ij, 1) - ph(ij, inb(ij) + 1)) 1571 uav(ij) = uav(ij) / (ph(ij, 1) - ph(ij, inb(ij) + 1)) 1572 vav(ij) = vav(ij) / (ph(ij, 1) - ph(ij, inb(ij) + 1)) 1586 1573 END DO 1587 1574 DO ij = 1, ncum 1588 1575 DO i = 1, inb(ij) 1589 ft(ij, i) = ft(ij, i) - ents(ij) /cpn(ij, i)1590 fu(ij, i) = (1. -cu)*(fu(ij,i)-uav(ij))1591 fv(ij, i) = (1. -cu)*(fv(ij,i)-vav(ij))1576 ft(ij, i) = ft(ij, i) - ents(ij) / cpn(ij, i) 1577 fu(ij, i) = (1. - cu) * (fu(ij, i) - uav(ij)) 1578 fv(ij, i) = (1. - cu) * (fv(ij, i) - vav(ij)) 1592 1579 END DO 1593 1580 END DO … … 1595 1582 DO k = 1, nl + 1 1596 1583 DO i = 1, ncum 1597 IF ((q(i,k)+delt*fq(i,k))<0.0) iflag(i) = 10 1598 END DO 1599 END DO 1600 1584 IF ((q(i, k) + delt * fq(i, k))<0.0) iflag(i) = 10 1585 END DO 1586 END DO 1601 1587 1602 1588 DO i = 1, ncum … … 1625 1611 DO k = nl, 1, -1 1626 1612 DO i = 1, ncum 1627 ma(i, k) = ma(i, k +1) + m(i, k)1613 ma(i, k) = ma(i, k + 1) + m(i, k) 1628 1614 END DO 1629 1615 END DO … … 1647 1633 ax(ij, i) = 0. ! cld 1648 1634 DO j = icb(ij), i ! cld 1649 ax(ij, i) = ax(ij, i) + rrd *(tvp(ij,j)-tv(ij,j)) & ! cld1650 *(ph(ij,j)-ph(ij,j+1))/p(ij, j) ! cld1635 ax(ij, i) = ax(ij, i) + rrd * (tvp(ij, j) - tv(ij, j)) & ! cld 1636 * (ph(ij, j) - ph(ij, j + 1)) / p(ij, j) ! cld 1651 1637 END DO ! cld 1652 IF (ax(ij, i)>0.0) THEN ! cld1653 wa(ij, i) = sqrt(2. *ax(ij,i)) ! cld1638 IF (ax(ij, i)>0.0) THEN ! cld 1639 wa(ij, i) = sqrt(2. * ax(ij, i)) ! cld 1654 1640 END IF ! cld 1655 1641 END DO ! cld 1656 1642 DO i = 1, nl ! cld 1657 IF (wa(ij, i)>0.0) & ! cld1658 siga(ij, i) = mac(ij, i)/wa(ij, i) & ! cld1659 *rrd*tvp(ij, i)/p(ij, i)/100./delta ! cld1660 siga(ij, i) = min(siga(ij, i), 1.0) ! cld1661 qcondc(ij, i) = siga(ij, i) *clw(ij, i)*(1.-ep(ij,i)) & ! cld1662 +(1.-siga(ij,i))*qcond(ij, i) ! cld1643 IF (wa(ij, i)>0.0) & ! cld 1644 siga(ij, i) = mac(ij, i) / wa(ij, i) & ! cld 1645 * rrd * tvp(ij, i) / p(ij, i) / 100. / delta ! cld 1646 siga(ij, i) = min(siga(ij, i), 1.0) ! cld 1647 qcondc(ij, i) = siga(ij, i) * clw(ij, i) * (1. - ep(ij, i)) & ! cld 1648 + (1. - siga(ij, i)) * qcond(ij, i) ! cld 1663 1649 END DO ! cld 1664 1650 END DO ! cld 1665 1651 1666 1667 1652 END SUBROUTINE cv_yield 1668 1653 1669 1654 SUBROUTINE cv_uncompress(nloc, len, ncum, nd, idcum, iflag, precip, cbmf, ft, & 1670 fq, fu, fv, ma, qcondc, iflag1, precip1, cbmf1, ft1, fq1, fu1, fv1, ma1, &1671 qcondc1)1655 fq, fu, fv, ma, qcondc, iflag1, precip1, cbmf1, ft1, fq1, fu1, fv1, ma1, & 1656 qcondc1) 1672 1657 IMPLICIT NONE 1673 1658 … … 1710 1695 END DO 1711 1696 1712 1713 1697 END SUBROUTINE cv_uncompress 1714 1698 -
LMDZ6/branches/Amaury_dev/libf/phylmd/lmdz_cv30.f90
r5140 r5141 1 1 ! $Id$ 2 2 3 4 5 SUBROUTINE cv30_param(nd, delt) 6 USE lmdz_conema3 7 IMPLICIT NONE 8 9 ! ------------------------------------------------------------ 10 ! Set parameters for convectL for iflag_con = 3 11 ! ------------------------------------------------------------ 12 13 14 ! *** PBCRIT IS THE CRITICAL CLOUD DEPTH (MB) BENEATH WHICH THE *** 15 ! *** PRECIPITATION EFFICIENCY IS ASSUMED TO BE ZERO *** 16 ! *** PTCRIT IS THE CLOUD DEPTH (MB) ABOVE WHICH THE PRECIP. *** 17 ! *** EFFICIENCY IS ASSUMED TO BE UNITY *** 18 ! *** SIGD IS THE FRACTIONAL AREA COVERED BY UNSATURATED DNDRAFT *** 19 ! *** SPFAC IS THE FRACTION OF PRECIPITATION FALLING OUTSIDE *** 20 ! *** OF CLOUD *** 21 22 ! [TAU: CHARACTERISTIC TIMESCALE USED TO COMPUTE ALPHA & BETA] 23 ! *** ALPHA AND BETA ARE PARAMETERS THAT CONTROL THE RATE OF *** 24 ! *** APPROACH TO QUASI-EQUILIBRIUM *** 25 ! *** (THEIR STANDARD VALUES ARE 1.0 AND 0.96, RESPECTIVELY) *** 26 ! *** (BETA MUST BE LESS THAN OR EQUAL TO 1) *** 27 28 ! *** DTCRIT IS THE CRITICAL BUOYANCY (K) USED TO ADJUST THE *** 29 ! *** APPROACH TO QUASI-EQUILIBRIUM *** 30 ! *** IT MUST BE LESS THAN 0 *** 31 32 include "cv30param.h" 33 34 INTEGER nd 35 REAL delt ! timestep (seconds) 36 37 ! noff: integer limit for convection (nd-noff) 38 ! minorig: First level of convection 39 40 ! -- limit levels for convection: 41 42 noff = 1 43 minorig = 1 44 nl = nd - noff 45 nlp = nl + 1 46 nlm = nl - 1 47 48 ! -- "microphysical" parameters: 49 50 sigd = 0.01 51 spfac = 0.15 52 pbcrit = 150.0 53 ptcrit = 500.0 54 ! IM cf. FH epmax = 0.993 55 56 omtrain = 45.0 ! used also for snow (no disctinction rain/snow) 57 58 ! -- misc: 59 60 dtovsh = -0.2 ! dT for overshoot 61 dpbase = -40. ! definition cloud base (400m above LCL) 62 dttrig = 5. ! (loose) condition for triggering 63 64 ! -- rate of approach to quasi-equilibrium: 65 66 dtcrit = -2.0 67 tau = 8000. 68 beta = 1.0 - delt / tau 69 alpha = 1.5E-3 * delt / tau 70 ! increase alpha to compensate W decrease: 71 alpha = alpha * 1.5 72 73 ! -- interface cloud parameterization: 74 75 delta = 0.01 ! cld 76 77 ! -- interface with boundary-layer (gust factor): (sb) 78 79 betad = 10.0 ! original value (from convect 4.3) 80 81 END SUBROUTINE cv30_param 82 83 SUBROUTINE cv30_prelim(len, nd, ndp1, t, q, p, ph, lv, cpn, tv, gz, h, hm, & 84 th) 85 IMPLICIT NONE 86 87 ! ===================================================================== 88 ! --- CALCULATE ARRAYS OF GEOPOTENTIAL, HEAT CAPACITY & STATIC ENERGY 89 ! "ori": from convect4.3 (vectorized) 90 ! "convect3": to be exactly consistent with convect3 91 ! ===================================================================== 92 93 ! inputs: 94 INTEGER len, nd, ndp1 95 REAL t(len, nd), q(len, nd), p(len, nd), ph(len, ndp1) 96 97 ! outputs: 98 REAL lv(len, nd), cpn(len, nd), tv(len, nd) 99 REAL gz(len, nd), h(len, nd), hm(len, nd) 100 REAL th(len, nd) 101 102 ! local variables: 103 INTEGER k, i 104 REAL rdcp 105 REAL tvx, tvy ! convect3 106 REAL cpx(len, nd) 107 108 include "cvthermo.h" 109 include "cv30param.h" 110 111 112 ! ori do 110 k=1,nlp 113 DO k = 1, nl ! convect3 3 MODULE lmdz_cv30 4 !------------------------------------------------------------ 5 ! Parameters for convectL, iflag_con=30: 6 ! (includes - microphysical parameters, 7 ! - parameters that control the rate of approach 8 ! to quasi-equilibrium) 9 ! - noff & minorig (previously in input of convect1) 10 !------------------------------------------------------------ 11 12 IMPLICIT NONE; PRIVATE 13 PUBLIC sigd, spfac, pbcrit, ptcrit, omtrain, dtovsh, dpbase, dttrig, dtcrit, & 14 tau, beta, alpha, delta, betad, noff, minorig, nl, nlp, nlm, & 15 cv30_param, cv30_prelim, cv30_feed, cv30_undilute1, cv30_trigger, & 16 cv30_compress, cv30_undilute2, cv30_closure, cv30_mixing, cv30_unsat, & 17 cv30_yield, cv30_tracer, cv30_uncompress, cv30_epmax_fn_cape 18 19 INTEGER noff, minorig, nl, nlp, nlm 20 REAL sigd, spfac 21 REAL pbcrit, ptcrit 22 REAL omtrain 23 REAL dtovsh, dpbase, dttrig 24 REAL dtcrit, tau, beta, alpha 25 REAL delta 26 REAL betad 27 28 !$OMP THREADPRIVATE(sigd, spfac, pbcrit, ptcrit, omtrain, dtovsh, dpbase, dttrig, dtcrit, & 29 !$OMP tau, beta, alpha, delta, betad, noff, minorig, nl, nlp, nlm) 30 CONTAINS 31 32 SUBROUTINE cv30_param(nd, delt) 33 USE lmdz_conema3 34 35 IMPLICIT NONE 36 37 ! ------------------------------------------------------------ 38 ! Set parameters for convectL for iflag_con = 3 39 ! ------------------------------------------------------------ 40 41 42 ! *** PBCRIT IS THE CRITICAL CLOUD DEPTH (MB) BENEATH WHICH THE *** 43 ! *** PRECIPITATION EFFICIENCY IS ASSUMED TO BE ZERO *** 44 ! *** PTCRIT IS THE CLOUD DEPTH (MB) ABOVE WHICH THE PRECIP. *** 45 ! *** EFFICIENCY IS ASSUMED TO BE UNITY *** 46 ! *** SIGD IS THE FRACTIONAL AREA COVERED BY UNSATURATED DNDRAFT *** 47 ! *** SPFAC IS THE FRACTION OF PRECIPITATION FALLING OUTSIDE *** 48 ! *** OF CLOUD *** 49 50 ! [TAU: CHARACTERISTIC TIMESCALE USED TO COMPUTE ALPHA & BETA] 51 ! *** ALPHA AND BETA ARE PARAMETERS THAT CONTROL THE RATE OF *** 52 ! *** APPROACH TO QUASI-EQUILIBRIUM *** 53 ! *** (THEIR STANDARD VALUES ARE 1.0 AND 0.96, RESPECTIVELY) *** 54 ! *** (BETA MUST BE LESS THAN OR EQUAL TO 1) *** 55 56 ! *** DTCRIT IS THE CRITICAL BUOYANCY (K) USED TO ADJUST THE *** 57 ! *** APPROACH TO QUASI-EQUILIBRIUM *** 58 ! *** IT MUST BE LESS THAN 0 *** 59 60 INTEGER nd 61 REAL delt ! timestep (seconds) 62 63 ! noff: integer limit for convection (nd-noff) 64 ! minorig: First level of convection 65 66 ! -- limit levels for convection: 67 68 noff = 1 69 minorig = 1 70 nl = nd - noff 71 nlp = nl + 1 72 nlm = nl - 1 73 74 ! -- "microphysical" parameters: 75 76 sigd = 0.01 77 spfac = 0.15 78 pbcrit = 150.0 79 ptcrit = 500.0 80 ! IM cf. FH epmax = 0.993 81 82 omtrain = 45.0 ! used also for snow (no disctinction rain/snow) 83 84 ! -- misc: 85 86 dtovsh = -0.2 ! dT for overshoot 87 dpbase = -40. ! definition cloud base (400m above LCL) 88 dttrig = 5. ! (loose) condition for triggering 89 90 ! -- rate of approach to quasi-equilibrium: 91 92 dtcrit = -2.0 93 tau = 8000. 94 beta = 1.0 - delt / tau 95 alpha = 1.5E-3 * delt / tau 96 ! increase alpha to compensate W decrease: 97 alpha = alpha * 1.5 98 99 ! -- interface cloud parameterization: 100 101 delta = 0.01 ! cld 102 103 ! -- interface with boundary-layer (gust factor): (sb) 104 105 betad = 10.0 ! original value (from convect 4.3) 106 107 END SUBROUTINE cv30_param 108 109 SUBROUTINE cv30_prelim(len, nd, ndp1, t, q, p, ph, lv, cpn, tv, gz, h, hm, & 110 th) 111 USE lmdz_cvthermo 112 113 IMPLICIT NONE 114 115 ! ===================================================================== 116 ! --- CALCULATE ARRAYS OF GEOPOTENTIAL, HEAT CAPACITY & STATIC ENERGY 117 ! "ori": from convect4.3 (vectorized) 118 ! "convect3": to be exactly consistent with convect3 119 ! ===================================================================== 120 121 ! inputs: 122 INTEGER len, nd, ndp1 123 REAL t(len, nd), q(len, nd), p(len, nd), ph(len, ndp1) 124 125 ! outputs: 126 REAL lv(len, nd), cpn(len, nd), tv(len, nd) 127 REAL gz(len, nd), h(len, nd), hm(len, nd) 128 REAL th(len, nd) 129 130 ! local variables: 131 INTEGER k, i 132 REAL rdcp 133 REAL tvx, tvy ! convect3 134 REAL cpx(len, nd) 135 136 ! ori do 110 k=1,nlp 137 DO k = 1, nl ! convect3 138 DO i = 1, len 139 ! debug lv(i,k)= lv0-clmcpv*(t(i,k)-t0) 140 lv(i, k) = lv0 - clmcpv * (t(i, k) - 273.15) 141 cpn(i, k) = cpd * (1.0 - q(i, k)) + cpv * q(i, k) 142 cpx(i, k) = cpd * (1.0 - q(i, k)) + cl * q(i, k) 143 ! ori tv(i,k)=t(i,k)*(1.0+q(i,k)*epsim1) 144 tv(i, k) = t(i, k) * (1.0 + q(i, k) / eps - q(i, k)) 145 rdcp = (rrd * (1. - q(i, k)) + q(i, k) * rrv) / cpn(i, k) 146 th(i, k) = t(i, k) * (1000.0 / p(i, k))**rdcp 147 END DO 148 END DO 149 150 ! gz = phi at the full levels (same as p). 151 114 152 DO i = 1, len 115 ! debug lv(i,k)= lv0-clmcpv*(t(i,k)-t0) 116 lv(i, k) = lv0 - clmcpv * (t(i, k) - 273.15) 117 cpn(i, k) = cpd * (1.0 - q(i, k)) + cpv * q(i, k) 118 cpx(i, k) = cpd * (1.0 - q(i, k)) + cl * q(i, k) 119 ! ori tv(i,k)=t(i,k)*(1.0+q(i,k)*epsim1) 120 tv(i, k) = t(i, k) * (1.0 + q(i, k) / eps - q(i, k)) 121 rdcp = (rrd * (1. - q(i, k)) + q(i, k) * rrv) / cpn(i, k) 122 th(i, k) = t(i, k) * (1000.0 / p(i, k))**rdcp 123 END DO 124 END DO 125 126 ! gz = phi at the full levels (same as p). 127 128 DO i = 1, len 129 gz(i, 1) = 0.0 130 END DO 131 ! ori do 140 k=2,nlp 132 DO k = 2, nl ! convect3 153 gz(i, 1) = 0.0 154 END DO 155 ! ori do 140 k=2,nlp 156 DO k = 2, nl ! convect3 157 DO i = 1, len 158 tvx = t(i, k) * (1. + q(i, k) / eps - q(i, k)) !convect3 159 tvy = t(i, k - 1) * (1. + q(i, k - 1) / eps - q(i, k - 1)) !convect3 160 gz(i, k) = gz(i, k - 1) + 0.5 * rrd * (tvx + tvy) & !convect3 161 * (p(i, k - 1) - p(i, k)) / ph(i, k) !convect3 162 163 ! ori gz(i,k)=gz(i,k-1)+hrd*(tv(i,k-1)+tv(i,k)) 164 ! ori & *(p(i,k-1)-p(i,k))/ph(i,k) 165 END DO 166 END DO 167 168 ! h = phi + cpT (dry static energy). 169 ! hm = phi + cp(T-Tbase)+Lq 170 171 ! ori do 170 k=1,nlp 172 DO k = 1, nl ! convect3 173 DO i = 1, len 174 h(i, k) = gz(i, k) + cpn(i, k) * t(i, k) 175 hm(i, k) = gz(i, k) + cpx(i, k) * (t(i, k) - t(i, 1)) + lv(i, k) * q(i, k) 176 END DO 177 END DO 178 179 END SUBROUTINE cv30_prelim 180 181 SUBROUTINE cv30_feed(len, nd, t, q, qs, p, ph, hm, gz, nk, icb, icbmax, & 182 iflag, tnk, qnk, gznk, plcl) 183 184 IMPLICIT NONE 185 186 ! ================================================================ 187 ! Purpose: CONVECTIVE FEED 188 189 ! Main differences with cv_feed: 190 ! - ph added in input 191 ! - here, nk(i)=minorig 192 ! - icb defined differently (plcl compared with ph instead of p) 193 194 ! Main differences with convect3: 195 ! - we do not compute dplcldt and dplcldr of CLIFT anymore 196 ! - values iflag different (but tests identical) 197 ! - A,B explicitely defined (!...) 198 ! ================================================================ 199 200 ! inputs: 201 INTEGER len, nd 202 REAL t(len, nd), q(len, nd), qs(len, nd), p(len, nd) 203 REAL hm(len, nd), gz(len, nd) 204 REAL ph(len, nd + 1) 205 206 ! outputs: 207 INTEGER iflag(len), nk(len), icb(len), icbmax 208 REAL tnk(len), qnk(len), gznk(len), plcl(len) 209 210 ! local variables: 211 INTEGER i, k 212 INTEGER ihmin(len) 213 REAL work(len) 214 REAL pnk(len), qsnk(len), rh(len), chi(len) 215 REAL a, b ! convect3 216 ! ym 217 plcl = 0.0 218 ! @ !------------------------------------------------------------------- 219 ! @ ! --- Find level of minimum moist static energy 220 ! @ ! --- If level of minimum moist static energy coincides with 221 ! @ ! --- or is lower than minimum allowable parcel origin level, 222 ! @ ! --- set iflag to 6. 223 ! @ !------------------------------------------------------------------- 224 ! @ 225 ! @ do 180 i=1,len 226 ! @ work(i)=1.0e12 227 ! @ ihmin(i)=nl 228 ! @ 180 continue 229 ! @ do 200 k=2,nlp 230 ! @ do 190 i=1,len 231 ! @ if((hm(i,k).lt.work(i)).AND. 232 ! @ & (hm(i,k).lt.hm(i,k-1)))THEN 233 ! @ work(i)=hm(i,k) 234 ! @ ihmin(i)=k 235 ! @ endif 236 ! @ 190 continue 237 ! @ 200 continue 238 ! @ do 210 i=1,len 239 ! @ ihmin(i)=min(ihmin(i),nlm) 240 ! @ IF(ihmin(i).le.minorig)THEN 241 ! @ iflag(i)=6 242 ! @ endif 243 ! @ 210 continue 244 ! @ c 245 ! @ !------------------------------------------------------------------- 246 ! @ ! --- Find that model level below the level of minimum moist static 247 ! @ ! --- energy that has the maximum value of moist static energy 248 ! @ !------------------------------------------------------------------- 249 ! @ 250 ! @ do 220 i=1,len 251 ! @ work(i)=hm(i,minorig) 252 ! @ nk(i)=minorig 253 ! @ 220 continue 254 ! @ do 240 k=minorig+1,nl 255 ! @ do 230 i=1,len 256 ! @ if((hm(i,k).gt.work(i)).AND.(k.le.ihmin(i)))THEN 257 ! @ work(i)=hm(i,k) 258 ! @ nk(i)=k 259 ! @ endif 260 ! @ 230 continue 261 ! @ 240 continue 262 263 ! ------------------------------------------------------------------- 264 ! --- Origin level of ascending parcels for convect3: 265 ! ------------------------------------------------------------------- 266 133 267 DO i = 1, len 134 tvx = t(i, k) * (1. + q(i, k) / eps - q(i, k)) !convect3 135 tvy = t(i, k - 1) * (1. + q(i, k - 1) / eps - q(i, k - 1)) !convect3 136 gz(i, k) = gz(i, k - 1) + 0.5 * rrd * (tvx + tvy) & !convect3 137 * (p(i, k - 1) - p(i, k)) / ph(i, k) !convect3 138 139 ! ori gz(i,k)=gz(i,k-1)+hrd*(tv(i,k-1)+tv(i,k)) 140 ! ori & *(p(i,k-1)-p(i,k))/ph(i,k) 141 END DO 142 END DO 143 144 ! h = phi + cpT (dry static energy). 145 ! hm = phi + cp(T-Tbase)+Lq 146 147 ! ori do 170 k=1,nlp 148 DO k = 1, nl ! convect3 268 nk(i) = minorig 269 END DO 270 271 ! ------------------------------------------------------------------- 272 ! --- Check whether parcel level temperature and specific humidity 273 ! --- are reasonable 274 ! ------------------------------------------------------------------- 149 275 DO i = 1, len 150 h(i, k) = gz(i, k) + cpn(i, k) * t(i, k) 151 hm(i, k) = gz(i, k) + cpx(i, k) * (t(i, k) - t(i, 1)) + lv(i, k) * q(i, k) 152 END DO 153 END DO 154 155 END SUBROUTINE cv30_prelim 156 157 SUBROUTINE cv30_feed(len, nd, t, q, qs, p, ph, hm, gz, nk, icb, icbmax, & 158 iflag, tnk, qnk, gznk, plcl) 159 IMPLICIT NONE 160 161 ! ================================================================ 162 ! Purpose: CONVECTIVE FEED 163 164 ! Main differences with cv_feed: 165 ! - ph added in input 166 ! - here, nk(i)=minorig 167 ! - icb defined differently (plcl compared with ph instead of p) 168 169 ! Main differences with convect3: 170 ! - we do not compute dplcldt and dplcldr of CLIFT anymore 171 ! - values iflag different (but tests identical) 172 ! - A,B explicitely defined (!...) 173 ! ================================================================ 174 175 include "cv30param.h" 176 177 ! inputs: 178 INTEGER len, nd 179 REAL t(len, nd), q(len, nd), qs(len, nd), p(len, nd) 180 REAL hm(len, nd), gz(len, nd) 181 REAL ph(len, nd + 1) 182 183 ! outputs: 184 INTEGER iflag(len), nk(len), icb(len), icbmax 185 REAL tnk(len), qnk(len), gznk(len), plcl(len) 186 187 ! local variables: 188 INTEGER i, k 189 INTEGER ihmin(len) 190 REAL work(len) 191 REAL pnk(len), qsnk(len), rh(len), chi(len) 192 REAL a, b ! convect3 193 ! ym 194 plcl = 0.0 195 ! @ !------------------------------------------------------------------- 196 ! @ ! --- Find level of minimum moist static energy 197 ! @ ! --- If level of minimum moist static energy coincides with 198 ! @ ! --- or is lower than minimum allowable parcel origin level, 199 ! @ ! --- set iflag to 6. 200 ! @ !------------------------------------------------------------------- 201 ! @ 202 ! @ do 180 i=1,len 203 ! @ work(i)=1.0e12 204 ! @ ihmin(i)=nl 205 ! @ 180 continue 206 ! @ do 200 k=2,nlp 207 ! @ do 190 i=1,len 208 ! @ if((hm(i,k).lt.work(i)).AND. 209 ! @ & (hm(i,k).lt.hm(i,k-1)))THEN 210 ! @ work(i)=hm(i,k) 211 ! @ ihmin(i)=k 212 ! @ endif 213 ! @ 190 continue 214 ! @ 200 continue 215 ! @ do 210 i=1,len 216 ! @ ihmin(i)=min(ihmin(i),nlm) 217 ! @ IF(ihmin(i).le.minorig)THEN 218 ! @ iflag(i)=6 219 ! @ endif 220 ! @ 210 continue 221 ! @ c 222 ! @ !------------------------------------------------------------------- 223 ! @ ! --- Find that model level below the level of minimum moist static 224 ! @ ! --- energy that has the maximum value of moist static energy 225 ! @ !------------------------------------------------------------------- 226 ! @ 227 ! @ do 220 i=1,len 228 ! @ work(i)=hm(i,minorig) 229 ! @ nk(i)=minorig 230 ! @ 220 continue 231 ! @ do 240 k=minorig+1,nl 232 ! @ do 230 i=1,len 233 ! @ if((hm(i,k).gt.work(i)).AND.(k.le.ihmin(i)))THEN 234 ! @ work(i)=hm(i,k) 235 ! @ nk(i)=k 236 ! @ endif 237 ! @ 230 continue 238 ! @ 240 continue 239 240 ! ------------------------------------------------------------------- 241 ! --- Origin level of ascending parcels for convect3: 242 ! ------------------------------------------------------------------- 243 244 DO i = 1, len 245 nk(i) = minorig 246 END DO 247 248 ! ------------------------------------------------------------------- 249 ! --- Check whether parcel level temperature and specific humidity 250 ! --- are reasonable 251 ! ------------------------------------------------------------------- 252 DO i = 1, len 253 IF (((t(i, nk(i))<250.0) .OR. (q(i, nk(i))<=0.0)) & ! @ & .OR.( 254 ! p(i,ihmin(i)).lt.400.0 255 ! ) ) 256 .AND. (iflag(i)==0)) iflag(i) = 7 257 END DO 258 ! ------------------------------------------------------------------- 259 ! --- Calculate lifted condensation level of air at parcel origin level 260 ! --- (Within 0.2% of formula of Bolton, MON. WEA. REV.,1980) 261 ! ------------------------------------------------------------------- 262 263 a = 1669.0 ! convect3 264 b = 122.0 ! convect3 265 266 DO i = 1, len 267 268 IF (iflag(i)/=7) THEN ! modif sb Jun7th 2002 269 276 IF (((t(i, nk(i))<250.0) .OR. (q(i, nk(i))<=0.0)) & ! @ & .OR.( 277 ! p(i,ihmin(i)).lt.400.0 278 ! ) ) 279 .AND. (iflag(i)==0)) iflag(i) = 7 280 END DO 281 ! ------------------------------------------------------------------- 282 ! --- Calculate lifted condensation level of air at parcel origin level 283 ! --- (Within 0.2% of formula of Bolton, MON. WEA. REV.,1980) 284 ! ------------------------------------------------------------------- 285 286 a = 1669.0 ! convect3 287 b = 122.0 ! convect3 288 289 DO i = 1, len 290 291 IF (iflag(i)/=7) THEN ! modif sb Jun7th 2002 292 293 tnk(i) = t(i, nk(i)) 294 qnk(i) = q(i, nk(i)) 295 gznk(i) = gz(i, nk(i)) 296 pnk(i) = p(i, nk(i)) 297 qsnk(i) = qs(i, nk(i)) 298 299 rh(i) = qnk(i) / qsnk(i) 300 ! ori rh(i)=min(1.0,rh(i)) ! removed for convect3 301 ! ori chi(i)=tnk(i)/(1669.0-122.0*rh(i)-tnk(i)) 302 chi(i) = tnk(i) / (a - b * rh(i) - tnk(i)) ! convect3 303 plcl(i) = pnk(i) * (rh(i)**chi(i)) 304 IF (((plcl(i)<200.0) .OR. (plcl(i)>=2000.0)) .AND. (iflag(i)==0)) iflag & 305 (i) = 8 306 307 END IF ! iflag=7 308 309 END DO 310 311 ! ------------------------------------------------------------------- 312 ! --- Calculate first level above lcl (=icb) 313 ! ------------------------------------------------------------------- 314 315 ! @ do 270 i=1,len 316 ! @ icb(i)=nlm 317 ! @ 270 continue 318 ! @c 319 ! @ do 290 k=minorig,nl 320 ! @ do 280 i=1,len 321 ! @ if((k.ge.(nk(i)+1)).AND.(p(i,k).lt.plcl(i))) 322 ! @ & icb(i)=min(icb(i),k) 323 ! @ 280 continue 324 ! @ 290 continue 325 ! @c 326 ! @ do 300 i=1,len 327 ! @ if((icb(i).ge.nlm).AND.(iflag(i).EQ.0))iflag(i)=9 328 ! @ 300 continue 329 330 DO i = 1, len 331 icb(i) = nlm 332 END DO 333 334 ! la modification consiste a comparer plcl a ph et non a p: 335 ! icb est defini par : ph(icb)<plcl<ph(icb-1) 336 ! @ do 290 k=minorig,nl 337 DO k = 3, nl - 1 ! modif pour que icb soit sup/egal a 2 338 DO i = 1, len 339 IF (ph(i, k)<plcl(i)) icb(i) = min(icb(i), k) 340 END DO 341 END DO 342 343 DO i = 1, len 344 ! @ if((icb(i).ge.nlm).AND.(iflag(i).EQ.0))iflag(i)=9 345 IF ((icb(i)==nlm) .AND. (iflag(i)==0)) iflag(i) = 9 346 END DO 347 348 DO i = 1, len 349 icb(i) = icb(i) - 1 ! icb sup ou egal a 2 350 END DO 351 352 ! Compute icbmax. 353 354 icbmax = 2 355 DO i = 1, len 356 ! icbmax=max(icbmax,icb(i)) 357 IF (iflag(i)<7) icbmax = max(icbmax, icb(i)) ! sb Jun7th02 358 END DO 359 360 END SUBROUTINE cv30_feed 361 362 SUBROUTINE cv30_undilute1(len, nd, t, q, qs, gz, plcl, p, nk, icb, tp, tvp, & 363 clw, icbs) 364 USE lmdz_cvthermo 365 366 IMPLICIT NONE 367 368 ! ---------------------------------------------------------------- 369 ! Equivalent de TLIFT entre NK et ICB+1 inclus 370 371 ! Differences with convect4: 372 ! - specify plcl in input 373 ! - icbs is the first level above LCL (may differ from icb) 374 ! - in the iterations, used x(icbs) instead x(icb) 375 ! - many minor differences in the iterations 376 ! - tvp is computed in only one time 377 ! - icbs: first level above Plcl (IMIN de TLIFT) in output 378 ! - if icbs=icb, compute also tp(icb+1),tvp(icb+1) & clw(icb+1) 379 ! ---------------------------------------------------------------- 380 381 382 383 ! inputs: 384 INTEGER len, nd 385 INTEGER nk(len), icb(len) 386 REAL t(len, nd), q(len, nd), qs(len, nd), gz(len, nd) 387 REAL p(len, nd) 388 REAL plcl(len) ! convect3 389 390 ! outputs: 391 REAL tp(len, nd), tvp(len, nd), clw(len, nd) 392 393 ! local variables: 394 INTEGER i, k 395 INTEGER icb1(len), icbs(len), icbsmax2 ! convect3 396 REAL tg, qg, alv, s, ahg, tc, denom, es, rg 397 REAL ah0(len), cpp(len) 398 REAL tnk(len), qnk(len), gznk(len), ticb(len), gzicb(len) 399 REAL qsicb(len) ! convect3 400 REAL cpinv(len) ! convect3 401 402 ! ------------------------------------------------------------------- 403 ! --- Calculates the lifted parcel virtual temperature at nk, 404 ! --- the actual temperature, and the adiabatic 405 ! --- liquid water content. The procedure is to solve the equation. 406 ! cp*tp+L*qp+phi=cp*tnk+L*qnk+gznk. 407 ! ------------------------------------------------------------------- 408 409 DO i = 1, len 270 410 tnk(i) = t(i, nk(i)) 271 411 qnk(i) = q(i, nk(i)) 272 412 gznk(i) = gz(i, nk(i)) 273 pnk(i) = p(i, nk(i)) 274 qsnk(i) = qs(i, nk(i)) 275 276 rh(i) = qnk(i) / qsnk(i) 277 ! ori rh(i)=min(1.0,rh(i)) ! removed for convect3 278 ! ori chi(i)=tnk(i)/(1669.0-122.0*rh(i)-tnk(i)) 279 chi(i) = tnk(i) / (a - b * rh(i) - tnk(i)) ! convect3 280 plcl(i) = pnk(i) * (rh(i)**chi(i)) 281 IF (((plcl(i)<200.0) .OR. (plcl(i)>=2000.0)) .AND. (iflag(i)==0)) iflag & 282 (i) = 8 283 284 END IF ! iflag=7 285 286 END DO 287 288 ! ------------------------------------------------------------------- 289 ! --- Calculate first level above lcl (=icb) 290 ! ------------------------------------------------------------------- 291 292 ! @ do 270 i=1,len 293 ! @ icb(i)=nlm 294 ! @ 270 continue 295 ! @c 296 ! @ do 290 k=minorig,nl 297 ! @ do 280 i=1,len 298 ! @ if((k.ge.(nk(i)+1)).AND.(p(i,k).lt.plcl(i))) 299 ! @ & icb(i)=min(icb(i),k) 300 ! @ 280 continue 301 ! @ 290 continue 302 ! @c 303 ! @ do 300 i=1,len 304 ! @ if((icb(i).ge.nlm).AND.(iflag(i).EQ.0))iflag(i)=9 305 ! @ 300 continue 306 307 DO i = 1, len 308 icb(i) = nlm 309 END DO 310 311 ! la modification consiste a comparer plcl a ph et non a p: 312 ! icb est defini par : ph(icb)<plcl<ph(icb-1) 313 ! @ do 290 k=minorig,nl 314 DO k = 3, nl - 1 ! modif pour que icb soit sup/egal a 2 413 ! ori ticb(i)=t(i,icb(i)) 414 ! ori gzicb(i)=gz(i,icb(i)) 415 END DO 416 417 ! *** Calculate certain parcel quantities, including static energy *** 418 315 419 DO i = 1, len 316 IF (ph(i, k)<plcl(i)) icb(i) = min(icb(i), k) 317 END DO 318 END DO 319 320 DO i = 1, len 321 ! @ if((icb(i).ge.nlm).AND.(iflag(i).EQ.0))iflag(i)=9 322 IF ((icb(i)==nlm) .AND. (iflag(i)==0)) iflag(i) = 9 323 END DO 324 325 DO i = 1, len 326 icb(i) = icb(i) - 1 ! icb sup ou egal a 2 327 END DO 328 329 ! Compute icbmax. 330 331 icbmax = 2 332 DO i = 1, len 333 ! icbmax=max(icbmax,icb(i)) 334 IF (iflag(i)<7) icbmax = max(icbmax, icb(i)) ! sb Jun7th02 335 END DO 336 337 END SUBROUTINE cv30_feed 338 339 SUBROUTINE cv30_undilute1(len, nd, t, q, qs, gz, plcl, p, nk, icb, tp, tvp, & 340 clw, icbs) 341 IMPLICIT NONE 342 343 ! ---------------------------------------------------------------- 344 ! Equivalent de TLIFT entre NK et ICB+1 inclus 345 346 ! Differences with convect4: 347 ! - specify plcl in input 348 ! - icbs is the first level above LCL (may differ from icb) 349 ! - in the iterations, used x(icbs) instead x(icb) 350 ! - many minor differences in the iterations 351 ! - tvp is computed in only one time 352 ! - icbs: first level above Plcl (IMIN de TLIFT) in output 353 ! - if icbs=icb, compute also tp(icb+1),tvp(icb+1) & clw(icb+1) 354 ! ---------------------------------------------------------------- 355 356 include "cvthermo.h" 357 include "cv30param.h" 358 359 ! inputs: 360 INTEGER len, nd 361 INTEGER nk(len), icb(len) 362 REAL t(len, nd), q(len, nd), qs(len, nd), gz(len, nd) 363 REAL p(len, nd) 364 REAL plcl(len) ! convect3 365 366 ! outputs: 367 REAL tp(len, nd), tvp(len, nd), clw(len, nd) 368 369 ! local variables: 370 INTEGER i, k 371 INTEGER icb1(len), icbs(len), icbsmax2 ! convect3 372 REAL tg, qg, alv, s, ahg, tc, denom, es, rg 373 REAL ah0(len), cpp(len) 374 REAL tnk(len), qnk(len), gznk(len), ticb(len), gzicb(len) 375 REAL qsicb(len) ! convect3 376 REAL cpinv(len) ! convect3 377 378 ! ------------------------------------------------------------------- 379 ! --- Calculates the lifted parcel virtual temperature at nk, 380 ! --- the actual temperature, and the adiabatic 381 ! --- liquid water content. The procedure is to solve the equation. 382 ! cp*tp+L*qp+phi=cp*tnk+L*qnk+gznk. 383 ! ------------------------------------------------------------------- 384 385 DO i = 1, len 386 tnk(i) = t(i, nk(i)) 387 qnk(i) = q(i, nk(i)) 388 gznk(i) = gz(i, nk(i)) 389 ! ori ticb(i)=t(i,icb(i)) 390 ! ori gzicb(i)=gz(i,icb(i)) 391 END DO 392 393 ! *** Calculate certain parcel quantities, including static energy *** 394 395 DO i = 1, len 396 ah0(i) = (cpd * (1. - qnk(i)) + cl * qnk(i)) * tnk(i) + qnk(i) * (lv0 - clmcpv * (tnk(i) - & 397 273.15)) + gznk(i) 398 cpp(i) = cpd * (1. - qnk(i)) + qnk(i) * cpv 399 cpinv(i) = 1. / cpp(i) 400 END DO 401 402 ! *** Calculate lifted parcel quantities below cloud base *** 403 404 DO i = 1, len !convect3 405 icb1(i) = min(max(icb(i), 2), nl) 406 ! if icb is below LCL, start loop at ICB+1: 407 ! (icbs est le premier niveau au-dessus du LCL) 408 icbs(i) = icb1(i) !convect3 409 IF (plcl(i)<p(i, icb1(i))) THEN 410 icbs(i) = min(icbs(i) + 1, nl) !convect3 420 ah0(i) = (cpd * (1. - qnk(i)) + cl * qnk(i)) * tnk(i) + qnk(i) * (lv0 - clmcpv * (tnk(i) - & 421 273.15)) + gznk(i) 422 cpp(i) = cpd * (1. - qnk(i)) + qnk(i) * cpv 423 cpinv(i) = 1. / cpp(i) 424 END DO 425 426 ! *** Calculate lifted parcel quantities below cloud base *** 427 428 DO i = 1, len !convect3 429 icb1(i) = min(max(icb(i), 2), nl) 430 ! if icb is below LCL, start loop at ICB+1: 431 ! (icbs est le premier niveau au-dessus du LCL) 432 icbs(i) = icb1(i) !convect3 433 IF (plcl(i)<p(i, icb1(i))) THEN 434 icbs(i) = min(icbs(i) + 1, nl) !convect3 435 END IF 436 END DO !convect3 437 438 DO i = 1, len !convect3 439 ticb(i) = t(i, icbs(i)) !convect3 440 gzicb(i) = gz(i, icbs(i)) !convect3 441 qsicb(i) = qs(i, icbs(i)) !convect3 442 END DO !convect3 443 444 445 ! Re-compute icbsmax (icbsmax2): !convect3 446 !convect3 447 icbsmax2 = 2 !convect3 448 DO i = 1, len !convect3 449 icbsmax2 = max(icbsmax2, icbs(i)) !convect3 450 END DO !convect3 451 452 ! initialization outputs: 453 454 DO k = 1, icbsmax2 ! convect3 455 DO i = 1, len ! convect3 456 tp(i, k) = 0.0 ! convect3 457 tvp(i, k) = 0.0 ! convect3 458 clw(i, k) = 0.0 ! convect3 459 END DO ! convect3 460 END DO ! convect3 461 462 ! tp and tvp below cloud base: 463 464 DO k = minorig, icbsmax2 - 1 465 DO i = 1, len 466 tp(i, k) = tnk(i) - (gz(i, k) - gznk(i)) * cpinv(i) 467 tvp(i, k) = tp(i, k) * (1. + qnk(i) / eps - qnk(i)) !whole thing (convect3) 468 END DO 469 END DO 470 471 ! *** Find lifted parcel quantities above cloud base *** 472 473 DO i = 1, len 474 tg = ticb(i) 475 ! ori qg=qs(i,icb(i)) 476 qg = qsicb(i) ! convect3 477 ! debug alv=lv0-clmcpv*(ticb(i)-t0) 478 alv = lv0 - clmcpv * (ticb(i) - 273.15) 479 480 ! First iteration. 481 482 ! ori s=cpd+alv*alv*qg/(rrv*ticb(i)*ticb(i)) 483 s = cpd * (1. - qnk(i)) + cl * qnk(i) & ! convect3 484 + alv * alv * qg / (rrv * ticb(i) * ticb(i)) ! convect3 485 s = 1. / s 486 ! ori ahg=cpd*tg+(cl-cpd)*qnk(i)*ticb(i)+alv*qg+gzicb(i) 487 ahg = cpd * tg + (cl - cpd) * qnk(i) * tg + alv * qg + gzicb(i) ! convect3 488 tg = tg + s * (ah0(i) - ahg) 489 ! ori tg=max(tg,35.0) 490 ! debug tc=tg-t0 491 tc = tg - 273.15 492 denom = 243.5 + tc 493 denom = max(denom, 1.0) ! convect3 494 ! ori IF(tc.ge.0.0)THEN 495 es = 6.112 * exp(17.67 * tc / denom) 496 ! ori else 497 ! ori es=exp(23.33086-6111.72784/tg+0.15215*log(tg)) 498 ! ori endif 499 ! ori qg=eps*es/(p(i,icb(i))-es*(1.-eps)) 500 qg = eps * es / (p(i, icbs(i)) - es * (1. - eps)) 501 502 ! Second iteration. 503 504 505 ! ori s=cpd+alv*alv*qg/(rrv*ticb(i)*ticb(i)) 506 ! ori s=1./s 507 ! ori ahg=cpd*tg+(cl-cpd)*qnk(i)*ticb(i)+alv*qg+gzicb(i) 508 ahg = cpd * tg + (cl - cpd) * qnk(i) * tg + alv * qg + gzicb(i) ! convect3 509 tg = tg + s * (ah0(i) - ahg) 510 ! ori tg=max(tg,35.0) 511 ! debug tc=tg-t0 512 tc = tg - 273.15 513 denom = 243.5 + tc 514 denom = max(denom, 1.0) ! convect3 515 ! ori IF(tc.ge.0.0)THEN 516 es = 6.112 * exp(17.67 * tc / denom) 517 ! ori else 518 ! ori es=exp(23.33086-6111.72784/tg+0.15215*log(tg)) 519 ! ori end if 520 ! ori qg=eps*es/(p(i,icb(i))-es*(1.-eps)) 521 qg = eps * es / (p(i, icbs(i)) - es * (1. - eps)) 522 523 alv = lv0 - clmcpv * (ticb(i) - 273.15) 524 525 ! ori c approximation here: 526 ! ori tp(i,icb(i))=(ah0(i)-(cl-cpd)*qnk(i)*ticb(i) 527 ! ori & -gz(i,icb(i))-alv*qg)/cpd 528 529 ! convect3: no approximation: 530 tp(i, icbs(i)) = (ah0(i) - gz(i, icbs(i)) - alv * qg) / (cpd + (cl - cpd) * qnk(i)) 531 532 ! ori clw(i,icb(i))=qnk(i)-qg 533 ! ori clw(i,icb(i))=max(0.0,clw(i,icb(i))) 534 clw(i, icbs(i)) = qnk(i) - qg 535 clw(i, icbs(i)) = max(0.0, clw(i, icbs(i))) 536 537 rg = qg / (1. - qnk(i)) 538 ! ori tvp(i,icb(i))=tp(i,icb(i))*(1.+rg*epsi) 539 ! convect3: (qg utilise au lieu du vrai mixing ratio rg) 540 tvp(i, icbs(i)) = tp(i, icbs(i)) * (1. + qg / eps - qnk(i)) !whole thing 541 542 END DO 543 544 ! ori do 380 k=minorig,icbsmax2 545 ! ori do 370 i=1,len 546 ! ori tvp(i,k)=tvp(i,k)-tp(i,k)*qnk(i) 547 ! ori 370 continue 548 ! ori 380 continue 549 550 551 ! -- The following is only for convect3: 552 553 ! * icbs is the first level above the LCL: 554 ! if plcl<p(icb), then icbs=icb+1 555 ! if plcl>p(icb), then icbs=icb 556 557 ! * the routine above computes tvp from minorig to icbs (included). 558 559 ! * to compute buoybase (in cv3_trigger.F), both tvp(icb) and tvp(icb+1) 560 ! must be known. This is the case if icbs=icb+1, but not if icbs=icb. 561 562 ! * therefore, in the case icbs=icb, we compute tvp at level icb+1 563 ! (tvp at other levels will be computed in cv3_undilute2.F) 564 565 DO i = 1, len 566 ticb(i) = t(i, icb(i) + 1) 567 gzicb(i) = gz(i, icb(i) + 1) 568 qsicb(i) = qs(i, icb(i) + 1) 569 END DO 570 571 DO i = 1, len 572 tg = ticb(i) 573 qg = qsicb(i) ! convect3 574 ! debug alv=lv0-clmcpv*(ticb(i)-t0) 575 alv = lv0 - clmcpv * (ticb(i) - 273.15) 576 577 ! First iteration. 578 579 ! ori s=cpd+alv*alv*qg/(rrv*ticb(i)*ticb(i)) 580 s = cpd * (1. - qnk(i)) + cl * qnk(i) & ! convect3 581 + alv * alv * qg / (rrv * ticb(i) * ticb(i)) ! convect3 582 s = 1. / s 583 ! ori ahg=cpd*tg+(cl-cpd)*qnk(i)*ticb(i)+alv*qg+gzicb(i) 584 ahg = cpd * tg + (cl - cpd) * qnk(i) * tg + alv * qg + gzicb(i) ! convect3 585 tg = tg + s * (ah0(i) - ahg) 586 ! ori tg=max(tg,35.0) 587 ! debug tc=tg-t0 588 tc = tg - 273.15 589 denom = 243.5 + tc 590 denom = max(denom, 1.0) ! convect3 591 ! ori IF(tc.ge.0.0)THEN 592 es = 6.112 * exp(17.67 * tc / denom) 593 ! ori else 594 ! ori es=exp(23.33086-6111.72784/tg+0.15215*log(tg)) 595 ! ori endif 596 ! ori qg=eps*es/(p(i,icb(i))-es*(1.-eps)) 597 qg = eps * es / (p(i, icb(i) + 1) - es * (1. - eps)) 598 599 ! Second iteration. 600 601 602 ! ori s=cpd+alv*alv*qg/(rrv*ticb(i)*ticb(i)) 603 ! ori s=1./s 604 ! ori ahg=cpd*tg+(cl-cpd)*qnk(i)*ticb(i)+alv*qg+gzicb(i) 605 ahg = cpd * tg + (cl - cpd) * qnk(i) * tg + alv * qg + gzicb(i) ! convect3 606 tg = tg + s * (ah0(i) - ahg) 607 ! ori tg=max(tg,35.0) 608 ! debug tc=tg-t0 609 tc = tg - 273.15 610 denom = 243.5 + tc 611 denom = max(denom, 1.0) ! convect3 612 ! ori IF(tc.ge.0.0)THEN 613 es = 6.112 * exp(17.67 * tc / denom) 614 ! ori else 615 ! ori es=exp(23.33086-6111.72784/tg+0.15215*log(tg)) 616 ! ori end if 617 ! ori qg=eps*es/(p(i,icb(i))-es*(1.-eps)) 618 qg = eps * es / (p(i, icb(i) + 1) - es * (1. - eps)) 619 620 alv = lv0 - clmcpv * (ticb(i) - 273.15) 621 622 ! ori c approximation here: 623 ! ori tp(i,icb(i))=(ah0(i)-(cl-cpd)*qnk(i)*ticb(i) 624 ! ori & -gz(i,icb(i))-alv*qg)/cpd 625 626 ! convect3: no approximation: 627 tp(i, icb(i) + 1) = (ah0(i) - gz(i, icb(i) + 1) - alv * qg) / (cpd + (cl - cpd) * qnk(i)) 628 629 ! ori clw(i,icb(i))=qnk(i)-qg 630 ! ori clw(i,icb(i))=max(0.0,clw(i,icb(i))) 631 clw(i, icb(i) + 1) = qnk(i) - qg 632 clw(i, icb(i) + 1) = max(0.0, clw(i, icb(i) + 1)) 633 634 rg = qg / (1. - qnk(i)) 635 ! ori tvp(i,icb(i))=tp(i,icb(i))*(1.+rg*epsi) 636 ! convect3: (qg utilise au lieu du vrai mixing ratio rg) 637 tvp(i, icb(i) + 1) = tp(i, icb(i) + 1) * (1. + qg / eps - qnk(i)) !whole thing 638 639 END DO 640 641 END SUBROUTINE cv30_undilute1 642 643 SUBROUTINE cv30_trigger(len, nd, icb, plcl, p, th, tv, tvp, pbase, buoybase, & 644 iflag, sig, w0) 645 IMPLICIT NONE 646 647 ! ------------------------------------------------------------------- 648 ! --- TRIGGERING 649 650 ! - computes the cloud base 651 ! - triggering (crude in this version) 652 ! - relaxation of sig and w0 when no convection 653 654 ! Caution1: if no convection, we set iflag=4 655 ! (it used to be 0 in convect3) 656 657 ! Caution2: at this stage, tvp (and thus buoy) are know up 658 ! through icb only! 659 ! -> the buoyancy below cloud base not (yet) set to the cloud base buoyancy 660 ! ------------------------------------------------------------------- 661 662 663 664 ! input: 665 INTEGER len, nd 666 INTEGER icb(len) 667 REAL plcl(len), p(len, nd) 668 REAL th(len, nd), tv(len, nd), tvp(len, nd) 669 670 ! output: 671 REAL pbase(len), buoybase(len) 672 673 ! input AND output: 674 INTEGER iflag(len) 675 REAL sig(len, nd), w0(len, nd) 676 677 ! local variables: 678 INTEGER i, k 679 REAL tvpbase, tvbase, tdif, ath, ath1 680 681 682 ! *** set cloud base buoyancy at (plcl+dpbase) level buoyancy 683 684 DO i = 1, len 685 pbase(i) = plcl(i) + dpbase 686 tvpbase = tvp(i, icb(i)) * (pbase(i) - p(i, icb(i) + 1)) / & 687 (p(i, icb(i)) - p(i, icb(i) + 1)) + tvp(i, icb(i) + 1) * (p(i, icb(i)) - pbase(i)) / (& 688 p(i, icb(i)) - p(i, icb(i) + 1)) 689 tvbase = tv(i, icb(i)) * (pbase(i) - p(i, icb(i) + 1)) / & 690 (p(i, icb(i)) - p(i, icb(i) + 1)) + tv(i, icb(i) + 1) * (p(i, icb(i)) - pbase(i)) / (p & 691 (i, icb(i)) - p(i, icb(i) + 1)) 692 buoybase(i) = tvpbase - tvbase 693 END DO 694 695 696 ! *** make sure that column is dry adiabatic between the surface *** 697 ! *** and cloud base, and that lifted air is positively buoyant *** 698 ! *** at cloud base *** 699 ! *** if not, return to calling program after resetting *** 700 ! *** sig(i) and w0(i) *** 701 702 703 ! oct3 do 200 i=1,len 704 ! oct3 705 ! oct3 tdif = buoybase(i) 706 ! oct3 ath1 = th(i,1) 707 ! oct3 ath = th(i,icb(i)-1) - dttrig 708 ! oct3 709 ! oct3 if (tdif.lt.dtcrit .OR. ath.gt.ath1) THEN 710 ! oct3 do 60 k=1,nl 711 ! oct3 sig(i,k) = beta*sig(i,k) - 2.*alpha*tdif*tdif 712 ! oct3 sig(i,k) = AMAX1(sig(i,k),0.0) 713 ! oct3 w0(i,k) = beta*w0(i,k) 714 ! oct3 60 continue 715 ! oct3 iflag(i)=4 ! pour version vectorisee 716 ! oct3c convect3 iflag(i)=0 717 ! oct3cccc RETURN 718 ! oct3 endif 719 ! oct3 720 ! oct3200 continue 721 722 ! -- oct3: on reecrit la boucle 200 (pour la vectorisation) 723 724 DO k = 1, nl 725 DO i = 1, len 726 727 tdif = buoybase(i) 728 ath1 = th(i, 1) 729 ath = th(i, icb(i) - 1) - dttrig 730 731 IF (tdif<dtcrit .OR. ath>ath1) THEN 732 sig(i, k) = beta * sig(i, k) - 2. * alpha * tdif * tdif 733 sig(i, k) = amax1(sig(i, k), 0.0) 734 w0(i, k) = beta * w0(i, k) 735 iflag(i) = 4 ! pour version vectorisee 736 ! convect3 iflag(i)=0 737 END IF 738 739 END DO 740 END DO 741 742 ! fin oct3 -- 743 744 END SUBROUTINE cv30_trigger 745 746 SUBROUTINE cv30_compress(len, nloc, ncum, nd, ntra, iflag1, nk1, icb1, icbs1, & 747 plcl1, tnk1, qnk1, gznk1, pbase1, buoybase1, t1, q1, qs1, u1, v1, gz1, & 748 th1, tra1, h1, lv1, cpn1, p1, ph1, tv1, tp1, tvp1, clw1, sig1, w01, & 749 iflag, nk, icb, icbs, plcl, tnk, qnk, gznk, pbase, buoybase, t, q, qs, u, & 750 v, gz, th, tra, h, lv, cpn, p, ph, tv, tp, tvp, clw, sig, w0) 751 USE lmdz_print_control, ONLY: lunout 752 USE lmdz_abort_physic, ONLY: abort_physic 753 IMPLICIT NONE 754 755 756 757 ! inputs: 758 INTEGER len, ncum, nd, ntra, nloc 759 INTEGER iflag1(len), nk1(len), icb1(len), icbs1(len) 760 REAL plcl1(len), tnk1(len), qnk1(len), gznk1(len) 761 REAL pbase1(len), buoybase1(len) 762 REAL t1(len, nd), q1(len, nd), qs1(len, nd), u1(len, nd), v1(len, nd) 763 REAL gz1(len, nd), h1(len, nd), lv1(len, nd), cpn1(len, nd) 764 REAL p1(len, nd), ph1(len, nd + 1), tv1(len, nd), tp1(len, nd) 765 REAL tvp1(len, nd), clw1(len, nd) 766 REAL th1(len, nd) 767 REAL sig1(len, nd), w01(len, nd) 768 REAL tra1(len, nd, ntra) 769 770 ! outputs: 771 ! en fait, on a nloc=len pour l'instant (cf cv_driver) 772 INTEGER iflag(nloc), nk(nloc), icb(nloc), icbs(nloc) 773 REAL plcl(nloc), tnk(nloc), qnk(nloc), gznk(nloc) 774 REAL pbase(nloc), buoybase(nloc) 775 REAL t(nloc, nd), q(nloc, nd), qs(nloc, nd), u(nloc, nd), v(nloc, nd) 776 REAL gz(nloc, nd), h(nloc, nd), lv(nloc, nd), cpn(nloc, nd) 777 REAL p(nloc, nd), ph(nloc, nd + 1), tv(nloc, nd), tp(nloc, nd) 778 REAL tvp(nloc, nd), clw(nloc, nd) 779 REAL th(nloc, nd) 780 REAL sig(nloc, nd), w0(nloc, nd) 781 REAL tra(nloc, nd, ntra) 782 783 ! local variables: 784 INTEGER i, k, nn, j 785 786 CHARACTER (LEN = 20) :: modname = 'cv30_compress' 787 CHARACTER (LEN = 80) :: abort_message 788 789 DO k = 1, nl + 1 790 nn = 0 791 DO i = 1, len 792 IF (iflag1(i)==0) THEN 793 nn = nn + 1 794 sig(nn, k) = sig1(i, k) 795 w0(nn, k) = w01(i, k) 796 t(nn, k) = t1(i, k) 797 q(nn, k) = q1(i, k) 798 qs(nn, k) = qs1(i, k) 799 u(nn, k) = u1(i, k) 800 v(nn, k) = v1(i, k) 801 gz(nn, k) = gz1(i, k) 802 h(nn, k) = h1(i, k) 803 lv(nn, k) = lv1(i, k) 804 cpn(nn, k) = cpn1(i, k) 805 p(nn, k) = p1(i, k) 806 ph(nn, k) = ph1(i, k) 807 tv(nn, k) = tv1(i, k) 808 tp(nn, k) = tp1(i, k) 809 tvp(nn, k) = tvp1(i, k) 810 clw(nn, k) = clw1(i, k) 811 th(nn, k) = th1(i, k) 812 END IF 813 END DO 814 END DO 815 816 ! do 121 j=1,ntra 817 ! do 111 k=1,nd 818 ! nn=0 819 ! do 101 i=1,len 820 ! IF(iflag1(i).EQ.0)THEN 821 ! nn=nn+1 822 ! tra(nn,k,j)=tra1(i,k,j) 823 ! END IF 824 ! 101 continue 825 ! 111 continue 826 ! 121 continue 827 828 IF (nn/=ncum) THEN 829 WRITE (lunout, *) 'strange! nn not equal to ncum: ', nn, ncum 830 abort_message = '' 831 CALL abort_physic(modname, abort_message, 1) 411 832 END IF 412 END DO !convect3 413 414 DO i = 1, len !convect3 415 ticb(i) = t(i, icbs(i)) !convect3 416 gzicb(i) = gz(i, icbs(i)) !convect3 417 qsicb(i) = qs(i, icbs(i)) !convect3 418 END DO !convect3 419 420 421 ! Re-compute icbsmax (icbsmax2): !convect3 422 !convect3 423 icbsmax2 = 2 !convect3 424 DO i = 1, len !convect3 425 icbsmax2 = max(icbsmax2, icbs(i)) !convect3 426 END DO !convect3 427 428 ! initialization outputs: 429 430 DO k = 1, icbsmax2 ! convect3 431 DO i = 1, len ! convect3 432 tp(i, k) = 0.0 ! convect3 433 tvp(i, k) = 0.0 ! convect3 434 clw(i, k) = 0.0 ! convect3 435 END DO ! convect3 436 END DO ! convect3 437 438 ! tp and tvp below cloud base: 439 440 DO k = minorig, icbsmax2 - 1 441 DO i = 1, len 442 tp(i, k) = tnk(i) - (gz(i, k) - gznk(i)) * cpinv(i) 443 tvp(i, k) = tp(i, k) * (1. + qnk(i) / eps - qnk(i)) !whole thing (convect3) 444 END DO 445 END DO 446 447 ! *** Find lifted parcel quantities above cloud base *** 448 449 DO i = 1, len 450 tg = ticb(i) 451 ! ori qg=qs(i,icb(i)) 452 qg = qsicb(i) ! convect3 453 ! debug alv=lv0-clmcpv*(ticb(i)-t0) 454 alv = lv0 - clmcpv * (ticb(i) - 273.15) 455 456 ! First iteration. 457 458 ! ori s=cpd+alv*alv*qg/(rrv*ticb(i)*ticb(i)) 459 s = cpd * (1. - qnk(i)) + cl * qnk(i) & ! convect3 460 + alv * alv * qg / (rrv * ticb(i) * ticb(i)) ! convect3 461 s = 1. / s 462 ! ori ahg=cpd*tg+(cl-cpd)*qnk(i)*ticb(i)+alv*qg+gzicb(i) 463 ahg = cpd * tg + (cl - cpd) * qnk(i) * tg + alv * qg + gzicb(i) ! convect3 464 tg = tg + s * (ah0(i) - ahg) 465 ! ori tg=max(tg,35.0) 466 ! debug tc=tg-t0 467 tc = tg - 273.15 468 denom = 243.5 + tc 469 denom = max(denom, 1.0) ! convect3 470 ! ori IF(tc.ge.0.0)THEN 471 es = 6.112 * exp(17.67 * tc / denom) 472 ! ori else 473 ! ori es=exp(23.33086-6111.72784/tg+0.15215*log(tg)) 474 ! ori endif 475 ! ori qg=eps*es/(p(i,icb(i))-es*(1.-eps)) 476 qg = eps * es / (p(i, icbs(i)) - es * (1. - eps)) 477 478 ! Second iteration. 479 480 481 ! ori s=cpd+alv*alv*qg/(rrv*ticb(i)*ticb(i)) 482 ! ori s=1./s 483 ! ori ahg=cpd*tg+(cl-cpd)*qnk(i)*ticb(i)+alv*qg+gzicb(i) 484 ahg = cpd * tg + (cl - cpd) * qnk(i) * tg + alv * qg + gzicb(i) ! convect3 485 tg = tg + s * (ah0(i) - ahg) 486 ! ori tg=max(tg,35.0) 487 ! debug tc=tg-t0 488 tc = tg - 273.15 489 denom = 243.5 + tc 490 denom = max(denom, 1.0) ! convect3 491 ! ori IF(tc.ge.0.0)THEN 492 es = 6.112 * exp(17.67 * tc / denom) 493 ! ori else 494 ! ori es=exp(23.33086-6111.72784/tg+0.15215*log(tg)) 495 ! ori end if 496 ! ori qg=eps*es/(p(i,icb(i))-es*(1.-eps)) 497 qg = eps * es / (p(i, icbs(i)) - es * (1. - eps)) 498 499 alv = lv0 - clmcpv * (ticb(i) - 273.15) 500 501 ! ori c approximation here: 502 ! ori tp(i,icb(i))=(ah0(i)-(cl-cpd)*qnk(i)*ticb(i) 503 ! ori & -gz(i,icb(i))-alv*qg)/cpd 504 505 ! convect3: no approximation: 506 tp(i, icbs(i)) = (ah0(i) - gz(i, icbs(i)) - alv * qg) / (cpd + (cl - cpd) * qnk(i)) 507 508 ! ori clw(i,icb(i))=qnk(i)-qg 509 ! ori clw(i,icb(i))=max(0.0,clw(i,icb(i))) 510 clw(i, icbs(i)) = qnk(i) - qg 511 clw(i, icbs(i)) = max(0.0, clw(i, icbs(i))) 512 513 rg = qg / (1. - qnk(i)) 514 ! ori tvp(i,icb(i))=tp(i,icb(i))*(1.+rg*epsi) 515 ! convect3: (qg utilise au lieu du vrai mixing ratio rg) 516 tvp(i, icbs(i)) = tp(i, icbs(i)) * (1. + qg / eps - qnk(i)) !whole thing 517 518 END DO 519 520 ! ori do 380 k=minorig,icbsmax2 521 ! ori do 370 i=1,len 522 ! ori tvp(i,k)=tvp(i,k)-tp(i,k)*qnk(i) 523 ! ori 370 continue 524 ! ori 380 continue 525 526 527 ! -- The following is only for convect3: 528 529 ! * icbs is the first level above the LCL: 530 ! if plcl<p(icb), then icbs=icb+1 531 ! if plcl>p(icb), then icbs=icb 532 533 ! * the routine above computes tvp from minorig to icbs (included). 534 535 ! * to compute buoybase (in cv3_trigger.F), both tvp(icb) and tvp(icb+1) 536 ! must be known. This is the case if icbs=icb+1, but not if icbs=icb. 537 538 ! * therefore, in the case icbs=icb, we compute tvp at level icb+1 539 ! (tvp at other levels will be computed in cv3_undilute2.F) 540 541 DO i = 1, len 542 ticb(i) = t(i, icb(i) + 1) 543 gzicb(i) = gz(i, icb(i) + 1) 544 qsicb(i) = qs(i, icb(i) + 1) 545 END DO 546 547 DO i = 1, len 548 tg = ticb(i) 549 qg = qsicb(i) ! convect3 550 ! debug alv=lv0-clmcpv*(ticb(i)-t0) 551 alv = lv0 - clmcpv * (ticb(i) - 273.15) 552 553 ! First iteration. 554 555 ! ori s=cpd+alv*alv*qg/(rrv*ticb(i)*ticb(i)) 556 s = cpd * (1. - qnk(i)) + cl * qnk(i) & ! convect3 557 + alv * alv * qg / (rrv * ticb(i) * ticb(i)) ! convect3 558 s = 1. / s 559 ! ori ahg=cpd*tg+(cl-cpd)*qnk(i)*ticb(i)+alv*qg+gzicb(i) 560 ahg = cpd * tg + (cl - cpd) * qnk(i) * tg + alv * qg + gzicb(i) ! convect3 561 tg = tg + s * (ah0(i) - ahg) 562 ! ori tg=max(tg,35.0) 563 ! debug tc=tg-t0 564 tc = tg - 273.15 565 denom = 243.5 + tc 566 denom = max(denom, 1.0) ! convect3 567 ! ori IF(tc.ge.0.0)THEN 568 es = 6.112 * exp(17.67 * tc / denom) 569 ! ori else 570 ! ori es=exp(23.33086-6111.72784/tg+0.15215*log(tg)) 571 ! ori endif 572 ! ori qg=eps*es/(p(i,icb(i))-es*(1.-eps)) 573 qg = eps * es / (p(i, icb(i) + 1) - es * (1. - eps)) 574 575 ! Second iteration. 576 577 578 ! ori s=cpd+alv*alv*qg/(rrv*ticb(i)*ticb(i)) 579 ! ori s=1./s 580 ! ori ahg=cpd*tg+(cl-cpd)*qnk(i)*ticb(i)+alv*qg+gzicb(i) 581 ahg = cpd * tg + (cl - cpd) * qnk(i) * tg + alv * qg + gzicb(i) ! convect3 582 tg = tg + s * (ah0(i) - ahg) 583 ! ori tg=max(tg,35.0) 584 ! debug tc=tg-t0 585 tc = tg - 273.15 586 denom = 243.5 + tc 587 denom = max(denom, 1.0) ! convect3 588 ! ori IF(tc.ge.0.0)THEN 589 es = 6.112 * exp(17.67 * tc / denom) 590 ! ori else 591 ! ori es=exp(23.33086-6111.72784/tg+0.15215*log(tg)) 592 ! ori end if 593 ! ori qg=eps*es/(p(i,icb(i))-es*(1.-eps)) 594 qg = eps * es / (p(i, icb(i) + 1) - es * (1. - eps)) 595 596 alv = lv0 - clmcpv * (ticb(i) - 273.15) 597 598 ! ori c approximation here: 599 ! ori tp(i,icb(i))=(ah0(i)-(cl-cpd)*qnk(i)*ticb(i) 600 ! ori & -gz(i,icb(i))-alv*qg)/cpd 601 602 ! convect3: no approximation: 603 tp(i, icb(i) + 1) = (ah0(i) - gz(i, icb(i) + 1) - alv * qg) / (cpd + (cl - cpd) * qnk(i)) 604 605 ! ori clw(i,icb(i))=qnk(i)-qg 606 ! ori clw(i,icb(i))=max(0.0,clw(i,icb(i))) 607 clw(i, icb(i) + 1) = qnk(i) - qg 608 clw(i, icb(i) + 1) = max(0.0, clw(i, icb(i) + 1)) 609 610 rg = qg / (1. - qnk(i)) 611 ! ori tvp(i,icb(i))=tp(i,icb(i))*(1.+rg*epsi) 612 ! convect3: (qg utilise au lieu du vrai mixing ratio rg) 613 tvp(i, icb(i) + 1) = tp(i, icb(i) + 1) * (1. + qg / eps - qnk(i)) !whole thing 614 615 END DO 616 617 END SUBROUTINE cv30_undilute1 618 619 SUBROUTINE cv30_trigger(len, nd, icb, plcl, p, th, tv, tvp, pbase, buoybase, & 620 iflag, sig, w0) 621 IMPLICIT NONE 622 623 ! ------------------------------------------------------------------- 624 ! --- TRIGGERING 625 626 ! - computes the cloud base 627 ! - triggering (crude in this version) 628 ! - relaxation of sig and w0 when no convection 629 630 ! Caution1: if no convection, we set iflag=4 631 ! (it used to be 0 in convect3) 632 633 ! Caution2: at this stage, tvp (and thus buoy) are know up 634 ! through icb only! 635 ! -> the buoyancy below cloud base not (yet) set to the cloud base buoyancy 636 ! ------------------------------------------------------------------- 637 638 include "cv30param.h" 639 640 ! input: 641 INTEGER len, nd 642 INTEGER icb(len) 643 REAL plcl(len), p(len, nd) 644 REAL th(len, nd), tv(len, nd), tvp(len, nd) 645 646 ! output: 647 REAL pbase(len), buoybase(len) 648 649 ! input AND output: 650 INTEGER iflag(len) 651 REAL sig(len, nd), w0(len, nd) 652 653 ! local variables: 654 INTEGER i, k 655 REAL tvpbase, tvbase, tdif, ath, ath1 656 657 658 ! *** set cloud base buoyancy at (plcl+dpbase) level buoyancy 659 660 DO i = 1, len 661 pbase(i) = plcl(i) + dpbase 662 tvpbase = tvp(i, icb(i)) * (pbase(i) - p(i, icb(i) + 1)) / & 663 (p(i, icb(i)) - p(i, icb(i) + 1)) + tvp(i, icb(i) + 1) * (p(i, icb(i)) - pbase(i)) / (& 664 p(i, icb(i)) - p(i, icb(i) + 1)) 665 tvbase = tv(i, icb(i)) * (pbase(i) - p(i, icb(i) + 1)) / & 666 (p(i, icb(i)) - p(i, icb(i) + 1)) + tv(i, icb(i) + 1) * (p(i, icb(i)) - pbase(i)) / (p & 667 (i, icb(i)) - p(i, icb(i) + 1)) 668 buoybase(i) = tvpbase - tvbase 669 END DO 670 671 672 ! *** make sure that column is dry adiabatic between the surface *** 673 ! *** and cloud base, and that lifted air is positively buoyant *** 674 ! *** at cloud base *** 675 ! *** if not, return to calling program after resetting *** 676 ! *** sig(i) and w0(i) *** 677 678 679 ! oct3 do 200 i=1,len 680 ! oct3 681 ! oct3 tdif = buoybase(i) 682 ! oct3 ath1 = th(i,1) 683 ! oct3 ath = th(i,icb(i)-1) - dttrig 684 ! oct3 685 ! oct3 if (tdif.lt.dtcrit .OR. ath.gt.ath1) THEN 686 ! oct3 do 60 k=1,nl 687 ! oct3 sig(i,k) = beta*sig(i,k) - 2.*alpha*tdif*tdif 688 ! oct3 sig(i,k) = AMAX1(sig(i,k),0.0) 689 ! oct3 w0(i,k) = beta*w0(i,k) 690 ! oct3 60 continue 691 ! oct3 iflag(i)=4 ! pour version vectorisee 692 ! oct3c convect3 iflag(i)=0 693 ! oct3cccc RETURN 694 ! oct3 endif 695 ! oct3 696 ! oct3200 continue 697 698 ! -- oct3: on reecrit la boucle 200 (pour la vectorisation) 699 700 DO k = 1, nl 701 DO i = 1, len 702 703 tdif = buoybase(i) 704 ath1 = th(i, 1) 705 ath = th(i, icb(i) - 1) - dttrig 706 707 IF (tdif<dtcrit .OR. ath>ath1) THEN 708 sig(i, k) = beta * sig(i, k) - 2. * alpha * tdif * tdif 709 sig(i, k) = amax1(sig(i, k), 0.0) 710 w0(i, k) = beta * w0(i, k) 711 iflag(i) = 4 ! pour version vectorisee 712 ! convect3 iflag(i)=0 713 END IF 714 715 END DO 716 END DO 717 718 ! fin oct3 -- 719 720 END SUBROUTINE cv30_trigger 721 722 SUBROUTINE cv30_compress(len, nloc, ncum, nd, ntra, iflag1, nk1, icb1, icbs1, & 723 plcl1, tnk1, qnk1, gznk1, pbase1, buoybase1, t1, q1, qs1, u1, v1, gz1, & 724 th1, tra1, h1, lv1, cpn1, p1, ph1, tv1, tp1, tvp1, clw1, sig1, w01, & 725 iflag, nk, icb, icbs, plcl, tnk, qnk, gznk, pbase, buoybase, t, q, qs, u, & 726 v, gz, th, tra, h, lv, cpn, p, ph, tv, tp, tvp, clw, sig, w0) 727 USE lmdz_print_control, ONLY: lunout 728 USE lmdz_abort_physic, ONLY: abort_physic 729 IMPLICIT NONE 730 731 include "cv30param.h" 732 733 ! inputs: 734 INTEGER len, ncum, nd, ntra, nloc 735 INTEGER iflag1(len), nk1(len), icb1(len), icbs1(len) 736 REAL plcl1(len), tnk1(len), qnk1(len), gznk1(len) 737 REAL pbase1(len), buoybase1(len) 738 REAL t1(len, nd), q1(len, nd), qs1(len, nd), u1(len, nd), v1(len, nd) 739 REAL gz1(len, nd), h1(len, nd), lv1(len, nd), cpn1(len, nd) 740 REAL p1(len, nd), ph1(len, nd + 1), tv1(len, nd), tp1(len, nd) 741 REAL tvp1(len, nd), clw1(len, nd) 742 REAL th1(len, nd) 743 REAL sig1(len, nd), w01(len, nd) 744 REAL tra1(len, nd, ntra) 745 746 ! outputs: 747 ! en fait, on a nloc=len pour l'instant (cf cv_driver) 748 INTEGER iflag(nloc), nk(nloc), icb(nloc), icbs(nloc) 749 REAL plcl(nloc), tnk(nloc), qnk(nloc), gznk(nloc) 750 REAL pbase(nloc), buoybase(nloc) 751 REAL t(nloc, nd), q(nloc, nd), qs(nloc, nd), u(nloc, nd), v(nloc, nd) 752 REAL gz(nloc, nd), h(nloc, nd), lv(nloc, nd), cpn(nloc, nd) 753 REAL p(nloc, nd), ph(nloc, nd + 1), tv(nloc, nd), tp(nloc, nd) 754 REAL tvp(nloc, nd), clw(nloc, nd) 755 REAL th(nloc, nd) 756 REAL sig(nloc, nd), w0(nloc, nd) 757 REAL tra(nloc, nd, ntra) 758 759 ! local variables: 760 INTEGER i, k, nn, j 761 762 CHARACTER (LEN = 20) :: modname = 'cv30_compress' 763 CHARACTER (LEN = 80) :: abort_message 764 765 DO k = 1, nl + 1 833 766 834 nn = 0 767 835 DO i = 1, len 768 836 IF (iflag1(i)==0) THEN 769 837 nn = nn + 1 770 sig(nn, k) = sig1(i, k) 771 w0(nn, k) = w01(i, k) 772 t(nn, k) = t1(i, k) 773 q(nn, k) = q1(i, k) 774 qs(nn, k) = qs1(i, k) 775 u(nn, k) = u1(i, k) 776 v(nn, k) = v1(i, k) 777 gz(nn, k) = gz1(i, k) 778 h(nn, k) = h1(i, k) 779 lv(nn, k) = lv1(i, k) 780 cpn(nn, k) = cpn1(i, k) 781 p(nn, k) = p1(i, k) 782 ph(nn, k) = ph1(i, k) 783 tv(nn, k) = tv1(i, k) 784 tp(nn, k) = tp1(i, k) 785 tvp(nn, k) = tvp1(i, k) 786 clw(nn, k) = clw1(i, k) 787 th(nn, k) = th1(i, k) 838 pbase(nn) = pbase1(i) 839 buoybase(nn) = buoybase1(i) 840 plcl(nn) = plcl1(i) 841 tnk(nn) = tnk1(i) 842 qnk(nn) = qnk1(i) 843 gznk(nn) = gznk1(i) 844 nk(nn) = nk1(i) 845 icb(nn) = icb1(i) 846 icbs(nn) = icbs1(i) 847 iflag(nn) = iflag1(i) 788 848 END IF 789 849 END DO 790 END DO 791 792 ! do 121 j=1,ntra 793 ! do 111 k=1,nd 794 ! nn=0 795 ! do 101 i=1,len 796 ! IF(iflag1(i).EQ.0)THEN 797 ! nn=nn+1 798 ! tra(nn,k,j)=tra1(i,k,j) 799 ! END IF 800 ! 101 continue 801 ! 111 continue 802 ! 121 continue 803 804 IF (nn/=ncum) THEN 805 WRITE (lunout, *) 'strange! nn not equal to ncum: ', nn, ncum 806 abort_message = '' 807 CALL abort_physic(modname, abort_message, 1) 808 END IF 809 810 nn = 0 811 DO i = 1, len 812 IF (iflag1(i)==0) THEN 813 nn = nn + 1 814 pbase(nn) = pbase1(i) 815 buoybase(nn) = buoybase1(i) 816 plcl(nn) = plcl1(i) 817 tnk(nn) = tnk1(i) 818 qnk(nn) = qnk1(i) 819 gznk(nn) = gznk1(i) 820 nk(nn) = nk1(i) 821 icb(nn) = icb1(i) 822 icbs(nn) = icbs1(i) 823 iflag(nn) = iflag1(i) 824 END IF 825 END DO 826 827 END SUBROUTINE cv30_compress 828 829 SUBROUTINE cv30_undilute2(nloc, ncum, nd, icb, icbs, nk, tnk, qnk, gznk, t, & 830 q, qs, gz, p, h, tv, lv, pbase, buoybase, plcl, inb, tp, tvp, clw, hp, & 831 ep, sigp, buoy) 832 ! epmax_cape: ajout arguments 833 USE lmdz_conema3 834 835 IMPLICIT NONE 836 837 ! --------------------------------------------------------------------- 838 ! Purpose: 839 ! FIND THE REST OF THE LIFTED PARCEL TEMPERATURES 840 ! & 841 ! COMPUTE THE PRECIPITATION EFFICIENCIES AND THE 842 ! FRACTION OF PRECIPITATION FALLING OUTSIDE OF CLOUD 843 ! & 844 ! FIND THE LEVEL OF NEUTRAL BUOYANCY 845 846 ! Main differences convect3/convect4: 847 ! - icbs (input) is the first level above LCL (may differ from icb) 848 ! - many minor differences in the iterations 849 ! - condensed water not removed from tvp in convect3 850 ! - vertical profile of buoyancy computed here (use of buoybase) 851 ! - the determination of inb is different 852 ! - no inb1, ONLY inb in output 853 ! --------------------------------------------------------------------- 854 855 include "cvthermo.h" 856 include "cv30param.h" 857 858 ! inputs: 859 INTEGER ncum, nd, nloc 860 INTEGER icb(nloc), icbs(nloc), nk(nloc) 861 REAL t(nloc, nd), q(nloc, nd), qs(nloc, nd), gz(nloc, nd) 862 REAL p(nloc, nd) 863 REAL tnk(nloc), qnk(nloc), gznk(nloc) 864 REAL lv(nloc, nd), tv(nloc, nd), h(nloc, nd) 865 REAL pbase(nloc), buoybase(nloc), plcl(nloc) 866 867 ! outputs: 868 INTEGER inb(nloc) 869 REAL tp(nloc, nd), tvp(nloc, nd), clw(nloc, nd) 870 REAL ep(nloc, nd), sigp(nloc, nd), hp(nloc, nd) 871 REAL buoy(nloc, nd) 872 873 ! local variables: 874 INTEGER i, k 875 REAL tg, qg, ahg, alv, s, tc, es, denom, rg, tca, elacrit 876 REAL by, defrac, pden 877 REAL ah0(nloc), cape(nloc), capem(nloc), byp(nloc) 878 LOGICAL lcape(nloc) 879 880 ! ===================================================================== 881 ! --- SOME INITIALIZATIONS 882 ! ===================================================================== 883 884 DO k = 1, nl 885 DO i = 1, ncum 886 ep(i, k) = 0.0 887 sigp(i, k) = spfac 888 END DO 889 END DO 890 891 ! ===================================================================== 892 ! --- FIND THE REST OF THE LIFTED PARCEL TEMPERATURES 893 ! ===================================================================== 894 895 ! --- The procedure is to solve the equation. 896 ! cp*tp+L*qp+phi=cp*tnk+L*qnk+gznk. 897 898 ! *** Calculate certain parcel quantities, including static energy *** 899 900 DO i = 1, ncum 901 ah0(i) = (cpd * (1. - qnk(i)) + cl * qnk(i)) * tnk(i) & ! debug & 902 ! +qnk(i)*(lv0-clmcpv*(tnk(i)-t0))+gznk(i) 903 + qnk(i) * (lv0 - clmcpv * (tnk(i) - 273.15)) + gznk(i) 904 END DO 905 906 907 ! *** Find lifted parcel quantities above cloud base *** 908 909 DO k = minorig + 1, nl 910 DO i = 1, ncum 911 ! ori IF(k.ge.(icb(i)+1))THEN 912 IF (k>=(icbs(i) + 1)) THEN ! convect3 913 tg = t(i, k) 914 qg = qs(i, k) 915 ! debug alv=lv0-clmcpv*(t(i,k)-t0) 916 alv = lv0 - clmcpv * (t(i, k) - 273.15) 917 918 ! First iteration. 919 920 ! ori s=cpd+alv*alv*qg/(rrv*t(i,k)*t(i,k)) 921 s = cpd * (1. - qnk(i)) + cl * qnk(i) & ! convect3 922 + alv * alv * qg / (rrv * t(i, k) * t(i, k)) ! convect3 923 s = 1. / s 924 ! ori ahg=cpd*tg+(cl-cpd)*qnk(i)*t(i,k)+alv*qg+gz(i,k) 925 ahg = cpd * tg + (cl - cpd) * qnk(i) * tg + alv * qg + gz(i, k) ! convect3 926 tg = tg + s * (ah0(i) - ahg) 927 ! ori tg=max(tg,35.0) 928 ! debug tc=tg-t0 929 tc = tg - 273.15 930 denom = 243.5 + tc 931 denom = max(denom, 1.0) ! convect3 932 ! ori IF(tc.ge.0.0)THEN 933 es = 6.112 * exp(17.67 * tc / denom) 934 ! ori else 935 ! ori es=exp(23.33086-6111.72784/tg+0.15215*log(tg)) 936 ! ori endif 937 qg = eps * es / (p(i, k) - es * (1. - eps)) 938 939 ! Second iteration. 940 941 ! ori s=cpd+alv*alv*qg/(rrv*t(i,k)*t(i,k)) 942 ! ori s=1./s 943 ! ori ahg=cpd*tg+(cl-cpd)*qnk(i)*t(i,k)+alv*qg+gz(i,k) 944 ahg = cpd * tg + (cl - cpd) * qnk(i) * tg + alv * qg + gz(i, k) ! convect3 945 tg = tg + s * (ah0(i) - ahg) 946 ! ori tg=max(tg,35.0) 947 ! debug tc=tg-t0 948 tc = tg - 273.15 949 denom = 243.5 + tc 950 denom = max(denom, 1.0) ! convect3 951 ! ori IF(tc.ge.0.0)THEN 952 es = 6.112 * exp(17.67 * tc / denom) 953 ! ori else 954 ! ori es=exp(23.33086-6111.72784/tg+0.15215*log(tg)) 955 ! ori endif 956 qg = eps * es / (p(i, k) - es * (1. - eps)) 957 958 ! debug alv=lv0-clmcpv*(t(i,k)-t0) 959 alv = lv0 - clmcpv * (t(i, k) - 273.15) 960 ! PRINT*,'cpd dans convect2 ',cpd 961 ! PRINT*,'tp(i,k),ah0(i),cl,cpd,qnk(i),t(i,k),gz(i,k),alv,qg,cpd' 962 ! PRINT*,tp(i,k),ah0(i),cl,cpd,qnk(i),t(i,k),gz(i,k),alv,qg,cpd 963 964 ! ori c approximation here: 965 ! ori 966 ! tp(i,k)=(ah0(i)-(cl-cpd)*qnk(i)*t(i,k)-gz(i,k)-alv*qg)/cpd 967 968 ! convect3: no approximation: 969 tp(i, k) = (ah0(i) - gz(i, k) - alv * qg) / (cpd + (cl - cpd) * qnk(i)) 970 971 clw(i, k) = qnk(i) - qg 972 clw(i, k) = max(0.0, clw(i, k)) 973 rg = qg / (1. - qnk(i)) 974 ! ori tvp(i,k)=tp(i,k)*(1.+rg*epsi) 975 ! convect3: (qg utilise au lieu du vrai mixing ratio rg): 976 tvp(i, k) = tp(i, k) * (1. + qg / eps - qnk(i)) ! whole thing 977 END IF 978 END DO 979 END DO 980 981 ! ===================================================================== 982 ! --- SET THE PRECIPITATION EFFICIENCIES AND THE FRACTION OF 983 ! --- PRECIPITATION FALLING OUTSIDE OF CLOUD 984 ! --- THESE MAY BE FUNCTIONS OF TP(I), P(I) AND CLW(I) 985 ! ===================================================================== 986 987 ! ori do 320 k=minorig+1,nl 988 DO k = 1, nl ! convect3 989 DO i = 1, ncum 990 pden = ptcrit - pbcrit 991 ep(i, k) = (plcl(i) - p(i, k) - pbcrit) / pden * epmax 992 ep(i, k) = amax1(ep(i, k), 0.0) 993 ep(i, k) = amin1(ep(i, k), epmax) 994 sigp(i, k) = spfac 995 ! ori IF(k.ge.(nk(i)+1))THEN 996 ! ori tca=tp(i,k)-t0 997 ! ori IF(tca.ge.0.0)THEN 998 ! ori elacrit=elcrit 999 ! ori else 1000 ! ori elacrit=elcrit*(1.0-tca/tlcrit) 1001 ! ori endif 1002 ! ori elacrit=max(elacrit,0.0) 1003 ! ori ep(i,k)=1.0-elacrit/max(clw(i,k),1.0e-8) 1004 ! ori ep(i,k)=max(ep(i,k),0.0 ) 1005 ! ori ep(i,k)=min(ep(i,k),1.0 ) 1006 ! ori sigp(i,k)=sigs 1007 ! ori endif 1008 END DO 1009 END DO 1010 1011 ! ===================================================================== 1012 ! --- CALCULATE VIRTUAL TEMPERATURE AND LIFTED PARCEL 1013 ! --- VIRTUAL TEMPERATURE 1014 ! ===================================================================== 1015 1016 ! dans convect3, tvp est calcule en une seule fois, et sans retirer 1017 ! l'eau condensee (~> reversible CAPE) 1018 1019 ! ori do 340 k=minorig+1,nl 1020 ! ori do 330 i=1,ncum 1021 ! ori IF(k.ge.(icb(i)+1))THEN 1022 ! ori tvp(i,k)=tvp(i,k)*(1.0-qnk(i)+ep(i,k)*clw(i,k)) 1023 ! oric PRINT*,'i,k,tvp(i,k),qnk(i),ep(i,k),clw(i,k)' 1024 ! oric PRINT*, i,k,tvp(i,k),qnk(i),ep(i,k),clw(i,k) 1025 ! ori endif 1026 ! ori 330 continue 1027 ! ori 340 continue 1028 1029 ! ori do 350 i=1,ncum 1030 ! ori tvp(i,nlp)=tvp(i,nl)-(gz(i,nlp)-gz(i,nl))/cpd 1031 ! ori 350 continue 1032 1033 DO i = 1, ncum ! convect3 1034 tp(i, nlp) = tp(i, nl) ! convect3 1035 END DO ! convect3 1036 1037 ! ===================================================================== 1038 ! --- EFFECTIVE VERTICAL PROFILE OF BUOYANCY (convect3 only): 1039 ! ===================================================================== 1040 1041 ! -- this is for convect3 only: 1042 1043 ! first estimate of buoyancy: 1044 1045 DO i = 1, ncum 1046 DO k = 1, nl 1047 buoy(i, k) = tvp(i, k) - tv(i, k) 1048 END DO 1049 END DO 1050 1051 ! set buoyancy=buoybase for all levels below base 1052 ! for safety, set buoy(icb)=buoybase 1053 1054 DO i = 1, ncum 1055 DO k = 1, nl 1056 IF ((k>=icb(i)) .AND. (k<=nl) .AND. (p(i, k)>=pbase(i))) THEN 1057 buoy(i, k) = buoybase(i) 1058 END IF 1059 END DO 1060 ! IM cf. CRio/JYG 270807 buoy(icb(i),k)=buoybase(i) 1061 buoy(i, icb(i)) = buoybase(i) 1062 END DO 1063 1064 ! -- end convect3 1065 1066 ! ===================================================================== 1067 ! --- FIND THE FIRST MODEL LEVEL (INB) ABOVE THE PARCEL'S 1068 ! --- LEVEL OF NEUTRAL BUOYANCY 1069 ! ===================================================================== 1070 1071 ! -- this is for convect3 only: 1072 1073 DO i = 1, ncum 1074 inb(i) = nl - 1 1075 END DO 1076 1077 DO i = 1, ncum 1078 DO k = 1, nl - 1 1079 IF ((k>=icb(i)) .AND. (buoy(i, k)<dtovsh)) THEN 1080 inb(i) = min(inb(i), k) 1081 END IF 1082 END DO 1083 END DO 1084 1085 ! -- end convect3 1086 1087 ! ori do 510 i=1,ncum 1088 ! ori cape(i)=0.0 1089 ! ori capem(i)=0.0 1090 ! ori inb(i)=icb(i)+1 1091 ! ori inb1(i)=inb(i) 1092 ! ori 510 continue 1093 1094 ! Originial Code 1095 1096 ! do 530 k=minorig+1,nl-1 1097 ! do 520 i=1,ncum 1098 ! IF(k.ge.(icb(i)+1))THEN 1099 ! by=(tvp(i,k)-tv(i,k))*dph(i,k)/p(i,k) 1100 ! byp=(tvp(i,k+1)-tv(i,k+1))*dph(i,k+1)/p(i,k+1) 1101 ! cape(i)=cape(i)+by 1102 ! IF(by.ge.0.0)inb1(i)=k+1 1103 ! IF(cape(i).gt.0.0)THEN 1104 ! inb(i)=k+1 1105 ! capem(i)=cape(i) 1106 ! END IF 1107 ! END IF 1108 ! 520 continue 1109 ! 530 continue 1110 ! do 540 i=1,ncum 1111 ! byp=(tvp(i,nl)-tv(i,nl))*dph(i,nl)/p(i,nl) 1112 ! cape(i)=capem(i)+byp 1113 ! defrac=capem(i)-cape(i) 1114 ! defrac=max(defrac,0.001) 1115 ! frac(i)=-cape(i)/defrac 1116 ! frac(i)=min(frac(i),1.0) 1117 ! frac(i)=max(frac(i),0.0) 1118 ! 540 continue 1119 1120 ! K Emanuel fix 1121 1122 ! CALL zilch(byp,ncum) 1123 ! do 530 k=minorig+1,nl-1 1124 ! do 520 i=1,ncum 1125 ! IF(k.ge.(icb(i)+1))THEN 1126 ! by=(tvp(i,k)-tv(i,k))*dph(i,k)/p(i,k) 1127 ! cape(i)=cape(i)+by 1128 ! IF(by.ge.0.0)inb1(i)=k+1 1129 ! IF(cape(i).gt.0.0)THEN 1130 ! inb(i)=k+1 1131 ! capem(i)=cape(i) 1132 ! byp(i)=(tvp(i,k+1)-tv(i,k+1))*dph(i,k+1)/p(i,k+1) 1133 ! END IF 1134 ! END IF 1135 ! 520 continue 1136 ! 530 continue 1137 ! do 540 i=1,ncum 1138 ! inb(i)=max(inb(i),inb1(i)) 1139 ! cape(i)=capem(i)+byp(i) 1140 ! defrac=capem(i)-cape(i) 1141 ! defrac=max(defrac,0.001) 1142 ! frac(i)=-cape(i)/defrac 1143 ! frac(i)=min(frac(i),1.0) 1144 ! frac(i)=max(frac(i),0.0) 1145 ! 540 continue 1146 1147 ! J Teixeira fix 1148 1149 ! ori CALL zilch(byp,ncum) 1150 ! ori do 515 i=1,ncum 1151 ! ori lcape(i)=.TRUE. 1152 ! ori 515 continue 1153 ! ori do 530 k=minorig+1,nl-1 1154 ! ori do 520 i=1,ncum 1155 ! ori IF(cape(i).lt.0.0)lcape(i)=.FALSE. 1156 ! ori if((k.ge.(icb(i)+1)).AND.lcape(i))THEN 1157 ! ori by=(tvp(i,k)-tv(i,k))*dph(i,k)/p(i,k) 1158 ! ori byp(i)=(tvp(i,k+1)-tv(i,k+1))*dph(i,k+1)/p(i,k+1) 1159 ! ori cape(i)=cape(i)+by 1160 ! ori IF(by.ge.0.0)inb1(i)=k+1 1161 ! ori IF(cape(i).gt.0.0)THEN 1162 ! ori inb(i)=k+1 1163 ! ori capem(i)=cape(i) 1164 ! ori endif 1165 ! ori endif 1166 ! ori 520 continue 1167 ! ori 530 continue 1168 ! ori do 540 i=1,ncum 1169 ! ori cape(i)=capem(i)+byp(i) 1170 ! ori defrac=capem(i)-cape(i) 1171 ! ori defrac=max(defrac,0.001) 1172 ! ori frac(i)=-cape(i)/defrac 1173 ! ori frac(i)=min(frac(i),1.0) 1174 ! ori frac(i)=max(frac(i),0.0) 1175 ! ori 540 continue 1176 1177 ! ===================================================================== 1178 ! --- CALCULATE LIQUID WATER STATIC ENERGY OF LIFTED PARCEL 1179 ! ===================================================================== 1180 1181 ! ym do i=1,ncum*nlp 1182 ! ym hp(i,1)=h(i,1) 1183 ! ym enddo 1184 1185 DO k = 1, nlp 1186 DO i = 1, ncum 1187 hp(i, k) = h(i, k) 1188 END DO 1189 END DO 1190 1191 DO k = minorig + 1, nl 1192 DO i = 1, ncum 1193 IF ((k>=icb(i)) .AND. (k<=inb(i))) THEN 1194 hp(i, k) = h(i, nk(i)) + (lv(i, k) + (cpd - cpv) * t(i, k)) * ep(i, k) * clw(i, k & 1195 ) 1196 END IF 1197 END DO 1198 END DO 1199 1200 END SUBROUTINE cv30_undilute2 1201 1202 SUBROUTINE cv30_closure(nloc, ncum, nd, icb, inb, pbase, p, ph, tv, buoy, & 1203 sig, w0, cape, m) 1204 IMPLICIT NONE 1205 1206 ! =================================================================== 1207 ! --- CLOSURE OF CONVECT3 1208 1209 ! vectorization: S. Bony 1210 ! =================================================================== 1211 1212 include "cvthermo.h" 1213 include "cv30param.h" 1214 1215 ! input: 1216 INTEGER ncum, nd, nloc 1217 INTEGER icb(nloc), inb(nloc) 1218 REAL pbase(nloc) 1219 REAL p(nloc, nd), ph(nloc, nd + 1) 1220 REAL tv(nloc, nd), buoy(nloc, nd) 1221 1222 ! input/output: 1223 REAL sig(nloc, nd), w0(nloc, nd) 1224 1225 ! output: 1226 REAL cape(nloc) 1227 REAL m(nloc, nd) 1228 1229 ! local variables: 1230 INTEGER i, j, k, icbmax 1231 REAL deltap, fac, w, amu 1232 REAL dtmin(nloc, nd), sigold(nloc, nd) 1233 1234 ! ------------------------------------------------------- 1235 ! -- Initialization 1236 ! ------------------------------------------------------- 1237 1238 DO k = 1, nl 1239 DO i = 1, ncum 1240 m(i, k) = 0.0 1241 END DO 1242 END DO 1243 1244 ! ------------------------------------------------------- 1245 ! -- Reset sig(i) and w0(i) for i>inb and i<icb 1246 ! ------------------------------------------------------- 1247 1248 ! update sig and w0 above LNB: 1249 1250 DO k = 1, nl - 1 1251 DO i = 1, ncum 1252 IF ((inb(i)<(nl - 1)) .AND. (k>=(inb(i) + 1))) THEN 1253 sig(i, k) = beta * sig(i, k) + 2. * alpha * buoy(i, inb(i)) * abs(buoy(i, inb(& 1254 i))) 1255 sig(i, k) = amax1(sig(i, k), 0.0) 1256 w0(i, k) = beta * w0(i, k) 1257 END IF 1258 END DO 1259 END DO 1260 1261 ! compute icbmax: 1262 1263 icbmax = 2 1264 DO i = 1, ncum 1265 icbmax = max(icbmax, icb(i)) 1266 END DO 1267 1268 ! update sig and w0 below cloud base: 1269 1270 DO k = 1, icbmax 1271 DO i = 1, ncum 1272 IF (k<=icb(i)) THEN 1273 sig(i, k) = beta * sig(i, k) - 2. * alpha * buoy(i, icb(i)) * buoy(i, icb(i)) 1274 sig(i, k) = amax1(sig(i, k), 0.0) 1275 w0(i, k) = beta * w0(i, k) 1276 END IF 1277 END DO 1278 END DO 1279 1280 ! IF(inb.lt.(nl-1))THEN 1281 ! do 85 i=inb+1,nl-1 1282 ! sig(i)=beta*sig(i)+2.*alpha*buoy(inb)* 1283 ! 1 abs(buoy(inb)) 1284 ! sig(i)=amax1(sig(i),0.0) 1285 ! w0(i)=beta*w0(i) 1286 ! 85 continue 1287 ! end if 1288 1289 ! do 87 i=1,icb 1290 ! sig(i)=beta*sig(i)-2.*alpha*buoy(icb)*buoy(icb) 1291 ! sig(i)=amax1(sig(i),0.0) 1292 ! w0(i)=beta*w0(i) 1293 ! 87 continue 1294 1295 ! ------------------------------------------------------------- 1296 ! -- Reset fractional areas of updrafts and w0 at initial time 1297 ! -- and after 10 time steps of no convection 1298 ! ------------------------------------------------------------- 1299 1300 DO k = 1, nl - 1 1301 DO i = 1, ncum 1302 IF (sig(i, nd)<1.5 .OR. sig(i, nd)>12.0) THEN 1303 sig(i, k) = 0.0 1304 w0(i, k) = 0.0 1305 END IF 1306 END DO 1307 END DO 1308 1309 ! ------------------------------------------------------------- 1310 ! -- Calculate convective available potential energy (cape), 1311 ! -- vertical velocity (w), fractional area covered by 1312 ! -- undilute updraft (sig), and updraft mass flux (m) 1313 ! ------------------------------------------------------------- 1314 1315 DO i = 1, ncum 1316 cape(i) = 0.0 1317 END DO 1318 1319 ! compute dtmin (minimum buoyancy between ICB and given level k): 1320 1321 DO i = 1, ncum 1322 DO k = 1, nl 1323 dtmin(i, k) = 100.0 1324 END DO 1325 END DO 1326 1327 DO i = 1, ncum 1328 DO k = 1, nl 1329 DO j = minorig, nl 1330 IF ((k>=(icb(i) + 1)) .AND. (k<=inb(i)) .AND. (j>=icb(i)) .AND. (j<=(k - & 1331 1))) THEN 1332 dtmin(i, k) = amin1(dtmin(i, k), buoy(i, j)) 1333 END IF 1334 END DO 1335 END DO 1336 END DO 1337 1338 ! the interval on which cape is computed starts at pbase : 1339 DO k = 1, nl 1340 DO i = 1, ncum 1341 1342 IF ((k>=(icb(i) + 1)) .AND. (k<=inb(i))) THEN 1343 1344 deltap = min(pbase(i), ph(i, k - 1)) - min(pbase(i), ph(i, k)) 1345 cape(i) = cape(i) + rrd * buoy(i, k - 1) * deltap / p(i, k - 1) 1346 cape(i) = amax1(0.0, cape(i)) 1347 sigold(i, k) = sig(i, k) 1348 1349 ! dtmin(i,k)=100.0 1350 ! do 97 j=icb(i),k-1 ! mauvaise vectorisation 1351 ! dtmin(i,k)=AMIN1(dtmin(i,k),buoy(i,j)) 1352 ! 97 continue 1353 1354 sig(i, k) = beta * sig(i, k) + alpha * dtmin(i, k) * abs(dtmin(i, k)) 1355 sig(i, k) = amax1(sig(i, k), 0.0) 1356 sig(i, k) = amin1(sig(i, k), 0.01) 1357 fac = amin1(((dtcrit - dtmin(i, k)) / dtcrit), 1.0) 1358 w = (1. - beta) * fac * sqrt(cape(i)) + beta * w0(i, k) 1359 amu = 0.5 * (sig(i, k) + sigold(i, k)) * w 1360 m(i, k) = amu * 0.007 * p(i, k) * (ph(i, k) - ph(i, k + 1)) / tv(i, k) 1361 w0(i, k) = w 1362 END IF 1363 1364 END DO 1365 END DO 1366 1367 DO i = 1, ncum 1368 w0(i, icb(i)) = 0.5 * w0(i, icb(i) + 1) 1369 m(i, icb(i)) = 0.5 * m(i, icb(i) + 1) * (ph(i, icb(i)) - ph(i, icb(i) + 1)) / & 1370 (ph(i, icb(i) + 1) - ph(i, icb(i) + 2)) 1371 sig(i, icb(i)) = sig(i, icb(i) + 1) 1372 sig(i, icb(i) - 1) = sig(i, icb(i)) 1373 END DO 1374 1375 1376 ! cape=0.0 1377 ! do 98 i=icb+1,inb 1378 ! deltap = min(pbase,ph(i-1))-min(pbase,ph(i)) 1379 ! cape=cape+rrd*buoy(i-1)*deltap/p(i-1) 1380 ! dcape=rrd*buoy(i-1)*deltap/p(i-1) 1381 ! dlnp=deltap/p(i-1) 1382 ! cape=amax1(0.0,cape) 1383 ! sigold=sig(i) 1384 1385 ! dtmin=100.0 1386 ! do 97 j=icb,i-1 1387 ! dtmin=amin1(dtmin,buoy(j)) 1388 ! 97 continue 1389 1390 ! sig(i)=beta*sig(i)+alpha*dtmin*abs(dtmin) 1391 ! sig(i)=amax1(sig(i),0.0) 1392 ! sig(i)=amin1(sig(i),0.01) 1393 ! fac=amin1(((dtcrit-dtmin)/dtcrit),1.0) 1394 ! w=(1.-beta)*fac*sqrt(cape)+beta*w0(i) 1395 ! amu=0.5*(sig(i)+sigold)*w 1396 ! m(i)=amu*0.007*p(i)*(ph(i)-ph(i+1))/tv(i) 1397 ! w0(i)=w 1398 ! 98 continue 1399 ! w0(icb)=0.5*w0(icb+1) 1400 ! m(icb)=0.5*m(icb+1)*(ph(icb)-ph(icb+1))/(ph(icb+1)-ph(icb+2)) 1401 ! sig(icb)=sig(icb+1) 1402 ! sig(icb-1)=sig(icb) 1403 1404 END SUBROUTINE cv30_closure 1405 1406 SUBROUTINE cv30_mixing(nloc, ncum, nd, na, ntra, icb, nk, inb, ph, t, rr, rs, & 1407 u, v, tra, h, lv, qnk, hp, tv, tvp, ep, clw, m, sig, ment, qent, uent, & 1408 vent, sij, elij, ments, qents, traent) 1409 IMPLICIT NONE 1410 1411 ! --------------------------------------------------------------------- 1412 ! a faire: 1413 ! - changer rr(il,1) -> qnk(il) 1414 ! - vectorisation de la partie normalisation des flux (do 789...) 1415 ! --------------------------------------------------------------------- 1416 1417 include "cvthermo.h" 1418 include "cv30param.h" 1419 1420 ! inputs: 1421 INTEGER ncum, nd, na, ntra, nloc 1422 INTEGER icb(nloc), inb(nloc), nk(nloc) 1423 REAL sig(nloc, nd) 1424 REAL qnk(nloc) 1425 REAL ph(nloc, nd + 1) 1426 REAL t(nloc, nd), rr(nloc, nd), rs(nloc, nd) 1427 REAL u(nloc, nd), v(nloc, nd) 1428 REAL tra(nloc, nd, ntra) ! input of convect3 1429 REAL lv(nloc, na), h(nloc, na), hp(nloc, na) 1430 REAL tv(nloc, na), tvp(nloc, na), ep(nloc, na), clw(nloc, na) 1431 REAL m(nloc, na) ! input of convect3 1432 1433 ! outputs: 1434 REAL ment(nloc, na, na), qent(nloc, na, na) 1435 REAL uent(nloc, na, na), vent(nloc, na, na) 1436 REAL sij(nloc, na, na), elij(nloc, na, na) 1437 REAL traent(nloc, nd, nd, ntra) 1438 REAL ments(nloc, nd, nd), qents(nloc, nd, nd) 1439 REAL sigij(nloc, nd, nd) 1440 1441 ! local variables: 1442 INTEGER i, j, k, il, im, jm 1443 INTEGER num1, num2 1444 INTEGER nent(nloc, na) 1445 REAL rti, bf2, anum, denom, dei, altem, cwat, stemp, qp 1446 REAL alt, smid, sjmin, sjmax, delp, delm 1447 REAL asij(nloc), smax(nloc), scrit(nloc) 1448 REAL asum(nloc, nd), bsum(nloc, nd), csum(nloc, nd) 1449 REAL wgh 1450 REAL zm(nloc, na) 1451 LOGICAL lwork(nloc) 1452 1453 ! ===================================================================== 1454 ! --- INITIALIZE VARIOUS ARRAYS USED IN THE COMPUTATIONS 1455 ! ===================================================================== 1456 1457 ! ori do 360 i=1,ncum*nlp 1458 DO j = 1, nl 1459 DO i = 1, ncum 1460 nent(i, j) = 0 1461 ! in convect3, m is computed in cv3_closure 1462 ! ori m(i,1)=0.0 1463 END DO 1464 END DO 1465 1466 ! ori do 400 k=1,nlp 1467 ! ori do 390 j=1,nlp 1468 DO j = 1, nl 850 851 END SUBROUTINE cv30_compress 852 853 SUBROUTINE cv30_undilute2(nloc, ncum, nd, icb, icbs, nk, tnk, qnk, gznk, t, & 854 q, qs, gz, p, h, tv, lv, pbase, buoybase, plcl, inb, tp, tvp, clw, hp, & 855 ep, sigp, buoy) 856 ! epmax_cape: ajout arguments 857 USE lmdz_conema3 858 USE lmdz_cvthermo 859 860 IMPLICIT NONE 861 862 ! --------------------------------------------------------------------- 863 ! Purpose: 864 ! FIND THE REST OF THE LIFTED PARCEL TEMPERATURES 865 ! & 866 ! COMPUTE THE PRECIPITATION EFFICIENCIES AND THE 867 ! FRACTION OF PRECIPITATION FALLING OUTSIDE OF CLOUD 868 ! & 869 ! FIND THE LEVEL OF NEUTRAL BUOYANCY 870 871 ! Main differences convect3/convect4: 872 ! - icbs (input) is the first level above LCL (may differ from icb) 873 ! - many minor differences in the iterations 874 ! - condensed water not removed from tvp in convect3 875 ! - vertical profile of buoyancy computed here (use of buoybase) 876 ! - the determination of inb is different 877 ! - no inb1, ONLY inb in output 878 ! --------------------------------------------------------------------- 879 880 881 882 ! inputs: 883 INTEGER ncum, nd, nloc 884 INTEGER icb(nloc), icbs(nloc), nk(nloc) 885 REAL t(nloc, nd), q(nloc, nd), qs(nloc, nd), gz(nloc, nd) 886 REAL p(nloc, nd) 887 REAL tnk(nloc), qnk(nloc), gznk(nloc) 888 REAL lv(nloc, nd), tv(nloc, nd), h(nloc, nd) 889 REAL pbase(nloc), buoybase(nloc), plcl(nloc) 890 891 ! outputs: 892 INTEGER inb(nloc) 893 REAL tp(nloc, nd), tvp(nloc, nd), clw(nloc, nd) 894 REAL ep(nloc, nd), sigp(nloc, nd), hp(nloc, nd) 895 REAL buoy(nloc, nd) 896 897 ! local variables: 898 INTEGER i, k 899 REAL tg, qg, ahg, alv, s, tc, es, denom, rg, tca, elacrit 900 REAL by, defrac, pden 901 REAL ah0(nloc), cape(nloc), capem(nloc), byp(nloc) 902 LOGICAL lcape(nloc) 903 904 ! ===================================================================== 905 ! --- SOME INITIALIZATIONS 906 ! ===================================================================== 907 1469 908 DO k = 1, nl 1470 909 DO i = 1, ncum 1471 qent(i, k, j) = rr(i, j) 1472 uent(i, k, j) = u(i, j) 1473 vent(i, k, j) = v(i, j) 1474 elij(i, k, j) = 0.0 1475 ! ym ment(i,k,j)=0.0 1476 ! ym sij(i,k,j)=0.0 1477 END DO 1478 END DO 1479 END DO 1480 1481 ! ym 1482 ment(1:ncum, 1:nd, 1:nd) = 0.0 1483 sij(1:ncum, 1:nd, 1:nd) = 0.0 1484 1485 ! do k=1,ntra 1486 ! do j=1,nd ! instead nlp 1487 ! do i=1,nd ! instead nlp 1488 ! do il=1,ncum 1489 ! traent(il,i,j,k)=tra(il,j,k) 1490 ! enddo 1491 ! enddo 1492 ! enddo 1493 ! enddo 1494 zm(:, :) = 0. 1495 1496 ! ===================================================================== 1497 ! --- CALCULATE ENTRAINED AIR MASS FLUX (ment), TOTAL WATER MIXING 1498 ! --- RATIO (QENT), TOTAL CONDENSED WATER (elij), AND MIXING 1499 ! --- FRACTION (sij) 1500 ! ===================================================================== 1501 1502 DO i = minorig + 1, nl 1503 1504 DO j = minorig, nl 910 ep(i, k) = 0.0 911 sigp(i, k) = spfac 912 END DO 913 END DO 914 915 ! ===================================================================== 916 ! --- FIND THE REST OF THE LIFTED PARCEL TEMPERATURES 917 ! ===================================================================== 918 919 ! --- The procedure is to solve the equation. 920 ! cp*tp+L*qp+phi=cp*tnk+L*qnk+gznk. 921 922 ! *** Calculate certain parcel quantities, including static energy *** 923 924 DO i = 1, ncum 925 ah0(i) = (cpd * (1. - qnk(i)) + cl * qnk(i)) * tnk(i) & ! debug & 926 ! +qnk(i)*(lv0-clmcpv*(tnk(i)-t0))+gznk(i) 927 + qnk(i) * (lv0 - clmcpv * (tnk(i) - 273.15)) + gznk(i) 928 END DO 929 930 931 ! *** Find lifted parcel quantities above cloud base *** 932 933 DO k = minorig + 1, nl 934 DO i = 1, ncum 935 ! ori IF(k.ge.(icb(i)+1))THEN 936 IF (k>=(icbs(i) + 1)) THEN ! convect3 937 tg = t(i, k) 938 qg = qs(i, k) 939 ! debug alv=lv0-clmcpv*(t(i,k)-t0) 940 alv = lv0 - clmcpv * (t(i, k) - 273.15) 941 942 ! First iteration. 943 944 ! ori s=cpd+alv*alv*qg/(rrv*t(i,k)*t(i,k)) 945 s = cpd * (1. - qnk(i)) + cl * qnk(i) & ! convect3 946 + alv * alv * qg / (rrv * t(i, k) * t(i, k)) ! convect3 947 s = 1. / s 948 ! ori ahg=cpd*tg+(cl-cpd)*qnk(i)*t(i,k)+alv*qg+gz(i,k) 949 ahg = cpd * tg + (cl - cpd) * qnk(i) * tg + alv * qg + gz(i, k) ! convect3 950 tg = tg + s * (ah0(i) - ahg) 951 ! ori tg=max(tg,35.0) 952 ! debug tc=tg-t0 953 tc = tg - 273.15 954 denom = 243.5 + tc 955 denom = max(denom, 1.0) ! convect3 956 ! ori IF(tc.ge.0.0)THEN 957 es = 6.112 * exp(17.67 * tc / denom) 958 ! ori else 959 ! ori es=exp(23.33086-6111.72784/tg+0.15215*log(tg)) 960 ! ori endif 961 qg = eps * es / (p(i, k) - es * (1. - eps)) 962 963 ! Second iteration. 964 965 ! ori s=cpd+alv*alv*qg/(rrv*t(i,k)*t(i,k)) 966 ! ori s=1./s 967 ! ori ahg=cpd*tg+(cl-cpd)*qnk(i)*t(i,k)+alv*qg+gz(i,k) 968 ahg = cpd * tg + (cl - cpd) * qnk(i) * tg + alv * qg + gz(i, k) ! convect3 969 tg = tg + s * (ah0(i) - ahg) 970 ! ori tg=max(tg,35.0) 971 ! debug tc=tg-t0 972 tc = tg - 273.15 973 denom = 243.5 + tc 974 denom = max(denom, 1.0) ! convect3 975 ! ori IF(tc.ge.0.0)THEN 976 es = 6.112 * exp(17.67 * tc / denom) 977 ! ori else 978 ! ori es=exp(23.33086-6111.72784/tg+0.15215*log(tg)) 979 ! ori endif 980 qg = eps * es / (p(i, k) - es * (1. - eps)) 981 982 ! debug alv=lv0-clmcpv*(t(i,k)-t0) 983 alv = lv0 - clmcpv * (t(i, k) - 273.15) 984 ! PRINT*,'cpd dans convect2 ',cpd 985 ! PRINT*,'tp(i,k),ah0(i),cl,cpd,qnk(i),t(i,k),gz(i,k),alv,qg,cpd' 986 ! PRINT*,tp(i,k),ah0(i),cl,cpd,qnk(i),t(i,k),gz(i,k),alv,qg,cpd 987 988 ! ori c approximation here: 989 ! ori 990 ! tp(i,k)=(ah0(i)-(cl-cpd)*qnk(i)*t(i,k)-gz(i,k)-alv*qg)/cpd 991 992 ! convect3: no approximation: 993 tp(i, k) = (ah0(i) - gz(i, k) - alv * qg) / (cpd + (cl - cpd) * qnk(i)) 994 995 clw(i, k) = qnk(i) - qg 996 clw(i, k) = max(0.0, clw(i, k)) 997 rg = qg / (1. - qnk(i)) 998 ! ori tvp(i,k)=tp(i,k)*(1.+rg*epsi) 999 ! convect3: (qg utilise au lieu du vrai mixing ratio rg): 1000 tvp(i, k) = tp(i, k) * (1. + qg / eps - qnk(i)) ! whole thing 1001 END IF 1002 END DO 1003 END DO 1004 1005 ! ===================================================================== 1006 ! --- SET THE PRECIPITATION EFFICIENCIES AND THE FRACTION OF 1007 ! --- PRECIPITATION FALLING OUTSIDE OF CLOUD 1008 ! --- THESE MAY BE FUNCTIONS OF TP(I), P(I) AND CLW(I) 1009 ! ===================================================================== 1010 1011 ! ori do 320 k=minorig+1,nl 1012 DO k = 1, nl ! convect3 1013 DO i = 1, ncum 1014 pden = ptcrit - pbcrit 1015 ep(i, k) = (plcl(i) - p(i, k) - pbcrit) / pden * epmax 1016 ep(i, k) = amax1(ep(i, k), 0.0) 1017 ep(i, k) = amin1(ep(i, k), epmax) 1018 sigp(i, k) = spfac 1019 ! ori IF(k.ge.(nk(i)+1))THEN 1020 ! ori tca=tp(i,k)-t0 1021 ! ori IF(tca.ge.0.0)THEN 1022 ! ori elacrit=elcrit 1023 ! ori else 1024 ! ori elacrit=elcrit*(1.0-tca/tlcrit) 1025 ! ori endif 1026 ! ori elacrit=max(elacrit,0.0) 1027 ! ori ep(i,k)=1.0-elacrit/max(clw(i,k),1.0e-8) 1028 ! ori ep(i,k)=max(ep(i,k),0.0 ) 1029 ! ori ep(i,k)=min(ep(i,k),1.0 ) 1030 ! ori sigp(i,k)=sigs 1031 ! ori endif 1032 END DO 1033 END DO 1034 1035 ! ===================================================================== 1036 ! --- CALCULATE VIRTUAL TEMPERATURE AND LIFTED PARCEL 1037 ! --- VIRTUAL TEMPERATURE 1038 ! ===================================================================== 1039 1040 ! dans convect3, tvp est calcule en une seule fois, et sans retirer 1041 ! l'eau condensee (~> reversible CAPE) 1042 1043 ! ori do 340 k=minorig+1,nl 1044 ! ori do 330 i=1,ncum 1045 ! ori IF(k.ge.(icb(i)+1))THEN 1046 ! ori tvp(i,k)=tvp(i,k)*(1.0-qnk(i)+ep(i,k)*clw(i,k)) 1047 ! oric PRINT*,'i,k,tvp(i,k),qnk(i),ep(i,k),clw(i,k)' 1048 ! oric PRINT*, i,k,tvp(i,k),qnk(i),ep(i,k),clw(i,k) 1049 ! ori endif 1050 ! ori 330 continue 1051 ! ori 340 continue 1052 1053 ! ori do 350 i=1,ncum 1054 ! ori tvp(i,nlp)=tvp(i,nl)-(gz(i,nlp)-gz(i,nl))/cpd 1055 ! ori 350 continue 1056 1057 DO i = 1, ncum ! convect3 1058 tp(i, nlp) = tp(i, nl) ! convect3 1059 END DO ! convect3 1060 1061 ! ===================================================================== 1062 ! --- EFFECTIVE VERTICAL PROFILE OF BUOYANCY (convect3 only): 1063 ! ===================================================================== 1064 1065 ! -- this is for convect3 only: 1066 1067 ! first estimate of buoyancy: 1068 1069 DO i = 1, ncum 1070 DO k = 1, nl 1071 buoy(i, k) = tvp(i, k) - tv(i, k) 1072 END DO 1073 END DO 1074 1075 ! set buoyancy=buoybase for all levels below base 1076 ! for safety, set buoy(icb)=buoybase 1077 1078 DO i = 1, ncum 1079 DO k = 1, nl 1080 IF ((k>=icb(i)) .AND. (k<=nl) .AND. (p(i, k)>=pbase(i))) THEN 1081 buoy(i, k) = buoybase(i) 1082 END IF 1083 END DO 1084 ! IM cf. CRio/JYG 270807 buoy(icb(i),k)=buoybase(i) 1085 buoy(i, icb(i)) = buoybase(i) 1086 END DO 1087 1088 ! -- end convect3 1089 1090 ! ===================================================================== 1091 ! --- FIND THE FIRST MODEL LEVEL (INB) ABOVE THE PARCEL'S 1092 ! --- LEVEL OF NEUTRAL BUOYANCY 1093 ! ===================================================================== 1094 1095 ! -- this is for convect3 only: 1096 1097 DO i = 1, ncum 1098 inb(i) = nl - 1 1099 END DO 1100 1101 DO i = 1, ncum 1102 DO k = 1, nl - 1 1103 IF ((k>=icb(i)) .AND. (buoy(i, k)<dtovsh)) THEN 1104 inb(i) = min(inb(i), k) 1105 END IF 1106 END DO 1107 END DO 1108 1109 ! -- end convect3 1110 1111 ! ori do 510 i=1,ncum 1112 ! ori cape(i)=0.0 1113 ! ori capem(i)=0.0 1114 ! ori inb(i)=icb(i)+1 1115 ! ori inb1(i)=inb(i) 1116 ! ori 510 continue 1117 1118 ! Originial Code 1119 1120 ! do 530 k=minorig+1,nl-1 1121 ! do 520 i=1,ncum 1122 ! IF(k.ge.(icb(i)+1))THEN 1123 ! by=(tvp(i,k)-tv(i,k))*dph(i,k)/p(i,k) 1124 ! byp=(tvp(i,k+1)-tv(i,k+1))*dph(i,k+1)/p(i,k+1) 1125 ! cape(i)=cape(i)+by 1126 ! IF(by.ge.0.0)inb1(i)=k+1 1127 ! IF(cape(i).gt.0.0)THEN 1128 ! inb(i)=k+1 1129 ! capem(i)=cape(i) 1130 ! END IF 1131 ! END IF 1132 ! 520 continue 1133 ! 530 continue 1134 ! do 540 i=1,ncum 1135 ! byp=(tvp(i,nl)-tv(i,nl))*dph(i,nl)/p(i,nl) 1136 ! cape(i)=capem(i)+byp 1137 ! defrac=capem(i)-cape(i) 1138 ! defrac=max(defrac,0.001) 1139 ! frac(i)=-cape(i)/defrac 1140 ! frac(i)=min(frac(i),1.0) 1141 ! frac(i)=max(frac(i),0.0) 1142 ! 540 continue 1143 1144 ! K Emanuel fix 1145 1146 ! CALL zilch(byp,ncum) 1147 ! do 530 k=minorig+1,nl-1 1148 ! do 520 i=1,ncum 1149 ! IF(k.ge.(icb(i)+1))THEN 1150 ! by=(tvp(i,k)-tv(i,k))*dph(i,k)/p(i,k) 1151 ! cape(i)=cape(i)+by 1152 ! IF(by.ge.0.0)inb1(i)=k+1 1153 ! IF(cape(i).gt.0.0)THEN 1154 ! inb(i)=k+1 1155 ! capem(i)=cape(i) 1156 ! byp(i)=(tvp(i,k+1)-tv(i,k+1))*dph(i,k+1)/p(i,k+1) 1157 ! END IF 1158 ! END IF 1159 ! 520 continue 1160 ! 530 continue 1161 ! do 540 i=1,ncum 1162 ! inb(i)=max(inb(i),inb1(i)) 1163 ! cape(i)=capem(i)+byp(i) 1164 ! defrac=capem(i)-cape(i) 1165 ! defrac=max(defrac,0.001) 1166 ! frac(i)=-cape(i)/defrac 1167 ! frac(i)=min(frac(i),1.0) 1168 ! frac(i)=max(frac(i),0.0) 1169 ! 540 continue 1170 1171 ! J Teixeira fix 1172 1173 ! ori CALL zilch(byp,ncum) 1174 ! ori do 515 i=1,ncum 1175 ! ori lcape(i)=.TRUE. 1176 ! ori 515 continue 1177 ! ori do 530 k=minorig+1,nl-1 1178 ! ori do 520 i=1,ncum 1179 ! ori IF(cape(i).lt.0.0)lcape(i)=.FALSE. 1180 ! ori if((k.ge.(icb(i)+1)).AND.lcape(i))THEN 1181 ! ori by=(tvp(i,k)-tv(i,k))*dph(i,k)/p(i,k) 1182 ! ori byp(i)=(tvp(i,k+1)-tv(i,k+1))*dph(i,k+1)/p(i,k+1) 1183 ! ori cape(i)=cape(i)+by 1184 ! ori IF(by.ge.0.0)inb1(i)=k+1 1185 ! ori IF(cape(i).gt.0.0)THEN 1186 ! ori inb(i)=k+1 1187 ! ori capem(i)=cape(i) 1188 ! ori endif 1189 ! ori endif 1190 ! ori 520 continue 1191 ! ori 530 continue 1192 ! ori do 540 i=1,ncum 1193 ! ori cape(i)=capem(i)+byp(i) 1194 ! ori defrac=capem(i)-cape(i) 1195 ! ori defrac=max(defrac,0.001) 1196 ! ori frac(i)=-cape(i)/defrac 1197 ! ori frac(i)=min(frac(i),1.0) 1198 ! ori frac(i)=max(frac(i),0.0) 1199 ! ori 540 continue 1200 1201 ! ===================================================================== 1202 ! --- CALCULATE LIQUID WATER STATIC ENERGY OF LIFTED PARCEL 1203 ! ===================================================================== 1204 1205 ! ym do i=1,ncum*nlp 1206 ! ym hp(i,1)=h(i,1) 1207 ! ym enddo 1208 1209 DO k = 1, nlp 1210 DO i = 1, ncum 1211 hp(i, k) = h(i, k) 1212 END DO 1213 END DO 1214 1215 DO k = minorig + 1, nl 1216 DO i = 1, ncum 1217 IF ((k>=icb(i)) .AND. (k<=inb(i))) THEN 1218 hp(i, k) = h(i, nk(i)) + (lv(i, k) + (cpd - cpv) * t(i, k)) * ep(i, k) * clw(i, k & 1219 ) 1220 END IF 1221 END DO 1222 END DO 1223 1224 END SUBROUTINE cv30_undilute2 1225 1226 SUBROUTINE cv30_closure(nloc, ncum, nd, icb, inb, pbase, p, ph, tv, buoy, & 1227 sig, w0, cape, m) 1228 USE lmdz_cvthermo 1229 1230 IMPLICIT NONE 1231 1232 ! =================================================================== 1233 ! --- CLOSURE OF CONVECT3 1234 1235 ! vectorization: S. Bony 1236 ! =================================================================== 1237 1238 1239 1240 ! input: 1241 INTEGER ncum, nd, nloc 1242 INTEGER icb(nloc), inb(nloc) 1243 REAL pbase(nloc) 1244 REAL p(nloc, nd), ph(nloc, nd + 1) 1245 REAL tv(nloc, nd), buoy(nloc, nd) 1246 1247 ! input/output: 1248 REAL sig(nloc, nd), w0(nloc, nd) 1249 1250 ! output: 1251 REAL cape(nloc) 1252 REAL m(nloc, nd) 1253 1254 ! local variables: 1255 INTEGER i, j, k, icbmax 1256 REAL deltap, fac, w, amu 1257 REAL dtmin(nloc, nd), sigold(nloc, nd) 1258 1259 ! ------------------------------------------------------- 1260 ! -- Initialization 1261 ! ------------------------------------------------------- 1262 1263 DO k = 1, nl 1264 DO i = 1, ncum 1265 m(i, k) = 0.0 1266 END DO 1267 END DO 1268 1269 ! ------------------------------------------------------- 1270 ! -- Reset sig(i) and w0(i) for i>inb and i<icb 1271 ! ------------------------------------------------------- 1272 1273 ! update sig and w0 above LNB: 1274 1275 DO k = 1, nl - 1 1276 DO i = 1, ncum 1277 IF ((inb(i)<(nl - 1)) .AND. (k>=(inb(i) + 1))) THEN 1278 sig(i, k) = beta * sig(i, k) + 2. * alpha * buoy(i, inb(i)) * abs(buoy(i, inb(& 1279 i))) 1280 sig(i, k) = amax1(sig(i, k), 0.0) 1281 w0(i, k) = beta * w0(i, k) 1282 END IF 1283 END DO 1284 END DO 1285 1286 ! compute icbmax: 1287 1288 icbmax = 2 1289 DO i = 1, ncum 1290 icbmax = max(icbmax, icb(i)) 1291 END DO 1292 1293 ! update sig and w0 below cloud base: 1294 1295 DO k = 1, icbmax 1296 DO i = 1, ncum 1297 IF (k<=icb(i)) THEN 1298 sig(i, k) = beta * sig(i, k) - 2. * alpha * buoy(i, icb(i)) * buoy(i, icb(i)) 1299 sig(i, k) = amax1(sig(i, k), 0.0) 1300 w0(i, k) = beta * w0(i, k) 1301 END IF 1302 END DO 1303 END DO 1304 1305 ! IF(inb.lt.(nl-1))THEN 1306 ! do 85 i=inb+1,nl-1 1307 ! sig(i)=beta*sig(i)+2.*alpha*buoy(inb)* 1308 ! 1 abs(buoy(inb)) 1309 ! sig(i)=amax1(sig(i),0.0) 1310 ! w0(i)=beta*w0(i) 1311 ! 85 continue 1312 ! end if 1313 1314 ! do 87 i=1,icb 1315 ! sig(i)=beta*sig(i)-2.*alpha*buoy(icb)*buoy(icb) 1316 ! sig(i)=amax1(sig(i),0.0) 1317 ! w0(i)=beta*w0(i) 1318 ! 87 continue 1319 1320 ! ------------------------------------------------------------- 1321 ! -- Reset fractional areas of updrafts and w0 at initial time 1322 ! -- and after 10 time steps of no convection 1323 ! ------------------------------------------------------------- 1324 1325 DO k = 1, nl - 1 1326 DO i = 1, ncum 1327 IF (sig(i, nd)<1.5 .OR. sig(i, nd)>12.0) THEN 1328 sig(i, k) = 0.0 1329 w0(i, k) = 0.0 1330 END IF 1331 END DO 1332 END DO 1333 1334 ! ------------------------------------------------------------- 1335 ! -- Calculate convective available potential energy (cape), 1336 ! -- vertical velocity (w), fractional area covered by 1337 ! -- undilute updraft (sig), and updraft mass flux (m) 1338 ! ------------------------------------------------------------- 1339 1340 DO i = 1, ncum 1341 cape(i) = 0.0 1342 END DO 1343 1344 ! compute dtmin (minimum buoyancy between ICB and given level k): 1345 1346 DO i = 1, ncum 1347 DO k = 1, nl 1348 dtmin(i, k) = 100.0 1349 END DO 1350 END DO 1351 1352 DO i = 1, ncum 1353 DO k = 1, nl 1354 DO j = minorig, nl 1355 IF ((k>=(icb(i) + 1)) .AND. (k<=inb(i)) .AND. (j>=icb(i)) .AND. (j<=(k - & 1356 1))) THEN 1357 dtmin(i, k) = amin1(dtmin(i, k), buoy(i, j)) 1358 END IF 1359 END DO 1360 END DO 1361 END DO 1362 1363 ! the interval on which cape is computed starts at pbase : 1364 DO k = 1, nl 1365 DO i = 1, ncum 1366 1367 IF ((k>=(icb(i) + 1)) .AND. (k<=inb(i))) THEN 1368 1369 deltap = min(pbase(i), ph(i, k - 1)) - min(pbase(i), ph(i, k)) 1370 cape(i) = cape(i) + rrd * buoy(i, k - 1) * deltap / p(i, k - 1) 1371 cape(i) = amax1(0.0, cape(i)) 1372 sigold(i, k) = sig(i, k) 1373 1374 ! dtmin(i,k)=100.0 1375 ! do 97 j=icb(i),k-1 ! mauvaise vectorisation 1376 ! dtmin(i,k)=AMIN1(dtmin(i,k),buoy(i,j)) 1377 ! 97 continue 1378 1379 sig(i, k) = beta * sig(i, k) + alpha * dtmin(i, k) * abs(dtmin(i, k)) 1380 sig(i, k) = amax1(sig(i, k), 0.0) 1381 sig(i, k) = amin1(sig(i, k), 0.01) 1382 fac = amin1(((dtcrit - dtmin(i, k)) / dtcrit), 1.0) 1383 w = (1. - beta) * fac * sqrt(cape(i)) + beta * w0(i, k) 1384 amu = 0.5 * (sig(i, k) + sigold(i, k)) * w 1385 m(i, k) = amu * 0.007 * p(i, k) * (ph(i, k) - ph(i, k + 1)) / tv(i, k) 1386 w0(i, k) = w 1387 END IF 1388 1389 END DO 1390 END DO 1391 1392 DO i = 1, ncum 1393 w0(i, icb(i)) = 0.5 * w0(i, icb(i) + 1) 1394 m(i, icb(i)) = 0.5 * m(i, icb(i) + 1) * (ph(i, icb(i)) - ph(i, icb(i) + 1)) / & 1395 (ph(i, icb(i) + 1) - ph(i, icb(i) + 2)) 1396 sig(i, icb(i)) = sig(i, icb(i) + 1) 1397 sig(i, icb(i) - 1) = sig(i, icb(i)) 1398 END DO 1399 1400 1401 ! cape=0.0 1402 ! do 98 i=icb+1,inb 1403 ! deltap = min(pbase,ph(i-1))-min(pbase,ph(i)) 1404 ! cape=cape+rrd*buoy(i-1)*deltap/p(i-1) 1405 ! dcape=rrd*buoy(i-1)*deltap/p(i-1) 1406 ! dlnp=deltap/p(i-1) 1407 ! cape=amax1(0.0,cape) 1408 ! sigold=sig(i) 1409 1410 ! dtmin=100.0 1411 ! do 97 j=icb,i-1 1412 ! dtmin=amin1(dtmin,buoy(j)) 1413 ! 97 continue 1414 1415 ! sig(i)=beta*sig(i)+alpha*dtmin*abs(dtmin) 1416 ! sig(i)=amax1(sig(i),0.0) 1417 ! sig(i)=amin1(sig(i),0.01) 1418 ! fac=amin1(((dtcrit-dtmin)/dtcrit),1.0) 1419 ! w=(1.-beta)*fac*sqrt(cape)+beta*w0(i) 1420 ! amu=0.5*(sig(i)+sigold)*w 1421 ! m(i)=amu*0.007*p(i)*(ph(i)-ph(i+1))/tv(i) 1422 ! w0(i)=w 1423 ! 98 continue 1424 ! w0(icb)=0.5*w0(icb+1) 1425 ! m(icb)=0.5*m(icb+1)*(ph(icb)-ph(icb+1))/(ph(icb+1)-ph(icb+2)) 1426 ! sig(icb)=sig(icb+1) 1427 ! sig(icb-1)=sig(icb) 1428 1429 END SUBROUTINE cv30_closure 1430 1431 SUBROUTINE cv30_mixing(nloc, ncum, nd, na, ntra, icb, nk, inb, ph, t, rr, rs, & 1432 u, v, tra, h, lv, qnk, hp, tv, tvp, ep, clw, m, sig, ment, qent, uent, & 1433 vent, sij, elij, ments, qents, traent) 1434 USE lmdz_cvthermo 1435 1436 IMPLICIT NONE 1437 1438 ! --------------------------------------------------------------------- 1439 ! a faire: 1440 ! - changer rr(il,1) -> qnk(il) 1441 ! - vectorisation de la partie normalisation des flux (do 789...) 1442 ! --------------------------------------------------------------------- 1443 1444 1445 1446 ! inputs: 1447 INTEGER ncum, nd, na, ntra, nloc 1448 INTEGER icb(nloc), inb(nloc), nk(nloc) 1449 REAL sig(nloc, nd) 1450 REAL qnk(nloc) 1451 REAL ph(nloc, nd + 1) 1452 REAL t(nloc, nd), rr(nloc, nd), rs(nloc, nd) 1453 REAL u(nloc, nd), v(nloc, nd) 1454 REAL tra(nloc, nd, ntra) ! input of convect3 1455 REAL lv(nloc, na), h(nloc, na), hp(nloc, na) 1456 REAL tv(nloc, na), tvp(nloc, na), ep(nloc, na), clw(nloc, na) 1457 REAL m(nloc, na) ! input of convect3 1458 1459 ! outputs: 1460 REAL ment(nloc, na, na), qent(nloc, na, na) 1461 REAL uent(nloc, na, na), vent(nloc, na, na) 1462 REAL sij(nloc, na, na), elij(nloc, na, na) 1463 REAL traent(nloc, nd, nd, ntra) 1464 REAL ments(nloc, nd, nd), qents(nloc, nd, nd) 1465 REAL sigij(nloc, nd, nd) 1466 1467 ! local variables: 1468 INTEGER i, j, k, il, im, jm 1469 INTEGER num1, num2 1470 INTEGER nent(nloc, na) 1471 REAL rti, bf2, anum, denom, dei, altem, cwat, stemp, qp 1472 REAL alt, smid, sjmin, sjmax, delp, delm 1473 REAL asij(nloc), smax(nloc), scrit(nloc) 1474 REAL asum(nloc, nd), bsum(nloc, nd), csum(nloc, nd) 1475 REAL wgh 1476 REAL zm(nloc, na) 1477 LOGICAL lwork(nloc) 1478 1479 ! ===================================================================== 1480 ! --- INITIALIZE VARIOUS ARRAYS USED IN THE COMPUTATIONS 1481 ! ===================================================================== 1482 1483 ! ori do 360 i=1,ncum*nlp 1484 DO j = 1, nl 1485 DO i = 1, ncum 1486 nent(i, j) = 0 1487 ! in convect3, m is computed in cv3_closure 1488 ! ori m(i,1)=0.0 1489 END DO 1490 END DO 1491 1492 ! ori do 400 k=1,nlp 1493 ! ori do 390 j=1,nlp 1494 DO j = 1, nl 1495 DO k = 1, nl 1496 DO i = 1, ncum 1497 qent(i, k, j) = rr(i, j) 1498 uent(i, k, j) = u(i, j) 1499 vent(i, k, j) = v(i, j) 1500 elij(i, k, j) = 0.0 1501 ! ym ment(i,k,j)=0.0 1502 ! ym sij(i,k,j)=0.0 1503 END DO 1504 END DO 1505 END DO 1506 1507 ! ym 1508 ment(1:ncum, 1:nd, 1:nd) = 0.0 1509 sij(1:ncum, 1:nd, 1:nd) = 0.0 1510 1511 ! do k=1,ntra 1512 ! do j=1,nd ! instead nlp 1513 ! do i=1,nd ! instead nlp 1514 ! do il=1,ncum 1515 ! traent(il,i,j,k)=tra(il,j,k) 1516 ! enddo 1517 ! enddo 1518 ! enddo 1519 ! enddo 1520 zm(:, :) = 0. 1521 1522 ! ===================================================================== 1523 ! --- CALCULATE ENTRAINED AIR MASS FLUX (ment), TOTAL WATER MIXING 1524 ! --- RATIO (QENT), TOTAL CONDENSED WATER (elij), AND MIXING 1525 ! --- FRACTION (sij) 1526 ! ===================================================================== 1527 1528 DO i = minorig + 1, nl 1529 1530 DO j = minorig, nl 1531 DO il = 1, ncum 1532 IF ((i>=icb(il)) .AND. (i<=inb(il)) .AND. (j>=(icb(il) - & 1533 1)) .AND. (j<=inb(il))) THEN 1534 1535 rti = rr(il, 1) - ep(il, i) * clw(il, i) 1536 bf2 = 1. + lv(il, j) * lv(il, j) * rs(il, j) / (rrv * t(il, j) * t(il, j) * cpd) 1537 anum = h(il, j) - hp(il, i) + (cpv - cpd) * t(il, j) * (rti - rr(il, j)) 1538 denom = h(il, i) - hp(il, i) + (cpd - cpv) * (rr(il, i) - rti) * t(il, j) 1539 dei = denom 1540 IF (abs(dei)<0.01) dei = 0.01 1541 sij(il, i, j) = anum / dei 1542 sij(il, i, i) = 1.0 1543 altem = sij(il, i, j) * rr(il, i) + (1. - sij(il, i, j)) * rti - rs(il, j) 1544 altem = altem / bf2 1545 cwat = clw(il, j) * (1. - ep(il, j)) 1546 stemp = sij(il, i, j) 1547 IF ((stemp<0.0 .OR. stemp>1.0 .OR. altem>cwat) .AND. j>i) THEN 1548 anum = anum - lv(il, j) * (rti - rs(il, j) - cwat * bf2) 1549 denom = denom + lv(il, j) * (rr(il, i) - rti) 1550 IF (abs(denom)<0.01) denom = 0.01 1551 sij(il, i, j) = anum / denom 1552 altem = sij(il, i, j) * rr(il, i) + (1. - sij(il, i, j)) * rti - & 1553 rs(il, j) 1554 altem = altem - (bf2 - 1.) * cwat 1555 END IF 1556 IF (sij(il, i, j)>0.0 .AND. sij(il, i, j)<0.95) THEN 1557 qent(il, i, j) = sij(il, i, j) * rr(il, i) + (1. - sij(il, i, j)) * rti 1558 uent(il, i, j) = sij(il, i, j) * u(il, i) + & 1559 (1. - sij(il, i, j)) * u(il, nk(il)) 1560 vent(il, i, j) = sij(il, i, j) * v(il, i) + & 1561 (1. - sij(il, i, j)) * v(il, nk(il)) 1562 ! !!! do k=1,ntra 1563 ! !!! traent(il,i,j,k)=sij(il,i,j)*tra(il,i,k) 1564 ! !!! : +(1.-sij(il,i,j))*tra(il,nk(il),k) 1565 ! !!! END DO 1566 elij(il, i, j) = altem 1567 elij(il, i, j) = amax1(0.0, elij(il, i, j)) 1568 ment(il, i, j) = m(il, i) / (1. - sij(il, i, j)) 1569 nent(il, i) = nent(il, i) + 1 1570 END IF 1571 sij(il, i, j) = amax1(0.0, sij(il, i, j)) 1572 sij(il, i, j) = amin1(1.0, sij(il, i, j)) 1573 END IF ! new 1574 END DO 1575 END DO 1576 1577 ! do k=1,ntra 1578 ! do j=minorig,nl 1579 ! do il=1,ncum 1580 ! IF( (i.ge.icb(il)).AND.(i.le.inb(il)).AND. 1581 ! : (j.ge.(icb(il)-1)).AND.(j.le.inb(il)))THEN 1582 ! traent(il,i,j,k)=sij(il,i,j)*tra(il,i,k) 1583 ! : +(1.-sij(il,i,j))*tra(il,nk(il),k) 1584 ! END IF 1585 ! enddo 1586 ! enddo 1587 ! enddo 1588 1589 1590 ! *** if no air can entrain at level i assume that updraft detrains 1591 ! *** 1592 ! *** at that level and calculate detrained air flux and properties 1593 ! *** 1594 1595 1596 ! @ do 170 i=icb(il),inb(il) 1597 1505 1598 DO il = 1, ncum 1506 IF ((i>=icb(il)) .AND. (i<=inb(il)) .AND. (j>=(icb(il) - & 1507 1)) .AND. (j<=inb(il))) THEN 1508 1509 rti = rr(il, 1) - ep(il, i) * clw(il, i) 1510 bf2 = 1. + lv(il, j) * lv(il, j) * rs(il, j) / (rrv * t(il, j) * t(il, j) * cpd) 1511 anum = h(il, j) - hp(il, i) + (cpv - cpd) * t(il, j) * (rti - rr(il, j)) 1512 denom = h(il, i) - hp(il, i) + (cpd - cpv) * (rr(il, i) - rti) * t(il, j) 1513 dei = denom 1514 IF (abs(dei)<0.01) dei = 0.01 1515 sij(il, i, j) = anum / dei 1516 sij(il, i, i) = 1.0 1517 altem = sij(il, i, j) * rr(il, i) + (1. - sij(il, i, j)) * rti - rs(il, j) 1518 altem = altem / bf2 1519 cwat = clw(il, j) * (1. - ep(il, j)) 1520 stemp = sij(il, i, j) 1521 IF ((stemp<0.0 .OR. stemp>1.0 .OR. altem>cwat) .AND. j>i) THEN 1522 anum = anum - lv(il, j) * (rti - rs(il, j) - cwat * bf2) 1523 denom = denom + lv(il, j) * (rr(il, i) - rti) 1524 IF (abs(denom)<0.01) denom = 0.01 1525 sij(il, i, j) = anum / denom 1526 altem = sij(il, i, j) * rr(il, i) + (1. - sij(il, i, j)) * rti - & 1527 rs(il, j) 1528 altem = altem - (bf2 - 1.) * cwat 1529 END IF 1530 IF (sij(il, i, j)>0.0 .AND. sij(il, i, j)<0.95) THEN 1531 qent(il, i, j) = sij(il, i, j) * rr(il, i) + (1. - sij(il, i, j)) * rti 1532 uent(il, i, j) = sij(il, i, j) * u(il, i) + & 1533 (1. - sij(il, i, j)) * u(il, nk(il)) 1534 vent(il, i, j) = sij(il, i, j) * v(il, i) + & 1535 (1. - sij(il, i, j)) * v(il, nk(il)) 1536 ! !!! do k=1,ntra 1537 ! !!! traent(il,i,j,k)=sij(il,i,j)*tra(il,i,k) 1538 ! !!! : +(1.-sij(il,i,j))*tra(il,nk(il),k) 1539 ! !!! END DO 1540 elij(il, i, j) = altem 1541 elij(il, i, j) = amax1(0.0, elij(il, i, j)) 1542 ment(il, i, j) = m(il, i) / (1. - sij(il, i, j)) 1543 nent(il, i) = nent(il, i) + 1 1544 END IF 1545 sij(il, i, j) = amax1(0.0, sij(il, i, j)) 1546 sij(il, i, j) = amin1(1.0, sij(il, i, j)) 1547 END IF ! new 1548 END DO 1549 END DO 1550 1551 ! do k=1,ntra 1552 ! do j=minorig,nl 1599 IF ((i>=icb(il)) .AND. (i<=inb(il)) .AND. (nent(il, i)==0)) THEN 1600 ! @ IF(nent(il,i).EQ.0)THEN 1601 ment(il, i, i) = m(il, i) 1602 qent(il, i, i) = rr(il, nk(il)) - ep(il, i) * clw(il, i) 1603 uent(il, i, i) = u(il, nk(il)) 1604 vent(il, i, i) = v(il, nk(il)) 1605 elij(il, i, i) = clw(il, i) 1606 ! MAF sij(il,i,i)=1.0 1607 sij(il, i, i) = 0.0 1608 END IF 1609 END DO 1610 END DO 1611 1612 ! do j=1,ntra 1613 ! do i=minorig+1,nl 1553 1614 ! do il=1,ncum 1554 ! IF( (i.ge.icb(il)).AND.(i.le.inb(il)).AND. 1555 ! : (j.ge.(icb(il)-1)).AND.(j.le.inb(il)))THEN 1556 ! traent(il,i,j,k)=sij(il,i,j)*tra(il,i,k) 1557 ! : +(1.-sij(il,i,j))*tra(il,nk(il),k) 1615 ! if (i.ge.icb(il) .AND. i.le.inb(il) .AND. nent(il,i).EQ.0) THEN 1616 ! traent(il,i,i,j)=tra(il,nk(il),j) 1558 1617 ! END IF 1559 1618 ! enddo … … 1561 1620 ! enddo 1562 1621 1563 1564 ! *** if no air can entrain at level i assume that updraft detrains 1565 ! *** 1566 ! *** at that level and calculate detrained air flux and properties 1567 ! *** 1568 1569 1570 ! @ do 170 i=icb(il),inb(il) 1622 DO j = minorig, nl 1623 DO i = minorig, nl 1624 DO il = 1, ncum 1625 IF ((j>=(icb(il) - 1)) .AND. (j<=inb(il)) .AND. (i>=icb(il)) .AND. (i<= & 1626 inb(il))) THEN 1627 sigij(il, i, j) = sij(il, i, j) 1628 END IF 1629 END DO 1630 END DO 1631 END DO 1632 ! @ enddo 1633 1634 ! @170 continue 1635 1636 ! ===================================================================== 1637 ! --- NORMALIZE ENTRAINED AIR MASS FLUXES 1638 ! --- TO REPRESENT EQUAL PROBABILITIES OF MIXING 1639 ! ===================================================================== 1640 1641 ! ym CALL zilch(asum,ncum*nd) 1642 ! ym CALL zilch(bsum,ncum*nd) 1643 ! ym CALL zilch(csum,ncum*nd) 1644 CALL zilch(asum, nloc * nd) 1645 CALL zilch(csum, nloc * nd) 1646 CALL zilch(csum, nloc * nd) 1571 1647 1572 1648 DO il = 1, ncum 1573 IF ((i>=icb(il)) .AND. (i<=inb(il)) .AND. (nent(il, i)==0)) THEN 1574 ! @ IF(nent(il,i).EQ.0)THEN 1575 ment(il, i, i) = m(il, i) 1576 qent(il, i, i) = rr(il, nk(il)) - ep(il, i) * clw(il, i) 1577 uent(il, i, i) = u(il, nk(il)) 1578 vent(il, i, i) = v(il, nk(il)) 1579 elij(il, i, i) = clw(il, i) 1580 ! MAF sij(il,i,i)=1.0 1581 sij(il, i, i) = 0.0 1582 END IF 1583 END DO 1584 END DO 1585 1586 ! do j=1,ntra 1587 ! do i=minorig+1,nl 1588 ! do il=1,ncum 1589 ! if (i.ge.icb(il) .AND. i.le.inb(il) .AND. nent(il,i).EQ.0) THEN 1590 ! traent(il,i,i,j)=tra(il,nk(il),j) 1591 ! END IF 1592 ! enddo 1593 ! enddo 1594 ! enddo 1595 1596 DO j = minorig, nl 1597 DO i = minorig, nl 1649 lwork(il) = .FALSE. 1650 END DO 1651 1652 DO i = minorig + 1, nl 1653 1654 num1 = 0 1598 1655 DO il = 1, ncum 1599 IF ((j>=(icb(il) - 1)) .AND. (j<=inb(il)) .AND. (i>=icb(il)) .AND. (i<= & 1600 inb(il))) THEN 1601 sigij(il, i, j) = sij(il, i, j) 1656 IF (i>=icb(il) .AND. i<=inb(il)) num1 = num1 + 1 1657 END DO 1658 IF (num1<=0) GO TO 789 1659 1660 DO il = 1, ncum 1661 IF (i>=icb(il) .AND. i<=inb(il)) THEN 1662 lwork(il) = (nent(il, i)/=0) 1663 qp = rr(il, 1) - ep(il, i) * clw(il, i) 1664 anum = h(il, i) - hp(il, i) - lv(il, i) * (qp - rs(il, i)) + & 1665 (cpv - cpd) * t(il, i) * (qp - rr(il, i)) 1666 denom = h(il, i) - hp(il, i) + lv(il, i) * (rr(il, i) - qp) + & 1667 (cpd - cpv) * t(il, i) * (rr(il, i) - qp) 1668 IF (abs(denom)<0.01) denom = 0.01 1669 scrit(il) = anum / denom 1670 alt = qp - rs(il, i) + scrit(il) * (rr(il, i) - qp) 1671 IF (scrit(il)<=0.0 .OR. alt<=0.0) scrit(il) = 1.0 1672 smax(il) = 0.0 1673 asij(il) = 0.0 1602 1674 END IF 1603 1675 END DO 1604 END DO 1605 END DO 1606 ! @ enddo 1607 1608 ! @170 continue 1609 1610 ! ===================================================================== 1611 ! --- NORMALIZE ENTRAINED AIR MASS FLUXES 1612 ! --- TO REPRESENT EQUAL PROBABILITIES OF MIXING 1613 ! ===================================================================== 1614 1615 ! ym CALL zilch(asum,ncum*nd) 1616 ! ym CALL zilch(bsum,ncum*nd) 1617 ! ym CALL zilch(csum,ncum*nd) 1618 CALL zilch(asum, nloc * nd) 1619 CALL zilch(csum, nloc * nd) 1620 CALL zilch(csum, nloc * nd) 1621 1622 DO il = 1, ncum 1623 lwork(il) = .FALSE. 1624 END DO 1625 1626 DO i = minorig + 1, nl 1627 1628 num1 = 0 1676 1677 DO j = nl, minorig, -1 1678 1679 num2 = 0 1680 DO il = 1, ncum 1681 IF (i>=icb(il) .AND. i<=inb(il) .AND. j>=(icb(& 1682 il) - 1) .AND. j<=inb(il) .AND. lwork(il)) num2 = num2 + 1 1683 END DO 1684 IF (num2<=0) GO TO 175 1685 1686 DO il = 1, ncum 1687 IF (i>=icb(il) .AND. i<=inb(il) .AND. j>=(icb(& 1688 il) - 1) .AND. j<=inb(il) .AND. lwork(il)) THEN 1689 1690 IF (sij(il, i, j)>1.0E-16 .AND. sij(il, i, j)<0.95) THEN 1691 wgh = 1.0 1692 IF (j>i) THEN 1693 sjmax = amax1(sij(il, i, j + 1), smax(il)) 1694 sjmax = amin1(sjmax, scrit(il)) 1695 smax(il) = amax1(sij(il, i, j), smax(il)) 1696 sjmin = amax1(sij(il, i, j - 1), smax(il)) 1697 sjmin = amin1(sjmin, scrit(il)) 1698 IF (sij(il, i, j)<(smax(il) - 1.0E-16)) wgh = 0.0 1699 smid = amin1(sij(il, i, j), scrit(il)) 1700 ELSE 1701 sjmax = amax1(sij(il, i, j + 1), scrit(il)) 1702 smid = amax1(sij(il, i, j), scrit(il)) 1703 sjmin = 0.0 1704 IF (j>1) sjmin = sij(il, i, j - 1) 1705 sjmin = amax1(sjmin, scrit(il)) 1706 END IF 1707 delp = abs(sjmax - smid) 1708 delm = abs(sjmin - smid) 1709 asij(il) = asij(il) + wgh * (delp + delm) 1710 ment(il, i, j) = ment(il, i, j) * (delp + delm) * wgh 1711 END IF 1712 END IF 1713 END DO 1714 1715 175 END DO 1716 1717 DO il = 1, ncum 1718 IF (i>=icb(il) .AND. i<=inb(il) .AND. lwork(il)) THEN 1719 asij(il) = amax1(1.0E-16, asij(il)) 1720 asij(il) = 1.0 / asij(il) 1721 asum(il, i) = 0.0 1722 bsum(il, i) = 0.0 1723 csum(il, i) = 0.0 1724 END IF 1725 END DO 1726 1727 DO j = minorig, nl 1728 DO il = 1, ncum 1729 IF (i>=icb(il) .AND. i<=inb(il) .AND. lwork(il) .AND. j>=(icb(& 1730 il) - 1) .AND. j<=inb(il)) THEN 1731 ment(il, i, j) = ment(il, i, j) * asij(il) 1732 END IF 1733 END DO 1734 END DO 1735 1736 DO j = minorig, nl 1737 DO il = 1, ncum 1738 IF (i>=icb(il) .AND. i<=inb(il) .AND. lwork(il) .AND. j>=(icb(& 1739 il) - 1) .AND. j<=inb(il)) THEN 1740 asum(il, i) = asum(il, i) + ment(il, i, j) 1741 ment(il, i, j) = ment(il, i, j) * sig(il, j) 1742 bsum(il, i) = bsum(il, i) + ment(il, i, j) 1743 END IF 1744 END DO 1745 END DO 1746 1747 DO il = 1, ncum 1748 IF (i>=icb(il) .AND. i<=inb(il) .AND. lwork(il)) THEN 1749 bsum(il, i) = amax1(bsum(il, i), 1.0E-16) 1750 bsum(il, i) = 1.0 / bsum(il, i) 1751 END IF 1752 END DO 1753 1754 DO j = minorig, nl 1755 DO il = 1, ncum 1756 IF (i>=icb(il) .AND. i<=inb(il) .AND. lwork(il) .AND. j>=(icb(& 1757 il) - 1) .AND. j<=inb(il)) THEN 1758 ment(il, i, j) = ment(il, i, j) * asum(il, i) * bsum(il, i) 1759 END IF 1760 END DO 1761 END DO 1762 1763 DO j = minorig, nl 1764 DO il = 1, ncum 1765 IF (i>=icb(il) .AND. i<=inb(il) .AND. lwork(il) .AND. j>=(icb(& 1766 il) - 1) .AND. j<=inb(il)) THEN 1767 csum(il, i) = csum(il, i) + ment(il, i, j) 1768 END IF 1769 END DO 1770 END DO 1771 1772 DO il = 1, ncum 1773 IF (i>=icb(il) .AND. i<=inb(il) .AND. lwork(il) .AND. & 1774 csum(il, i)<m(il, i)) THEN 1775 nent(il, i) = 0 1776 ment(il, i, i) = m(il, i) 1777 qent(il, i, i) = rr(il, 1) - ep(il, i) * clw(il, i) 1778 uent(il, i, i) = u(il, nk(il)) 1779 vent(il, i, i) = v(il, nk(il)) 1780 elij(il, i, i) = clw(il, i) 1781 ! MAF sij(il,i,i)=1.0 1782 sij(il, i, i) = 0.0 1783 END IF 1784 END DO ! il 1785 1786 ! do j=1,ntra 1787 ! do il=1,ncum 1788 ! if ( i.ge.icb(il) .AND. i.le.inb(il) .AND. lwork(il) 1789 ! : .AND. csum(il,i).lt.m(il,i) ) THEN 1790 ! traent(il,i,i,j)=tra(il,nk(il),j) 1791 ! END IF 1792 ! enddo 1793 ! enddo 1794 789 END DO 1795 1796 ! MAF: renormalisation de MENT 1797 DO jm = 1, nd 1798 DO im = 1, nd 1799 DO il = 1, ncum 1800 zm(il, im) = zm(il, im) + (1. - sij(il, im, jm)) * ment(il, im, jm) 1801 END DO 1802 END DO 1803 END DO 1804 1805 DO jm = 1, nd 1806 DO im = 1, nd 1807 DO il = 1, ncum 1808 IF (zm(il, im)/=0.) THEN 1809 ment(il, im, jm) = ment(il, im, jm) * m(il, im) / zm(il, im) 1810 END IF 1811 END DO 1812 END DO 1813 END DO 1814 1815 DO jm = 1, nd 1816 DO im = 1, nd 1817 DO il = 1, ncum 1818 qents(il, im, jm) = qent(il, im, jm) 1819 ments(il, im, jm) = ment(il, im, jm) 1820 END DO 1821 END DO 1822 END DO 1823 1824 END SUBROUTINE cv30_mixing 1825 1826 1827 SUBROUTINE cv30_unsat(nloc, ncum, nd, na, ntra, icb, inb, t, rr, rs, gz, u, & 1828 v, tra, p, ph, th, tv, lv, cpn, ep, sigp, clw, m, ment, elij, delt, plcl, & 1829 mp, rp, up, vp, trap, wt, water, evap, b & ! RomP-jyg 1830 , wdtraina, wdtrainm) ! 26/08/10 RomP-jyg 1831 USE lmdz_cvflag 1832 USE lmdz_cvthermo 1833 1834 IMPLICIT NONE 1835 1836 1837 1838 ! inputs: 1839 INTEGER ncum, nd, na, ntra, nloc 1840 INTEGER icb(nloc), inb(nloc) 1841 REAL delt, plcl(nloc) 1842 REAL t(nloc, nd), rr(nloc, nd), rs(nloc, nd) 1843 REAL u(nloc, nd), v(nloc, nd) 1844 REAL tra(nloc, nd, ntra) 1845 REAL p(nloc, nd), ph(nloc, nd + 1) 1846 REAL th(nloc, na), gz(nloc, na) 1847 REAL lv(nloc, na), ep(nloc, na), sigp(nloc, na), clw(nloc, na) 1848 REAL cpn(nloc, na), tv(nloc, na) 1849 REAL m(nloc, na), ment(nloc, na, na), elij(nloc, na, na) 1850 1851 ! outputs: 1852 REAL mp(nloc, na), rp(nloc, na), up(nloc, na), vp(nloc, na) 1853 REAL water(nloc, na), evap(nloc, na), wt(nloc, na) 1854 REAL trap(nloc, na, ntra) 1855 REAL b(nloc, na) 1856 ! 25/08/10 - RomP---- ajout des masses precipitantes ejectees 1857 ! lascendance adiabatique et des flux melanges Pa et Pm. 1858 ! Distinction des wdtrain 1859 ! Pa = wdtrainA Pm = wdtrainM 1860 REAL wdtraina(nloc, na), wdtrainm(nloc, na) 1861 1862 ! local variables 1863 INTEGER i, j, k, il, num1 1864 REAL tinv, delti 1865 REAL awat, afac, afac1, afac2, bfac 1866 REAL pr1, pr2, sigt, b6, c6, revap, tevap, delth 1867 REAL amfac, amp2, xf, tf, fac2, ur, sru, fac, d, af, bf 1868 REAL ampmax 1869 REAL lvcp(nloc, na) 1870 REAL wdtrain(nloc) 1871 LOGICAL lwork(nloc) 1872 1873 1874 ! ------------------------------------------------------ 1875 1876 delti = 1. / delt 1877 tinv = 1. / 3. 1878 1879 mp(:, :) = 0. 1880 1881 DO i = 1, nl 1882 DO il = 1, ncum 1883 mp(il, i) = 0.0 1884 rp(il, i) = rr(il, i) 1885 up(il, i) = u(il, i) 1886 vp(il, i) = v(il, i) 1887 wt(il, i) = 0.001 1888 water(il, i) = 0.0 1889 evap(il, i) = 0.0 1890 b(il, i) = 0.0 1891 lvcp(il, i) = lv(il, i) / cpn(il, i) 1892 END DO 1893 END DO 1894 1895 ! do k=1,ntra 1896 ! do i=1,nd 1897 ! do il=1,ncum 1898 ! trap(il,i,k)=tra(il,i,k) 1899 ! enddo 1900 ! enddo 1901 ! enddo 1902 ! RomP >>> 1903 DO i = 1, nd 1904 DO il = 1, ncum 1905 wdtraina(il, i) = 0.0 1906 wdtrainm(il, i) = 0.0 1907 END DO 1908 END DO 1909 ! RomP <<< 1910 1911 ! *** check whether ep(inb)=0, if so, skip precipitating *** 1912 ! *** downdraft calculation *** 1913 1629 1914 DO il = 1, ncum 1630 IF (i>=icb(il) .AND. i<=inb(il)) num1 = num1 + 1 1631 END DO 1632 IF (num1<=0) GO TO 789 1633 1634 DO il = 1, ncum 1635 IF (i>=icb(il) .AND. i<=inb(il)) THEN 1636 lwork(il) = (nent(il, i)/=0) 1637 qp = rr(il, 1) - ep(il, i) * clw(il, i) 1638 anum = h(il, i) - hp(il, i) - lv(il, i) * (qp - rs(il, i)) + & 1639 (cpv - cpd) * t(il, i) * (qp - rr(il, i)) 1640 denom = h(il, i) - hp(il, i) + lv(il, i) * (rr(il, i) - qp) + & 1641 (cpd - cpv) * t(il, i) * (rr(il, i) - qp) 1642 IF (abs(denom)<0.01) denom = 0.01 1643 scrit(il) = anum / denom 1644 alt = qp - rs(il, i) + scrit(il) * (rr(il, i) - qp) 1645 IF (scrit(il)<=0.0 .OR. alt<=0.0) scrit(il) = 1.0 1646 smax(il) = 0.0 1647 asij(il) = 0.0 1648 END IF 1649 END DO 1650 1651 DO j = nl, minorig, -1 1652 1653 num2 = 0 1915 lwork(il) = .TRUE. 1916 IF (ep(il, inb(il))<0.0001) lwork(il) = .FALSE. 1917 END DO 1918 1919 CALL zilch(wdtrain, ncum) 1920 1921 DO i = nl + 1, 1, -1 1922 1923 num1 = 0 1654 1924 DO il = 1, ncum 1655 IF (i>=icb(il) .AND. i<=inb(il) .AND. j>=(icb(& 1656 il) - 1) .AND. j<=inb(il) .AND. lwork(il)) num2 = num2 + 1 1657 END DO 1658 IF (num2<=0) GO TO 175 1925 IF (i<=inb(il) .AND. lwork(il)) num1 = num1 + 1 1926 END DO 1927 IF (num1<=0) GO TO 400 1928 1929 1930 ! *** integrate liquid water equation to find condensed water *** 1931 ! *** and condensed water flux *** 1932 1933 1934 1935 ! *** begin downdraft loop *** 1936 1937 1938 1939 ! *** calculate detrained precipitation *** 1659 1940 1660 1941 DO il = 1, ncum 1661 IF (i>=icb(il) .AND. i<=inb(il) .AND. j>=(icb(& 1662 il) - 1) .AND. j<=inb(il) .AND. lwork(il)) THEN 1663 1664 IF (sij(il, i, j)>1.0E-16 .AND. sij(il, i, j)<0.95) THEN 1665 wgh = 1.0 1666 IF (j>i) THEN 1667 sjmax = amax1(sij(il, i, j + 1), smax(il)) 1668 sjmax = amin1(sjmax, scrit(il)) 1669 smax(il) = amax1(sij(il, i, j), smax(il)) 1670 sjmin = amax1(sij(il, i, j - 1), smax(il)) 1671 sjmin = amin1(sjmin, scrit(il)) 1672 IF (sij(il, i, j)<(smax(il) - 1.0E-16)) wgh = 0.0 1673 smid = amin1(sij(il, i, j), scrit(il)) 1674 ELSE 1675 sjmax = amax1(sij(il, i, j + 1), scrit(il)) 1676 smid = amax1(sij(il, i, j), scrit(il)) 1677 sjmin = 0.0 1678 IF (j>1) sjmin = sij(il, i, j - 1) 1679 sjmin = amax1(sjmin, scrit(il)) 1680 END IF 1681 delp = abs(sjmax - smid) 1682 delm = abs(sjmin - smid) 1683 asij(il) = asij(il) + wgh * (delp + delm) 1684 ment(il, i, j) = ment(il, i, j) * (delp + delm) * wgh 1942 IF (i<=inb(il) .AND. lwork(il)) THEN 1943 IF (cvflag_grav) THEN 1944 wdtrain(il) = grav * ep(il, i) * m(il, i) * clw(il, i) 1945 wdtraina(il, i) = wdtrain(il) / grav ! Pa 26/08/10 RomP 1946 ELSE 1947 wdtrain(il) = 10.0 * ep(il, i) * m(il, i) * clw(il, i) 1948 wdtraina(il, i) = wdtrain(il) / 10. ! Pa 26/08/10 RomP 1685 1949 END IF 1686 1950 END IF 1687 1951 END DO 1688 1952 1689 175 END DO 1953 IF (i>1) THEN 1954 1955 DO j = 1, i - 1 1956 DO il = 1, ncum 1957 IF (i<=inb(il) .AND. lwork(il)) THEN 1958 awat = elij(il, j, i) - (1. - ep(il, i)) * clw(il, i) 1959 awat = amax1(awat, 0.0) 1960 IF (cvflag_grav) THEN 1961 wdtrain(il) = wdtrain(il) + grav * awat * ment(il, j, i) 1962 ELSE 1963 wdtrain(il) = wdtrain(il) + 10.0 * awat * ment(il, j, i) 1964 END IF 1965 END IF 1966 END DO 1967 END DO 1968 DO il = 1, ncum 1969 IF (cvflag_grav) THEN 1970 wdtrainm(il, i) = wdtrain(il) / grav - wdtraina(il, i) ! Pm 26/08/10 RomP 1971 ELSE 1972 wdtrainm(il, i) = wdtrain(il) / 10. - wdtraina(il, i) ! Pm 26/08/10 RomP 1973 END IF 1974 END DO 1975 1976 END IF 1977 1978 1979 ! *** find rain water and evaporation using provisional *** 1980 ! *** estimates of rp(i)and rp(i-1) *** 1981 1982 DO il = 1, ncum 1983 1984 IF (i<=inb(il) .AND. lwork(il)) THEN 1985 1986 wt(il, i) = 45.0 1987 1988 IF (i<inb(il)) THEN 1989 rp(il, i) = rp(il, i + 1) + (cpd * (t(il, i + 1) - t(il, & 1990 i)) + gz(il, i + 1) - gz(il, i)) / lv(il, i) 1991 rp(il, i) = 0.5 * (rp(il, i) + rr(il, i)) 1992 END IF 1993 rp(il, i) = amax1(rp(il, i), 0.0) 1994 rp(il, i) = amin1(rp(il, i), rs(il, i)) 1995 rp(il, inb(il)) = rr(il, inb(il)) 1996 1997 IF (i==1) THEN 1998 afac = p(il, 1) * (rs(il, 1) - rp(il, 1)) / (1.0E4 + 2000.0 * p(il, 1) * rs(il, 1)) 1999 ELSE 2000 rp(il, i - 1) = rp(il, i) + (cpd * (t(il, i) - t(il, & 2001 i - 1)) + gz(il, i) - gz(il, i - 1)) / lv(il, i) 2002 rp(il, i - 1) = 0.5 * (rp(il, i - 1) + rr(il, i - 1)) 2003 rp(il, i - 1) = amin1(rp(il, i - 1), rs(il, i - 1)) 2004 rp(il, i - 1) = amax1(rp(il, i - 1), 0.0) 2005 afac1 = p(il, i) * (rs(il, i) - rp(il, i)) / (1.0E4 + 2000.0 * p(il, i) * rs(il, i) & 2006 ) 2007 afac2 = p(il, i - 1) * (rs(il, i - 1) - rp(il, i - 1)) / & 2008 (1.0E4 + 2000.0 * p(il, i - 1) * rs(il, i - 1)) 2009 afac = 0.5 * (afac1 + afac2) 2010 END IF 2011 IF (i==inb(il)) afac = 0.0 2012 afac = amax1(afac, 0.0) 2013 bfac = 1. / (sigd * wt(il, i)) 2014 2015 ! jyg1 2016 ! cc sigt=1.0 2017 ! cc IF(i.ge.icb)sigt=sigp(i) 2018 ! prise en compte de la variation progressive de sigt dans 2019 ! les couches icb et icb-1: 2020 ! pour plcl<ph(i+1), pr1=0 & pr2=1 2021 ! pour plcl>ph(i), pr1=1 & pr2=0 2022 ! pour ph(i+1)<plcl<ph(i), pr1 est la proportion a cheval 2023 ! sur le nuage, et pr2 est la proportion sous la base du 2024 ! nuage. 2025 pr1 = (plcl(il) - ph(il, i + 1)) / (ph(il, i) - ph(il, i + 1)) 2026 pr1 = max(0., min(1., pr1)) 2027 pr2 = (ph(il, i) - plcl(il)) / (ph(il, i) - ph(il, i + 1)) 2028 pr2 = max(0., min(1., pr2)) 2029 sigt = sigp(il, i) * pr1 + pr2 2030 ! jyg2 2031 2032 b6 = bfac * 50. * sigd * (ph(il, i) - ph(il, i + 1)) * sigt * afac 2033 c6 = water(il, i + 1) + bfac * wdtrain(il) - 50. * sigd * bfac * (ph(il, i) - ph(& 2034 il, i + 1)) * evap(il, i + 1) 2035 IF (c6>0.0) THEN 2036 revap = 0.5 * (-b6 + sqrt(b6 * b6 + 4. * c6)) 2037 evap(il, i) = sigt * afac * revap 2038 water(il, i) = revap * revap 2039 ELSE 2040 evap(il, i) = -evap(il, i + 1) + 0.02 * (wdtrain(il) + sigd * wt(il, i) * & 2041 water(il, i + 1)) / (sigd * (ph(il, i) - ph(il, i + 1))) 2042 END IF 2043 2044 ! *** calculate precipitating downdraft mass flux under *** 2045 ! *** hydrostatic approximation *** 2046 2047 IF (i/=1) THEN 2048 2049 tevap = amax1(0.0, evap(il, i)) 2050 delth = amax1(0.001, (th(il, i) - th(il, i - 1))) 2051 IF (cvflag_grav) THEN 2052 mp(il, i) = 100. * ginv * lvcp(il, i) * sigd * tevap * (p(il, i - 1) - p(il, i)) / & 2053 delth 2054 ELSE 2055 mp(il, i) = 10. * lvcp(il, i) * sigd * tevap * (p(il, i - 1) - p(il, i)) / delth 2056 END IF 2057 2058 ! *** if hydrostatic assumption fails, *** 2059 ! *** solve cubic difference equation for downdraft theta *** 2060 ! *** and mass flux from two simultaneous differential eqns *** 2061 2062 amfac = sigd * sigd * 70.0 * ph(il, i) * (p(il, i - 1) - p(il, i)) * & 2063 (th(il, i) - th(il, i - 1)) / (tv(il, i) * th(il, i)) 2064 amp2 = abs(mp(il, i + 1) * mp(il, i + 1) - mp(il, i) * mp(il, i)) 2065 IF (amp2>(0.1 * amfac)) THEN 2066 xf = 100.0 * sigd * sigd * sigd * (ph(il, i) - ph(il, i + 1)) 2067 tf = b(il, i) - 5.0 * (th(il, i) - th(il, i - 1)) * t(il, i) / (lvcp(il, i) * & 2068 sigd * th(il, i)) 2069 af = xf * tf + mp(il, i + 1) * mp(il, i + 1) * tinv 2070 bf = 2. * (tinv * mp(il, i + 1))**3 + tinv * mp(il, i + 1) * xf * tf + & 2071 50. * (p(il, i - 1) - p(il, i)) * xf * tevap 2072 fac2 = 1.0 2073 IF (bf<0.0) fac2 = -1.0 2074 bf = abs(bf) 2075 ur = 0.25 * bf * bf - af * af * af * tinv * tinv * tinv 2076 IF (ur>=0.0) THEN 2077 sru = sqrt(ur) 2078 fac = 1.0 2079 IF ((0.5 * bf - sru)<0.0) fac = -1.0 2080 mp(il, i) = mp(il, i + 1) * tinv + (0.5 * bf + sru)**tinv + & 2081 fac * (abs(0.5 * bf - sru))**tinv 2082 ELSE 2083 d = atan(2. * sqrt(-ur) / (bf + 1.0E-28)) 2084 IF (fac2<0.0) d = 3.14159 - d 2085 mp(il, i) = mp(il, i + 1) * tinv + 2. * sqrt(af * tinv) * cos(d * tinv) 2086 END IF 2087 mp(il, i) = amax1(0.0, mp(il, i)) 2088 2089 IF (cvflag_grav) THEN 2090 ! jyg : il y a vraisemblablement une erreur dans la ligne 2 2091 ! suivante: 2092 ! il faut diviser par (mp(il,i)*sigd*grav) et non par 2093 ! (mp(il,i)+sigd*0.1). 2094 ! Et il faut bien revoir les facteurs 100. 2095 b(il, i - 1) = b(il, i) + 100.0 * (p(il, i - 1) - p(il, i)) * tevap / (mp(il, & 2096 i) + sigd * 0.1) - 10.0 * (th(il, i) - th(il, i - 1)) * t(il, i) / (lvcp(il, i & 2097 ) * sigd * th(il, i)) 2098 ELSE 2099 b(il, i - 1) = b(il, i) + 100.0 * (p(il, i - 1) - p(il, i)) * tevap / (mp(il, & 2100 i) + sigd * 0.1) - 10.0 * (th(il, i) - th(il, i - 1)) * t(il, i) / (lvcp(il, i & 2101 ) * sigd * th(il, i)) 2102 END IF 2103 b(il, i - 1) = amax1(b(il, i - 1), 0.0) 2104 END IF 2105 2106 ! *** limit magnitude of mp(i) to meet cfl condition 2107 ! *** 2108 2109 ampmax = 2.0 * (ph(il, i) - ph(il, i + 1)) * delti 2110 amp2 = 2.0 * (ph(il, i - 1) - ph(il, i)) * delti 2111 ampmax = amin1(ampmax, amp2) 2112 mp(il, i) = amin1(mp(il, i), ampmax) 2113 2114 ! *** force mp to decrease linearly to zero 2115 ! *** 2116 ! *** between cloud base and the surface 2117 ! *** 2118 2119 IF (p(il, i)>p(il, icb(il))) THEN 2120 mp(il, i) = mp(il, icb(il)) * (p(il, 1) - p(il, i)) / & 2121 (p(il, 1) - p(il, icb(il))) 2122 END IF 2123 2124 END IF ! i.EQ.1 2125 2126 ! *** find mixing ratio of precipitating downdraft *** 2127 2128 IF (i/=inb(il)) THEN 2129 2130 rp(il, i) = rr(il, i) 2131 2132 IF (mp(il, i)>mp(il, i + 1)) THEN 2133 2134 IF (cvflag_grav) THEN 2135 rp(il, i) = rp(il, i + 1) * mp(il, i + 1) + & 2136 rr(il, i) * (mp(il, i) - mp(il, i + 1)) + 100. * ginv * 0.5 * sigd * (ph(il, i & 2137 ) - ph(il, i + 1)) * (evap(il, i + 1) + evap(il, i)) 2138 ELSE 2139 rp(il, i) = rp(il, i + 1) * mp(il, i + 1) + & 2140 rr(il, i) * (mp(il, i) - mp(il, i + 1)) + 5. * sigd * (ph(il, i) - ph(il, i + 1 & 2141 )) * (evap(il, i + 1) + evap(il, i)) 2142 END IF 2143 rp(il, i) = rp(il, i) / mp(il, i) 2144 up(il, i) = up(il, i + 1) * mp(il, i + 1) + u(il, i) * (mp(il, i) - mp(il, i + & 2145 1)) 2146 up(il, i) = up(il, i) / mp(il, i) 2147 vp(il, i) = vp(il, i + 1) * mp(il, i + 1) + v(il, i) * (mp(il, i) - mp(il, i + & 2148 1)) 2149 vp(il, i) = vp(il, i) / mp(il, i) 2150 2151 ! do j=1,ntra 2152 ! trap(il,i,j)=trap(il,i+1,j)*mp(il,i+1) 2153 ! testmaf : +trap(il,i,j)*(mp(il,i)-mp(il,i+1)) 2154 ! : +tra(il,i,j)*(mp(il,i)-mp(il,i+1)) 2155 ! trap(il,i,j)=trap(il,i,j)/mp(il,i) 2156 ! END DO 2157 2158 ELSE 2159 2160 IF (mp(il, i + 1)>1.0E-16) THEN 2161 IF (cvflag_grav) THEN 2162 rp(il, i) = rp(il, i + 1) + 100. * ginv * 0.5 * sigd * (ph(il, i) - ph(il, & 2163 i + 1)) * (evap(il, i + 1) + evap(il, i)) / mp(il, i + 1) 2164 ELSE 2165 rp(il, i) = rp(il, i + 1) + 5. * sigd * (ph(il, i) - ph(il, i + 1)) * (evap & 2166 (il, i + 1) + evap(il, i)) / mp(il, i + 1) 2167 END IF 2168 up(il, i) = up(il, i + 1) 2169 vp(il, i) = vp(il, i + 1) 2170 2171 ! do j=1,ntra 2172 ! trap(il,i,j)=trap(il,i+1,j) 2173 ! END DO 2174 2175 END IF 2176 END IF 2177 rp(il, i) = amin1(rp(il, i), rs(il, i)) 2178 rp(il, i) = amax1(rp(il, i), 0.0) 2179 2180 END IF 2181 END IF 2182 END DO 2183 2184 400 END DO 2185 2186 END SUBROUTINE cv30_unsat 2187 2188 SUBROUTINE cv30_yield(nloc, ncum, nd, na, ntra, icb, inb, delt, t, rr, u, v, & 2189 tra, gz, p, ph, h, hp, lv, cpn, th, ep, clw, m, tp, mp, rp, up, vp, trap, & 2190 wt, water, evap, b, ment, qent, uent, vent, nent, elij, traent, sig, tv, & 2191 tvp, iflag, precip, vprecip, ft, fr, fu, fv, ftra, upwd, dnwd, dnwd0, ma, & 2192 mike, tls, tps, qcondc, wd) 2193 USE lmdz_conema3 2194 USE lmdz_cvflag 2195 USE lmdz_cvthermo 2196 2197 IMPLICIT NONE 2198 2199 ! inputs: 2200 INTEGER ncum, nd, na, ntra, nloc 2201 INTEGER icb(nloc), inb(nloc) 2202 REAL delt 2203 REAL t(nloc, nd), rr(nloc, nd), u(nloc, nd), v(nloc, nd) 2204 REAL tra(nloc, nd, ntra), sig(nloc, nd) 2205 REAL gz(nloc, na), ph(nloc, nd + 1), h(nloc, na), hp(nloc, na) 2206 REAL th(nloc, na), p(nloc, nd), tp(nloc, na) 2207 REAL lv(nloc, na), cpn(nloc, na), ep(nloc, na), clw(nloc, na) 2208 REAL m(nloc, na), mp(nloc, na), rp(nloc, na), up(nloc, na) 2209 REAL vp(nloc, na), wt(nloc, nd), trap(nloc, nd, ntra) 2210 REAL water(nloc, na), evap(nloc, na), b(nloc, na) 2211 REAL ment(nloc, na, na), qent(nloc, na, na), uent(nloc, na, na) 2212 ! ym real vent(nloc,na,na), nent(nloc,na), elij(nloc,na,na) 2213 REAL vent(nloc, na, na), elij(nloc, na, na) 2214 INTEGER nent(nloc, na) 2215 REAL traent(nloc, na, na, ntra) 2216 REAL tv(nloc, nd), tvp(nloc, nd) 2217 2218 ! input/output: 2219 INTEGER iflag(nloc) 2220 2221 ! outputs: 2222 REAL precip(nloc) 2223 REAL vprecip(nloc, nd + 1) 2224 REAL ft(nloc, nd), fr(nloc, nd), fu(nloc, nd), fv(nloc, nd) 2225 REAL ftra(nloc, nd, ntra) 2226 REAL upwd(nloc, nd), dnwd(nloc, nd), ma(nloc, nd) 2227 REAL dnwd0(nloc, nd), mike(nloc, nd) 2228 REAL tls(nloc, nd), tps(nloc, nd) 2229 REAL qcondc(nloc, nd) ! cld 2230 REAL wd(nloc) ! gust 2231 2232 ! local variables: 2233 INTEGER i, k, il, n, j, num1 2234 REAL rat, awat, delti 2235 REAL ax, bx, cx, dx, ex 2236 REAL cpinv, rdcp, dpinv 2237 REAL lvcp(nloc, na), mke(nloc, na) 2238 REAL am(nloc), work(nloc), ad(nloc), amp1(nloc) 2239 ! !! real up1(nloc), dn1(nloc) 2240 REAL up1(nloc, nd, nd), dn1(nloc, nd, nd) 2241 REAL asum(nloc), bsum(nloc), csum(nloc), dsum(nloc) 2242 REAL qcond(nloc, nd), nqcond(nloc, nd), wa(nloc, nd) ! cld 2243 REAL siga(nloc, nd), sax(nloc, nd), mac(nloc, nd) ! cld 2244 2245 2246 ! ------------------------------------------------------------- 2247 2248 ! initialization: 2249 2250 delti = 1.0 / delt 1690 2251 1691 2252 DO il = 1, ncum 1692 IF (i>=icb(il) .AND. i<=inb(il) .AND. lwork(il)) THEN 1693 asij(il) = amax1(1.0E-16, asij(il)) 1694 asij(il) = 1.0 / asij(il) 1695 asum(il, i) = 0.0 1696 bsum(il, i) = 0.0 1697 csum(il, i) = 0.0 2253 precip(il) = 0.0 2254 wd(il) = 0.0 ! gust 2255 vprecip(il, nd + 1) = 0. 2256 END DO 2257 2258 DO i = 1, nd 2259 DO il = 1, ncum 2260 vprecip(il, i) = 0.0 2261 ft(il, i) = 0.0 2262 fr(il, i) = 0.0 2263 fu(il, i) = 0.0 2264 fv(il, i) = 0.0 2265 qcondc(il, i) = 0.0 ! cld 2266 qcond(il, i) = 0.0 ! cld 2267 nqcond(il, i) = 0.0 ! cld 2268 END DO 2269 END DO 2270 2271 ! do j=1,ntra 2272 ! do i=1,nd 2273 ! do il=1,ncum 2274 ! ftra(il,i,j)=0.0 2275 ! enddo 2276 ! enddo 2277 ! enddo 2278 2279 DO i = 1, nl 2280 DO il = 1, ncum 2281 lvcp(il, i) = lv(il, i) / cpn(il, i) 2282 END DO 2283 END DO 2284 2285 2286 2287 ! *** calculate surface precipitation in mm/day *** 2288 2289 DO il = 1, ncum 2290 IF (ep(il, inb(il))>=0.0001) THEN 2291 IF (cvflag_grav) THEN 2292 precip(il) = wt(il, 1) * sigd * water(il, 1) * 86400. * 1000. / (rowl * grav) 2293 ELSE 2294 precip(il) = wt(il, 1) * sigd * water(il, 1) * 8640. 2295 END IF 1698 2296 END IF 1699 2297 END DO 1700 2298 1701 DO j = minorig, nl 2299 ! *** CALCULATE VERTICAL PROFILE OF PRECIPITATIONs IN kg/m2/s === 2300 2301 ! MAF rajout pour lessivage 2302 DO k = 1, nl 1702 2303 DO il = 1, ncum 1703 IF (i>=icb(il) .AND. i<=inb(il) .AND. lwork(il) .AND. j>=(icb(& 1704 il) - 1) .AND. j<=inb(il)) THEN 1705 ment(il, i, j) = ment(il, i, j) * asij(il) 2304 IF (k<=inb(il)) THEN 2305 IF (cvflag_grav) THEN 2306 vprecip(il, k) = wt(il, k) * sigd * water(il, k) / grav 2307 ELSE 2308 vprecip(il, k) = wt(il, k) * sigd * water(il, k) / 10. 2309 END IF 1706 2310 END IF 1707 2311 END DO 1708 2312 END DO 1709 2313 1710 DO j = minorig, nl 2314 2315 ! *** Calculate downdraft velocity scale *** 2316 ! *** NE PAS UTILISER POUR L'INSTANT *** 2317 2318 ! do il=1,ncum 2319 ! wd(il)=betad*abs(mp(il,icb(il)))*0.01*rrd*t(il,icb(il)) 2320 ! : /(sigd*p(il,icb(il))) 2321 ! enddo 2322 2323 2324 ! *** calculate tendencies of lowest level potential temperature *** 2325 ! *** and mixing ratio *** 2326 2327 DO il = 1, ncum 2328 work(il) = 1.0 / (ph(il, 1) - ph(il, 2)) 2329 am(il) = 0.0 2330 END DO 2331 2332 DO k = 2, nl 1711 2333 DO il = 1, ncum 1712 IF (i>=icb(il) .AND. i<=inb(il) .AND. lwork(il) .AND. j>=(icb(& 1713 il) - 1) .AND. j<=inb(il)) THEN 1714 asum(il, i) = asum(il, i) + ment(il, i, j) 1715 ment(il, i, j) = ment(il, i, j) * sig(il, j) 1716 bsum(il, i) = bsum(il, i) + ment(il, i, j) 2334 IF (k<=inb(il)) THEN 2335 am(il) = am(il) + m(il, k) 1717 2336 END IF 1718 2337 END DO … … 1720 2339 1721 2340 DO il = 1, ncum 1722 IF (i>=icb(il) .AND. i<=inb(il) .AND. lwork(il)) THEN 1723 bsum(il, i) = amax1(bsum(il, i), 1.0E-16) 1724 bsum(il, i) = 1.0 / bsum(il, i) 2341 2342 ! convect3 if((0.1*dpinv*am).ge.delti)iflag(il)=4 2343 IF (cvflag_grav) THEN 2344 IF ((0.01 * grav * work(il) * am(il))>=delti) iflag(il) = 1 !consist vect 2345 ft(il, 1) = 0.01 * grav * work(il) * am(il) * (t(il, 2) - t(il, 1) + (gz(il, 2) - gz(il, & 2346 1)) / cpn(il, 1)) 2347 ELSE 2348 IF ((0.1 * work(il) * am(il))>=delti) iflag(il) = 1 !consistency vect 2349 ft(il, 1) = 0.1 * work(il) * am(il) * (t(il, 2) - t(il, 1) + (gz(il, 2) - gz(il, & 2350 1)) / cpn(il, 1)) 1725 2351 END IF 1726 END DO 1727 1728 DO j = minorig, nl 1729 DO il = 1, ncum 1730 IF (i>=icb(il) .AND. i<=inb(il) .AND. lwork(il) .AND. j>=(icb(& 1731 il) - 1) .AND. j<=inb(il)) THEN 1732 ment(il, i, j) = ment(il, i, j) * asum(il, i) * bsum(il, i) 1733 END IF 1734 END DO 1735 END DO 1736 1737 DO j = minorig, nl 1738 DO il = 1, ncum 1739 IF (i>=icb(il) .AND. i<=inb(il) .AND. lwork(il) .AND. j>=(icb(& 1740 il) - 1) .AND. j<=inb(il)) THEN 1741 csum(il, i) = csum(il, i) + ment(il, i, j) 1742 END IF 1743 END DO 1744 END DO 1745 1746 DO il = 1, ncum 1747 IF (i>=icb(il) .AND. i<=inb(il) .AND. lwork(il) .AND. & 1748 csum(il, i)<m(il, i)) THEN 1749 nent(il, i) = 0 1750 ment(il, i, i) = m(il, i) 1751 qent(il, i, i) = rr(il, 1) - ep(il, i) * clw(il, i) 1752 uent(il, i, i) = u(il, nk(il)) 1753 vent(il, i, i) = v(il, nk(il)) 1754 elij(il, i, i) = clw(il, i) 1755 ! MAF sij(il,i,i)=1.0 1756 sij(il, i, i) = 0.0 2352 2353 ft(il, 1) = ft(il, 1) - 0.5 * lvcp(il, 1) * sigd * (evap(il, 1) + evap(il, 2)) 2354 2355 IF (cvflag_grav) THEN 2356 ft(il, 1) = ft(il, 1) - 0.009 * grav * sigd * mp(il, 2) * t(il, 1) * b(il, 1) * & 2357 work(il) 2358 ELSE 2359 ft(il, 1) = ft(il, 1) - 0.09 * sigd * mp(il, 2) * t(il, 1) * b(il, 1) * work(il) 1757 2360 END IF 2361 2362 ft(il, 1) = ft(il, 1) + 0.01 * sigd * wt(il, 1) * (cl - cpd) * water(il, 2) * (t(il, 2 & 2363 ) - t(il, 1)) * work(il) / cpn(il, 1) 2364 2365 IF (cvflag_grav) THEN 2366 ! jyg1 Correction pour mieux conserver l'eau (conformite avec 2367 ! CONVECT4.3) 2368 ! (sb: pour l'instant, on ne fait que le chgt concernant grav, pas 2369 ! evap) 2370 fr(il, 1) = 0.01 * grav * mp(il, 2) * (rp(il, 2) - rr(il, 1)) * work(il) + & 2371 sigd * 0.5 * (evap(il, 1) + evap(il, 2)) 2372 ! +tard : +sigd*evap(il,1) 2373 2374 fr(il, 1) = fr(il, 1) + 0.01 * grav * am(il) * (rr(il, 2) - rr(il, 1)) * work(il) 2375 2376 fu(il, 1) = fu(il, 1) + 0.01 * grav * work(il) * (mp(il, 2) * (up(il, 2) - u(il, & 2377 1)) + am(il) * (u(il, 2) - u(il, 1))) 2378 fv(il, 1) = fv(il, 1) + 0.01 * grav * work(il) * (mp(il, 2) * (vp(il, 2) - v(il, & 2379 1)) + am(il) * (v(il, 2) - v(il, 1))) 2380 ELSE ! cvflag_grav 2381 fr(il, 1) = 0.1 * mp(il, 2) * (rp(il, 2) - rr(il, 1)) * work(il) + & 2382 sigd * 0.5 * (evap(il, 1) + evap(il, 2)) 2383 fr(il, 1) = fr(il, 1) + 0.1 * am(il) * (rr(il, 2) - rr(il, 1)) * work(il) 2384 fu(il, 1) = fu(il, 1) + 0.1 * work(il) * (mp(il, 2) * (up(il, 2) - u(il, & 2385 1)) + am(il) * (u(il, 2) - u(il, 1))) 2386 fv(il, 1) = fv(il, 1) + 0.1 * work(il) * (mp(il, 2) * (vp(il, 2) - v(il, & 2387 1)) + am(il) * (v(il, 2) - v(il, 1))) 2388 END IF ! cvflag_grav 2389 1758 2390 END DO ! il 1759 2391 1760 2392 ! do j=1,ntra 1761 2393 ! do il=1,ncum 1762 ! if ( i.ge.icb(il) .AND. i.le.inb(il) .AND. lwork(il) 1763 ! : .AND. csum(il,i).lt.m(il,i) ) THEN 1764 ! traent(il,i,i,j)=tra(il,nk(il),j) 2394 ! if (cvflag_grav) THEN 2395 ! ftra(il,1,j)=ftra(il,1,j)+0.01*grav*work(il) 2396 ! : *(mp(il,2)*(trap(il,2,j)-tra(il,1,j)) 2397 ! : +am(il)*(tra(il,2,j)-tra(il,1,j))) 2398 ! else 2399 ! ftra(il,1,j)=ftra(il,1,j)+0.1*work(il) 2400 ! : *(mp(il,2)*(trap(il,2,j)-tra(il,1,j)) 2401 ! : +am(il)*(tra(il,2,j)-tra(il,1,j))) 1765 2402 ! END IF 1766 2403 ! enddo 1767 2404 ! enddo 1768 789 END DO 1769 1770 ! MAF: renormalisation de MENT 1771 DO jm = 1, nd 1772 DO im = 1, nd 2405 2406 DO j = 2, nl 1773 2407 DO il = 1, ncum 1774 zm(il, im) = zm(il, im) + (1. - sij(il, im, jm)) * ment(il, im, jm) 1775 END DO 1776 END DO 1777 END DO 1778 1779 DO jm = 1, nd 1780 DO im = 1, nd 1781 DO il = 1, ncum 1782 IF (zm(il, im)/=0.) THEN 1783 ment(il, im, jm) = ment(il, im, jm) * m(il, im) / zm(il, im) 1784 END IF 1785 END DO 1786 END DO 1787 END DO 1788 1789 DO jm = 1, nd 1790 DO im = 1, nd 1791 DO il = 1, ncum 1792 qents(il, im, jm) = qent(il, im, jm) 1793 ments(il, im, jm) = ment(il, im, jm) 1794 END DO 1795 END DO 1796 END DO 1797 1798 END SUBROUTINE cv30_mixing 1799 1800 1801 SUBROUTINE cv30_unsat(nloc, ncum, nd, na, ntra, icb, inb, t, rr, rs, gz, u, & 1802 v, tra, p, ph, th, tv, lv, cpn, ep, sigp, clw, m, ment, elij, delt, plcl, & 1803 mp, rp, up, vp, trap, wt, water, evap, b & ! RomP-jyg 1804 , wdtraina, wdtrainm) ! 26/08/10 RomP-jyg 1805 USE lmdz_cvflag 1806 1807 IMPLICIT NONE 1808 1809 include "cvthermo.h" 1810 include "cv30param.h" 1811 1812 ! inputs: 1813 INTEGER ncum, nd, na, ntra, nloc 1814 INTEGER icb(nloc), inb(nloc) 1815 REAL delt, plcl(nloc) 1816 REAL t(nloc, nd), rr(nloc, nd), rs(nloc, nd) 1817 REAL u(nloc, nd), v(nloc, nd) 1818 REAL tra(nloc, nd, ntra) 1819 REAL p(nloc, nd), ph(nloc, nd + 1) 1820 REAL th(nloc, na), gz(nloc, na) 1821 REAL lv(nloc, na), ep(nloc, na), sigp(nloc, na), clw(nloc, na) 1822 REAL cpn(nloc, na), tv(nloc, na) 1823 REAL m(nloc, na), ment(nloc, na, na), elij(nloc, na, na) 1824 1825 ! outputs: 1826 REAL mp(nloc, na), rp(nloc, na), up(nloc, na), vp(nloc, na) 1827 REAL water(nloc, na), evap(nloc, na), wt(nloc, na) 1828 REAL trap(nloc, na, ntra) 1829 REAL b(nloc, na) 1830 ! 25/08/10 - RomP---- ajout des masses precipitantes ejectees 1831 ! lascendance adiabatique et des flux melanges Pa et Pm. 1832 ! Distinction des wdtrain 1833 ! Pa = wdtrainA Pm = wdtrainM 1834 REAL wdtraina(nloc, na), wdtrainm(nloc, na) 1835 1836 ! local variables 1837 INTEGER i, j, k, il, num1 1838 REAL tinv, delti 1839 REAL awat, afac, afac1, afac2, bfac 1840 REAL pr1, pr2, sigt, b6, c6, revap, tevap, delth 1841 REAL amfac, amp2, xf, tf, fac2, ur, sru, fac, d, af, bf 1842 REAL ampmax 1843 REAL lvcp(nloc, na) 1844 REAL wdtrain(nloc) 1845 LOGICAL lwork(nloc) 1846 1847 1848 ! ------------------------------------------------------ 1849 1850 delti = 1. / delt 1851 tinv = 1. / 3. 1852 1853 mp(:, :) = 0. 1854 1855 DO i = 1, nl 1856 DO il = 1, ncum 1857 mp(il, i) = 0.0 1858 rp(il, i) = rr(il, i) 1859 up(il, i) = u(il, i) 1860 vp(il, i) = v(il, i) 1861 wt(il, i) = 0.001 1862 water(il, i) = 0.0 1863 evap(il, i) = 0.0 1864 b(il, i) = 0.0 1865 lvcp(il, i) = lv(il, i) / cpn(il, i) 1866 END DO 1867 END DO 1868 1869 ! do k=1,ntra 1870 ! do i=1,nd 1871 ! do il=1,ncum 1872 ! trap(il,i,k)=tra(il,i,k) 1873 ! enddo 1874 ! enddo 1875 ! enddo 1876 ! RomP >>> 1877 DO i = 1, nd 1878 DO il = 1, ncum 1879 wdtraina(il, i) = 0.0 1880 wdtrainm(il, i) = 0.0 1881 END DO 1882 END DO 1883 ! RomP <<< 1884 1885 ! *** check whether ep(inb)=0, if so, skip precipitating *** 1886 ! *** downdraft calculation *** 1887 1888 DO il = 1, ncum 1889 lwork(il) = .TRUE. 1890 IF (ep(il, inb(il))<0.0001) lwork(il) = .FALSE. 1891 END DO 1892 1893 CALL zilch(wdtrain, ncum) 1894 1895 DO i = nl + 1, 1, -1 1896 1897 num1 = 0 1898 DO il = 1, ncum 1899 IF (i<=inb(il) .AND. lwork(il)) num1 = num1 + 1 1900 END DO 1901 IF (num1<=0) GO TO 400 1902 1903 1904 ! *** integrate liquid water equation to find condensed water *** 1905 ! *** and condensed water flux *** 1906 1907 1908 1909 ! *** begin downdraft loop *** 1910 1911 1912 1913 ! *** calculate detrained precipitation *** 1914 1915 DO il = 1, ncum 1916 IF (i<=inb(il) .AND. lwork(il)) THEN 1917 IF (cvflag_grav) THEN 1918 wdtrain(il) = grav * ep(il, i) * m(il, i) * clw(il, i) 1919 wdtraina(il, i) = wdtrain(il) / grav ! Pa 26/08/10 RomP 1920 ELSE 1921 wdtrain(il) = 10.0 * ep(il, i) * m(il, i) * clw(il, i) 1922 wdtraina(il, i) = wdtrain(il) / 10. ! Pa 26/08/10 RomP 1923 END IF 1924 END IF 1925 END DO 1926 1927 IF (i>1) THEN 1928 1929 DO j = 1, i - 1 1930 DO il = 1, ncum 1931 IF (i<=inb(il) .AND. lwork(il)) THEN 1932 awat = elij(il, j, i) - (1. - ep(il, i)) * clw(il, i) 1933 awat = amax1(awat, 0.0) 1934 IF (cvflag_grav) THEN 1935 wdtrain(il) = wdtrain(il) + grav * awat * ment(il, j, i) 1936 ELSE 1937 wdtrain(il) = wdtrain(il) + 10.0 * awat * ment(il, j, i) 1938 END IF 1939 END IF 1940 END DO 1941 END DO 1942 DO il = 1, ncum 1943 IF (cvflag_grav) THEN 1944 wdtrainm(il, i) = wdtrain(il) / grav - wdtraina(il, i) ! Pm 26/08/10 RomP 1945 ELSE 1946 wdtrainm(il, i) = wdtrain(il) / 10. - wdtraina(il, i) ! Pm 26/08/10 RomP 1947 END IF 1948 END DO 1949 1950 END IF 1951 1952 1953 ! *** find rain water and evaporation using provisional *** 1954 ! *** estimates of rp(i)and rp(i-1) *** 1955 1956 DO il = 1, ncum 1957 1958 IF (i<=inb(il) .AND. lwork(il)) THEN 1959 1960 wt(il, i) = 45.0 1961 1962 IF (i<inb(il)) THEN 1963 rp(il, i) = rp(il, i + 1) + (cpd * (t(il, i + 1) - t(il, & 1964 i)) + gz(il, i + 1) - gz(il, i)) / lv(il, i) 1965 rp(il, i) = 0.5 * (rp(il, i) + rr(il, i)) 1966 END IF 1967 rp(il, i) = amax1(rp(il, i), 0.0) 1968 rp(il, i) = amin1(rp(il, i), rs(il, i)) 1969 rp(il, inb(il)) = rr(il, inb(il)) 1970 1971 IF (i==1) THEN 1972 afac = p(il, 1) * (rs(il, 1) - rp(il, 1)) / (1.0E4 + 2000.0 * p(il, 1) * rs(il, 1)) 1973 ELSE 1974 rp(il, i - 1) = rp(il, i) + (cpd * (t(il, i) - t(il, & 1975 i - 1)) + gz(il, i) - gz(il, i - 1)) / lv(il, i) 1976 rp(il, i - 1) = 0.5 * (rp(il, i - 1) + rr(il, i - 1)) 1977 rp(il, i - 1) = amin1(rp(il, i - 1), rs(il, i - 1)) 1978 rp(il, i - 1) = amax1(rp(il, i - 1), 0.0) 1979 afac1 = p(il, i) * (rs(il, i) - rp(il, i)) / (1.0E4 + 2000.0 * p(il, i) * rs(il, i) & 1980 ) 1981 afac2 = p(il, i - 1) * (rs(il, i - 1) - rp(il, i - 1)) / & 1982 (1.0E4 + 2000.0 * p(il, i - 1) * rs(il, i - 1)) 1983 afac = 0.5 * (afac1 + afac2) 1984 END IF 1985 IF (i==inb(il)) afac = 0.0 1986 afac = amax1(afac, 0.0) 1987 bfac = 1. / (sigd * wt(il, i)) 1988 1989 ! jyg1 1990 ! cc sigt=1.0 1991 ! cc IF(i.ge.icb)sigt=sigp(i) 1992 ! prise en compte de la variation progressive de sigt dans 1993 ! les couches icb et icb-1: 1994 ! pour plcl<ph(i+1), pr1=0 & pr2=1 1995 ! pour plcl>ph(i), pr1=1 & pr2=0 1996 ! pour ph(i+1)<plcl<ph(i), pr1 est la proportion a cheval 1997 ! sur le nuage, et pr2 est la proportion sous la base du 1998 ! nuage. 1999 pr1 = (plcl(il) - ph(il, i + 1)) / (ph(il, i) - ph(il, i + 1)) 2000 pr1 = max(0., min(1., pr1)) 2001 pr2 = (ph(il, i) - plcl(il)) / (ph(il, i) - ph(il, i + 1)) 2002 pr2 = max(0., min(1., pr2)) 2003 sigt = sigp(il, i) * pr1 + pr2 2004 ! jyg2 2005 2006 b6 = bfac * 50. * sigd * (ph(il, i) - ph(il, i + 1)) * sigt * afac 2007 c6 = water(il, i + 1) + bfac * wdtrain(il) - 50. * sigd * bfac * (ph(il, i) - ph(& 2008 il, i + 1)) * evap(il, i + 1) 2009 IF (c6>0.0) THEN 2010 revap = 0.5 * (-b6 + sqrt(b6 * b6 + 4. * c6)) 2011 evap(il, i) = sigt * afac * revap 2012 water(il, i) = revap * revap 2013 ELSE 2014 evap(il, i) = -evap(il, i + 1) + 0.02 * (wdtrain(il) + sigd * wt(il, i) * & 2015 water(il, i + 1)) / (sigd * (ph(il, i) - ph(il, i + 1))) 2016 END IF 2017 2018 ! *** calculate precipitating downdraft mass flux under *** 2019 ! *** hydrostatic approximation *** 2020 2021 IF (i/=1) THEN 2022 2023 tevap = amax1(0.0, evap(il, i)) 2024 delth = amax1(0.001, (th(il, i) - th(il, i - 1))) 2408 IF (j<=inb(il)) THEN 2025 2409 IF (cvflag_grav) THEN 2026 mp(il, i) = 100. * ginv * lvcp(il, i) * sigd * tevap * (p(il, i - 1) - p(il, i)) / & 2027 delth 2028 ELSE 2029 mp(il, i) = 10. * lvcp(il, i) * sigd * tevap * (p(il, i - 1) - p(il, i)) / delth 2030 END IF 2031 2032 ! *** if hydrostatic assumption fails, *** 2033 ! *** solve cubic difference equation for downdraft theta *** 2034 ! *** and mass flux from two simultaneous differential eqns *** 2035 2036 amfac = sigd * sigd * 70.0 * ph(il, i) * (p(il, i - 1) - p(il, i)) * & 2037 (th(il, i) - th(il, i - 1)) / (tv(il, i) * th(il, i)) 2038 amp2 = abs(mp(il, i + 1) * mp(il, i + 1) - mp(il, i) * mp(il, i)) 2039 IF (amp2>(0.1 * amfac)) THEN 2040 xf = 100.0 * sigd * sigd * sigd * (ph(il, i) - ph(il, i + 1)) 2041 tf = b(il, i) - 5.0 * (th(il, i) - th(il, i - 1)) * t(il, i) / (lvcp(il, i) * & 2042 sigd * th(il, i)) 2043 af = xf * tf + mp(il, i + 1) * mp(il, i + 1) * tinv 2044 bf = 2. * (tinv * mp(il, i + 1))**3 + tinv * mp(il, i + 1) * xf * tf + & 2045 50. * (p(il, i - 1) - p(il, i)) * xf * tevap 2046 fac2 = 1.0 2047 IF (bf<0.0) fac2 = -1.0 2048 bf = abs(bf) 2049 ur = 0.25 * bf * bf - af * af * af * tinv * tinv * tinv 2050 IF (ur>=0.0) THEN 2051 sru = sqrt(ur) 2052 fac = 1.0 2053 IF ((0.5 * bf - sru)<0.0) fac = -1.0 2054 mp(il, i) = mp(il, i + 1) * tinv + (0.5 * bf + sru)**tinv + & 2055 fac * (abs(0.5 * bf - sru))**tinv 2056 ELSE 2057 d = atan(2. * sqrt(-ur) / (bf + 1.0E-28)) 2058 IF (fac2<0.0) d = 3.14159 - d 2059 mp(il, i) = mp(il, i + 1) * tinv + 2. * sqrt(af * tinv) * cos(d * tinv) 2060 END IF 2061 mp(il, i) = amax1(0.0, mp(il, i)) 2062 2063 IF (cvflag_grav) THEN 2064 ! jyg : il y a vraisemblablement une erreur dans la ligne 2 2065 ! suivante: 2066 ! il faut diviser par (mp(il,i)*sigd*grav) et non par 2067 ! (mp(il,i)+sigd*0.1). 2068 ! Et il faut bien revoir les facteurs 100. 2069 b(il, i - 1) = b(il, i) + 100.0 * (p(il, i - 1) - p(il, i)) * tevap / (mp(il, & 2070 i) + sigd * 0.1) - 10.0 * (th(il, i) - th(il, i - 1)) * t(il, i) / (lvcp(il, i & 2071 ) * sigd * th(il, i)) 2072 ELSE 2073 b(il, i - 1) = b(il, i) + 100.0 * (p(il, i - 1) - p(il, i)) * tevap / (mp(il, & 2074 i) + sigd * 0.1) - 10.0 * (th(il, i) - th(il, i - 1)) * t(il, i) / (lvcp(il, i & 2075 ) * sigd * th(il, i)) 2076 END IF 2077 b(il, i - 1) = amax1(b(il, i - 1), 0.0) 2078 END IF 2079 2080 ! *** limit magnitude of mp(i) to meet cfl condition 2081 ! *** 2082 2083 ampmax = 2.0 * (ph(il, i) - ph(il, i + 1)) * delti 2084 amp2 = 2.0 * (ph(il, i - 1) - ph(il, i)) * delti 2085 ampmax = amin1(ampmax, amp2) 2086 mp(il, i) = amin1(mp(il, i), ampmax) 2087 2088 ! *** force mp to decrease linearly to zero 2089 ! *** 2090 ! *** between cloud base and the surface 2091 ! *** 2092 2093 IF (p(il, i)>p(il, icb(il))) THEN 2094 mp(il, i) = mp(il, icb(il)) * (p(il, 1) - p(il, i)) / & 2095 (p(il, 1) - p(il, icb(il))) 2096 END IF 2097 2098 END IF ! i.EQ.1 2099 2100 ! *** find mixing ratio of precipitating downdraft *** 2101 2102 IF (i/=inb(il)) THEN 2103 2104 rp(il, i) = rr(il, i) 2105 2106 IF (mp(il, i)>mp(il, i + 1)) THEN 2107 2108 IF (cvflag_grav) THEN 2109 rp(il, i) = rp(il, i + 1) * mp(il, i + 1) + & 2110 rr(il, i) * (mp(il, i) - mp(il, i + 1)) + 100. * ginv * 0.5 * sigd * (ph(il, i & 2111 ) - ph(il, i + 1)) * (evap(il, i + 1) + evap(il, i)) 2112 ELSE 2113 rp(il, i) = rp(il, i + 1) * mp(il, i + 1) + & 2114 rr(il, i) * (mp(il, i) - mp(il, i + 1)) + 5. * sigd * (ph(il, i) - ph(il, i + 1 & 2115 )) * (evap(il, i + 1) + evap(il, i)) 2116 END IF 2117 rp(il, i) = rp(il, i) / mp(il, i) 2118 up(il, i) = up(il, i + 1) * mp(il, i + 1) + u(il, i) * (mp(il, i) - mp(il, i + & 2119 1)) 2120 up(il, i) = up(il, i) / mp(il, i) 2121 vp(il, i) = vp(il, i + 1) * mp(il, i + 1) + v(il, i) * (mp(il, i) - mp(il, i + & 2122 1)) 2123 vp(il, i) = vp(il, i) / mp(il, i) 2124 2125 ! do j=1,ntra 2126 ! trap(il,i,j)=trap(il,i+1,j)*mp(il,i+1) 2127 ! testmaf : +trap(il,i,j)*(mp(il,i)-mp(il,i+1)) 2128 ! : +tra(il,i,j)*(mp(il,i)-mp(il,i+1)) 2129 ! trap(il,i,j)=trap(il,i,j)/mp(il,i) 2130 ! END DO 2131 2132 ELSE 2133 2134 IF (mp(il, i + 1)>1.0E-16) THEN 2135 IF (cvflag_grav) THEN 2136 rp(il, i) = rp(il, i + 1) + 100. * ginv * 0.5 * sigd * (ph(il, i) - ph(il, & 2137 i + 1)) * (evap(il, i + 1) + evap(il, i)) / mp(il, i + 1) 2138 ELSE 2139 rp(il, i) = rp(il, i + 1) + 5. * sigd * (ph(il, i) - ph(il, i + 1)) * (evap & 2140 (il, i + 1) + evap(il, i)) / mp(il, i + 1) 2141 END IF 2142 up(il, i) = up(il, i + 1) 2143 vp(il, i) = vp(il, i + 1) 2144 2145 ! do j=1,ntra 2146 ! trap(il,i,j)=trap(il,i+1,j) 2147 ! END DO 2148 2149 END IF 2150 END IF 2151 rp(il, i) = amin1(rp(il, i), rs(il, i)) 2152 rp(il, i) = amax1(rp(il, i), 0.0) 2153 2154 END IF 2155 END IF 2156 END DO 2157 2158 400 END DO 2159 2160 END SUBROUTINE cv30_unsat 2161 2162 SUBROUTINE cv30_yield(nloc, ncum, nd, na, ntra, icb, inb, delt, t, rr, u, v, & 2163 tra, gz, p, ph, h, hp, lv, cpn, th, ep, clw, m, tp, mp, rp, up, vp, trap, & 2164 wt, water, evap, b, ment, qent, uent, vent, nent, elij, traent, sig, tv, & 2165 tvp, iflag, precip, vprecip, ft, fr, fu, fv, ftra, upwd, dnwd, dnwd0, ma, & 2166 mike, tls, tps, qcondc, wd) 2167 USE lmdz_conema3 2168 USE lmdz_cvflag 2169 2170 IMPLICIT NONE 2171 2172 include "cvthermo.h" 2173 include "cv30param.h" 2174 2175 ! inputs: 2176 INTEGER ncum, nd, na, ntra, nloc 2177 INTEGER icb(nloc), inb(nloc) 2178 REAL delt 2179 REAL t(nloc, nd), rr(nloc, nd), u(nloc, nd), v(nloc, nd) 2180 REAL tra(nloc, nd, ntra), sig(nloc, nd) 2181 REAL gz(nloc, na), ph(nloc, nd + 1), h(nloc, na), hp(nloc, na) 2182 REAL th(nloc, na), p(nloc, nd), tp(nloc, na) 2183 REAL lv(nloc, na), cpn(nloc, na), ep(nloc, na), clw(nloc, na) 2184 REAL m(nloc, na), mp(nloc, na), rp(nloc, na), up(nloc, na) 2185 REAL vp(nloc, na), wt(nloc, nd), trap(nloc, nd, ntra) 2186 REAL water(nloc, na), evap(nloc, na), b(nloc, na) 2187 REAL ment(nloc, na, na), qent(nloc, na, na), uent(nloc, na, na) 2188 ! ym real vent(nloc,na,na), nent(nloc,na), elij(nloc,na,na) 2189 REAL vent(nloc, na, na), elij(nloc, na, na) 2190 INTEGER nent(nloc, na) 2191 REAL traent(nloc, na, na, ntra) 2192 REAL tv(nloc, nd), tvp(nloc, nd) 2193 2194 ! input/output: 2195 INTEGER iflag(nloc) 2196 2197 ! outputs: 2198 REAL precip(nloc) 2199 REAL vprecip(nloc, nd + 1) 2200 REAL ft(nloc, nd), fr(nloc, nd), fu(nloc, nd), fv(nloc, nd) 2201 REAL ftra(nloc, nd, ntra) 2202 REAL upwd(nloc, nd), dnwd(nloc, nd), ma(nloc, nd) 2203 REAL dnwd0(nloc, nd), mike(nloc, nd) 2204 REAL tls(nloc, nd), tps(nloc, nd) 2205 REAL qcondc(nloc, nd) ! cld 2206 REAL wd(nloc) ! gust 2207 2208 ! local variables: 2209 INTEGER i, k, il, n, j, num1 2210 REAL rat, awat, delti 2211 REAL ax, bx, cx, dx, ex 2212 REAL cpinv, rdcp, dpinv 2213 REAL lvcp(nloc, na), mke(nloc, na) 2214 REAL am(nloc), work(nloc), ad(nloc), amp1(nloc) 2215 ! !! real up1(nloc), dn1(nloc) 2216 REAL up1(nloc, nd, nd), dn1(nloc, nd, nd) 2217 REAL asum(nloc), bsum(nloc), csum(nloc), dsum(nloc) 2218 REAL qcond(nloc, nd), nqcond(nloc, nd), wa(nloc, nd) ! cld 2219 REAL siga(nloc, nd), sax(nloc, nd), mac(nloc, nd) ! cld 2220 2221 2222 ! ------------------------------------------------------------- 2223 2224 ! initialization: 2225 2226 delti = 1.0 / delt 2227 2228 DO il = 1, ncum 2229 precip(il) = 0.0 2230 wd(il) = 0.0 ! gust 2231 vprecip(il, nd + 1) = 0. 2232 END DO 2233 2234 DO i = 1, nd 2235 DO il = 1, ncum 2236 vprecip(il, i) = 0.0 2237 ft(il, i) = 0.0 2238 fr(il, i) = 0.0 2239 fu(il, i) = 0.0 2240 fv(il, i) = 0.0 2241 qcondc(il, i) = 0.0 ! cld 2242 qcond(il, i) = 0.0 ! cld 2243 nqcond(il, i) = 0.0 ! cld 2244 END DO 2245 END DO 2246 2247 ! do j=1,ntra 2248 ! do i=1,nd 2249 ! do il=1,ncum 2250 ! ftra(il,i,j)=0.0 2251 ! enddo 2252 ! enddo 2253 ! enddo 2254 2255 DO i = 1, nl 2256 DO il = 1, ncum 2257 lvcp(il, i) = lv(il, i) / cpn(il, i) 2258 END DO 2259 END DO 2260 2261 2262 2263 ! *** calculate surface precipitation in mm/day *** 2264 2265 DO il = 1, ncum 2266 IF (ep(il, inb(il))>=0.0001) THEN 2267 IF (cvflag_grav) THEN 2268 precip(il) = wt(il, 1) * sigd * water(il, 1) * 86400. * 1000. / (rowl * grav) 2269 ELSE 2270 precip(il) = wt(il, 1) * sigd * water(il, 1) * 8640. 2271 END IF 2272 END IF 2273 END DO 2274 2275 ! *** CALCULATE VERTICAL PROFILE OF PRECIPITATIONs IN kg/m2/s === 2276 2277 ! MAF rajout pour lessivage 2278 DO k = 1, nl 2279 DO il = 1, ncum 2280 IF (k<=inb(il)) THEN 2281 IF (cvflag_grav) THEN 2282 vprecip(il, k) = wt(il, k) * sigd * water(il, k) / grav 2283 ELSE 2284 vprecip(il, k) = wt(il, k) * sigd * water(il, k) / 10. 2285 END IF 2286 END IF 2287 END DO 2288 END DO 2289 2290 2291 ! *** Calculate downdraft velocity scale *** 2292 ! *** NE PAS UTILISER POUR L'INSTANT *** 2293 2294 ! do il=1,ncum 2295 ! wd(il)=betad*abs(mp(il,icb(il)))*0.01*rrd*t(il,icb(il)) 2296 ! : /(sigd*p(il,icb(il))) 2297 ! enddo 2298 2299 2300 ! *** calculate tendencies of lowest level potential temperature *** 2301 ! *** and mixing ratio *** 2302 2303 DO il = 1, ncum 2304 work(il) = 1.0 / (ph(il, 1) - ph(il, 2)) 2305 am(il) = 0.0 2306 END DO 2307 2308 DO k = 2, nl 2309 DO il = 1, ncum 2310 IF (k<=inb(il)) THEN 2311 am(il) = am(il) + m(il, k) 2312 END IF 2313 END DO 2314 END DO 2315 2316 DO il = 1, ncum 2317 2318 ! convect3 if((0.1*dpinv*am).ge.delti)iflag(il)=4 2319 IF (cvflag_grav) THEN 2320 IF ((0.01 * grav * work(il) * am(il))>=delti) iflag(il) = 1 !consist vect 2321 ft(il, 1) = 0.01 * grav * work(il) * am(il) * (t(il, 2) - t(il, 1) + (gz(il, 2) - gz(il, & 2322 1)) / cpn(il, 1)) 2323 ELSE 2324 IF ((0.1 * work(il) * am(il))>=delti) iflag(il) = 1 !consistency vect 2325 ft(il, 1) = 0.1 * work(il) * am(il) * (t(il, 2) - t(il, 1) + (gz(il, 2) - gz(il, & 2326 1)) / cpn(il, 1)) 2327 END IF 2328 2329 ft(il, 1) = ft(il, 1) - 0.5 * lvcp(il, 1) * sigd * (evap(il, 1) + evap(il, 2)) 2330 2331 IF (cvflag_grav) THEN 2332 ft(il, 1) = ft(il, 1) - 0.009 * grav * sigd * mp(il, 2) * t(il, 1) * b(il, 1) * & 2333 work(il) 2334 ELSE 2335 ft(il, 1) = ft(il, 1) - 0.09 * sigd * mp(il, 2) * t(il, 1) * b(il, 1) * work(il) 2336 END IF 2337 2338 ft(il, 1) = ft(il, 1) + 0.01 * sigd * wt(il, 1) * (cl - cpd) * water(il, 2) * (t(il, 2 & 2339 ) - t(il, 1)) * work(il) / cpn(il, 1) 2340 2341 IF (cvflag_grav) THEN 2342 ! jyg1 Correction pour mieux conserver l'eau (conformite avec 2343 ! CONVECT4.3) 2344 ! (sb: pour l'instant, on ne fait que le chgt concernant grav, pas 2345 ! evap) 2346 fr(il, 1) = 0.01 * grav * mp(il, 2) * (rp(il, 2) - rr(il, 1)) * work(il) + & 2347 sigd * 0.5 * (evap(il, 1) + evap(il, 2)) 2348 ! +tard : +sigd*evap(il,1) 2349 2350 fr(il, 1) = fr(il, 1) + 0.01 * grav * am(il) * (rr(il, 2) - rr(il, 1)) * work(il) 2351 2352 fu(il, 1) = fu(il, 1) + 0.01 * grav * work(il) * (mp(il, 2) * (up(il, 2) - u(il, & 2353 1)) + am(il) * (u(il, 2) - u(il, 1))) 2354 fv(il, 1) = fv(il, 1) + 0.01 * grav * work(il) * (mp(il, 2) * (vp(il, 2) - v(il, & 2355 1)) + am(il) * (v(il, 2) - v(il, 1))) 2356 ELSE ! cvflag_grav 2357 fr(il, 1) = 0.1 * mp(il, 2) * (rp(il, 2) - rr(il, 1)) * work(il) + & 2358 sigd * 0.5 * (evap(il, 1) + evap(il, 2)) 2359 fr(il, 1) = fr(il, 1) + 0.1 * am(il) * (rr(il, 2) - rr(il, 1)) * work(il) 2360 fu(il, 1) = fu(il, 1) + 0.1 * work(il) * (mp(il, 2) * (up(il, 2) - u(il, & 2361 1)) + am(il) * (u(il, 2) - u(il, 1))) 2362 fv(il, 1) = fv(il, 1) + 0.1 * work(il) * (mp(il, 2) * (vp(il, 2) - v(il, & 2363 1)) + am(il) * (v(il, 2) - v(il, 1))) 2364 END IF ! cvflag_grav 2365 2366 END DO ! il 2367 2368 ! do j=1,ntra 2369 ! do il=1,ncum 2370 ! if (cvflag_grav) THEN 2371 ! ftra(il,1,j)=ftra(il,1,j)+0.01*grav*work(il) 2372 ! : *(mp(il,2)*(trap(il,2,j)-tra(il,1,j)) 2373 ! : +am(il)*(tra(il,2,j)-tra(il,1,j))) 2374 ! else 2375 ! ftra(il,1,j)=ftra(il,1,j)+0.1*work(il) 2376 ! : *(mp(il,2)*(trap(il,2,j)-tra(il,1,j)) 2377 ! : +am(il)*(tra(il,2,j)-tra(il,1,j))) 2378 ! END IF 2379 ! enddo 2380 ! enddo 2381 2382 DO j = 2, nl 2383 DO il = 1, ncum 2384 IF (j<=inb(il)) THEN 2385 IF (cvflag_grav) THEN 2386 fr(il, 1) = fr(il, 1) + 0.01 * grav * work(il) * ment(il, j, 1) * (qent(il, & 2387 j, 1) - rr(il, 1)) 2388 fu(il, 1) = fu(il, 1) + 0.01 * grav * work(il) * ment(il, j, 1) * (uent(il, & 2389 j, 1) - u(il, 1)) 2390 fv(il, 1) = fv(il, 1) + 0.01 * grav * work(il) * ment(il, j, 1) * (vent(il, & 2391 j, 1) - v(il, 1)) 2392 ELSE ! cvflag_grav 2393 fr(il, 1) = fr(il, 1) + 0.1 * work(il) * ment(il, j, 1) * (qent(il, j, 1) - & 2394 rr(il, 1)) 2395 fu(il, 1) = fu(il, 1) + 0.1 * work(il) * ment(il, j, 1) * (uent(il, j, 1) - u & 2396 (il, 1)) 2397 fv(il, 1) = fv(il, 1) + 0.1 * work(il) * ment(il, j, 1) * (vent(il, j, 1) - v & 2398 (il, 1)) 2399 END IF ! cvflag_grav 2400 END IF ! j 2401 END DO 2402 END DO 2403 2404 ! do k=1,ntra 2405 ! do j=2,nl 2406 ! do il=1,ncum 2407 ! if (j.le.inb(il)) THEN 2408 ! if (cvflag_grav) THEN 2409 ! ftra(il,1,k)=ftra(il,1,k)+0.01*grav*work(il)*ment(il,j,1) 2410 ! : *(traent(il,j,1,k)-tra(il,1,k)) 2411 ! else 2412 ! ftra(il,1,k)=ftra(il,1,k)+0.1*work(il)*ment(il,j,1) 2413 ! : *(traent(il,j,1,k)-tra(il,1,k)) 2414 ! END IF 2415 2416 ! END IF 2417 ! enddo 2418 ! enddo 2419 ! enddo 2420 2421 2422 ! *** calculate tendencies of potential temperature and mixing ratio *** 2423 ! *** at levels above the lowest level *** 2424 2425 ! *** first find the net saturated updraft and downdraft mass fluxes *** 2426 ! *** through each level *** 2427 2428 DO i = 2, nl + 1 ! newvecto: mettre nl au lieu nl+1? 2429 2430 num1 = 0 2431 DO il = 1, ncum 2432 IF (i<=inb(il)) num1 = num1 + 1 2433 END DO 2434 IF (num1<=0) GO TO 500 2435 2436 CALL zilch(amp1, ncum) 2437 CALL zilch(ad, ncum) 2438 2439 DO k = i + 1, nl + 1 2440 DO il = 1, ncum 2441 IF (i<=inb(il) .AND. k<=(inb(il) + 1)) THEN 2442 amp1(il) = amp1(il) + m(il, k) 2443 END IF 2444 END DO 2445 END DO 2446 2447 DO k = 1, i 2448 DO j = i + 1, nl + 1 2449 DO il = 1, ncum 2450 IF (i<=inb(il) .AND. j<=(inb(il) + 1)) THEN 2451 amp1(il) = amp1(il) + ment(il, k, j) 2452 END IF 2453 END DO 2454 END DO 2455 END DO 2456 2457 DO k = 1, i - 1 2458 DO j = i, nl + 1 ! newvecto: nl au lieu nl+1? 2459 DO il = 1, ncum 2460 IF (i<=inb(il) .AND. j<=inb(il)) THEN 2461 ad(il) = ad(il) + ment(il, j, k) 2462 END IF 2463 END DO 2464 END DO 2465 END DO 2466 2467 DO il = 1, ncum 2468 IF (i<=inb(il)) THEN 2469 dpinv = 1.0 / (ph(il, i) - ph(il, i + 1)) 2470 cpinv = 1.0 / cpn(il, i) 2471 2472 ! convect3 if((0.1*dpinv*amp1).ge.delti)iflag(il)=4 2473 IF (cvflag_grav) THEN 2474 IF ((0.01 * grav * dpinv * amp1(il))>=delti) iflag(il) = 1 ! vecto 2475 ELSE 2476 IF ((0.1 * dpinv * amp1(il))>=delti) iflag(il) = 1 ! vecto 2477 END IF 2478 2479 IF (cvflag_grav) THEN 2480 ft(il, i) = 0.01 * grav * dpinv * (amp1(il) * (t(il, i + 1) - t(il, & 2481 i) + (gz(il, i + 1) - gz(il, i)) * cpinv) - ad(il) * (t(il, i) - t(il, & 2482 i - 1) + (gz(il, i) - gz(il, i - 1)) * cpinv)) - 0.5 * sigd * lvcp(il, i) * (evap(& 2483 il, i) + evap(il, i + 1)) 2484 rat = cpn(il, i - 1) * cpinv 2485 ft(il, i) = ft(il, i) - 0.009 * grav * sigd * (mp(il, i + 1) * t(il, i) * b(il, i) & 2486 - mp(il, i) * t(il, i - 1) * rat * b(il, i - 1)) * dpinv 2487 ft(il, i) = ft(il, i) + 0.01 * grav * dpinv * ment(il, i, i) * (hp(il, i) - h(& 2488 il, i) + t(il, i) * (cpv - cpd) * (rr(il, i) - qent(il, i, i))) * cpinv 2489 ELSE ! cvflag_grav 2490 ft(il, i) = 0.1 * dpinv * (amp1(il) * (t(il, i + 1) - t(il, & 2491 i) + (gz(il, i + 1) - gz(il, i)) * cpinv) - ad(il) * (t(il, i) - t(il, & 2492 i - 1) + (gz(il, i) - gz(il, i - 1)) * cpinv)) - 0.5 * sigd * lvcp(il, i) * (evap(& 2493 il, i) + evap(il, i + 1)) 2494 rat = cpn(il, i - 1) * cpinv 2495 ft(il, i) = ft(il, i) - 0.09 * sigd * (mp(il, i + 1) * t(il, i) * b(il, i) - mp(il & 2496 , i) * t(il, i - 1) * rat * b(il, i - 1)) * dpinv 2497 ft(il, i) = ft(il, i) + 0.1 * dpinv * ment(il, i, i) * (hp(il, i) - h(il, i) + & 2498 t(il, i) * (cpv - cpd) * (rr(il, i) - qent(il, i, i))) * cpinv 2499 END IF ! cvflag_grav 2500 2501 ft(il, i) = ft(il, i) + 0.01 * sigd * wt(il, i) * (cl - cpd) * water(il, i + 1) * (& 2502 t(il, i + 1) - t(il, i)) * dpinv * cpinv 2503 2504 IF (cvflag_grav) THEN 2505 fr(il, i) = 0.01 * grav * dpinv * (amp1(il) * (rr(il, i + 1) - rr(il, & 2506 i)) - ad(il) * (rr(il, i) - rr(il, i - 1))) 2507 fu(il, i) = fu(il, i) + 0.01 * grav * dpinv * (amp1(il) * (u(il, i + 1) - u(il, & 2508 i)) - ad(il) * (u(il, i) - u(il, i - 1))) 2509 fv(il, i) = fv(il, i) + 0.01 * grav * dpinv * (amp1(il) * (v(il, i + 1) - v(il, & 2510 i)) - ad(il) * (v(il, i) - v(il, i - 1))) 2511 ELSE ! cvflag_grav 2512 fr(il, i) = 0.1 * dpinv * (amp1(il) * (rr(il, i + 1) - rr(il, & 2513 i)) - ad(il) * (rr(il, i) - rr(il, i - 1))) 2514 fu(il, i) = fu(il, i) + 0.1 * dpinv * (amp1(il) * (u(il, i + 1) - u(il, & 2515 i)) - ad(il) * (u(il, i) - u(il, i - 1))) 2516 fv(il, i) = fv(il, i) + 0.1 * dpinv * (amp1(il) * (v(il, i + 1) - v(il, & 2517 i)) - ad(il) * (v(il, i) - v(il, i - 1))) 2518 END IF ! cvflag_grav 2519 2520 END IF ! i 2410 fr(il, 1) = fr(il, 1) + 0.01 * grav * work(il) * ment(il, j, 1) * (qent(il, & 2411 j, 1) - rr(il, 1)) 2412 fu(il, 1) = fu(il, 1) + 0.01 * grav * work(il) * ment(il, j, 1) * (uent(il, & 2413 j, 1) - u(il, 1)) 2414 fv(il, 1) = fv(il, 1) + 0.01 * grav * work(il) * ment(il, j, 1) * (vent(il, & 2415 j, 1) - v(il, 1)) 2416 ELSE ! cvflag_grav 2417 fr(il, 1) = fr(il, 1) + 0.1 * work(il) * ment(il, j, 1) * (qent(il, j, 1) - & 2418 rr(il, 1)) 2419 fu(il, 1) = fu(il, 1) + 0.1 * work(il) * ment(il, j, 1) * (uent(il, j, 1) - u & 2420 (il, 1)) 2421 fv(il, 1) = fv(il, 1) + 0.1 * work(il) * ment(il, j, 1) * (vent(il, j, 1) - v & 2422 (il, 1)) 2423 END IF ! cvflag_grav 2424 END IF ! j 2425 END DO 2521 2426 END DO 2522 2427 2523 2428 ! do k=1,ntra 2429 ! do j=2,nl 2524 2430 ! do il=1,ncum 2525 ! if (i.le.inb(il)) THEN 2526 ! dpinv=1.0/(ph(il,i)-ph(il,i+1)) 2527 ! cpinv=1.0/cpn(il,i) 2431 ! if (j.le.inb(il)) THEN 2528 2432 ! if (cvflag_grav) THEN 2529 ! ftra(il,i,k)=ftra(il,i,k)+0.01*grav*dpinv 2530 ! : *(amp1(il)*(tra(il,i+1,k)-tra(il,i,k)) 2531 ! : -ad(il)*(tra(il,i,k)-tra(il,i-1,k))) 2433 ! ftra(il,1,k)=ftra(il,1,k)+0.01*grav*work(il)*ment(il,j,1) 2434 ! : *(traent(il,j,1,k)-tra(il,1,k)) 2532 2435 ! else 2533 ! ftra(il,i,k)=ftra(il,i,k)+0.1*dpinv 2534 ! : *(amp1(il)*(tra(il,i+1,k)-tra(il,i,k)) 2535 ! : -ad(il)*(tra(il,i,k)-tra(il,i-1,k))) 2436 ! ftra(il,1,k)=ftra(il,1,k)+0.1*work(il)*ment(il,j,1) 2437 ! : *(traent(il,j,1,k)-tra(il,1,k)) 2536 2438 ! END IF 2439 2537 2440 ! END IF 2538 2441 ! enddo 2539 2442 ! enddo 2540 2541 DO k = 1, i - 1 2443 ! enddo 2444 2445 2446 ! *** calculate tendencies of potential temperature and mixing ratio *** 2447 ! *** at levels above the lowest level *** 2448 2449 ! *** first find the net saturated updraft and downdraft mass fluxes *** 2450 ! *** through each level *** 2451 2452 DO i = 2, nl + 1 ! newvecto: mettre nl au lieu nl+1? 2453 2454 num1 = 0 2455 DO il = 1, ncum 2456 IF (i<=inb(il)) num1 = num1 + 1 2457 END DO 2458 IF (num1<=0) GO TO 500 2459 2460 CALL zilch(amp1, ncum) 2461 CALL zilch(ad, ncum) 2462 2463 DO k = i + 1, nl + 1 2464 DO il = 1, ncum 2465 IF (i<=inb(il) .AND. k<=(inb(il) + 1)) THEN 2466 amp1(il) = amp1(il) + m(il, k) 2467 END IF 2468 END DO 2469 END DO 2470 2471 DO k = 1, i 2472 DO j = i + 1, nl + 1 2473 DO il = 1, ncum 2474 IF (i<=inb(il) .AND. j<=(inb(il) + 1)) THEN 2475 amp1(il) = amp1(il) + ment(il, k, j) 2476 END IF 2477 END DO 2478 END DO 2479 END DO 2480 2481 DO k = 1, i - 1 2482 DO j = i, nl + 1 ! newvecto: nl au lieu nl+1? 2483 DO il = 1, ncum 2484 IF (i<=inb(il) .AND. j<=inb(il)) THEN 2485 ad(il) = ad(il) + ment(il, j, k) 2486 END IF 2487 END DO 2488 END DO 2489 END DO 2490 2542 2491 DO il = 1, ncum 2543 2492 IF (i<=inb(il)) THEN … … 2545 2494 cpinv = 1.0 / cpn(il, i) 2546 2495 2547 awat = elij(il, k, i) - (1. - ep(il, i)) * clw(il, i) 2548 awat = amax1(awat, 0.0) 2549 2496 ! convect3 if((0.1*dpinv*amp1).ge.delti)iflag(il)=4 2550 2497 IF (cvflag_grav) THEN 2551 fr(il, i) = fr(il, i) + 0.01 * grav * dpinv * ment(il, k, i) * (qent(il, k & 2552 , i) - awat - rr(il, i)) 2553 fu(il, i) = fu(il, i) + 0.01 * grav * dpinv * ment(il, k, i) * (uent(il, k & 2554 , i) - u(il, i)) 2555 fv(il, i) = fv(il, i) + 0.01 * grav * dpinv * ment(il, k, i) * (vent(il, k & 2556 , i) - v(il, i)) 2498 IF ((0.01 * grav * dpinv * amp1(il))>=delti) iflag(il) = 1 ! vecto 2499 ELSE 2500 IF ((0.1 * dpinv * amp1(il))>=delti) iflag(il) = 1 ! vecto 2501 END IF 2502 2503 IF (cvflag_grav) THEN 2504 ft(il, i) = 0.01 * grav * dpinv * (amp1(il) * (t(il, i + 1) - t(il, & 2505 i) + (gz(il, i + 1) - gz(il, i)) * cpinv) - ad(il) * (t(il, i) - t(il, & 2506 i - 1) + (gz(il, i) - gz(il, i - 1)) * cpinv)) - 0.5 * sigd * lvcp(il, i) * (evap(& 2507 il, i) + evap(il, i + 1)) 2508 rat = cpn(il, i - 1) * cpinv 2509 ft(il, i) = ft(il, i) - 0.009 * grav * sigd * (mp(il, i + 1) * t(il, i) * b(il, i) & 2510 - mp(il, i) * t(il, i - 1) * rat * b(il, i - 1)) * dpinv 2511 ft(il, i) = ft(il, i) + 0.01 * grav * dpinv * ment(il, i, i) * (hp(il, i) - h(& 2512 il, i) + t(il, i) * (cpv - cpd) * (rr(il, i) - qent(il, i, i))) * cpinv 2557 2513 ELSE ! cvflag_grav 2558 fr(il, i) = fr(il, i) + 0.1 * dpinv * ment(il, k, i) * (qent(il, k, i) - & 2559 awat - rr(il, i)) 2560 fu(il, i) = fu(il, i) + 0.01 * grav * dpinv * ment(il, k, i) * (uent(il, k & 2561 , i) - u(il, i)) 2562 fv(il, i) = fv(il, i) + 0.1 * dpinv * ment(il, k, i) * (vent(il, k, i) - v(& 2563 il, i)) 2514 ft(il, i) = 0.1 * dpinv * (amp1(il) * (t(il, i + 1) - t(il, & 2515 i) + (gz(il, i + 1) - gz(il, i)) * cpinv) - ad(il) * (t(il, i) - t(il, & 2516 i - 1) + (gz(il, i) - gz(il, i - 1)) * cpinv)) - 0.5 * sigd * lvcp(il, i) * (evap(& 2517 il, i) + evap(il, i + 1)) 2518 rat = cpn(il, i - 1) * cpinv 2519 ft(il, i) = ft(il, i) - 0.09 * sigd * (mp(il, i + 1) * t(il, i) * b(il, i) - mp(il & 2520 , i) * t(il, i - 1) * rat * b(il, i - 1)) * dpinv 2521 ft(il, i) = ft(il, i) + 0.1 * dpinv * ment(il, i, i) * (hp(il, i) - h(il, i) + & 2522 t(il, i) * (cpv - cpd) * (rr(il, i) - qent(il, i, i))) * cpinv 2564 2523 END IF ! cvflag_grav 2565 2524 2566 ! (saturated updrafts resulting from mixing) ! cld 2567 qcond(il, i) = qcond(il, i) + (elij(il, k, i) - awat) ! cld 2568 nqcond(il, i) = nqcond(il, i) + 1. ! cld 2525 ft(il, i) = ft(il, i) + 0.01 * sigd * wt(il, i) * (cl - cpd) * water(il, i + 1) * (& 2526 t(il, i + 1) - t(il, i)) * dpinv * cpinv 2527 2528 IF (cvflag_grav) THEN 2529 fr(il, i) = 0.01 * grav * dpinv * (amp1(il) * (rr(il, i + 1) - rr(il, & 2530 i)) - ad(il) * (rr(il, i) - rr(il, i - 1))) 2531 fu(il, i) = fu(il, i) + 0.01 * grav * dpinv * (amp1(il) * (u(il, i + 1) - u(il, & 2532 i)) - ad(il) * (u(il, i) - u(il, i - 1))) 2533 fv(il, i) = fv(il, i) + 0.01 * grav * dpinv * (amp1(il) * (v(il, i + 1) - v(il, & 2534 i)) - ad(il) * (v(il, i) - v(il, i - 1))) 2535 ELSE ! cvflag_grav 2536 fr(il, i) = 0.1 * dpinv * (amp1(il) * (rr(il, i + 1) - rr(il, & 2537 i)) - ad(il) * (rr(il, i) - rr(il, i - 1))) 2538 fu(il, i) = fu(il, i) + 0.1 * dpinv * (amp1(il) * (u(il, i + 1) - u(il, & 2539 i)) - ad(il) * (u(il, i) - u(il, i - 1))) 2540 fv(il, i) = fv(il, i) + 0.1 * dpinv * (amp1(il) * (v(il, i + 1) - v(il, & 2541 i)) - ad(il) * (v(il, i) - v(il, i - 1))) 2542 END IF ! cvflag_grav 2543 2569 2544 END IF ! i 2570 2545 END DO 2571 END DO 2572 2573 ! do j=1,ntra 2574 ! do k=1,i-1 2575 ! do il=1,ncum 2576 ! if (i.le.inb(il)) THEN 2577 ! dpinv=1.0/(ph(il,i)-ph(il,i+1)) 2578 ! cpinv=1.0/cpn(il,i) 2579 ! if (cvflag_grav) THEN 2580 ! ftra(il,i,j)=ftra(il,i,j)+0.01*grav*dpinv*ment(il,k,i) 2581 ! : *(traent(il,k,i,j)-tra(il,i,j)) 2582 ! else 2583 ! ftra(il,i,j)=ftra(il,i,j)+0.1*dpinv*ment(il,k,i) 2584 ! : *(traent(il,k,i,j)-tra(il,i,j)) 2585 ! END IF 2586 ! END IF 2587 ! enddo 2588 ! enddo 2589 ! enddo 2590 2591 DO k = i, nl + 1 2546 2547 ! do k=1,ntra 2548 ! do il=1,ncum 2549 ! if (i.le.inb(il)) THEN 2550 ! dpinv=1.0/(ph(il,i)-ph(il,i+1)) 2551 ! cpinv=1.0/cpn(il,i) 2552 ! if (cvflag_grav) THEN 2553 ! ftra(il,i,k)=ftra(il,i,k)+0.01*grav*dpinv 2554 ! : *(amp1(il)*(tra(il,i+1,k)-tra(il,i,k)) 2555 ! : -ad(il)*(tra(il,i,k)-tra(il,i-1,k))) 2556 ! else 2557 ! ftra(il,i,k)=ftra(il,i,k)+0.1*dpinv 2558 ! : *(amp1(il)*(tra(il,i+1,k)-tra(il,i,k)) 2559 ! : -ad(il)*(tra(il,i,k)-tra(il,i-1,k))) 2560 ! END IF 2561 ! END IF 2562 ! enddo 2563 ! enddo 2564 2565 DO k = 1, i - 1 2566 DO il = 1, ncum 2567 IF (i<=inb(il)) THEN 2568 dpinv = 1.0 / (ph(il, i) - ph(il, i + 1)) 2569 cpinv = 1.0 / cpn(il, i) 2570 2571 awat = elij(il, k, i) - (1. - ep(il, i)) * clw(il, i) 2572 awat = amax1(awat, 0.0) 2573 2574 IF (cvflag_grav) THEN 2575 fr(il, i) = fr(il, i) + 0.01 * grav * dpinv * ment(il, k, i) * (qent(il, k & 2576 , i) - awat - rr(il, i)) 2577 fu(il, i) = fu(il, i) + 0.01 * grav * dpinv * ment(il, k, i) * (uent(il, k & 2578 , i) - u(il, i)) 2579 fv(il, i) = fv(il, i) + 0.01 * grav * dpinv * ment(il, k, i) * (vent(il, k & 2580 , i) - v(il, i)) 2581 ELSE ! cvflag_grav 2582 fr(il, i) = fr(il, i) + 0.1 * dpinv * ment(il, k, i) * (qent(il, k, i) - & 2583 awat - rr(il, i)) 2584 fu(il, i) = fu(il, i) + 0.01 * grav * dpinv * ment(il, k, i) * (uent(il, k & 2585 , i) - u(il, i)) 2586 fv(il, i) = fv(il, i) + 0.1 * dpinv * ment(il, k, i) * (vent(il, k, i) - v(& 2587 il, i)) 2588 END IF ! cvflag_grav 2589 2590 ! (saturated updrafts resulting from mixing) ! cld 2591 qcond(il, i) = qcond(il, i) + (elij(il, k, i) - awat) ! cld 2592 nqcond(il, i) = nqcond(il, i) + 1. ! cld 2593 END IF ! i 2594 END DO 2595 END DO 2596 2597 ! do j=1,ntra 2598 ! do k=1,i-1 2599 ! do il=1,ncum 2600 ! if (i.le.inb(il)) THEN 2601 ! dpinv=1.0/(ph(il,i)-ph(il,i+1)) 2602 ! cpinv=1.0/cpn(il,i) 2603 ! if (cvflag_grav) THEN 2604 ! ftra(il,i,j)=ftra(il,i,j)+0.01*grav*dpinv*ment(il,k,i) 2605 ! : *(traent(il,k,i,j)-tra(il,i,j)) 2606 ! else 2607 ! ftra(il,i,j)=ftra(il,i,j)+0.1*dpinv*ment(il,k,i) 2608 ! : *(traent(il,k,i,j)-tra(il,i,j)) 2609 ! END IF 2610 ! END IF 2611 ! enddo 2612 ! enddo 2613 ! enddo 2614 2615 DO k = i, nl + 1 2616 DO il = 1, ncum 2617 IF (i<=inb(il) .AND. k<=inb(il)) THEN 2618 dpinv = 1.0 / (ph(il, i) - ph(il, i + 1)) 2619 cpinv = 1.0 / cpn(il, i) 2620 2621 IF (cvflag_grav) THEN 2622 fr(il, i) = fr(il, i) + 0.01 * grav * dpinv * ment(il, k, i) * (qent(il, k & 2623 , i) - rr(il, i)) 2624 fu(il, i) = fu(il, i) + 0.01 * grav * dpinv * ment(il, k, i) * (uent(il, k & 2625 , i) - u(il, i)) 2626 fv(il, i) = fv(il, i) + 0.01 * grav * dpinv * ment(il, k, i) * (vent(il, k & 2627 , i) - v(il, i)) 2628 ELSE ! cvflag_grav 2629 fr(il, i) = fr(il, i) + 0.1 * dpinv * ment(il, k, i) * (qent(il, k, i) - rr & 2630 (il, i)) 2631 fu(il, i) = fu(il, i) + 0.1 * dpinv * ment(il, k, i) * (uent(il, k, i) - u(& 2632 il, i)) 2633 fv(il, i) = fv(il, i) + 0.1 * dpinv * ment(il, k, i) * (vent(il, k, i) - v(& 2634 il, i)) 2635 END IF ! cvflag_grav 2636 END IF ! i and k 2637 END DO 2638 END DO 2639 2640 ! do j=1,ntra 2641 ! do k=i,nl+1 2642 ! do il=1,ncum 2643 ! if (i.le.inb(il) .AND. k.le.inb(il)) THEN 2644 ! dpinv=1.0/(ph(il,i)-ph(il,i+1)) 2645 ! cpinv=1.0/cpn(il,i) 2646 ! if (cvflag_grav) THEN 2647 ! ftra(il,i,j)=ftra(il,i,j)+0.01*grav*dpinv*ment(il,k,i) 2648 ! : *(traent(il,k,i,j)-tra(il,i,j)) 2649 ! else 2650 ! ftra(il,i,j)=ftra(il,i,j)+0.1*dpinv*ment(il,k,i) 2651 ! : *(traent(il,k,i,j)-tra(il,i,j)) 2652 ! END IF 2653 ! END IF ! i and k 2654 ! enddo 2655 ! enddo 2656 ! enddo 2657 2592 2658 DO il = 1, ncum 2593 IF (i<=inb(il) .AND. k<=inb(il)) THEN2659 IF (i<=inb(il)) THEN 2594 2660 dpinv = 1.0 / (ph(il, i) - ph(il, i + 1)) 2595 2661 cpinv = 1.0 / cpn(il, i) 2596 2662 2597 2663 IF (cvflag_grav) THEN 2598 fr(il, i) = fr(il, i) + 0.01 * grav * dpinv * ment(il, k, i) * (qent(il, k & 2599 , i) - rr(il, i)) 2600 fu(il, i) = fu(il, i) + 0.01 * grav * dpinv * ment(il, k, i) * (uent(il, k & 2601 , i) - u(il, i)) 2602 fv(il, i) = fv(il, i) + 0.01 * grav * dpinv * ment(il, k, i) * (vent(il, k & 2603 , i) - v(il, i)) 2664 ! sb: on ne fait pas encore la correction permettant de mieux 2665 ! conserver l'eau: 2666 fr(il, i) = fr(il, i) + 0.5 * sigd * (evap(il, i) + evap(il, i + 1)) + & 2667 0.01 * grav * (mp(il, i + 1) * (rp(il, i + 1) - rr(il, i)) - mp(il, i) * (rp(il, & 2668 i) - rr(il, i - 1))) * dpinv 2669 2670 fu(il, i) = fu(il, i) + 0.01 * grav * (mp(il, i + 1) * (up(il, i + 1) - u(il, & 2671 i)) - mp(il, i) * (up(il, i) - u(il, i - 1))) * dpinv 2672 fv(il, i) = fv(il, i) + 0.01 * grav * (mp(il, i + 1) * (vp(il, i + 1) - v(il, & 2673 i)) - mp(il, i) * (vp(il, i) - v(il, i - 1))) * dpinv 2604 2674 ELSE ! cvflag_grav 2605 fr(il, i) = fr(il, i) + 0.1 * dpinv * ment(il, k, i) * (qent(il, k, i) - rr & 2606 (il, i)) 2607 fu(il, i) = fu(il, i) + 0.1 * dpinv * ment(il, k, i) * (uent(il, k, i) - u(& 2608 il, i)) 2609 fv(il, i) = fv(il, i) + 0.1 * dpinv * ment(il, k, i) * (vent(il, k, i) - v(& 2610 il, i)) 2675 fr(il, i) = fr(il, i) + 0.5 * sigd * (evap(il, i) + evap(il, i + 1)) + & 2676 0.1 * (mp(il, i + 1) * (rp(il, i + 1) - rr(il, i)) - mp(il, i) * (rp(il, i) - rr(il, & 2677 i - 1))) * dpinv 2678 fu(il, i) = fu(il, i) + 0.1 * (mp(il, i + 1) * (up(il, i + 1) - u(il, & 2679 i)) - mp(il, i) * (up(il, i) - u(il, i - 1))) * dpinv 2680 fv(il, i) = fv(il, i) + 0.1 * (mp(il, i + 1) * (vp(il, i + 1) - v(il, & 2681 i)) - mp(il, i) * (vp(il, i) - v(il, i - 1))) * dpinv 2611 2682 END IF ! cvflag_grav 2612 END IF ! i and k 2613 END DO 2614 END DO 2615 2616 ! do j=1,ntra 2617 ! do k=i,nl+1 2618 ! do il=1,ncum 2619 ! if (i.le.inb(il) .AND. k.le.inb(il)) THEN 2620 ! dpinv=1.0/(ph(il,i)-ph(il,i+1)) 2621 ! cpinv=1.0/cpn(il,i) 2622 ! if (cvflag_grav) THEN 2623 ! ftra(il,i,j)=ftra(il,i,j)+0.01*grav*dpinv*ment(il,k,i) 2624 ! : *(traent(il,k,i,j)-tra(il,i,j)) 2625 ! else 2626 ! ftra(il,i,j)=ftra(il,i,j)+0.1*dpinv*ment(il,k,i) 2627 ! : *(traent(il,k,i,j)-tra(il,i,j)) 2628 ! END IF 2629 ! END IF ! i and k 2630 ! enddo 2631 ! enddo 2632 ! enddo 2633 2634 DO il = 1, ncum 2635 IF (i<=inb(il)) THEN 2636 dpinv = 1.0 / (ph(il, i) - ph(il, i + 1)) 2637 cpinv = 1.0 / cpn(il, i) 2638 2639 IF (cvflag_grav) THEN 2640 ! sb: on ne fait pas encore la correction permettant de mieux 2641 ! conserver l'eau: 2642 fr(il, i) = fr(il, i) + 0.5 * sigd * (evap(il, i) + evap(il, i + 1)) + & 2643 0.01 * grav * (mp(il, i + 1) * (rp(il, i + 1) - rr(il, i)) - mp(il, i) * (rp(il, & 2644 i) - rr(il, i - 1))) * dpinv 2645 2646 fu(il, i) = fu(il, i) + 0.01 * grav * (mp(il, i + 1) * (up(il, i + 1) - u(il, & 2647 i)) - mp(il, i) * (up(il, i) - u(il, i - 1))) * dpinv 2648 fv(il, i) = fv(il, i) + 0.01 * grav * (mp(il, i + 1) * (vp(il, i + 1) - v(il, & 2649 i)) - mp(il, i) * (vp(il, i) - v(il, i - 1))) * dpinv 2650 ELSE ! cvflag_grav 2651 fr(il, i) = fr(il, i) + 0.5 * sigd * (evap(il, i) + evap(il, i + 1)) + & 2652 0.1 * (mp(il, i + 1) * (rp(il, i + 1) - rr(il, i)) - mp(il, i) * (rp(il, i) - rr(il, & 2653 i - 1))) * dpinv 2654 fu(il, i) = fu(il, i) + 0.1 * (mp(il, i + 1) * (up(il, i + 1) - u(il, & 2655 i)) - mp(il, i) * (up(il, i) - u(il, i - 1))) * dpinv 2656 fv(il, i) = fv(il, i) + 0.1 * (mp(il, i + 1) * (vp(il, i + 1) - v(il, & 2657 i)) - mp(il, i) * (vp(il, i) - v(il, i - 1))) * dpinv 2658 END IF ! cvflag_grav 2659 2660 END IF ! i 2661 END DO 2662 2663 ! sb: interface with the cloud parameterization: ! cld 2664 2665 DO k = i + 1, nl 2666 DO il = 1, ncum 2667 IF (k<=inb(il) .AND. i<=inb(il)) THEN ! cld 2668 ! (saturated downdrafts resulting from mixing) ! cld 2669 qcond(il, i) = qcond(il, i) + elij(il, k, i) ! cld 2683 2684 END IF ! i 2685 END DO 2686 2687 ! sb: interface with the cloud parameterization: ! cld 2688 2689 DO k = i + 1, nl 2690 DO il = 1, ncum 2691 IF (k<=inb(il) .AND. i<=inb(il)) THEN ! cld 2692 ! (saturated downdrafts resulting from mixing) ! cld 2693 qcond(il, i) = qcond(il, i) + elij(il, k, i) ! cld 2694 nqcond(il, i) = nqcond(il, i) + 1. ! cld 2695 END IF ! cld 2696 END DO ! cld 2697 END DO ! cld 2698 2699 ! (particular case: no detraining level is found) ! cld 2700 DO il = 1, ncum ! cld 2701 IF (i<=inb(il) .AND. nent(il, i)==0) THEN ! cld 2702 qcond(il, i) = qcond(il, i) + (1. - ep(il, i)) * clw(il, i) ! cld 2670 2703 nqcond(il, i) = nqcond(il, i) + 1. ! cld 2671 2704 END IF ! cld 2672 2705 END DO ! cld 2673 END DO ! cld 2674 2675 ! (particular case: no detraining level is found) ! cld 2676 DO il = 1, ncum ! cld 2677 IF (i<=inb(il) .AND. nent(il, i)==0) THEN ! cld 2678 qcond(il, i) = qcond(il, i) + (1. - ep(il, i)) * clw(il, i) ! cld 2679 nqcond(il, i) = nqcond(il, i) + 1. ! cld 2680 END IF ! cld 2681 END DO ! cld 2682 2683 DO il = 1, ncum ! cld 2684 IF (i<=inb(il) .AND. nqcond(il, i)/=0.) THEN ! cld 2685 qcond(il, i) = qcond(il, i) / nqcond(il, i) ! cld 2686 END IF ! cld 2706 2707 DO il = 1, ncum ! cld 2708 IF (i<=inb(il) .AND. nqcond(il, i)/=0.) THEN ! cld 2709 qcond(il, i) = qcond(il, i) / nqcond(il, i) ! cld 2710 END IF ! cld 2711 END DO 2712 2713 ! do j=1,ntra 2714 ! do il=1,ncum 2715 ! if (i.le.inb(il)) THEN 2716 ! dpinv=1.0/(ph(il,i)-ph(il,i+1)) 2717 ! cpinv=1.0/cpn(il,i) 2718 2719 ! if (cvflag_grav) THEN 2720 ! ftra(il,i,j)=ftra(il,i,j)+0.01*grav*dpinv 2721 ! : *(mp(il,i+1)*(trap(il,i+1,j)-tra(il,i,j)) 2722 ! : -mp(il,i)*(trap(il,i,j)-tra(il,i-1,j))) 2723 ! else 2724 ! ftra(il,i,j)=ftra(il,i,j)+0.1*dpinv 2725 ! : *(mp(il,i+1)*(trap(il,i+1,j)-tra(il,i,j)) 2726 ! : -mp(il,i)*(trap(il,i,j)-tra(il,i-1,j))) 2727 ! END IF 2728 ! END IF ! i 2729 ! enddo 2730 ! enddo 2731 2732 500 END DO 2733 2734 2735 ! *** move the detrainment at level inb down to level inb-1 *** 2736 ! *** in such a way as to preserve the vertically *** 2737 ! *** integrated enthalpy and water tendencies *** 2738 2739 DO il = 1, ncum 2740 2741 ax = 0.1 * ment(il, inb(il), inb(il)) * (hp(il, inb(il)) - h(il, inb(il)) + t(il, & 2742 inb(il)) * (cpv - cpd) * (rr(il, inb(il)) - qent(il, inb(il), & 2743 inb(il)))) / (cpn(il, inb(il)) * (ph(il, inb(il)) - ph(il, inb(il) + 1))) 2744 ft(il, inb(il)) = ft(il, inb(il)) - ax 2745 ft(il, inb(il) - 1) = ft(il, inb(il) - 1) + ax * cpn(il, inb(il)) * (ph(il, inb(il & 2746 )) - ph(il, inb(il) + 1)) / (cpn(il, inb(il) - 1) * (ph(il, inb(il) - 1) - ph(il, & 2747 inb(il)))) 2748 2749 bx = 0.1 * ment(il, inb(il), inb(il)) * (qent(il, inb(il), inb(il)) - rr(il, inb(& 2750 il))) / (ph(il, inb(il)) - ph(il, inb(il) + 1)) 2751 fr(il, inb(il)) = fr(il, inb(il)) - bx 2752 fr(il, inb(il) - 1) = fr(il, inb(il) - 1) + bx * (ph(il, inb(il)) - ph(il, inb(il) + & 2753 1)) / (ph(il, inb(il) - 1) - ph(il, inb(il))) 2754 2755 cx = 0.1 * ment(il, inb(il), inb(il)) * (uent(il, inb(il), inb(il)) - u(il, inb(il & 2756 ))) / (ph(il, inb(il)) - ph(il, inb(il) + 1)) 2757 fu(il, inb(il)) = fu(il, inb(il)) - cx 2758 fu(il, inb(il) - 1) = fu(il, inb(il) - 1) + cx * (ph(il, inb(il)) - ph(il, inb(il) + & 2759 1)) / (ph(il, inb(il) - 1) - ph(il, inb(il))) 2760 2761 dx = 0.1 * ment(il, inb(il), inb(il)) * (vent(il, inb(il), inb(il)) - v(il, inb(il & 2762 ))) / (ph(il, inb(il)) - ph(il, inb(il) + 1)) 2763 fv(il, inb(il)) = fv(il, inb(il)) - dx 2764 fv(il, inb(il) - 1) = fv(il, inb(il) - 1) + dx * (ph(il, inb(il)) - ph(il, inb(il) + & 2765 1)) / (ph(il, inb(il) - 1) - ph(il, inb(il))) 2766 2687 2767 END DO 2688 2768 2689 2769 ! do j=1,ntra 2690 2770 ! do il=1,ncum 2691 ! if (i.le.inb(il)) THEN 2692 ! dpinv=1.0/(ph(il,i)-ph(il,i+1)) 2693 ! cpinv=1.0/cpn(il,i) 2694 2695 ! if (cvflag_grav) THEN 2696 ! ftra(il,i,j)=ftra(il,i,j)+0.01*grav*dpinv 2697 ! : *(mp(il,i+1)*(trap(il,i+1,j)-tra(il,i,j)) 2698 ! : -mp(il,i)*(trap(il,i,j)-tra(il,i-1,j))) 2699 ! else 2700 ! ftra(il,i,j)=ftra(il,i,j)+0.1*dpinv 2701 ! : *(mp(il,i+1)*(trap(il,i+1,j)-tra(il,i,j)) 2702 ! : -mp(il,i)*(trap(il,i,j)-tra(il,i-1,j))) 2703 ! END IF 2704 ! END IF ! i 2771 ! ex=0.1*ment(il,inb(il),inb(il)) 2772 ! : *(traent(il,inb(il),inb(il),j)-tra(il,inb(il),j)) 2773 ! : /(ph(il,inb(il))-ph(il,inb(il)+1)) 2774 ! ftra(il,inb(il),j)=ftra(il,inb(il),j)-ex 2775 ! ftra(il,inb(il)-1,j)=ftra(il,inb(il)-1,j) 2776 ! : +ex*(ph(il,inb(il))-ph(il,inb(il)+1)) 2777 ! : /(ph(il,inb(il)-1)-ph(il,inb(il))) 2705 2778 ! enddo 2706 2779 ! enddo 2707 2780 2708 500 END DO 2709 2710 2711 ! *** move the detrainment at level inb down to level inb-1 *** 2712 ! *** in such a way as to preserve the vertically *** 2713 ! *** integrated enthalpy and water tendencies *** 2714 2715 DO il = 1, ncum 2716 2717 ax = 0.1 * ment(il, inb(il), inb(il)) * (hp(il, inb(il)) - h(il, inb(il)) + t(il, & 2718 inb(il)) * (cpv - cpd) * (rr(il, inb(il)) - qent(il, inb(il), & 2719 inb(il)))) / (cpn(il, inb(il)) * (ph(il, inb(il)) - ph(il, inb(il) + 1))) 2720 ft(il, inb(il)) = ft(il, inb(il)) - ax 2721 ft(il, inb(il) - 1) = ft(il, inb(il) - 1) + ax * cpn(il, inb(il)) * (ph(il, inb(il & 2722 )) - ph(il, inb(il) + 1)) / (cpn(il, inb(il) - 1) * (ph(il, inb(il) - 1) - ph(il, & 2723 inb(il)))) 2724 2725 bx = 0.1 * ment(il, inb(il), inb(il)) * (qent(il, inb(il), inb(il)) - rr(il, inb(& 2726 il))) / (ph(il, inb(il)) - ph(il, inb(il) + 1)) 2727 fr(il, inb(il)) = fr(il, inb(il)) - bx 2728 fr(il, inb(il) - 1) = fr(il, inb(il) - 1) + bx * (ph(il, inb(il)) - ph(il, inb(il) + & 2729 1)) / (ph(il, inb(il) - 1) - ph(il, inb(il))) 2730 2731 cx = 0.1 * ment(il, inb(il), inb(il)) * (uent(il, inb(il), inb(il)) - u(il, inb(il & 2732 ))) / (ph(il, inb(il)) - ph(il, inb(il) + 1)) 2733 fu(il, inb(il)) = fu(il, inb(il)) - cx 2734 fu(il, inb(il) - 1) = fu(il, inb(il) - 1) + cx * (ph(il, inb(il)) - ph(il, inb(il) + & 2735 1)) / (ph(il, inb(il) - 1) - ph(il, inb(il))) 2736 2737 dx = 0.1 * ment(il, inb(il), inb(il)) * (vent(il, inb(il), inb(il)) - v(il, inb(il & 2738 ))) / (ph(il, inb(il)) - ph(il, inb(il) + 1)) 2739 fv(il, inb(il)) = fv(il, inb(il)) - dx 2740 fv(il, inb(il) - 1) = fv(il, inb(il) - 1) + dx * (ph(il, inb(il)) - ph(il, inb(il) + & 2741 1)) / (ph(il, inb(il) - 1) - ph(il, inb(il))) 2742 2743 END DO 2744 2745 ! do j=1,ntra 2746 ! do il=1,ncum 2747 ! ex=0.1*ment(il,inb(il),inb(il)) 2748 ! : *(traent(il,inb(il),inb(il),j)-tra(il,inb(il),j)) 2749 ! : /(ph(il,inb(il))-ph(il,inb(il)+1)) 2750 ! ftra(il,inb(il),j)=ftra(il,inb(il),j)-ex 2751 ! ftra(il,inb(il)-1,j)=ftra(il,inb(il)-1,j) 2752 ! : +ex*(ph(il,inb(il))-ph(il,inb(il)+1)) 2753 ! : /(ph(il,inb(il)-1)-ph(il,inb(il))) 2754 ! enddo 2755 ! enddo 2756 2757 2758 ! *** homoginize tendencies below cloud base *** 2759 2760 DO il = 1, ncum 2761 asum(il) = 0.0 2762 bsum(il) = 0.0 2763 csum(il) = 0.0 2764 dsum(il) = 0.0 2765 END DO 2766 2767 DO i = 1, nl 2781 2782 ! *** homoginize tendencies below cloud base *** 2783 2768 2784 DO il = 1, ncum 2769 IF (i<=(icb(il) - 1)) THEN 2770 asum(il) = asum(il) + ft(il, i) * (ph(il, i) - ph(il, i + 1)) 2771 bsum(il) = bsum(il) + fr(il, i) * (lv(il, i) + (cl - cpd) * (t(il, i) - t(il, & 2772 1))) * (ph(il, i) - ph(il, i + 1)) 2773 csum(il) = csum(il) + (lv(il, i) + (cl - cpd) * (t(il, i) - t(il, & 2774 1))) * (ph(il, i) - ph(il, i + 1)) 2775 dsum(il) = dsum(il) + t(il, i) * (ph(il, i) - ph(il, i + 1)) / th(il, i) 2776 END IF 2777 END DO 2778 END DO 2779 2780 ! !!! do 700 i=1,icb(il)-1 2781 DO i = 1, nl 2785 asum(il) = 0.0 2786 bsum(il) = 0.0 2787 csum(il) = 0.0 2788 dsum(il) = 0.0 2789 END DO 2790 2791 DO i = 1, nl 2792 DO il = 1, ncum 2793 IF (i<=(icb(il) - 1)) THEN 2794 asum(il) = asum(il) + ft(il, i) * (ph(il, i) - ph(il, i + 1)) 2795 bsum(il) = bsum(il) + fr(il, i) * (lv(il, i) + (cl - cpd) * (t(il, i) - t(il, & 2796 1))) * (ph(il, i) - ph(il, i + 1)) 2797 csum(il) = csum(il) + (lv(il, i) + (cl - cpd) * (t(il, i) - t(il, & 2798 1))) * (ph(il, i) - ph(il, i + 1)) 2799 dsum(il) = dsum(il) + t(il, i) * (ph(il, i) - ph(il, i + 1)) / th(il, i) 2800 END IF 2801 END DO 2802 END DO 2803 2804 ! !!! do 700 i=1,icb(il)-1 2805 DO i = 1, nl 2806 DO il = 1, ncum 2807 IF (i<=(icb(il) - 1)) THEN 2808 ft(il, i) = asum(il) * t(il, i) / (th(il, i) * dsum(il)) 2809 fr(il, i) = bsum(il) / csum(il) 2810 END IF 2811 END DO 2812 END DO 2813 2814 2815 ! *** reset counter and return *** 2816 2782 2817 DO il = 1, ncum 2783 IF (i<=(icb(il) - 1)) THEN 2784 ft(il, i) = asum(il) * t(il, i) / (th(il, i) * dsum(il)) 2785 fr(il, i) = bsum(il) / csum(il) 2786 END IF 2787 END DO 2788 END DO 2789 2790 2791 ! *** reset counter and return *** 2792 2793 DO il = 1, ncum 2794 sig(il, nd) = 2.0 2795 END DO 2796 2797 DO i = 1, nd 2798 DO il = 1, ncum 2799 upwd(il, i) = 0.0 2800 dnwd(il, i) = 0.0 2801 END DO 2802 END DO 2803 2804 DO i = 1, nl 2805 DO il = 1, ncum 2806 dnwd0(il, i) = -mp(il, i) 2807 END DO 2808 END DO 2809 DO i = nl + 1, nd 2810 DO il = 1, ncum 2811 dnwd0(il, i) = 0. 2812 END DO 2813 END DO 2814 2815 DO i = 1, nl 2816 DO il = 1, ncum 2817 IF (i>=icb(il) .AND. i<=inb(il)) THEN 2818 sig(il, nd) = 2.0 2819 END DO 2820 2821 DO i = 1, nd 2822 DO il = 1, ncum 2818 2823 upwd(il, i) = 0.0 2819 2824 dnwd(il, i) = 0.0 2820 END IF 2821 END DO 2822 END DO 2823 2824 DO i = 1, nl 2825 DO k = 1, nl 2825 END DO 2826 END DO 2827 2828 DO i = 1, nl 2826 2829 DO il = 1, ncum 2827 up1(il, k, i) = 0.0 2828 dn1(il, k, i) = 0.0 2829 END DO 2830 END DO 2831 END DO 2832 2833 DO i = 1, nl 2834 DO k = i, nl 2835 DO n = 1, i - 1 2830 dnwd0(il, i) = -mp(il, i) 2831 END DO 2832 END DO 2833 DO i = nl + 1, nd 2834 DO il = 1, ncum 2835 dnwd0(il, i) = 0. 2836 END DO 2837 END DO 2838 2839 DO i = 1, nl 2840 DO il = 1, ncum 2841 IF (i>=icb(il) .AND. i<=inb(il)) THEN 2842 upwd(il, i) = 0.0 2843 dnwd(il, i) = 0.0 2844 END IF 2845 END DO 2846 END DO 2847 2848 DO i = 1, nl 2849 DO k = 1, nl 2836 2850 DO il = 1, ncum 2837 IF (i>=icb(il) .AND. i<=inb(il) .AND. k<=inb(il)) THEN 2838 up1(il, k, i) = up1(il, k, i) + ment(il, n, k) 2839 dn1(il, k, i) = dn1(il, k, i) - ment(il, k, n) 2851 up1(il, k, i) = 0.0 2852 dn1(il, k, i) = 0.0 2853 END DO 2854 END DO 2855 END DO 2856 2857 DO i = 1, nl 2858 DO k = i, nl 2859 DO n = 1, i - 1 2860 DO il = 1, ncum 2861 IF (i>=icb(il) .AND. i<=inb(il) .AND. k<=inb(il)) THEN 2862 up1(il, k, i) = up1(il, k, i) + ment(il, n, k) 2863 dn1(il, k, i) = dn1(il, k, i) - ment(il, k, n) 2864 END IF 2865 END DO 2866 END DO 2867 END DO 2868 END DO 2869 2870 DO i = 2, nl 2871 DO k = i, nl 2872 DO il = 1, ncum 2873 ! test if (i.ge.icb(il).AND.i.le.inb(il).AND.k.le.inb(il)) 2874 ! THEN 2875 IF (i<=inb(il) .AND. k<=inb(il)) THEN 2876 upwd(il, i) = upwd(il, i) + m(il, k) + up1(il, k, i) 2877 dnwd(il, i) = dnwd(il, i) + dn1(il, k, i) 2840 2878 END IF 2841 2879 END DO 2842 2880 END DO 2843 2881 END DO 2844 END DO 2845 2846 DO i = 2, nl 2847 DO k = i, nl 2882 2883 2884 ! !!! DO il=1,ncum 2885 ! !!! do i=icb(il),inb(il) 2886 ! !!! 2887 ! !!! upwd(il,i)=0.0 2888 ! !!! dnwd(il,i)=0.0 2889 ! !!! do k=i,inb(il) 2890 ! !!! up1=0.0 2891 ! !!! dn1=0.0 2892 ! !!! do n=1,i-1 2893 ! !!! up1=up1+ment(il,n,k) 2894 ! !!! dn1=dn1-ment(il,k,n) 2895 ! !!! enddo 2896 ! !!! upwd(il,i)=upwd(il,i)+m(il,k)+up1 2897 ! !!! dnwd(il,i)=dnwd(il,i)+dn1 2898 ! !!! enddo 2899 ! !!! enddo 2900 ! !!! 2901 ! !!! ENDDO 2902 2903 ! ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc 2904 ! determination de la variation de flux ascendant entre 2905 ! deux niveau non dilue mike 2906 ! ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc 2907 2908 DO i = 1, nl 2848 2909 DO il = 1, ncum 2849 ! test if (i.ge.icb(il).AND.i.le.inb(il).AND.k.le.inb(il)) 2850 ! THEN 2851 IF (i<=inb(il) .AND. k<=inb(il)) THEN 2852 upwd(il, i) = upwd(il, i) + m(il, k) + up1(il, k, i) 2853 dnwd(il, i) = dnwd(il, i) + dn1(il, k, i) 2910 mike(il, i) = m(il, i) 2911 END DO 2912 END DO 2913 2914 DO i = nl + 1, nd 2915 DO il = 1, ncum 2916 mike(il, i) = 0. 2917 END DO 2918 END DO 2919 2920 DO i = 1, nd 2921 DO il = 1, ncum 2922 ma(il, i) = 0 2923 END DO 2924 END DO 2925 2926 DO i = 1, nl 2927 DO j = i, nl 2928 DO il = 1, ncum 2929 ma(il, i) = ma(il, i) + m(il, j) 2930 END DO 2931 END DO 2932 END DO 2933 2934 DO i = nl + 1, nd 2935 DO il = 1, ncum 2936 ma(il, i) = 0. 2937 END DO 2938 END DO 2939 2940 DO i = 1, nl 2941 DO il = 1, ncum 2942 IF (i<=(icb(il) - 1)) THEN 2943 ma(il, i) = 0 2854 2944 END IF 2855 2945 END DO 2856 2946 END DO 2857 END DO 2858 2859 2860 ! !!! DO il=1,ncum 2861 ! !!! do i=icb(il),inb(il) 2862 ! !!! 2863 ! !!! upwd(il,i)=0.0 2864 ! !!! dnwd(il,i)=0.0 2865 ! !!! do k=i,inb(il) 2866 ! !!! up1=0.0 2867 ! !!! dn1=0.0 2868 ! !!! do n=1,i-1 2869 ! !!! up1=up1+ment(il,n,k) 2870 ! !!! dn1=dn1-ment(il,k,n) 2871 ! !!! enddo 2872 ! !!! upwd(il,i)=upwd(il,i)+m(il,k)+up1 2873 ! !!! dnwd(il,i)=dnwd(il,i)+dn1 2874 ! !!! enddo 2875 ! !!! enddo 2876 ! !!! 2877 ! !!! ENDDO 2878 2879 ! ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc 2880 ! determination de la variation de flux ascendant entre 2881 ! deux niveau non dilue mike 2882 ! ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc 2883 2884 DO i = 1, nl 2885 DO il = 1, ncum 2886 mike(il, i) = m(il, i) 2887 END DO 2888 END DO 2889 2890 DO i = nl + 1, nd 2891 DO il = 1, ncum 2892 mike(il, i) = 0. 2893 END DO 2894 END DO 2895 2896 DO i = 1, nd 2897 DO il = 1, ncum 2898 ma(il, i) = 0 2899 END DO 2900 END DO 2901 2902 DO i = 1, nl 2903 DO j = i, nl 2947 2948 ! cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc 2949 ! icb represente de niveau ou se trouve la 2950 ! base du nuage , et inb le top du nuage 2951 ! ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc 2952 2953 DO i = 1, nd 2904 2954 DO il = 1, ncum 2905 ma(il, i) = ma(il, i) + m(il, j) 2906 END DO 2907 END DO 2908 END DO 2909 2910 DO i = nl + 1, nd 2911 DO il = 1, ncum 2912 ma(il, i) = 0. 2913 END DO 2914 END DO 2915 2916 DO i = 1, nl 2917 DO il = 1, ncum 2918 IF (i<=(icb(il) - 1)) THEN 2919 ma(il, i) = 0 2920 END IF 2921 END DO 2922 END DO 2923 2924 ! cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc 2925 ! icb represente de niveau ou se trouve la 2926 ! base du nuage , et inb le top du nuage 2927 ! ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc 2928 2929 DO i = 1, nd 2930 DO il = 1, ncum 2931 mke(il, i) = upwd(il, i) + dnwd(il, i) 2932 END DO 2933 END DO 2934 2935 DO i = 1, nd 2936 DO il = 1, ncum 2937 rdcp = (rrd * (1. - rr(il, i)) - rr(il, i) * rrv) / (cpd * (1. - rr(il, & 2938 i)) + rr(il, i) * cpv) 2939 tls(il, i) = t(il, i) * (1000.0 / p(il, i))**rdcp 2940 tps(il, i) = tp(il, i) 2941 END DO 2942 END DO 2943 2944 2945 ! *** diagnose the in-cloud mixing ratio *** ! cld 2946 ! *** of condensed water *** ! cld 2947 ! cld 2948 2949 DO i = 1, nd ! cld 2950 DO il = 1, ncum ! cld 2951 mac(il, i) = 0.0 ! cld 2952 wa(il, i) = 0.0 ! cld 2953 siga(il, i) = 0.0 ! cld 2954 sax(il, i) = 0.0 ! cld 2955 mke(il, i) = upwd(il, i) + dnwd(il, i) 2956 END DO 2957 END DO 2958 2959 DO i = 1, nd 2960 DO il = 1, ncum 2961 rdcp = (rrd * (1. - rr(il, i)) - rr(il, i) * rrv) / (cpd * (1. - rr(il, & 2962 i)) + rr(il, i) * cpv) 2963 tls(il, i) = t(il, i) * (1000.0 / p(il, i))**rdcp 2964 tps(il, i) = tp(il, i) 2965 END DO 2966 END DO 2967 2968 2969 ! *** diagnose the in-cloud mixing ratio *** ! cld 2970 ! *** of condensed water *** ! cld 2971 ! cld 2972 2973 DO i = 1, nd ! cld 2974 DO il = 1, ncum ! cld 2975 mac(il, i) = 0.0 ! cld 2976 wa(il, i) = 0.0 ! cld 2977 siga(il, i) = 0.0 ! cld 2978 sax(il, i) = 0.0 ! cld 2979 END DO ! cld 2955 2980 END DO ! cld 2956 END DO ! cld 2957 2958 DO i = minorig, nl ! cld 2959 DO k = i + 1, nl + 1 ! cld 2981 2982 DO i = minorig, nl ! cld 2983 DO k = i + 1, nl + 1 ! cld 2984 DO il = 1, ncum ! cld 2985 IF (i<=inb(il) .AND. k<=(inb(il) + 1)) THEN ! cld 2986 mac(il, i) = mac(il, i) + m(il, k) ! cld 2987 END IF ! cld 2988 END DO ! cld 2989 END DO ! cld 2990 END DO ! cld 2991 2992 DO i = 1, nl ! cld 2993 DO j = 1, i ! cld 2994 DO il = 1, ncum ! cld 2995 IF (i>=icb(il) .AND. i<=(inb(il) - 1) & ! cld 2996 .AND. j>=icb(il)) THEN ! cld 2997 sax(il, i) = sax(il, i) + rrd * (tvp(il, j) - tv(il, j)) & ! cld 2998 * (ph(il, j) - ph(il, j + 1)) / p(il, j) ! cld 2999 END IF ! cld 3000 END DO ! cld 3001 END DO ! cld 3002 END DO ! cld 3003 3004 DO i = 1, nl ! cld 2960 3005 DO il = 1, ncum ! cld 2961 IF (i<=inb(il) .AND. k<=(inb(il) + 1)) THEN ! cld 2962 mac(il, i) = mac(il, i) + m(il, k) ! cld 3006 IF (i>=icb(il) .AND. i<=(inb(il) - 1) & ! cld 3007 .AND. sax(il, i)>0.0) THEN ! cld 3008 wa(il, i) = sqrt(2. * sax(il, i)) ! cld 2963 3009 END IF ! cld 2964 3010 END DO ! cld 2965 3011 END DO ! cld 2966 END DO ! cld 2967 2968 DO i = 1, nl ! cld 2969 DO j = 1, i ! cld 3012 3013 DO i = 1, nl ! cld 2970 3014 DO il = 1, ncum ! cld 2971 IF (i>=icb(il) .AND. i<=(inb(il) - 1) & ! cld 2972 .AND. j>=icb(il)) THEN ! cld 2973 sax(il, i) = sax(il, i) + rrd * (tvp(il, j) - tv(il, j)) & ! cld 2974 * (ph(il, j) - ph(il, j + 1)) / p(il, j) ! cld 2975 END IF ! cld 3015 IF (wa(il, i)>0.0) & ! cld 3016 siga(il, i) = mac(il, i) / wa(il, i) & ! cld 3017 * rrd * tvp(il, i) / p(il, i) / 100. / delta ! cld 3018 siga(il, i) = min(siga(il, i), 1.0) ! cld 3019 ! IM cf. FH 3020 IF (iflag_clw==0) THEN 3021 qcondc(il, i) = siga(il, i) * clw(il, i) * (1. - ep(il, i)) & ! cld 3022 + (1. - siga(il, i)) * qcond(il, i) ! cld 3023 ELSE IF (iflag_clw==1) THEN 3024 qcondc(il, i) = qcond(il, i) ! cld 3025 END IF 3026 2976 3027 END DO ! cld 2977 3028 END DO ! cld 2978 END DO ! cld 2979 2980 DO i = 1, nl ! cld 2981 DO il = 1, ncum ! cld 2982 IF (i>=icb(il) .AND. i<=(inb(il) - 1) & ! cld 2983 .AND. sax(il, i)>0.0) THEN ! cld 2984 wa(il, i) = sqrt(2. * sax(il, i)) ! cld 2985 END IF ! cld 2986 END DO ! cld 2987 END DO ! cld 2988 2989 DO i = 1, nl ! cld 2990 DO il = 1, ncum ! cld 2991 IF (wa(il, i)>0.0) & ! cld 2992 siga(il, i) = mac(il, i) / wa(il, i) & ! cld 2993 * rrd * tvp(il, i) / p(il, i) / 100. / delta ! cld 2994 siga(il, i) = min(siga(il, i), 1.0) ! cld 2995 ! IM cf. FH 2996 IF (iflag_clw==0) THEN 2997 qcondc(il, i) = siga(il, i) * clw(il, i) * (1. - ep(il, i)) & ! cld 2998 + (1. - siga(il, i)) * qcond(il, i) ! cld 2999 ELSE IF (iflag_clw==1) THEN 3000 qcondc(il, i) = qcond(il, i) ! cld 3001 END IF 3002 3003 END DO ! cld 3004 END DO ! cld 3005 3006 END SUBROUTINE cv30_yield 3007 3008 !RomP >>> 3009 SUBROUTINE cv30_tracer(nloc, len, ncum, nd, na, ment, sij, da, phi, phi2, & 3010 d1a, dam, ep, vprecip, elij, clw, epmlmmm, eplamm, icb, inb) 3011 IMPLICIT NONE 3012 3013 include "cv30param.h" 3014 3015 ! inputs: 3016 INTEGER ncum, nd, na, nloc, len 3017 REAL ment(nloc, na, na), sij(nloc, na, na) 3018 REAL clw(nloc, nd), elij(nloc, na, na) 3019 REAL ep(nloc, na) 3020 INTEGER icb(nloc), inb(nloc) 3021 REAL vprecip(nloc, nd + 1) 3022 ! ouputs: 3023 REAL da(nloc, na), phi(nloc, na, na) 3024 REAL phi2(nloc, na, na) 3025 REAL d1a(nloc, na), dam(nloc, na) 3026 REAL epmlmmm(nloc, na, na), eplamm(nloc, na) 3027 ! variables pour tracer dans precip de l'AA et des mel 3028 ! local variables: 3029 INTEGER i, j, k, nam1 3030 REAL epm(nloc, na, na) 3031 3032 nam1 = na - 1 ! Introduced because ep is not defined for j=na 3033 ! variables d'Emanuel : du second indice au troisieme 3034 ! ---> tab(i,k,j) -> de l origine k a l arrivee j 3035 ! ment, sij, elij 3036 ! variables personnelles : du troisieme au second indice 3037 ! ---> tab(i,j,k) -> de k a j 3038 ! phi, phi2 3039 3040 ! initialisations 3041 DO j = 1, na 3042 DO i = 1, ncum 3043 da(i, j) = 0. 3044 d1a(i, j) = 0. 3045 dam(i, j) = 0. 3046 eplamm(i, j) = 0. 3047 END DO 3048 END DO 3049 DO k = 1, na 3029 3030 END SUBROUTINE cv30_yield 3031 3032 !RomP >>> 3033 SUBROUTINE cv30_tracer(nloc, len, ncum, nd, na, ment, sij, da, phi, phi2, & 3034 d1a, dam, ep, vprecip, elij, clw, epmlmmm, eplamm, icb, inb) 3035 IMPLICIT NONE 3036 3037 3038 3039 ! inputs: 3040 INTEGER ncum, nd, na, nloc, len 3041 REAL ment(nloc, na, na), sij(nloc, na, na) 3042 REAL clw(nloc, nd), elij(nloc, na, na) 3043 REAL ep(nloc, na) 3044 INTEGER icb(nloc), inb(nloc) 3045 REAL vprecip(nloc, nd + 1) 3046 ! ouputs: 3047 REAL da(nloc, na), phi(nloc, na, na) 3048 REAL phi2(nloc, na, na) 3049 REAL d1a(nloc, na), dam(nloc, na) 3050 REAL epmlmmm(nloc, na, na), eplamm(nloc, na) 3051 ! variables pour tracer dans precip de l'AA et des mel 3052 ! local variables: 3053 INTEGER i, j, k, nam1 3054 REAL epm(nloc, na, na) 3055 3056 nam1 = na - 1 ! Introduced because ep is not defined for j=na 3057 ! variables d'Emanuel : du second indice au troisieme 3058 ! ---> tab(i,k,j) -> de l origine k a l arrivee j 3059 ! ment, sij, elij 3060 ! variables personnelles : du troisieme au second indice 3061 ! ---> tab(i,j,k) -> de k a j 3062 ! phi, phi2 3063 3064 ! initialisations 3050 3065 DO j = 1, na 3051 3066 DO i = 1, ncum 3052 epm(i, j, k) = 0. 3053 epmlmmm(i, j, k) = 0. 3054 phi(i, j, k) = 0. 3055 phi2(i, j, k) = 0. 3056 END DO 3057 END DO 3058 END DO 3059 3060 ! fraction deau condensee dans les melanges convertie en precip : epm 3061 ! et eau condensée précipitée dans masse d'air saturé : l_m*dM_m/dzdz.dzdz 3062 DO j = 1, nam1 3063 DO k = 1, j - 1 3067 da(i, j) = 0. 3068 d1a(i, j) = 0. 3069 dam(i, j) = 0. 3070 eplamm(i, j) = 0. 3071 END DO 3072 END DO 3073 DO k = 1, na 3074 DO j = 1, na 3075 DO i = 1, ncum 3076 epm(i, j, k) = 0. 3077 epmlmmm(i, j, k) = 0. 3078 phi(i, j, k) = 0. 3079 phi2(i, j, k) = 0. 3080 END DO 3081 END DO 3082 END DO 3083 3084 ! fraction deau condensee dans les melanges convertie en precip : epm 3085 ! et eau condensée précipitée dans masse d'air saturé : l_m*dM_m/dzdz.dzdz 3086 DO j = 1, nam1 3087 DO k = 1, j - 1 3088 DO i = 1, ncum 3089 IF (k>=icb(i) .AND. k<=inb(i) .AND. j<=inb(i)) THEN 3090 !jyg epm(i,j,k)=1.-(1.-ep(i,j))*clw(i,j)/elij(i,k,j) 3091 epm(i, j, k) = 1. - (1. - ep(i, j)) * clw(i, j) / max(elij(i, k, j), 1.E-16) 3092 ! 3093 epm(i, j, k) = max(epm(i, j, k), 0.0) 3094 END IF 3095 END DO 3096 END DO 3097 END DO 3098 3099 DO j = 1, nam1 3100 DO k = 1, nam1 3101 DO i = 1, ncum 3102 IF (k>=icb(i) .AND. k<=inb(i)) THEN 3103 eplamm(i, j) = eplamm(i, j) + ep(i, j) * clw(i, j) * ment(i, j, k) * (1. - & 3104 sij(i, j, k)) 3105 END IF 3106 END DO 3107 END DO 3108 END DO 3109 3110 DO j = 1, nam1 3111 DO k = 1, j - 1 3112 DO i = 1, ncum 3113 IF (k>=icb(i) .AND. k<=inb(i) .AND. j<=inb(i)) THEN 3114 epmlmmm(i, j, k) = epm(i, j, k) * elij(i, k, j) * ment(i, k, j) 3115 END IF 3116 END DO 3117 END DO 3118 END DO 3119 3120 ! matrices pour calculer la tendance des concentrations dans cvltr.F90 3121 DO j = 1, nam1 3122 DO k = 1, nam1 3123 DO i = 1, ncum 3124 da(i, j) = da(i, j) + (1. - sij(i, k, j)) * ment(i, k, j) 3125 phi(i, j, k) = sij(i, k, j) * ment(i, k, j) 3126 d1a(i, j) = d1a(i, j) + ment(i, k, j) * ep(i, k) * (1. - sij(i, k, j)) 3127 END DO 3128 END DO 3129 END DO 3130 3131 DO j = 1, nam1 3132 DO k = 1, j - 1 3133 DO i = 1, ncum 3134 dam(i, j) = dam(i, j) + ment(i, k, j) * epm(i, j, k) * (1. - ep(i, k)) * (1. - & 3135 sij(i, k, j)) 3136 phi2(i, j, k) = phi(i, j, k) * epm(i, j, k) 3137 END DO 3138 END DO 3139 END DO 3140 3141 END SUBROUTINE cv30_tracer 3142 ! RomP <<< 3143 3144 SUBROUTINE cv30_uncompress(nloc, len, ncum, nd, ntra, idcum, iflag, precip, & 3145 vprecip, evap, ep, sig, w0, ft, fq, fu, fv, ftra, inb, ma, upwd, dnwd, & 3146 dnwd0, qcondc, wd, cape, da, phi, mp, phi2, d1a, dam, sij, elij, clw, & 3147 epmlmmm, eplamm, wdtraina, wdtrainm, epmax_diag, iflag1, precip1, vprecip1, evap1, & 3148 ep1, sig1, w01, ft1, fq1, fu1, fv1, ftra1, inb1, ma1, upwd1, dnwd1, & 3149 dnwd01, qcondc1, wd1, cape1, da1, phi1, mp1, phi21, d1a1, dam1, sij1, & 3150 elij1, clw1, epmlmmm1, eplamm1, wdtraina1, wdtrainm1, epmax_diag1) ! epmax_cape 3151 IMPLICIT NONE 3152 3153 3154 3155 ! inputs: 3156 INTEGER len, ncum, nd, ntra, nloc 3157 INTEGER idcum(nloc) 3158 INTEGER iflag(nloc) 3159 INTEGER inb(nloc) 3160 REAL precip(nloc) 3161 REAL vprecip(nloc, nd + 1), evap(nloc, nd) 3162 REAL ep(nloc, nd) 3163 REAL sig(nloc, nd), w0(nloc, nd) 3164 REAL ft(nloc, nd), fq(nloc, nd), fu(nloc, nd), fv(nloc, nd) 3165 REAL ftra(nloc, nd, ntra) 3166 REAL ma(nloc, nd) 3167 REAL upwd(nloc, nd), dnwd(nloc, nd), dnwd0(nloc, nd) 3168 REAL qcondc(nloc, nd) 3169 REAL wd(nloc), cape(nloc) 3170 REAL da(nloc, nd), phi(nloc, nd, nd), mp(nloc, nd) 3171 REAL epmax_diag(nloc) ! epmax_cape 3172 ! RomP >>> 3173 REAL phi2(nloc, nd, nd) 3174 REAL d1a(nloc, nd), dam(nloc, nd) 3175 REAL wdtraina(nloc, nd), wdtrainm(nloc, nd) 3176 REAL sij(nloc, nd, nd) 3177 REAL elij(nloc, nd, nd), clw(nloc, nd) 3178 REAL epmlmmm(nloc, nd, nd), eplamm(nloc, nd) 3179 ! RomP <<< 3180 3181 ! outputs: 3182 INTEGER iflag1(len) 3183 INTEGER inb1(len) 3184 REAL precip1(len) 3185 REAL vprecip1(len, nd + 1), evap1(len, nd) !<<< RomP 3186 REAL ep1(len, nd) !<<< RomP 3187 REAL sig1(len, nd), w01(len, nd) 3188 REAL ft1(len, nd), fq1(len, nd), fu1(len, nd), fv1(len, nd) 3189 REAL ftra1(len, nd, ntra) 3190 REAL ma1(len, nd) 3191 REAL upwd1(len, nd), dnwd1(len, nd), dnwd01(len, nd) 3192 REAL qcondc1(nloc, nd) 3193 REAL wd1(nloc), cape1(nloc) 3194 REAL da1(nloc, nd), phi1(nloc, nd, nd), mp1(nloc, nd) 3195 REAL epmax_diag1(len) ! epmax_cape 3196 ! RomP >>> 3197 REAL phi21(len, nd, nd) 3198 REAL d1a1(len, nd), dam1(len, nd) 3199 REAL wdtraina1(len, nd), wdtrainm1(len, nd) 3200 REAL sij1(len, nd, nd) 3201 REAL elij1(len, nd, nd), clw1(len, nd) 3202 REAL epmlmmm1(len, nd, nd), eplamm1(len, nd) 3203 ! RomP <<< 3204 3205 ! local variables: 3206 INTEGER i, k, j 3207 3208 DO i = 1, ncum 3209 precip1(idcum(i)) = precip(i) 3210 iflag1(idcum(i)) = iflag(i) 3211 wd1(idcum(i)) = wd(i) 3212 inb1(idcum(i)) = inb(i) 3213 cape1(idcum(i)) = cape(i) 3214 epmax_diag1(idcum(i)) = epmax_diag(i) ! epmax_cape 3215 END DO 3216 3217 DO k = 1, nl 3064 3218 DO i = 1, ncum 3065 IF (k>=icb(i) .AND. k<=inb(i) .AND. j<=inb(i)) THEN 3066 !jyg epm(i,j,k)=1.-(1.-ep(i,j))*clw(i,j)/elij(i,k,j) 3067 epm(i, j, k) = 1. - (1. - ep(i, j)) * clw(i, j) / max(elij(i, k, j), 1.E-16) 3068 ! 3069 epm(i, j, k) = max(epm(i, j, k), 0.0) 3070 END IF 3071 END DO 3072 END DO 3073 END DO 3074 3075 DO j = 1, nam1 3076 DO k = 1, nam1 3077 DO i = 1, ncum 3078 IF (k>=icb(i) .AND. k<=inb(i)) THEN 3079 eplamm(i, j) = eplamm(i, j) + ep(i, j) * clw(i, j) * ment(i, j, k) * (1. - & 3080 sij(i, j, k)) 3081 END IF 3082 END DO 3083 END DO 3084 END DO 3085 3086 DO j = 1, nam1 3087 DO k = 1, j - 1 3088 DO i = 1, ncum 3089 IF (k>=icb(i) .AND. k<=inb(i) .AND. j<=inb(i)) THEN 3090 epmlmmm(i, j, k) = epm(i, j, k) * elij(i, k, j) * ment(i, k, j) 3091 END IF 3092 END DO 3093 END DO 3094 END DO 3095 3096 ! matrices pour calculer la tendance des concentrations dans cvltr.F90 3097 DO j = 1, nam1 3098 DO k = 1, nam1 3099 DO i = 1, ncum 3100 da(i, j) = da(i, j) + (1. - sij(i, k, j)) * ment(i, k, j) 3101 phi(i, j, k) = sij(i, k, j) * ment(i, k, j) 3102 d1a(i, j) = d1a(i, j) + ment(i, k, j) * ep(i, k) * (1. - sij(i, k, j)) 3103 END DO 3104 END DO 3105 END DO 3106 3107 DO j = 1, nam1 3108 DO k = 1, j - 1 3109 DO i = 1, ncum 3110 dam(i, j) = dam(i, j) + ment(i, k, j) * epm(i, j, k) * (1. - ep(i, k)) * (1. - & 3111 sij(i, k, j)) 3112 phi2(i, j, k) = phi(i, j, k) * epm(i, j, k) 3113 END DO 3114 END DO 3115 END DO 3116 3117 END SUBROUTINE cv30_tracer 3118 ! RomP <<< 3119 3120 SUBROUTINE cv30_uncompress(nloc, len, ncum, nd, ntra, idcum, iflag, precip, & 3121 vprecip, evap, ep, sig, w0, ft, fq, fu, fv, ftra, inb, ma, upwd, dnwd, & 3122 dnwd0, qcondc, wd, cape, da, phi, mp, phi2, d1a, dam, sij, elij, clw, & 3123 epmlmmm, eplamm, wdtraina, wdtrainm, epmax_diag, iflag1, precip1, vprecip1, evap1, & 3124 ep1, sig1, w01, ft1, fq1, fu1, fv1, ftra1, inb1, ma1, upwd1, dnwd1, & 3125 dnwd01, qcondc1, wd1, cape1, da1, phi1, mp1, phi21, d1a1, dam1, sij1, & 3126 elij1, clw1, epmlmmm1, eplamm1, wdtraina1, wdtrainm1, epmax_diag1) ! epmax_cape 3127 IMPLICIT NONE 3128 3129 include "cv30param.h" 3130 3131 ! inputs: 3132 INTEGER len, ncum, nd, ntra, nloc 3133 INTEGER idcum(nloc) 3134 INTEGER iflag(nloc) 3135 INTEGER inb(nloc) 3136 REAL precip(nloc) 3137 REAL vprecip(nloc, nd + 1), evap(nloc, nd) 3138 REAL ep(nloc, nd) 3139 REAL sig(nloc, nd), w0(nloc, nd) 3140 REAL ft(nloc, nd), fq(nloc, nd), fu(nloc, nd), fv(nloc, nd) 3141 REAL ftra(nloc, nd, ntra) 3142 REAL ma(nloc, nd) 3143 REAL upwd(nloc, nd), dnwd(nloc, nd), dnwd0(nloc, nd) 3144 REAL qcondc(nloc, nd) 3145 REAL wd(nloc), cape(nloc) 3146 REAL da(nloc, nd), phi(nloc, nd, nd), mp(nloc, nd) 3147 REAL epmax_diag(nloc) ! epmax_cape 3148 ! RomP >>> 3149 REAL phi2(nloc, nd, nd) 3150 REAL d1a(nloc, nd), dam(nloc, nd) 3151 REAL wdtraina(nloc, nd), wdtrainm(nloc, nd) 3152 REAL sij(nloc, nd, nd) 3153 REAL elij(nloc, nd, nd), clw(nloc, nd) 3154 REAL epmlmmm(nloc, nd, nd), eplamm(nloc, nd) 3155 ! RomP <<< 3156 3157 ! outputs: 3158 INTEGER iflag1(len) 3159 INTEGER inb1(len) 3160 REAL precip1(len) 3161 REAL vprecip1(len, nd + 1), evap1(len, nd) !<<< RomP 3162 REAL ep1(len, nd) !<<< RomP 3163 REAL sig1(len, nd), w01(len, nd) 3164 REAL ft1(len, nd), fq1(len, nd), fu1(len, nd), fv1(len, nd) 3165 REAL ftra1(len, nd, ntra) 3166 REAL ma1(len, nd) 3167 REAL upwd1(len, nd), dnwd1(len, nd), dnwd01(len, nd) 3168 REAL qcondc1(nloc, nd) 3169 REAL wd1(nloc), cape1(nloc) 3170 REAL da1(nloc, nd), phi1(nloc, nd, nd), mp1(nloc, nd) 3171 REAL epmax_diag1(len) ! epmax_cape 3172 ! RomP >>> 3173 REAL phi21(len, nd, nd) 3174 REAL d1a1(len, nd), dam1(len, nd) 3175 REAL wdtraina1(len, nd), wdtrainm1(len, nd) 3176 REAL sij1(len, nd, nd) 3177 REAL elij1(len, nd, nd), clw1(len, nd) 3178 REAL epmlmmm1(len, nd, nd), eplamm1(len, nd) 3179 ! RomP <<< 3180 3181 ! local variables: 3182 INTEGER i, k, j 3183 3184 DO i = 1, ncum 3185 precip1(idcum(i)) = precip(i) 3186 iflag1(idcum(i)) = iflag(i) 3187 wd1(idcum(i)) = wd(i) 3188 inb1(idcum(i)) = inb(i) 3189 cape1(idcum(i)) = cape(i) 3190 epmax_diag1(idcum(i)) = epmax_diag(i) ! epmax_cape 3191 END DO 3192 3193 DO k = 1, nl 3219 vprecip1(idcum(i), k) = vprecip(i, k) 3220 evap1(idcum(i), k) = evap(i, k) !<<< RomP 3221 sig1(idcum(i), k) = sig(i, k) 3222 w01(idcum(i), k) = w0(i, k) 3223 ft1(idcum(i), k) = ft(i, k) 3224 fq1(idcum(i), k) = fq(i, k) 3225 fu1(idcum(i), k) = fu(i, k) 3226 fv1(idcum(i), k) = fv(i, k) 3227 ma1(idcum(i), k) = ma(i, k) 3228 upwd1(idcum(i), k) = upwd(i, k) 3229 dnwd1(idcum(i), k) = dnwd(i, k) 3230 dnwd01(idcum(i), k) = dnwd0(i, k) 3231 qcondc1(idcum(i), k) = qcondc(i, k) 3232 da1(idcum(i), k) = da(i, k) 3233 mp1(idcum(i), k) = mp(i, k) 3234 ! RomP >>> 3235 ep1(idcum(i), k) = ep(i, k) 3236 d1a1(idcum(i), k) = d1a(i, k) 3237 dam1(idcum(i), k) = dam(i, k) 3238 clw1(idcum(i), k) = clw(i, k) 3239 eplamm1(idcum(i), k) = eplamm(i, k) 3240 wdtraina1(idcum(i), k) = wdtraina(i, k) 3241 wdtrainm1(idcum(i), k) = wdtrainm(i, k) 3242 ! RomP <<< 3243 END DO 3244 END DO 3245 3194 3246 DO i = 1, ncum 3195 vprecip1(idcum(i), k) = vprecip(i, k) 3196 evap1(idcum(i), k) = evap(i, k) !<<< RomP 3197 sig1(idcum(i), k) = sig(i, k) 3198 w01(idcum(i), k) = w0(i, k) 3199 ft1(idcum(i), k) = ft(i, k) 3200 fq1(idcum(i), k) = fq(i, k) 3201 fu1(idcum(i), k) = fu(i, k) 3202 fv1(idcum(i), k) = fv(i, k) 3203 ma1(idcum(i), k) = ma(i, k) 3204 upwd1(idcum(i), k) = upwd(i, k) 3205 dnwd1(idcum(i), k) = dnwd(i, k) 3206 dnwd01(idcum(i), k) = dnwd0(i, k) 3207 qcondc1(idcum(i), k) = qcondc(i, k) 3208 da1(idcum(i), k) = da(i, k) 3209 mp1(idcum(i), k) = mp(i, k) 3210 ! RomP >>> 3211 ep1(idcum(i), k) = ep(i, k) 3212 d1a1(idcum(i), k) = d1a(i, k) 3213 dam1(idcum(i), k) = dam(i, k) 3214 clw1(idcum(i), k) = clw(i, k) 3215 eplamm1(idcum(i), k) = eplamm(i, k) 3216 wdtraina1(idcum(i), k) = wdtraina(i, k) 3217 wdtrainm1(idcum(i), k) = wdtrainm(i, k) 3218 ! RomP <<< 3219 END DO 3220 END DO 3221 3222 DO i = 1, ncum 3223 sig1(idcum(i), nd) = sig(i, nd) 3224 END DO 3225 3226 3227 ! do 2100 j=1,ntra 3228 ! do 2110 k=1,nd ! oct3 3229 ! do 2120 i=1,ncum 3230 ! ftra1(idcum(i),k,j)=ftra(i,k,j) 3231 ! 2120 continue 3232 ! 2110 continue 3233 ! 2100 continue 3234 DO j = 1, nd 3235 DO k = 1, nd 3236 DO i = 1, ncum 3237 sij1(idcum(i), k, j) = sij(i, k, j) 3238 phi1(idcum(i), k, j) = phi(i, k, j) 3239 phi21(idcum(i), k, j) = phi2(i, k, j) 3240 elij1(idcum(i), k, j) = elij(i, k, j) 3241 epmlmmm1(idcum(i), k, j) = epmlmmm(i, k, j) 3242 END DO 3243 END DO 3244 END DO 3245 3246 END SUBROUTINE cv30_uncompress 3247 3248 SUBROUTINE cv30_epmax_fn_cape(nloc, ncum, nd & 3249 , cape, ep, hp, icb, inb, clw, nk, t, h, lv & 3250 , epmax_diag) 3251 USE lmdz_abort_physic, ONLY: abort_physic 3252 USE lmdz_conema3 3253 3254 IMPLICIT NONE 3255 3256 ! On fait varier epmax en fn de la cape 3257 ! Il faut donc recalculer ep, et hp qui a déjà été calculé et 3258 ! qui en dépend 3259 ! Toutes les autres variables fn de ep sont calculées plus bas. 3260 3261 INCLUDE "cvthermo.h" 3262 INCLUDE "cv30param.h" 3263 3264 ! inputs: 3265 INTEGER ncum, nd, nloc 3266 INTEGER icb(nloc), inb(nloc) 3267 REAL cape(nloc) 3268 REAL clw(nloc, nd), lv(nloc, nd), t(nloc, nd), h(nloc, nd) 3269 INTEGER nk(nloc) 3270 ! inouts: 3271 REAL ep(nloc, nd) 3272 REAL hp(nloc, nd) 3273 ! outputs ou local 3274 REAL epmax_diag(nloc) 3275 ! locals 3276 INTEGER i, k 3277 REAL hp_bak(nloc, nd) 3278 CHARACTER (LEN = 20) :: modname = 'cv30_epmax_fn_cape' 3279 CHARACTER (LEN = 80) :: abort_message 3280 3281 ! on recalcule ep et hp 3282 3283 IF (coef_epmax_cape>1e-12) THEN 3284 do i = 1, ncum 3285 epmax_diag(i) = epmax - coef_epmax_cape * sqrt(cape(i)) 3247 sig1(idcum(i), nd) = sig(i, nd) 3248 END DO 3249 3250 3251 ! do 2100 j=1,ntra 3252 ! do 2110 k=1,nd ! oct3 3253 ! do 2120 i=1,ncum 3254 ! ftra1(idcum(i),k,j)=ftra(i,k,j) 3255 ! 2120 continue 3256 ! 2110 continue 3257 ! 2100 continue 3258 DO j = 1, nd 3259 DO k = 1, nd 3260 DO i = 1, ncum 3261 sij1(idcum(i), k, j) = sij(i, k, j) 3262 phi1(idcum(i), k, j) = phi(i, k, j) 3263 phi21(idcum(i), k, j) = phi2(i, k, j) 3264 elij1(idcum(i), k, j) = elij(i, k, j) 3265 epmlmmm1(idcum(i), k, j) = epmlmmm(i, k, j) 3266 END DO 3267 END DO 3268 END DO 3269 3270 END SUBROUTINE cv30_uncompress 3271 3272 SUBROUTINE cv30_epmax_fn_cape(nloc, ncum, nd & 3273 , cape, ep, hp, icb, inb, clw, nk, t, h, lv & 3274 , epmax_diag) 3275 USE lmdz_abort_physic, ONLY: abort_physic 3276 USE lmdz_conema3 3277 USE lmdz_cvthermo 3278 3279 IMPLICIT NONE 3280 3281 ! On fait varier epmax en fn de la cape 3282 ! Il faut donc recalculer ep, et hp qui a déjà été calculé et 3283 ! qui en dépend 3284 ! Toutes les autres variables fn de ep sont calculées plus bas. 3285 3286 3287 3288 ! inputs: 3289 INTEGER ncum, nd, nloc 3290 INTEGER icb(nloc), inb(nloc) 3291 REAL cape(nloc) 3292 REAL clw(nloc, nd), lv(nloc, nd), t(nloc, nd), h(nloc, nd) 3293 INTEGER nk(nloc) 3294 ! inouts: 3295 REAL ep(nloc, nd) 3296 REAL hp(nloc, nd) 3297 ! outputs ou local 3298 REAL epmax_diag(nloc) 3299 ! locals 3300 INTEGER i, k 3301 REAL hp_bak(nloc, nd) 3302 CHARACTER (LEN = 20) :: modname = 'cv30_epmax_fn_cape' 3303 CHARACTER (LEN = 80) :: abort_message 3304 3305 ! on recalcule ep et hp 3306 3307 IF (coef_epmax_cape>1e-12) THEN 3308 do i = 1, ncum 3309 epmax_diag(i) = epmax - coef_epmax_cape * sqrt(cape(i)) 3310 do k = 1, nl 3311 ep(i, k) = ep(i, k) / epmax * epmax_diag(i) 3312 ep(i, k) = amax1(ep(i, k), 0.0) 3313 ep(i, k) = amin1(ep(i, k), epmax_diag(i)) 3314 enddo 3315 enddo 3316 3317 ! On recalcule hp: 3286 3318 do k = 1, nl 3287 ep(i, k) = ep(i, k) / epmax * epmax_diag(i)3288 ep(i, k) = amax1(ep(i, k), 0.0)3289 e p(i, k) = amin1(ep(i, k), epmax_diag(i))3319 do i = 1, ncum 3320 hp_bak(i, k) = hp(i, k) 3321 enddo 3290 3322 enddo 3291 enddo 3292 3293 ! On recalcule hp: 3294 do k = 1, nl 3323 do k = 1, nlp 3324 do i = 1, ncum 3325 hp(i, k) = h(i, k) 3326 enddo 3327 enddo 3328 do k = minorig + 1, nl 3329 do i = 1, ncum 3330 IF((k>=icb(i)).AND.(k<=inb(i)))THEN 3331 hp(i, k) = h(i, nk(i)) + (lv(i, k) + (cpd - cpv) * t(i, k)) * ep(i, k) * clw(i, k) 3332 endif 3333 enddo 3334 enddo !do k=minorig+1,n 3335 ! WRITE(*,*) 'cv30_routines 6218: hp(1,20)=',hp(1,20) 3295 3336 do i = 1, ncum 3296 hp_bak(i, k) = hp(i, k) 3297 enddo 3298 enddo 3299 do k = 1, nlp 3300 do i = 1, ncum 3301 hp(i, k) = h(i, k) 3302 enddo 3303 enddo 3304 do k = minorig + 1, nl 3305 do i = 1, ncum 3306 IF((k>=icb(i)).AND.(k<=inb(i)))THEN 3307 hp(i, k) = h(i, nk(i)) + (lv(i, k) + (cpd - cpv) * t(i, k)) * ep(i, k) * clw(i, k) 3308 endif 3309 enddo 3310 enddo !do k=minorig+1,n 3311 ! WRITE(*,*) 'cv30_routines 6218: hp(1,20)=',hp(1,20) 3312 do i = 1, ncum 3313 do k = 1, nl 3314 IF (abs(hp_bak(i, k) - hp(i, k))>0.01) THEN 3315 WRITE(*, *) 'i,k=', i, k 3316 WRITE(*, *) 'coef_epmax_cape=', coef_epmax_cape 3317 WRITE(*, *) 'epmax_diag(i)=', epmax_diag(i) 3318 WRITE(*, *) 'ep(i,k)=', ep(i, k) 3319 WRITE(*, *) 'hp(i,k)=', hp(i, k) 3320 WRITE(*, *) 'hp_bak(i,k)=', hp_bak(i, k) 3321 WRITE(*, *) 'h(i,k)=', h(i, k) 3322 WRITE(*, *) 'nk(i)=', nk(i) 3323 WRITE(*, *) 'h(i,nk(i))=', h(i, nk(i)) 3324 WRITE(*, *) 'lv(i,k)=', lv(i, k) 3325 WRITE(*, *) 't(i,k)=', t(i, k) 3326 WRITE(*, *) 'clw(i,k)=', clw(i, k) 3327 WRITE(*, *) 'cpd,cpv=', cpd, cpv 3328 CALL abort_physic(modname, abort_message, 1) 3329 endif 3330 enddo !do k=1,nl 3331 enddo !do i=1,ncum 3332 ENDIF !if (coef_epmax_cape.gt.1e-12) THEN 3333 END SUBROUTINE cv30_epmax_fn_cape 3334 3335 3337 do k = 1, nl 3338 IF (abs(hp_bak(i, k) - hp(i, k))>0.01) THEN 3339 WRITE(*, *) 'i,k=', i, k 3340 WRITE(*, *) 'coef_epmax_cape=', coef_epmax_cape 3341 WRITE(*, *) 'epmax_diag(i)=', epmax_diag(i) 3342 WRITE(*, *) 'ep(i,k)=', ep(i, k) 3343 WRITE(*, *) 'hp(i,k)=', hp(i, k) 3344 WRITE(*, *) 'hp_bak(i,k)=', hp_bak(i, k) 3345 WRITE(*, *) 'h(i,k)=', h(i, k) 3346 WRITE(*, *) 'nk(i)=', nk(i) 3347 WRITE(*, *) 'h(i,nk(i))=', h(i, nk(i)) 3348 WRITE(*, *) 'lv(i,k)=', lv(i, k) 3349 WRITE(*, *) 't(i,k)=', t(i, k) 3350 WRITE(*, *) 'clw(i,k)=', clw(i, k) 3351 WRITE(*, *) 'cpd,cpv=', cpd, cpv 3352 CALL abort_physic(modname, abort_message, 1) 3353 endif 3354 enddo !do k=1,nl 3355 enddo !do i=1,ncum 3356 ENDIF !if (coef_epmax_cape.gt.1e-12) THEN 3357 END SUBROUTINE cv30_epmax_fn_cape 3358 3359 3360 END MODULE lmdz_cv30 3361 3362 -
LMDZ6/branches/Amaury_dev/libf/phylmd/lmdz_cv3param.f90
r5140 r5141 1 !------------------------------------------------------------ 2 ! Parameters for convectL, iflag_con=3: 3 ! (includes - microphysical parameters, 4 ! - parameters that control the rate of approach 5 ! to quasi-equilibrium) 6 ! - noff & minorig (previously in input of convect1) 7 !------------------------------------------------------------ 1 ! Replaces cv3param.h 8 2 9 INTEGER flag_epKEorig 10 REAL flag_wb 11 INTEGER cv_flag_feed 12 INTEGER noff, minorig, nl, nlp, nlm 13 REAL sigdz, spfac 14 REAL pbcrit, ptcrit 15 REAL elcrit, tlcrit 16 REAL coef_peel 17 REAL omtrain 18 REAL dtovsh, dpbase, dttrig 19 REAL dtcrit, tau, beta, alpha, alpha1 20 REAL T_top_max 21 REAL tau_stop, noconv_stop 22 REAL wbmax 23 REAL delta 24 REAL betad 25 REAL ejectliq 26 REAL ejectice 3 MODULE lmdz_cv3param 4 !------------------------------------------------------------ 5 ! Parameters for convectL, iflag_con=3: 6 ! (includes - microphysical parameters, 7 ! - parameters that control the rate of approach 8 ! to quasi-equilibrium) 9 ! - noff & minorig (previously in input of convect1) 10 !------------------------------------------------------------ 11 IMPLICIT NONE; PRIVATE 12 PUBLIC sigdz, spfac, pbcrit, ptcrit, elcrit, tlcrit, coef_peel, omtrain, dtovsh, dpbase, & 13 dttrig, dtcrit, tau, beta, alpha, alpha1, T_top_max, tau_stop, noconv_stop, wbmax, & 14 delta, betad, ejectliq, ejectice, flag_wb, flag_epKEorig, cv_flag_feed, noff, minorig, & 15 nl, nlp, nlm 27 16 28 COMMON /cv3param/ sigdz, spfac & 29 ,pbcrit, ptcrit & 30 ,elcrit, tlcrit & 31 ,coef_peel & 32 ,omtrain & 33 ,dtovsh, dpbase, dttrig & 34 ,dtcrit, tau, beta, alpha, alpha1 & 35 ,T_top_max & 36 ,tau_stop, noconv_stop & 37 ,wbmax & 38 ,delta, betad & 39 ,ejectliq, ejectice & 40 ,flag_wb & 41 ,flag_epKEorig & 42 ,cv_flag_feed & 43 ,noff, minorig, nl, nlp, nlm 44 !$OMP THREADPRIVATE(/cv3param/) 17 INTEGER flag_epKEorig 18 REAL flag_wb 19 INTEGER cv_flag_feed 20 INTEGER noff, minorig, nl, nlp, nlm 21 REAL sigdz, spfac 22 REAL pbcrit, ptcrit 23 REAL elcrit, tlcrit 24 REAL coef_peel 25 REAL omtrain 26 REAL dtovsh, dpbase, dttrig 27 REAL dtcrit, tau, beta, alpha, alpha1 28 REAL T_top_max 29 REAL tau_stop, noconv_stop 30 REAL wbmax 31 REAL delta 32 REAL betad 33 REAL ejectliq 34 REAL ejectice 45 35 36 !$OMP THREADPRIVATE(sigdz, spfac, pbcrit, ptcrit, elcrit, tlcrit, coef_peel, omtrain, dtovsh, dpbase, & 37 !$OMP dttrig, dtcrit, tau, beta, alpha, alpha1, T_top_max, tau_stop, noconv_stop, wbmax, & 38 !$OMP delta, betad, ejectliq, ejectice, flag_wb, flag_epKEorig, cv_flag_feed, noff, minorig, & 39 !$OMP nl, nlp, nlm) 40 END MODULE lmdz_cv3param 41 42 43 44 -
LMDZ6/branches/Amaury_dev/libf/phylmd/lmdz_cvthermo.f90
r5140 r5141 1 ! Replaces cvthermo.h 1 2 2 ! $Header$ 3 MODULE lmdz_cvthermo 4 IMPLICIT NONE; PRIVATE 5 PUBLIC cpd, cpv, cl, ci, rrv, rrd, lv0, lf0, g, rowl, t0, clmcpv, clmcpd, cpdmcp, cpvmcpd, cpvmcl & 6 , clmci, eps, epsi, epsim1, ginv, hrd, grav 3 7 4 ! Thermodynamical constants for convectL: 8 ! Thermodynamical constants for convectL: 9 REAL cpd, cpv, cl, ci, rrv, rrd, lv0, lf0, g, rowl, t0 10 REAL clmcpv, clmcpd, cpdmcp, cpvmcpd, cpvmcl, clmci 11 REAL eps, epsi, epsim1 12 REAL ginv, hrd 13 REAL grav 5 14 6 REAL cpd, cpv, cl, ci, rrv, rrd, lv0, lf0, g, rowl, t0 7 REAL clmcpv, clmcpd, cpdmcp, cpvmcpd, cpvmcl, clmci 8 REAL eps, epsi, epsim1 9 REAL ginv, hrd 10 REAL grav 11 12 COMMON /cvthermo/ cpd, cpv, cl, ci, rrv, rrd, lv0, lf0, g, rowl & 13 ,t0, clmcpv, clmcpd, cpdmcp, cpvmcpd, cpvmcl & 14 ,clmci, eps, epsi, epsim1, ginv, hrd, grav 15 16 !$OMP THREADPRIVATE(/cvthermo/) 15 !$OMP THREADPRIVATE(cpd, cpv, cl, ci, rrv, rrd, lv0, lf0, g, rowl, t0, clmcpv, clmcpd, cpdmcp, cpvmcpd, cpvmcl & 16 !$OMP , clmci, eps, epsi, epsim1, ginv, hrd, grav) 17 END MODULE lmdz_cvthermo -
LMDZ6/branches/Amaury_dev/libf/phylmdiso/cv3_enthalpmix.F90
r5117 r5141 17 17 ! modified by : Filiberti M-A 06/2005 vectorisation * 18 18 ! ************************************************************** 19 USE lmdz_cvthermo 19 20 20 21 IMPLICIT NONE … … 29 30 ! =============================================================== 30 31 31 include "cvthermo.h"32 32 include "YOETHF.h" 33 33 include "YOMCST.h" -
LMDZ6/branches/Amaury_dev/libf/phylmdiso/cv3_estatmix.F90
r5117 r5141 18 18 ! modified by : Filiberti M-A 06/2005 vectorisation * 19 19 ! **************************************************************** 20 USE lmdz_cvthermo 20 21 21 22 IMPLICIT NONE … … 30 31 ! =============================================================== 31 32 32 include "cvthermo.h"33 33 include "YOETHF.h" 34 34 include "YOMCST.h" -
LMDZ6/branches/Amaury_dev/libf/phylmdiso/cv3_routines.F90
r5140 r5141 11 11 USE lmdz_conema3 12 12 USE lmdz_cvflag 13 USE lmdz_cv3param 13 14 14 15 IMPLICIT NONE … … 36 37 !*** APPROACH TO QUASI-EQUILIBRIUM *** 37 38 !*** IT MUST BE LESS THAN 0 *** 38 39 include "cv3param.h"40 39 41 40 INTEGER, INTENT(IN) :: nd … … 184 183 SUBROUTINE cv3_incrcount(len, nd, delt, sig) 185 184 USE lmdz_cvflag 185 USE lmdz_cv3param 186 186 187 187 IMPLICIT NONE … … 190 190 ! Increment the counter sig(nd) 191 191 ! ===================================================================== 192 193 include "cv3param.h"194 192 195 193 !inputs: … … 224 222 SUBROUTINE cv3_prelim(len, nd, ndp1, t, q, p, ph, & 225 223 lv, lf, cpn, tv, gz, h, hm, th) 224 USE lmdz_cvthermo 225 USE lmdz_cv3param 226 226 227 IMPLICIT NONE 227 228 … … 246 247 REAL tvx, tvy ! convect3 247 248 REAL cpx(len, nd) 248 249 include "cvthermo.h"250 include "cv3param.h"251 252 249 253 250 ! ori do 110 k=1,nlp … … 324 321 USE add_phys_tend_mod, ONLY: fl_cor_ebil 325 322 USE lmdz_print_control, ONLY: prt_level 323 USE lmdz_cvthermo 324 USE lmdz_cv3param 325 326 326 IMPLICIT NONE 327 327 … … 340 340 ! - A,B explicitely defined (!...) 341 341 ! ================================================================ 342 343 include "cv3param.h"344 include "cvthermo.h"345 342 346 343 !inputs: … … 699 696 #endif 700 697 #endif 698 USE lmdz_cvthermo 699 USE lmdz_cv3param 700 701 701 IMPLICIT NONE 702 702 … … 713 713 ! - if icbs=icb, compute also tp(icb+1),tvp(icb+1) & clw(icb+1) 714 714 ! ---------------------------------------------------------------- 715 716 include "cvthermo.h"717 include "cv3param.h"718 715 719 716 ! inputs: … … 1146 1143 SUBROUTINE cv3_trigger(len, nd, icb, plcl, p, th, tv, tvp, thnk, & 1147 1144 pbase, buoybase, iflag, sig, w0) 1145 USE lmdz_cv3param 1146 1148 1147 IMPLICIT NONE 1149 1148 … … 1162 1161 ! -> the buoyancy below cloud base not (yet) set to the cloud base buoyancy 1163 1162 ! ------------------------------------------------------------------- 1164 1165 include "cv3param.h"1166 1163 1167 1164 ! input: … … 1278 1275 #endif 1279 1276 #endif 1277 1278 USE lmdz_cv3param 1279 1280 1280 IMPLICIT NONE 1281 1282 include "cv3param.h"1283 1281 1284 1282 !inputs: … … 1487 1485 #endif 1488 1486 USE lmdz_cvflag 1487 USE lmdz_cvthermo 1488 USE lmdz_cv3param 1489 1489 1490 IMPLICIT NONE 1490 1491 … … 1507 1508 ! --------------------------------------------------------------------- 1508 1509 1509 include "cvthermo.h"1510 include "cv3param.h"1511 1510 include "YOMCST2.h" 1512 1511 … … 2509 2508 END SUBROUTINE cv3_undilute2 2510 2509 2511 SUBROUTINE cv3_closure(nloc, ncum, nd, icb, inb, & 2512 pbase, p, ph, tv, buoy, & 2510 SUBROUTINE cv3_closure(nloc, ncum, nd, icb, inb, pbase, p, ph, tv, buoy, & 2513 2511 sig, w0, cape, m, iflag) 2512 USE lmdz_cvthermo 2513 USE lmdz_cv3param 2514 2514 2515 IMPLICIT NONE 2515 2516 … … 2519 2520 ! vectorization: S. Bony 2520 2521 ! =================================================================== 2521 2522 include "cvthermo.h"2523 include "cv3param.h"2524 2522 2525 2523 !input: … … 2784 2782 #endif 2785 2783 USE lmdz_cvflag 2784 USE lmdz_cvthermo 2785 USE lmdz_cv3param 2786 2786 2787 IMPLICIT NONE 2787 2788 … … 2790 2791 ! - vectorisation de la partie normalisation des flux (do 789...) 2791 2792 ! --------------------------------------------------------------------- 2792 2793 include "cvthermo.h"2794 include "cv3param.h"2795 2793 2796 2794 !inputs: … … 3612 3610 #endif 3613 3611 USE lmdz_cvflag 3612 USE lmdz_cvthermo 3613 USE lmdz_cv3param 3614 3614 3615 IMPLICIT NONE 3615 3616 3617 include "cvthermo.h"3618 include "cv3param.h"3619 3616 3620 3617 !inputs: … … 4718 4715 #endif 4719 4716 USE lmdz_cvflag 4717 USE lmdz_cvthermo 4718 USE lmdz_cv3param 4719 4720 4720 IMPLICIT NONE 4721 4722 include "cvthermo.h"4723 include "cv3param.h"4724 4721 4725 4722 !inputs: … … 7274 7271 ep, Vprecip, elij, clw, epmlmMm, eplaMm, & 7275 7272 icb, inb) 7273 USE lmdz_cv3param 7274 7276 7275 IMPLICIT NONE 7277 7278 include "cv3param.h"7279 7276 7280 7277 !inputs: … … 7409 7406 #endif 7410 7407 #endif 7408 USE lmdz_cv3param 7409 7411 7410 IMPLICIT NONE 7412 7413 include "cv3param.h"7414 7411 7415 7412 !inputs: … … 7597 7594 USE lmdz_conema3 7598 7595 USE lmdz_cvflag 7596 USE lmdz_cvthermo 7597 USE lmdz_cv3param 7599 7598 7600 7599 IMPLICIT NONE … … 7605 7604 ! qui en depend 7606 7605 ! Toutes les autres variables fn de ep sont calculees plus bas. 7607 7608 include "cvthermo.h"7609 include "cv3param.h"7610 7606 7611 7607 ! inputs: -
LMDZ6/branches/Amaury_dev/libf/phylmdiso/cv3a_compress.F90
r5132 r5141 41 41 #endif 42 42 USE lmdz_abort_physic, ONLY: abort_physic 43 USE lmdz_cv3param 44 43 45 IMPLICIT NONE 44 45 include "cv3param.h"46 46 47 47 ! inputs: -
LMDZ6/branches/Amaury_dev/libf/phylmdiso/cv3a_uncompress.F90
r5117 r5141 56 56 USE infotrac_phy, ONLY: ntraciso=>ntiso 57 57 #endif 58 USE lmdz_cv3param 59 58 60 IMPLICIT NONE 59 60 include "cv3param.h"61 61 62 62 ! inputs: -
LMDZ6/branches/Amaury_dev/libf/phylmdiso/cv3p_mixing.F90
r5140 r5141 40 40 #endif 41 41 USE lmdz_cvflag 42 USE lmdz_cvthermo 43 USE lmdz_cv3param 44 42 45 IMPLICIT NONE 43 46 44 include "cvthermo.h"45 include "cv3param.h"46 47 include "YOMCST2.h" 47 48 -
LMDZ6/branches/Amaury_dev/libf/phylmdiso/cv_driver.F90
r5140 r5141 42 42 #endif 43 43 #endif 44 USE lmdz_cv30, ONLY: cv30_param, cv30_prelim, cv30_feed, cv30_undilute1, cv30_trigger, cv30_compress, cv30_undilute2, & 45 cv30_closure, cv30_epmax_fn_cape, cv30_mixing, cv30_unsat, cv30_yield, cv30_tracer, cv30_uncompress 46 44 47 IMPLICIT NONE 45 48 … … 1261 1264 ! ================================================================== 1262 1265 SUBROUTINE cv_thermo(iflag_con) 1266 USE lmdz_cvthermo 1267 1263 1268 IMPLICIT NONE 1264 1269 … … 1268 1273 1269 1274 include "YOMCST.h" 1270 include "cvthermo.h"1271 1275 1272 1276 INTEGER iflag_con -
LMDZ6/branches/Amaury_dev/libf/phylmdiso/cv_routines.F90
r5132 r5141 73 73 74 74 SUBROUTINE cv_prelim(len, nd, ndp1, t, q, p, ph, lv, cpn, tv, gz, h, hm) 75 USE lmdz_cvthermo 76 75 77 IMPLICIT NONE 76 78 … … 91 93 REAL cpx(len, nd) 92 94 93 include "cvthermo.h"94 95 include "cvparam.h" 95 96 … … 249 250 SUBROUTINE cv_undilute1(len, nd, t, q, qs, gz, p, nk, icb, icbmax, tp, tvp, & 250 251 clw) 252 USE lmdz_cvthermo 253 251 254 IMPLICIT NONE 252 255 253 include "cvthermo.h"254 256 include "cvparam.h" 255 257 … … 472 474 SUBROUTINE cv_undilute2(nloc, ncum, nd, icb, nk, tnk, qnk, gznk, t, q, qs, & 473 475 gz, p, dph, h, tv, lv, inb, inb1, tp, tvp, clw, hp, ep, sigp, frac) 476 USE lmdz_cvthermo 477 474 478 IMPLICIT NONE 475 479 … … 484 488 ! --------------------------------------------------------------------- 485 489 486 include "cvthermo.h"487 490 include "cvparam.h" 488 491 … … 752 755 SUBROUTINE cv_closure(nloc, ncum, nd, nk, icb, tv, tvp, p, ph, dph, plcl, & 753 756 cpn, iflag, cbmf) 757 USE lmdz_cvthermo 758 754 759 IMPLICIT NONE 755 760 … … 770 775 REAL work(nloc) 771 776 772 include "cvthermo.h"773 777 include "cvparam.h" 774 778 … … 834 838 h, lv, qnk, hp, tv, tvp, ep, clw, cbmf, m, ment, qent, uent, vent, nent, & 835 839 sij, elij) 840 USE lmdz_cvthermo 841 836 842 IMPLICIT NONE 837 843 838 include "cvthermo.h"839 844 include "cvparam.h" 840 845 … … 1083 1088 SUBROUTINE cv_unsat(nloc, ncum, nd, inb, t, q, qs, gz, u, v, p, ph, h, lv, & 1084 1089 ep, sigp, clw, m, ment, elij, iflag, mp, qp, up, vp, wt, water, evap) 1090 USE lmdz_cvthermo 1091 1085 1092 IMPLICIT NONE 1086 1093 1087 include "cvthermo.h"1088 1094 include "cvparam.h" 1089 1095 … … 1282 1288 ment, qent, uent, vent, nent, elij, tv, tvp, iflag, wd, qprime, tprime, & 1283 1289 precip, cbmf, ft, fq, fu, fv, ma, qcondc) 1290 USE lmdz_cvthermo 1291 1284 1292 IMPLICIT NONE 1285 1293 1286 include "cvthermo.h"1287 1294 include "cvparam.h" 1288 1295 -
LMDZ6/branches/Amaury_dev/libf/phylmdiso/lmdz_cv30.F90
r5140 r5141 1 ! $Id$ 2 3 MODULE lmdz_cv30 4 !------------------------------------------------------------ 5 ! Parameters for convectL, iflag_con=30: 6 ! (includes - microphysical parameters, 7 ! - parameters that control the rate of approach 8 ! to quasi-equilibrium) 9 ! - noff & minorig (previously in input of convect1) 10 !------------------------------------------------------------ 11 12 IMPLICIT NONE; PRIVATE 13 PUBLIC sigd, spfac, pbcrit, ptcrit, omtrain, dtovsh, dpbase, dttrig, dtcrit, & 14 tau, beta, alpha, delta, betad, noff, minorig, nl, nlp, nlm, & 15 cv30_param, cv30_prelim, cv30_feed, cv30_undilute1, cv30_trigger, & 16 cv30_compress, cv30_undilute2, cv30_closure, cv30_mixing, cv30_unsat, & 17 cv30_yield, cv30_tracer, cv30_uncompress, cv30_epmax_fn_cape 18 19 INTEGER noff, minorig, nl, nlp, nlm 20 REAL sigd, spfac 21 REAL pbcrit, ptcrit 22 REAL omtrain 23 REAL dtovsh, dpbase, dttrig 24 REAL dtcrit, tau, beta, alpha 25 REAL delta 26 REAL betad 27 28 !$OMP THREADPRIVATE(sigd, spfac, pbcrit, ptcrit, omtrain, dtovsh, dpbase, dttrig, dtcrit, & 29 !$OMP tau, beta, alpha, delta, betad, noff, minorig, nl, nlp, nlm) 30 CONTAINS 31 1 32 2 33 ! $Id$ … … 31 62 ! *** APPROACH TO QUASI-EQUILIBRIUM *** 32 63 ! *** IT MUST BE LESS THAN 0 *** 33 34 include "cv30param.h" 35 64 36 65 INTEGER nd 37 66 REAL delt ! timestep (seconds) … … 86 115 SUBROUTINE cv30_prelim(len, nd, ndp1, t, q, p, ph, lv, cpn, tv, gz, h, hm, & 87 116 th) 117 118 USE lmdz_cvthermo 88 119 IMPLICIT NONE 89 120 … … 108 139 REAL tvx, tvy ! convect3 109 140 REAL cpx(len, nd) 110 111 include "cvthermo.h"112 include "cv30param.h"113 141 114 142 … … 184 212 ! ================================================================ 185 213 186 include "cv30param.h"214 187 215 188 216 ! inputs: … … 389 417 #endif 390 418 #endif 419 USE lmdz_cvthermo 391 420 392 421 IMPLICIT NONE … … 405 434 ! ---------------------------------------------------------------- 406 435 407 include "cvthermo.h"408 include "cv30param.h"409 436 410 437 ! inputs: … … 851 878 ! ------------------------------------------------------------------- 852 879 853 include "cv30param.h"880 854 881 855 882 ! input: … … 961 988 IMPLICIT NONE 962 989 963 include "cv30param.h"990 964 991 965 992 ! inputs: … … 1154 1181 #endif 1155 1182 #endif 1183 USE lmdz_cvthermo 1156 1184 IMPLICIT NONE 1157 1185 … … 1173 1201 ! - no inb1, ONLY inb in output 1174 1202 ! --------------------------------------------------------------------- 1175 1176 include "cvthermo.h"1177 include "cv30param.h"1178 1203 1179 1204 ! inputs: … … 1618 1643 SUBROUTINE cv30_closure(nloc, ncum, nd, icb, inb, pbase, p, ph, tv, buoy, & 1619 1644 sig, w0, cape, m) 1645 USE lmdz_cvthermo 1646 1620 1647 IMPLICIT NONE 1621 1648 … … 1625 1652 ! vectorization: S. Bony 1626 1653 ! =================================================================== 1627 1628 include "cvthermo.h"1629 include "cv30param.h"1630 1654 1631 1655 ! input: … … 1854 1878 #endif 1855 1879 #endif 1880 USE lmdz_cvthermo 1881 1856 1882 IMPLICIT NONE 1857 1883 … … 1861 1887 ! - vectorisation de la partie normalisation des flux (do 789...) 1862 1888 ! --------------------------------------------------------------------- 1863 1864 include "cvthermo.h"1865 include "cv30param.h"1866 1889 1867 1890 ! inputs: … … 2670 2693 #endif 2671 2694 USE lmdz_cvflag 2695 USE lmdz_cvthermo 2672 2696 2673 2697 IMPLICIT NONE 2674 2675 2676 include "cvthermo.h"2677 include "cv30param.h"2678 2698 2679 2699 ! inputs: … … 3402 3422 #endif 3403 3423 USE lmdz_cvflag 3424 USE lmdz_cvthermo 3404 3425 3405 3426 IMPLICIT NONE 3406 3407 include "cvthermo.h"3408 include "cv30param.h"3409 3410 3427 ! inputs: 3411 3428 INTEGER ncum, nd, na, ntra, nloc … … 5972 5989 IMPLICIT NONE 5973 5990 5974 include "cv30param.h"5991 5975 5992 5976 5993 ! inputs: … … 6114 6131 IMPLICIT NONE 6115 6132 6116 include "cv30param.h"6133 6117 6134 6118 6135 ! inputs: … … 6338 6355 USE lmdz_abort_physic, ONLY: abort_physic 6339 6356 USE lmdz_conema3 6357 USE lmdz_cvthermo 6340 6358 6341 6359 IMPLICIT NONE … … 6345 6363 ! qui en depend 6346 6364 ! Toutes les autres variables fn de ep sont calculees plus bas. 6347 6348 include "cvthermo.h"6349 include "cv30param.h"6350 6365 6351 6366 ! inputs: … … 6421 6436 6422 6437 6438 6439 6440 6441 6442 END MODULE lmdz_cv30 6443 6444 -
LMDZ6/branches/Amaury_dev/libf/phylmdiso/lmdz_cv3param.f90
r5140 r5141 1 link ../phylmd/ cv3param.h1 link ../phylmd/lmdz_cv3param.f90 -
LMDZ6/branches/Amaury_dev/libf/phylmdiso/lmdz_cvthermo.f90
r5140 r5141 1 link ../phylmd/ cvthermo.h1 link ../phylmd/lmdz_cvthermo.f90 -
LMDZ6/branches/Amaury_dev/libf/phylmdiso/lmdz_wake.F90
r5117 r5141 41 41 #endif 42 42 #endif 43 USE lmdz_cvthermo 44 43 45 IMPLICIT NONE 44 46 ! ============================================================================ … … 136 138 137 139 include "YOMCST.h" 138 include "cvthermo.h"139 140 140 141 ! Arguments en entree
Note: See TracChangeset
for help on using the changeset viewer.