SCALE-RM
scale_atmos_dyn.F90
Go to the documentation of this file.
1 !-------------------------------------------------------------------------------
34 !-------------------------------------------------------------------------------
35 #include "inc_openmp.h"
37  !-----------------------------------------------------------------------------
38  !
39  !++ used modules
40  !
41  use scale_precision
42  use scale_stdio
43  use scale_prof
45  use scale_index
46  use scale_tracer
47 #ifdef DEBUG
48  use scale_debug, only: &
49  check
50  use scale_const, only: &
51  undef => const_undef, &
52  iundef => const_undef2
53 #endif
54  !-----------------------------------------------------------------------------
55  implicit none
56  private
57  !-----------------------------------------------------------------------------
58  !
59  !++ Public procedure
60  !
61  public :: atmos_dyn_setup
62  public :: atmos_dyn
63 
64  !-----------------------------------------------------------------------------
65  !
66  !++ Public parameters & variables
67  !
68  real(RP), public, allocatable :: corioli (:,:) ! coriolis term
69 
70  !-----------------------------------------------------------------------------
71  !
72  !++ Private procedure
73  !
74  !-----------------------------------------------------------------------------
75  !
76  !++ Private parameters & variables
77  !
78  ! for communication
79  integer, private :: i_comm_dens = 1
80  integer, private :: i_comm_momz = 2
81  integer, private :: i_comm_momx = 3
82  integer, private :: i_comm_momy = 4
83  integer, private :: i_comm_rhot = 5
84  integer, private, allocatable :: i_comm_prog(:)
85  integer, private, allocatable :: i_comm_qtrc(:)
86 
87  logical, private :: bnd_w
88  logical, private :: bnd_e
89  logical, private :: bnd_s
90  logical, private :: bnd_n
91 
92  real(RP), private, allocatable :: mflx_hi (:,:,:,:) ! rho * vel(x,y,z) @ (u,v,w)-face high order
93 
94  real(RP), private, allocatable :: num_diff (:,:,:,:,:)
95  real(RP), private, allocatable :: num_diff_q(:,:,:,:)
96  real(RP), private, allocatable :: wdamp_coef(:) ! coefficient for Rayleigh damping of w
97 
98  logical, private :: dyn_none
99 
100  !-----------------------------------------------------------------------------
101 contains
102  !-----------------------------------------------------------------------------
104  subroutine atmos_dyn_setup( &
105  DYN_Tinteg_Short_TYPE, &
106  DYN_Tinteg_Tracer_TYPE, &
107  DYN_Tinteg_Large_TYPE, &
108  DYN_Tstep_Tracer_TYPE, &
109  DYN_Tstep_Large_TYPE, &
110  DYN_FVM_FLUX_TYPE, &
111  DYN_FVM_FLUX_TYPE_TRACER, &
112  DENS, MOMZ, MOMX, MOMY, RHOT, &
113  QTRC, PROG, &
114  CDZ, CDX, CDY, &
115  FDZ, FDX, FDY, &
116  wdamp_tau, &
117  wdamp_height, &
118  FZ, &
119  enable_coriolis, &
120  lat, &
121  none )
122  use scale_process, only: &
124  use scale_rm_process, only: &
125  prc_has_e, &
126  prc_has_w, &
127  prc_has_n, &
128  prc_has_s
129  use scale_const, only: &
130  ohm => const_ohm, &
131  undef => const_undef
132  use scale_comm, only: &
134  use scale_atmos_dyn_common, only: &
137  use scale_atmos_dyn_tinteg_short, only: &
139  use scale_atmos_dyn_tinteg_tracer, only: &
141  use scale_atmos_dyn_tinteg_large, only: &
143  use scale_atmos_dyn_tstep_short, only: &
145  use scale_atmos_dyn_tstep_tracer, only: &
147  use scale_atmos_dyn_tstep_large, only: &
149  use scale_atmos_dyn_fvm_flux, only: &
151  implicit none
152 
153  character(len=*), intent(in) :: dyn_tinteg_short_type
154  character(len=*), intent(in) :: dyn_tinteg_tracer_type
155  character(len=*), intent(in) :: dyn_tinteg_large_type
156  character(len=*), intent(in) :: dyn_tstep_tracer_type
157  character(len=*), intent(in) :: dyn_tstep_large_type
158  character(len=*), intent(in) :: dyn_fvm_flux_type
159  character(len=*), intent(in) :: dyn_fvm_flux_type_tracer
160  real(RP), intent(inout) :: dens(ka,ia,ja) ! MPI_RECV_INIT requires intent(inout)
161  real(RP), intent(inout) :: momz(ka,ia,ja)
162  real(RP), intent(inout) :: momx(ka,ia,ja)
163  real(RP), intent(inout) :: momy(ka,ia,ja)
164  real(RP), intent(inout) :: rhot(ka,ia,ja)
165  real(RP), intent(inout) :: qtrc(ka,ia,ja,qa)
166  real(RP), intent(inout) :: prog(ka,ia,ja,va)
167  real(RP), intent(in) :: cdz(ka)
168  real(RP), intent(in) :: cdx(ia)
169  real(RP), intent(in) :: cdy(ja)
170  real(RP), intent(in) :: fdz(ka-1)
171  real(RP), intent(in) :: fdx(ia-1)
172  real(RP), intent(in) :: fdy(ja-1)
173  real(RP), intent(in) :: wdamp_tau
174  real(RP), intent(in) :: wdamp_height
175  real(RP), intent(in) :: fz(0:ka)
176  logical, intent(in) :: enable_coriolis
177  real(RP), intent(in) :: lat(ia,ja)
178  logical, optional, intent(in) :: none
179 
180  integer :: iv, iq
181  !---------------------------------------------------------------------------
182 
183  dyn_none = .false.
184 
185  if ( present(none) ) then
186  dyn_none = none
187  endif
188 
189  allocate( i_comm_prog(max(va,1)) )
190  allocate( i_comm_qtrc(qa) )
191 
192  if ( .NOT. dyn_none ) then
193  bnd_w = .NOT. prc_has_w
194  bnd_e = .NOT. prc_has_e
195  bnd_s = .NOT. prc_has_s
196  bnd_n = .NOT. prc_has_n
197 
198  allocate( corioli(ia,ja) )
199  allocate( mflx_hi(ka,ia,ja,3) )
200  allocate( num_diff(ka,ia,ja,5,3) )
201  allocate( num_diff_q(ka,ia,ja,3) )
202  allocate( wdamp_coef(ka) )
203  mflx_hi(:,:,:,:) = undef
204 
205  call atmos_dyn_fvm_flux_setup ( dyn_fvm_flux_type, & ! [IN]
206  dyn_fvm_flux_type_tracer ) ! [IN]
207 
209 
210  call atmos_dyn_tstep_tracer_setup ( dyn_tstep_tracer_type ) ! [IN]
211 
212  call atmos_dyn_tstep_large_setup ( dyn_tstep_large_type, & ! [IN]
213  dens, momz, momx, momy, rhot, & ! [INOUT]
214  qtrc, prog, & ! [INOUT]
215  mflx_hi ) ! [INOUT]
216 
217  call atmos_dyn_tinteg_short_setup ( dyn_tinteg_short_type ) ! [IN]
218 
219  call atmos_dyn_tinteg_tracer_setup( dyn_tinteg_tracer_type ) ! [IN]
220 
221  call atmos_dyn_tinteg_large_setup ( dyn_tinteg_large_type ) ! [IN]
222 
223  ! numerical diffusion
224  call atmos_dyn_filter_setup( num_diff, num_diff_q, & ! [INOUT]
225  cdz, cdx, cdy, fdz, fdx, fdy ) ! [IN]
226 
227  ! numerical diffusion
228  call atmos_dyn_wdamp_setup( wdamp_coef(:), & ! [INOUT]
229  wdamp_tau, wdamp_height, & ! [IN]
230  fz(:) ) ! [IN]
231 
232  ! coriolis parameter
233  if ( enable_coriolis ) then
234  corioli(:,:) = 2.0_rp * ohm * sin( lat(:,:) )
235  else
236  corioli(:,:) = 0.0_rp
237  endif
238 
239  else
240 
241  call comm_vars8_init( 'DENS', dens, i_comm_dens )
242  call comm_vars8_init( 'MOMZ', momz, i_comm_momz )
243  call comm_vars8_init( 'MOMX', momx, i_comm_momx )
244  call comm_vars8_init( 'MOMY', momy, i_comm_momy )
245  call comm_vars8_init( 'RHOT', rhot, i_comm_rhot )
246 
247  do iv = 1, va
248  i_comm_prog(iv) = 5 + iv
249  call comm_vars8_init( 'PROG', prog(:,:,:,iv), i_comm_prog(iv) )
250  enddo
251 
252  do iq = 1, qa
253  i_comm_qtrc(iq) = 5 + va + iq
254  call comm_vars8_init( 'QTRC', qtrc(:,:,:,iq), i_comm_qtrc(iq) )
255  enddo
256 
257  endif
258 
259  return
260  end subroutine atmos_dyn_setup
261 
262  !-----------------------------------------------------------------------------
264  subroutine atmos_dyn( &
265  DENS, MOMZ, MOMX, MOMY, RHOT, QTRC, &
266  PROG, &
267  DENS_av, MOMZ_av, MOMX_av, MOMY_av, RHOT_av, QTRC_av, &
268  DENS_tp, MOMZ_tp, MOMX_tp, MOMY_tp, RHOT_tp, RHOQ_tp, &
269  CDZ, CDX, CDY, FDZ, FDX, FDY, &
270  RCDZ, RCDX, RCDY, RFDZ, RFDX, RFDY, &
271  PHI, GSQRT, &
272  J13G, J23G, J33G, MAPF, &
273  AQ_R, AQ_CV, AQ_CP, AQ_MASS, &
274  REF_dens, REF_pott, REF_qv, REF_pres, &
275  ND_COEF, ND_COEF_Q, ND_ORDER, ND_SFC_FACT, ND_USE_RS, &
276  DAMP_DENS, DAMP_VELZ, DAMP_VELX, &
277  DAMP_VELY, DAMP_POTT, DAMP_QTRC, &
278  DAMP_alpha_DENS, DAMP_alpha_VELZ, DAMP_alpha_VELX, &
279  DAMP_alpha_VELY, DAMP_alpha_POTT, DAMP_alpha_QTRC, &
280  divdmp_coef, &
281  FLAG_FCT_MOMENTUM, FLAG_FCT_T, FLAG_FCT_TRACER, &
282  FLAG_FCT_ALONG_STREAM, &
283  USE_AVERAGE, &
284  DTSEC, DTSEC_DYN )
285  use scale_comm, only: &
286  comm_vars8, &
287  comm_wait
288  use scale_atmos_boundary, only: &
289  bnd_qa
290  use scale_atmos_dyn_tinteg_large, only: &
292  implicit none
293 
294  real(RP), intent(inout) :: dens(ka,ia,ja)
295  real(RP), intent(inout) :: momz(ka,ia,ja)
296  real(RP), intent(inout) :: momx(ka,ia,ja)
297  real(RP), intent(inout) :: momy(ka,ia,ja)
298  real(RP), intent(inout) :: rhot(ka,ia,ja)
299  real(RP), intent(inout) :: qtrc(ka,ia,ja,qa)
300  real(RP), intent(inout) :: prog(ka,ia,ja,va)
301 
302  real(RP), intent(inout) :: dens_av(ka,ia,ja)
303  real(RP), intent(inout) :: momz_av(ka,ia,ja)
304  real(RP), intent(inout) :: momx_av(ka,ia,ja)
305  real(RP), intent(inout) :: momy_av(ka,ia,ja)
306  real(RP), intent(inout) :: rhot_av(ka,ia,ja)
307  real(RP), intent(inout) :: qtrc_av(ka,ia,ja,qa)
308 
309  real(RP), intent(in) :: dens_tp(ka,ia,ja)
310  real(RP), intent(in) :: momz_tp(ka,ia,ja)
311  real(RP), intent(in) :: momx_tp(ka,ia,ja)
312  real(RP), intent(in) :: momy_tp(ka,ia,ja)
313  real(RP), intent(in) :: rhot_tp(ka,ia,ja)
314  real(RP), intent(in) :: rhoq_tp(ka,ia,ja,qa)
315 
316  real(RP), intent(in) :: cdz (ka)
317  real(RP), intent(in) :: cdx (ia)
318  real(RP), intent(in) :: cdy (ja)
319  real(RP), intent(in) :: fdz (ka-1)
320  real(RP), intent(in) :: fdx (ia-1)
321  real(RP), intent(in) :: fdy (ja-1)
322  real(RP), intent(in) :: rcdz(ka)
323  real(RP), intent(in) :: rcdx(ia)
324  real(RP), intent(in) :: rcdy(ja)
325  real(RP), intent(in) :: rfdz(ka-1)
326  real(RP), intent(in) :: rfdx(ia-1)
327  real(RP), intent(in) :: rfdy(ja-1)
328 
329  real(RP), intent(in) :: phi (ka,ia,ja)
330  real(RP), intent(in) :: gsqrt(ka,ia,ja,7)
331  real(RP), intent(in) :: j13g (ka,ia,ja,7)
332  real(RP), intent(in) :: j23g (ka,ia,ja,7)
333  real(RP), intent(in) :: j33g
334  real(RP), intent(in) :: mapf (ia,ja,2,4)
335 
336  real(RP), intent(in) :: aq_r (qa)
337  real(RP), intent(in) :: aq_cv (qa)
338  real(RP), intent(in) :: aq_cp (qa)
339  real(RP), intent(in) :: aq_mass(qa)
340 
341  real(RP), intent(in) :: ref_dens(ka,ia,ja)
342  real(RP), intent(in) :: ref_pott(ka,ia,ja)
343  real(RP), intent(in) :: ref_qv (ka,ia,ja)
344  real(RP), intent(in) :: ref_pres(ka,ia,ja)
345  real(RP), intent(in) :: nd_coef
346  real(RP), intent(in) :: nd_coef_q
347  integer, intent(in) :: nd_order
348  real(RP), intent(in) :: nd_sfc_fact
349  logical, intent(in) :: nd_use_rs
350 
351  real(RP), intent(in) :: damp_dens(ka,ia,ja)
352  real(RP), intent(in) :: damp_velz(ka,ia,ja)
353  real(RP), intent(in) :: damp_velx(ka,ia,ja)
354  real(RP), intent(in) :: damp_vely(ka,ia,ja)
355  real(RP), intent(in) :: damp_pott(ka,ia,ja)
356  real(RP), intent(in) :: damp_qtrc(ka,ia,ja,bnd_qa)
357 
358  real(RP), intent(in) :: damp_alpha_dens(ka,ia,ja)
359  real(RP), intent(in) :: damp_alpha_velz(ka,ia,ja)
360  real(RP), intent(in) :: damp_alpha_velx(ka,ia,ja)
361  real(RP), intent(in) :: damp_alpha_vely(ka,ia,ja)
362  real(RP), intent(in) :: damp_alpha_pott(ka,ia,ja)
363  real(RP), intent(in) :: damp_alpha_qtrc(ka,ia,ja,bnd_qa)
364 
365  real(RP), intent(in) :: divdmp_coef
366 
367  logical, intent(in) :: flag_fct_momentum
368  logical, intent(in) :: flag_fct_t
369  logical, intent(in) :: flag_fct_tracer
370  logical, intent(in) :: flag_fct_along_stream
371 
372  logical, intent(in) :: use_average
373 
374  real(DP), intent(in) :: dtsec
375  real(DP), intent(in) :: dtsec_dyn
376 
377  ! for time integartion
378  real(RP) :: dens00 (ka,ia,ja) ! saved density before update
379 
380  ! For tracer advection
381  real(RP) :: tflx_hi(ka,ia,ja,3) ! rho * theta * vel(x,y,z) @ (u,v,w)-face high order
382  real(RP) :: dt
383 
384  integer :: i, j, k, iq
385  !---------------------------------------------------------------------------
386 
387  if( io_l ) write(io_fid_log,*) '*** Atmos dynamics step'
388 
389  dt = real(dtsec, kind=rp)
390 
391  if ( dyn_none ) then
392 
393  call prof_rapstart("DYN_Tinteg", 2)
394 
395  do j = js, je
396  do i = is, ie
397  do k = ks, ke
398  dens00(k,i,j) = dens(k,i,j) ! save previous value
399 
400  dens(k,i,j) = dens(k,i,j) + dens_tp(k,i,j) * dt
401  enddo
402  enddo
403  enddo
404 
405  do j = js, je
406  do i = is, ie
407  do k = ks, ke
408  momz(k,i,j) = momz(k,i,j) + momz_tp(k,i,j) * dt
409  enddo
410  enddo
411  enddo
412 
413  do j = js, je
414  do i = is, ie
415  do k = ks, ke
416  momx(k,i,j) = momx(k,i,j) + momx_tp(k,i,j) * dt
417  enddo
418  enddo
419  enddo
420 
421  do j = js, je
422  do i = is, ie
423  do k = ks, ke
424  momy(k,i,j) = momy(k,i,j) + momy_tp(k,i,j) * dt
425  enddo
426  enddo
427  enddo
428 
429  do j = js, je
430  do i = is, ie
431  do k = ks, ke
432  rhot(k,i,j) = rhot(k,i,j) + rhot_tp(k,i,j) * dt
433  enddo
434  enddo
435  enddo
436 
437  do iq = 1, qa
438  do j = js, je
439  do i = is, ie
440  do k = ks, ke
441  qtrc(k,i,j,iq) = max( 0.0_rp, &
442  qtrc(k,i,j,iq) * dens00(k,i,j) + rhoq_tp(k,i,j,iq) * dt &
443  ) / dens(k,i,j)
444  enddo
445  enddo
446  enddo
447  enddo
448 
449  call comm_vars8( dens(:,:,:), i_comm_dens )
450  call comm_vars8( momz(:,:,:), i_comm_momz )
451  call comm_vars8( momx(:,:,:), i_comm_momx )
452  call comm_vars8( momy(:,:,:), i_comm_momy )
453  call comm_vars8( rhot(:,:,:), i_comm_rhot )
454  do iq = 1, qa
455  call comm_vars8( qtrc(:,:,:,iq), i_comm_qtrc(iq) )
456  enddo
457 
458  call comm_wait ( dens(:,:,:), i_comm_dens, .false. )
459  call comm_wait ( momz(:,:,:), i_comm_momz, .false. )
460  call comm_wait ( momx(:,:,:), i_comm_momx, .false. )
461  call comm_wait ( momy(:,:,:), i_comm_momy, .false. )
462  call comm_wait ( rhot(:,:,:), i_comm_rhot, .false. )
463  do iq = 1, qa
464  call comm_wait ( qtrc(:,:,:,iq), i_comm_qtrc(iq), .false. )
465  enddo
466 
467  if ( use_average ) then
468  dens_av(:,:,:) = dens(:,:,:)
469  momz_av(:,:,:) = momz(:,:,:)
470  momx_av(:,:,:) = momx(:,:,:)
471  momy_av(:,:,:) = momy(:,:,:)
472  rhot_av(:,:,:) = rhot(:,:,:)
473  qtrc_av(:,:,:,:) = qtrc(:,:,:,:)
474  endif
475 
476  call prof_rapend("DYN_Tinteg", 2)
477 
478  return
479  endif ! if DYN_NONE == .true.
480 
481  call prof_rapstart("DYN_Tinteg", 2)
482 
483  call atmos_dyn_tinteg_large( dens, momz, momx, momy, rhot, qtrc, & ! [INOUT]
484  prog, & ! [INOUT]
485  dens_av, momz_av, momx_av, momy_av, rhot_av, qtrc_av, & ! [INOUT]
486  mflx_hi, tflx_hi, & ! [OUT]
487  num_diff, num_diff_q, & ! [OUT;WORK]
488  dens_tp, momz_tp, momx_tp, momy_tp, rhot_tp, rhoq_tp, & ! [IN]
489  corioli, & ! [IN]
490  cdz, cdx, cdy, fdz, fdx, fdy, & ! [IN]
491  rcdz, rcdx, rcdy, rfdz, rfdx, rfdy, & ! [IN]
492  phi, gsqrt, & ! [IN]
493  j13g, j23g, j33g, mapf, & ! [IN]
494  aq_r, aq_cv, aq_cp, aq_mass, & ! [IN]
495  ref_dens, ref_pott, ref_qv, ref_pres, & ! [IN]
496  bnd_w, bnd_e, bnd_s, bnd_n, & ! [IN]
497  nd_coef, nd_coef_q, nd_order, nd_sfc_fact, nd_use_rs, & ! [IN]
498  damp_dens, damp_velz, damp_velx, & ! [IN]
499  damp_vely, damp_pott, damp_qtrc, & ! [IN]
500  damp_alpha_dens, damp_alpha_velz, damp_alpha_velx, & ! [IN]
501  damp_alpha_vely, damp_alpha_pott, damp_alpha_qtrc, & ! [IN]
502  wdamp_coef, & ! [IN]
503  divdmp_coef, & ! [IN]
504  flag_fct_momentum, flag_fct_t, flag_fct_tracer, & ! [IN]
505  flag_fct_along_stream, & ! [IN]
506  use_average, & ! [IN]
507  dtsec, dtsec_dyn ) ! [IN]
508 
509  call prof_rapend ("DYN_Tinteg", 2)
510 
511 #ifdef CHECK_MASS
512  call check_mass( dens, damp_dens, & ! [IN]
513  mflx_hi, tflx_hi, & ! [IN]
514  gsqrt, mapf, & ! [IN]
515  rcdx, rcdy, & ! [IN]
516  dt, & ! [IN]
517  bnd_w, bnd_e, bnd_s, bnd_n ) ! [IN]
518 #endif
519 
520  return
521  end subroutine atmos_dyn
522 
523 #ifdef CHECK_MASS
524  !-----------------------------------------------------------------------------
525  subroutine check_mass( &
526  DENS, DAMP_DENS, &
527  mflx_hi, tflx_hi, &
528  GSQRT, MAPF, &
529  RCDX, RCDY, &
530  dt, &
531  BND_W, BND_E, BND_S, BND_N )
532  use mpi
533  use scale_grid_real, only: &
534  vol => real_vol
535  use scale_comm, only: &
536  comm_datatype, &
537  comm_world
538  use scale_history, only: &
539  hist_in
540  use scale_gridtrans, only: &
541  i_xyz, &
542  i_xy
543  implicit none
544 
545  real(RP), intent(in) :: dens (ka,ia,ja)
546  real(RP), intent(in) :: damp_dens(ka,ia,ja)
547  real(RP), intent(in) :: mflx_hi (ka,ia,ja,3)
548  real(RP), intent(in) :: tflx_hi (ka,ia,ja,3)
549  real(RP), intent(in) :: gsqrt (ka,ia,ja,7)
550  real(RP), intent(in) :: mapf ( ia,ja,2,7)
551  real(RP), intent(in) :: rcdx(ia)
552  real(RP), intent(in) :: rcdy(ja)
553  real(RP), intent(in) :: dt
554  logical, intent(in) :: bnd_w
555  logical, intent(in) :: bnd_e
556  logical, intent(in) :: bnd_s
557  logical, intent(in) :: bnd_n
558 
559  ! lateral boundary flux
560  real(RP) :: mflx_lb_horizontal(ka)
561  real(RP) :: allmflx_lb_horizontal(ka)
562  real(RP) :: mflx_lb_total
563  real(RP) :: mass_total
564  real(RP) :: mass_total2
565  real(RP) :: allmflx_lb_total
566  real(RP) :: allmass_total
567  real(RP) :: allmass_total2
568 
569  integer :: k, i, j
570  integer :: ierr
571  !---------------------------------------------------------------------------
572 
573  call hist_in(mflx_hi(:,:,:,zdir), 'MFLXZ', 'momentum flux of z-direction', 'kg/m2/s', zdim='half' )
574  call hist_in(mflx_hi(:,:,:,xdir), 'MFLXX', 'momentum flux of x-direction', 'kg/m2/s', xdim='half' )
575  call hist_in(mflx_hi(:,:,:,ydir), 'MFLXY', 'momentum flux of y-direction', 'kg/m2/s', ydim='half' )
576 
577  call hist_in(tflx_hi(:,:,:,zdir), 'TFLXZ', 'potential temperature flux of z-direction', 'K*kg/m2/s', zdim='half' )
578  call hist_in(tflx_hi(:,:,:,xdir), 'TFLXX', 'potential temperature flux of x-direction', 'K*kg/m2/s', xdim='half' )
579  call hist_in(tflx_hi(:,:,:,ydir), 'TFLXY', 'potential temperature flux of y-direction', 'K*kg/m2/s', ydim='half' )
580 
581  mflx_lb_total = 0.0_rp
582  mflx_lb_horizontal(:) = 0.0_rp
583  allmflx_lb_horizontal(:) = 0.0_rp
584 
585  if ( bnd_w ) then ! for western boundary
586  i = is
587  do j = js, je
588  do k = ks, ke
589  mflx_lb_total = mflx_lb_total + mflx_hi(k,i-1,j,xdir) * rcdx(i) * vol(k,i,j) &
590  * mapf(i,j,1,i_xy) * mapf(i,j,2,i_xy) / gsqrt(k,i,j,i_xyz) * dt
591  mflx_lb_horizontal(k) = mflx_lb_horizontal(k) + mflx_hi(k,i-1,j,xdir) * rcdx(i) * vol(k,i,j) &
592  * mapf(i,j,1,i_xy) * mapf(i,j,2,i_xy) / gsqrt(k,i,j,i_xyz) * dt
593 
594  enddo
595  enddo
596  endif
597  if ( bnd_e ) then ! for eastern boundary
598  i = ie
599  do j = js, je
600  do k = ks, ke
601  mflx_lb_total = mflx_lb_total - mflx_hi(k,i,j,xdir) * rcdx(i) * vol(k,i,j) &
602  * mapf(i,j,1,i_xy) * mapf(i,j,2,i_xy) / gsqrt(k,i,j,i_xyz) * dt
603  mflx_lb_horizontal(k) = mflx_lb_horizontal(k) - mflx_hi(k,i,j,xdir) * rcdx(i) * vol(k,i,j) &
604  * mapf(i,j,1,i_xy) * mapf(i,j,2,i_xy) / gsqrt(k,i,j,i_xyz) * dt
605  enddo
606  enddo
607  endif
608  if ( bnd_s ) then ! for sourthern boundary
609  j = js
610  do i = is, ie
611  do k = ks, ke
612  mflx_lb_total = mflx_lb_total + mflx_hi(k,i,j-1,ydir) * rcdy(j) * vol(k,i,j) &
613  * mapf(i,j,1,i_xy) * mapf(i,j,2,i_xy) / gsqrt(k,i,j,i_xyz) * dt
614  mflx_lb_horizontal(k) = mflx_lb_horizontal(k) + mflx_hi(k,i,j-1,ydir) * rcdy(j) * vol(k,i,j) &
615  * mapf(i,j,1,i_xy) * mapf(i,j,2,i_xy) / gsqrt(k,i,j,i_xyz) * dt
616  enddo
617  enddo
618  endif
619  if ( bnd_n ) then ! for northern boundary
620  j = je
621  do i = is, ie
622  do k = ks, ke
623  mflx_lb_total = mflx_lb_total - mflx_hi(k,i,j,ydir) * rcdy(j) * vol(k,i,j) &
624  * mapf(i,j,1,i_xy) * mapf(i,j,2,i_xy) / gsqrt(k,i,j,i_xyz) * dt
625  mflx_lb_horizontal(k) = mflx_lb_horizontal(k) - mflx_hi(k,i,j,ydir) * rcdy(j) * vol(k,i,j) &
626  * mapf(i,j,1,i_xy) * mapf(i,j,2,i_xy) / gsqrt(k,i,j,i_xyz) * dt
627  enddo
628  enddo
629  endif
630 
631  mass_total = 0.0_rp
632  mass_total2 = 0.0_rp
633 
634  ! check total mass in the inner region
635  do j = js, je
636  do i = is, ie
637  do k = ks, ke
638  mass_total = mass_total + dens(k,i,j) * vol(k,i,j)
639  mass_total2 = mass_total2 + damp_dens(k,i,j) * vol(k,i,j)
640  enddo
641  enddo
642  enddo
643 
644  call mpi_allreduce( mflx_lb_total, &
645  allmflx_lb_total, &
646  1, &
647  comm_datatype, &
648  mpi_sum, &
649  comm_world, &
650  ierr )
651 
652  if( io_l ) write(io_fid_log,'(A,1x,ES24.17)') 'total mflx_lb:', allmflx_lb_total
653 
654  call mpi_allreduce( mass_total, &
655  allmass_total, &
656  1, &
657  comm_datatype, &
658  mpi_sum, &
659  comm_world, &
660  ierr )
661 
662  if( io_l ) write(io_fid_log,'(A,1x,ES24.17)') 'total mass :', allmass_total
663 
664  call mpi_allreduce( mass_total2, &
665  allmass_total2, &
666  1, &
667  comm_datatype, &
668  mpi_sum, &
669  comm_world, &
670  ierr )
671 
672  if( io_l ) write(io_fid_log,'(A,1x,ES24.17)') 'total mass2 :', allmass_total2
673 
674  call mpi_allreduce( mflx_lb_horizontal(ks:ke), &
675  allmflx_lb_horizontal(ks:ke), &
676  kmax, &
677  comm_datatype, &
678  mpi_sum, &
679  comm_world, &
680  ierr )
681 
682  call hist_in(allmflx_lb_horizontal(:), 'ALLMOM_lb_hz', &
683  'horizontally total momentum flux from lateral boundary', 'kg/m2/s' )
684 
685  return
686  end subroutine check_mass
687 #endif
688 
689 end module scale_atmos_dyn
integer, public is
start point of inner domain: x, local
module DEBUG
Definition: scale_debug.F90:13
integer, public comm_datatype
datatype of variable
Definition: scale_comm.F90:117
integer, public je
end point of inner domain: y, local
logical, public prc_has_n
subroutine, public prc_mpistop
Abort MPI.
integer, public va
Definition: scale_index.F90:38
subroutine, public atmos_dyn_tinteg_large_setup(ATMOS_DYN_Tinteg_large_TYPE)
Register.
subroutine, public comm_vars8_init(varname, var, vid)
Register variables.
Definition: scale_comm.F90:313
module Atmosphere / Dynamical scheme
module Atmosphere / Dynamics Temporal integration
module Atmosphere / Dynamics Temporal integration
logical, public io_l
output log or not? (this process)
Definition: scale_stdio.F90:61
subroutine, public atmos_dyn_tstep_tracer_setup(ATMOS_DYN_TSTEP_TRACER_TYPE)
Register.
integer, parameter, public zdir
module Atmosphere / Dynamics FENT + FCT
logical, public prc_has_e
module STDIO
Definition: scale_stdio.F90:12
integer, parameter, public ydir
integer, public ke
end point of inner domain: z, local
integer, parameter, public xdir
integer, public qa
integer, public i_xy
subroutine, public atmos_dyn_setup(DYN_Tinteg_Short_TYPE, DYN_Tinteg_Tracer_TYPE, DYN_Tinteg_Large_TYPE, DYN_Tstep_Tracer_TYPE, DYN_Tstep_Large_TYPE, DYN_FVM_FLUX_TYPE, DYN_FVM_FLUX_TYPE_TRACER, DENS, MOMZ, MOMX, MOMY, RHOT, QTRC, PROG, CDZ, CDX, CDY, FDZ, FDX, FDY, wdamp_tau, wdamp_height, FZ, enable_coriolis, lat, none)
Setup.
module Atmosphere / Dynamical scheme
subroutine, public check(current_line, v)
Undefined value checker.
Definition: scale_debug.F90:58
module Atmosphere / Dynamics Temporal integration
logical, public prc_has_s
subroutine, public atmos_dyn_wdamp_setup(wdamp_coef, wdamp_tau, wdamp_height, FZ)
Setup.
real(rp), public const_undef
Definition: scale_const.F90:43
real(rp), dimension(:,:), allocatable, public corioli
procedure(large), pointer, public atmos_dyn_tinteg_large
subroutine, public atmos_dyn(DENS, MOMZ, MOMX, MOMY, RHOT, QTRC, PROG, DENS_av, MOMZ_av, MOMX_av, MOMY_av, RHOT_av, QTRC_av, DENS_tp, MOMZ_tp, MOMX_tp, MOMY_tp, RHOT_tp, RHOQ_tp, 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, 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, DTSEC, DTSEC_DYN)
Dynamical Process.
module grid index
real(rp), public const_ohm
angular velocity of the planet [1/s]
Definition: scale_const.F90:47
module TRACER
module Index
Definition: scale_index.F90:14
integer, public ia
of whole cells: x, local, with HALO
module GRIDTRANS
module GRID (real space)
integer, public ka
of whole cells: z, local, with HALO
integer, public comm_world
communication world ID
Definition: scale_comm.F90:118
subroutine, public atmos_dyn_filter_setup(num_diff, num_diff_q, CDZ, CDX, CDY, FDZ, FDX, FDY)
Setup.
integer, public kmax
of computational cells: z, local
module COMMUNICATION
Definition: scale_comm.F90:23
integer, public js
start point of inner domain: y, local
integer, parameter, public const_undef2
undefined value (INT2)
Definition: scale_const.F90:40
module Atmosphere / Dynamics common
module PROCESS
real(rp), dimension(:,:,:), allocatable, public real_vol
control volume [m3]
module CONSTANT
Definition: scale_const.F90:14
integer, public ks
start point of inner domain: z, local
subroutine, public prof_rapstart(rapname_base, level)
Start raptime.
Definition: scale_prof.F90:156
module RM PROCESS
module profiler
Definition: scale_prof.F90:10
integer, public ie
end point of inner domain: x, local
subroutine, public atmos_dyn_tstep_large_setup(Tstep_large_type, DENS, MOMZ, MOMX, MOMY, RHOT, QTRC, PROG, mflx_hi)
Register.
subroutine, public atmos_dyn_fvm_flux_setup(scheme, scheme_tracer)
setup
module scale_atmos_dyn_fvm_flux
module PRECISION
module ATMOSPHERE / Boundary treatment
module HISTORY
subroutine, public atmos_dyn_tinteg_short_setup(ATMOS_DYN_Tinteg_short_TYPE)
Register.
integer, public i_xyz
integer, public io_fid_log
Log file ID.
Definition: scale_stdio.F90:56
subroutine, public prof_rapend(rapname_base, level)
Save raptime.
Definition: scale_prof.F90:204
logical, public prc_has_w
integer, parameter, public rp
procedure(short_setup), pointer, public atmos_dyn_tstep_short_setup
subroutine, public atmos_dyn_tinteg_tracer_setup(ATMOS_DYN_Tinteg_tracer_TYPE)
Register.
module Atmosphere / Dynamical scheme
integer, public ja
of whole cells: y, local, with HALO