SCALE-RM
scale_atmos_phy_tb_hybrid.F90
Go to the documentation of this file.
1 !-------------------------------------------------------------------------------
14 !-------------------------------------------------------------------------------
15 #include "inc_openmp.h"
17  !-----------------------------------------------------------------------------
18  !
19  !++ used modules
20  !
21  use scale_precision
22  use scale_stdio
23  use scale_prof
25  use scale_tracer
26 
27 #ifdef DEBUG
28  use scale_debug, only: &
29  check
30  use scale_const, only: &
31  undef => const_undef, &
32  iundef => const_undef2
33 #endif
34  !-----------------------------------------------------------------------------
35  implicit none
36  private
37  !-----------------------------------------------------------------------------
38  !
39  !++ Public procedure
40  !
43  public :: atmos_phy_tb_hybrid
44 
45  !-----------------------------------------------------------------------------
46  !
47  !++ Public parameters & variables
48  !
49  !-----------------------------------------------------------------------------
50  !
51  !++ Private procedure
52  !
53  abstract interface
54  subroutine tb( &
55  qflx_sgs_momz, qflx_sgs_momx, qflx_sgs_momy, &
56  qflx_sgs_rhot, qflx_sgs_rhoq, &
57  RHOQ_t, nu_C, Ri, Pr, &
58  MOMZ, MOMX, MOMY, RHOT, DENS, QTRC, N2, &
59  SFLX_MW, SFLX_MU, SFLX_MV, SFLX_SH, SFLX_Q, &
60  GSQRT, J13G, J23G, J33G, MAPF, dt )
61  use scale_precision
63  use scale_tracer
64  implicit none
65 
66  real(RP), intent(out) :: qflx_sgs_momz(KA,IA,JA,3)
67  real(RP), intent(out) :: qflx_sgs_momx(KA,IA,JA,3)
68  real(RP), intent(out) :: qflx_sgs_momy(KA,IA,JA,3)
69  real(RP), intent(out) :: qflx_sgs_rhot(KA,IA,JA,3)
70  real(RP), intent(out) :: qflx_sgs_rhoq(KA,IA,JA,3,QA)
71 
72  real(RP), intent(inout) :: RHOQ_t (KA,IA,JA,QA) ! tendency of rho * QTRC
73 
74  real(RP), intent(out) :: nu_C (KA,IA,JA) ! eddy viscosity (center)
75  real(RP), intent(out) :: Ri (KA,IA,JA) ! Richardson number
76  real(RP), intent(out) :: Pr (KA,IA,JA) ! Prantle number
77 
78  real(RP), intent(in) :: MOMZ (KA,IA,JA)
79  real(RP), intent(in) :: MOMX (KA,IA,JA)
80  real(RP), intent(in) :: MOMY (KA,IA,JA)
81  real(RP), intent(in) :: RHOT (KA,IA,JA)
82  real(RP), intent(in) :: DENS (KA,IA,JA)
83  real(RP), intent(in) :: QTRC (KA,IA,JA,QA)
84  real(RP), intent(in) :: N2 (KA,IA,JA)
85 
86  real(RP), intent(in) :: SFLX_MW (IA,JA)
87  real(RP), intent(in) :: SFLX_MU (IA,JA)
88  real(RP), intent(in) :: SFLX_MV (IA,JA)
89  real(RP), intent(in) :: SFLX_SH (IA,JA)
90  real(RP), intent(in) :: SFLX_Q (IA,JA,QA)
91 
92  real(RP), intent(in) :: GSQRT (KA,IA,JA,7)
93  real(RP), intent(in) :: J13G (KA,IA,JA,7)
94  real(RP), intent(in) :: J23G (KA,IA,JA,7)
95  real(RP), intent(in) :: J33G
96  real(RP), intent(in) :: MAPF (IA,JA,2,4)
97  real(DP), intent(in) :: dt
98  end subroutine tb
99 
100  subroutine su( &
101  CDZ, CDX, CDY, CZ )
102  use scale_precision
103  use scale_grid_index
104  use scale_tracer
105  implicit none
106 
107  real(RP), intent(in) :: CDZ(KA)
108  real(RP), intent(in) :: CDX(IA)
109  real(RP), intent(in) :: CDY(JA)
110  real(RP), intent(in) :: CZ (KA,IA,JA)
111  end subroutine su
112  end interface
113 
114  procedure(tb), pointer :: sgs_tb => null()
115  procedure(tb), pointer :: pbl_tb => null()
116 
117  procedure(su), pointer :: sgs_tb_setup => null()
118  procedure(su), pointer :: pbl_tb_setup => null()
119 
120  !-----------------------------------------------------------------------------
121  !
122  !++ Private parameters & variables
123  !
124  real(RP), private :: atmos_phy_tb_hybrid_sgs_dx = 100.0_rp
125  real(RP), private :: atmos_phy_tb_hybrid_pbl_dx = 500.0_rp
126 
127  real(RP), private, allocatable :: frac_sgs (:,:)
128  real(RP), private, allocatable :: frac_pbl (:,:)
129  real(RP), private, allocatable :: frac_sgs_tke(:,:)
130  real(RP), private, allocatable :: frac_pbl_tke(:,:)
131 
132  integer, private :: i_tke_sgs, i_tke_pbl
133 
134  !-----------------------------------------------------------------------------
135 contains
136  !-----------------------------------------------------------------------------
138  subroutine atmos_phy_tb_hybrid_config( &
139  TB_TYPE, &
140  I_TKE_out )
141  use scale_process, only: &
143  use scale_atmos_phy_tb_smg, only: &
147  use scale_atmos_phy_tb_mynn, only: &
151  implicit none
152 
153  character(len=*), intent(in) :: tb_type
154  integer, intent(out) :: i_tke_out
155 
156  character(len=H_SHORT) :: atmos_phy_tb_hybrid_sgs_type = 'SMAGORINSKY'
157  character(len=H_SHORT) :: atmos_phy_tb_hybrid_pbl_type = 'MYNN'
158 
159  namelist / param_atmos_phy_tb_hybrid / &
160  atmos_phy_tb_hybrid_sgs_dx, &
161  atmos_phy_tb_hybrid_pbl_dx, &
162  atmos_phy_tb_hybrid_sgs_type, &
163  atmos_phy_tb_hybrid_pbl_type
164 
165  integer :: ierr
166  !---------------------------------------------------------------------------
167 
168  if( io_l ) write(io_fid_log,*)
169  if( io_l ) write(io_fid_log,*) '++++++ Module[Turbulence Tracer] / Categ[ATMOS PHYSICS] / Origin[SCALElib]'
170  if( io_l ) write(io_fid_log,*) '*** Tracers for SGS-parameterization hybrid Model'
171 
172  if ( tb_type /= 'HYBRID' ) then
173  write(*,*) 'xxx ATMOS_PHY_TB_TYPE is not HYBRID. Check!'
174  call prc_mpistop
175  endif
176 
177  !--- read namelist
178  rewind(io_fid_conf)
179  read(io_fid_conf,nml=param_atmos_phy_tb_hybrid,iostat=ierr)
180  if( ierr < 0 ) then !--- missing
181  if( io_l ) write(io_fid_log,*) '*** Not found namelist. Default used.'
182  elseif( ierr > 0 ) then !--- fatal error
183  write(*,*) 'xxx Not appropriate names in namelist PARAM_ATMOS_PHY_TB_HYBRID. Check!'
184  call prc_mpistop
185  endif
186  if( io_nml ) write(io_fid_nml,nml=param_atmos_phy_tb_hybrid)
187 
188  select case( atmos_phy_tb_hybrid_sgs_type )
189  case('SMAGORINSKY')
191  atmos_phy_tb_hybrid_sgs_type, &
192  i_tke_sgs )
194  sgs_tb_setup => atmos_phy_tb_smg_setup
195  case default
196  write(*,*) 'xxx ATMOS_PHY_TB_HYBRID_SGS_TYPE is invalid'
197  call prc_mpistop
198  end select
199 
200  select case( atmos_phy_tb_hybrid_pbl_type )
201  case('MYNN')
203  atmos_phy_tb_hybrid_pbl_type, &
204  i_tke_pbl )
205  pbl_tb => atmos_phy_tb_mynn
206  pbl_tb_setup => atmos_phy_tb_mynn_setup
207  case default
208  write(*,*) 'xxx ATMOS_PHY_TB_HYBRID_PBL_TYPE is invalid'
209  call prc_mpistop
210  end select
211 
212  i_tke_out = i_tke_pbl
213 
214  return
215  end subroutine atmos_phy_tb_hybrid_config
216 
217  !-----------------------------------------------------------------------------
219  subroutine atmos_phy_tb_hybrid_setup( &
220  CDZ, CDX, CDY, CZ )
221  implicit none
222 
223  real(RP), intent(in) :: cdz(ka)
224  real(RP), intent(in) :: cdx(ia)
225  real(RP), intent(in) :: cdy(ja)
226  real(RP), intent(in) :: cz (ka,ia,ja)
227 
228  real(RP) :: dxy
229 
230  integer :: i, j
231  !---------------------------------------------------------------------------
232 
233  if( io_l ) write(io_fid_log,*)
234  if( io_l ) write(io_fid_log,*) '++++++ Module[Turbulence] / Categ[ATMOS PHYSICS] / Origin[SCALElib]'
235  if( io_l ) write(io_fid_log,*) '*** SGS-parameterization hybrid Model'
236 
237  call sgs_tb_setup( cdz, cdx, cdy, cz )
238  call pbl_tb_setup( cdz, cdx, cdy, cz )
239 
240  allocate( frac_sgs(ia,ja) )
241  allocate( frac_pbl(ia,ja) )
242  allocate( frac_sgs_tke(ia,ja) )
243  allocate( frac_pbl_tke(ia,ja) )
244 
245  do j = 1, ja
246  do i = 1, ia
247  dxy = sqrt( 0.5_rp * ( cdx(i)**2 + cdy(j)**2 ) )
248 
249  frac_pbl(i,j) = ( dxy - atmos_phy_tb_hybrid_sgs_dx ) / ( atmos_phy_tb_hybrid_pbl_dx - atmos_phy_tb_hybrid_sgs_dx )
250  frac_pbl(i,j) = min( 1.0_rp, max( 0.0_rp, frac_pbl(i,j) ) )
251  frac_sgs(i,j) = 1.0_rp - frac_pbl(i,j)
252  end do
253  end do
254 
255  return
256  end subroutine atmos_phy_tb_hybrid_setup
257 
258  !-----------------------------------------------------------------------------
259  subroutine atmos_phy_tb_hybrid( &
260  qflx_sgs_momz, qflx_sgs_momx, qflx_sgs_momy, &
261  qflx_sgs_rhot, qflx_sgs_rhoq, &
262  RHOQ_t, &
263  Nu, Ri, Pr, &
264  MOMZ, MOMX, MOMY, RHOT, DENS, QTRC, N2, &
265  SFLX_MW, SFLX_MU, SFLX_MV, SFLX_SH, SFLX_Q, &
266  GSQRT, J13G, J23G, J33G, MAPF, dt )
268  use scale_grid_index
269  use scale_tracer
270  use scale_const, only: &
271  grav => const_grav
272  implicit none
273 
274  real(RP), intent(out) :: qflx_sgs_momz(ka,ia,ja,3)
275  real(RP), intent(out) :: qflx_sgs_momx(ka,ia,ja,3)
276  real(RP), intent(out) :: qflx_sgs_momy(ka,ia,ja,3)
277  real(RP), intent(out) :: qflx_sgs_rhot(ka,ia,ja,3)
278  real(RP), intent(out) :: qflx_sgs_rhoq(ka,ia,ja,3,qa)
279 
280  real(RP), intent(inout) :: rhoq_t (ka,ia,ja,qa) ! tendency of rho * QTRC
281 
282  real(RP), intent(out) :: nu (ka,ia,ja) ! eddy viscosity (center)
283  real(RP), intent(out) :: pr (ka,ia,ja) ! Plandtle number
284  real(RP), intent(out) :: ri (ka,ia,ja) ! Richardson number
285 
286  real(RP), intent(in) :: momz (ka,ia,ja)
287  real(RP), intent(in) :: momx (ka,ia,ja)
288  real(RP), intent(in) :: momy (ka,ia,ja)
289  real(RP), intent(in) :: rhot (ka,ia,ja)
290  real(RP), intent(in) :: dens (ka,ia,ja)
291  real(RP), intent(in) :: qtrc (ka,ia,ja,qa)
292  real(RP), intent(in) :: n2 (ka,ia,ja)
293 
294  real(RP), intent(in) :: sflx_mw (ia,ja)
295  real(RP), intent(in) :: sflx_mu (ia,ja)
296  real(RP), intent(in) :: sflx_mv (ia,ja)
297  real(RP), intent(in) :: sflx_sh (ia,ja)
298  real(RP), intent(in) :: sflx_q (ia,ja,qa)
299 
300  real(RP), intent(in) :: gsqrt (ka,ia,ja,7)
301  real(RP), intent(in) :: j13g (ka,ia,ja,7)
302  real(RP), intent(in) :: j23g (ka,ia,ja,7)
303  real(RP), intent(in) :: j33g
304  real(RP), intent(in) :: mapf (ia,ja,2,4)
305  real(DP), intent(in) :: dt
306 
307  real(RP) :: w_qflx_sgs_momz(ka,ia,ja,3,2)
308  real(RP) :: w_qflx_sgs_momx(ka,ia,ja,3,2)
309  real(RP) :: w_qflx_sgs_momy(ka,ia,ja,3,2)
310  real(RP) :: w_qflx_sgs_rhot(ka,ia,ja,3,2)
311  real(RP) :: w_qflx_sgs_rhoq(ka,ia,ja,3,qa,2)
312 
313  real(RP) :: w_nu (ka,ia,ja,2)
314  real(RP) :: w_ri (ka,ia,ja,2)
315  real(RP) :: w_pr (ka,ia,ja,2)
316 
317  integer :: k, i, j, iq
318  !---------------------------------------------------------------------------
319 
320  call sgs_tb( w_qflx_sgs_momz(:,:,:,:,1), w_qflx_sgs_momx(:,:,:,:,1), & ! [OUT]
321  w_qflx_sgs_momy(:,:,:,:,1), w_qflx_sgs_rhot(:,:,:,:,1), & ! [OUT]
322  w_qflx_sgs_rhoq(:,:,:,:,:,1), & ! [OUT]
323  rhoq_t, & ! [INOUT]
324  w_nu(:,:,:,1), w_ri(:,:,:,1), w_pr(:,:,:,1), & ! [OUT]
325  momz, momx, momy, rhot, dens, qtrc, n2, & ! [IN]
326  sflx_mw, sflx_mu, sflx_mv, sflx_sh, sflx_q, & ! [IN]
327  gsqrt, j13g, j23g, j33g, mapf, dt ) ! [IN]
328 
329  call pbl_tb( w_qflx_sgs_momz(:,:,:,:,2), w_qflx_sgs_momx(:,:,:,:,2), & ! [OUT]
330  w_qflx_sgs_momy(:,:,:,:,2), w_qflx_sgs_rhot(:,:,:,:,2), & ! [OUT]
331  w_qflx_sgs_rhoq(:,:,:,:,:,2), & ! [OUT]
332  rhoq_t, & ! [INOUT]
333  w_nu(:,:,:,2), w_ri(:,:,:,2), w_pr(:,:,:,2), & ! [OUT]
334  momz, momx, momy, rhot, dens, qtrc, n2, & ! [IN]
335  sflx_mw, sflx_mu, sflx_mv, sflx_sh, sflx_q, & ! [IN]
336  gsqrt, j13g, j23g, j33g, mapf, dt ) ! [IN]
337 
338  !$omp parallel do default(none) private(i,j,k) OMP_SCHEDULE_ collapse(2) &
339  !$omp shared(JA,IA,KS,KE,qflx_sgs_momz,w_qflx_sgs_momz,frac_sgs,frac_pbl)
340  do j = 1, ja
341  do i = 1, ia
342  do k = ks, ke
343  qflx_sgs_momz(k,i,j,zdir) = w_qflx_sgs_momz(k,i,j,zdir,1) * frac_sgs(i,j) &
344  + w_qflx_sgs_momz(k,i,j,zdir,2) * frac_pbl(i,j)
345  qflx_sgs_momz(k,i,j,xdir) = w_qflx_sgs_momz(k,i,j,xdir,1)
346  qflx_sgs_momz(k,i,j,ydir) = w_qflx_sgs_momz(k,i,j,ydir,1)
347  end do
348  end do
349  end do
350 
351  do j = 1, ja
352  do i = 1, ia
353  do k = ks, ke
354  qflx_sgs_momx(k,i,j,zdir) = w_qflx_sgs_momx(k,i,j,zdir,1) * frac_sgs(i,j) &
355  + w_qflx_sgs_momx(k,i,j,zdir,2) * frac_pbl(i,j)
356  qflx_sgs_momx(k,i,j,xdir) = w_qflx_sgs_momx(k,i,j,xdir,1)
357  qflx_sgs_momx(k,i,j,ydir) = w_qflx_sgs_momx(k,i,j,ydir,1)
358  end do
359  end do
360  end do
361 
362  do j = 1, ja
363  do i = 1, ia
364  do k = ks, ke
365  qflx_sgs_momy(k,i,j,zdir) = w_qflx_sgs_momy(k,i,j,zdir,1) * frac_sgs(i,j) &
366  + w_qflx_sgs_momy(k,i,j,zdir,2) * frac_pbl(i,j)
367  qflx_sgs_momy(k,i,j,xdir) = w_qflx_sgs_momy(k,i,j,xdir,1)
368  qflx_sgs_momy(k,i,j,ydir) = w_qflx_sgs_momy(k,i,j,ydir,1)
369  end do
370  end do
371  end do
372 
373  do j = 1, ja
374  do i = 1, ia
375  do k = ks, ke
376  qflx_sgs_rhot(k,i,j,zdir) = w_qflx_sgs_rhot(k,i,j,zdir,1) * frac_sgs(i,j) &
377  + w_qflx_sgs_rhot(k,i,j,zdir,2) * frac_pbl(i,j)
378  qflx_sgs_rhot(k,i,j,xdir) = w_qflx_sgs_rhot(k,i,j,xdir,1)
379  qflx_sgs_rhot(k,i,j,ydir) = w_qflx_sgs_rhot(k,i,j,ydir,1)
380  end do
381  end do
382  end do
383 
384  !$omp parallel do default(none) &
385  !$omp shared(JA,IA,KS,KE,qflx_sgs_rhoq,w_qflx_sgs_rhoq,frac_sgs,frac_pbl,QA,I_TKE_SGS) &
386  !$omp shared(I_TKE_PBL,TRACER_ADVC) &
387  !$omp private(i,j,k,iq) OMP_SCHEDULE_
388  do iq = 1, qa
389 
390  if ( iq == i_tke_sgs .or. iq == i_tke_pbl ) then
391  qflx_sgs_rhoq(:,:,:,:,iq) = 0.0_rp
392  cycle
393  end if
394  if ( .not. tracer_advc(iq) ) cycle
395 
396  do j = 1, ja
397  do i = 1, ia
398  do k = ks, ke
399  qflx_sgs_rhoq(k,i,j,zdir,iq) = w_qflx_sgs_rhoq(k,i,j,zdir,iq,1) * frac_sgs(i,j) &
400  + w_qflx_sgs_rhoq(k,i,j,zdir,iq,2) * frac_pbl(i,j)
401  qflx_sgs_rhoq(k,i,j,xdir,iq) = w_qflx_sgs_rhoq(k,i,j,xdir,iq,1)
402  qflx_sgs_rhoq(k,i,j,ydir,iq) = w_qflx_sgs_rhoq(k,i,j,ydir,iq,1)
403  end do
404  end do
405  end do
406 
407  end do
408 
409  do j = 1, ja
410  do i = 1, ia
411  do k = ks, ke
412  nu(k,i,j) = w_nu(k,i,j,1) * frac_sgs(i,j) &
413  + w_nu(k,i,j,2) * frac_pbl(i,j)
414  end do
415  end do
416  end do
417 
418  do j = 1, ja
419  do i = 1, ia
420  do k = ks, ke
421  ri(k,i,j) = w_ri(k,i,j,1) * frac_sgs(i,j) &
422  + w_ri(k,i,j,2) * frac_pbl(i,j)
423  end do
424  end do
425  end do
426 
427  do j = 1, ja
428  do i = 1, ia
429  do k = ks, ke
430  pr(k,i,j) = w_pr(k,i,j,1) * frac_sgs(i,j) &
431  + w_pr(k,i,j,2) * frac_pbl(i,j)
432  end do
433  end do
434  end do
435 
436  return
437  end subroutine atmos_phy_tb_hybrid
438 
439 end module scale_atmos_phy_tb_hybrid
module DEBUG
Definition: scale_debug.F90:13
module ATMOSPHERE / Physics Turbulence
subroutine, public prc_mpistop
Abort MPI.
logical, public io_l
output log or not? (this process)
Definition: scale_stdio.F90:61
integer, parameter, public zdir
module STDIO
Definition: scale_stdio.F90:12
integer, parameter, public ydir
integer, public ke
end point of inner domain: z, local
integer, parameter, public xdir
subroutine, public atmos_phy_tb_smg_setup(CDZ, CDX, CDY, CZ)
Setup.
integer, public qa
logical, dimension(qa_max), public tracer_advc
subroutine, public atmos_phy_tb_mynn_setup(CDZ, CDX, CDY, CZ)
Setup.
subroutine, public check(current_line, v)
Undefined value checker.
Definition: scale_debug.F90:58
real(rp), public const_undef
Definition: scale_const.F90:43
module grid index
logical, public io_nml
output log or not? (for namelist, this process)
Definition: scale_stdio.F90:62
module TRACER
module ATMOSPHERE / Physics Turbulence
integer, public ia
of whole cells: x, local, with HALO
integer, public ka
of whole cells: z, local, with HALO
subroutine, public atmos_phy_tb_hybrid_config(TB_TYPE, I_TKE_out)
Config.
subroutine, public atmos_phy_tb_mynn(qflx_sgs_momz, qflx_sgs_momx, qflx_sgs_momy, qflx_sgs_rhot, qflx_sgs_rhoq, RHOQ_t, Nu, Ri, Pr, MOMZ, MOMX, MOMY, RHOT, DENS, QTRC, N2_in, SFLX_MW, SFLX_MU, SFLX_MV, SFLX_SH, SFLX_Q, GSQRT, J13G, J23G, J33G, MAPF, dt)
real(rp), public const_grav
standard acceleration of gravity [m/s2]
Definition: scale_const.F90:48
integer, parameter, public const_undef2
undefined value (INT2)
Definition: scale_const.F90:40
subroutine, public atmos_phy_tb_mynn_config(TYPE_TB, I_TKE_out)
Config.
module PROCESS
subroutine, public atmos_phy_tb_hybrid_setup(CDZ, CDX, CDY, CZ)
Setup.
module CONSTANT
Definition: scale_const.F90:14
integer, public ks
start point of inner domain: z, local
subroutine, public atmos_phy_tb_smg(qflx_sgs_momz, qflx_sgs_momx, qflx_sgs_momy, qflx_sgs_rhot, qflx_sgs_rhoq, RHOQ_t, Nu, Ri, Pr, MOMZ, MOMX, MOMY, RHOT, DENS, QTRC, N2, SFLX_MW, SFLX_MU, SFLX_MV, SFLX_SH, SFLX_Q, GSQRT, J13G, J23G, J33G, MAPF, dt)
module profiler
Definition: scale_prof.F90:10
module PRECISION
integer, public io_fid_conf
Config file ID.
Definition: scale_stdio.F90:55
subroutine, public atmos_phy_tb_hybrid(qflx_sgs_momz, qflx_sgs_momx, qflx_sgs_momy, qflx_sgs_rhot, qflx_sgs_rhoq, RHOQ_t, Nu, Ri, Pr, MOMZ, MOMX, MOMY, RHOT, DENS, QTRC, N2, SFLX_MW, SFLX_MU, SFLX_MV, SFLX_SH, SFLX_Q, GSQRT, J13G, J23G, J33G, MAPF, dt)
integer, public io_fid_log
Log file ID.
Definition: scale_stdio.F90:56
module ATMOSPHERE / Physics Turbulence
subroutine, public atmos_phy_tb_smg_config(TYPE_TB, I_TKE_out)
Config.
integer, public io_fid_nml
Log file ID (only for output namelist)
Definition: scale_stdio.F90:57
integer, public ja
of whole cells: y, local, with HALO