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