Setup.
81 real(RP),
intent(out) :: qflx_anti(KA,IA,JA,3)
83 real(RP),
intent(in) :: phi_in(KA,IA,JA)
84 real(RP),
intent(in) :: DENS0(KA,IA,JA)
85 real(RP),
intent(in) :: DENS (KA,IA,JA)
87 real(RP),
intent(in) :: qflx_hi(KA,IA,JA,3)
88 real(RP),
intent(in) :: qflx_lo(KA,IA,JA,3)
89 real(RP),
intent(in) :: mflx_hi(KA,IA,JA,3)
91 real(RP),
intent(in) :: RDZ(:)
92 real(RP),
intent(in) :: RDX(:)
93 real(RP),
intent(in) :: RDY(:)
95 real(RP),
intent(in) :: GSQRT(KA,IA,JA)
96 real(RP),
intent(in) :: MAPF(IA,JA,2)
98 logical,
intent(in) :: TwoD
99 real(RP),
intent(in) :: dt
101 logical,
intent(in) :: flag_vect
104 real(RP) :: phi_lo(KA,IA,JA)
105 real(RP) :: pjpls(KA,IA,JA)
106 real(RP) :: pjmns(KA,IA,JA)
107 real(RP) :: qjpls(KA,IA,JA)
108 real(RP) :: qjmns(KA,IA,JA)
109 real(RP) :: rjpls(KA,IA,JA)
110 real(RP) :: rjmns(KA,IA,JA)
112 real(RP) :: qmin, qmax
113 real(RP) :: zerosw, dirsw
115 real(RP) :: fact(0:1,-1:1,-1:1)
116 real(RP) :: rw, ru, rv
117 real(RP) :: qa_in, qb_in
118 real(RP) :: qa_lo, qb_lo
120 integer :: k, i, j, ijs
121 integer :: IIS, IIE, JJS, JJE
125 qflx_anti(:,:,:,:) = undef
135 do jjs = js, je, jblock
137 do iis = is, ie, iblock
145 call check( __line__, qflx_hi(k,i,j,zdir) )
146 call check( __line__, qflx_lo(k,i,j,zdir) )
148 qflx_anti(k,i,j,zdir) = qflx_hi(k,i,j,zdir) - qflx_lo(k,i,j,zdir)
153 k = iundef; i = iundef; j = iundef
158 qflx_anti(ks-1,i,j,zdir) = 0.0_rp
159 qflx_anti(ke ,i,j,zdir) = 0.0_rp
163 k = iundef; i = iundef; j = iundef
166 if ( .not. twod )
then
172 call check( __line__, qflx_hi(k,i,j,xdir) )
173 call check( __line__, qflx_lo(k,i,j,xdir) )
175 qflx_anti(k,i,j,xdir) = qflx_hi(k,i,j,xdir) - qflx_lo(k,i,j,xdir)
180 k = iundef; i = iundef; j = iundef
189 call check( __line__, qflx_hi(k,i,j,ydir) )
190 call check( __line__, qflx_lo(k,i,j,ydir) )
192 qflx_anti(k,i,j,ydir) = qflx_hi(k,i,j,ydir) - qflx_lo(k,i,j,ydir)
197 k = iundef; i = iundef; j = iundef
206 call check( __line__, phi_in(k,is,j) )
207 call check( __line__, qflx_lo(k ,is,j ,zdir) )
208 call check( __line__, qflx_lo(k-1,is,j ,zdir) )
209 call check( __line__, qflx_lo(k ,is,j ,ydir) )
210 call check( __line__, qflx_lo(k ,is,j-1,ydir) )
212 phi_lo(k,is,j) = ( phi_in(k,is,j) * dens0(k,is,j) &
213 + dt * ( - ( ( qflx_lo(k,is,j,zdir)-qflx_lo(k-1,is,j ,zdir) ) * rdz(k) &
214 + ( qflx_lo(k,is,j,ydir)-qflx_lo(k ,is,j-1,ydir) ) * rdy(j) &
215 ) * mapf(is,j,2) / gsqrt(k,is,j) ) &
225 call check( __line__, phi_in(k,i,j) )
226 call check( __line__, qflx_lo(k ,i ,j ,zdir) )
227 call check( __line__, qflx_lo(k-1,i ,j ,zdir) )
228 call check( __line__, qflx_lo(k ,i ,j ,xdir) )
229 call check( __line__, qflx_lo(k ,i-1,j ,xdir) )
230 call check( __line__, qflx_lo(k ,i ,j ,ydir) )
231 call check( __line__, qflx_lo(k ,i ,j-1,ydir) )
233 phi_lo(k,i,j) = ( phi_in(k,i,j) * dens0(k,i,j) &
234 + dt * ( - ( ( qflx_lo(k,i,j,zdir)-qflx_lo(k-1,i ,j ,zdir) ) * rdz(k) &
235 + ( qflx_lo(k,i,j,xdir)-qflx_lo(k ,i-1,j ,xdir) ) * rdx(i) &
236 + ( qflx_lo(k,i,j,ydir)-qflx_lo(k ,i ,j-1,ydir) ) * rdy(j) &
237 ) * mapf(i,j,1) * mapf(i,j,2) / gsqrt(k,i,j) ) &
244 k = iundef; i = iundef; j = iundef
253 call check( __line__, qflx_anti(k ,is,j ,zdir) )
254 call check( __line__, qflx_anti(k-1,is,j ,zdir) )
255 call check( __line__, qflx_anti(k ,is,j ,ydir) )
256 call check( __line__, qflx_anti(k ,is,j-1,ydir) )
258 pjpls(k,is,j) = dt * ( ( max(0.0_rp,qflx_anti(k-1,is ,j ,zdir)) - min(0.0_rp,qflx_anti(k,is,j,zdir)) ) * rdz(k) &
259 + ( max(0.0_rp,qflx_anti(k ,is,j-1,ydir)) - min(0.0_rp,qflx_anti(k,is,j,ydir)) ) * rdy(j) &
260 ) * mapf(is,j,2) / gsqrt(k,is,j)
269 call check( __line__, qflx_anti(k ,i ,j ,zdir) )
270 call check( __line__, qflx_anti(k-1,i ,j ,zdir) )
271 call check( __line__, qflx_anti(k ,i ,j ,xdir) )
272 call check( __line__, qflx_anti(k ,i-1,j ,xdir) )
273 call check( __line__, qflx_anti(k ,i ,j ,ydir) )
274 call check( __line__, qflx_anti(k ,i ,j-1,ydir) )
276 pjpls(k,i,j) = dt * ( ( max(0.0_rp,qflx_anti(k-1,i ,j ,zdir)) - min(0.0_rp,qflx_anti(k,i,j,zdir)) ) * rdz(k) &
277 + ( max(0.0_rp,qflx_anti(k ,i-1,j ,xdir)) - min(0.0_rp,qflx_anti(k,i,j,xdir)) ) * rdx(i) &
278 + ( max(0.0_rp,qflx_anti(k ,i ,j-1,ydir)) - min(0.0_rp,qflx_anti(k,i,j,ydir)) ) * rdy(j) &
279 ) * mapf(i,j,1) * mapf(i,j,2) / gsqrt(k,i,j)
285 k = iundef; i = iundef; j = iundef
294 call check( __line__, qflx_anti(k ,is,j ,zdir) )
295 call check( __line__, qflx_anti(k-1,is,j ,zdir) )
296 call check( __line__, qflx_anti(k ,is,j ,ydir) )
297 call check( __line__, qflx_anti(k ,is,j-1,ydir) )
299 pjmns(k,is,j) = dt * ( ( max(0.0_rp,qflx_anti(k,is,j,zdir)) - min(0.0_rp,qflx_anti(k-1,is,j ,zdir)) ) * rdz(k) &
300 + ( max(0.0_rp,qflx_anti(k,is,j,ydir)) - min(0.0_rp,qflx_anti(k ,is,j-1,ydir)) ) * rdy(j) &
301 ) * mapf(is,j,2) / gsqrt(k,is,j)
310 call check( __line__, qflx_anti(k ,i ,j ,zdir) )
311 call check( __line__, qflx_anti(k-1,i ,j ,zdir) )
312 call check( __line__, qflx_anti(k ,i ,j ,xdir) )
313 call check( __line__, qflx_anti(k ,i-1,j ,xdir) )
314 call check( __line__, qflx_anti(k ,i ,j ,ydir) )
315 call check( __line__, qflx_anti(k ,i ,j-1,ydir) )
317 pjmns(k,i,j) = dt * ( ( max(0.0_rp,qflx_anti(k,i,j,zdir)) - min(0.0_rp,qflx_anti(k-1,i ,j ,zdir)) ) * rdz(k) &
318 + ( max(0.0_rp,qflx_anti(k,i,j,xdir)) - min(0.0_rp,qflx_anti(k ,i-1,j ,xdir)) ) * rdx(i) &
319 + ( max(0.0_rp,qflx_anti(k,i,j,ydir)) - min(0.0_rp,qflx_anti(k ,i ,j-1,ydir)) ) * rdy(j) &
320 ) * mapf(i,j,1) * mapf(i,j,2) / gsqrt(k,i,j)
326 k = iundef; i = iundef; j = iundef
338 rw = (mflx_hi(k,i,j,zdir)+mflx_hi(k-1,i ,j ,zdir)) * rdz(k)
340 rv = (mflx_hi(k,i,j,ydir)+mflx_hi(k ,i ,j-1,ydir)) * rdy(j)
342 call get_fact_fct( fact, &
345 qa_in = fact(1, 0, 1) * phi_in(k+1,i ,j+1) &
346 + fact(0, 0, 1) * phi_in(k ,i ,j+1) &
347 + fact(1, 0, 0) * phi_in(k+1,i ,j ) &
348 + fact(1, 0,-1) * phi_in(k+1,i ,j-1) &
349 + fact(0, 0, 0) * phi_in(k ,i ,j )
350 qb_in = fact(1, 0, 1) * phi_in(k-1,i ,j-1) &
351 + fact(0, 0, 1) * phi_in(k ,i ,j-1) &
352 + fact(1, 0, 0) * phi_in(k-1,i ,j ) &
353 + fact(1, 0,-1) * phi_in(k-1,i ,j-1) &
354 + fact(0, 0, 0) * phi_in(k ,i ,j )
355 qa_lo = fact(1, 0, 1) * phi_lo(k+1,i ,j+1) &
356 + fact(0, 0, 1) * phi_lo(k ,i ,j+1) &
357 + fact(1, 0, 0) * phi_lo(k+1,i ,j ) &
358 + fact(1, 0,-1) * phi_lo(k+1,i ,j-1) &
359 + fact(0, 0, 0) * phi_lo(k ,i ,j )
360 qb_lo = fact(1, 0, 1) * phi_lo(k-1,i ,j-1) &
361 + fact(0, 0, 1) * phi_lo(k ,i ,j-1) &
362 + fact(1, 0, 0) * phi_lo(k-1,i ,j ) &
363 + fact(1, 0,-1) * phi_lo(k-1,i ,j-1) &
364 + fact(0, 0, 0) * phi_lo(k ,i ,j )
367 phi_in(k,i,j), qa_in, qb_in, &
368 phi_lo(k,i,j), qa_lo, qb_lo )
370 phi_in(k,i,j), qa_in, qb_in, &
371 phi_lo(k,i,j), qa_lo, qb_lo )
372 qjpls(k,i,j) = ( qmax - phi_lo(k,i,j) ) * dens(k,i,j)
373 qjmns(k,i,j) = ( phi_lo(k,i,j) - qmin ) * dens(k,i,j)
380 rw = (mflx_hi(ks,i,j,zdir) ) * rdz(ks)
382 rv = (mflx_hi(ks,i,j,ydir)+mflx_hi(ks ,i ,j-1,ydir)) * rdy(j)
384 call get_fact_fct( fact, &
387 qa_in = fact(1, 0, 1) * phi_in(ks+1,i ,j+1) &
388 + fact(0, 0, 1) * phi_in(ks ,i ,j+1) &
389 + fact(1, 0, 0) * phi_in(ks+1,i ,j ) &
390 + fact(1, 0,-1) * phi_in(ks+1,i ,j-1) &
391 + fact(0, 0, 0) * phi_in(ks ,i ,j )
392 qb_in = fact(1, 0, 1) * phi_in(ks ,i ,j-1) &
393 + fact(0, 0, 1) * phi_in(ks ,i ,j-1) &
394 + fact(1, 0, 0) * phi_in(ks ,i ,j ) &
395 + fact(1, 0,-1) * phi_in(ks ,i ,j-1) &
396 + fact(0, 0, 0) * phi_in(ks ,i ,j )
397 qa_lo = fact(1, 0, 1) * phi_lo(ks+1,i ,j+1) &
398 + fact(0, 0, 1) * phi_lo(ks ,i ,j+1) &
399 + fact(1, 0, 0) * phi_lo(ks+1,i ,j ) &
400 + fact(1, 0,-1) * phi_lo(ks+1,i ,j-1) &
401 + fact(0, 0, 0) * phi_lo(ks ,i ,j )
402 qb_lo = fact(1, 0, 1) * phi_lo(ks ,i ,j-1) &
403 + fact(0, 0, 1) * phi_lo(ks ,i ,j-1) &
404 + fact(1, 0, 0) * phi_lo(ks ,i ,j ) &
405 + fact(1, 0,-1) * phi_lo(ks ,i ,j-1) &
406 + fact(0, 0, 0) * phi_lo(ks ,i ,j )
409 phi_in(ks,i,j), qa_in, qb_in, &
410 phi_lo(ks,i,j), qa_lo, qb_lo )
412 phi_in(ks,i,j), qa_in, qb_in, &
413 phi_lo(ks,i,j), qa_lo, qb_lo )
414 qjpls(ks,i,j) = ( qmax - phi_lo(ks,i,j) ) * dens(ks,i,j)
415 qjmns(ks,i,j) = ( phi_lo(ks,i,j) - qmin ) * dens(ks,i,j)
421 rw = ( mflx_hi(ke-1,i ,j ,zdir)) * rdz(ke)
423 rv = (mflx_hi(ke,i,j,ydir)+mflx_hi(ke ,i ,j-1,ydir)) * rdy(j)
425 call get_fact_fct( fact, &
428 qa_in = fact(1, 0, 1) * phi_in(ke ,i ,j+1) &
429 + fact(0, 0, 1) * phi_in(ke ,i ,j+1) &
430 + fact(1, 0, 0) * phi_in(ke ,i ,j ) &
431 + fact(1, 0,-1) * phi_in(ke ,i ,j-1) &
432 + fact(0, 0, 0) * phi_in(ke ,i ,j )
433 qb_in = fact(1, 0, 1) * phi_in(ke-1,i ,j-1) &
434 + fact(0, 0, 1) * phi_in(ke ,i ,j-1) &
435 + fact(1, 0, 0) * phi_in(ke-1,i ,j ) &
436 + fact(1, 0,-1) * phi_in(ke-1,i ,j-1) &
437 + fact(0, 0, 0) * phi_in(ke ,i ,j )
438 qa_lo = fact(1, 0, 1) * phi_lo(ke ,i ,j+1) &
439 + fact(0, 0, 1) * phi_lo(ke ,i ,j+1) &
440 + fact(1, 0, 0) * phi_lo(ke ,i ,j ) &
441 + fact(1, 0,-1) * phi_lo(ke ,i ,j-1) &
442 + fact(0, 0, 0) * phi_lo(ke ,i ,j )
443 qb_lo = fact(1, 0, 1) * phi_lo(ke-1,i ,j-1) &
444 + fact(0, 0, 1) * phi_lo(ke ,i ,j-1) &
445 + fact(1, 0, 0) * phi_lo(ke-1,i ,j ) &
446 + fact(1, 0,-1) * phi_lo(ke-1,i ,j-1) &
447 + fact(0, 0, 0) * phi_lo(ke ,i ,j )
450 phi_in(ke,i,j), qa_in, qb_in, &
451 phi_lo(ke,i,j), qa_lo, qb_lo )
453 phi_in(ke,i,j), qa_in, qb_in, &
454 phi_lo(ke,i,j), qa_lo, qb_lo )
455 qjpls(ke,i,j) = ( qmax - phi_lo(ke,i,j) ) * dens(ke,i,j)
456 qjmns(ke,i,j) = ( phi_lo(ke,i,j) - qmin ) * dens(ke,i,j)
464 rw = (mflx_hi(k,i,j,zdir)+mflx_hi(k-1,i ,j ,zdir)) * rdz(k)
465 ru = (mflx_hi(k,i,j,xdir)+mflx_hi(k ,i-1,j ,xdir)) * rdx(i)
466 rv = (mflx_hi(k,i,j,ydir)+mflx_hi(k ,i ,j-1,ydir)) * rdy(j)
468 call get_fact_fct( fact, &
471 qa_in = fact(1, 1, 1) * phi_in(k+1,i+1,j+1) &
472 + fact(0, 1, 1) * phi_in(k ,i+1,j+1) &
473 + fact(1, 0, 1) * phi_in(k+1,i ,j+1) &
474 + fact(0, 0, 1) * phi_in(k ,i ,j+1) &
475 + fact(1,-1, 1) * phi_in(k+1,i-1,j+1) &
476 + fact(1, 1, 0) * phi_in(k+1,i+1,j ) &
477 + fact(0, 1, 0) * phi_in(k ,i+1,j ) &
478 + fact(1, 0, 0) * phi_in(k+1,i ,j ) &
479 + fact(1,-1, 0) * phi_in(k+1,i-1,j ) &
480 + fact(1, 1,-1) * phi_in(k+1,i+1,j-1) &
481 + fact(0, 1,-1) * phi_in(k ,i+1,j-1) &
482 + fact(1, 0,-1) * phi_in(k+1,i ,j-1) &
483 + fact(1,-1,-1) * phi_in(k+1,i-1,j-1) &
484 + fact(0, 0, 0) * phi_in(k ,i ,j )
485 qb_in = fact(1, 1, 1) * phi_in(k-1,i-1,j-1) &
486 + fact(0, 1, 1) * phi_in(k ,i-1,j-1) &
487 + fact(1, 0, 1) * phi_in(k-1,i ,j-1) &
488 + fact(0, 0, 1) * phi_in(k ,i ,j-1) &
489 + fact(1,-1, 1) * phi_in(k-1,i+1,j-1) &
490 + fact(1, 1, 0) * phi_in(k-1,i-1,j ) &
491 + fact(0, 1, 0) * phi_in(k ,i-1,j ) &
492 + fact(1, 0, 0) * phi_in(k-1,i ,j ) &
493 + fact(1,-1, 0) * phi_in(k-1,i+1,j ) &
494 + fact(1, 1,-1) * phi_in(k-1,i-1,j+1) &
495 + fact(0, 1,-1) * phi_in(k ,i-1,j-1) &
496 + fact(1, 0,-1) * phi_in(k-1,i ,j-1) &
497 + fact(1,-1,-1) * phi_in(k-1,i+1,j+1) &
498 + fact(0, 0, 0) * phi_in(k ,i ,j )
499 qa_lo = fact(1, 1, 1) * phi_lo(k+1,i+1,j+1) &
500 + fact(0, 1, 1) * phi_lo(k ,i+1,j+1) &
501 + fact(1, 0, 1) * phi_lo(k+1,i ,j+1) &
502 + fact(0, 0, 1) * phi_lo(k ,i ,j+1) &
503 + fact(1,-1, 1) * phi_lo(k+1,i-1,j+1) &
504 + fact(1, 1, 0) * phi_lo(k+1,i+1,j ) &
505 + fact(0, 1, 0) * phi_lo(k ,i+1,j ) &
506 + fact(1, 0, 0) * phi_lo(k+1,i ,j ) &
507 + fact(1,-1, 0) * phi_lo(k+1,i-1,j ) &
508 + fact(1, 1,-1) * phi_lo(k+1,i+1,j-1) &
509 + fact(0, 1,-1) * phi_lo(k ,i+1,j-1) &
510 + fact(1, 0,-1) * phi_lo(k+1,i ,j-1) &
511 + fact(1,-1,-1) * phi_lo(k+1,i-1,j-1) &
512 + fact(0, 0, 0) * phi_lo(k ,i ,j )
513 qb_lo = fact(1, 1, 1) * phi_lo(k-1,i-1,j-1) &
514 + fact(0, 1, 1) * phi_lo(k ,i-1,j-1) &
515 + fact(1, 0, 1) * phi_lo(k-1,i ,j-1) &
516 + fact(0, 0, 1) * phi_lo(k ,i ,j-1) &
517 + fact(1,-1, 1) * phi_lo(k-1,i+1,j-1) &
518 + fact(1, 1, 0) * phi_lo(k-1,i-1,j ) &
519 + fact(0, 1, 0) * phi_lo(k ,i-1,j ) &
520 + fact(1, 0, 0) * phi_lo(k-1,i ,j ) &
521 + fact(1,-1, 0) * phi_lo(k-1,i+1,j ) &
522 + fact(1, 1,-1) * phi_lo(k-1,i-1,j+1) &
523 + fact(0, 1,-1) * phi_lo(k ,i-1,j-1) &
524 + fact(1, 0,-1) * phi_lo(k-1,i ,j-1) &
525 + fact(1,-1,-1) * phi_lo(k-1,i+1,j+1) &
526 + fact(0, 0, 0) * phi_lo(k ,i ,j )
529 phi_in(k,i,j), qa_in, qb_in, &
530 phi_lo(k,i,j), qa_lo, qb_lo )
532 phi_in(k,i,j), qa_in, qb_in, &
533 phi_lo(k,i,j), qa_lo, qb_lo )
534 qjpls(k,i,j) = ( qmax - phi_lo(k,i,j) ) * dens(k,i,j)
535 qjmns(k,i,j) = ( phi_lo(k,i,j) - qmin ) * dens(k,i,j)
544 rw = (mflx_hi(ks,i,j,zdir) ) * rdz(ks)
545 ru = (mflx_hi(ks,i,j,xdir)+mflx_hi(ks ,i-1,j ,xdir)) * rdx(i)
546 rv = (mflx_hi(ks,i,j,ydir)+mflx_hi(ks ,i ,j-1,ydir)) * rdy(j)
548 call get_fact_fct( fact, &
551 qa_in = fact(1, 1, 1) * phi_in(ks+1,i+1,j+1) &
552 + fact(0, 1, 1) * phi_in(ks ,i+1,j+1) &
553 + fact(1, 0, 1) * phi_in(ks+1,i ,j+1) &
554 + fact(0, 0, 1) * phi_in(ks ,i ,j+1) &
555 + fact(1,-1, 1) * phi_in(ks+1,i-1,j+1) &
556 + fact(1, 1, 0) * phi_in(ks+1,i+1,j ) &
557 + fact(0, 1, 0) * phi_in(ks ,i+1,j ) &
558 + fact(1, 0, 0) * phi_in(ks+1,i ,j ) &
559 + fact(1,-1, 0) * phi_in(ks+1,i-1,j ) &
560 + fact(1, 1,-1) * phi_in(ks+1,i+1,j-1) &
561 + fact(0, 1,-1) * phi_in(ks ,i+1,j-1) &
562 + fact(1, 0,-1) * phi_in(ks+1,i ,j-1) &
563 + fact(1,-1,-1) * phi_in(ks+1,i-1,j-1) &
564 + fact(0, 0, 0) * phi_in(ks ,i ,j )
565 qb_in = fact(1, 1, 1) * phi_in(ks ,i-1,j-1) &
566 + fact(0, 1, 1) * phi_in(ks ,i-1,j-1) &
567 + fact(1, 0, 1) * phi_in(ks ,i ,j-1) &
568 + fact(0, 0, 1) * phi_in(ks ,i ,j-1) &
569 + fact(1,-1, 1) * phi_in(ks ,i+1,j-1) &
570 + fact(1, 1, 0) * phi_in(ks ,i-1,j ) &
571 + fact(0, 1, 0) * phi_in(ks ,i-1,j ) &
572 + fact(1, 0, 0) * phi_in(ks ,i ,j ) &
573 + fact(1,-1, 0) * phi_in(ks ,i+1,j ) &
574 + fact(1, 1,-1) * phi_in(ks ,i-1,j+1) &
575 + fact(0, 1,-1) * phi_in(ks ,i-1,j-1) &
576 + fact(1, 0,-1) * phi_in(ks ,i ,j-1) &
577 + fact(1,-1,-1) * phi_in(ks ,i+1,j+1) &
578 + fact(0, 0, 0) * phi_in(ks ,i ,j )
579 qa_lo = fact(1, 1, 1) * phi_lo(ks+1,i+1,j+1) &
580 + fact(0, 1, 1) * phi_lo(ks ,i+1,j+1) &
581 + fact(1, 0, 1) * phi_lo(ks+1,i ,j+1) &
582 + fact(0, 0, 1) * phi_lo(ks ,i ,j+1) &
583 + fact(1,-1, 1) * phi_lo(ks+1,i-1,j+1) &
584 + fact(1, 1, 0) * phi_lo(ks+1,i+1,j ) &
585 + fact(0, 1, 0) * phi_lo(ks ,i+1,j ) &
586 + fact(1, 0, 0) * phi_lo(ks+1,i ,j ) &
587 + fact(1,-1, 0) * phi_lo(ks+1,i-1,j ) &
588 + fact(1, 1,-1) * phi_lo(ks+1,i+1,j-1) &
589 + fact(0, 1,-1) * phi_lo(ks ,i+1,j-1) &
590 + fact(1, 0,-1) * phi_lo(ks+1,i ,j-1) &
591 + fact(1,-1,-1) * phi_lo(ks+1,i-1,j-1) &
592 + fact(0, 0, 0) * phi_lo(ks ,i ,j )
593 qb_lo = fact(1, 1, 1) * phi_lo(ks ,i-1,j-1) &
594 + fact(0, 1, 1) * phi_lo(ks ,i-1,j-1) &
595 + fact(1, 0, 1) * phi_lo(ks ,i ,j-1) &
596 + fact(0, 0, 1) * phi_lo(ks ,i ,j-1) &
597 + fact(1,-1, 1) * phi_lo(ks ,i+1,j-1) &
598 + fact(1, 1, 0) * phi_lo(ks ,i-1,j ) &
599 + fact(0, 1, 0) * phi_lo(ks ,i-1,j ) &
600 + fact(1, 0, 0) * phi_lo(ks ,i ,j ) &
601 + fact(1,-1, 0) * phi_lo(ks ,i+1,j ) &
602 + fact(1, 1,-1) * phi_lo(ks ,i-1,j+1) &
603 + fact(0, 1,-1) * phi_lo(ks ,i-1,j-1) &
604 + fact(1, 0,-1) * phi_lo(ks ,i ,j-1) &
605 + fact(1,-1,-1) * phi_lo(ks ,i+1,j+1) &
606 + fact(0, 0, 0) * phi_lo(ks ,i ,j )
609 phi_in(ks,i,j), qa_in, qb_in, &
610 phi_lo(ks,i,j), qa_lo, qb_lo )
612 phi_in(ks,i,j), qa_in, qb_in, &
613 phi_lo(ks,i,j), qa_lo, qb_lo )
614 qjpls(ks,i,j) = ( qmax - phi_lo(ks,i,j) ) * dens(ks,i,j)
615 qjmns(ks,i,j) = ( phi_lo(ks,i,j) - qmin ) * dens(ks,i,j)
623 rw = ( mflx_hi(ke-1,i ,j ,zdir)) * rdz(ke)
624 ru = (mflx_hi(ke,i,j,xdir)+mflx_hi(ke ,i-1,j ,xdir)) * rdx(i)
625 rv = (mflx_hi(ke,i,j,ydir)+mflx_hi(ke ,i ,j-1,ydir)) * rdy(j)
627 call get_fact_fct( fact, &
630 qa_in = fact(1, 1, 1) * phi_in(ke ,i+1,j+1) &
631 + fact(0, 1, 1) * phi_in(ke ,i+1,j+1) &
632 + fact(1, 0, 1) * phi_in(ke ,i ,j+1) &
633 + fact(0, 0, 1) * phi_in(ke ,i ,j+1) &
634 + fact(1,-1, 1) * phi_in(ke ,i-1,j+1) &
635 + fact(1, 1, 0) * phi_in(ke ,i+1,j ) &
636 + fact(0, 1, 0) * phi_in(ke ,i+1,j ) &
637 + fact(1, 0, 0) * phi_in(ke ,i ,j ) &
638 + fact(1,-1, 0) * phi_in(ke ,i-1,j ) &
639 + fact(1, 1,-1) * phi_in(ke ,i+1,j-1) &
640 + fact(0, 1,-1) * phi_in(ke ,i+1,j-1) &
641 + fact(1, 0,-1) * phi_in(ke ,i ,j-1) &
642 + fact(1,-1,-1) * phi_in(ke ,i-1,j-1) &
643 + fact(0, 0, 0) * phi_in(ke ,i ,j )
644 qb_in = fact(1, 1, 1) * phi_in(ke-1,i-1,j-1) &
645 + fact(0, 1, 1) * phi_in(ke ,i-1,j-1) &
646 + fact(1, 0, 1) * phi_in(ke-1,i ,j-1) &
647 + fact(0, 0, 1) * phi_in(ke ,i ,j-1) &
648 + fact(1,-1, 1) * phi_in(ke-1,i+1,j-1) &
649 + fact(1, 1, 0) * phi_in(ke-1,i-1,j ) &
650 + fact(0, 1, 0) * phi_in(ke ,i-1,j ) &
651 + fact(1, 0, 0) * phi_in(ke-1,i ,j ) &
652 + fact(1,-1, 0) * phi_in(ke-1,i+1,j ) &
653 + fact(1, 1,-1) * phi_in(ke-1,i-1,j+1) &
654 + fact(0, 1,-1) * phi_in(ke ,i-1,j-1) &
655 + fact(1, 0,-1) * phi_in(ke-1,i ,j-1) &
656 + fact(1,-1,-1) * phi_in(ke-1,i+1,j+1) &
657 + fact(0, 0, 0) * phi_in(ke ,i ,j )
658 qa_lo = fact(1, 1, 1) * phi_lo(ke ,i+1,j+1) &
659 + fact(0, 1, 1) * phi_lo(ke ,i+1,j+1) &
660 + fact(1, 0, 1) * phi_lo(ke ,i ,j+1) &
661 + fact(0, 0, 1) * phi_lo(ke ,i ,j+1) &
662 + fact(1,-1, 1) * phi_lo(ke ,i-1,j+1) &
663 + fact(1, 1, 0) * phi_lo(ke ,i+1,j ) &
664 + fact(0, 1, 0) * phi_lo(ke ,i+1,j ) &
665 + fact(1, 0, 0) * phi_lo(ke ,i ,j ) &
666 + fact(1,-1, 0) * phi_lo(ke ,i-1,j ) &
667 + fact(1, 1,-1) * phi_lo(ke ,i+1,j-1) &
668 + fact(0, 1,-1) * phi_lo(ke ,i+1,j-1) &
669 + fact(1, 0,-1) * phi_lo(ke ,i ,j-1) &
670 + fact(1,-1,-1) * phi_lo(ke ,i-1,j-1) &
671 + fact(0, 0, 0) * phi_lo(ke ,i ,j )
672 qb_lo = fact(1, 1, 1) * phi_lo(ke-1,i-1,j-1) &
673 + fact(0, 1, 1) * phi_lo(ke ,i-1,j-1) &
674 + fact(1, 0, 1) * phi_lo(ke-1,i ,j-1) &
675 + fact(0, 0, 1) * phi_lo(ke ,i ,j-1) &
676 + fact(1,-1, 1) * phi_lo(ke-1,i+1,j-1) &
677 + fact(1, 1, 0) * phi_lo(ke-1,i-1,j ) &
678 + fact(0, 1, 0) * phi_lo(ke ,i-1,j ) &
679 + fact(1, 0, 0) * phi_lo(ke-1,i ,j ) &
680 + fact(1,-1, 0) * phi_lo(ke-1,i+1,j ) &
681 + fact(1, 1,-1) * phi_lo(ke-1,i-1,j+1) &
682 + fact(0, 1,-1) * phi_lo(ke ,i-1,j-1) &
683 + fact(1, 0,-1) * phi_lo(ke-1,i ,j-1) &
684 + fact(1,-1,-1) * phi_lo(ke-1,i+1,j+1) &
685 + fact(0, 0, 0) * phi_lo(ke ,i ,j )
688 phi_in(ke,i,j), qa_in, qb_in, &
689 phi_lo(ke,i,j), qa_lo, qb_lo )
691 phi_in(ke,i,j), qa_in, qb_in, &
692 phi_lo(ke,i,j), qa_lo, qb_lo )
693 qjpls(ke,i,j) = ( qmax - phi_lo(ke,i,j) ) * dens(ke,i,j)
694 qjmns(ke,i,j) = ( phi_lo(ke,i,j) - qmin ) * dens(ke,i,j)
707 call check( __line__, phi_in(k ,i ,j ) )
708 call check( __line__, phi_in(k-1,i ,j ) )
709 call check( __line__, phi_in(k+1,i ,j ) )
710 call check( __line__, phi_in(k ,i ,j+1) )
711 call check( __line__, phi_in(k ,i ,j-1) )
712 call check( __line__, phi_lo(k ,i ,j ) )
713 call check( __line__, phi_lo(k-1,i ,j ) )
714 call check( __line__, phi_lo(k+1,i ,j ) )
715 call check( __line__, phi_lo(k ,i ,j+1) )
716 call check( __line__, phi_lo(k ,i ,j-1) )
718 qmax = max( phi_in(k ,i ,j ), &
728 qmin = min( phi_in(k ,i ,j ), &
738 qjpls(k,i,j) = ( qmax - phi_lo(k,i,j) ) * dens(k,i,j)
739 qjmns(k,i,j) = ( phi_lo(k,i,j) - qmin ) * dens(k,i,j)
743 k = iundef; j = iundef
748 call check( __line__, phi_in(ks ,i ,j ) )
749 call check( __line__, phi_in(ks+1,i ,j ) )
750 call check( __line__, phi_in(ks ,i ,j+1) )
751 call check( __line__, phi_in(ks ,i ,j-1) )
752 call check( __line__, phi_lo(ks ,i ,j ) )
753 call check( __line__, phi_lo(ks+1,i ,j ) )
754 call check( __line__, phi_lo(ks ,i ,j+1) )
755 call check( __line__, phi_lo(ks ,i ,j-1) )
756 call check( __line__, phi_in(ke ,i ,j ) )
757 call check( __line__, phi_in(ke-1,i ,j ) )
758 call check( __line__, phi_in(ke ,i ,j+1) )
759 call check( __line__, phi_in(ke ,i ,j-1) )
760 call check( __line__, phi_lo(ke ,i ,j ) )
761 call check( __line__, phi_lo(ke-1,i ,j ) )
762 call check( __line__, phi_lo(ke ,i ,j+1) )
763 call check( __line__, phi_lo(ke ,i ,j-1) )
765 qmax = max( phi_in(ks ,i ,j ), &
766 phi_in(ks+1,i ,j ), &
767 phi_in(ks ,i ,j+1), &
768 phi_in(ks ,i ,j-1), &
770 phi_lo(ks+1,i ,j ), &
771 phi_lo(ks ,i ,j+1), &
773 qmin = min( phi_in(ks ,i ,j ), &
774 phi_in(ks+1,i ,j ), &
775 phi_in(ks ,i ,j+1), &
776 phi_in(ks ,i ,j-1), &
778 phi_lo(ks+1,i ,j ), &
779 phi_lo(ks ,i ,j+1), &
781 qjmns(ks,i,j) = ( phi_lo(ks,i,j) - qmin ) * dens(ks,i,j)
782 qjpls(ks,i,j) = ( qmax - phi_lo(ks,i,j) ) * dens(ks,i,j)
784 qmax = max( phi_in(ke ,i ,j ), &
785 phi_in(ke-1,i ,j ), &
786 phi_in(ke ,i ,j+1), &
787 phi_in(ke ,i ,j-1), &
789 phi_lo(ke-1,i ,j ), &
790 phi_lo(ke ,i ,j+1), &
792 qmin = min( phi_in(ke ,i ,j ), &
793 phi_in(ke-1,i ,j ), &
794 phi_in(ke ,i ,j+1), &
795 phi_in(ke ,i ,j-1), &
797 phi_lo(ke-1,i ,j ), &
798 phi_lo(ke ,i ,j+1), &
800 qjpls(ke,i,j) = ( qmax - phi_lo(ke,i,j) ) * dens(ke,i,j)
801 qjmns(ke,i,j) = ( phi_lo(ke,i,j) - qmin ) * dens(ke,i,j)
804 k = iundef; i = iundef; j = iundef
812 call check( __line__, phi_in(k ,i ,j ) )
813 call check( __line__, phi_in(k-1,i ,j ) )
814 call check( __line__, phi_in(k+1,i ,j ) )
815 call check( __line__, phi_in(k ,i-1,j ) )
816 call check( __line__, phi_in(k ,i+1,j ) )
817 call check( __line__, phi_in(k ,i ,j+1) )
818 call check( __line__, phi_in(k ,i ,j-1) )
819 call check( __line__, phi_lo(k ,i ,j ) )
820 call check( __line__, phi_lo(k-1,i ,j ) )
821 call check( __line__, phi_lo(k+1,i ,j ) )
822 call check( __line__, phi_lo(k ,i-1,j ) )
823 call check( __line__, phi_lo(k ,i+1,j ) )
824 call check( __line__, phi_lo(k ,i ,j+1) )
825 call check( __line__, phi_lo(k ,i ,j-1) )
827 qmax = max( phi_in(k ,i ,j ), &
841 qmin = min( phi_in(k ,i ,j ), &
855 qjpls(k,i,j) = ( qmax - phi_lo(k,i,j) ) * dens(k,i,j)
856 qjmns(k,i,j) = ( phi_lo(k,i,j) - qmin ) * dens(k,i,j)
861 k = iundef; i = iundef; j = iundef
867 call check( __line__, phi_in(ks ,i ,j ) )
868 call check( __line__, phi_in(ks+1,i ,j ) )
869 call check( __line__, phi_in(ks ,i-1,j ) )
870 call check( __line__, phi_in(ks ,i+1,j ) )
871 call check( __line__, phi_in(ks ,i ,j+1) )
872 call check( __line__, phi_in(ks ,i ,j-1) )
873 call check( __line__, phi_lo(ks ,i ,j ) )
874 call check( __line__, phi_lo(ks+1,i ,j ) )
875 call check( __line__, phi_lo(ks ,i-1,j ) )
876 call check( __line__, phi_lo(ks ,i+1,j ) )
877 call check( __line__, phi_lo(ks ,i ,j+1) )
878 call check( __line__, phi_lo(ks ,i ,j-1) )
879 call check( __line__, phi_in(ke ,i ,j ) )
880 call check( __line__, phi_in(ke-1,i ,j ) )
881 call check( __line__, phi_in(ke ,i-1,j ) )
882 call check( __line__, phi_in(ke ,i+1,j ) )
883 call check( __line__, phi_in(ke ,i ,j+1) )
884 call check( __line__, phi_in(ke ,i ,j-1) )
885 call check( __line__, phi_lo(ke ,i ,j ) )
886 call check( __line__, phi_lo(ke-1,i ,j ) )
887 call check( __line__, phi_lo(ke ,i-1,j ) )
888 call check( __line__, phi_lo(ke ,i+1,j ) )
889 call check( __line__, phi_lo(ke ,i ,j+1) )
890 call check( __line__, phi_lo(ke ,i ,j-1) )
892 qmax = max( phi_in(ks ,i ,j ), &
893 phi_in(ks+1,i ,j ), &
894 phi_in(ks ,i+1,j ), &
895 phi_in(ks ,i-1,j ), &
896 phi_in(ks ,i ,j+1), &
897 phi_in(ks ,i ,j-1), &
899 phi_lo(ks+1,i ,j ), &
900 phi_lo(ks ,i+1,j ), &
901 phi_lo(ks ,i-1,j ), &
902 phi_lo(ks ,i ,j+1), &
904 qmin = min( phi_in(ks ,i ,j ), &
905 phi_in(ks+1,i ,j ), &
906 phi_in(ks ,i+1,j ), &
907 phi_in(ks ,i-1,j ), &
908 phi_in(ks ,i ,j+1), &
909 phi_in(ks ,i ,j-1), &
911 phi_lo(ks+1,i ,j ), &
912 phi_lo(ks ,i+1,j ), &
913 phi_lo(ks ,i-1,j ), &
914 phi_lo(ks ,i ,j+1), &
916 qjmns(ks,i,j) = ( phi_lo(ks,i,j) - qmin ) * dens(ks,i,j)
917 qjpls(ks,i,j) = ( qmax - phi_lo(ks,i,j) ) * dens(ks,i,j)
919 qmax = max( phi_in(ke ,i ,j ), &
920 phi_in(ke-1,i ,j ), &
921 phi_in(ke ,i+1,j ), &
922 phi_in(ke ,i-1,j ), &
923 phi_in(ke ,i ,j+1), &
924 phi_in(ke ,i ,j-1), &
926 phi_lo(ke-1,i ,j ), &
927 phi_lo(ke ,i+1,j ), &
928 phi_lo(ke ,i-1,j ), &
929 phi_lo(ke ,i ,j+1), &
931 qmin = min( phi_in(ke ,i ,j ), &
932 phi_in(ke-1,i ,j ), &
933 phi_in(ke ,i-1,j ), &
934 phi_in(ke ,i+1,j ), &
935 phi_in(ke ,i ,j+1), &
936 phi_in(ke ,i ,j-1), &
938 phi_lo(ke-1,i ,j ), &
939 phi_lo(ke ,i-1,j ), &
940 phi_lo(ke ,i+1,j ), &
941 phi_lo(ke ,i ,j+1), &
943 qjpls(ke,i,j) = ( qmax - phi_lo(ke,i,j) ) * dens(ke,i,j)
944 qjmns(ke,i,j) = ( phi_lo(ke,i,j) - qmin ) * dens(ke,i,j)
948 k = iundef; i = iundef; j = iundef
960 call check( __line__, pjpls(k,i,j) )
961 call check( __line__, qjpls(k,i,j) )
964 zerosw = 0.5_rp - sign( 0.5_rp, pjpls(k,i,j)-epsilon )
965 rjpls(k,i,j) = min( 1.0_rp, qjpls(k,i,j) * ( 1.0_rp-zerosw ) / ( pjpls(k,i,j)-zerosw ) )
970 k = iundef; i = iundef; j = iundef
979 call check( __line__, pjmns(k,i,j) )
980 call check( __line__, qjmns(k,i,j) )
983 zerosw = 0.5_rp - sign( 0.5_rp, pjmns(k,i,j)-epsilon )
984 rjmns(k,i,j) = min( 1.0_rp, qjmns(k,i,j) * ( 1.0_rp-zerosw ) / ( pjmns(k,i,j)-zerosw ) )
989 k = iundef; i = iundef; j = iundef
995 call comm_vars8( rjpls(:,:,:), 1 )
996 call comm_vars8( rjmns(:,:,:), 2 )
997 call comm_wait ( rjpls(:,:,:), 1 )
998 call comm_wait ( rjmns(:,:,:), 2 )
1000 do jjs = js, je, jblock
1002 do iis = is, ie, iblock
1011 call check( __line__, qflx_anti(k,i,j,zdir) )
1012 call check( __line__, rjpls(k ,i,j) )
1013 call check( __line__, rjpls(k+1,i,j) )
1014 call check( __line__, rjmns(k ,i,j) )
1015 call check( __line__, rjmns(k+1,i,j) )
1018 dirsw = 0.5_rp + sign( 0.5_rp, qflx_anti(k,i,j,zdir) )
1019 qflx_anti(k,i,j,zdir) = qflx_anti(k,i,j,zdir) &
1021 - min( rjpls(k+1,i,j),rjmns(k ,i,j) ) * ( dirsw ) &
1022 - min( rjpls(k ,i,j),rjmns(k+1,i,j) ) * ( 1.0_rp - dirsw ) )
1027 k = iundef; i = iundef; j = iundef
1033 call check( __line__, qflx_anti(ke,i,j,zdir) )
1034 call check( __line__, rjpls(ke ,i,j) )
1035 call check( __line__, rjmns(ke ,i,j) )
1037 qflx_anti(ks-1,i,j,zdir) = 0.0_rp
1038 qflx_anti(ke ,i,j,zdir) = 0.0_rp
1042 k = iundef; i = iundef; j = iundef
1045 if ( .not. twod )
then
1046 if ( iis == is )
then
1057 call check( __line__, qflx_anti(k,i,j,xdir) )
1058 call check( __line__, rjpls(k,i ,j) )
1059 call check( __line__, rjpls(k,i+1,j) )
1060 call check( __line__, rjmns(k,i ,j) )
1061 call check( __line__, rjmns(k,i+1,j) )
1064 dirsw = 0.5_rp + sign( 0.5_rp, qflx_anti(k,i,j,xdir) )
1065 qflx_anti(k,i,j,xdir) = qflx_anti(k,i,j,xdir) &
1067 - min( rjpls(k,i+1,j),rjmns(k,i ,j) ) * ( dirsw ) &
1068 - min( rjpls(k,i ,j),rjmns(k,i+1,j) ) * ( 1.0_rp - dirsw ) )
1073 k = iundef; i = iundef; j = iundef
1077 if ( jjs == js )
then
1087 call check( __line__, qflx_anti(k,i,j,ydir) )
1088 call check( __line__, rjpls(k,i,j+1) )
1089 call check( __line__, rjpls(k,i,j ) )
1090 call check( __line__, rjmns(k,i,j ) )
1091 call check( __line__, rjmns(k,i,j+1) )
1094 dirsw = 0.5_rp + sign( 0.5_rp, qflx_anti(k,i,j,ydir) )
1095 qflx_anti(k,i,j,ydir) = qflx_anti(k,i,j,ydir) &
1097 - min( rjpls(k,i,j+1),rjmns(k,i,j ) ) * ( dirsw ) &
1098 - min( rjpls(k,i,j ),rjmns(k,i,j+1) ) * ( 1.0_rp - dirsw ) )
1103 k = iundef; i = iundef; j = iundef