SCALE-RM
scale_atmos_phy_bl_common.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
20 
21 #if defined DEBUG || defined QUICKDEBUG
22  use scale_debug, only: &
23  check
24 #endif
25  use scale_const, only: &
26  undef => const_undef, &
27  iundef => const_undef2
28  !-----------------------------------------------------------------------------
29  implicit none
30  private
31  !-----------------------------------------------------------------------------
32  !
33  !++ Public procedure
34  !
36 
37  !-----------------------------------------------------------------------------
38  !
39  !++ Public parameters & variables
40  !
41  !-----------------------------------------------------------------------------
42  !
43  !++ Private procedure
44  !
45  !-----------------------------------------------------------------------------
46  !
47  !++ Private parameters & variables
48  !
49  !-----------------------------------------------------------------------------
50 contains
51  !-----------------------------------------------------------------------------
55  subroutine atmos_phy_bl_tendency_tracer( &
56  KA, KS, KE, IA, IS, IE, JA, JS, JE, &
57  DENS, QTRC, SFLX_Q, &
58  Kh, MASS, &
59  CZ, FZ, F2H, DDT, &
60  TRACER_NAME, &
61  RHOQ_t )
62  use scale_matrix, only: &
63  matrix_solver_tridiagonal
64  use scale_file_history, only: &
65  file_history_in
66  integer, intent(in) :: ka, ks, ke
67  integer, intent(in) :: ia, is, ie
68  integer, intent(in) :: ja, js, je
69 
70  real(rp), intent(in) :: dens (ka,ia,ja)
71  real(rp), intent(in) :: qtrc (ka,ia,ja)
72  real(rp), intent(in) :: sflx_q( ia,ja)
73  real(rp), intent(in) :: kh (ka,ia,ja)
74  real(rp), intent(in) :: mass
75  real(rp), intent(in) :: cz ( ka,ia,ja)
76  real(rp), intent(in) :: fz (0:ka,ia,ja)
77  real(rp), intent(in) :: f2h(ka,2,ia,ja)
78  real(dp), intent(in) :: ddt
79  character(len=*), intent(in) :: tracer_name
80 
81  real(rp), intent(out) :: rhoq_t(ka,ia,ja)
82 
83  real(rp) :: qtrc_n(ka)
84  real(rp) :: rho (ka)
85  real(rp) :: rhokh (ka)
86  real(rp) :: a(ka)
87  real(rp) :: b(ka)
88  real(rp) :: c(ka)
89  real(rp) :: d(ka)
90  real(rp) :: rho_h
91  real(rp) :: ap
92  real(rp) :: sf_t
93 
94  real(rp) :: flx(ka,ia,ja)
95 
96  real(rp) :: cdz(ka)
97  real(rp) :: fdz(ka)
98 
99  real(rp) :: dt
100 
101  integer :: ke_pbl
102  integer :: k, i, j
103 
104 #ifdef _OPENACC
105  real(rp) :: work(ks:ke,4)
106 #endif
107  dt = real( ddt, kind=rp )
108 
109  !$acc data create(flx)
110 
111 !OCL INDEPENDENT
112  !$omp parallel do default(none) OMP_SCHEDULE_ collapse(2) &
113  !$omp shared(KA,KS,KE,IS,IE,JS,JE) &
114  !$omp shared(RHOQ_t,DENS,QTRC,SFLX_Q,Kh,MASS,CZ,FZ,F2H,DT,flx) &
115  !$omp private(QTRC_n,RHO,RHOKh,rho_h,a,b,c,d,ap,sf_t,CDZ,FDZ) &
116  !$omp private(KE_PBL,k,i,j)
117  !$acc kernels
118  !$acc loop independent collapse(2) &
119  !$acc private(QTRC_n,RHO,RHOKh,rho_h,a,b,c,d,ap,sf_t,CDZ,FDZ, &
120  !$acc KE_PBL, &
121  !$acc work)
122  do j = js, je
123  do i = is, ie
124 
125  ke_pbl = ke-1
126  !$acc loop seq
127  do k = ke-2, ks+1, -1
128  if ( kh(k,i,j) > 0.0_rp ) then
129  ke_pbl = k + 1
130  else
131  exit
132  end if
133  end do
134 
135  do k = ks, ke_pbl
136  cdz(k) = fz(k ,i,j) - fz(k-1,i,j)
137  fdz(k) = cz(k+1,i,j) - cz(k ,i,j)
138  end do
139 
140  sf_t = sflx_q(i,j) / cdz(ks)
141 
142  rho(ks) = dens(ks,i,j) + dt * sf_t * mass
143  do k = ks+1, ke_pbl
144  rho(k) = dens(k,i,j)
145  end do
146 
147  ! dens * coefficient at the half level
148  do k = ks, ke_pbl-1
149  rho_h = f2h(k,1,i,j) * dens(k+1,i,j) + f2h(k,2,i,j) * dens(k,i,j)
150  rhokh(k) = rho_h * kh(k,i,j)
151  end do
152 
153  d(ks) = ( qtrc(ks,i,j) * dens(ks,i,j) + dt * sf_t ) / rho(ks)
154  do k = ks+1, ke_pbl
155  d(k) = qtrc(k,i,j)
156  end do
157 
158  c(ks) = 0.0_rp
159  do k = ks, ke_pbl-1
160  ap = - dt * rhokh(k) / fdz(k)
161  a(k) = ap / ( rho(k) * cdz(k) )
162 #ifdef _OPENACC
163  if ( k==ks ) then
164  b(k) = - a(k) + 1.0_rp
165  else
166  b(k) = - a(k) + dt * rhokh(k-1) / ( fdz(k-1) * rho(k) * cdz(k) ) + 1.0_rp
167  end if
168 #else
169  b(k) = - a(k) - c(k) + 1.0_rp
170 #endif
171  c(k+1) = ap / ( rho(k+1) * cdz(k+1) )
172  end do
173  a(ke_pbl) = 0.0_rp
174  b(ke_pbl) = - c(ke_pbl) + 1.0_rp
175 
176  call matrix_solver_tridiagonal( &
177  ka, ks, ke_pbl, &
178 #ifdef _OPENACC
179  work(:,:), & ! (wrok)
180 #endif
181  a(:), b(:), c(:), d(:), & ! (in)
182  qtrc_n(:) ) ! (out)
183 
184  rhoq_t(ks,i,j) = ( qtrc_n(ks) * rho(ks) - qtrc(ks,i,j) * dens(ks,i,j) ) / dt - sf_t
185  do k = ks+1, ke_pbl
186  rhoq_t(k,i,j) = ( qtrc_n(k) - qtrc(k,i,j) ) * rho(k) / dt
187  end do
188  do k = ke_pbl+1, ke
189  rhoq_t(k,i,j) = 0.0_rp
190  end do
191 
192  do k = ks, ke_pbl-1
193  flx(k,i,j) = - rhokh(k) * ( qtrc_n(k+1) - qtrc_n(k) ) / fdz(k)
194  end do
195 
196  end do
197  end do
198  !$acc end kernels
199 
200  call file_history_in(flx(:,:,:), 'ZFLX_'//trim(tracer_name)//'_BL', 'Z FLUX of DENS * '//trim(tracer_name)//' (PBL)', 'kg/m2/s', fill_halo=.true.)
201 
202  !$acc end data
203 
204  return
205  end subroutine atmos_phy_bl_tendency_tracer
206 
207 end module scale_atmos_phy_bl_common
scale_atmos_grid_cartesc_index::ke
integer, public ke
end point of inner domain: z, local
Definition: scale_atmos_grid_cartesC_index.F90:52
scale_const::const_undef2
integer, parameter, public const_undef2
undefined value (INT2)
Definition: scale_const.F90:40
scale_precision
module PRECISION
Definition: scale_precision.F90:14
scale_atmos_grid_cartesc_index::ka
integer, public ka
Definition: scale_atmos_grid_cartesC_index.F90:47
scale_tracer::mass
real(rp), public mass
Definition: scale_tracer.F90:47
scale_file_history
module file_history
Definition: scale_file_history.F90:15
scale_precision::rp
integer, parameter, public rp
Definition: scale_precision.F90:41
scale_atmos_grid_cartesc_index::ie
integer, public ie
end point of inner domain: x, local
Definition: scale_atmos_grid_cartesC_index.F90:54
scale_io
module STDIO
Definition: scale_io.F90:10
scale_tracer::k
real(rp), public k
Definition: scale_tracer.F90:45
scale_const
module CONSTANT
Definition: scale_const.F90:11
scale_atmos_grid_cartesc_index::ia
integer, public ia
Definition: scale_atmos_grid_cartesC_index.F90:48
scale_debug::check
subroutine, public check(current_line, v)
Undefined value checker.
Definition: scale_debug.F90:59
scale_tracer::tracer_name
character(len=h_short), dimension(qa_max), public tracer_name
Definition: scale_tracer.F90:39
scale_atmos_phy_bl_common::atmos_phy_bl_tendency_tracer
subroutine, public atmos_phy_bl_tendency_tracer(KA, KS, KE, IA, IS, IE, JA, JS, JE, DENS, QTRC, SFLX_Q, Kh, MASS, CZ, FZ, F2H, DDT, TRACER_NAME, RHOQ_t)
ATMOS_PHY_BL_tendency_tracer calculate tendency of tracers by the eddy viscosity.
Definition: scale_atmos_phy_bl_common.F90:62
scale_prof
module profiler
Definition: scale_prof.F90:11
scale_atmos_grid_cartesc_index::is
integer, public is
start point of inner domain: x, local
Definition: scale_atmos_grid_cartesC_index.F90:53
scale_precision::dp
integer, parameter, public dp
Definition: scale_precision.F90:32
scale_atmos_grid_cartesc_index::ja
integer, public ja
Definition: scale_atmos_grid_cartesC_index.F90:49
scale_atmos_grid_cartesc_index::ks
integer, public ks
start point of inner domain: z, local
Definition: scale_atmos_grid_cartesC_index.F90:51
scale_debug
module DEBUG
Definition: scale_debug.F90:11
scale_atmos_grid_cartesc_index::js
integer, public js
start point of inner domain: y, local
Definition: scale_atmos_grid_cartesC_index.F90:55
scale_matrix
module MATRIX
Definition: scale_matrix.F90:17
scale_const::const_undef
real(rp), public const_undef
Definition: scale_const.F90:43
scale_atmos_grid_cartesc_index::je
integer, public je
end point of inner domain: y, local
Definition: scale_atmos_grid_cartesC_index.F90:56
scale_atmos_phy_bl_common
module atmosphere / physics / pbl / common
Definition: scale_atmos_phy_bl_common.F90:12