SCALE-RM
mod_atmos_phy_tb_driver.f90
Go to the documentation of this file.
1 !-------------------------------------------------------------------------------
12 !-------------------------------------------------------------------------------
13 #include "inc_openmp.h"
15  !-----------------------------------------------------------------------------
16  !
17  !++ used modules
18  !
19  use scale_precision
20  use scale_stdio
21  use scale_prof
23  use scale_tracer
24  !-----------------------------------------------------------------------------
25  implicit none
26  private
27  !-----------------------------------------------------------------------------
28  !
29  !++ Public procedure
30  !
34  public :: atmos_phy_tb_driver
35 
36  !-----------------------------------------------------------------------------
37  !
38  !++ Public parameters & variables
39  !
40  !-----------------------------------------------------------------------------
41  !
42  !++ Private procedure
43  !
44  !-----------------------------------------------------------------------------
45  !
46  !++ Private parameters & variables
47  !
48  !-----------------------------------------------------------------------------
49 contains
50  !-----------------------------------------------------------------------------
53  use scale_atmos_phy_tb, only: &
55  use mod_atmos_admin, only: &
58  implicit none
59  !---------------------------------------------------------------------------
60 
61  if( io_l ) write(io_fid_log,*)
62  if( io_l ) write(io_fid_log,*) '++++++ Module[CONFIG] / Categ[ATMOS PHY_TB] / Origin[SCALE-RM]'
63 
64  if ( atmos_sw_phy_tb ) then
66  end if
67 
68  return
69  end subroutine atmos_phy_tb_driver_config
70 
71  !-----------------------------------------------------------------------------
73  subroutine atmos_phy_tb_driver_setup
74  use scale_grid, only: &
75  cdz => grid_cdz, &
76  cdx => grid_cdx, &
77  cdy => grid_cdy
78  use scale_grid_real, only: &
79  cz => real_cz
80  use scale_atmos_phy_tb, only: &
82  use mod_atmos_admin, only: &
84  use mod_atmos_phy_tb_vars, only: &
85  momz_t_tb => atmos_phy_tb_momz_t
86  implicit none
87 
88  integer :: i, j
89  !---------------------------------------------------------------------------
90 
91  if( io_l ) write(io_fid_log,*)
92  if( io_l ) write(io_fid_log,*) '++++++ Module[DRIVER] / Categ[ATMOS PHY_TB] / Origin[SCALE-RM]'
93 
94  ! initialize
95  do j = js, je
96  do i = is, ie
97  momz_t_tb(ks-1,i,j) = 0.0_rp
98  momz_t_tb(ke ,i,j) = 0.0_rp
99  enddo
100  enddo
101 
102  if ( atmos_sw_phy_tb ) then
103  ! setup library component
104  call atmos_phy_tb_setup( cdz, cdx, cdy, cz ) ! [IN]
105  else
106  if( io_l ) write(io_fid_log,*) '*** this component is never called.'
107  endif
108 
109  return
110  end subroutine atmos_phy_tb_driver_setup
111 
112  !-----------------------------------------------------------------------------
114  subroutine atmos_phy_tb_driver_resume
115  use mod_atmos_admin, only: &
117  implicit none
118 
119  if ( atmos_sw_phy_tb ) then
120 
121  ! run once (only for the diagnostic value)
122  call prof_rapstart('ATM_Turbulence', 1)
123  call atmos_phy_tb_driver( update_flag = .true. )
124  call prof_rapend ('ATM_Turbulence', 1)
125 
126  end if
127 
128  return
129  end subroutine atmos_phy_tb_driver_resume
130 
131  !-----------------------------------------------------------------------------
133  subroutine atmos_phy_tb_driver( update_flag )
134  use scale_gridtrans, only: &
135  gsqrt => gtrans_gsqrt, &
136  j13g => gtrans_j13g, &
137  j23g => gtrans_j23g, &
138  j33g => gtrans_j33g, &
139  mapf => gtrans_mapf
140  use scale_rm_statistics, only: &
142  stat_total
143  use scale_comm, only: &
144  comm_vars8, &
145  comm_wait
146  use scale_history, only: &
147  hist_in
148  use scale_time, only: &
149  dt_tb => time_dtsec_atmos_phy_tb
150  use scale_atmos_phy_tb, only: &
151  atmos_phy_tb, &
152  i_tke
153  use scale_atmos_phy_tb_common, only: &
154  calc_tend_momz => atmos_phy_tb_calc_tend_momz, &
155  calc_tend_momx => atmos_phy_tb_calc_tend_momx, &
156  calc_tend_momy => atmos_phy_tb_calc_tend_momy, &
157  calc_tend_phi => atmos_phy_tb_calc_tend_phi
158  use mod_atmos_vars, only: &
159  dens => dens_av, &
160  momz => momz_av, &
161  momx => momx_av, &
162  momy => momy_av, &
163  rhot => rhot_av, &
164  qtrc => qtrc_av, &
165  n2 => n2, &
166  momz_t => momz_tp, &
167  momx_t => momx_tp, &
168  momy_t => momy_tp, &
169  rhot_t => rhot_tp, &
170  rhoq_t => rhoq_tp
171  use mod_atmos_phy_tb_vars, only: &
172  momz_t_tb => atmos_phy_tb_momz_t, &
173  momx_t_tb => atmos_phy_tb_momx_t, &
174  momy_t_tb => atmos_phy_tb_momy_t, &
175  rhot_t_tb => atmos_phy_tb_rhot_t, &
176  rhoq_t_tb => atmos_phy_tb_rhoq_t
177  use mod_atmos_phy_sf_vars, only: &
178  sflx_mw => atmos_phy_sf_sflx_mw, &
179  sflx_mu => atmos_phy_sf_sflx_mu, &
180  sflx_mv => atmos_phy_sf_sflx_mv, &
181  sflx_sh => atmos_phy_sf_sflx_sh, &
182  sflx_q => atmos_phy_sf_sflx_qtrc
183  implicit none
184 
185  logical, intent(in) :: update_flag
186 
187  ! eddy viscosity/diffusion flux
188  real(RP) :: qflx_momz(ka,ia,ja,3)
189  real(RP) :: qflx_momx(ka,ia,ja,3)
190  real(RP) :: qflx_momy(ka,ia,ja,3)
191  real(RP) :: qflx_rhot(ka,ia,ja,3)
192  real(RP) :: qflx_rhoq(ka,ia,ja,3,qa)
193 
194  real(RP) :: nu(ka,ia,ja) ! eddy viscosity
195  real(RP) :: ri(ka,ia,ja) ! Richardson number
196  real(RP) :: pr(ka,ia,ja) ! Prandtl number
197 
198  real(RP) :: tend(ka,ia,ja)
199  real(RP) :: total ! dummy
200 
201  integer :: jjs, jje
202  integer :: iis, iie
203 
204  integer :: k, i, j, iq
205  !---------------------------------------------------------------------------
206 
207  if ( update_flag ) then
208 
209  rhoq_t_tb = 0.0_rp
210 
211  call atmos_phy_tb( qflx_momz, qflx_momx, qflx_momy, & ! [OUT]
212  qflx_rhot, qflx_rhoq, & ! [OUT]
213  rhoq_t_tb, & ! [INOUT]
214  nu, ri, pr, & ! [OUT]
215  momz, momx, momy, rhot, dens, qtrc, n2, & ! [IN]
216  sflx_mw, sflx_mu, sflx_mv, & ! [IN]
217  sflx_sh, sflx_q, & ! [IN]
218  gsqrt, j13g, j23g, j33g, mapf, & ! [IN]
219  dt_tb ) ! [IN]
220 
221  do jjs = js, je, jblock
222  jje = jjs+jblock-1
223  do iis = is, ie, iblock
224  iie = iis+iblock-1
225  call calc_tend_momz( momz_t_tb, & ! (out)
226  qflx_momz, & ! (in)
227  gsqrt, j13g, j23g, j33g, mapf, & ! (in)
228  iis, iie, jjs, jje ) ! (in)
229  end do
230  end do
231 
232  do jjs = js, je, jblock
233  jje = jjs+jblock-1
234  do iis = is, ie, iblock
235  iie = iis+iblock-1
236  call calc_tend_momx( momx_t_tb, & ! (out)
237  qflx_momx, & ! (in)
238  gsqrt, j13g, j23g, j33g, mapf, & ! (in)
239  iis, iie, jjs, jje ) ! (in)
240  end do
241  end do
242 
243  do jjs = js, je, jblock
244  jje = jjs+jblock-1
245  do iis = is, ie, iblock
246  iie = iis+iblock-1
247  call calc_tend_momy( momy_t_tb, & ! (out)
248  qflx_momy, & ! (in)
249  gsqrt, j13g, j23g, j33g, mapf, & ! (in)
250  iis, iie, jjs, jje ) ! (in)
251  end do
252  end do
253 
254  do jjs = js, je, jblock
255  jje = jjs+jblock-1
256  do iis = is, ie, iblock
257  iie = iis+iblock-1
258  call calc_tend_phi ( rhot_t_tb, & ! (out)
259  qflx_rhot, & ! (in)
260  gsqrt, j13g, j23g, j33g, mapf, & ! (in)
261  iis, iie, jjs, jje ) ! (in)
262  end do
263  end do
264 
265  do iq = 1, qa
266  if ( iq == i_tke .or. .not. tracer_advc(iq) ) cycle
267 
268  do jjs = js, je, jblock
269  jje = jjs+jblock-1
270  do iis = is, ie, iblock
271  iie = iis+iblock-1
272  call calc_tend_phi( tend(:,:,:), & ! (out)
273  qflx_rhoq(:,:,:,:,iq), & ! (in)
274  gsqrt, j13g, j23g, j33g, mapf, & ! (in)
275  iis, iie, jjs, jje ) ! (in)
276 
277  do j = jjs, jje
278  do i = iis, iie
279  do k = ks, ke
280  rhoq_t_tb(k,i,j,iq) = rhoq_t_tb(k,i,j,iq) + tend(k,i,j)
281  end do
282  end do
283  end do
284 
285  end do
286  end do
287  end do
288 
289  call hist_in( nu(:,:,:), 'NU', 'eddy viscosity', 'm2/s' , nohalo=.true. )
290  call hist_in( ri(:,:,:), 'Ri', 'Richardson number', 'NIL' , nohalo=.true. )
291  call hist_in( pr(:,:,:), 'Pr', 'Prantle number', 'NIL' , nohalo=.true. )
292 
293  call hist_in( momz_t_tb(:,:,:), 'MOMZ_t_TB', 'MOMZ tendency (TB)', 'kg/m2/s2', nohalo=.true. )
294  call hist_in( momx_t_tb(:,:,:), 'MOMX_t_TB', 'MOMX tendency (TB)', 'kg/m2/s2', nohalo=.true. )
295  call hist_in( momy_t_tb(:,:,:), 'MOMY_t_TB', 'MOMY tendency (TB)', 'kg/m2/s2', nohalo=.true. )
296  call hist_in( rhot_t_tb(:,:,:), 'RHOT_t_TB', 'RHOT tendency (TB)', 'K.kg/m3/s', nohalo=.true. )
297 
298  do iq = 1, qa
299  call hist_in( rhoq_t_tb(:,:,:,iq), trim(tracer_name(iq))//'_t_TB', &
300  'RHO*'//trim(tracer_name(iq))//' tendency (TB)', 'kg/m3/s', nohalo=.true. )
301  enddo
302 
303  call hist_in( qflx_momz(:,:,:,zdir), 'SGS_ZFLX_MOMZ', 'SGS Z FLUX of MOMZ', 'kg/m/s2', &
304  nohalo=.true.)
305  call hist_in( qflx_momz(:,:,:,xdir), 'SGS_XFLX_MOMZ', 'SGS X FLUX of MOMZ', 'kg/m/s2', &
306  xdim='half', zdim='half', nohalo=.true.)
307  call hist_in( qflx_momz(:,:,:,ydir), 'SGS_YFLX_MOMZ', 'SGS Y FLUX of MOMZ', 'kg/m/s2', &
308  ydim='half', zdim='half', nohalo=.true.)
309 
310  call hist_in( qflx_momx(:,:,:,zdir), 'SGS_ZFLX_MOMX', 'SGS Z FLUX of MOMX', 'kg/m/s2', &
311  xdim='half', zdim='half', nohalo=.true.)
312  call hist_in( qflx_momx(:,:,:,xdir), 'SGS_XFLX_MOMX', 'SGS X FLUX of MOMX', 'kg/m/s2', &
313  nohalo=.true.)
314  call hist_in( qflx_momx(:,:,:,ydir), 'SGS_YFLX_MOMX', 'SGS Y FLUX of MOMX', 'kg/m/s2', &
315  xdim='half', ydim='half', nohalo=.true.)
316 
317  call hist_in( qflx_momy(:,:,:,zdir), 'SGS_ZFLX_MOMY', 'SGS Z FLUX of MOMY', 'kg/m/s2', &
318  ydim='half', zdim='half', nohalo=.true.)
319  call hist_in( qflx_momy(:,:,:,xdir), 'SGS_XFLX_MOMY', 'SGS X FLUX of MOMY', 'kg/m/s2', &
320  xdim='half', ydim='half', nohalo=.true.)
321  call hist_in( qflx_momy(:,:,:,ydir), 'SGS_YFLX_MOMY', 'SGS Y FLUX of MOMY', 'kg/m/s2', &
322  nohalo=.true.)
323 
324  call hist_in( qflx_rhot(:,:,:,zdir), 'SGS_ZFLX_RHOT', 'SGS Z FLUX of RHOT', 'K*kg/m2/s', &
325  zdim='half', nohalo=.true.)
326  call hist_in( qflx_rhot(:,:,:,xdir), 'SGS_XFLX_RHOT', 'SGS X FLUX of RHOT', 'K*kg/m2/s', &
327  xdim='half', nohalo=.true.)
328  call hist_in( qflx_rhot(:,:,:,ydir), 'SGS_YFLX_RHOT', 'SGS Y FLUX of RHOT', 'K*kg/m2/s', &
329  ydim='half', nohalo=.true.)
330 
331 
332  do iq = 1, qa
333  if ( iq == i_tke .or. .not. tracer_advc(iq) ) cycle
334 
335  call hist_in( qflx_rhoq(:,:,:,zdir,iq), &
336  'SGS_ZFLX_'//trim(tracer_name(iq)), 'SGS Z FLUX of '//trim(tracer_name(iq)), 'kg/m2/s', &
337  zdim='half', nohalo=.true.)
338  call hist_in( qflx_rhoq(:,:,:,xdir,iq), &
339  'SGS_XFLX_'//trim(tracer_name(iq)), 'SGS X FLUX of '//trim(tracer_name(iq)), 'kg/m2/s', &
340  xdim='half', nohalo=.true.)
341  call hist_in( qflx_rhoq(:,:,:,ydir,iq), &
342  'SGS_YFLX_'//trim(tracer_name(iq)), 'SGS Y FLUX of '//trim(tracer_name(ia)), 'kg/m2/s', &
343  ydim='half', nohalo=.true.)
344  end do
345 
346  if ( statistics_checktotal ) then
347  call stat_total( total, momz_t_tb(:,:,:), 'MOMZ_t_TB' )
348  call stat_total( total, momx_t_tb(:,:,:), 'MOMX_t_TB' )
349  call stat_total( total, momy_t_tb(:,:,:), 'MOMY_t_TB' )
350  call stat_total( total, rhot_t_tb(:,:,:), 'RHOT_t_TB' )
351  call stat_total( total, nu(:,:,:), 'Nu' )
352  call stat_total( total, ri(:,:,:), 'Ri' )
353  call stat_total( total, pr(:,:,:), 'Pr' )
354 
355  do iq = 1, qa
356  call stat_total( total, rhoq_t_tb(:,:,:,iq), trim(tracer_name(iq))//'_t_TB' )
357  enddo
358  endif
359 
360  endif
361 
362  !$omp parallel do default(none) private(i,j,k) OMP_SCHEDULE_ collapse(2) &
363  !$omp shared(JS,JE,IS,IE,KS,KE,MOMZ_t,MOMZ_t_TB,MOMX_t,MOMX_t_TB,MOMY_t,MOMY_t_TB,RHOT_t,RHOT_t_TB)
364  do j = js, je
365  do i = is, ie
366  do k = ks, ke
367  momz_t(k,i,j) = momz_t(k,i,j) + momz_t_tb(k,i,j)
368  momx_t(k,i,j) = momx_t(k,i,j) + momx_t_tb(k,i,j)
369  momy_t(k,i,j) = momy_t(k,i,j) + momy_t_tb(k,i,j)
370  rhot_t(k,i,j) = rhot_t(k,i,j) + rhot_t_tb(k,i,j)
371  enddo
372  enddo
373  enddo
374 
375  !$omp parallel do private(i,j,k) OMP_SCHEDULE_ collapse(3)
376  do iq = 1, qa
377  do j = js, je
378  do i = is, ie
379  do k = ks, ke
380  rhoq_t(k,i,j,iq) = rhoq_t(k,i,j,iq) + rhoq_t_tb(k,i,j,iq)
381  enddo
382  enddo
383  enddo
384  enddo
385 
386  return
387  end subroutine atmos_phy_tb_driver
388 
389 end module mod_atmos_phy_tb_driver
module ATMOS admin
integer, public is
start point of inner domain: x, local
logical, public statistics_checktotal
calc&report variable totals to logfile?
real(rp), dimension(:,:,:), allocatable, target, public momz
subroutine, public atmos_phy_tb_calc_tend_momz(MOMZ_t_TB, QFLX_MOMZ, GSQRT, J13G, J23G, J33G, MAPF, IIS, IIE, JJS, JJE)
integer, public je
end point of inner domain: y, local
real(rp), dimension(:,:,:), allocatable, public atmos_phy_tb_momx_t
real(rp), dimension(:,:,:), allocatable, public atmos_phy_sf_sflx_qtrc
real(rp), dimension(:,:,:), allocatable, public atmos_phy_tb_rhot_t
real(rp), dimension(:,:), allocatable, public atmos_phy_sf_sflx_mw
subroutine, public atmos_phy_tb_driver_config
Config.
real(rp), dimension(:,:,:), allocatable, target, public rhot
real(rp), dimension(:,:,:,:), allocatable, public gtrans_j23g
(2,3) element of Jacobian matrix * {G}^1/2
real(rp), dimension(:,:,:), allocatable, public momy_tp
module ATMOSPHERE / Physics Turbulence
integer, public iblock
block size for cache blocking: x
subroutine, public atmos_phy_tb_calc_tend_momy(MOMY_t_TB, QFLX_MOMY, GSQRT, J13G, J23G, J33G, MAPF, IIS, IIE, JJS, JJE)
logical, public io_l
output log or not? (this process)
Definition: scale_stdio.F90:61
integer, parameter, public zdir
procedure(tb), pointer, public atmos_phy_tb
module ATMOSPHERIC Variables
real(rp), dimension(:,:,:,:), pointer, public qtrc_av
real(rp), dimension(:,:,:), allocatable, target, public momx
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
real(rp), public gtrans_j33g
(3,3) element of Jacobian matrix * {G}^1/2
real(rp), dimension(:,:,:), allocatable, public rhot_tp
integer, public qa
logical, dimension(qa_max), public tracer_advc
real(rp), dimension(:,:,:), allocatable, public real_cz
geopotential height [m] (cell center)
real(rp), dimension(:,:,:), allocatable, target, public dens
real(rp), dimension(:,:), allocatable, public atmos_phy_sf_sflx_mv
character(len=h_short), dimension(qa_max), public tracer_name
module Statistics
module grid index
subroutine, public atmos_phy_tb_calc_tend_phi(phi_t_TB, QFLX_phi, GSQRT, J13G, J23G, J33G, MAPF, IIS, IIE, JJS, JJE)
module ATMOSPHERIC Surface Variables
real(rp), dimension(:,:,:), pointer, public momx_av
logical, public atmos_sw_phy_tb
real(rp), dimension(:,:,:,:), allocatable, public gtrans_mapf
map factor
module TRACER
integer, public ia
of whole cells: x, local, with HALO
subroutine, public atmos_phy_tb_calc_tend_momx(MOMX_t_TB, QFLX_MOMX, GSQRT, J13G, J23G, J33G, MAPF, IIS, IIE, JJS, JJE)
module GRIDTRANS
module GRID (real space)
integer, public ka
of whole cells: z, local, with HALO
integer, public jblock
block size for cache blocking: y
real(rp), dimension(:,:,:,:), allocatable, public rhoq_tp
module COMMUNICATION
Definition: scale_comm.F90:23
integer, public js
start point of inner domain: y, local
module TIME
Definition: scale_time.F90:15
real(dp), public time_dtsec_atmos_phy_tb
time interval of physics(turbulence ) [sec]
Definition: scale_time.F90:44
module Atmosphere / Physics Turbulence
real(rp), dimension(:,:,:), pointer, public dens_av
real(rp), dimension(:,:,:,:), allocatable, public gtrans_j13g
(1,3) element of Jacobian matrix * {G}^1/2
character(len=h_short), public atmos_phy_tb_type
module ATMOSPHERE / Physics Turbulence
integer, public ks
start point of inner domain: z, local
subroutine, public atmos_phy_tb_driver_setup
Setup.
module ATMOSPHERE / Physics Turbulence
real(rp), dimension(:,:,:), allocatable, public atmos_phy_tb_momy_t
real(rp), dimension(:,:,:), allocatable, public momx_tp
real(rp), dimension(:,:,:), allocatable, target, public momy
module GRID (cartesian)
subroutine, public prof_rapstart(rapname_base, level)
Start raptime.
Definition: scale_prof.F90:156
real(rp), dimension(:,:,:), allocatable, public momz_tp
real(rp), dimension(:,:), allocatable, public atmos_phy_sf_sflx_sh
module profiler
Definition: scale_prof.F90:10
real(rp), dimension(:,:,:), allocatable, public n2
integer, public ie
end point of inner domain: x, local
real(rp), dimension(:,:,:,:), allocatable, public gtrans_gsqrt
transformation metrics from Z to Xi, {G}^1/2
module PRECISION
real(rp), dimension(:), allocatable, public grid_cdz
z-length of control volume [m]
real(rp), dimension(:,:,:,:), allocatable, public atmos_phy_tb_rhoq_t
real(rp), dimension(:), allocatable, public grid_cdy
y-length of control volume [m]
module HISTORY
real(rp), dimension(:,:,:), pointer, public momz_av
real(rp), dimension(:,:,:), pointer, public rhot_av
procedure(su), pointer, public atmos_phy_tb_setup
subroutine, public atmos_phy_tb_driver(update_flag)
Driver.
integer, public io_fid_log
Log file ID.
Definition: scale_stdio.F90:56
real(rp), dimension(:,:,:), pointer, public momy_av
real(rp), dimension(:,:), allocatable, public atmos_phy_sf_sflx_mu
subroutine, public prof_rapend(rapname_base, level)
Save raptime.
Definition: scale_prof.F90:204
subroutine, public atmos_phy_tb_driver_resume
Resume.
subroutine, public atmos_phy_tb_config(TB_TYPE)
register
real(rp), dimension(:), allocatable, public grid_cdx
x-length of control volume [m]
real(rp), dimension(:,:,:), allocatable, public atmos_phy_tb_momz_t
real(rp), dimension(:,:,:,:), allocatable, target, public qtrc
integer, public ja
of whole cells: y, local, with HALO