SCALE-RM
scale_atmos_phy_cp_kf_jmapplib.F90
Go to the documentation of this file.
1 !-------------------------------------------------------------------------------
11 !-------------------------------------------------------------------------------
12 #include "scalelib.h"
14  !-----------------------------------------------------------------------------
15  !
16  !++ used modules
17  !
18  use scale_precision
19  use scale_io
20  use scale_prof
21 
22  use scale_const, only: &
23  undef => const_undef, &
24  iundef => const_undef2
25  !-----------------------------------------------------------------------------
26  implicit none
27  private
28  !-----------------------------------------------------------------------------
29  !
30  !++ Public procedure
31  !
35 
36  !-----------------------------------------------------------------------------
37  !
38  !++ Public parameters & variables
39  !
40  !-----------------------------------------------------------------------------
41  !
42  !++ Private procedure
43  !
44  !-----------------------------------------------------------------------------
45  !
46  !++ Private parameters & variables
47  !
48 #ifdef JMAPPLIB
49  character(len=6), private :: ATMOS_PHY_CP_KF_JMAPPLIB_type = "KF1701"
50  real(RP), allocatable, private :: ishall_counter(:,:)
51  real(RP), allocatable, private :: ideep_counter (:,:)
52 #endif
53  !-----------------------------------------------------------------------------
54 contains
55  !-----------------------------------------------------------------------------
59  subroutine atmos_phy_cp_kf_jmapplib_setup( &
60  KA, KS, KE, IA, JA, &
61  dx, dt )
62  use scale_prc, only: &
63  prc_abort
64  use scale_const, only: &
65  pre00 => const_pre00
66 #ifdef JMAPPLIB
67  use conv_grid, only: &
68  conv_grid_ini
69  use conv_kf_const, only: &
70  conv_kf_const_ini
71  use conv_kf_parm, only: &
72  conv_kf_parm_ini, &
73  conv_kf_parm_get_stepcu
74  use conv_kf_parm1701, only: &
75  conv_kf_parm_ini1701, &
76  conv_kf_parm_get_stepcu1701
77  use conv_kf_lut, only: &
78  conv_kf_lut_ini
79 #endif
80  implicit none
81 
82  integer, intent(in) :: ka, ks, ke
83  integer, intent(in) :: ia, ja
84 
85  real(rp), intent(in) :: dx
86  real(dp), intent(in) :: dt
87 
88 #ifdef JMAPPLIB
89 
90  integer :: atmos_phy_cp_kf_jmapplib_radius_type = 3
94  real(rp) :: atmos_phy_cp_kf_jmapplib_dtlcl_fact = 0.5_rp
95  real(rp) :: atmos_phy_cp_kf_jmapplib_dpmin = 5000.0_rp
96  real(rp) :: atmos_phy_cp_kf_jmapplib_dlifetime = 600.0_rp
97  real(rp) :: atmos_phy_cp_kf_jmapplib_slifetime = 600.0_rp
98  real(rp) :: atmos_phy_cp_kf_jmapplib_detlq_qr_rate = 0.0_rp
99  real(rp) :: atmos_phy_cp_kf_jmapplib_detic_qs_rate = 1.0_rp
100 
101  namelist / param_atmos_phy_cp_kf_jmapplib / &
102  atmos_phy_cp_kf_jmapplib_type, &
103  atmos_phy_cp_kf_jmapplib_radius_type, &
104  atmos_phy_cp_kf_jmapplib_dtlcl_fact, &
105  atmos_phy_cp_kf_jmapplib_dpmin, &
106  atmos_phy_cp_kf_jmapplib_dlifetime, &
107  atmos_phy_cp_kf_jmapplib_slifetime, &
108  atmos_phy_cp_kf_jmapplib_detlq_qr_rate, &
109  atmos_phy_cp_kf_jmapplib_detic_qs_rate
110 
111  integer :: kmax
112 
113  integer :: ierr
114  integer :: k
115  !---------------------------------------------------------------------------
116 
117  log_newline
118  log_info("ATMOS_PHY_CP_KF_JMAPPLIB_setup",*) 'Setup'
119  log_info("ATMOS_PHY_CP_KF_JMAPPLIB_setup",*) 'KF scheme implemented in the JMA Physics Process Library'
120 
121  !--- read namelist
122  rewind(io_fid_conf)
123  read(io_fid_conf,nml=param_atmos_phy_cp_kf_jmapplib,iostat=ierr)
124  if( ierr > 0 ) then !--- fatal error
125  log_error("ATMOS_PHY_CP_KF_JMAPPLIB_setup",*) 'Not appropriate names in namelist PARAM_ATMOS_PHY_CP_KF_JMAPPLIB. Check!'
126  call prc_abort
127  endif
128  log_nml(param_atmos_phy_cp_kf_jmapplib)
129 
130 
131  kmax = ke - ks + 1
132  call conv_grid_ini( kmax )
133  call conv_kf_const_ini( dx, pre00, dt )
134 
135  select case ( atmos_phy_cp_kf_jmapplib_type )
136  case ( "KF" )
137 
138  call conv_kf_parm_ini( &
139  dt, &
140  kfrad_var_in = atmos_phy_cp_kf_jmapplib_radius_type, &
141  cudt_in = -1.0_rp, &
142  dtlcl_fct_in = atmos_phy_cp_kf_jmapplib_dtlcl_fact, &
143  dpmin_in = atmos_phy_cp_kf_jmapplib_dpmin, &
144  cu_lifetime_min_in = atmos_phy_cp_kf_jmapplib_dlifetime, &
145  shallow_lifetime_in = atmos_phy_cp_kf_jmapplib_slifetime, &
146  detlq_qr_r_in = atmos_phy_cp_kf_jmapplib_detlq_qr_rate, &
147  detic_qs_r_in = atmos_phy_cp_kf_jmapplib_detic_qs_rate )
148 
149 ! call conv_kf_parm_get_stepcu(stepcu) ! (out)
150 
151  case ( "KF1701" )
152 
153  call conv_kf_parm_ini1701( &
154  dt, &
155  kfrad_var_in = atmos_phy_cp_kf_jmapplib_radius_type, &
156  kfrad_in = 1000.0_rp, &
157  cudt_in = -1.0_rp, &
158  dpmin_in = atmos_phy_cp_kf_jmapplib_dpmin, &
159  cu_lifetime_min_in = atmos_phy_cp_kf_jmapplib_dlifetime, &
160  shallow_lifetime_in = atmos_phy_cp_kf_jmapplib_slifetime, &
161  detlq_qr_r_in = atmos_phy_cp_kf_jmapplib_detlq_qr_rate, &
162  detic_qs_r_in = atmos_phy_cp_kf_jmapplib_detic_qs_rate, &
163  tkemax_in = 1.0_rp )
164 
165 ! call conv_kf_parm_get_stepcu1701(stepcu) ! (out)
166 
167  case default
168  log_error("ATMOS_PHY_CP_KF_JMAPPLIB_setup",*) 'ATMOS_PHY_CP_KF_TYPE must be either "KF" or "KF1701"'
169  call prc_abort
170  end select
171 
172  call conv_kf_lut_ini
173 
174  allocate( ishall_counter(ia,ja), ideep_counter(ia,ja) )
175  ishall_counter(:,:) = 0.0_rp
176  ideep_counter(:,:) = 0.0_rp
177 
178 #else
179 
180  log_error("ATMOS_PHY_CP_KF_JMAPPLIB_setup",*) 'To use "KF-JMAPPLIB", compile SCALE with "SCALE_ENABLE_JMAPPLIB=T" option.'
181  call prc_abort
182 
183 #endif
184 
185  return
186  end subroutine atmos_phy_cp_kf_jmapplib_setup
187 
188  !-----------------------------------------------------------------------------
189  !! Finalize
190 
192  implicit none
193 
194 #ifdef JMAPPLIB
195  deallocate( ishall_counter, ideep_counter )
196 #endif
197 
198  return
199  end subroutine atmos_phy_cp_kf_jmapplib_finalize
200 
201  !-----------------------------------------------------------------------------
206  KA, KS, KE, IA, IS, IE, JA, JS, JE, &
207  DENS, U, V, W, TEMP, POTT, &
208  PRES, EXNER, &
209  QDRY, QV, QC, QI, &
210  us, PBLH, SFLX_BUOY, &
211  CZ, FZ, &
212  DENS_t, RHOT_t, &
213  RHOQV_t, RHOQ_t, &
214  w0avg, nca, &
215  SFLX_rain, SFLX_snow, SFLX_prec, &
216  cloudtop, cloudbase )
218  n_hyd, &
219  i_hc, &
220  i_hr, &
221  i_hi, &
222  i_hs, &
223  i_hg
224 #ifdef JMAPPLIB
225  use conv_kf_main, only: &
226  conv_kf_run
227  use conv_kf_main1701, only: &
228  conv_kf_run1701
229  use pbl_diag, only: &
230  pbl_diag_buoyancy_excess
231 #endif
232  implicit none
233 
234  integer, intent(in) :: ka, ks, ke
235  integer, intent(in) :: ia, is, ie
236  integer, intent(in) :: ja, js, je
237 
238  real(rp), intent(in) :: dens (ka,ia,ja)
239  real(rp), intent(in) :: u (ka,ia,ja)
240  real(rp), intent(in) :: v (ka,ia,ja)
241  real(rp), intent(in) :: w (ka,ia,ja)
242  real(rp), intent(in) :: temp (ka,ia,ja)
243  real(rp), intent(in) :: pott (ka,ia,ja)
244  real(rp), intent(in) :: pres (ka,ia,ja)
245  real(rp), intent(in) :: exner(ka,ia,ja)
246  real(rp), intent(in) :: qdry (ka,ia,ja)
247  real(rp), intent(in) :: qv (ka,ia,ja)
248  real(rp), intent(in) :: qc (ka,ia,ja)
249  real(rp), intent(in) :: qi (ka,ia,ja)
250  real(rp), intent(in) :: us (ia,ja)
251  real(rp), intent(in) :: pblh (ia,ja)
252  real(rp), intent(in) :: sflx_buoy(ia,ja)
253  real(rp), intent(in) :: cz (ka,ia,ja)
254  real(rp), intent(in) :: fz (0:ka,ia,ja)
255 
256  real(rp), intent(out) :: dens_t (ka,ia,ja)
257  real(rp), intent(inout) :: rhot_t (ka,ia,ja)
258  real(rp), intent(inout) :: rhoqv_t(ka,ia,ja)
259  real(rp), intent(inout) :: rhoq_t (ka,ia,ja,n_hyd)
260  real(rp), intent(inout) :: w0avg (ka,ia,ja)
261  real(rp), intent(inout) :: nca (ia,ja)
262  real(rp), intent(inout) :: sflx_rain(ia,ja)
263  real(rp), intent(inout) :: sflx_snow(ia,ja)
264  real(rp), intent(inout) :: sflx_prec(ia,ja)
265  real(rp), intent(inout) :: cloudtop (ia,ja)
266  real(rp), intent(inout) :: cloudbase(ia,ja)
267 
268 #ifdef JMAPPLIB
269 
270  integer, parameter :: iconv_run = 1
271 
272  real(rp) :: tend_pt(ks:ke)
273  real(rp) :: tend_qv(ks:ke)
274  real(rp) :: tend_qc(ks:ke)
275  real(rp) :: tend_qr(ks:ke)
276  real(rp) :: tend_qi(ks:ke)
277  real(rp) :: tend_qs(ks:ke)
278  real(rp) :: tend_qg(ks:ke)
279  real(rp) :: dens_lc(ks:ke)
280  real(rp) :: qv_lc (ks:ke)
281  real(rp) :: qc_lc
282  real(rp) :: qi_lc
283  real(rp) :: z_f (ks:ke)
284  real(rp) :: dz_f (ks:ke)
285 
286  real(rp) :: lcl_temp(ia,ja)
287  real(rp) :: abe_out
288  real(rp) :: tv_ex
289  real(rp) :: ptv_ex
290 
291  integer :: k, i, j
292  !---------------------------------------------------------------------------
293 
294  log_progress(*) "atmosphere / physics / cumulus / KF-JMAPPLIB"
295 
296  !$omp parallel do &
297  !$omp private(tend_pt,tend_qv,tend_qc,tend_qr,tend_qi,tend_qs,tend_qg, &
298  !$omp dens_lc,qv_lc,qc_lc,qi_lc,z_f,dz_f, &
299  !$omp ptv_ex,tv_ex,abe_out)
300  do j = js, je
301  do i = is, ie
302 
303  do k = ks, ke
304  dens_lc(k) = dens(k,i,j) * qdry(k,i,j)
305  qv_lc(k) = qv(k,i,j) / qdry(k,i,j)
306  tend_pt(k) = rhot_t(k,i,j) / dens(k,i,j)
307  tend_qv(k) = rhoqv_t(k,i,j) / dens_lc(k)
308  tend_qc(k) = rhoq_t(k,i,j,i_hc) / dens_lc(k)
309  tend_qr(k) = rhoq_t(k,i,j,i_hr) / dens_lc(k)
310  tend_qi(k) = rhoq_t(k,i,j,i_hi) / dens_lc(k)
311  tend_qs(k) = rhoq_t(k,i,j,i_hs) / dens_lc(k)
312  tend_qg(k) = rhoq_t(k,i,j,i_hg) / dens_lc(k)
313 
314  z_f(k) = cz(k,i,j) - fz(ks-1,i,j)
315  dz_f(k) = fz(k,i,j) - fz(k-1,i,j)
316  end do
317 
318  select case ( atmos_phy_cp_kf_jmapplib_type )
319  case ( "KF" )
320 
321  call conv_kf_run( &
322  iconv_run, & ! (in)
323  u(ks:ke,i,j), v(ks:ke,i,j), w(ks:ke,i,j), temp(ks:ke,i,j), qv_lc(:), & ! (in)
324  pres(ks:ke,i,j), exner(ks:ke,i,j), dens_lc(:), z_f(:), dz_f(:), & ! (in)
325  nca(i,j), & ! (inout)
326  sflx_prec(i,j), sflx_rain(i,j), sflx_snow(i,j), & ! (inout)
327  cloudtop(i,j), cloudbase(i,j), abe_out, & ! (inout)
328  ishall_counter(i,j), ideep_counter(i,j), & ! (inout)
329  lcl_temp(i,j), & ! (inout)
330  w0avg(ks:ke,i,j), & ! (inout)
331  tend_pt(:), tend_qv(:), tend_qc(:), & ! (inout)
332  tend_qi(:), tend_qr(:), tend_qs(:) ) ! (inout)
333 
334  tend_qg(ks:ke) = 0.0_rp
335 
336  case ( "KF1701" )
337 
338  qc_lc = qc(ks,i,j) / qdry(ks,i,j)
339  qi_lc = qi(ks,i,j) / qdry(ks,i,j)
340  call pbl_diag_buoyancy_excess( &
341  pott(ks,i,j), qv_lc(ks),qc_lc, qi_lc, & ! (in)
342  pblh(i,j), us(i,j), sflx_buoy(i,j), exner(ks,i,j), & ! (in)
343  ptv_ex, tv_ex ) ! (out)
344 
345  call conv_kf_run1701( &
346  iconv_run, & ! (in)
347  u(ks:ke,i,j), v(ks:ke,i,j), w(ks:ke,i,j), temp(ks:ke,i,j), qv_lc(:), & ! (in)
348  pres(ks:ke,i,j), exner(ks:ke,i,j), dens_lc(:), z_f(:), dz_f(:), & ! (in)
349  pblh(i,j), tv_ex, & ! (in)
350  nca(i,j), & ! (inout)
351  sflx_prec(i,j), sflx_rain(i,j), sflx_snow(i,j), & ! (inout)
352  cloudtop(i,j), cloudbase(i,j), abe_out, & ! (inout)
353  ishall_counter(i,j), ideep_counter(i,j), & ! (inout)
354  lcl_temp(i,j), & ! (inout)
355  w0avg(ks:ke,i,j), & ! (inout)
356  tend_pt(:), tend_qv(:), tend_qc(:), & ! (inout)
357  tend_qi(:), tend_qr(:), & ! (inout)
358  tend_qs(:), tend_qg(:) ) ! (inout)
359 
360  end select
361 
362  if ( nca(i,j) < -1 ) nca(i,j) = -1
363 
364  do k = ks, ke
365  rhot_t(k,i,j) = tend_pt(k) * dens(k,i,j)
366  rhoqv_t(k,i,j) = tend_qv(k) * dens_lc(k)
367  rhoq_t(k,i,j,i_hc) = tend_qc(k) * dens_lc(k)
368  rhoq_t(k,i,j,i_hr) = tend_qr(k) * dens_lc(k)
369  rhoq_t(k,i,j,i_hi) = tend_qi(k) * dens_lc(k)
370  rhoq_t(k,i,j,i_hs) = tend_qs(k) * dens_lc(k)
371  rhoq_t(k,i,j,i_hg) = tend_qg(k) * dens_lc(k)
372  dens_t(k,i,j) = rhoqv_t(k,i,j) &
373  + rhoq_t(k,i,j,i_hc) + rhoq_t(k,i,j,i_hr) &
374  + rhoq_t(k,i,j,i_hi) + rhoq_t(k,i,j,i_hs) + rhoq_t(k,i,j,i_hg)
375  end do
376 
377  end do
378  end do
379 
380 #endif
381 
382  return
383  end subroutine atmos_phy_cp_kf_jmapplib_tendency
384 
scale_prc::prc_abort
subroutine, public prc_abort
Abort Process.
Definition: scale_prc.F90:350
scale_atmos_hydrometeor::i_hr
integer, parameter, public i_hr
liquid water rain
Definition: scale_atmos_hydrometeor.F90:98
scale_atmos_phy_cp_kf_jmapplib
module atmosphere / physics / cumulus / kf-jmapplib
Definition: scale_atmos_phy_cp_kf_jmapplib.F90:13
scale_atmos_hydrometeor::i_hs
integer, parameter, public i_hs
snow
Definition: scale_atmos_hydrometeor.F90:100
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_phy_cp_kf_jmapplib::atmos_phy_cp_kf_jmapplib_finalize
subroutine, public atmos_phy_cp_kf_jmapplib_finalize
Definition: scale_atmos_phy_cp_kf_jmapplib.F90:192
scale_atmos_hydrometeor
module atmosphere / hydrometeor
Definition: scale_atmos_hydrometeor.F90:12
scale_prc
module PROCESS
Definition: scale_prc.F90:11
scale_atmos_hydrometeor::i_hi
integer, parameter, public i_hi
ice water cloud
Definition: scale_atmos_hydrometeor.F90:99
scale_io
module STDIO
Definition: scale_io.F90:10
scale_atmos_phy_cp_kf_jmapplib::atmos_phy_cp_kf_jmapplib_tendency
subroutine, public atmos_phy_cp_kf_jmapplib_tendency(KA, KS, KE, IA, IS, IE, JA, JS, JE, DENS, U, V, W, TEMP, POTT, PRES, EXNER, QDRY, QV, QC, QI, us, PBLH, SFLX_BUOY, CZ, FZ, DENS_t, RHOT_t, RHOQV_t, RHOQ_t, w0avg, nca, SFLX_rain, SFLX_snow, SFLX_prec, cloudtop, cloudbase)
ATMOS_PHY_CP_KF_JMAPPLIB_tendency calculate tendency by the virtical eddy viscosity.
Definition: scale_atmos_phy_cp_kf_jmapplib.F90:217
scale_const
module CONSTANT
Definition: scale_const.F90:11
scale_prof
module profiler
Definition: scale_prof.F90:11
scale_precision::dp
integer, parameter, public dp
Definition: scale_precision.F90:32
scale_atmos_hydrometeor::i_hc
integer, parameter, public i_hc
liquid water cloud
Definition: scale_atmos_hydrometeor.F90:97
scale_atmos_phy_cp_kf_jmapplib::atmos_phy_cp_kf_jmapplib_setup
subroutine, public atmos_phy_cp_kf_jmapplib_setup(KA, KS, KE, IA, JA, dx, dt)
ATMOS_PHY_CP_KF_JMAPPLIB_setup Setup.
Definition: scale_atmos_phy_cp_kf_jmapplib.F90:62
scale_const::const_undef
real(rp), public const_undef
Definition: scale_const.F90:43
scale_const::const_pre00
real(rp), public const_pre00
pressure reference [Pa]
Definition: scale_const.F90:97
scale_io::io_fid_conf
integer, public io_fid_conf
Config file ID.
Definition: scale_io.F90:57
scale_atmos_hydrometeor::n_hyd
integer, parameter, public n_hyd
Definition: scale_atmos_hydrometeor.F90:95
scale_atmos_hydrometeor::i_hg
integer, parameter, public i_hg
graupel
Definition: scale_atmos_hydrometeor.F90:101