1 !WRF:MODEL_LAYER:PHYSICS
3 !==============================================================================
5 ! Copyright 2009. Lawrence Livermore National Security, LLC. All rights reserved.
6 ! This work was produced at the Lawrence Livermore National Laboratory (LLNL) under
7 ! contract no. DE-AC52-07NA27344 (Contract 44) between the U.S. Department of Energy (DOE)
8 ! and Lawrence Livermore National Security, LLC (LLNS) for the operation of LLNL. Copyright
9 ! is reserved to Lawrence Livermore National Security, LLC for purposes of controlled
10 ! dissemination, commercialization through formal licensing, or other disposition under
11 ! terms of Contract 44; DOE policies, regulations and orders; and U.S. statutes. The rights
12 ! of the Federal Government are reserved under Contract 44.
15 ! This work was prepared as an account of work sponsored by an agency of the United States
16 ! Government. Neither the United States Government nor Lawrence Livermore National
17 ! Security, LLC nor any of their employees, makes any warranty, express or implied, or
18 ! assumes any liability or responsibility for the accuracy, completeness, or usefulness of
19 ! any information, apparatus, product, or process disclosed, or represents that its use
20 ! would not infringe privately-owned rights. Reference herein to any specific commercial
21 ! products, process, or service by trade name, trademark, manufacturer or otherwise does
22 ! not necessarily constitute or imply its endorsement, recommendation, or favoring by the
23 ! United States Government or Lawrence Livermore National Security, LLC. The views and
24 ! opinions of authors expressed herein do not necessarily state or reflect those of the
25 ! United States Government or Lawrence Livermore National Security, LLC, and shall not be
26 ! used for advertising or product endorsement purposes.
28 ! LICENSING REQUIREMENTS
29 ! Any use, reproduction, modification, or distribution of this software or documentation
30 ! for commercial purposes requires a license from Lawrence Livermore National Security,
31 ! LLC. Contact: Lawrence Livermore National Laboratory, Industrial Partnerships Office,
32 ! P.O. Box 808, L-795, Livermore, CA 94551
34 !=============================================================================
36 ! Modification History:
38 ! Implemented 12/2009 by Jeff Mirocha, jmirocha@llnl.gov
40 !=============================================================================
44 USE module_configure, ONLY : grid_config_rec_type
48 REAL :: c1, c2, c3, ce, cb, cs ! global model parameters
52 !=============================================================================
54 SUBROUTINE calc_mij_constants( )
56 !-----------------------------------------------------------------------------
58 ! PURPOSE: Compute constants for Mij calculations
60 !-----------------------------------------------------------------------------
64 REAL :: sk, pi ! local model parameters
66 !-----------------------------------------------------------------------------
72 cs = ( ( 8.0*( 1.0+cb ) )/( 27.0*pi**2 ) )**0.5
73 c1 = ( ( 960.0**0.5 )*cb )/( 7.0*( 1.0+cb )*sk )
75 ce = ( ( 8.0*pi/27.0 )**( 1.0/3.0 ) )*cs**( 4.0/3.0 )
76 c3 = ( ( 27.0/( 8.0*pi ) )**( 1.0/3.0 ) )*cs**( 2.0/3.0 )
80 END SUBROUTINE calc_mij_constants
82 !=============================================================================
84 SUBROUTINE calc_smnsmn( smnsmn, &
88 ids, ide, jds, jde, kds, kde, &
89 ims, ime, jms, jme, kms, kme, &
90 ips, ipe, jps, jpe, kps, kpe, &
91 its, ite, jts, jte, kts, kte )
93 !-----------------------------------------------------------------------------
95 ! PURPOSE: Compute Smn*Smn = S11^2 + S22^2 + S33^2 + 2*(S12^2 + S13^2 +S23^2)
97 !-----------------------------------------------------------------------------
101 REAL, DIMENSION( ims:ime, kms:kme, jms:jme ), INTENT( OUT ) &
102 :: smnsmn ! Smn*Smn (s-2)
104 REAL, DIMENSION( ims:ime, kms:kme, jms:jme ), INTENT( IN ) &
105 :: s11 & ! 2*deformation element 11 (s-1)
106 , s22 & ! 2*deformation element 22 (s-1)
107 , s33 & ! 2*deformation element 33 (s-1)
108 , s12 & ! 2*deformation element 12 (s-1)
109 , s13 & ! 2*deformation element 13 (s-1)
110 , s23 ! 2*deformation element 23 (s-1)
112 TYPE (grid_config_rec_type), INTENT( IN ) &
115 INTEGER, INTENT( IN ) &
116 :: ids, ide, jds, jde, kds, kde, &
117 ims, ime, jms, jme, kms, kme, &
118 ips, ipe, jps, jpe, kps, kpe, &
119 its, ite, jts, jte, kts, kte
121 ! LOCAL VARIABLES ------------------------------------------------------------
125 INTEGER :: i, j, k, i_start, i_end, j_start, j_end, ktf
127 !-----------------------------------------------------------------------------
130 ! taken from /dyn_em/module_diffusion_em.F SUBROUTINE smag_km
132 !-----------------------------------------------------------------------------
137 i_end = MIN(ite,ide-1)
139 j_end = MIN(jte,jde-1)
141 IF ( config_flags%open_xs .or. config_flags%specified .or. &
142 config_flags%nested) i_start = MAX(ids+1,its)
143 IF ( config_flags%open_xe .or. config_flags%specified .or. &
144 config_flags%nested) i_end = MIN(ide-2,ite)
145 IF ( config_flags%open_ys .or. config_flags%specified .or. &
146 config_flags%nested) j_start = MAX(jds+1,jts)
147 IF ( config_flags%open_ye .or. config_flags%specified .or. &
148 config_flags%nested) j_end = MIN(jde-2,jte)
149 IF ( config_flags%periodic_x ) i_start = its
150 IF ( config_flags%periodic_x ) i_end = MIN( ite, ide-1 )
152 !-----------------------------------------------------------------------------
154 ! Below the 0.25 factor divides the incoming WRF deformations,
155 ! which are multiplied by a factor of 2, by 2
161 smnsmn(i,k,j) = 0.25*( s11(i,k,j)*s11(i,k,j) + &
162 s22(i,k,j)*s22(i,k,j) + &
163 s33(i,k,j)*s33(i,k,j) )
169 ! Below the 0.125 factor accounts for the four-point averaging (0.25)
170 ! and divides the incoming WRF deformation elements by 2 (0.5)
176 tmp = 0.125*( s12(i ,k,j) + s12(i ,k,j+1) + &
177 s12(i+1,k,j) + s12(i+1,k,j+1) )
178 smnsmn(i,k,j) = smnsmn(i,k,j) + 2.0*tmp*tmp
188 tmp = 0.125*( s13(i ,k+1,j) + s13(i ,k,j) + &
189 s13(i+1,k+1,j) + s13(i+1,k,j) )
190 smnsmn(i,k,j) = smnsmn(i,k,j) + 2.0*tmp*tmp
200 tmp = 0.125*( s23(i,k+1,j ) + s23(i,k,j ) + &
201 s23(i,k+1,j+1) + s23(i,k,j+1) )
202 smnsmn(i,k,j) = smnsmn(i,k,j) + 2.0*tmp*tmp
210 END SUBROUTINE calc_smnsmn
212 !=============================================================================
214 SUBROUTINE calc_mii( m11, m22, m33, &
217 r12, r13, r23, smnsmn, &
220 ids, ide, jds, jde, kds, kde, &
221 ims, ime, jms, jme, kms, kme, &
222 ips, ipe, jps, jpe, kps, kpe, &
223 its, ite, jts, jte, kts, kte )
225 !-----------------------------------------------------------------------------
227 ! PURPOSE: Compute Mij for i = j
229 !-----------------------------------------------------------------------------
233 REAL, DIMENSION( ims:ime, kms:kme, jms:jme ), INTENT( OUT ) &
234 :: m11 & ! NBA stress element 11 (m2 s-2)
235 , m22 & ! NBA stress element 22 (m2 s-2)
236 , m33 ! NBA stress element 33 (m2 s-2)
238 REAL, DIMENSION( ims:ime, kms:kme, jms:jme ), INTENT( IN ) &
239 :: s11 & ! 2*deformation element 11 (s-1)
240 , s22 & ! 2*deformation element 22 (s-1)
241 , s33 & ! 2*deformation element 33 (s-1)
242 , s12 & ! 2*deformation element 12 (s-1)
243 , s13 & ! 2*deformation element 13 (s-1)
244 , s23 & ! 2*deformation element 23 (s-1)
245 , r12 & ! 2*rotation element 12 (s-1)
246 , r13 & ! 2*rotation element 13 (s-1)
247 , r23 & ! 2*rotation element 23 (s-1)
248 , smnsmn & ! Smn*Smn (s-2)
249 , tke & ! tke (m2 s-2)
250 , rdzw ! 1/dz at w-levels (m-1)
253 :: dx & ! grid spacing in x (m)
254 , dy ! grid spacing in y (m)
256 TYPE (grid_config_rec_type), INTENT( IN ) &
259 INTEGER, INTENT( IN ) &
260 :: ids, ide, jds, jde, kds, kde, &
261 ims, ime, jms, jme, kms, kme, &
262 ips, ipe, jps, jpe, kps, kpe, &
263 its, ite, jts, jte, kts, kte
265 ! LOCAL VARIABLES ------------------------------------------------------------
267 REAL, DIMENSION( its-1:ite+1, kms:kme, jts-1:jte+1 ) & ! sij/2, rij/2
278 REAL, DIMENSION( its-1:ite+1, kms:kme, jts-1:jte+1 ) & ! projected to c
288 INTEGER :: i, j, k, i_start, i_end, j_start, j_end, ktf, is_ext, js_ext
290 !-----------------------------------------------------------------------------
293 ! taken from /dyn_em/module_diffusion_em.F SUBROUTINE cal_titau_11_22_33
295 !-----------------------------------------------------------------------------
297 ktf = MIN( kte, kde-1 )
304 IF ( config_flags%open_xs .OR. config_flags%specified .OR. &
305 config_flags%nested) i_start = MAX( ids+1, its )
306 IF ( config_flags%open_xe .OR. config_flags%specified .OR. &
307 config_flags%nested) i_end = MIN( ide-1, ite )
308 IF ( config_flags%open_ys .OR. config_flags%specified .OR. &
309 config_flags%nested) j_start = MAX( jds+1, jts )
310 IF ( config_flags%open_ye .OR. config_flags%specified .OR. &
311 config_flags%nested) j_end = MIN( jde-1, jte )
312 IF ( config_flags%periodic_x ) i_start = its
313 IF ( config_flags%periodic_x ) i_end = ite
318 i_start = i_start - is_ext
319 j_start = j_start - js_ext
321 !-----------------------------------------------------------------------------
323 ! Divide WRF deformations, which are multiplied by 2, by 2
325 !-----------------------------------------------------------------------------
331 ss11(i,k,j)=s11(i,k,j)/2.0
332 ss22(i,k,j)=s22(i,k,j)/2.0
333 ss33(i,k,j)=s33(i,k,j)/2.0
334 ss12(i,k,j)=s12(i,k,j)/2.0
335 ss13(i,k,j)=s13(i,k,j)/2.0
336 ss23(i,k,j)=s23(i,k,j)/2.0
337 rr12(i,k,j)=r12(i,k,j)/2.0
338 rr13(i,k,j)=r13(i,k,j)/2.0
339 rr23(i,k,j)=r23(i,k,j)/2.0
356 !-----------------------------------------------------------------------------
358 ! Project variables to c
360 !-----------------------------------------------------------------------------
362 DO j = j_start, j_end
364 DO i = i_start, i_end
366 ss12c(i,k,j) = 0.25*( ss12(i ,k ,j ) + ss12(i ,k ,j+1) + &
367 ss12(i+1,k ,j ) + ss12(i+1,k ,j+1) )
369 rr12c(i,k,j) = 0.25*( rr12(i ,k ,j ) + rr12(i ,k ,j+1) + &
370 rr12(i+1,k ,j ) + rr12(i+1,k ,j+1) )
372 ss13c(i,k,j) = 0.25*( ss13(i ,k+1,j ) + ss13(i ,k ,j ) + &
373 ss13(i+1,k+1,j ) + ss13(i+1,k ,j ) )
375 rr13c(i,k,j) = 0.25*( rr13(i ,k+1,j ) + rr13(i ,k ,j ) + &
376 rr13(i+1,k+1,j ) + rr13(i+1,k ,j ) )
378 ss23c(i,k,j) = 0.25*( ss23(i ,k+1,j ) + ss23(i ,k ,j ) + &
379 ss23(i ,k+1,j+1) + ss23(i ,k ,j+1) )
381 rr23c(i,k,j) = 0.25*( rr23(i ,k+1,j ) + rr23(i ,k ,j ) + &
382 rr23(i ,k+1,j+1) + rr23(i ,k ,j+1) )
388 !-----------------------------------------------------------------------------
390 ! Calculate M11, M22 and M33
392 !-----------------------------------------------------------------------------
394 IF ( config_flags%sfs_opt .EQ. 1 ) THEN !Do not use TKE
400 delta = ( dx * dy / rdzw(i,k,j) )**0.33333333
401 a = -1.0*( cs*delta )**2
403 m11(i,k,j) = a*( 2.0*sqrt( 2.0*smnsmn(i,k,j) )*ss11(i,k,j) &
404 + c1*( ss11(i,k,j) *ss11(i,k,j) &
405 + ss12c(i,k,j)*ss12c(i,k,j) &
406 + ss13c(i,k,j)*ss13c(i,k,j) &
407 - smnsmn(i,k,j)/3.0 &
409 + c2*( -2.0*( ss12c(i,k,j)*rr12c(i,k,j) &
410 + ss13c(i,k,j)*rr13c(i,k,j) &
415 m22(i,k,j) = a*( 2.0*sqrt( 2.0*smnsmn(i,k,j) )*ss22(i,k,j) &
416 + c1*( ss22(i,k,j) *ss22(i,k,j) &
417 + ss12c(i,k,j)*ss12c(i,k,j) &
418 + ss23c(i,k,j)*ss23c(i,k,j) &
419 - smnsmn(i,k,j)/3.0 &
421 + c2*( 2.0*( ss12c(i,k,j)*rr12c(i,k,j) &
422 - ss23c(i,k,j)*rr23c(i,k,j) &
427 m33(i,k,j) = a*( 2.0*sqrt( 2.0*smnsmn(i,k,j) )*ss33(i,k,j) &
428 + c1*( ss33(i,k,j) *ss33(i,k,j) &
429 + ss13c(i,k,j)*ss13c(i,k,j) &
430 + ss23c(i,k,j)*ss23c(i,k,j) &
431 - smnsmn(i,k,j)/3.0 &
433 + c2*( 2.0*( ss13c(i,k,j)*rr13c(i,k,j) &
434 + ss23c(i,k,j)*rr23c(i,k,j) &
443 ELSE !(config_flags%sfs_opt .EQ. 2) Use TKE
449 delta = ( dx * dy / rdzw(i,k,j) )**0.33333333
453 m11(i,k,j) = a*( 2.0*sqrt( tke(i,k,j) )*ss11(i,k,j) &
455 c1*( ss11(i,k,j) *ss11(i,k,j) &
456 + ss12c(i,k,j)*ss12c(i,k,j) &
457 + ss13c(i,k,j)*ss13c(i,k,j) &
458 - smnsmn(i,k,j)/3.0 &
460 + c2*( -2.0*( ss12c(i,k,j)*rr12c(i,k,j) &
461 + ss13c(i,k,j)*rr13c(i,k,j) &
467 m22(i,k,j) = a*( 2.0*sqrt( tke(i,k,j) )*ss22(i,k,j) &
469 c1*( ss22(i,k,j) *ss22(i,k,j) &
470 + ss12c(i,k,j)*ss12c(i,k,j) &
471 + ss23c(i,k,j)*ss23c(i,k,j) &
472 - smnsmn(i,k,j)/3.0 &
474 + c2*( 2.0*( ss12c(i,k,j)*rr12c(i,k,j) &
475 - ss23c(i,k,j)*rr23c(i,k,j) &
481 m33(i,k,j) = a*( 2.0*sqrt( tke(i,k,j) )*ss33(i,k,j) &
483 c1*( ss33(i,k,j) *ss33(i,k,j) &
484 + ss13c(i,k,j)*ss13c(i,k,j) &
485 + ss23c(i,k,j)*ss23c(i,k,j) &
486 - smnsmn(i,k,j)/3.0 &
488 + c2*( 2.0*( ss13c(i,k,j)*rr13c(i,k,j) &
489 + ss23c(i,k,j)*rr23c(i,k,j) &
504 END SUBROUTINE calc_mii
506 !=============================================================================
508 SUBROUTINE calc_m12( m12, &
511 r12, r13, r23, smnsmn, &
514 ids, ide, jds, jde, kds, kde, &
515 ims, ime, jms, jme, kms, kme, &
516 ips, ipe, jps, jpe, kps, kpe, &
517 its, ite, jts, jte, kts, kte )
519 !-----------------------------------------------------------------------------
521 ! PURPOSE: Compute M12
523 !-----------------------------------------------------------------------------
527 REAL, DIMENSION( ims:ime, kms:kme, jms:jme ), INTENT( OUT ) &
528 :: m12 ! NBA stress element 12 (m2 s-2)
530 REAL, DIMENSION( ims:ime, kms:kme, jms:jme ), INTENT( IN ) &
531 :: s11 & ! 2*deformation element 11 (s-1)
532 , s22 & ! 2*deformation element 22 (s-1)
533 , s12 & ! 2*deformation element 12 (s-1)
534 , s13 & ! 2*deformation element 13 (s-1)
535 , s23 & ! 2*deformation element 23 (s-1)
536 , r12 & ! 2*rotation element 12 (s-1)
537 , r13 & ! 2*rotation element 13 (s-1)
538 , r23 & ! 2*rotation element 23 (s-1)
539 , smnsmn & ! Smn*Smn (s-2)
540 , tke & ! tke (m2 s-2)
541 , rdzw ! 1/dz at w-levels (m-1)
544 :: dx & ! grid spacing in x (m)
545 , dy ! grid spacing in y (m)
547 TYPE (grid_config_rec_type), INTENT( IN ) &
550 INTEGER, INTENT( IN ) &
551 :: ids, ide, jds, jde, kds, kde, &
552 ims, ime, jms, jme, kms, kme, &
553 ips, ipe, jps, jpe, kps, kpe, &
554 its, ite, jts, jte, kts, kte
556 ! LOCAL VARIABLES ------------------------------------------------------------
558 REAL, DIMENSION( its-1:ite+1, kms:kme, jts-1:jte+1 ) & ! sij/2, rij/2
569 REAL, DIMENSION( its-1:ite+1, kms:kme, jts-1:jte+1 ) & ! projected to d
581 INTEGER :: i, j, k, i_start, i_end, j_start, j_end, ktf, je_ext, ie_ext
583 !-----------------------------------------------------------------------------
586 ! taken from /dyn_em/module_diffusion_em.F SUBROUTINE cal_titau_12_21
588 !-----------------------------------------------------------------------------
590 ktf = MIN( kte, kde-1 )
592 ! Needs one more point in the x and y directions.
599 IF ( config_flags%open_xs .OR. config_flags%specified .OR. &
600 config_flags%nested ) i_start = MAX( ids+1, its )
601 IF ( config_flags%open_xe .OR. config_flags%specified .OR. &
602 config_flags%nested ) i_end = MIN( ide-1, ite )
603 IF ( config_flags%open_ys .OR. config_flags%specified .OR. &
604 config_flags%nested ) j_start = MAX( jds+1, jts )
605 IF ( config_flags%open_ye .OR. config_flags%specified .OR. &
606 config_flags%nested ) j_end = MIN( jde-1, jte )
607 IF ( config_flags%periodic_x ) i_start = its
608 IF ( config_flags%periodic_x ) i_end = ite
613 i_end = i_end + ie_ext
614 j_end = j_end + je_ext
616 !-----------------------------------------------------------------------------
618 ! Divide WRF deformations, which are multiplied by 2, by 2
620 !-----------------------------------------------------------------------------
626 ss11(i,k,j)=s11(i,k,j)/2.0
627 ss22(i,k,j)=s22(i,k,j)/2.0
628 ss12(i,k,j)=s12(i,k,j)/2.0
629 ss13(i,k,j)=s13(i,k,j)/2.0
630 ss23(i,k,j)=s23(i,k,j)/2.0
631 rr12(i,k,j)=r12(i,k,j)/2.0
632 rr13(i,k,j)=r13(i,k,j)/2.0
633 rr23(i,k,j)=r23(i,k,j)/2.0
650 !-----------------------------------------------------------------------------
652 ! Project variables to d
654 !-----------------------------------------------------------------------------
656 DO j = j_start, j_end
658 DO i = i_start, i_end
660 tked(i,k,j) = 0.25*( tke(i-1,k ,j ) + tke(i ,k ,j ) + &
661 tke(i-1,k ,j-1) + tke(i ,k ,j-1) )
663 smnsmnd(i,k,j) = 0.25*( smnsmn(i-1,k ,j ) + smnsmn(i ,k ,j ) + &
664 smnsmn(i-1,k ,j-1) + smnsmn(i ,k ,j-1) )
666 ss11d(i,k,j) = 0.25*( ss11(i-1,k ,j ) + ss11(i ,k ,j ) + &
667 ss11(i-1,k ,j-1) + ss11(i ,k ,j-1) )
669 ss22d(i,k,j) = 0.25*( ss22(i-1,k ,j ) + ss22(i ,k ,j ) + &
670 ss22(i-1,k ,j-1) + ss22(i ,k ,j-1) )
672 ss13d(i,k,j) = 0.25*( ss13(i ,k+1,j ) + ss13(i ,k+1,j-1) + &
673 ss13(i ,k ,j ) + ss13(i ,k ,j-1) )
675 rr13d(i,k,j) = 0.25*( rr13(i ,k+1,j ) + rr13(i ,k+1,j-1) + &
676 rr13(i ,k ,j ) + rr13(i ,k ,j-1) )
678 ss23d(i,k,j) = 0.25*( ss23(i ,k+1,j ) + ss23(i-1,k+1,j ) + &
679 ss23(i ,k ,j ) + ss23(i-1,k ,j ) )
681 rr23d(i,k,j) = 0.25*( rr23(i ,k+1,j ) + rr23(i-1,k+1,j ) + &
682 rr23(i ,k ,j ) + rr23(i-1,k ,j ) )
688 !-----------------------------------------------------------------------------
692 !-----------------------------------------------------------------------------
694 IF ( config_flags%sfs_opt .EQ. 1 ) THEN !Do not use TKE
700 delta = ( dx * dy / rdzw(i,k,j) )**0.33333333
701 a = -1.0*( cs*delta )**2
703 m12(i,k,j) = a*( 2.0*sqrt( 2.0*smnsmnd(i,k,j) )*ss12(i,k,j) &
704 + c1*( ss11d(i,k,j)*ss12(i,k,j) &
705 + ss22d(i,k,j)*ss12(i,k,j) &
706 + ss13d(i,k,j)*ss23d(i,k,j) &
708 + c2*( ss11d(i,k,j)*rr12(i,k,j) &
709 - ss13d(i,k,j)*rr23d(i,k,j) &
710 - ss22d(i,k,j)*rr12(i,k,j) &
711 - ss23d(i,k,j)*rr13d(i,k,j) &
719 ELSE !(config_flags%sfs_opt .EQ. 2) Use TKE
725 delta = ( dx * dy / rdzw(i,k,j) )**0.33333333
729 m12(i,k,j) = a*( 2.0*sqrt( tked(i,k,j) )*s12(i,k,j) &
731 c1*( ss11d(i,k,j)*ss12(i,k,j) &
732 + ss22d(i,k,j)*ss12(i,k,j) &
733 + ss13d(i,k,j)*ss23d(i,k,j) &
735 + c2*( ss11d(i,k,j)*rr12(i,k,j) &
736 - ss13d(i,k,j)*rr23d(i,k,j) &
737 - ss22d(i,k,j)*rr12(i,k,j) &
738 - ss23d(i,k,j)*rr13d(i,k,j) &
750 END SUBROUTINE calc_m12
752 !=============================================================================
754 SUBROUTINE calc_m13( m13, &
757 r12, r13, r23, smnsmn, &
761 ids, ide, jds, jde, kds, kde, &
762 ims, ime, jms, jme, kms, kme, &
763 ips, ipe, jps, jpe, kps, kpe, &
764 its, ite, jts, jte, kts, kte )
766 !-----------------------------------------------------------------------------
768 ! PURPOSE: Compute M13
770 !-----------------------------------------------------------------------------
774 REAL, DIMENSION( ims:ime, kms:kme, jms:jme ), INTENT( OUT ) &
777 REAL, DIMENSION( ims:ime, kms:kme, jms:jme ), INTENT( IN ) &
778 :: s11 & ! 2*deformation element 11 (s-1)
779 , s33 & ! 2*deformation element 33 (s-1)
780 , s12 & ! 2*deformation element 12 (s-1)
781 , s13 & ! 2*deformation element 13 (s-1)
782 , s23 & ! 2*deformation element 23 (s-1)
783 , r12 & ! 2*rotation element 12 (s-1)
784 , r13 & ! 2*rotation element 13 (s-1)
785 , r23 & ! 2*rotation element 23 (s-1)
786 , smnsmn & ! Smn*Smn (s-2)
787 , tke & ! tke (m2 s-2)
788 , rdzw ! 1/dz at w-levels (m-1)
791 :: dx & ! grid spacing in x (m)
792 , dy ! grid spacing in y (m)
794 REAL, DIMENSION( kms:kme ), INTENT( IN ) &
795 :: fnm & ! vertical interpolation coefficients
798 TYPE (grid_config_rec_type), INTENT( IN ) &
801 INTEGER, INTENT( IN ) &
802 :: ids, ide, jds, jde, kds, kde, &
803 ims, ime, jms, jme, kms, kme, &
804 ips, ipe, jps, jpe, kps, kpe, &
805 its, ite, jts, jte, kts, kte
807 ! LOCAL VARIABLES ------------------------------------------------------------
809 REAL, DIMENSION( its-1:ite+1, kms:kme, jts-1:jte+1 ) & ! sij/2, rij/2
819 REAL, DIMENSION( its-1:ite+1, kms:kme, jts-1:jte+1 ) & ! projected to e
831 INTEGER :: i, j, k, i_start, i_end, j_start, j_end, ktf, ie_ext
833 !-----------------------------------------------------------------------------
836 ! taken from /dyn_em/module_diffusion_em.F SUBROUTINE cal_titau_13_31
838 !-----------------------------------------------------------------------------
840 ktf = MIN( kte, kde-1 )
842 ! Find ide-1 and jde-1 for averaging to p point.
847 j_end = MIN( jte, jde-1 )
849 IF ( config_flags%open_xs .OR. config_flags%specified .OR. &
850 config_flags%nested) i_start = MAX( ids+1, its )
851 IF ( config_flags%open_xe .OR. config_flags%specified .OR. &
852 config_flags%nested) i_end = MIN( ide-1, ite )
853 IF ( config_flags%open_ys .OR. config_flags%specified .OR. &
854 config_flags%nested) j_start = MAX( jds+1, jts )
855 IF ( config_flags%open_ye .OR. config_flags%specified .OR. &
856 config_flags%nested) j_end = MIN( jde-2, jte )
857 IF ( config_flags%periodic_x ) i_start = its
858 IF ( config_flags%periodic_x ) i_end = ite
861 i_end = i_end + ie_ext
863 !-----------------------------------------------------------------------------
865 ! Divide WRF deformations, which are multiplied by 2, by 2
867 !-----------------------------------------------------------------------------
873 ss11(i,k,j)=s11(i,k,j)/2.0
874 ss33(i,k,j)=s33(i,k,j)/2.0
875 ss12(i,k,j)=s12(i,k,j)/2.0
876 ss13(i,k,j)=s13(i,k,j)/2.0
877 ss23(i,k,j)=s23(i,k,j)/2.0
878 rr12(i,k,j)=r12(i,k,j)/2.0
879 rr13(i,k,j)=r13(i,k,j)/2.0
880 rr23(i,k,j)=r23(i,k,j)/2.0
886 !-----------------------------------------------------------------------------
888 ! Project variables to e
890 !-----------------------------------------------------------------------------
892 DO j = j_start, j_end
894 DO i = i_start, i_end
896 tkee(i,k,j) = 0.5*( fnm(k)*( tke(i,k ,j) + tke(i-1,k ,j) ) + &
897 fnp(k)*( tke(i,k-1,j) + tke(i-1,k-1,j) ) )
899 smnsmne(i,k,j) = 0.5*( fnm(k)*( smnsmn(i,k ,j) + smnsmn(i-1,k ,j) ) + &
900 fnp(k)*( smnsmn(i,k-1,j) + smnsmn(i-1,k-1,j) ) )
902 ss11e(i,k,j) = 0.5*( fnm(k)*( ss11(i ,k ,j ) + ss11(i-1,k ,j ) ) + &
903 fnp(k)*( ss11(i ,k-1,j ) + ss11(i-1,k-1,j ) ) )
905 ss33e(i,k,j) = 0.5*( fnm(k)*( ss33(i ,k ,j ) + ss33(i-1,k ,j ) ) + &
906 fnp(k)*( ss33(i ,k-1,j ) + ss33(i-1,k-1,j ) ) )
908 ss12e(i,k,j) = 0.5*( fnm(k)*( ss12(i ,k ,j ) + ss12(i ,k ,j+1) ) + &
909 fnp(k)*( ss12(i ,k-1,j ) + ss12(i ,k-1,j+1) ) )
911 rr12e(i,k,j) = 0.5*( fnm(k)*( rr12(i ,k ,j ) + rr12(i ,k ,j+1) ) + &
912 fnp(k)*( rr12(i ,k-1,j ) + rr12(i ,k-1,j+1) ) )
914 ss23e(i,k,j) = 0.25*( ss23(i ,k ,j) + ss23(i ,k ,j+1) + &
915 ss23(i-1,k ,j) + ss23(i-1,k ,j+1) )
917 rr23e(i,k,j) = 0.25*( rr23(i ,k ,j) + rr23(i ,k ,j+1) + &
918 rr23(i-1,k ,j) + rr23(i-1,k ,j+1) )
924 !-----------------------------------------------------------------------------
928 !-----------------------------------------------------------------------------
931 IF ( config_flags%sfs_opt .EQ. 1 ) THEN !Do not use TKE
937 delta = ( dx * dy / rdzw(i,k,j) )**0.33333333
938 a = -1.0*( cs*delta )**2
940 m13(i,k,j) = a*( 2.0*sqrt( 2.0*smnsmne(i,k,j) )*ss13(i,k,j) &
941 + c1*( ss11e(i,k,j)*ss13(i,k,j) &
942 + ss12e(i,k,j)*ss23e(i,k,j) &
943 + ss13(i,k,j)*ss33e(i,k,j) &
945 + c2*( ss11e(i,k,j)*rr13(i,k,j) &
946 + ss12e(i,k,j)*rr23e(i,k,j) &
947 - ss23e(i,k,j)*rr12e(i,k,j) &
948 - ss33e(i,k,j)*rr13(i,k,j) &
956 ELSE !(config_flags%sfs_opt .EQ. 2) Use TKE
962 delta = ( dx * dy / rdzw(i,k,j) )**0.33333333
966 m13(i,k,j) = a*( 2.0*sqrt( tkee(i,k,j) )*ss13(i,k,j) &
968 c1*( ss11e(i,k,j)*ss13(i,k,j) &
969 + ss12e(i,k,j)*ss23e(i,k,j) &
970 + ss13(i,k,j)*ss33e(i,k,j) &
972 + c2*( ss11e(i,k,j)*rr13(i,k,j) &
973 + ss12e(i,k,j)*rr23e(i,k,j) &
974 - ss23e(i,k,j)*rr12e(i,k,j) &
975 - ss33e(i,k,j)*rr13(i,k,j) &
988 END SUBROUTINE calc_m13
990 !=============================================================================
992 SUBROUTINE calc_m23( m23, &
995 r12, r13, r23, smnsmn, &
999 ids, ide, jds, jde, kds, kde, &
1000 ims, ime, jms, jme, kms, kme, &
1001 ips, ipe, jps, jpe, kps, kpe, &
1002 its, ite, jts, jte, kts, kte )
1004 !-----------------------------------------------------------------------------
1006 ! PURPOSE: Compute M23
1008 !-----------------------------------------------------------------------------
1012 REAL, DIMENSION( ims:ime, kms:kme, jms:jme ), INTENT( OUT ) &
1015 REAL, DIMENSION( ims:ime, kms:kme, jms:jme ), INTENT( IN ) &
1016 :: s22 & ! 2*deformation element 22 (s-1)
1017 , s33 & ! 2*deformation element 33 (s-1)
1018 , s12 & ! 2*deformation element 12 (s-1)
1019 , s13 & ! 2*deformation element 13 (s-1)
1020 , s23 & ! 2*deformation element 23 (s-1)
1021 , r12 & ! 2*rotation element 12 (s-1)
1022 , r13 & ! 2*rotation element 13 (s-1)
1023 , r23 & ! 2*rotation element 23 (s-1)
1024 , smnsmn & ! Smn*Smn (s-2)
1025 , tke & ! tke (m2 s-2)
1026 , rdzw ! 1/dz at w-levels (m-1)
1028 REAL, INTENT( IN ) &
1029 :: dx & ! grid spacing in x (m)
1030 , dy ! grid spacing in y (m)
1032 REAL, DIMENSION( kms:kme ), INTENT( IN ) &
1033 :: fnm & ! vertical interpolation coefficients
1036 TYPE (grid_config_rec_type), INTENT( IN ) &
1039 INTEGER, INTENT( IN ) &
1040 :: ids, ide, jds, jde, kds, kde, &
1041 ims, ime, jms, jme, kms, kme, &
1042 ips, ipe, jps, jpe, kps, kpe, &
1043 its, ite, jts, jte, kts, kte
1045 ! LOCAL VARIABLES ------------------------------------------------------------
1047 REAL, DIMENSION( its-1:ite+1, kms:kme, jts-1:jte+1 ) & ! sij/2, rij/2
1057 REAL, DIMENSION( its-1:ite+1, kms:kme, jts-1:jte+1 ) & ! projected to f
1069 INTEGER :: i, j, k, i_start, i_end, j_start, j_end, ktf, je_ext
1071 !-----------------------------------------------------------------------------
1074 ! taken from /dyn_em/module_diffusion_em.F SUBROUTINE cal_titau_23_32
1076 !-----------------------------------------------------------------------------
1078 ktf = MIN( kte, kde-1 )
1080 ! Find ide-1 and jde-1 for averaging to p point.
1083 i_end = MIN( ite, ide-1 )
1087 IF ( config_flags%open_xs .OR. config_flags%specified .OR. &
1088 config_flags%nested) i_start = MAX( ids+1, its )
1089 IF ( config_flags%open_xe .OR. config_flags%specified .OR. &
1090 config_flags%nested) i_end = MIN( ide-2, ite )
1091 IF ( config_flags%open_ys .OR. config_flags%specified .OR. &
1092 config_flags%nested) j_start = MAX( jds+1, jts )
1093 IF ( config_flags%open_ye .OR. config_flags%specified .OR. &
1094 config_flags%nested) j_end = MIN( jde-1, jte )
1095 IF ( config_flags%periodic_x ) i_start = its
1096 IF ( config_flags%periodic_x ) i_end = MIN( ite, ide-1 )
1099 j_end = j_end + je_ext
1101 !-----------------------------------------------------------------------------
1103 ! Divide WRF deformations, which are multiplied by 2, by 2
1105 !-----------------------------------------------------------------------------
1107 DO j=j_start-1,j_end
1109 DO i=i_start,i_end+1
1111 ss22(i,k,j)=s22(i,k,j)/2.0
1112 ss33(i,k,j)=s33(i,k,j)/2.0
1113 ss12(i,k,j)=s12(i,k,j)/2.0
1114 ss13(i,k,j)=s13(i,k,j)/2.0
1115 ss23(i,k,j)=s23(i,k,j)/2.0
1116 rr12(i,k,j)=r12(i,k,j)/2.0
1117 rr13(i,k,j)=r13(i,k,j)/2.0
1118 rr23(i,k,j)=r23(i,k,j)/2.0
1124 !-----------------------------------------------------------------------------
1126 ! Project variables to f
1128 !-----------------------------------------------------------------------------
1130 DO j = j_start, j_end
1132 DO i = i_start, i_end
1134 tkef(i,k,j) = 0.5*( fnm(k)*( tke(i ,k ,j ) + tke(i ,k ,j-1) ) + &
1135 fnp(k)*( tke(i ,k-1,j ) + tke(i ,k-1,j-1) ) )
1137 smnsmnf(i,k,j) = 0.5*( fnm(k)*( smnsmn(i ,k ,j ) + smnsmn(i ,k ,j-1) ) + &
1138 fnp(k)*( smnsmn(i ,k-1,j ) + smnsmn(i ,k-1,j-1) ) )
1140 ss22f(i,k,j) = 0.5*( fnm(k)*( ss22(i ,k ,j ) + ss22(i ,k ,j-1) ) + &
1141 fnp(k)*( ss22(i ,k-1,j ) + ss22(i ,k-1,j-1) ) )
1143 ss33f(i,k,j) = 0.5*( fnm(k)*( ss33(i ,k ,j ) + ss33(i ,k ,j-1) ) + &
1144 fnp(k)*( ss33(i ,k-1,j ) + ss33(i ,k-1,j-1) ) )
1146 ss12f(i,k,j) = 0.5*( fnm(k)*( ss12(i ,k ,j ) + ss12(i+1,k ,j ) ) + &
1147 fnp(k)*( ss12(i ,k-1,j ) + ss12(i+1,k-1,j ) ) )
1149 rr12f(i,k,j) = 0.5*( fnm(k)*( rr12(i ,k ,j ) + rr12(i+1,k ,j ) ) + &
1150 fnp(k)*( rr12(i ,k-1,j ) + rr12(i+1,k-1,j ) ) )
1152 ss13f(i,k,j) = 0.25*( ss13(i ,k ,j ) + ss13(i ,k ,j-1) + &
1153 ss13(i+1,k ,j-1) + ss13(i+1,k ,j ) )
1155 rr13f(i,k,j) = 0.25*( rr13(i ,k ,j ) + rr13(i ,k ,j-1) + &
1156 rr13(i+1,k ,j-1) + rr13(i+1,k ,j ) )
1162 !-----------------------------------------------------------------------------
1166 !-----------------------------------------------------------------------------
1168 IF ( config_flags%sfs_opt .EQ. 1 ) THEN !Do not use TKE
1174 delta = ( dx * dy / rdzw(i,k,j) )**0.33333333
1175 a = -1.0*( cs*delta )**2
1177 m23(i,k,j) = a*( 2.0*sqrt( 2.0*smnsmnf(i,k,j) )*ss23(i,k,j) &
1178 + c1*( ss12f(i,k,j)*ss13f(i,k,j) &
1179 + ss22f(i,k,j)*ss23(i,k,j) &
1180 + ss23(i,k,j) *ss33f(i,k,j) &
1182 + c2*( ss12f(i,k,j)*rr13f(i,k,j) &
1183 + ss22f(i,k,j)*rr23(i,k,j) &
1184 + ss13f(i,k,j)*rr12f(i,k,j) &
1185 - ss33f(i,k,j)*rr23(i,k,j) &
1193 ELSE !(config_flags%sfs_opt .EQ. 2) Use TKE
1199 delta = ( dx * dy / rdzw(i,k,j) )**0.33333333
1203 m23(i,k,j) = a*( 2.0*sqrt( tkef(i,k,j) )*ss23(i,k,j) &
1205 c1*( ss12f(i,k,j)*ss13f(i,k,j) &
1206 + ss22f(i,k,j)*ss23(i,k,j) &
1207 + ss23(i,k,j) *ss33f(i,k,j) &
1209 + c2*( ss12f(i,k,j)*rr13f(i,k,j) &
1210 + ss22f(i,k,j)*rr23(i,k,j) &
1211 + ss13f(i,k,j)*rr12f(i,k,j) &
1212 - ss33f(i,k,j)*rr23(i,k,j) &
1225 END SUBROUTINE calc_m23
1227 !=============================================================================
1229 END MODULE module_sfs_nba