SCALE-RM
scale_atmos_dyn_tstep_large_fvm_heve.F90
Go to the documentation of this file.
1 !-------------------------------------------------------------------------------
13 !-------------------------------------------------------------------------------
14 #include "inc_openmp.h"
16  !-----------------------------------------------------------------------------
17  !
18  !++ used modules
19  !
20  use scale_precision
21  use scale_stdio
22  use scale_prof
24  use scale_index
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 
44  !-----------------------------------------------------------------------------
45  !
46  !++ Public parameters & variables
47  !
48  !-----------------------------------------------------------------------------
49  !
50  !++ Private procedure
51  !
52  !-----------------------------------------------------------------------------
53  !
54  !++ Private parameters & variables
55  !
56  ! tendency
57  real(RP), private, allocatable :: DENS_t(:,:,:)
58  real(RP), private, allocatable :: MOMZ_t(:,:,:)
59  real(RP), private, allocatable :: MOMX_t(:,:,:)
60  real(RP), private, allocatable :: MOMY_t(:,:,:)
61  real(RP), private, allocatable :: RHOT_t(:,:,:)
62  real(RP), private, allocatable :: RHOQ_t(:,:,:,:)
63 
64  real(RP), private, allocatable :: mflx_hi(:,:,:,:) ! rho * vel(x,y,z) @ (u,v,w)-face high order
65 
66  ! for communication
67  integer :: I_COMM_DENS = 1
68  integer :: I_COMM_MOMZ = 2
69  integer :: I_COMM_MOMX = 3
70  integer :: I_COMM_MOMY = 4
71  integer :: I_COMM_RHOT = 5
72  integer, allocatable :: I_COMM_PROG(:)
73 
74  integer :: I_COMM_DENS_t = 1
75  integer :: I_COMM_MOMZ_t = 2
76  integer :: I_COMM_MOMX_t = 3
77  integer :: I_COMM_MOMY_t = 4
78  integer :: I_COMM_RHOT_t = 5
79 
80  integer, allocatable :: I_COMM_RHOQ_t(:)
81  integer, allocatable :: I_COMM_QTRC(:)
82 
83  integer :: I_COMM_mflx_z = 1
84  integer :: I_COMM_mflx_x = 2
85  integer :: I_COMM_mflx_y = 3
86 
87  !-----------------------------------------------------------------------------
88 contains
89 
90  !-----------------------------------------------------------------------------
93  DENS, MOMZ, MOMX, MOMY, RHOT, QTRC, PROG, &
94  mflx_hi )
95  use scale_process, only: &
97  use scale_rm_process, only: &
98  prc_has_e, &
99  prc_has_w, &
100  prc_has_n, &
101  prc_has_s
102  use scale_const, only: &
103  ohm => const_ohm, &
104  undef => const_undef
105  use scale_comm, only: &
107  implicit none
108 
109  ! MPI_RECV_INIT requires intent(inout)
110  real(RP), intent(inout) :: dens(ka,ia,ja)
111  real(RP), intent(inout) :: momz(ka,ia,ja)
112  real(RP), intent(inout) :: momx(ka,ia,ja)
113  real(RP), intent(inout) :: momy(ka,ia,ja)
114  real(RP), intent(inout) :: rhot(ka,ia,ja)
115  real(RP), intent(inout) :: qtrc(ka,ia,ja,qa)
116  real(RP), intent(inout) :: prog(ka,ia,ja,va)
117  real(RP), intent(inout) :: mflx_hi(ka,ia,ja,3)
118 
119  integer :: iv, iq
120  !---------------------------------------------------------------------------
121 
122  allocate( dens_t(ka,ia,ja) )
123  allocate( momz_t(ka,ia,ja) )
124  allocate( momx_t(ka,ia,ja) )
125  allocate( momy_t(ka,ia,ja) )
126  allocate( rhot_t(ka,ia,ja) )
127  allocate( rhoq_t(ka,ia,ja,qa) )
128 
129  allocate( i_comm_prog(max(va,1)) )
130  allocate( i_comm_qtrc(qa) )
131  allocate( i_comm_rhoq_t(qa) )
132 
133  call comm_vars8_init( 'DENS', dens, i_comm_dens )
134  call comm_vars8_init( 'MOMZ', momz, i_comm_momz )
135  call comm_vars8_init( 'MOMX', momx, i_comm_momx )
136  call comm_vars8_init( 'MOMY', momy, i_comm_momy )
137  call comm_vars8_init( 'RHOT', rhot, i_comm_rhot )
138  do iv = 1, va
139  i_comm_prog(iv) = 5 + iv
140  call comm_vars8_init( 'PROG', prog(:,:,:,iv), i_comm_prog(iv) )
141  end do
142 
143  call comm_vars8_init( 'DENS_t', dens_t, i_comm_dens_t )
144  call comm_vars8_init( 'MOMZ_t', momz_t, i_comm_momz_t )
145  call comm_vars8_init( 'MOMX_t', momx_t, i_comm_momx_t )
146  call comm_vars8_init( 'MOMY_t', momy_t, i_comm_momy_t )
147  call comm_vars8_init( 'RHOT_t', rhot_t, i_comm_rhot_t )
148 
149  do iq = 1, qa
150  i_comm_rhoq_t(iq) = 5 + va + iq
151  i_comm_qtrc(iq) = 5 + va + iq
152 
153  call comm_vars8_init( 'RHOQ_t', rhoq_t(:,:,:,iq), i_comm_rhoq_t(iq) )
154  call comm_vars8_init( 'QTRC', qtrc(:,:,:,iq), i_comm_qtrc(iq) )
155  end do
156 
157  call comm_vars8_init( 'mflx_Z', mflx_hi(:,:,:,zdir), i_comm_mflx_z )
158  call comm_vars8_init( 'mflx_X', mflx_hi(:,:,:,xdir), i_comm_mflx_x )
159  call comm_vars8_init( 'mflx_Y', mflx_hi(:,:,:,ydir), i_comm_mflx_y )
160 
161  mflx_hi(:,:,:,:) = undef
162 
163  return
165 
166  !-----------------------------------------------------------------------------
168  subroutine atmos_dyn_tstep_large_fvm_heve( &
169  DENS, MOMZ, MOMX, MOMY, RHOT, QTRC, PROG, &
170  DENS_av, MOMZ_av, MOMX_av, MOMY_av, RHOT_av, QTRC_av, &
171  mflx_hi, tflx_hi, &
172  num_diff, num_diff_q, &
173  QTRC0, &
174  DENS_tp, MOMZ_tp, MOMX_tp, MOMY_tp, RHOT_tp, RHOQ_tp, &
175  CORIOLI, &
176  CDZ, CDX, CDY, FDZ, FDX, FDY, &
177  RCDZ, RCDX, RCDY, RFDZ, RFDX, RFDY, &
178  PHI, GSQRT, &
179  J13G, J23G, J33G, MAPF, &
180  AQ_R, AQ_CV, AQ_CP, AQ_MASS, &
181  REF_dens, REF_pott, REF_qv, REF_pres, &
182  BND_W, BND_E, BND_S, BND_N, &
183  ND_COEF, ND_COEF_Q, ND_ORDER, ND_SFC_FACT, ND_USE_RS, &
184  DAMP_DENS, DAMP_VELZ, DAMP_VELX, &
185  DAMP_VELY, DAMP_POTT, DAMP_QTRC, &
186  DAMP_alpha_DENS, DAMP_alpha_VELZ, DAMP_alpha_VELX, &
187  DAMP_alpha_VELY, DAMP_alpha_POTT, DAMP_alpha_QTRC, &
188  wdamp_coef, &
189  divdmp_coef, &
190  FLAG_FCT_MOMENTUM, FLAG_FCT_T, FLAG_FCT_TRACER, &
191  FLAG_FCT_ALONG_STREAM, &
192  USE_AVERAGE, &
193  DTLS, DTSS, Llast )
194  use scale_const, only: &
195  eps => const_eps, &
196  p0 => const_pre00, &
197  rdry => const_rdry, &
198  cvdry => const_cvdry, &
199  cpdry => const_cpdry
200  use scale_comm, only: &
201  comm_vars8, &
202  comm_wait
203  use scale_gridtrans, only: &
204  i_xyz, &
205  i_xyw, &
206  i_uyz, &
207  i_xvz, &
208  i_xy, &
209  i_uy, &
210  i_xv
211  use scale_atmos_dyn_common, only: &
216  use scale_atmos_dyn_fvm_flux_ud1, only: &
220  use scale_atmos_dyn_fvm_flux, only: &
224  use scale_atmos_boundary, only: &
225  bnd_qa, &
226  bnd_smoother_fact => atmos_boundary_smoother_fact
227  use scale_history, only: &
228 #ifdef hist_tend
229  hist_in, &
230 #endif
231  hist_switch
232  use scale_atmos_dyn_tinteg_short, only: &
234  use scale_atmos_dyn_tinteg_tracer, only: &
236  implicit none
237 
238  real(RP), intent(inout) :: dens(ka,ia,ja)
239  real(RP), intent(inout) :: momz(ka,ia,ja)
240  real(RP), intent(inout) :: momx(ka,ia,ja)
241  real(RP), intent(inout) :: momy(ka,ia,ja)
242  real(RP), intent(inout) :: rhot(ka,ia,ja)
243  real(RP), intent(inout) :: qtrc(ka,ia,ja,qa)
244  real(RP), intent(inout) :: prog(ka,ia,ja,va)
245 
246  real(RP), intent(inout) :: dens_av(ka,ia,ja)
247  real(RP), intent(inout) :: momz_av(ka,ia,ja)
248  real(RP), intent(inout) :: momx_av(ka,ia,ja)
249  real(RP), intent(inout) :: momy_av(ka,ia,ja)
250  real(RP), intent(inout) :: rhot_av(ka,ia,ja)
251  real(RP), intent(inout) :: qtrc_av(ka,ia,ja,qa)
252 
253  real(RP), intent(out) :: mflx_hi(ka,ia,ja,3)
254  real(RP), intent(out) :: tflx_hi(ka,ia,ja,3)
255 
256  real(RP), intent(out) :: num_diff(ka,ia,ja,5,3)
257  real(RP), intent(out) :: num_diff_q(ka,ia,ja,3)
258 
259  real(RP), intent(in) :: qtrc0(ka,ia,ja,qa)
260 
261  real(RP), intent(in) :: dens_tp(ka,ia,ja)
262  real(RP), intent(in) :: momz_tp(ka,ia,ja)
263  real(RP), intent(in) :: momx_tp(ka,ia,ja)
264  real(RP), intent(in) :: momy_tp(ka,ia,ja)
265  real(RP), intent(in) :: rhot_tp(ka,ia,ja)
266  real(RP), intent(in) :: rhoq_tp(ka,ia,ja,qa)
267 
268  real(RP), intent(in) :: corioli(ia,ja)
269 
270  real(RP), intent(in) :: cdz (ka)
271  real(RP), intent(in) :: cdx (ia)
272  real(RP), intent(in) :: cdy (ja)
273  real(RP), intent(in) :: fdz (ka-1)
274  real(RP), intent(in) :: fdx (ia-1)
275  real(RP), intent(in) :: fdy (ja-1)
276  real(RP), intent(in) :: rcdz(ka)
277  real(RP), intent(in) :: rcdx(ia)
278  real(RP), intent(in) :: rcdy(ja)
279  real(RP), intent(in) :: rfdz(ka-1)
280  real(RP), intent(in) :: rfdx(ia-1)
281  real(RP), intent(in) :: rfdy(ja-1)
282 
283  real(RP), intent(in) :: phi (ka,ia,ja)
284  real(RP), intent(in) :: gsqrt(ka,ia,ja,7)
285  real(RP), intent(in) :: j13g (ka,ia,ja,7)
286  real(RP), intent(in) :: j23g (ka,ia,ja,7)
287  real(RP), intent(in) :: j33g
288  real(RP), intent(in) :: mapf (ia,ja,2,4)
289 
290  real(RP), intent(in) :: aq_r (qa)
291  real(RP), intent(in) :: aq_cv (qa)
292  real(RP), intent(in) :: aq_cp (qa)
293  real(RP), intent(in) :: aq_mass(qa)
294 
295  real(RP), intent(in) :: ref_dens(ka,ia,ja)
296  real(RP), intent(in) :: ref_pott(ka,ia,ja)
297  real(RP), intent(in) :: ref_qv (ka,ia,ja)
298  real(RP), intent(in) :: ref_pres(ka,ia,ja)
299 
300  logical, intent(in) :: bnd_w
301  logical, intent(in) :: bnd_e
302  logical, intent(in) :: bnd_s
303  logical, intent(in) :: bnd_n
304 
305  real(RP), intent(in) :: nd_coef
306  real(RP), intent(in) :: nd_coef_q
307  integer, intent(in) :: nd_order
308  real(RP), intent(in) :: nd_sfc_fact
309  logical, intent(in) :: nd_use_rs
310 
311  real(RP), intent(in) :: damp_dens(ka,ia,ja)
312  real(RP), intent(in) :: damp_velz(ka,ia,ja)
313  real(RP), intent(in) :: damp_velx(ka,ia,ja)
314  real(RP), intent(in) :: damp_vely(ka,ia,ja)
315  real(RP), intent(in) :: damp_pott(ka,ia,ja)
316  real(RP), intent(in) :: damp_qtrc(ka,ia,ja,bnd_qa)
317 
318  real(RP), intent(in) :: damp_alpha_dens(ka,ia,ja)
319  real(RP), intent(in) :: damp_alpha_velz(ka,ia,ja)
320  real(RP), intent(in) :: damp_alpha_velx(ka,ia,ja)
321  real(RP), intent(in) :: damp_alpha_vely(ka,ia,ja)
322  real(RP), intent(in) :: damp_alpha_pott(ka,ia,ja)
323  real(RP), intent(in) :: damp_alpha_qtrc(ka,ia,ja,bnd_qa)
324 
325  real(RP), intent(in) :: wdamp_coef(ka)
326  real(RP), intent(in) :: divdmp_coef
327 
328  logical, intent(in) :: flag_fct_momentum
329  logical, intent(in) :: flag_fct_t
330  logical, intent(in) :: flag_fct_tracer
331  logical, intent(in) :: flag_fct_along_stream
332 
333  logical, intent(in) :: use_average
334 
335  real(DP), intent(in) :: dtls
336  real(DP), intent(in) :: dtss
337  logical , intent(in) :: llast
338 
339  ! for time integartion
340  real(RP) :: dens00 (ka,ia,ja) ! saved density before small step loop
341 
342  ! diagnostic variables
343  real(RP) :: ddiv (ka,ia,ja) ! 3 dimensional divergence
344  real(RP) :: dpres0 (ka,ia,ja) ! pressure deviation
345  real(RP) :: rt2p (ka,ia,ja) ! factor of RHOT to PRES
346  real(RP) :: ref_rhot(ka,ia,ja) ! reference of RHOT
347 
348  real(RP) :: qdry ! dry air
349  real(RP) :: rtot ! total R
350  real(RP) :: cvtot ! total CV
351  real(RP) :: cptot ! total CP
352  real(RP) :: pres ! pressure
353 #ifdef DRY
354  real(RP) :: cpovcv
355 #endif
356 
357  real(RP) :: dens_tq(ka,ia,ja)
358  real(RP) :: diff(ka,ia,ja)
359  real(RP) :: damp
360 #ifdef HIST_TEND
361  real(RP) :: damp_t(ka,ia,ja)
362 #endif
363 
364  ! For tracer advection
365  real(RP) :: mflx_av (ka,ia,ja,3) ! rho * vel(x,y,z) @ (u,v,w)-face average
366  real(RP) :: qflx_hi (ka,ia,ja,3) ! rho * vel(x,y,z) * phi @ (u,v,w)-face high order
367  real(RP) :: qflx_lo (ka,ia,ja,3) ! rho * vel(x,y,z) * phi, monotone flux
368  real(RP) :: qflx_anti(ka,ia,ja,3) ! anti-diffusive flux
369 
370  real(RP) :: dtl
371  real(RP) :: dts
372  integer :: nstep
373 
374  integer :: iis, iie
375  integer :: jjs, jje
376  integer :: i, j, k, iq, step
377  integer :: iv
378 
379  real(RP) :: diff_coef
380  !---------------------------------------------------------------------------
381 
382  call prof_rapstart("DYN_Large_Preparation", 2)
383 
384  dts = real(DTSS, kind=RP) ! short time step
385  dtl = real(DTLS, kind=RP) ! large time step
386  nstep = ceiling( ( dtl - eps ) / dts )
387  dts = dtl / nstep ! dts is divisor of dtl and smaller or equal to dtss
388 
389 #ifdef DEBUG
390  if( io_l ) write(io_fid_log,*) '*** Dynamics large time step'
391  if( io_l ) write(io_fid_log,'(1x,A,F0.2,A,F0.2,A,I0)') &
392  '*** -> DT_large, DT_small, DT_large/DT_small : ', dtl, ', ', dts, ', ', nstep
393 
394  dens00(:,:,:) = undef
395 
396  num_diff(:,:,:,:,:) = undef
397 
398  mflx_hi(:,:,:,:) = undef
399  tflx_hi(:,:,:,:) = undef
400 
401  qflx_hi(:,:,:,:) = undef
402  qflx_lo(:,:,:,:) = undef
403 #endif
404 
405 !OCL XFILL
406  dens00(:,:,:) = dens(:,:,:)
407 
408  if ( use_average ) then
409 !OCL XFILL
410  dens_av(:,:,:) = 0.0_rp
411 !OCL XFILL
412  momz_av(:,:,:) = 0.0_rp
413 !OCL XFILL
414  momx_av(:,:,:) = 0.0_rp
415 !OCL XFILL
416  momy_av(:,:,:) = 0.0_rp
417 !OCL XFILL
418  rhot_av(:,:,:) = 0.0_rp
419  endif
420 
421 #ifndef DRY
422 !OCL XFILL
423  mflx_av(:,:,:,:) = 0.0_rp
424 
425 #endif
426 
427 #ifdef DRY
428  cpovcv = cpdry / cvdry
429 #endif
430  !------------------------------------------------------------------------
431  ! prepare thermodynamical data
432  ! specific heat
433  ! pressure data ( linearization )
434  !
435  ! pres = P0 * ( R * rhot / P0 )**(CP/CV)
436  ! d pres / d rhot ~ CP*R/CV * ( R * rhot / P0 )**(R/CV)
437  ! = CP*R/CV * ( pres / P0 )**(R/CP)
438  ! = CP*R/CV * temp / pott
439  ! = CP/CV * pres / rhot
440  ! pres ~ P0 * ( R * rhot0 / P0 ) ** (CP/CV) + CV*R/CP * ( pres / P0 )**(R/CP) * rhot'
441  !------------------------------------------------------------------------
442 !OCL XFILL
443  !$omp parallel do default(none) OMP_SCHEDULE_ collapse(2) &
444  !$omp shared(JA,IA,KS,KE) &
445  !$omp shared(P0,Rdry,RHOT,AQ_R,AQ_CV,AQ_CP,QTRC,AQ_MASS,REF_rhot,REF_pres,CPdry,CVdry,QA,RT2P,DPRES0) &
446 #ifdef DRY
447  !$omp shared(CPovCV) &
448 #endif
449  !$omp private(i,j,k,iq) &
450  !$omp private(PRES,Rtot,CVtot,CPtot,QDRY)
451  do j = 1, ja
452  do i = 1, ia
453  do k = ks, ke
454 #ifdef DRY
455  pres = p0 * ( rdry * rhot(k,i,j) / p0 )**cpovcv
456  rt2p(k,i,j) = cpovcv * pres / rhot(k,i,j)
457 #else
458  rtot = 0.0_rp
459  cvtot = 0.0_rp
460  cptot = 0.0_rp
461  qdry = 1.0_rp
462  do iq = 1, qa
463  rtot = rtot + aq_r(iq) * qtrc(k,i,j,iq)
464  cvtot = cvtot + aq_cv(iq) * qtrc(k,i,j,iq)
465  cptot = cptot + aq_cp(iq) * qtrc(k,i,j,iq)
466  qdry = qdry - qtrc(k,i,j,iq) * aq_mass(iq)
467  enddo
468  rtot = rtot + rdry * qdry
469  cvtot = cvtot + cvdry * qdry
470  cptot = cptot + cpdry * qdry
471  pres = p0 * ( rtot * rhot(k,i,j) / p0 )**( cptot / cvtot )
472  rt2p(k,i,j) = cptot / cvtot * pres / rhot(k,i,j)
473 #endif
474  dpres0(k,i,j) = pres - ref_pres(k,i,j)
475  ref_rhot(k,i,j) = rhot(k,i,j)
476  end do
477  dpres0(ks-1,i,j) = dpres0(ks+1,i,j) + ( ref_pres(ks+1,i,j) - ref_pres(ks-1,i,j) )
478  dpres0(ke+1,i,j) = dpres0(ke-1,i,j) + ( ref_pres(ke-1,i,j) - ref_pres(ke+1,i,j) )
479  end do
480  end do
481 
482  call prof_rapend ("DYN_Large_Preparation", 2)
483 
484  !###########################################################################
485  ! Update DENS,MONZ,MOMX,MOMY,MOMZ,RHOT
486  !###########################################################################
487 
488  call prof_rapstart("DYN_Large_Tendency", 2)
489 
490 #ifdef HIST_TEND
491 !OCL XFILL
492  damp_t(:,:,:) = 0.0_rp
493 #endif
494 
495 !OCL XFILL
496  dens_tq(:,:,:) = 0.0_rp
497 
498  do iq = 1, bnd_qa
499 
500  !$omp parallel do private(i,j,k) OMP_SCHEDULE_ collapse(2)
501 !OCL XFILL
502  do j = js-1, je+2
503  do i = is-1, ie+2
504  do k = ks, ke
505  diff(k,i,j) = qtrc(k,i,j,iq) - damp_qtrc(k,i,j,iq)
506  enddo
507  enddo
508  enddo
509  !$omp parallel do default(none) OMP_SCHEDULE_ collapse(2) &
510  !$omp private(i,j,k,damp) &
511 #ifdef HIST_TEND
512  !$omp shared(damp_t) &
513 #endif
514  !$omp shared(JS,JE,IS,IE,KS,KE,iq) &
515  !$omp shared(RHOQ_t,RHOQ_tp,DENS_tq,DAMP_alpha_QTRC,diff,BND_SMOOTHER_FACT,DENS00,TRACER_MASS)
516 !OCL XFILL
517  do j = js, je
518  do i = is, ie
519  do k = ks, ke
520  damp = - damp_alpha_qtrc(k,i,j,iq) &
521  * ( diff(k,i,j) & ! rayleigh damping
522  - ( diff(k,i-1,j) + diff(k,i+1,j) + diff(k,i,j-1) + diff(k,i,j+1) - diff(k,i,j)*4.0_rp ) &
523  * 0.125_rp * bnd_smoother_fact ) ! horizontal smoother
524 #ifdef HIST_TEND
525  damp_t(k,i,j) = damp
526 #endif
527  damp = damp * dens00(k,i,j)
528  rhoq_t(k,i,j,iq) = rhoq_tp(k,i,j,iq) + damp
529  dens_tq(k,i,j) = dens_tq(k,i,j) + damp * tracer_mass(iq) ! only for mass tracer
530  enddo
531  enddo
532  enddo
533 #ifdef HIST_TEND
534  call hist_in(rhoq_tp(:,:,:,iq), trim(tracer_name(iq))//'_t_phys', &
535  'tendency of '//trim(tracer_name(iq))//' due to physics', 'kg/kg/s' )
536  call hist_in(damp_t, trim(tracer_name(iq))//'_t_damp', &
537  'tendency of '//trim(tracer_name(iq))//' due to damping', 'kg/kg/s' )
538 #endif
539 !OCL XFILL
540  do j = js, je
541  do i = is, ie
542  rhoq_t( 1:ks-1,i,j,iq) = 0.0_rp
543  rhoq_t(ke+1:ka ,i,j,iq) = 0.0_rp
544  enddo
545  enddo
546 
547  call comm_vars8( rhoq_t(:,:,:,iq), i_comm_rhoq_t(iq) )
548  call comm_wait ( rhoq_t(:,:,:,iq), i_comm_rhoq_t(iq), .false. )
549 
550  end do
551 
552  !$omp parallel do private(i,j,k,iq) OMP_SCHEDULE_ collapse(3)
553 !OCL XFILL
554  do iq = bnd_qa+1, qa
555  do j = 1, ja
556  do i = 1, ia
557  do k = 1, ka
558  rhoq_t(k,i,j,iq) = rhoq_tp(k,i,j,iq)
559  enddo
560  enddo
561  enddo
562  end do
563 
564  call prof_rapend ("DYN_Large_Tendency", 2)
565 
566  call prof_rapstart("DYN_Large_Boundary", 2)
567 
568  if ( bnd_w ) then
569  !$omp parallel do private(j,k) OMP_SCHEDULE_ collapse(2)
570  do j = js, je
571  do k = ks, ke
572  mflx_hi(k,is-1,j,xdir) = gsqrt(k,is-1,j,i_uyz) * momx(k,is-1,j) / mapf(is-1,j,2,i_uy)
573  enddo
574  enddo
575  end if
576  if ( bnd_e ) then
577  !$omp parallel do private(j,k) OMP_SCHEDULE_ collapse(2)
578  do j = js, je
579  do k = ks, ke
580  mflx_hi(k,ie,j,xdir) = gsqrt(k,ie,j,i_uyz) * momx(k,ie,j) / mapf(ie,j,2,i_uy)
581  enddo
582  enddo
583  end if
584  if ( bnd_s ) then
585  !$omp parallel do private(i,k) OMP_SCHEDULE_ collapse(2)
586  do i = is, ie
587  do k = ks, ke
588  mflx_hi(k,i,js-1,ydir) = gsqrt(k,i,js-1,i_xvz) * momy(k,i,js-1) / mapf(i,js-1,1,i_xv)
589  enddo
590  enddo
591  end if
592  if ( bnd_n ) then
593  !$omp parallel do private(i,k) OMP_SCHEDULE_ collapse(2)
594  do i = is, ie
595  do k = ks, ke
596  mflx_hi(k,i,je,ydir) = gsqrt(k,i,je,i_xvz) * momy(k,i,je) / mapf(i,je,1,i_xv)
597  enddo
598  enddo
599  end if
600 
601  call prof_rapend ("DYN_Large_Boundary", 2)
602 
603 
604  do step = 1, nstep
605 
606  call hist_switch( llast .AND. step == nstep )
607 
608  !-----< prepare tendency >-----
609 
610  call prof_rapstart("DYN_Large_Tendency", 2)
611 
612  !$omp parallel do private(i,j,k) OMP_SCHEDULE_ collapse(2)
613 !OCL XFILL
614  do j = js-1, je+1
615  do i = is-1, ie+1
616  do k = ks, ke
617  diff(k,i,j) = dens(k,i,j) - damp_dens(k,i,j)
618  enddo
619  enddo
620  enddo
621  !$omp parallel do default(none) OMP_SCHEDULE_ collapse(2) &
622  !$omp private(i,j,k,damp) &
623 #ifdef HIST_TEND
624  !$omp shared(damp_t) &
625 #endif
626  !$omp shared(JS,JE,IS,IE,KS,KE) &
627  !$omp shared(DAMP_alpha_DENS,diff,DENS_tq,DENS_t,DENS_tp,BND_SMOOTHER_FACT)
628 !OCL XFILL
629  do j = js, je
630  do i = is, ie
631  do k = ks, ke
632  damp = - damp_alpha_dens(k,i,j) &
633  * ( diff(k,i,j) & ! rayleigh damping
634  - ( diff(k,i-1,j) + diff(k,i+1,j) + diff(k,i,j-1) + diff(k,i,j+1) - diff(k,i,j)*4.0_rp ) &
635  * 0.125_rp * bnd_smoother_fact ) & ! horizontal smoother
636  + dens_tq(k,i,j) ! dencity change due to rayleigh damping for tracers
637  dens_t(k,i,j) = dens_tp(k,i,j) & ! tendency from physical step
638  + damp
639 #ifdef HIST_TEND
640  damp_t(k,i,j) = damp
641 #endif
642  enddo
643  enddo
644  enddo
645 !OCL XFILL
646  do j = js, je
647  do i = is, ie
648  dens_t( 1:ks-1,i,j) = 0.0_rp
649  dens_t(ke+1:ka ,i,j) = 0.0_rp
650  enddo
651  enddo
652  call comm_vars8( dens_t(:,:,:), i_comm_dens_t )
653 #ifdef HIST_TEND
654  call hist_in(dens_tp, 'DENS_t_phys', 'tendency of dencity due to physics', 'kg/m3/s' )
655  call hist_in(damp_t, 'DENS_t_damp', 'tendency of dencity due to damping', 'kg/m3/s' )
656 #endif
657 
658  !$omp parallel do private(i,j,k) OMP_SCHEDULE_ collapse(2)
659 !OCL XFILL
660  do j = js-1, je+1
661  do i = is-1, ie+1
662  do k = ks, ke-1
663  diff(k,i,j) = momz(k,i,j) - damp_velz(k,i,j) * ( dens(k,i,j)+dens(k+1,i,j) ) * 0.5_rp
664  enddo
665  enddo
666  enddo
667  !$omp parallel do default(none) OMP_SCHEDULE_ collapse(2) &
668  !$omp private(i,j,k,damp) &
669 #ifdef HIST_TEND
670  !$omp shared(damp_t) &
671 #endif
672  !$omp shared(JS,JE,IS,IE,KS,KE) &
673  !$omp shared(DAMP_alpha_VELZ,diff,BND_SMOOTHER_FACT,MOMZ_t,MOMZ_tp)
674 !OCL XFILL
675  do j = js, je
676  do i = is, ie
677  do k = ks, ke-1
678  damp = - damp_alpha_velz(k,i,j) &
679  * ( diff(k,i,j) & ! rayleigh damping
680  - ( diff(k,i-1,j) + diff(k,i+1,j) + diff(k,i,j-1) + diff(k,i,j+1) - diff(k,i,j)*4.0_rp ) &
681  * 0.125_rp * bnd_smoother_fact ) ! horizontal smoother
682 
683  momz_t(k,i,j) = momz_tp(k,i,j) & ! tendency from physical step
684  + damp
685 #ifdef HIST_TEND
686  damp_t(k,i,j) = damp
687 #endif
688  enddo
689  enddo
690  enddo
691 !OCL XFILL
692  do j = js, je
693  do i = is, ie
694  momz_t( 1:ks-1,i,j) = 0.0_rp
695  momz_t(ke:ka ,i,j) = 0.0_rp
696  enddo
697  enddo
698  call comm_vars8( momz_t(:,:,:), i_comm_momz_t )
699 #ifdef HIST_TEND
700  call hist_in(momz_tp, 'MOMZ_t_phys', 'tendency of momentum z due to physics', 'kg/m2/s2', zdim='half' )
701  call hist_in(damp_t, 'MOMZ_t_damp', 'tendency of momentum z due to damping', 'kg/m2/s2', zdim='half' )
702 #endif
703 
704  !$omp parallel do private(i,j,k) OMP_SCHEDULE_ collapse(2)
705 !OCL XFILL
706  do j = js-1, je+1
707  do i = is-1, ie+1
708  do k = ks, ke
709  diff(k,i,j) = momx(k,i,j) - damp_velx(k,i,j) * ( dens(k,i,j)+dens(k,i+1,j) ) * 0.5_rp
710  enddo
711  enddo
712  enddo
713 !OCL XFILL
714  !$omp parallel do default(none) OMP_SCHEDULE_ collapse(2) &
715  !$omp private(i,j,k,damp) &
716 #ifdef HIST_TEND
717  !$omp shared(damp_t) &
718 #endif
719  !$omp shared(JS,JE,IS,IE,KS,KE) &
720  !$omp shared(DAMP_alpha_VELX,diff,BND_SMOOTHER_FACT,MOMX_tp,MOMX_t)
721  do j = js, je
722  do i = is, ie
723  do k = ks, ke
724  damp = - damp_alpha_velx(k,i,j) &
725  * ( diff(k,i,j) & ! rayleigh damping
726  - ( diff(k,i-1,j) + diff(k,i+1,j) + diff(k,i,j-1) + diff(k,i,j+1) - diff(k,i,j)*4.0_rp ) &
727  * 0.125_rp * bnd_smoother_fact ) ! horizontal smoother
728  momx_t(k,i,j) = momx_tp(k,i,j) & ! tendency from physical step
729  + damp
730 #ifdef HIST_TEND
731  damp_t(k,i,j) = damp
732 #endif
733  enddo
734  enddo
735  enddo
736 !OCL XFILL
737  do j = js, je
738  do i = is, ie
739  momx_t( 1:ks-1,i,j) = 0.0_rp
740  momx_t(ke+1:ka ,i,j) = 0.0_rp
741  enddo
742  enddo
743  call comm_vars8( momx_t(:,:,:), i_comm_momx_t )
744 #ifdef HIST_TEND
745  call hist_in(momx_tp, 'MOMX_t_phys', 'tendency of momentum x due to physics', 'kg/m2/s2', xdim='half' )
746  call hist_in(damp_t, 'MOMX_t_damp', 'tendency of momentum x due to damping', 'kg/m2/s2', xdim='half' )
747 #endif
748 
749  !$omp parallel do private(i,j,k) OMP_SCHEDULE_ collapse(2)
750 !OCL XFILL
751  do j = js-1, je+1
752  do i = is-1, ie+1
753  do k = ks, ke
754  diff(k,i,j) = momy(k,i,j) - damp_vely(k,i,j) * ( dens(k,i,j)+dens(k,i,j+1) ) * 0.5_rp
755  enddo
756  enddo
757  enddo
758 !OCL XFILL
759  !$omp parallel do default(none) OMP_SCHEDULE_ collapse(2) &
760  !$omp private(i,j,k,damp) &
761 #ifdef HIST_TEND
762  !$omp shared(damp_t) &
763 #endif
764  !$omp shared(JS,JE,IS,IE,KS,KE) &
765  !$omp shared(DAMP_alpha_VELY,diff,BND_SMOOTHER_FACT,MOMY_tp,MOMY_t)
766  do j = js, je
767  do i = is, ie
768  do k = ks, ke
769  damp = - damp_alpha_vely(k,i,j) &
770  * ( diff(k,i,j) & ! rayleigh damping
771  - ( diff(k,i-1,j) + diff(k,i+1,j) + diff(k,i,j-1) + diff(k,i,j+1) - diff(k,i,j)*4.0_rp ) &
772  * 0.125_rp * bnd_smoother_fact ) ! horizontal smoother
773  momy_t(k,i,j) = momy_tp(k,i,j) & ! tendency from physical step
774  + damp
775 #ifdef HIST_TEND
776  damp_t(k,i,j) = damp
777 #endif
778  enddo
779  enddo
780  enddo
781 !OCL XFILL
782  do j = js, je
783  do i = is, ie
784  momy_t( 1:ks-1,i,j) = 0.0_rp
785  momy_t(ke+1:ka ,i,j) = 0.0_rp
786  enddo
787  enddo
788  call comm_vars8( momy_t(:,:,:), i_comm_momy_t )
789 #ifdef HIST_TEND
790  call hist_in(momy_tp, 'MOMY_t_phys', 'tendency of momentum y due to physics', 'kg/m2/s2', ydim='half' )
791  call hist_in(damp_t, 'MOMY_t_damp', 'tendency of momentum y due to damping', 'kg/m2/s2', ydim='half' )
792 #endif
793 
794  !$omp parallel do private(i,j,k) OMP_SCHEDULE_ collapse(2)
795 !OCL XFILL
796  do j = js-1, je+2
797  do i = is-1, ie+2
798  do k = ks, ke
799  diff(k,i,j) = rhot(k,i,j) - damp_pott(k,i,j) * dens(k,i,j)
800  enddo
801  enddo
802  enddo
803 !OCL XFILL
804  !$omp parallel do default(none) OMP_SCHEDULE_ collapse(2) &
805  !$omp private(i,j,k,damp) &
806 #ifdef HIST_TEND
807  !$omp shared(damp_t) &
808 #endif
809  !$omp shared(JS,JE,IS,IE,KS,KE) &
810  !$omp shared(DAMP_alpha_POTT,diff,BND_SMOOTHER_FACT,RHOT_t,RHOT_tp)
811  do j = js, je
812  do i = is, ie
813  do k = ks, ke
814  damp = - damp_alpha_pott(k,i,j) &
815  * ( diff(k,i,j) & ! rayleigh damping
816  - ( diff(k,i-1,j) + diff(k,i+1,j) + diff(k,i,j-1) + diff(k,i,j+1) - diff(k,i,j)*4.0_rp ) &
817  * 0.125_rp * bnd_smoother_fact ) ! horizontal smoother
818  rhot_t(k,i,j) = rhot_tp(k,i,j) & ! tendency from physical step
819  + damp
820 #ifdef HIST_TEND
821  damp_t(k,i,j) = damp
822 #endif
823  enddo
824  enddo
825  enddo
826 !OCL XFILL
827  do j = js, je
828  do i = is, ie
829  rhot_t( 1:ks-1,i,j) = 0.0_rp
830  rhot_t(ke+1:ka ,i,j) = 0.0_rp
831  enddo
832  enddo
833  call comm_vars8( rhot_t(:,:,:), i_comm_rhot_t )
834 #ifdef HIST_TEND
835  call hist_in(rhot_tp, 'RHOT_t_phys', 'tendency of rho*theta temperature due to physics', 'K kg/m3/s' )
836  call hist_in(damp_t, 'RHOT_t_damp', 'tendency of rho*theta temperature due to damping', 'K kg/m3/s' )
837 #endif
838 
839  call comm_wait ( dens_t(:,:,:), i_comm_dens_t, .false. )
840  call comm_wait ( momz_t(:,:,:), i_comm_momz_t, .false. )
841  call comm_wait ( momx_t(:,:,:), i_comm_momx_t, .false. )
842  call comm_wait ( momy_t(:,:,:), i_comm_momy_t, .false. )
843  call comm_wait ( rhot_t(:,:,:), i_comm_rhot_t, .false. )
844 
845  call prof_rapend ("DYN_Large_Tendency", 2)
846 
847  call prof_rapstart("DYN_Large_Numfilter", 2)
848 
849  !-----< prepare numerical diffusion coefficient >-----
850 
851  if ( nd_coef == 0.0_rp ) then
852 !OCL XFILL
853  num_diff(:,:,:,:,:) = 0.0_rp
854  else
855  call atmos_dyn_numfilter_coef( num_diff(:,:,:,:,:), & ! [OUT]
856  dens, momz, momx, momy, rhot, & ! [IN]
857  cdz, cdx, cdy, fdz, fdx, fdy, dts, & ! [IN]
858  ref_dens, ref_pott, & ! [IN]
859  nd_coef, nd_order, nd_sfc_fact, nd_use_rs ) ! [IN]
860  endif
861 
862  call prof_rapend ("DYN_Large_Numfilter", 2)
863 
864  if ( divdmp_coef > 0.0_rp ) then
865 
866  call atmos_dyn_divergence( ddiv, & ! (out)
867  momz, momx, momy, & ! (in)
868  gsqrt, j13g, j23g, j33g, mapf, & ! (in)
869  rcdz, rcdx, rcdy, rfdz, fdz ) ! (in)
870 
871  else
872 
873 !XFILL
874  ddiv = 0.0_rp
875 
876  end if
877 
878  !------------------------------------------------------------------------
879  ! Start short time integration
880  !------------------------------------------------------------------------
881 
882  call prof_rapstart("DYN_Short_Tinteg", 2)
883 
884  call atmos_dyn_tinteg_short( dens, momz, momx, momy, rhot, prog, & ! (inout)
885  mflx_hi, tflx_hi, & ! (inout)
886  dens_t, momz_t, momx_t, momy_t, rhot_t, & ! (in)
887  dpres0, rt2p, corioli, & ! (in)
888  num_diff, wdamp_coef, divdmp_coef, ddiv, & ! (in)
889  flag_fct_momentum, flag_fct_t, & ! (in)
890  flag_fct_along_stream, & ! (in)
891  cdz, fdz, fdx, fdy, & ! (in)
892  rcdz, rcdx, rcdy, rfdz, rfdx, rfdy, & ! (in)
893  phi, gsqrt, j13g, j23g, j33g, mapf, & ! (in)
894  ref_dens, ref_rhot, & ! (in)
895  bnd_w, bnd_e, bnd_s, bnd_n, & ! (in)
896  dts ) ! (in)
897 
898  call prof_rapend ("DYN_Short_Tinteg", 2)
899 
900 #ifdef CHECK_MASS
901  call check_mass( &
902  dens, damp_dens, &
903  mflx_hi, tflx_hi, &
904  gsqrt, mapf, &
905  rcdx, rcdy, &
906  dts, step, &
907  bnd_w, bnd_e, bnd_s, bnd_n )
908 #endif
909 
910  !$omp parallel do default(none) private(i,j,iv) OMP_SCHEDULE_ collapse(2) &
911  !$omp shared(JSB,JEB,ISB,IEB,KS,KA,DENS,MOMZ,MOMX,MOMY,RHOT,VA,PROG,KE)
912  do j = jsb, jeb
913  do i = isb, ieb
914  dens( 1:ks-1,i,j) = dens(ks,i,j)
915  momz( 1:ks-1,i,j) = momz(ks,i,j)
916  momx( 1:ks-1,i,j) = momx(ks,i,j)
917  momy( 1:ks-1,i,j) = momy(ks,i,j)
918  rhot( 1:ks-1,i,j) = rhot(ks,i,j)
919  do iv = 1, va
920  prog( 1:ks-1,i,j,iv) = prog(ks,i,j,iv)
921  end do
922  dens(ke+1:ka, i,j) = dens(ke,i,j)
923  momz(ke+1:ka, i,j) = momz(ke,i,j)
924  momx(ke+1:ka, i,j) = momx(ke,i,j)
925  momy(ke+1:ka, i,j) = momy(ke,i,j)
926  rhot(ke+1:ka, i,j) = rhot(ke,i,j)
927  do iv = 1, va
928  prog(ke+1:ka, i,j,iv) = prog(ke,i,j,iv)
929  end do
930  enddo
931  enddo
932 
933  call comm_vars8( dens(:,:,:), i_comm_dens )
934  call comm_vars8( momz(:,:,:), i_comm_momz )
935  call comm_vars8( momx(:,:,:), i_comm_momx )
936  call comm_vars8( momy(:,:,:), i_comm_momy )
937  call comm_vars8( rhot(:,:,:), i_comm_rhot )
938  do iv = 1, va
939  call comm_vars8( prog(:,:,:,iv), i_comm_prog(iv) )
940  end do
941  call comm_wait ( dens(:,:,:), i_comm_dens, .false. )
942  call comm_wait ( momz(:,:,:), i_comm_momz, .false. )
943  call comm_wait ( momx(:,:,:), i_comm_momx, .false. )
944  call comm_wait ( momy(:,:,:), i_comm_momy, .false. )
945  call comm_wait ( rhot(:,:,:), i_comm_rhot, .false. )
946  do iv = 1, va
947  call comm_wait ( prog(:,:,:,iv), i_comm_prog(iv), .false. )
948  end do
949 
950  if ( use_average ) then
951  dens_av(:,:,:) = dens_av(:,:,:) + dens(:,:,:)
952  momz_av(:,:,:) = momz_av(:,:,:) + momz(:,:,:)
953  momx_av(:,:,:) = momx_av(:,:,:) + momx(:,:,:)
954  momy_av(:,:,:) = momy_av(:,:,:) + momy(:,:,:)
955  rhot_av(:,:,:) = rhot_av(:,:,:) + rhot(:,:,:)
956  endif
957 
958 #ifndef DRY
959  mflx_av(:,:,:,:) = mflx_av(:,:,:,:) + mflx_hi(:,:,:,:)
960 #endif
961 
962  enddo ! dynamical steps
963 
964  if ( use_average ) then
965  dens_av(:,:,:) = dens_av(:,:,:) / nstep
966  momz_av(:,:,:) = momz_av(:,:,:) / nstep
967  momx_av(:,:,:) = momx_av(:,:,:) / nstep
968  momy_av(:,:,:) = momy_av(:,:,:) / nstep
969  rhot_av(:,:,:) = rhot_av(:,:,:) / nstep
970  endif
971 
972 #ifndef DRY
973  !###########################################################################
974  ! Update Tracers
975  !###########################################################################
976 
977 !OCL XFILL
978  mflx_hi(:,:,:,:) = mflx_av(:,:,:,:) / nstep
979 
980  call comm_vars8( mflx_hi(:,:,:,zdir), i_comm_mflx_z )
981  call comm_vars8( mflx_hi(:,:,:,xdir), i_comm_mflx_x )
982  call comm_vars8( mflx_hi(:,:,:,ydir), i_comm_mflx_y )
983  call comm_wait ( mflx_hi(:,:,:,zdir), i_comm_mflx_z, .false. )
984  call comm_wait ( mflx_hi(:,:,:,xdir), i_comm_mflx_x, .false. )
985  call comm_wait ( mflx_hi(:,:,:,ydir), i_comm_mflx_y, .false. )
986 
987  if ( use_average ) then
988 !OCL XFILL
989  qtrc_av(:,:,:,:) = 0.0_rp
990  endif
991 
992  !------------------------------------------------------------------------
993  ! Update each tracer
994  !------------------------------------------------------------------------
995 
996 #ifdef SDM
997  do iq = 1, i_qv
998 #else
999  do iq = 1, qa
1000 #endif
1001 
1002  if ( tracer_advc(iq) ) then
1003 
1004  call prof_rapstart("DYN_Large_Numfilter", 2)
1005 
1006  if ( nd_coef_q == 0.0_rp ) then
1007 !OCL XFILL
1008  num_diff_q(:,:,:,:) = 0.0_rp
1009  else
1010  call atmos_dyn_numfilter_coef_q( num_diff_q(:,:,:,:), & ! [OUT]
1011  dens00, qtrc(:,:,:,iq), & ! [IN]
1012  cdz, cdx, cdy, dtl, & ! [IN]
1013  ref_qv, iq, & ! [IN]
1014  nd_coef_q, nd_order, nd_sfc_fact, nd_use_rs ) ! [IN]
1015  endif
1016 
1017  call prof_rapend ("DYN_Large_Numfilter", 2)
1018 
1019  call prof_rapstart("DYN_Tracer_Tinteg", 2)
1020 
1021  call atmos_dyn_tinteg_tracer( &
1022  qtrc(:,:,:,iq), & ! (inout)
1023  qtrc0(:,:,:,iq), rhoq_t(:,:,:,iq), &! (in)
1024  dens00, dens, & ! (in)
1025  mflx_hi, num_diff_q, & ! (in)
1026  gsqrt, mapf(:,:,:,i_xy), & ! (in)
1027  cdz, rcdz, rcdx, rcdy, & ! (in)
1028  bnd_w, bnd_e, bnd_s, bnd_n, & ! (in)
1029  dtl, & ! (in)
1030  llast .AND. flag_fct_tracer, & ! (in)
1031  flag_fct_along_stream ) ! (in)
1032 
1033  call prof_rapend ("DYN_Tracer_Tinteg", 2)
1034 
1035  else
1036 
1037  do j = js, je
1038  do i = is, ie
1039  do k = ks, ke
1040  qtrc(k,i,j,iq) = ( qtrc0(k,i,j,iq) * dens00(k,i,j) &
1041  + rhoq_t(k,i,j,iq) * dtl ) / dens(k,i,j)
1042  end do
1043  end do
1044  end do
1045 
1046  end if
1047 
1048  if ( use_average ) then
1049  qtrc_av(:,:,:,iq) = qtrc(:,:,:,iq)
1050  endif
1051 
1052  call comm_vars8( qtrc(:,:,:,iq), i_comm_qtrc(iq) )
1053 
1054  enddo ! scalar quantities loop
1055 
1056  do iq = 1, qa
1057  call comm_wait ( qtrc(:,:,:,iq), i_comm_qtrc(iq), .false. )
1058  enddo
1059 #endif
1060 
1061  return
1062  end subroutine atmos_dyn_tstep_large_fvm_heve
1063 
1064 #ifdef CHECK_MASS
1065  subroutine check_mass( &
1066  DENS, DAMP_DENS, &
1067  mflx_hi, tflx_hi, &
1068  GSQRT, MAPF, &
1069  RCDX, RCDY, &
1070  dt, step, &
1071  BND_W, BND_E, BND_S, BND_N &
1072  )
1073  use mpi
1074  use scale_grid_real, only: &
1075  vol => real_vol
1076  use scale_comm, only: &
1077  comm_datatype, &
1078  comm_world
1079  use scale_history, only: &
1080  hist_in
1081  use scale_gridtrans, only: &
1082  i_xyz, &
1083  i_xy
1084  implicit none
1085  real(RP), intent(in) :: DENS (KA,IA,JA)
1086  real(RP), intent(in) :: DAMP_DENS(KA,IA,JA)
1087  real(RP), intent(in) :: mflx_hi (KA,IA,JA,3)
1088  real(RP), intent(in) :: tflx_hi (KA,IA,JA,3)
1089  real(RP), intent(in) :: GSQRT (KA,IA,JA,7)
1090  real(RP), intent(in) :: MAPF ( IA,JA,2,7)
1091  real(RP), intent(in) :: RCDX(IA)
1092  real(RP), intent(in) :: RCDY(JA)
1093  real(RP), intent(in) :: dt
1094  integer, intent(in) :: step
1095  logical, intent(in) :: BND_W
1096  logical, intent(in) :: BND_E
1097  logical, intent(in) :: BND_S
1098  logical, intent(in) :: BND_N
1099 
1100  ! lateral boundary flux
1101  real(RP) :: mflx_lb_horizontal(KA)
1102  real(RP) :: allmflx_lb_horizontal(KA)
1103  real(RP) :: mflx_lb_total
1104  real(RP) :: mass_total
1105  real(RP) :: mass_total2
1106  real(RP) :: allmflx_lb_total
1107  real(RP) :: allmass_total
1108  real(RP) :: allmass_total2
1109 
1110  integer :: k, i, j
1111  integer :: ierr
1112 
1113 
1114  call hist_in(mflx_hi(:,:,:,zdir), 'MFLXZ', 'momentum flux of z-direction', 'kg/m2/s', zdim='half' )
1115  call hist_in(mflx_hi(:,:,:,xdir), 'MFLXX', 'momentum flux of x-direction', 'kg/m2/s', xdim='half' )
1116  call hist_in(mflx_hi(:,:,:,ydir), 'MFLXY', 'momentum flux of y-direction', 'kg/m2/s', ydim='half' )
1117 
1118  call hist_in(tflx_hi(:,:,:,zdir), 'TFLXZ', 'potential temperature flux of z-direction', 'K*kg/m2/s', zdim='half' )
1119  call hist_in(tflx_hi(:,:,:,xdir), 'TFLXX', 'potential temperature flux of x-direction', 'K*kg/m2/s', xdim='half' )
1120  call hist_in(tflx_hi(:,:,:,ydir), 'TFLXY', 'potential temperature flux of y-direction', 'K*kg/m2/s', ydim='half' )
1121 
1122  mflx_lb_total = 0.0_rp
1123  mflx_lb_horizontal(:) = 0.0_rp
1124  allmflx_lb_horizontal(:) = 0.0_rp
1125 
1126  if ( bnd_w ) then ! for western boundary
1127  i = is
1128  do j = js, je
1129  do k = ks, ke
1130  mflx_lb_total = mflx_lb_total + mflx_hi(k,i-1,j,xdir) * rcdx(i) * vol(k,i,j) &
1131  * mapf(i,j,1,i_xy) * mapf(i,j,2,i_xy) / gsqrt(k,i,j,i_xyz) * dt
1132  mflx_lb_horizontal(k) = mflx_lb_horizontal(k) + mflx_hi(k,i-1,j,xdir) * rcdx(i) * vol(k,i,j) &
1133  * mapf(i,j,1,i_xy) * mapf(i,j,2,i_xy) / gsqrt(k,i,j,i_xyz) * dt
1134 
1135  end do
1136  end do
1137  end if
1138  if ( bnd_e ) then ! for eastern boundary
1139  i = ie
1140  do j = js, je
1141  do k = ks, ke
1142  mflx_lb_total = mflx_lb_total - mflx_hi(k,i,j,xdir) * rcdx(i) * vol(k,i,j) &
1143  * mapf(i,j,1,i_xy) * mapf(i,j,2,i_xy) / gsqrt(k,i,j,i_xyz) * dt
1144  mflx_lb_horizontal(k) = mflx_lb_horizontal(k) - mflx_hi(k,i,j,xdir) * rcdx(i) * vol(k,i,j) &
1145  * mapf(i,j,1,i_xy) * mapf(i,j,2,i_xy) / gsqrt(k,i,j,i_xyz) * dt
1146  end do
1147  end do
1148  end if
1149  if ( bnd_s ) then ! for sourthern boundary
1150  j = js
1151  do i = is, ie
1152  do k = ks, ke
1153  mflx_lb_total = mflx_lb_total + mflx_hi(k,i,j-1,ydir) * rcdy(j) * vol(k,i,j) &
1154  * mapf(i,j,1,i_xy) * mapf(i,j,2,i_xy) / gsqrt(k,i,j,i_xyz) * dt
1155  mflx_lb_horizontal(k) = mflx_lb_horizontal(k) + mflx_hi(k,i,j-1,ydir) * rcdy(j) * vol(k,i,j) &
1156  * mapf(i,j,1,i_xy) * mapf(i,j,2,i_xy) / gsqrt(k,i,j,i_xyz) * dt
1157  end do
1158  end do
1159  end if
1160  if ( bnd_n ) then ! for northern boundary
1161  j = je
1162  do i = is, ie
1163  do k = ks, ke
1164  mflx_lb_total = mflx_lb_total - mflx_hi(k,i,j,ydir) * rcdy(j) * vol(k,i,j) &
1165  * mapf(i,j,1,i_xy) * mapf(i,j,2,i_xy) / gsqrt(k,i,j,i_xyz) * dt
1166  mflx_lb_horizontal(k) = mflx_lb_horizontal(k) - mflx_hi(k,i,j,ydir) * rcdy(j) * vol(k,i,j) &
1167  * mapf(i,j,1,i_xy) * mapf(i,j,2,i_xy) / gsqrt(k,i,j,i_xyz) * dt
1168  end do
1169  end do
1170  end if
1171 
1172  mass_total = 0.0_rp
1173  mass_total2 = 0.0_rp
1174 
1175  ! check total mass in the inner region
1176  do j = js, je
1177  do i = is, ie
1178  do k = ks, ke
1179  mass_total = mass_total + dens(k,i,j) * vol(k,i,j)
1180  mass_total2 = mass_total2 + damp_dens(k,i,j) * vol(k,i,j)
1181  end do
1182  end do
1183  end do
1184 
1185  call mpi_allreduce( mflx_lb_total, &
1186  allmflx_lb_total, &
1187  1, &
1188  comm_datatype, &
1189  mpi_sum, &
1190  comm_world, &
1191  ierr )
1192 
1193  if( io_l ) write(io_fid_log,'(A,1x,I1,1x,ES24.17)') 'total mflx_lb:', step, allmflx_lb_total
1194 
1195  call mpi_allreduce( mass_total, &
1196  allmass_total, &
1197  1, &
1198  comm_datatype, &
1199  mpi_sum, &
1200  comm_world, &
1201  ierr )
1202 
1203  if( io_l ) write(io_fid_log,'(A,1x,I1,1x,ES24.17)') 'total mass :', step, allmass_total
1204 
1205  call mpi_allreduce( mass_total2, &
1206  allmass_total2, &
1207  1, &
1208  comm_datatype, &
1209  mpi_sum, &
1210  comm_world, &
1211  ierr )
1212 
1213  if( io_l ) write(io_fid_log,'(A,1x,I1,1x,ES24.17)') 'total mass2 :', step, allmass_total2
1214 
1215  call mpi_allreduce( mflx_lb_horizontal(ks:ke), &
1216  allmflx_lb_horizontal(ks:ke), &
1217  kmax, &
1218  comm_datatype, &
1219  mpi_sum, &
1220  comm_world, &
1221  ierr )
1222 
1223  call hist_in(allmflx_lb_horizontal(:), 'ALLMOM_lb_hz', &
1224  'horizontally total momentum flux from lateral boundary', 'kg/m2/s' )
1225 
1226  return
1227  end subroutine check_mass
1228 #endif
1229 
integer, public is
start point of inner domain: x, local
module DEBUG
Definition: scale_debug.F90:13
integer, public i_xvz
integer, public comm_datatype
datatype of variable
Definition: scale_comm.F90:117
real(rp), public const_cvdry
specific heat (dry air,constant volume) [J/kg/K]
Definition: scale_const.F90:59
subroutine, public atmos_dyn_tstep_large_fvm_heve_setup(DENS, MOMZ, MOMX, MOMY, RHOT, QTRC, PROG, mflx_hi)
Setup.
integer, public je
end point of inner domain: y, local
real(rp), public const_cpdry
specific heat (dry air,constant pressure) [J/kg/K]
Definition: scale_const.F90:58
logical, public prc_has_n
subroutine, public atmos_dyn_fvm_fluxy_xyz_ud1(flux, mflx, val, GSQRT, num_diff, CDZ, IIS, IIE, JJS, JJE)
calculation Y-flux at XYZ
subroutine, public prc_mpistop
Abort MPI.
subroutine, public atmos_dyn_numfilter_coef_q(num_diff_q, DENS, QTRC, CDZ, CDX, CDY, dt, REF_qv, iq, ND_COEF, ND_ORDER, ND_SFC_FACT, ND_USE_RS)
Calc coefficient of numerical filter.
integer, public jeb
integer, public va
Definition: scale_index.F90:38
subroutine, public atmos_dyn_fvm_fluxz_xyz_ud1(flux, mflx, val, GSQRT, num_diff, CDZ, IIS, IIE, JJS, JJE)
calculation z-flux at XYZ
subroutine, public comm_vars8_init(varname, var, vid)
Register variables.
Definition: scale_comm.F90:313
module Atmosphere / Dynamics Temporal integration
subroutine, public atmos_dyn_numfilter_coef(num_diff, DENS, MOMZ, MOMX, MOMY, RHOT, CDZ, CDX, CDY, FDZ, FDX, FDY, DT, REF_dens, REF_pott, ND_COEF, ND_ORDER, ND_SFC_FACT, ND_USE_RS)
Calc coefficient of numerical filter.
logical, public io_l
output log or not? (this process)
Definition: scale_stdio.F90:61
integer, parameter, public zdir
procedure(flux_phi), pointer, public atmos_dyn_fvm_fluxx_xyz
logical, public prc_has_e
module STDIO
Definition: scale_stdio.F90:12
integer, parameter, public ydir
integer, public ke
end point of inner domain: z, local
subroutine check_mass(DENS, DAMP_DENS, mflx_hi, tflx_hi, GSQRT, MAPF, RCDX, RCDY, dt, step, BND_W, BND_E, BND_S, BND_N)
integer, parameter, public xdir
subroutine, public atmos_dyn_tstep_large_fvm_heve(DENS, MOMZ, MOMX, MOMY, RHOT, QTRC, PROG, DENS_av, MOMZ_av, MOMX_av, MOMY_av, RHOT_av, QTRC_av, mflx_hi, tflx_hi, num_diff, num_diff_q, QTRC0, DENS_tp, MOMZ_tp, MOMX_tp, MOMY_tp, RHOT_tp, RHOQ_tp, CORIOLI, CDZ, CDX, CDY, FDZ, FDX, FDY, RCDZ, RCDX, RCDY, RFDZ, RFDX, RFDY, PHI, GSQRT, J13G, J23G, J33G, MAPF, AQ_R, AQ_CV, AQ_CP, AQ_MASS, REF_dens, REF_pott, REF_qv, REF_pres, BND_W, BND_E, BND_S, BND_N, ND_COEF, ND_COEF_Q, ND_ORDER, ND_SFC_FACT, ND_USE_RS, DAMP_DENS, DAMP_VELZ, DAMP_VELX, DAMP_VELY, DAMP_POTT, DAMP_QTRC, DAMP_alpha_DENS, DAMP_alpha_VELZ, DAMP_alpha_VELX, DAMP_alpha_VELY, DAMP_alpha_POTT, DAMP_alpha_QTRC, wdamp_coef, divdmp_coef, FLAG_FCT_MOMENTUM, FLAG_FCT_T, FLAG_FCT_TRACER, FLAG_FCT_ALONG_STREAM, USE_AVERAGE, DTLS, DTSS, Llast)
Dynamical Process.
integer, public qa
logical, dimension(qa_max), public tracer_advc
integer, public i_xy
subroutine, public check(current_line, v)
Undefined value checker.
Definition: scale_debug.F90:58
module Atmosphere / Dynamics Temporal integration
character(len=h_short), dimension(qa_max), public tracer_name
logical, public prc_has_s
real(rp), public const_rdry
specific gas constant (dry air) [J/kg/K]
Definition: scale_const.F90:57
real(rp), public const_undef
Definition: scale_const.F90:43
integer, public ieb
module grid index
real(rp), public const_ohm
angular velocity of the planet [1/s]
Definition: scale_const.F90:47
module TRACER
module Index
Definition: scale_index.F90:14
integer, public ia
of whole cells: x, local, with HALO
module GRIDTRANS
module GRID (real space)
integer, public ka
of whole cells: z, local, with HALO
integer, public i_uy
real(rp), public const_pre00
pressure reference [Pa]
Definition: scale_const.F90:90
integer, public comm_world
communication world ID
Definition: scale_comm.F90:118
integer, public i_xyw
integer, public kmax
of computational cells: z, local
module COMMUNICATION
Definition: scale_comm.F90:23
integer, public js
start point of inner domain: y, local
procedure(tinteg), pointer, public atmos_dyn_tinteg_tracer
integer, parameter, public const_undef2
undefined value (INT2)
Definition: scale_const.F90:40
module Atmosphere / Dynamics common
module PROCESS
real(rp), dimension(:,:,:), allocatable, public real_vol
control volume [m3]
module CONSTANT
Definition: scale_const.F90:14
integer, public ks
start point of inner domain: z, local
subroutine, public prof_rapstart(rapname_base, level)
Start raptime.
Definition: scale_prof.F90:156
module RM PROCESS
integer, public i_xv
module profiler
Definition: scale_prof.F90:10
integer, public ie
end point of inner domain: x, local
real(rp), public const_eps
small number
Definition: scale_const.F90:36
module scale_atmos_dyn_fvm_flux
integer, public i_uyz
module PRECISION
subroutine, public atmos_dyn_fct(qflx_anti, phi_in, DENS0, DENS, qflx_hi, qflx_lo, mflx_hi, rdz, rdx, rdy, GSQRT, MAPF, dt, flag_vect)
Flux Correction Transport Limiter.
subroutine, public atmos_dyn_divergence(DDIV, MOMZ, MOMX, MOMY, GSQRT, J13G, J23G, J33G, MAPF, RCDZ, RCDX, RCDY, RFDZ, FDZ)
module ATMOSPHERE / Boundary treatment
module HISTORY
integer, public isb
procedure(short), pointer, public atmos_dyn_tinteg_short
integer, public i_xyz
integer, public io_fid_log
Log file ID.
Definition: scale_stdio.F90:56
integer, public jsb
subroutine, public prof_rapend(rapname_base, level)
Save raptime.
Definition: scale_prof.F90:204
logical, public prc_has_w
procedure(flux_phi), pointer, public atmos_dyn_fvm_fluxz_xyz
real(rp), dimension(qa_max), public tracer_mass
procedure(flux_phi), pointer, public atmos_dyn_fvm_fluxy_xyz
subroutine, public atmos_dyn_fvm_fluxx_xyz_ud1(flux, mflx, val, GSQRT, num_diff, CDZ, IIS, IIE, JJS, JJE)
calculation X-flux at XYZ
module scale_atmos_dyn_fvm_flux_ud1
real(rp), public atmos_boundary_smoother_fact
integer, public ja
of whole cells: y, local, with HALO