PHYEX 0.9.5
PHYsique EXternalisée
Loading...
Searching...
No Matches
ice4_stepping.F90
Go to the documentation of this file.
1!MNH_LIC Copyright 1995-2025 CNRS, Meteo-France and Universite Paul Sabatier
2!MNH_LIC This is part of the Meso-NH software governed by the CeCILL-C licence
3!MNH_LIC version 1. See LICENSE, CeCILL-C_V1-en.txt and CeCILL-C_V1-fr.txt
4!MNH_LIC for details. version 1.
5!-----------------------------------------------------------------
6SUBROUTINE ice4_stepping(D, CST, PARAMI, ICEP, ICED, BUCONF, PTSTEP, &
7 &KRR, OSAVE_MICRO, LDMICRO, OELEC, &
8 &PEXN, PRHODREF, PPABST, PCIT, PCLDFR, &
9 &PHLC_HCF, PHLC_HRC, PHLI_HCF, PHLI_HRI, &
10 &PTHS, PRS, PRREVAV, PRAINFR, PSIGS, PTHT, PRT, &
11 &PICLDFR, PZZZ, PCONC3D, PSSIO, PSSIU, PIFR, &
12 &PBUDGETS, PLATHAM_IAGGS, PRCRIAUTI, PRCRIAUTC, PICENU)
13
14!$ACDC singlecolumn --nocreate-interface
15
16! ######################################################################
17!
18!!**** * - compute the explicit microphysical sources
19!!
20!! PURPOSE
21!! -------
22!! The purpose of this routine is to pack arrays to compute
23!! the microphysics tendencies
24!!
25!!
26!! METHOD
27!! ------
28!! Pack arrays by chuncks
29!!
30!!
31!! MODIFICATIONS
32!! -------------
33!! R. El Khatib 03-May-2023 Replace OMP SIMD loops by explicit loops : more portable and even slightly faster
34!! S. Riette Sept 23: 3D arrays suppressed from ice4_tendencies
35! -----------------------------------------------------------------
36!
37!* 0. DECLARATIONS
38! ------------
39!
40USE yomhook , ONLY : lhook, dr_hook, jphook
41
44USE modd_cst, ONLY: cst_t
48USE modd_fields_address, ONLY : & ! common fields adress
49 & irv, & ! Water vapor
50 & irc, & ! Cloud water
51 & irr, & ! Rain water
52 & iri, & ! Pristine ice
53 & ibunum, & ! Number of tendency terms
54 & ibunum_mr, & ! Number of tendency terms expressed as mixing ratio changes
55 & ibunum_extra, & ! Number of extra tendency terms
56 & irrevav, & ! Index for the evaporation tendency
58! Index indirection
59!
61!
62IMPLICIT NONE
63!
64!* 0.1 Declarations of dummy arguments :
65!
66!
67!
68TYPE(dimphyex_t), INTENT(IN) :: D
69TYPE(cst_t), INTENT(IN) :: CST
70TYPE(param_ice_t), INTENT(IN) :: PARAMI
71TYPE(rain_ice_param_t), INTENT(IN) :: ICEP
72TYPE(rain_ice_descr_t), INTENT(IN) :: ICED
73TYPE(tbudgetconf_t), INTENT(IN) :: BUCONF
74REAL, INTENT(IN) :: PTSTEP ! Double Time step (single if cold start)
75INTEGER, INTENT(IN) :: KRR ! Number of moist variable
76LOGICAL, INTENT(IN) :: OSAVE_MICRO ! if true, save the microphysical tendencies
77LOGICAL, DIMENSION(D%NIJT), INTENT(IN) :: LDMICRO
78LOGICAL, INTENT(IN) :: OELEC ! if true, cloud electricity is activated
79!
80REAL, DIMENSION(D%NIJT), INTENT(IN) :: PEXN ! Exner function
81REAL, DIMENSION(D%NIJT), INTENT(IN) :: PRHODREF! Reference density
82REAL, DIMENSION(D%NIJT), INTENT(IN) :: PPABST
83
84REAL, DIMENSION(D%NIJT), INTENT(INOUT) :: PCIT
85
86REAL, DIMENSION(D%NIJT), INTENT(IN) :: PCLDFR ! Cloud fraction
87REAL, DIMENSION(D%NIJT), INTENT(IN) :: PICLDFR ! Ice cloud fraction
88REAL, DIMENSION(D%NIJT), INTENT(IN) :: PZZZ ! Model level height
89REAL, DIMENSION(D%NIJT), INTENT(IN) :: PCONC3D ! Cloud croplet number concentration
90REAL, DIMENSION(D%NIJT), INTENT(IN) :: PSSIO ! Super-sat. with respect to ice in the supersat fraction
91REAL, DIMENSION(D%NIJT), INTENT(IN) :: PSSIU ! Sub-sat. with respect to ice in the subsaturated fraction
92REAL, DIMENSION(D%NIJT), INTENT(IN) :: PIFR ! Ratio cloud ice moist part to dry part
93! SPP microphysics perturbation arrays
94REAL, DIMENSION(D%NIJT), OPTIONAL, INTENT(IN) :: PRCRIAUTI
95REAL, DIMENSION(D%NIJT), OPTIONAL, INTENT(IN) :: PRCRIAUTC
96REAL, DIMENSION(D%NIJT), OPTIONAL, INTENT(IN) :: PICENU
97REAL, DIMENSION(MERGE(D%NIJT,0,PARAMI%CSUBG_AUCV_RC=='ADJU' .OR. PARAMI%CSUBG_AUCV_RI=='ADJU')), INTENT(INOUT) :: PHLC_HRC, &
98 & PHLC_HCF, &
99 & PHLI_HRI, &
100 & PHLI_HCF
101REAL, DIMENSION(MERGE(D%NIJT,0,PARAMI%LEXT_TEND)), INTENT(IN) :: PTHS !To use external tendencies inside the splitting
102REAL, DIMENSION(MERGE(D%NIJT,0,PARAMI%LEXT_TEND),7), INTENT(IN) :: PRS !To use external tendencies inside the splitting
103REAL, DIMENSION(D%NIJT), INTENT(OUT) :: PRREVAV
104REAL, DIMENSION(D%NIJT), INTENT(INOUT) :: PRAINFR
105REAL, DIMENSION(MERGE(D%NIJT,0,PARAMI%CSUBG_AUCV_RC=='PDF ' .AND. PARAMI%CSUBG_PR_PDF=='SIGM')), INTENT(IN) :: PSIGS
106REAL, DIMENSION(D%NIJT), INTENT(INOUT) :: PTHT
107REAL, DIMENSION(D%NIJT,7), INTENT(INOUT) :: PRT !Packed variables
108REAL, DIMENSION(MERGE(D%NIJT,0,BUCONF%LBU_ENABLE .OR. OSAVE_MICRO), & MERGE(IBUNUM-IBUNUM_EXTRA,0,BUCONF%LBU_ENABLE .OR. OSAVE_MICRO)),INTENT(OUT) :: PBUDGETS
109REAL, DIMENSION(MERGE(D%NIJT,0,OELEC)), INTENT(IN) :: PLATHAM_IAGGS ! E Function to simulate
110 ! enhancement of IAGGS
111!
112!
113!* 0.2 Declarations of local variables :
114!
115REAL(KIND=jphook) :: zhook_handle
116!
117LOGICAL :: LSOFT ! Must we really compute tendencies or only adjust them to new T variables
118INTEGER :: INB_ITER_MAX ! Maximum number of iterations (with real tendencies computation)
119REAL :: ZTSTEP ! length of sub-timestep in case of time splitting
120REAL :: ZINV_TSTEP ! Inverse ov PTSTEP
121REAL :: ZTIME_THRESHOLD ! Time to reach threshold
122!
123INTEGER :: JIJ, JV, JJV, IIJB, IIJE
124REAL, DIMENSION(D%NIJT) :: &
125 & ZTIME, & ! Current integration time (starts with 0 and ends with PTSTEP)
126 & ZMAXTIME, & ! Time on which we can apply the current tendencies
127 & ZTIME_LASTCALL, & ! Integration time when last tendecies call has been done
128 & ZSSI, &
129 & ZZT, & ! Temperature
130 & ZLSFACT, & ! L_s/(Pi*C_ph)
131 & ZLVFACT, & ! L_v/(Pi*C_ph)
132 & ZHLC_LCF, & ! HLCLOUDS : fraction of Low Cloud Fraction in grid
133 ! note that PCLDFR = PHLC_HCF + ZHLC_LCF
134 & zhlc_lrc, & ! HLCLOUDS : LWC that is Low LWC in grid
135 ! note that ZRC = PHLC_HRC + ZHLC_LRC
136 & zhli_lcf, &
137 & zhli_lri, &
138 & zsigma_rc, &
139 & zextth
140REAL, DIMENSION(D%NIJT) :: ZRCRIAUTI, ZRCRIAUTC, ZICENU ! SPP perturbations
141REAL, DIMENSION(D%NIJT,7) :: ZEXTPK
142LOGICAL, DIMENSION(D%NIJT) :: LLCOMPUTE ! .TRUE. or points where we must compute tendencies,
143REAL, DIMENSION(SIZE(ICED%XRTMIN)) :: ZRSMIN
144!
145!Output packed tendencies (for budgets only)
146REAL, DIMENSION(D%NIJT, IBUNUM) :: ZBU_INST
147!
148!For mixing-ratio-splitting
149LOGICAL :: LLCPZ0RT
150REAL :: ZTIME_THRESHOLD1D(D%NIJT) ! Time to reach threshold
151REAL, DIMENSION(D%NIJT, KRR) :: Z0RT ! Mixing-ratios at the beginig of the current loop
152!
153REAL, DIMENSION(D%NIJT,KRR) :: ZA, ZB
154REAL, DIMENSION(D%NIJT) :: ZATH, ZBTH
155!
156REAL, DIMENSION(D%NIJT, 8) :: ZRS_TEND, ZRG_TEND
157REAL, DIMENSION(D%NIJT,10) :: ZRH_TEND
158
159INTEGER, DIMENSION(D%NIJT) :: IITER ! Number of iterations done (with real tendencies computation)
160!
161REAL, DIMENSION(D%NIJT) :: ZSUM2, ZMAXB
162REAL :: ZDEVIDE, ZX
163!
164LOGICAL :: LL_ANY_ITER
165!
166!-------------------------------------------------------------------------------
167IF (lhook) CALL dr_hook('ICE4_STEPPING', 0, zhook_handle)
168!
169#ifdef MNH_COMPILER_CCE
170!$mnh_undef(LOOP)
171#endif
172!
173!* 1. GENERALITIES
174! ------------
175!
176zinv_tstep=1./ptstep
177zrsmin = iced%XRTMIN
178iijb=d%NIJB
179iije=d%NIJE
180!
181!SPP perturbations (default values if absent)
182IF (PRESENT(prcriauti)) THEN
183!$acc kernels
184 !$mnh_expand_array(JIJ=IIJB:IIJE)
185 zrcriauti(iijb:iije) = prcriauti(iijb:iije)
186 !$mnh_end_expand_array(JIJ=IIJB:IIJE)
187!$acc end kernels
188ELSE
189!$acc kernels
190 zrcriauti(iijb:iije) = icep%XCRIAUTI
191!$acc end kernels
192ENDIF
193IF (PRESENT(prcriautc)) THEN
194!$acc kernels
195 !$mnh_expand_array(JIJ=IIJB:IIJE)
196 zrcriautc(iijb:iije) = prcriautc(iijb:iije)
197 !$mnh_end_expand_array(JIJ=IIJB:IIJE)
198!$acc end kernels
199ELSE
200!$acc kernels
201 zrcriautc(iijb:iije) = icep%XCRIAUTC
202!$acc end kernels
203ENDIF
204IF (PRESENT(picenu)) THEN
205!$acc kernels
206 !$mnh_expand_array(JIJ=IIJB:IIJE)
207 zicenu(iijb:iije) = picenu(iijb:iije)
208 !$mnh_end_expand_array(JIJ=IIJB:IIJE)
209!$acc end kernels
210ELSE
211!$acc kernels
212 zicenu(iijb:iije) = 1.
213!$acc end kernels
214ENDIF
215!
216IF(buconf%LBU_ENABLE .OR. osave_micro) THEN
217 DO jv=1, ibunum-ibunum_extra
218 pbudgets(:, jv)=0.
219 ENDDO
220ENDIF
221
222!Maximum number of iterations
223!We only count real iterations (those for which we *compute* tendencies)
224inb_iter_max=parami%NMAXITER_MICRO
225IF(parami%XTSTEP_TS/=0.)THEN
226 inb_iter_max=max(1, int(ptstep/parami%XTSTEP_TS)) !At least the number of iterations needed for the time-splitting
227 ztstep=ptstep/inb_iter_max
228 inb_iter_max=max(parami%NMAXITER_MICRO, inb_iter_max) !For the case XMRSTEP/=0. at the same time
229ENDIF
230
231IF (parami%LEXT_TEND) THEN
232!$acc kernels
233 DO jij=d%NIJB, d%NIJE
234 zextth(jij)=pths(jij)-ptht(jij)*zinv_tstep
235 ENDDO
236!$acc end kernels
237!$acc kernels
238!$acc loop independent collapse(2)
239 DO jv=1, krr
240 DO jij=d%NIJB, d%NIJE
241 zextpk(jij, jv)=prs(jij, jv)-prt(jij, jv)*zinv_tstep
242 ENDDO
243 ENDDO
244!$acc end kernels
245ENDIF
246IF (parami%CSUBG_AUCV_RC=='PDF ' .AND. parami%CSUBG_PR_PDF=='SIGM') THEN
247!$acc kernels
248!$acc loop independent
249 DO jij=d%NIJB, d%NIJE
250 zsigma_rc(jij)=psigs(jij)*2.
251 ENDDO
252!$acc end kernels
253ENDIF
254IF (parami%CSUBG_AUCV_RC=='ADJU' .OR. parami%CSUBG_AUCV_RI=='ADJU') THEN
255!$acc kernels
256!$acc loop independent
257 DO jij=d%NIJB, d%NIJE
258 zhlc_lrc(jij) = prt(jij, irc) - phlc_hrc(jij)
259 zhli_lri(jij) = prt(jij, iri) - phli_hri(jij)
260 IF(prt(jij, irc)>0.) THEN
261 zhlc_lcf(jij) = pcldfr(jij)- phlc_hcf(jij)
262 ELSE
263 zhlc_lcf(jij)=0.
264 ENDIF
265 IF(prt(jij, iri)>0.) THEN
266 zhli_lcf(jij) = pcldfr(jij)- phli_hcf(jij)
267 ELSE
268 zhli_lcf(jij)=0.
269 ENDIF
270 ENDDO
271!$acc end kernels
272ENDIF
273
274!-------------------------------------------------------------------------------
275!
276!*** 4.4 temporal loop
277!
278!
279!$acc kernels
280iiter(d%NIJB:d%NIJE )=0
281!$acc loop independent
282DO jij=d%NIJB, d%NIJE
283 IF(ldmicro(jij)) THEN
284 ztime(jij)=0. ! Current integration time (all points may have a different integration time)
285 ELSE
286 ztime(jij)=ptstep ! Nothing to do on this point, it has already reached the end of the timestep
287 ENDIF
288ENDDO
289!$acc end kernels
290
291DO WHILE(any(ztime(d%NIJB:d%NIJE )<ptstep)) ! Loop to *really* compute tendencies
292
293 IF(parami%XTSTEP_TS/=0.) THEN
294 ! In this case we need to remember the time when tendencies were computed
295 ! because when time has evolved more than a limit, we must re-compute tendencies
296 ztime_lastcall(d%NIJB:d%NIJE )=ztime(d%NIJB:d%NIJE )
297 ENDIF
298!$acc kernels
299!$acc loop independent
300 DO jij=d%NIJB, d%NIJE
301 IF (ztime(jij) < ptstep) THEN
302 llcompute(jij)=.true. ! Computation (.TRUE.) only for points for which integration time has not reached the timestep
303 iiter(jij)=iiter(jij)+1
304 ELSE
305 llcompute(jij)=.false.
306 ENDIF
307 ENDDO
308!$acc end kernels
309 ll_any_iter=any(iiter(d%NIJB:d%NIJE ) < inb_iter_max)
310 llcpz0rt=.true.
311 lsoft=.false. ! We *really* compute the tendencies
312
313 DO WHILE(any(llcompute(d%NIJB:d%NIJE ))) ! Loop to adjust tendencies when we cross the 0°C or when a species disappears
314!$acc kernels
315 zsum2(d%NIJB:d%NIJE )=prt(d%NIJB:d%NIJE , iri)
316!$acc loop independent collapse(2)
317 DO jv=iri+1,krr
318 DO jij=d%NIJB, d%NIJE
319 zsum2(jij)=zsum2(jij)+prt(jij, jv)
320 ENDDO
321 ENDDO
322!$acc end kernels
323!$acc kernels
324!$acc loop independent
325 DO jij=d%NIJB, d%NIJE
326 zdevide=(cst%XCPD + cst%XCPV*prt(jij, irv) + cst%XCL*(prt(jij, irc)+prt(jij, irr)) + cst%XCI*zsum2(jij)) * pexn(jij)
327 zzt(jij) = ptht(jij) * pexn(jij)
328 zlsfact(jij)=(cst%XLSTT+(cst%XCPV-cst%XCI)*(zzt(jij)-cst%XTT)) / zdevide
329 zlvfact(jij)=(cst%XLVTT+(cst%XCPV-cst%XCL)*(zzt(jij)-cst%XTT)) / zdevide
330 ENDDO
331!$acc end kernels
332 !-------------------------------------------------------------------------------
333 !
334 !*** 4.5 Effective tendencies computation
335 !
336 !
337 ! Tendencies are *really* computed when LSOFT==.FALSE. and only adjusted otherwise
338 CALL ice4_tendencies(cst, parami, icep, iced, buconf, &
339 &d, &
340 &krr, lsoft, llcompute, &
341 &osave_micro, oelec, &
342 &pexn, prhodref, zlvfact, zlsfact, &
343 &ppabst, pcldfr, zsigma_rc, &
344 &pcit, &
345 &zzt, picldfr, pzzz, pconc3d, &
346 &pssio, pssiu, pifr, ptht, prt, &
347 &platham_iaggs, &
348 &zbu_inst, &
349 &zrs_tend, zrg_tend, zrh_tend, zssi, &
350 &za, zb, zath, zbth, &
351 &phlc_hcf, zhlc_lcf, phlc_hrc, zhlc_lrc, &
352 &phli_hcf, zhli_lcf, phli_hri, zhli_lri, prainfr, &
353 &zrcriauti, zrcriautc, zicenu)
354
355 ! External tendencies
356 IF(parami%LEXT_TEND) THEN
357!$acc kernels
358 DO jij=d%NIJB, d%NIJE
359 zath(jij) = zath(jij) + zextth(jij)
360 ENDDO
361!$acc end kernels
362!$acc kernels
363!$acc loop independent
364 DO jv=1, krr
365 DO jij=d%NIJB, d%NIJE
366 za(jij, jv) = za(jij, jv) + zextpk(jij, jv)
367 ENDDO
368 ENDDO
369!$acc end kernels
370 ENDIF
371 !-------------------------------------------------------------------------------
372 !
373 !*** 4.6 Time integration
374 !
375 !
376 ! If we can, we shall use these tendencies until the end of the timestep
377!$acc kernels
378!$acc loop independent
379 DO jij=d%NIJB, d%NIJE
380 IF(llcompute(jij)) THEN
381 zmaxtime(jij)=(ptstep-ztime(jij)) ! Remaining time until the end of the timestep
382 ELSE
383 zmaxtime(jij)=0.
384 ENDIF
385 ENDDO
386!$acc end kernels
387 !We need to adjust tendencies when temperature reaches 0
388 IF(parami%LFEEDBACKT) THEN
389!$acc kernels
390 !$mnh_do_concurrent( JIJ=D%NIJB:D%NIJE )
391 DO jij=d%NIJB, d%NIJE
392 !Is ZB(:, ITH) enough to change temperature sign?
393 zx=cst%XTT/pexn(jij)
394 IF ((ptht(jij) - zx) * (ptht(jij) + zbth(jij) - zx) < 0.) THEN
395 zmaxtime(jij)=0.
396 ENDIF
397 !Can ZATH(:) make temperature change of sign?
398 IF (abs(zath(jij)) > 1.e-20 ) THEN
399 ztime_threshold=(zx - zbth(jij) - ptht(jij))/zath(jij)
400 IF (ztime_threshold > 0.) THEN
401 zmaxtime(jij)=min(zmaxtime(jij), ztime_threshold)
402 ENDIF
403 ENDIF
404 ENDDO
405 !$mnh_end_do()
406!$acc end kernels
407 ENDIF
408
409 !We need to adjust tendencies when a species disappears
410 !When a species is missing, only the external tendencies can be negative (and we must keep track of it)
411!$acc kernels
412 DO jv=1, krr
413!$acc loop independent
414 DO jij=d%NIJB, d%NIJE
415 IF (za(jij, jv) < -1.e-20 .AND. prt(jij, jv) > zrsmin(jv)) THEN
416 zmaxtime(jij)=min(zmaxtime(jij), -(zb(jij, jv)+prt(jij, jv))/za(jij, jv))
417 zmaxtime(jij)=max(zmaxtime(jij), cst%XMNH_TINY) !to prevent rounding errors
418 ENDIF
419 ENDDO
420 ENDDO
421!$acc end kernels
422 !We stop when the end of the timestep is reached
423!$acc kernels
424!$acc loop independent
425 DO jij=d%NIJB, d%NIJE
426 IF (ztime(jij)+zmaxtime(jij) >= ptstep) THEN
427 llcompute(jij)=.false.
428 ENDIF
429 ENDDO
430!$acc end kernels
431 !We must recompute tendencies when the end of the sub-timestep is reached
432 IF (parami%XTSTEP_TS/=0.) THEN
433!$acc kernels
434!$acc loop independent
435 DO jij=d%NIJB, d%NIJE
436 IF ((iiter(jij) < inb_iter_max) .AND. (ztime(jij)+zmaxtime(jij) > ztime_lastcall(jij)+ztstep)) THEN
437 zmaxtime(jij)=ztime_lastcall(jij)-ztime(jij)+ztstep
438 llcompute(jij)=.false.
439 ENDIF
440 ENDDO
441!$acc end kernels
442 ENDIF
443
444 !We must recompute tendencies when the maximum allowed change is reached
445 !When a species is missing, only the external tendencies can be active and we do not want to recompute
446 !the microphysical tendencies when external tendencies are negative (results won't change because species was already missing)
447 IF (parami%XMRSTEP/=0.) THEN
448 IF (ll_any_iter) THEN
449 ! In this case we need to remember the initial mixing ratios used to compute the tendencies
450 ! because when mixing ratio has evolved more than a threshold, we must re-compute tendencies
451 ! Thus, at first iteration (ie when LLCPZ0RT=.TRUE.) we copy PRT into Z0RT
452 DO jv=1,krr
453!$acc kernels
454 IF (llcpz0rt) THEN
455 z0rt(d%NIJB:d%NIJE , jv)=prt(d%NIJB:d%NIJE , jv)
456 ENDIF
457!$acc loop independent
458 DO jij=d%NIJB, d%NIJE
459 IF (iiter(jij)<inb_iter_max .AND. abs(za(jij,jv))>1.e-20) THEN
460 ztime_threshold1d(jij)=(sign(1., za(jij, jv))*parami%XMRSTEP+ &
461 &z0rt(jij, jv)-prt(jij, jv)-zb(jij, jv))/za(jij, jv)
462 ELSE
463 ztime_threshold1d(jij)=-1.
464 ENDIF
465 ENDDO
466!$acc loop independent
467 DO jij=d%NIJB, d%NIJE
468 IF (ztime_threshold1d(jij)>=0 .AND. ztime_threshold1d(jij)<zmaxtime(jij) .AND. &
469 &(prt(jij, jv)>zrsmin(jv) .OR. za(jij, jv)>0.)) THEN
470 zmaxtime(jij)=min(zmaxtime(jij), ztime_threshold1d(jij))
471 llcompute(jij)=.false.
472 ENDIF
473 ENDDO
474 IF (jv == 1) THEN
475!$acc loop independent
476 DO jij=d%NIJB, d%NIJE
477 zmaxb(jij)=abs(zb(jij, jv))
478 ENDDO
479 ELSE
480!$acc loop independent
481 DO jij=d%NIJB, d%NIJE
482 zmaxb(jij)=max(zmaxb(jij), abs(zb(jij, jv)))
483 ENDDO
484 ENDIF
485!$acc end kernels
486 ENDDO
487 llcpz0rt=.false.
488!$acc kernels
489!$acc loop independent
490 DO jij=d%NIJB, d%NIJE
491 IF (iiter(jij)<inb_iter_max .AND. zmaxb(jij)>parami%XMRSTEP) THEN
492 zmaxtime(jij)=0.
493 llcompute(jij)=.false.
494 ENDIF
495 ENDDO
496!$acc end kernels
497 ENDIF ! LL_ANY_ITER
498 ENDIF ! XMRSTEP/=0.
499 !-------------------------------------------------------------------------------
500 !
501 !*** 4.7 New values of variables for next iteration
502 !
503 !
504!$acc kernels
505 DO jij=d%NIJB, d%NIJE
506 IF(ldmicro(jij)) THEN
507 ptht(jij)=ptht(jij)+zath(jij)*zmaxtime(jij)+zbth(jij)
508 ENDIF
509 ENDDO
510!$acc end kernels
511!$acc kernels
512!$acc loop independent collapse(2)
513 DO jv=1, krr
514 DO jij=d%NIJB, d%NIJE
515 IF(ldmicro(jij)) THEN
516 prt(jij, jv)=prt(jij, jv)+za(jij, jv)*zmaxtime(jij)+zb(jij, jv)
517 ENDIF
518 ENDDO
519 ENDDO
520!$acc end kernels
521!$acc kernels
522!$acc loop independent
523 DO jij=d%NIJB, d%NIJE
524 IF (prt(jij,iri)<=0. .AND. ldmicro(jij)) pcit(jij) = 0.
525 ztime(jij)=ztime(jij)+zmaxtime(jij)
526 ENDDO
527!$acc end kernels
528 !-------------------------------------------------------------------------------
529 !
530 !*** 4.8 Mixing ratio change due to each process
531 !
532 IF(buconf%LBU_ENABLE .OR. osave_micro) THEN
533 !Mixing ratio change due to a tendency
534!$acc kernels
535!$acc loop independent collapse(2)
537 DO jij=d%NIJB, d%NIJE
538 pbudgets(jij, jv) = pbudgets(jij, jv) + zbu_inst(jij, jv)*zmaxtime(jij)
539 ENDDO
540 ENDDO
541!$acc end kernels
542
543 !Mixing ratio change due to a mixing ratio change
544!$acc kernels
545!$acc loop independent collapse(2)
547 DO jij=d%NIJB, d%NIJE
548 pbudgets(jij, jv) = pbudgets(jij, jv) + zbu_inst(jij, jv)
549 ENDDO
550 ENDDO
551!$acc end kernels
552
553 !Extra contribution as a mixing ratio change
554 DO jv=ibunum-ibunum_extra+1, ibunum
555 jjv=ibuextraind(jv)
556!$acc kernels
557!$acc loop independent
558 DO jij=d%NIJB, d%NIJE
559 pbudgets(jij, jjv) = pbudgets(jij, jjv) + zbu_inst(jij, jv)
560 ENDDO
561!$acc end kernels
562 ENDDO
563 ENDIF
564 !-------------------------------------------------------------------------------
565 !
566 !*** 4.9 Next loop
567 !
568 lsoft=.true. ! We try to adjust tendencies (inner while loop)
569 ENDDO !Iterations on tendency computations (WHILE ANY(LLCOMPUTE))
570ENDDO !Temporal loop
571
572IF(parami%LEXT_TEND) THEN
573 !Z..T variables contain the external tendency, we substract it
574!$acc kernels
575 DO jij=d%NIJB, d%NIJE
576 IF(ldmicro(jij)) THEN
577 ptht(jij)=ptht(jij) - zextth(jij) * ptstep
578 ENDIF
579 ENDDO
580!$acc end kernels
581!$acc kernels
582!$acc loop independent collapse(2)
583 DO jv=1, krr
584 DO jij=d%NIJB, d%NIJE
585 IF(ldmicro(jij)) THEN
586 prt(jij, jv) = prt(jij, jv) - zextpk(jij, jv) * ptstep
587 ENDIF
588 ENDDO
589 ENDDO
590!$acc end kernels
591ENDIF
592!$acc kernels
593DO jij=d%NIJB, d%NIJE
594 prrevav(jij)=zbu_inst(jij, irrevav)
595ENDDO
596!$acc end kernels
597!
598IF (lhook) CALL dr_hook('ICE4_STEPPING', 1, zhook_handle)
599END SUBROUTINE ice4_stepping
600
subroutine ice4_stepping(d, cst, parami, icep, iced, buconf, ptstep, krr, osave_micro, ldmicro, oelec, pexn, prhodref, ppabst, pcit, pcldfr, phlc_hcf, phlc_hrc, phli_hcf, phli_hri, pths, prs, prrevav, prainfr, psigs, ptht, prt, picldfr, pzzz, pconc3d, pssio, pssiu, pifr, pbudgets, platham_iaggs, prcriauti, prcriautc, picenu)
integer, parameter irrevav
integer, dimension(ibunum-ibunum_extra+1:ibunum), parameter ibuextraind
integer, parameter ibunum_mr
integer, parameter ibunum_extra
integer, parameter ibunum
subroutine ice4_tendencies(cst, parami, icep, iced, buconf, d, krr, odsoft, ldcompute, osave_micro, oelec, pexn, prhodref, plvfact, plsfact, ppres, pcf, psigma_rc, pcit, pt, picldfr, pzzz, pconc, pssio, pssiu, pifr, pth, pvart, platham_iaggs, pbu_inst, prs_tend, prg_tend, prh_tend, pssi, pa, pb, path, pbth, phlc_hcf, phlc_lcf, phlc_hrc, phlc_lrc, phli_hcf, phli_lcf, phli_hri, phli_lri, prainfr, prcriauti, prcriautc, picenu)