SCALE-RM
Functions/Subroutines
scale_atmos_dyn_tstep_large_fvm_heve Module Reference

module Atmosphere / Dynamics More...

Functions/Subroutines

subroutine, public atmos_dyn_tstep_large_fvm_heve_setup (DENS, MOMZ, MOMX, MOMY, RHOT, QTRC, PROG, mflx_hi)
 Setup. More...
 
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_CV, 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, divdmp_coef, FLAG_FCT_MOMENTUM, FLAG_FCT_T, FLAG_FCT_TRACER, FLAG_FCT_ALONG_STREAM, USE_AVERAGE, DTLS, DTSS, Llast)
 Dynamical Process. More...
 
subroutine check_mass (DENS, DAMP_DENS, mflx_hi, tflx_hi, GSQRT, MAPF, RCDX, RCDY, dt, step, BND_W, BND_E, BND_S, BND_N)
 

Detailed Description

module Atmosphere / Dynamics

Description
HEVE FVM scheme for large time step in Atmospheric dynamical process
Author
Team SCALE
History
NAMELIST
  • No namelist group
History Output
namedescriptionunitvariable
ALLMOM_lb_hz horizontally total momentum flux from lateral boundary kg/m2/s allmflx_lb_horizontal
DENS_t_damp tendency of dencity due to rayleigh damping kg/m3/s damp_t
DENS_t_phys tendency of dencity due to physics kg/m3/s DENS_tp
MFLXX momentum flux of x-direction kg/m2/s mflx_hi
MFLXY momentum flux of y-direction kg/m2/s mflx_hi
MFLXZ momentum flux of z-direction kg/m2/s mflx_hi
MOMX_t_damp tendency of momentum x due to rayleigh damping kg/m2/s2 damp_t
MOMX_t_phys tendency of momentum x due to physics kg/m2/s2 MOMX_tp
MOMY_t_damp tendency of momentum y due to rayleigh damping kg/m2/s2 damp_t
MOMY_t_phys tendency of momentum y due to physics kg/m2/s2 MOMY_tp
MOMZ_t_damp tendency of momentum z due to rayleigh damping kg/m2/s2 damp_t
MOMZ_t_phys tendency of momentum z due to physics kg/m2/s2 MOMZ_tp
RHOT_t_damp tendency of rho*theta temperature due to rayleigh damping K kg/m3/s damp_t
RHOT_t_phys tendency of rho*theta temperature due to physics K kg/m3/s RHOT_tp
TFLXX potential temperature flux of x-direction K*kg/m2/s tflx_hi
TFLXY potential temperature flux of y-direction K*kg/m2/s tflx_hi
TFLXZ potential temperature flux of z-direction K*kg/m2/s tflx_hi
trim(AQ_NAME(iq))//'_t_damp' tendency of '//trim(AQ_NAME(iq))//' due to rayleigh damping kg/kg/s damp_t
trim(AQ_NAME(iq))//'_t_phys' tendency of '//trim(AQ_NAME(iq))//' due to physics kg/kg/s RHOQ_tp

Function/Subroutine Documentation

◆ atmos_dyn_tstep_large_fvm_heve_setup()

subroutine, public scale_atmos_dyn_tstep_large_fvm_heve::atmos_dyn_tstep_large_fvm_heve_setup ( real(rp), dimension(ka,ia,ja), intent(inout)  DENS,
real(rp), dimension(ka,ia,ja), intent(inout)  MOMZ,
real(rp), dimension(ka,ia,ja), intent(inout)  MOMX,
real(rp), dimension(ka,ia,ja), intent(inout)  MOMY,
real(rp), dimension(ka,ia,ja), intent(inout)  RHOT,
real(rp), dimension(ka,ia,ja,qa), intent(inout)  QTRC,
real(rp), dimension(ka,ia,ja,va), intent(inout)  PROG,
real(rp), dimension(ka,ia,ja,3), intent(inout)  mflx_hi 
)

Setup.

Definition at line 95 of file scale_atmos_dyn_tstep_large_fvm_heve.F90.

References scale_comm::comm_vars8_init(), scale_const::const_ohm, scale_const::const_undef, scale_grid_index::ia, scale_grid_index::ja, scale_grid_index::ka, scale_rm_process::prc_has_e, scale_rm_process::prc_has_n, scale_rm_process::prc_has_s, scale_rm_process::prc_has_w, scale_process::prc_mpistop(), scale_tracer::qa, scale_index::va, scale_grid_index::xdir, scale_grid_index::ydir, and scale_grid_index::zdir.

Referenced by scale_atmos_dyn_tstep_large::atmos_dyn_tstep_large_setup().

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, i_comm_dens )
134  call comm_vars8_init( momz, i_comm_momz )
135  call comm_vars8_init( momx, i_comm_momx )
136  call comm_vars8_init( momy, i_comm_momy )
137  call comm_vars8_init( rhot, i_comm_rhot )
138  do iv = 1, va
139  i_comm_prog(iv) = 5 + iv
140  call comm_vars8_init( prog(:,:,:,iv), i_comm_prog(iv) )
141  end do
142 
143  call comm_vars8_init( dens_t, i_comm_dens_t )
144  call comm_vars8_init( momz_t, i_comm_momz_t )
145  call comm_vars8_init( momx_t, i_comm_momx_t )
146  call comm_vars8_init( momy_t, i_comm_momy_t )
147  call comm_vars8_init( 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(:,:,:,iq), i_comm_rhoq_t(iq) )
154  call comm_vars8_init( qtrc(:,:,:,iq), i_comm_qtrc(iq) )
155  end do
156 
157  call comm_vars8_init( mflx_hi(:,:,:,zdir), i_comm_mflx_z )
158  call comm_vars8_init( mflx_hi(:,:,:,xdir), i_comm_mflx_x )
159  call comm_vars8_init( mflx_hi(:,:,:,ydir), i_comm_mflx_y )
160 
161  mflx_hi(:,:,:,:) = undef
162 
163  return
logical, public prc_has_n
subroutine, public prc_mpistop
Abort MPI.
integer, public va
Definition: scale_index.F90:38
integer, parameter, public zdir
logical, public prc_has_e
integer, parameter, public ydir
integer, parameter, public xdir
logical, public prc_has_s
real(rp), public const_undef
Definition: scale_const.F90:43
real(rp), public const_ohm
angular velocity of the planet [1/s]
Definition: scale_const.F90:47
integer, public ia
of x whole cells (local, with HALO)
subroutine, public comm_vars8_init(var, vid)
Register variables.
Definition: scale_comm.F90:328
integer, public ka
of z whole cells (local, with HALO)
module COMMUNICATION
Definition: scale_comm.F90:23
module PROCESS
module CONSTANT
Definition: scale_const.F90:14
module RM PROCESS
logical, public prc_has_w
integer, public ja
of y whole cells (local, with HALO)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ atmos_dyn_tstep_large_fvm_heve()

subroutine, public scale_atmos_dyn_tstep_large_fvm_heve::atmos_dyn_tstep_large_fvm_heve ( real(rp), dimension(ka,ia,ja), intent(inout)  DENS,
real(rp), dimension(ka,ia,ja), intent(inout)  MOMZ,
real(rp), dimension(ka,ia,ja), intent(inout)  MOMX,
real(rp), dimension(ka,ia,ja), intent(inout)  MOMY,
real(rp), dimension(ka,ia,ja), intent(inout)  RHOT,
real(rp), dimension(ka,ia,ja,qa), intent(inout)  QTRC,
real(rp), dimension(ka,ia,ja,va), intent(inout)  PROG,
real(rp), dimension(ka,ia,ja), intent(inout)  DENS_av,
real(rp), dimension(ka,ia,ja), intent(inout)  MOMZ_av,
real(rp), dimension(ka,ia,ja), intent(inout)  MOMX_av,
real(rp), dimension(ka,ia,ja), intent(inout)  MOMY_av,
real(rp), dimension(ka,ia,ja), intent(inout)  RHOT_av,
real(rp), dimension(ka,ia,ja,qa), intent(inout)  QTRC_av,
real(rp), dimension(ka,ia,ja,3), intent(out)  mflx_hi,
real(rp), dimension(ka,ia,ja,3), intent(out)  tflx_hi,
real(rp), dimension(ka,ia,ja,5,3), intent(out)  num_diff,
real(rp), dimension(ka,ia,ja,3), intent(out)  num_diff_q,
real(rp), dimension(ka,ia,ja,qa), intent(in)  QTRC0,
real(rp), dimension(ka,ia,ja), intent(in)  DENS_tp,
real(rp), dimension(ka,ia,ja), intent(in)  MOMZ_tp,
real(rp), dimension(ka,ia,ja), intent(in)  MOMX_tp,
real(rp), dimension(ka,ia,ja), intent(in)  MOMY_tp,
real(rp), dimension(ka,ia,ja), intent(in)  RHOT_tp,
real(rp), dimension(ka,ia,ja,qa), intent(in)  RHOQ_tp,
real(rp), dimension(ia,ja), intent(in)  CORIOLI,
real(rp), dimension (ka), intent(in)  CDZ,
real(rp), dimension (ia), intent(in)  CDX,
real(rp), dimension (ja), intent(in)  CDY,
real(rp), dimension (ka-1), intent(in)  FDZ,
real(rp), dimension (ia-1), intent(in)  FDX,
real(rp), dimension (ja-1), intent(in)  FDY,
real(rp), dimension(ka), intent(in)  RCDZ,
real(rp), dimension(ia), intent(in)  RCDX,
real(rp), dimension(ja), intent(in)  RCDY,
real(rp), dimension(ka-1), intent(in)  RFDZ,
real(rp), dimension(ia-1), intent(in)  RFDX,
real(rp), dimension(ja-1), intent(in)  RFDY,
real(rp), dimension (ka,ia,ja), intent(in)  PHI,
real(rp), dimension(ka,ia,ja,7), intent(in)  GSQRT,
real(rp), dimension (ka,ia,ja,7), intent(in)  J13G,
real(rp), dimension (ka,ia,ja,7), intent(in)  J23G,
real(rp), intent(in)  J33G,
real(rp), dimension (ia,ja,2,4), intent(in)  MAPF,
real(rp), dimension(qqa), intent(in)  AQ_CV,
real(rp), dimension(ka,ia,ja), intent(in)  REF_dens,
real(rp), dimension(ka,ia,ja), intent(in)  REF_pott,
real(rp), dimension (ka,ia,ja), intent(in)  REF_qv,
real(rp), dimension(ka,ia,ja), intent(in)  REF_pres,
logical, intent(in)  BND_W,
logical, intent(in)  BND_E,
logical, intent(in)  BND_S,
logical, intent(in)  BND_N,
real(rp), intent(in)  ND_COEF,
real(rp), intent(in)  ND_COEF_Q,
integer, intent(in)  ND_ORDER,
real(rp), intent(in)  ND_SFC_FACT,
logical, intent(in)  ND_USE_RS,
real(rp), dimension(ka,ia,ja), intent(in)  DAMP_DENS,
real(rp), dimension(ka,ia,ja), intent(in)  DAMP_VELZ,
real(rp), dimension(ka,ia,ja), intent(in)  DAMP_VELX,
real(rp), dimension(ka,ia,ja), intent(in)  DAMP_VELY,
real(rp), dimension(ka,ia,ja), intent(in)  DAMP_POTT,
real(rp), dimension(ka,ia,ja,bnd_qa), intent(in)  DAMP_QTRC,
real(rp), dimension(ka,ia,ja), intent(in)  DAMP_alpha_DENS,
real(rp), dimension(ka,ia,ja), intent(in)  DAMP_alpha_VELZ,
real(rp), dimension(ka,ia,ja), intent(in)  DAMP_alpha_VELX,
real(rp), dimension(ka,ia,ja), intent(in)  DAMP_alpha_VELY,
real(rp), dimension(ka,ia,ja), intent(in)  DAMP_alpha_POTT,
real(rp), dimension(ka,ia,ja,bnd_qa), intent(in)  DAMP_alpha_QTRC,
real(rp), intent(in)  divdmp_coef,
logical, intent(in)  FLAG_FCT_MOMENTUM,
logical, intent(in)  FLAG_FCT_T,
logical, intent(in)  FLAG_FCT_TRACER,
logical, intent(in)  FLAG_FCT_ALONG_STREAM,
logical, intent(in)  USE_AVERAGE,
real(dp), intent(in)  DTLS,
real(dp), intent(in)  DTSS,
logical, intent(in)  Llast 
)

Dynamical Process.

Parameters
[in]phigeopotential
[in]gsqrtvertical metrics {G}^1/2
[in]j13g(1,3) element of Jacobian matrix
[in]j23g(2,3) element of Jacobian matrix
[in]j33g(3,3) element of Jacobian matrix
[in]mapfmap factor
[in]ref_presreference pressure

Definition at line 193 of file scale_atmos_dyn_tstep_large_fvm_heve.F90.

References scale_tracer::aq_name, scale_atmos_boundary::atmos_boundary_smoother_fact, scale_atmos_dyn_common::atmos_dyn_divergence(), scale_atmos_dyn_common::atmos_dyn_fct(), scale_atmos_dyn_fvm_flux::atmos_dyn_fvm_fluxx_xyz, scale_atmos_dyn_fvm_flux_ud1::atmos_dyn_fvm_fluxx_xyz_ud1(), scale_atmos_dyn_fvm_flux::atmos_dyn_fvm_fluxy_xyz, scale_atmos_dyn_fvm_flux_ud1::atmos_dyn_fvm_fluxy_xyz_ud1(), scale_atmos_dyn_fvm_flux::atmos_dyn_fvm_fluxz_xyz, scale_atmos_dyn_fvm_flux_ud1::atmos_dyn_fvm_fluxz_xyz_ud1(), scale_atmos_dyn_common::atmos_dyn_numfilter_coef(), scale_atmos_dyn_common::atmos_dyn_numfilter_coef_q(), scale_atmos_dyn_tinteg_short::atmos_dyn_tinteg_short, scale_atmos_dyn_tinteg_tracer::atmos_dyn_tinteg_tracer, scale_atmos_boundary::bnd_qa, check_mass(), scale_const::const_cvdry, scale_const::const_eps, scale_const::const_pre00, scale_const::const_rdry, scale_const::const_rvap, scale_tracer::i_qv, scale_gridtrans::i_uy, scale_gridtrans::i_uyz, scale_gridtrans::i_xv, scale_gridtrans::i_xvz, scale_gridtrans::i_xy, scale_gridtrans::i_xyw, scale_gridtrans::i_xyz, scale_grid_index::ia, scale_grid_index::ie, scale_stdio::io_fid_log, scale_stdio::io_l, scale_grid_index::is, scale_grid_index::ja, scale_grid_index::je, scale_grid_index::js, scale_grid_index::ka, scale_grid_index::ke, scale_grid_index::ks, scale_prof::prof_rapend(), scale_prof::prof_rapstart(), scale_tracer::qa, scale_tracer::qqe, scale_tracer::qqs, scale_index::va, scale_grid_index::xdir, scale_grid_index::ydir, and scale_grid_index::zdir.

Referenced by scale_atmos_dyn_tstep_large::atmos_dyn_tstep_large_setup().

193  use scale_const, only: &
194  eps => const_eps, &
195  p0 => const_pre00, &
196  rdry => const_rdry, &
197  rvap => const_rvap, &
198  cvdry => const_cvdry
199  use scale_comm, only: &
200  comm_vars8, &
201  comm_wait
202  use scale_gridtrans, only: &
203  i_xyz, &
204  i_xyw, &
205  i_uyz, &
206  i_xvz, &
207  i_xy, &
208  i_uy, &
209  i_xv
210  use scale_atmos_dyn_common, only: &
215  use scale_atmos_dyn_fvm_flux_ud1, only: &
219  use scale_atmos_dyn_fvm_flux, only: &
223  use scale_atmos_boundary, only: &
224  bnd_qa, &
225  bnd_smoother_fact => atmos_boundary_smoother_fact
226  use scale_history, only: &
227 #ifdef hist_tend
228  hist_in, &
229 #endif
230  hist_switch
231  use scale_atmos_dyn_tinteg_short, only: &
233  use scale_atmos_dyn_tinteg_tracer, only: &
235  implicit none
236 
237  real(RP), intent(inout) :: dens(ka,ia,ja)
238  real(RP), intent(inout) :: momz(ka,ia,ja)
239  real(RP), intent(inout) :: momx(ka,ia,ja)
240  real(RP), intent(inout) :: momy(ka,ia,ja)
241  real(RP), intent(inout) :: rhot(ka,ia,ja)
242  real(RP), intent(inout) :: qtrc(ka,ia,ja,qa)
243  real(RP), intent(inout) :: prog(ka,ia,ja,va)
244 
245  real(RP), intent(inout) :: dens_av(ka,ia,ja)
246  real(RP), intent(inout) :: momz_av(ka,ia,ja)
247  real(RP), intent(inout) :: momx_av(ka,ia,ja)
248  real(RP), intent(inout) :: momy_av(ka,ia,ja)
249  real(RP), intent(inout) :: rhot_av(ka,ia,ja)
250  real(RP), intent(inout) :: qtrc_av(ka,ia,ja,qa)
251 
252  real(RP), intent(out) :: mflx_hi(ka,ia,ja,3)
253  real(RP), intent(out) :: tflx_hi(ka,ia,ja,3)
254 
255  real(RP), intent(out) :: num_diff(ka,ia,ja,5,3)
256  real(RP), intent(out) :: num_diff_q(ka,ia,ja,3)
257 
258  real(RP), intent(in) :: qtrc0(ka,ia,ja,qa)
259 
260  real(RP), intent(in) :: dens_tp(ka,ia,ja)
261  real(RP), intent(in) :: momz_tp(ka,ia,ja)
262  real(RP), intent(in) :: momx_tp(ka,ia,ja)
263  real(RP), intent(in) :: momy_tp(ka,ia,ja)
264  real(RP), intent(in) :: rhot_tp(ka,ia,ja)
265  real(RP), intent(in) :: rhoq_tp(ka,ia,ja,qa)
266 
267  real(RP), intent(in) :: corioli(ia,ja)
268 
269  real(RP), intent(in) :: cdz (ka)
270  real(RP), intent(in) :: cdx (ia)
271  real(RP), intent(in) :: cdy (ja)
272  real(RP), intent(in) :: fdz (ka-1)
273  real(RP), intent(in) :: fdx (ia-1)
274  real(RP), intent(in) :: fdy (ja-1)
275  real(RP), intent(in) :: rcdz(ka)
276  real(RP), intent(in) :: rcdx(ia)
277  real(RP), intent(in) :: rcdy(ja)
278  real(RP), intent(in) :: rfdz(ka-1)
279  real(RP), intent(in) :: rfdx(ia-1)
280  real(RP), intent(in) :: rfdy(ja-1)
281 
282  real(RP), intent(in) :: phi (ka,ia,ja)
283  real(RP), intent(in) :: gsqrt(ka,ia,ja,7)
284  real(RP), intent(in) :: j13g (ka,ia,ja,7)
285  real(RP), intent(in) :: j23g (ka,ia,ja,7)
286  real(RP), intent(in) :: j33g
287  real(RP), intent(in) :: mapf (ia,ja,2,4)
288 
289  real(RP), intent(in) :: aq_cv(qqa)
290 
291  real(RP), intent(in) :: ref_dens(ka,ia,ja)
292  real(RP), intent(in) :: ref_pott(ka,ia,ja)
293  real(RP), intent(in) :: ref_qv (ka,ia,ja)
294  real(RP), intent(in) :: ref_pres(ka,ia,ja)
295 
296  logical, intent(in) :: bnd_w
297  logical, intent(in) :: bnd_e
298  logical, intent(in) :: bnd_s
299  logical, intent(in) :: bnd_n
300 
301  real(RP), intent(in) :: nd_coef
302  real(RP), intent(in) :: nd_coef_q
303  integer, intent(in) :: nd_order
304  real(RP), intent(in) :: nd_sfc_fact
305  logical, intent(in) :: nd_use_rs
306 
307  real(RP), intent(in) :: damp_dens(ka,ia,ja)
308  real(RP), intent(in) :: damp_velz(ka,ia,ja)
309  real(RP), intent(in) :: damp_velx(ka,ia,ja)
310  real(RP), intent(in) :: damp_vely(ka,ia,ja)
311  real(RP), intent(in) :: damp_pott(ka,ia,ja)
312  real(RP), intent(in) :: damp_qtrc(ka,ia,ja,bnd_qa)
313 
314  real(RP), intent(in) :: damp_alpha_dens(ka,ia,ja)
315  real(RP), intent(in) :: damp_alpha_velz(ka,ia,ja)
316  real(RP), intent(in) :: damp_alpha_velx(ka,ia,ja)
317  real(RP), intent(in) :: damp_alpha_vely(ka,ia,ja)
318  real(RP), intent(in) :: damp_alpha_pott(ka,ia,ja)
319  real(RP), intent(in) :: damp_alpha_qtrc(ka,ia,ja,bnd_qa)
320 
321  real(RP), intent(in) :: divdmp_coef
322 
323  logical, intent(in) :: flag_fct_momentum
324  logical, intent(in) :: flag_fct_t
325  logical, intent(in) :: flag_fct_tracer
326  logical, intent(in) :: flag_fct_along_stream
327 
328  logical, intent(in) :: use_average
329 
330  real(DP), intent(in) :: dtls
331  real(DP), intent(in) :: dtss
332  logical , intent(in) :: llast
333 
334  ! for time integartion
335  real(RP) :: dens00 (ka,ia,ja) ! saved density before small step loop
336 
337  ! diagnostic variables
338  real(RP) :: ddiv (ka,ia,ja) ! 3 dimensional divergence
339  real(RP) :: dpres0 (ka,ia,ja) ! pressure deviation
340  real(RP) :: rt2p (ka,ia,ja) ! factor of RHOT to PRES
341  real(RP) :: ref_rhot(ka,ia,ja) ! reference of RHOT
342 
343  real(RP) :: qdry ! dry air
344  real(RP) :: rtot ! total R
345  real(RP) :: cvtot ! total CV
346  real(RP) :: cptot ! total CP
347  real(RP) :: pres ! pressure
348 
349  real(RP) :: dens_tq(ka,ia,ja)
350  real(RP) :: diff(ka,ia,ja)
351  real(RP) :: damp
352 #ifdef HIST_TEND
353  real(RP) :: damp_t(ka,ia,ja)
354 #endif
355 
356  ! For tracer advection
357  real(RP) :: mflx_av (ka,ia,ja,3) ! rho * vel(x,y,z) @ (u,v,w)-face average
358  real(RP) :: qflx_hi (ka,ia,ja,3) ! rho * vel(x,y,z) * phi @ (u,v,w)-face high order
359  real(RP) :: qflx_lo (ka,ia,ja,3) ! rho * vel(x,y,z) * phi, monotone flux
360  real(RP) :: qflx_anti(ka,ia,ja,3) ! anti-diffusive flux
361 
362  real(RP) :: dtl
363  real(RP) :: dts
364  integer :: nstep
365 
366  integer :: iis, iie
367  integer :: jjs, jje
368  integer :: i, j, k, iq, step
369  integer :: iv
370 
371  real(RP) :: diff_coef
372  !---------------------------------------------------------------------------
373 
374  call prof_rapstart("DYN_Large_Preparation", 2)
375 
376  dts = real(DTSS, kind=RP) ! short time step
377  dtl = real(DTLS, kind=RP) ! large time step
378  nstep = ceiling( ( dtl - eps ) / dts )
379  dts = dtl / nstep ! dts is divisor of dtl and smaller or equal to dtss
380 
381 #ifdef DEBUG
382  if( io_l ) write(io_fid_log,*) '*** Dynamics large time step'
383  if( io_l ) write(io_fid_log,'(1x,A,F0.2,A,F0.2,A,I0)') &
384  '*** -> DT_large, DT_small, DT_large/DT_small : ', dtl, ', ', dts, ', ', nstep
385 
386  dens00(:,:,:) = undef
387 
388  num_diff(:,:,:,:,:) = undef
389 
390  mflx_hi(:,:,:,:) = undef
391  tflx_hi(:,:,:,:) = undef
392 
393  qflx_hi(:,:,:,:) = undef
394  qflx_lo(:,:,:,:) = 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  !------------------------------------------------------------------------
420  ! prepare thermodynamical data
421  ! specific heat
422  ! pressure data ( linearization )
423  !
424  ! pres = P0 * ( R * rhot / P0 )**(CP/CV)
425  ! d pres / d rhot ~ CP*R/CV * ( R * rhot / P0 )**(R/CV)
426  ! = CP*R/CV * ( pres / P0 )**(R/CP)
427  ! = CP*R/CV * temp / pott
428  ! = CP/CV * pres / rhot
429  ! pres ~ P0 * ( R * rhot0 / P0 ) ** (CP/CV) + CV*R/CP * ( pres / P0 )**(R/CP) * rhot'
430  !------------------------------------------------------------------------
431 !OCL XFILL
432  do j = 1, ja
433  do i = 1, ia
434  do k = ks, ke
435 #ifdef DRY
436  pres = p0 * ( rdry * rhot(k,i,j) / p0 )**cpovcv
437  rt2p(k,i,j) = cpovcv * pres / rhot(k,i,j)
438 #else
439  cvtot = 0.0_rp
440  qdry = 1.0_rp
441  do iq = qqs, qqe
442  cvtot = cvtot + aq_cv(iq) * qtrc(k,i,j,iq)
443  qdry = qdry - qtrc(k,i,j,iq)
444  enddo
445  cvtot = cvdry * qdry + cvtot
446  rtot = rdry * qdry + rvap * qtrc(k,i,j,i_qv)
447  cptot = cvtot + rtot
448  pres = p0 * ( rtot * rhot(k,i,j) / p0 )**( cptot / cvtot )
449  rt2p(k,i,j) = cptot / cvtot * pres / rhot(k,i,j)
450 #endif
451  dpres0(k,i,j) = pres - ref_pres(k,i,j)
452  ref_rhot(k,i,j) = rhot(k,i,j)
453  end do
454  dpres0(ks-1,i,j) = dpres0(ks+1,i,j) + ( ref_pres(ks+1,i,j) - ref_pres(ks-1,i,j) )
455  dpres0(ke+1,i,j) = dpres0(ke-1,i,j) + ( ref_pres(ke-1,i,j) - ref_pres(ke+1,i,j) )
456  end do
457  end do
458 
459  call prof_rapend ("DYN_Large_Preparation", 2)
460 
461  !###########################################################################
462  ! Update DENS,MONZ,MOMX,MOMY,MOMZ,RHOT
463  !###########################################################################
464 
465  call prof_rapstart("DYN_Large_Tendency", 2)
466 
467 #ifdef HIST_TEND
468 !OCL XFILL
469  damp_t(:,:,:) = 0.0_rp
470 #endif
471 
472 !OCL XFILL
473  dens_tq(:,:,:) = 0.0_rp
474 
475  do iq = 1, bnd_qa
476 
477  !$omp parallel do private(i,j,k) OMP_SCHEDULE_ collapse(2)
478 !OCL XFILL
479  do j = js-1, je+2
480  do i = is-1, ie+2
481  do k = ks, ke
482  diff(k,i,j) = qtrc(k,i,j,iq) - damp_qtrc(k,i,j,iq)
483  enddo
484  enddo
485  enddo
486  !$omp parallel do private(i,j,k) OMP_SCHEDULE_ collapse(2)
487 !OCL XFILL
488  do j = js, je
489  do i = is, ie
490  do k = ks, ke
491  damp = - damp_alpha_qtrc(k,i,j,iq) &
492  * ( diff(k,i,j) & ! rayleigh damping
493  - ( 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 ) &
494  * 0.125_rp * bnd_smoother_fact ) ! horizontal smoother
495 #ifdef HIST_TEND
496  damp_t(k,i,j) = damp
497 #endif
498  damp = damp * dens00(k,i,j)
499  rhoq_t(k,i,j,iq) = rhoq_tp(k,i,j,iq) + damp
500  dens_tq(k,i,j) = dens_tq(k,i,j) + damp
501  enddo
502  enddo
503  enddo
504 #ifdef HIST_TEND
505  call hist_in(rhoq_tp(:,:,:,iq), trim(aq_name(iq))//'_t_phys', &
506  'tendency of '//trim(aq_name(iq))//' due to physics', 'kg/kg/s' )
507  call hist_in(damp_t, trim(aq_name(iq))//'_t_damp', &
508  'tendency of '//trim(aq_name(iq))//' due to rayleigh damping', 'kg/kg/s' )
509 #endif
510 !OCL XFILL
511  do j = js, je
512  do i = is, ie
513  rhoq_t( 1:ks-1,i,j,iq) = 0.0_rp
514  rhoq_t(ke+1:ka ,i,j,iq) = 0.0_rp
515  enddo
516  enddo
517 
518  call comm_vars8( rhoq_t(:,:,:,iq), i_comm_rhoq_t(iq) )
519  call comm_wait ( rhoq_t(:,:,:,iq), i_comm_rhoq_t(iq), .false. )
520 
521  end do
522 
523  !$omp parallel do private(i,j,k,iq) OMP_SCHEDULE_ collapse(3)
524 !OCL XFILL
525  do iq = bnd_qa+1, qa
526  do j = 1, ja
527  do i = 1, ia
528  do k = 1, ka
529  rhoq_t(k,i,j,iq) = rhoq_tp(k,i,j,iq)
530  enddo
531  enddo
532  enddo
533  end do
534 
535  call prof_rapend ("DYN_Large_Tendency", 2)
536 
537  call prof_rapstart("DYN_Large_Boundary", 2)
538 
539  if ( bnd_w ) then
540  !$omp parallel do private(j,k) OMP_SCHEDULE_ collapse(2)
541  do j = js, je
542  do k = ks, ke
543  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)
544  enddo
545  enddo
546  end if
547  if ( bnd_e ) then
548  !$omp parallel do private(j,k) OMP_SCHEDULE_ collapse(2)
549  do j = js, je
550  do k = ks, ke
551  mflx_hi(k,ie,j,xdir) = gsqrt(k,ie,j,i_uyz) * momx(k,ie,j) / mapf(ie,j,2,i_uy)
552  enddo
553  enddo
554  end if
555  if ( bnd_s ) then
556  !$omp parallel do private(i,k) OMP_SCHEDULE_ collapse(2)
557  do i = is, ie
558  do k = ks, ke
559  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)
560  enddo
561  enddo
562  end if
563  if ( bnd_n ) then
564  !$omp parallel do private(i,k) OMP_SCHEDULE_ collapse(2)
565  do i = is, ie
566  do k = ks, ke
567  mflx_hi(k,i,je,ydir) = gsqrt(k,i,je,i_xvz) * momy(k,i,je) / mapf(i,je,1,i_xv)
568  enddo
569  enddo
570  end if
571 
572  call prof_rapend ("DYN_Large_Boundary", 2)
573 
574 
575  do step = 1, nstep
576 
577  call hist_switch( llast .AND. step == nstep )
578 
579  !-----< prepare tendency >-----
580 
581  call prof_rapstart("DYN_Large_Tendency", 2)
582 
583  !$omp parallel do private(i,j,k) OMP_SCHEDULE_ collapse(2)
584 !OCL XFILL
585  do j = js-1, je+1
586  do i = is-1, ie+1
587  do k = ks, ke
588  diff(k,i,j) = dens(k,i,j) - damp_dens(k,i,j)
589  enddo
590  enddo
591  enddo
592  !$omp parallel do private(i,j,k) OMP_SCHEDULE_ collapse(2)
593 !OCL XFILL
594  do j = js, je
595  do i = is, ie
596  do k = ks, ke
597  damp = - damp_alpha_dens(k,i,j) &
598  * ( diff(k,i,j) & ! rayleigh damping
599  - ( 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 ) &
600  * 0.125_rp * bnd_smoother_fact ) & ! horizontal smoother
601  + dens_tq(k,i,j) ! dencity change due to rayleigh damping for tracers
602  dens_t(k,i,j) = dens_tp(k,i,j) & ! tendency from physical step
603  + damp
604 #ifdef HIST_TEND
605  damp_t(k,i,j) = damp
606 #endif
607  enddo
608  enddo
609  enddo
610 !OCL XFILL
611  do j = js, je
612  do i = is, ie
613  dens_t( 1:ks-1,i,j) = 0.0_rp
614  dens_t(ke+1:ka ,i,j) = 0.0_rp
615  enddo
616  enddo
617  call comm_vars8( dens_t(:,:,:), i_comm_dens_t )
618 #ifdef HIST_TEND
619  call hist_in(dens_tp, 'DENS_t_phys', 'tendency of dencity due to physics', 'kg/m3/s' )
620  call hist_in(damp_t, 'DENS_t_damp', 'tendency of dencity due to rayleigh damping', 'kg/m3/s' )
621 #endif
622 
623  !$omp parallel do private(i,j,k) OMP_SCHEDULE_ collapse(2)
624 !OCL XFILL
625  do j = js-1, je+1
626  do i = is-1, ie+1
627  do k = ks, ke-1
628  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
629  enddo
630  enddo
631  enddo
632  !$omp parallel do private(i,j,k) OMP_SCHEDULE_ collapse(2)
633 !OCL XFILL
634  do j = js, je
635  do i = is, ie
636  do k = ks, ke-1
637  damp = - damp_alpha_velz(k,i,j) &
638  * ( diff(k,i,j) & ! rayleigh damping
639  - ( 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 ) &
640  * 0.125_rp * bnd_smoother_fact ) ! horizontal smoother
641  momz_t(k,i,j) = momz_tp(k,i,j) & ! tendency from physical step
642  + damp
643 #ifdef HIST_TEND
644  damp_t(k,i,j) = damp
645 #endif
646  enddo
647  enddo
648  enddo
649 !OCL XFILL
650  do j = js, je
651  do i = is, ie
652  momz_t( 1:ks-1,i,j) = 0.0_rp
653  momz_t(ke:ka ,i,j) = 0.0_rp
654  enddo
655  enddo
656  call comm_vars8( momz_t(:,:,:), i_comm_momz_t )
657 #ifdef HIST_TEND
658  call hist_in(momz_tp, 'MOMZ_t_phys', 'tendency of momentum z due to physics', 'kg/m2/s2', zdim='half' )
659  call hist_in(damp_t, 'MOMZ_t_damp', 'tendency of momentum z due to rayleigh damping', 'kg/m2/s2', zdim='half' )
660 #endif
661 
662  !$omp parallel do private(i,j,k) OMP_SCHEDULE_ collapse(2)
663 !OCL XFILL
664  do j = js-1, je+1
665  do i = is-1, ie+1
666  do k = ks, ke
667  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
668  enddo
669  enddo
670  enddo
671 !OCL XFILL
672  do j = js, je
673  do i = is, ie
674  do k = ks, ke
675  damp = - damp_alpha_velx(k,i,j) &
676  * ( diff(k,i,j) & ! rayleigh damping
677  - ( 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 ) &
678  * 0.125_rp * bnd_smoother_fact ) ! horizontal smoother
679  momx_t(k,i,j) = momx_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  momx_t( 1:ks-1,i,j) = 0.0_rp
691  momx_t(ke+1:ka ,i,j) = 0.0_rp
692  enddo
693  enddo
694  call comm_vars8( momx_t(:,:,:), i_comm_momx_t )
695 #ifdef HIST_TEND
696  call hist_in(momx_tp, 'MOMX_t_phys', 'tendency of momentum x due to physics', 'kg/m2/s2', xdim='half' )
697  call hist_in(damp_t, 'MOMX_t_damp', 'tendency of momentum x due to rayleigh damping', 'kg/m2/s2', xdim='half' )
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) = momy(k,i,j) - damp_vely(k,i,j) * ( dens(k,i,j)+dens(k,i,j+1) ) * 0.5_rp
706  enddo
707  enddo
708  enddo
709 !OCL XFILL
710  do j = js, je
711  do i = is, ie
712  do k = ks, ke
713  damp = - damp_alpha_vely(k,i,j) &
714  * ( diff(k,i,j) & ! rayleigh damping
715  - ( 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 ) &
716  * 0.125_rp * bnd_smoother_fact ) ! horizontal smoother
717  momy_t(k,i,j) = momy_tp(k,i,j) & ! tendency from physical step
718  + damp
719 #ifdef HIST_TEND
720  damp_t(k,i,j) = damp
721 #endif
722  enddo
723  enddo
724  enddo
725 !OCL XFILL
726  do j = js, je
727  do i = is, ie
728  momy_t( 1:ks-1,i,j) = 0.0_rp
729  momy_t(ke+1:ka ,i,j) = 0.0_rp
730  enddo
731  enddo
732  call comm_vars8( momy_t(:,:,:), i_comm_momy_t )
733 #ifdef HIST_TEND
734  call hist_in(momy_tp, 'MOMY_t_phys', 'tendency of momentum y due to physics', 'kg/m2/s2', ydim='half' )
735  call hist_in(damp_t, 'MOMY_t_damp', 'tendency of momentum y due to rayleigh damping', 'kg/m2/s2', ydim='half' )
736 #endif
737 
738  !$omp parallel do private(i,j,k) OMP_SCHEDULE_ collapse(2)
739 !OCL XFILL
740  do j = js-1, je+2
741  do i = is-1, ie+2
742  do k = ks, ke
743  diff(k,i,j) = rhot(k,i,j) - damp_pott(k,i,j) * dens(k,i,j)
744  enddo
745  enddo
746  enddo
747 !OCL XFILL
748  do j = js, je
749  do i = is, ie
750  do k = ks, ke
751  damp = - damp_alpha_pott(k,i,j) &
752  * ( diff(k,i,j) & ! rayleigh damping
753  - ( 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 ) &
754  * 0.125_rp * bnd_smoother_fact ) ! horizontal smoother
755  rhot_t(k,i,j) = rhot_tp(k,i,j) & ! tendency from physical step
756  + damp
757 #ifdef HIST_TEND
758  damp_t(k,i,j) = damp
759 #endif
760  enddo
761  enddo
762  enddo
763 !OCL XFILL
764  do j = js, je
765  do i = is, ie
766  rhot_t( 1:ks-1,i,j) = 0.0_rp
767  rhot_t(ke+1:ka ,i,j) = 0.0_rp
768  enddo
769  enddo
770  call comm_vars8( rhot_t(:,:,:), i_comm_rhot_t )
771 #ifdef HIST_TEND
772  call hist_in(rhot_tp, 'RHOT_t_phys', 'tendency of rho*theta temperature due to physics', 'K kg/m3/s' )
773  call hist_in(damp_t, 'RHOT_t_damp', 'tendency of rho*theta temperature due to rayleigh damping', 'K kg/m3/s' )
774 #endif
775 
776  call comm_wait ( dens_t(:,:,:), i_comm_dens_t, .false. )
777  call comm_wait ( momz_t(:,:,:), i_comm_momz_t, .false. )
778  call comm_wait ( momx_t(:,:,:), i_comm_momx_t, .false. )
779  call comm_wait ( momy_t(:,:,:), i_comm_momy_t, .false. )
780  call comm_wait ( rhot_t(:,:,:), i_comm_rhot_t, .false. )
781 
782  call prof_rapend ("DYN_Large_Tendency", 2)
783 
784  call prof_rapstart("DYN_Large_Numfilter", 2)
785 
786  !-----< prepare numerical diffusion coefficient >-----
787 
788  if ( nd_coef == 0.0_rp ) then
789 !OCL XFILL
790  num_diff(:,:,:,:,:) = 0.0_rp
791  else
792  call atmos_dyn_numfilter_coef( num_diff(:,:,:,:,:), & ! [OUT]
793  dens, momz, momx, momy, rhot, & ! [IN]
794  cdz, cdx, cdy, fdz, fdx, fdy, dts, & ! [IN]
795  ref_dens, ref_pott, & ! [IN]
796  nd_coef, nd_order, nd_sfc_fact, nd_use_rs ) ! [IN]
797  endif
798 
799  call prof_rapend ("DYN_Large_Numfilter", 2)
800 
801  if ( divdmp_coef > 0.0_rp ) then
802 
803  call atmos_dyn_divergence( ddiv, & ! (out)
804  momz, momx, momy, & ! (in)
805  gsqrt, j13g, j23g, j33g, mapf, & ! (in)
806  rcdz, rcdx, rcdy, rfdz, fdz ) ! (in)
807 
808  else
809 
810 !XFILL
811  ddiv = 0.0_rp
812 
813  end if
814 
815  !------------------------------------------------------------------------
816  ! Start short time integration
817  !------------------------------------------------------------------------
818 
819  call prof_rapstart("DYN_Short_Tinteg", 2)
820 
821  call atmos_dyn_tinteg_short( dens, momz, momx, momy, rhot, prog, & ! (inout)
822  mflx_hi, tflx_hi, & ! (inout)
823  dens_t, momz_t, momx_t, momy_t, rhot_t, & ! (in)
824  dpres0, rt2p, corioli, & ! (in)
825  num_diff, divdmp_coef, ddiv, & ! (in)
826  flag_fct_momentum, flag_fct_t, & ! (in)
827  flag_fct_along_stream, & ! (in)
828  cdz, fdz, fdx, fdy, & ! (in)
829  rcdz, rcdx, rcdy, rfdz, rfdx, rfdy, & ! (in)
830  phi, gsqrt, j13g, j23g, j33g, mapf, & ! (in)
831  ref_dens, ref_rhot, & ! (in)
832  bnd_w, bnd_e, bnd_s, bnd_n, & ! (in)
833  dts ) ! (in)
834 
835  call prof_rapend ("DYN_Short_Tinteg", 2)
836 
837 #ifdef CHECK_MASS
838  call check_mass( &
839  dens, damp_dens, &
840  mflx_hi, tflx_hi, &
841  gsqrt, mapf, &
842  rcdx, rcdy, &
843  dts, step, &
844  bnd_w, bnd_e, bnd_s, bnd_n )
845 #endif
846 
847  do j = js, je
848  do i = is, ie
849  dens( 1:ks-1,i,j) = dens(ks,i,j)
850  momz( 1:ks-1,i,j) = momz(ks,i,j)
851  momx( 1:ks-1,i,j) = momx(ks,i,j)
852  momy( 1:ks-1,i,j) = momy(ks,i,j)
853  rhot( 1:ks-1,i,j) = rhot(ks,i,j)
854  do iv = 1, va
855  prog( 1:ks-1,i,j,iv) = prog(ks,i,j,iv)
856  end do
857  dens(ke+1:ka, i,j) = dens(ke,i,j)
858  momz(ke+1:ka, i,j) = momz(ke,i,j)
859  momx(ke+1:ka, i,j) = momx(ke,i,j)
860  momy(ke+1:ka, i,j) = momy(ke,i,j)
861  rhot(ke+1:ka, i,j) = rhot(ke,i,j)
862  do iv = 1, va
863  prog(ke+1:ka, i,j,iv) = prog(ke,i,j,iv)
864  end do
865  enddo
866  enddo
867 
868  call comm_vars8( dens(:,:,:), i_comm_dens )
869  call comm_vars8( momz(:,:,:), i_comm_momz )
870  call comm_vars8( momx(:,:,:), i_comm_momx )
871  call comm_vars8( momy(:,:,:), i_comm_momy )
872  call comm_vars8( rhot(:,:,:), i_comm_rhot )
873  do iv = 1, va
874  call comm_vars8( prog(:,:,:,iv), i_comm_prog(iv) )
875  end do
876  call comm_wait ( dens(:,:,:), i_comm_dens, .false. )
877  call comm_wait ( momz(:,:,:), i_comm_momz, .false. )
878  call comm_wait ( momx(:,:,:), i_comm_momx, .false. )
879  call comm_wait ( momy(:,:,:), i_comm_momy, .false. )
880  call comm_wait ( rhot(:,:,:), i_comm_rhot, .false. )
881  do iv = 1, va
882  call comm_wait ( prog(:,:,:,iv), i_comm_prog(iv), .false. )
883  end do
884 
885  if ( use_average ) then
886  dens_av(:,:,:) = dens_av(:,:,:) + dens(:,:,:)
887  momz_av(:,:,:) = momz_av(:,:,:) + momz(:,:,:)
888  momx_av(:,:,:) = momx_av(:,:,:) + momx(:,:,:)
889  momy_av(:,:,:) = momy_av(:,:,:) + momy(:,:,:)
890  rhot_av(:,:,:) = rhot_av(:,:,:) + rhot(:,:,:)
891  endif
892 
893 #ifndef DRY
894  mflx_av(:,:,:,:) = mflx_av(:,:,:,:) + mflx_hi(:,:,:,:)
895 #endif
896 
897  enddo ! dynamical steps
898 
899  if ( use_average ) then
900  dens_av(:,:,:) = dens_av(:,:,:) / nstep
901  momz_av(:,:,:) = momz_av(:,:,:) / nstep
902  momx_av(:,:,:) = momx_av(:,:,:) / nstep
903  momy_av(:,:,:) = momy_av(:,:,:) / nstep
904  rhot_av(:,:,:) = rhot_av(:,:,:) / nstep
905  endif
906 
907 #ifndef DRY
908  !###########################################################################
909  ! Update Tracers
910  !###########################################################################
911 
912 !OCL XFILL
913  mflx_hi(:,:,:,:) = mflx_av(:,:,:,:) / nstep
914 
915  call comm_vars8( mflx_hi(:,:,:,zdir), i_comm_mflx_z )
916  call comm_vars8( mflx_hi(:,:,:,xdir), i_comm_mflx_x )
917  call comm_vars8( mflx_hi(:,:,:,ydir), i_comm_mflx_y )
918  call comm_wait ( mflx_hi(:,:,:,zdir), i_comm_mflx_z, .false. )
919  call comm_wait ( mflx_hi(:,:,:,xdir), i_comm_mflx_x, .false. )
920  call comm_wait ( mflx_hi(:,:,:,ydir), i_comm_mflx_y, .false. )
921 
922  if ( use_average ) then
923 !OCL XFILL
924  qtrc_av(:,:,:,:) = 0.0_rp
925  endif
926 
927  !------------------------------------------------------------------------
928  ! Update each tracer
929  !------------------------------------------------------------------------
930 
931 #ifdef _SDM
932  do iq = 1, i_qv
933 #else
934  do iq = 1, qa
935 #endif
936 
937  call prof_rapstart("DYN_Large_Numfilter", 2)
938 
939  if ( nd_coef_q == 0.0_rp ) then
940 !OCL XFILL
941  num_diff_q(:,:,:,:) = 0.0_rp
942  else
943  call atmos_dyn_numfilter_coef_q( num_diff_q(:,:,:,:), & ! [OUT]
944  dens00, qtrc(:,:,:,iq), & ! [IN]
945  cdz, cdx, cdy, dtl, & ! [IN]
946  ref_qv, iq, & ! [IN]
947  nd_coef_q, nd_order, nd_sfc_fact, nd_use_rs ) ! [IN]
948  endif
949 
950  call prof_rapend ("DYN_Large_Numfilter", 2)
951 
952  call prof_rapstart("DYN_Tracer_Tinteg", 2)
953 
955  qtrc(:,:,:,iq), & ! (inout)
956  qtrc0(:,:,:,iq), rhoq_t(:,:,:,iq), &! (in)
957  dens00, dens, & ! (in)
958  mflx_hi, num_diff_q, & ! (in)
959  gsqrt, mapf(:,:,:,i_xy), & ! (in)
960  cdz, rcdz, rcdx, rcdy, & ! (in)
961  dtl, & ! (in)
962  llast .AND. flag_fct_tracer, & ! (in)
963  flag_fct_along_stream ) ! (in)
964 
965 
966  call prof_rapend ("DYN_Tracer_Tinteg", 2)
967 
968  if ( use_average ) then
969  qtrc_av(:,:,:,iq) = qtrc(:,:,:,iq)
970  endif
971 
972  call comm_vars8( qtrc(:,:,:,iq), i_comm_qtrc(iq) )
973 
974  enddo ! scalar quantities loop
975 
976  do iq = 1, qa
977  call comm_wait ( qtrc(:,:,:,iq), i_comm_qtrc(iq), .false. )
978  enddo
979 #endif
980 
981  return
integer, public is
start point of inner domain: x, local
integer, public i_xvz
real(rp), public const_cvdry
specific heat (dry air,constant volume) [J/kg/K]
Definition: scale_const.F90:59
integer, public je
end point of inner domain: y, local
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 va
Definition: scale_index.F90:38
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.
subroutine, public atmos_dyn_fvm_fluxy_xyz_ud1(flux, mflx, val, GSQRT, CDZ, IIS, IIE, JJS, JJE)
calculation Y-flux at XYZ
integer, parameter, public zdir
procedure(flux_phi), pointer, public atmos_dyn_fvm_fluxx_xyz
integer, parameter, public ydir
integer, public ke
end point of inner domain: z, local
integer, parameter, public xdir
integer, public i_xy
module Atmosphere / Dynamics Temporal integration
real(rp), public const_rdry
specific gas constant (dry air) [J/kg/K]
Definition: scale_const.F90:57
integer, public ia
of x whole cells (local, with HALO)
module GRIDTRANS
integer, public ka
of z whole cells (local, with HALO)
integer, public i_uy
real(rp), public const_pre00
pressure reference [Pa]
Definition: scale_const.F90:93
integer, public i_xyw
module COMMUNICATION
Definition: scale_comm.F90:23
subroutine, public atmos_dyn_fvm_fluxz_xyz_ud1(flux, mflx, val, GSQRT, CDZ, IIS, IIE, JJS, JJE)
calculation z-flux at XYZ
integer, public js
start point of inner domain: y, local
procedure(tinteg), pointer, public atmos_dyn_tinteg_tracer
module Atmosphere / Dynamics common
real(rp), parameter, public const_rvap
specific gas constant (water vapor) [J/kg/K]
Definition: scale_const.F90:65
module CONSTANT
Definition: scale_const.F90:14
integer, public ks
start point of inner domain: z, local
integer, public i_xv
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
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
subroutine, public atmos_dyn_fvm_fluxx_xyz_ud1(flux, mflx, val, GSQRT, CDZ, IIS, IIE, JJS, JJE)
calculation X-flux at XYZ
module HISTORY
procedure(short), pointer, public atmos_dyn_tinteg_short
integer, public i_xyz
procedure(flux_phi), pointer, public atmos_dyn_fvm_fluxz_xyz
procedure(flux_phi), pointer, public atmos_dyn_fvm_fluxy_xyz
module scale_atmos_dyn_fvm_flux_ud1
real(rp), public atmos_boundary_smoother_fact
integer, public ja
of y whole cells (local, with HALO)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_mass()

subroutine scale_atmos_dyn_tstep_large_fvm_heve::check_mass ( real(rp), dimension (ka,ia,ja), intent(in)  DENS,
real(rp), dimension(ka,ia,ja), intent(in)  DAMP_DENS,
real(rp), dimension (ka,ia,ja,3), intent(in)  mflx_hi,
real(rp), dimension (ka,ia,ja,3), intent(in)  tflx_hi,
real(rp), dimension (ka,ia,ja,7), intent(in)  GSQRT,
real(rp), dimension ( ia,ja,2,7), intent(in)  MAPF,
real(rp), dimension(ia), intent(in)  RCDX,
real(rp), dimension(ja), intent(in)  RCDY,
real(rp), intent(in)  dt,
integer, intent(in)  step,
logical, intent(in)  BND_W,
logical, intent(in)  BND_E,
logical, intent(in)  BND_S,
logical, intent(in)  BND_N 
)

Definition at line 993 of file scale_atmos_dyn_tstep_large_fvm_heve.F90.

References scale_comm::comm_datatype, scale_comm::comm_world, scale_gridtrans::i_xy, scale_gridtrans::i_xyz, scale_grid_index::ie, scale_stdio::io_fid_log, scale_stdio::io_l, scale_grid_index::is, scale_grid_index::je, scale_grid_index::js, scale_grid_index::ke, scale_grid_index::kmax, scale_grid_index::ks, scale_grid_real::real_vol, scale_grid_index::xdir, scale_grid_index::ydir, and scale_grid_index::zdir.

Referenced by atmos_dyn_tstep_large_fvm_heve().

993  use mpi
994  use scale_grid_real, only: &
995  vol => real_vol
996  use scale_comm, only: &
997  comm_datatype, &
998  comm_world
999  use scale_history, only: &
1000  hist_in
1001  use scale_gridtrans, only: &
1002  i_xyz, &
1003  i_xy
1004  implicit none
1005  real(RP), intent(in) :: dens (ka,ia,ja)
1006  real(RP), intent(in) :: damp_dens(ka,ia,ja)
1007  real(RP), intent(in) :: mflx_hi (ka,ia,ja,3)
1008  real(RP), intent(in) :: tflx_hi (ka,ia,ja,3)
1009  real(RP), intent(in) :: gsqrt (ka,ia,ja,7)
1010  real(RP), intent(in) :: mapf ( ia,ja,2,7)
1011  real(RP), intent(in) :: rcdx(ia)
1012  real(RP), intent(in) :: rcdy(ja)
1013  real(RP), intent(in) :: dt
1014  integer, intent(in) :: step
1015  logical, intent(in) :: bnd_w
1016  logical, intent(in) :: bnd_e
1017  logical, intent(in) :: bnd_s
1018  logical, intent(in) :: bnd_n
1019 
1020  ! lateral boundary flux
1021  real(RP) :: mflx_lb_horizontal(ka)
1022  real(RP) :: allmflx_lb_horizontal(ka)
1023  real(RP) :: mflx_lb_total
1024  real(RP) :: mass_total
1025  real(RP) :: mass_total2
1026  real(RP) :: allmflx_lb_total
1027  real(RP) :: allmass_total
1028  real(RP) :: allmass_total2
1029 
1030  integer :: k, i, j
1031  integer :: ierr
1032 
1033 
1034  call hist_in(mflx_hi(:,:,:,zdir), 'MFLXZ', 'momentum flux of z-direction', 'kg/m2/s', zdim='half' )
1035  call hist_in(mflx_hi(:,:,:,xdir), 'MFLXX', 'momentum flux of x-direction', 'kg/m2/s', xdim='half' )
1036  call hist_in(mflx_hi(:,:,:,ydir), 'MFLXY', 'momentum flux of y-direction', 'kg/m2/s', ydim='half' )
1037 
1038  call hist_in(tflx_hi(:,:,:,zdir), 'TFLXZ', 'potential temperature flux of z-direction', 'K*kg/m2/s', zdim='half' )
1039  call hist_in(tflx_hi(:,:,:,xdir), 'TFLXX', 'potential temperature flux of x-direction', 'K*kg/m2/s', xdim='half' )
1040  call hist_in(tflx_hi(:,:,:,ydir), 'TFLXY', 'potential temperature flux of y-direction', 'K*kg/m2/s', ydim='half' )
1041 
1042  mflx_lb_total = 0.0_rp
1043  mflx_lb_horizontal(:) = 0.0_rp
1044  allmflx_lb_horizontal(:) = 0.0_rp
1045 
1046  if ( bnd_w ) then ! for western boundary
1047  i = is
1048  do j = js, je
1049  do k = ks, ke
1050  mflx_lb_total = mflx_lb_total + mflx_hi(k,i-1,j,xdir) * rcdx(i) * vol(k,i,j) &
1051  * mapf(i,j,1,i_xy) * mapf(i,j,2,i_xy) / gsqrt(k,i,j,i_xyz) * dt
1052  mflx_lb_horizontal(k) = mflx_lb_horizontal(k) + mflx_hi(k,i-1,j,xdir) * rcdx(i) * vol(k,i,j) &
1053  * mapf(i,j,1,i_xy) * mapf(i,j,2,i_xy) / gsqrt(k,i,j,i_xyz) * dt
1054 
1055  end do
1056  end do
1057  end if
1058  if ( bnd_e ) then ! for eastern boundary
1059  i = ie
1060  do j = js, je
1061  do k = ks, ke
1062  mflx_lb_total = mflx_lb_total - mflx_hi(k,i,j,xdir) * rcdx(i) * vol(k,i,j) &
1063  * mapf(i,j,1,i_xy) * mapf(i,j,2,i_xy) / gsqrt(k,i,j,i_xyz) * dt
1064  mflx_lb_horizontal(k) = mflx_lb_horizontal(k) - mflx_hi(k,i,j,xdir) * rcdx(i) * vol(k,i,j) &
1065  * mapf(i,j,1,i_xy) * mapf(i,j,2,i_xy) / gsqrt(k,i,j,i_xyz) * dt
1066  end do
1067  end do
1068  end if
1069  if ( bnd_s ) then ! for sourthern boundary
1070  j = js
1071  do i = is, ie
1072  do k = ks, ke
1073  mflx_lb_total = mflx_lb_total + mflx_hi(k,i,j-1,ydir) * rcdy(j) * vol(k,i,j) &
1074  * mapf(i,j,1,i_xy) * mapf(i,j,2,i_xy) / gsqrt(k,i,j,i_xyz) * dt
1075  mflx_lb_horizontal(k) = mflx_lb_horizontal(k) + mflx_hi(k,i,j-1,ydir) * rcdy(j) * vol(k,i,j) &
1076  * mapf(i,j,1,i_xy) * mapf(i,j,2,i_xy) / gsqrt(k,i,j,i_xyz) * dt
1077  end do
1078  end do
1079  end if
1080  if ( bnd_n ) then ! for northern boundary
1081  j = je
1082  do i = is, ie
1083  do k = ks, ke
1084  mflx_lb_total = mflx_lb_total - mflx_hi(k,i,j,ydir) * rcdy(j) * vol(k,i,j) &
1085  * mapf(i,j,1,i_xy) * mapf(i,j,2,i_xy) / gsqrt(k,i,j,i_xyz) * dt
1086  mflx_lb_horizontal(k) = mflx_lb_horizontal(k) - mflx_hi(k,i,j,ydir) * rcdy(j) * vol(k,i,j) &
1087  * mapf(i,j,1,i_xy) * mapf(i,j,2,i_xy) / gsqrt(k,i,j,i_xyz) * dt
1088  end do
1089  end do
1090  end if
1091 
1092  mass_total = 0.0_rp
1093  mass_total2 = 0.0_rp
1094 
1095  ! check total mass in the inner region
1096  do j = js, je
1097  do i = is, ie
1098  do k = ks, ke
1099  mass_total = mass_total + dens(k,i,j) * vol(k,i,j)
1100  mass_total2 = mass_total2 + damp_dens(k,i,j) * vol(k,i,j)
1101  end do
1102  end do
1103  end do
1104 
1105  call mpi_allreduce( mflx_lb_total, &
1106  allmflx_lb_total, &
1107  1, &
1108  comm_datatype, &
1109  mpi_sum, &
1110  comm_world, &
1111  ierr )
1112 
1113  if( io_l ) write(io_fid_log,'(A,1x,I1,1x,ES24.17)') 'total mflx_lb:', step, allmflx_lb_total
1114 
1115  call mpi_allreduce( mass_total, &
1116  allmass_total, &
1117  1, &
1118  comm_datatype, &
1119  mpi_sum, &
1120  comm_world, &
1121  ierr )
1122 
1123  if( io_l ) write(io_fid_log,'(A,1x,I1,1x,ES24.17)') 'total mass :', step, allmass_total
1124 
1125  call mpi_allreduce( mass_total2, &
1126  allmass_total2, &
1127  1, &
1128  comm_datatype, &
1129  mpi_sum, &
1130  comm_world, &
1131  ierr )
1132 
1133  if( io_l ) write(io_fid_log,'(A,1x,I1,1x,ES24.17)') 'total mass2 :', step, allmass_total2
1134 
1135  call mpi_allreduce( mflx_lb_horizontal(ks:ke), &
1136  allmflx_lb_horizontal(ks:ke), &
1137  kmax, &
1138  comm_datatype, &
1139  mpi_sum, &
1140  comm_world, &
1141  ierr )
1142 
1143  call hist_in(allmflx_lb_horizontal(:), 'ALLMOM_lb_hz', &
1144  'horizontally total momentum flux from lateral boundary', 'kg/m2/s' )
1145 
1146  return
integer, public is
start point of inner domain: x, local
integer, public comm_datatype
datatype of variable
Definition: scale_comm.F90:117
integer, public je
end point of inner domain: y, local
integer, parameter, public zdir
integer, parameter, public ydir
integer, public ke
end point of inner domain: z, local
integer, parameter, public xdir
integer, public i_xy
integer, public ia
of x whole cells (local, with HALO)
module GRIDTRANS
module GRID (real space)
integer, public ka
of z whole cells (local, with HALO)
integer, public comm_world
communication world ID
Definition: scale_comm.F90:118
integer, public kmax
of computational cells: z
module COMMUNICATION
Definition: scale_comm.F90:23
integer, public js
start point of inner domain: y, local
real(rp), dimension(:,:,:), allocatable, public real_vol
control volume [m3]
integer, public ks
start point of inner domain: z, local
integer, public ie
end point of inner domain: x, local
module HISTORY
integer, public i_xyz
integer, public ja
of y whole cells (local, with HALO)
Here is the caller graph for this function: