19 #elif defined(_OPENMP)
65 integer,
private :: ITMAX = 3000
66 real(RP),
private :: epsilon = 0.1_rp ** (rp*2)
67 character(len=64),
private :: NUTR_TYPE=
'F2013'
68 character(len=64),
private,
save :: NUTR_qhyd=
'Each_POLARITY2'
69 integer,
private :: MAX_NUTR = 100
70 real(RP),
private :: Eint = 150.0e+3_rp
71 real(RP),
private :: delEint = 10.0e+3_rp
72 real(RP),
private :: Estop = 15.0e+3_rp
73 real(RP),
private :: qrho_chan = 0.5_rp
74 real(RP),
private :: qrho_neut = 0.5_rp
75 real(RP),
private :: fp = 0.3_rp
76 real(RP),
private :: zcg = 0.0_rp
77 integer,
private :: NUTR_ITMAX = 1000
78 integer,
private :: FLAG_preprocessing = 2
82 integer,
private :: KIJMAXG
83 character(len=H_LONG) :: ATMOS_PHY_LT_LUT_FILENAME
84 character(len=H_LONG) :: fname_lut_lt=
"LUT_TK1978_v.txt"
85 integer,
save :: fid_lut_lt
86 real(RP),
private :: R_neut = 2000.0_rp
87 real(RP),
private :: rho0 = 1.225_rp
88 real(RP),
save :: flg_eint_hgt
89 logical,
private :: LT_DO_Lightning = .true.
92 real(RP),
allocatable,
private :: d_QCRG_TOT(:,:,:)
93 real(RP),
allocatable,
private :: LT_PATH_TOT(:,:,:,:)
94 real(RP),
allocatable,
private :: fls_int_p_tot(:,:,:)
95 real(RP),
allocatable,
private :: B_F2013_TOT(:,:)
96 real(RP),
allocatable,
private :: G_F2013(:,:)
97 real(RP),
private :: C_F2013
99 real(RP),
allocatable,
private :: A(:,:,:,:)
103 integer,
parameter,
private :: nxlut_lt = 200, nylut_lt = 200
104 real(RP),
private :: dq_chrg( nxlut_lt,nylut_lt )
105 real(RP),
private :: grid_lut_t( nxlut_lt )
106 real(RP),
private :: grid_lut_l( nylut_lt )
108 real(RP),
private :: tcrglimit
109 logical,
private :: Hgt_dependency_Eint = .false.
112 integer,
private,
parameter :: I_lt_x = 1
113 integer,
private,
parameter :: I_lt_y = 2
114 integer,
private,
parameter :: I_lt_z = 3
115 integer,
private,
parameter :: I_lt_abs = 4
118 integer,
private,
parameter :: w_nmax = 11
119 integer,
private,
parameter :: I_Ex = 1
120 integer,
private,
parameter :: I_Ey = 2
121 integer,
private,
parameter :: I_Ez = 3
122 integer,
private,
parameter :: I_Eabs = 4
123 integer,
private,
parameter :: I_Epot = 5
124 integer,
private,
parameter :: I_Qneut = 6
125 integer,
private,
parameter :: I_LTpath = 7
126 integer,
private,
parameter :: I_PosFLASH = 8
127 integer,
private,
parameter :: I_NegFLASH = 9
128 integer,
private,
parameter :: I_FlashPoint = 10
129 integer,
private,
parameter :: I_FOD = 11
130 integer,
private :: HIST_id(w_nmax)
131 character(len=H_SHORT),
private :: w_name(w_nmax)
132 character(len=H_MID),
private :: w_longname(w_nmax)
133 character(len=H_SHORT),
private :: w_unit(w_nmax)
134 data w_name /
'Ex', &
146 'X component of Electrical Field', &
147 'Y component of Electrical Field', &
148 'Z component of Electrical Field', &
149 'Absolute value of Electrical Field', &
150 'Electric Potential', &
151 'Cumulative Neutralizated charge', &
152 'Cumulative Number of flash path', &
153 'Cumulative Number of Positive flash', &
154 'Cumulative Number of Negative flash', &
155 'Cumulative Number of Flash point', &
156 'Flash Origin Density' /
219 integer,
intent(in) :: ka, ks, ke
220 integer,
intent(in) :: ia, is, ie
221 integer,
intent(in) :: ja, js, je
222 integer,
intent(in) :: imaxg
223 integer,
intent(in) :: jmaxg
224 integer,
intent(in) :: kmax
226 character(len=*),
intent(in) :: mp_type
227 real(rp),
intent(in) :: cdx(ia)
228 real(rp),
intent(in) :: cdy(ja)
230 integer :: n, myu, ip
234 namelist / param_atmos_phy_lt_sato2019 / &
236 atmos_phy_lt_lut_filename, &
250 hgt_dependency_eint, &
256 read(
io_fid_conf,nml=param_atmos_phy_lt_sato2019,iostat=ierr)
259 log_info(
"ATMOS_PHY_LT_sato2019_setup",*)
'*** Not found namelist. Default used.'
260 elseif( ierr > 0 )
then
261 log_error(
"ATMOS_PHY_LT_sato2019_setup",*)
'xxx Not appropriate names in namelist PARAM_ATMOS_PHY_LT_SATO2019. Check!'
264 log_nml(param_atmos_phy_lt_sato2019)
267 if( zcg <= cz(ks) )
then
271 if( r_neut <= minval( cdx,1 ) .or. r_neut <= minval( cdy,1 ) )
then
272 r_neut = 2.d0 * min( minval( cdx,1 ), minval( cdy,1 ) )
277 fname_lut_lt = atmos_phy_lt_lut_filename
280 open ( fid_lut_lt, file = fname_lut_lt, form =
'formatted', status =
'old', iostat=ierr )
282 if ( ierr == 0 )
then
283 log_info(
"ATMOS_PHY_LT_sato2019_setup",
'(2A)')
'Read LUT of TK78 table from ', trim(fname_lut_lt)
287 read( fid_lut_lt,* ) grid_lut_t( myu ), grid_lut_l( n ), dq_chrg( myu,n )
293 log_error(
"ATMOS_PHY_LT_sato2019_setup",*)
'xxx LUT for LT is requied when ATMOS_PHY_LT_TYPE = SATO2019, stop!'
297 if( nutr_type /=
'MG2001' .and. nutr_type /=
'F2013' )
then
298 log_error(
"ATMOS_PHY_LT_sato2019_setup",*)
'xxx NUTR_TYPE should be MG2001 or F2013 stop!'
303 call comm_bcast( nxlut_lt, nylut_lt, dq_chrg )
304 call comm_bcast( nxlut_lt, grid_lut_t )
305 call comm_bcast( nylut_lt, grid_lut_l )
308 kijmaxg = imaxg*jmaxg*kmax
311 allocate( d_qcrg_tot(ka,ia,ja) )
312 allocate( lt_path_tot(ka,ia,ja,3) )
313 allocate( fls_int_p_tot(ka,ia,ja) )
314 d_qcrg_tot(:,:,:) = 0.0_rp
315 lt_path_tot(:,:,:,:) = 0.0_rp
316 fls_int_p_tot(:,:,:) = 0.0_rp
319 tcrglimit = -60.0_rp+t00
321 if( nutr_type ==
'F2013' )
then
322 log_info(
"ATMOS_PHY_LT_sato2019_setup",
'(A,F15.7,A)')
'Radius of neutralization is ', r_neut,
"[m]"
324 allocate( b_f2013_tot(ia,ja) )
325 allocate( g_f2013(ia,ja) )
326 b_f2013_tot(:,:) = 0.0_rp
329 g_f2013(i,j) = cdx(i)*cdy(j)*1.0e-6_rp
333 c_f2013 = pi*r_neut*r_neut*1.0e-6_rp
335 flg_eint_hgt = 0.0_rp
336 if( hgt_dependency_eint .and. nutr_type ==
'MG2001')
then
337 flg_eint_hgt = 1.0_rp
340 if( nutr_qhyd /=
'TOTAL' .and. nutr_qhyd /=
'Each_POLARITY' .and. nutr_qhyd /=
'Each_POLARITY2' )
then
341 log_error(
"ATMOS_PHY_LT_sato2019_setup",*)
'xxx NUTR_qhyd should be TOTAL, or Each_POLARITY, or Each_POLARITY2, stop!'
351 if( ip /= i_fod )
then
354 elseif( ip == i_fod )
then
356 hist_id(ip), dim_type=
'XY' )
360 allocate( a(ka,15,ia,ja) )
368 - mapf(i,j ,1,
i_xy)*mapf(i,j ,1,
i_xy)*rcdx(i )*rfdx(i) &
369 - mapf(i,j ,1,
i_xy)*mapf(i,j ,1,
i_xy)*rcdx(i-1)*rfdx(i) &
370 + mapf(i,j ,1,
i_xy)*j13g(k,i ,j,
i_uyz)*f2h(k ,i,j,2)*0.5_rp*rfdx(i)*rfdz(k) &
371 - mapf(i,j ,1,
i_xy)*j13g(k,i ,j,
i_uyz)*f2h(k-1,i,j,1)*0.5_rp*rfdx(i)*rfdz(k) &
372 - mapf(i,j ,1,
i_xy)*j13g(k,i-1,j,
i_uyz)*f2h(k ,i,j,2)*0.5_rp*rfdx(i)*rfdz(k) &
373 + mapf(i,j ,1,
i_xy)*j13g(k,i-1,j,
i_uyz)*f2h(k-1,i,j,1)*0.5_rp*rfdx(i)*rfdz(k) &
374 - j13g(k,i,j,
i_xyz)*j13g(k ,i,j,
i_xyw)*rcdz(k)*rfdz(k) &
375 - j13g(k,i,j,
i_xyz)*j13g(k-1,i,j,
i_xyw)*rcdz(k)*rfdz(k) &
376 - mapf(i,j ,2,
i_xy)*mapf(i,j ,2,
i_xy)*rcdy(j )*rfdy(j) &
377 - mapf(i,j ,2,
i_xy)*mapf(i,j ,2,
i_xy)*rcdy(j-1)*rfdy(j) &
378 + mapf(i,j ,2,
i_xy)*j23g(k,i,j ,
i_xvz)*f2h(k ,i,j,2)*0.5_rp*rfdy(j)*rfdz(k) &
379 - mapf(i,j ,2,
i_xy)*j23g(k,i,j ,
i_xvz)*f2h(k-1,i,j,1)*0.5_rp*rfdy(j)*rfdz(k) &
380 - mapf(i,j ,2,
i_xy)*j23g(k,i,j-1,
i_xvz)*f2h(k ,i,j,2)*0.5_rp*rfdy(j)*rfdz(k) &
381 + mapf(i,j ,2,
i_xy)*j23g(k,i,j-1,
i_xvz)*f2h(k-1,i,j,1)*0.5_rp*rfdy(j)*rfdz(k) &
382 - j23g(k,i,j,
i_xyz)*j23g(k ,i,j,
i_xyw)*rcdz(k)*rfdz(k) &
383 - j23g(k,i,j,
i_xyz)*j23g(k-1,i,j,
i_xyw)*rcdz(k)*rfdz(k) &
384 - j33g*j33g*rfdz(k)*rcdz(k) &
385 - j33g*j33g*rfdz(k)*rcdz(k-1)
389 - mapf(i,j,1,
i_xy)*j13g(k,i ,j,
i_uyz)*f2h(k-1,i,j,2)*0.50_rp*rfdx(i)*rfdz(k) &
390 + mapf(i,j,1,
i_xy)*j13g(k,i-1,j,
i_uyz)*f2h(k-1,i,j,2)*0.50_rp*rfdx(i)*rfdz(k) &
391 + j13g(k,i,j,
i_xyz)*j13g(k-1,i,j,
i_xyw)*rfdz(k)*rcdz(k-1) &
392 - mapf(i,j,2,
i_xy)*j23g(k,i,j ,
i_xvz)*f2h(k-1,i,j,2)*0.50_rp*rfdy(j)*rfdz(k) &
393 + mapf(i,j,2,
i_xy)*j23g(k,i,j-1,
i_xvz)*f2h(k-1,i,j,2)*0.50_rp*rfdy(j)*rfdz(k) &
394 + j23g(k,i,j,
i_xyz)*j23g(k-1,i,j,
i_xyw)*rfdz(k)*rcdz(k-1) &
395 + j33g*j33g*rfdz(k)*rcdz(k-1)
399 mapf(i,j,1,
i_xy)*j13g(k,i ,j,
i_uyz)*f2h(k,i,j,1)*0.50_rp*rfdx(i)*rfdz(k) &
400 - mapf(i,j,1,
i_xy)*j13g(k,i-1,j,
i_uyz)*f2h(k,i,j,1)*0.50_rp*rfdx(i)*rfdz(k) &
401 + j13g(k,i,j,
i_xyz)*j13g(k,i,j,
i_xyw)*rfdz(k)*rcdz(k) &
402 + mapf(i,j,2,
i_xy)*j23g(k,i,j ,
i_xvz)*f2h(k,i,j,1)*0.50_rp*rfdy(j)*rfdz(k) &
403 - mapf(i,j,2,
i_xy)*j23g(k,i,j-1,
i_xvz)*f2h(k,i,j,1)*0.50_rp*rfdy(j)*rfdz(k) &
404 + j23g(k,i,j,
i_xyz)*j23g(k,i,j,
i_xyw)*rfdz(k)*rcdz(k) &
405 + j33g*j33g*rfdz(k)*rcdz(k)
409 mapf(i,j,1,
i_xy)*mapf(i-1,j,1,
i_xy)*rfdx(i)*rcdx(i-1) &
410 - mapf(i,j,1,
i_xy)*j13g(k,i-1,j,
i_uyz)*f2h(k ,i-1,j,2)*0.50_rp*rfdx(i)*rfdz(k) &
411 + mapf(i,j,1,
i_xy)*j13g(k,i-1,j,
i_uyz)*f2h(k-1,i-1,j,1)*0.50_rp*rfdx(i)*rfdz(k) &
412 - j13g(k,i,j,
i_xyz)*mapf(i,j,1,
i_xy)*f2h(k ,i-1,j,2)*0.50_rp*rfdx(i)*rfdz(k) &
413 + j13g(k,i,j,
i_xyz)*mapf(i,j,1,
i_xy)*f2h(k-1,i-1,j,1)*0.50_rp*rfdx(i)*rfdz(k)
417 mapf(i,j,1,
i_xy)*mapf(i+1,j,1,
i_xy)*rfdx(i)*rcdx(i) &
418 + mapf(i,j,1,
i_xy)*j13g(k,i,j,
i_uyz)*f2h(k ,i+1,j,2)*0.50_rp*rfdx(i)*rfdz(k) &
419 - mapf(i,j,1,
i_xy)*j13g(k,i,j,
i_uyz)*f2h(k-1,i+1,j,1)*0.50_rp*rfdx(i)*rfdz(k) &
420 + j13g(k,i,j,
i_xyz)*mapf(i,j,1,
i_xy)*f2h(k ,i+1,j,2)*0.50_rp*rfdx(i)*rfdz(k) &
421 - j13g(k,i,j,
i_xyz)*mapf(i,j,1,
i_xy)*f2h(k-1,i+1,j,1)*0.50_rp*rfdx(i)*rfdz(k)
425 mapf(i,j,2,
i_xy)*mapf(i,j-1,2,
i_xy)*rfdy(j)*rcdy(j-1) &
426 - mapf(i,j,2,
i_xy)*j23g(k,i,j-1,
i_xvz)*f2h(k ,i,j-1,2)*0.50_rp*rfdy(j)*rfdz(k) &
427 + mapf(i,j,2,
i_xy)*j23g(k,i,j-1,
i_xvz)*f2h(k-1,i,j-1,1)*0.50_rp*rfdy(j)*rfdz(k) &
428 - j23g(k,i,j,
i_xyz)*mapf(i,j,2,
i_xy)*f2h(k ,i,j-1,2)*0.50_rp*rfdy(j)*rfdz(k) &
429 + j23g(k,i,j,
i_xyz)*mapf(i,j,2,
i_xy)*f2h(k-1,i,j-1,1)*0.50_rp*rfdy(j)*rfdz(k)
433 mapf(i,j,2,
i_xy)*mapf(i,j+1,2,
i_xy)*rfdy(j)*rcdy(j) &
434 + mapf(i,j,2,
i_xy)*j23g(k,i,j,
i_xvz)*f2h(k ,i,j+1,2)*0.50_rp*rfdy(j)*rfdz(k) &
435 - mapf(i,j,2,
i_xy)*j23g(k,i,j,
i_xvz)*f2h(k-1,i,j+1,1)*0.50_rp*rfdy(j)*rfdz(k) &
436 + j23g(k,i,j,
i_xyz)*mapf(i,j,2,
i_xy)*f2h(k ,i,j+1,2)*0.50_rp*rfdy(j)*rfdz(k) &
437 - j23g(k,i,j,
i_xyz)*mapf(i,j,2,
i_xy)*f2h(k-1,i,j+1,1)*0.50_rp*rfdy(j)*rfdz(k)
441 mapf(i,j,1,
i_xy)*j13g(k,i-1,j,
i_uyz)*f2h(k-1,i-1,j,2)*0.5_rp*rfdx(i)*rfdz(k) &
442 + j13g(k,i,j,
i_xyz)*mapf(i,j,1,
i_xy)*f2h(k-1,i-1,j,2)*0.5_rp*rfdx(i)*rfdz(k)
446 - mapf(i,j,1,
i_xy)*j13g(k,i,j,
i_uyz)*f2h(k-1,i+1,j,2)*0.5_rp*rfdx(i)*rfdz(k) &
447 - j13g(k,i,j,
i_xyz)*mapf(i,j,1,
i_xy)*f2h(k-1,i+1,j,2)*0.5_rp*rfdx(i)*rfdz(k)
451 mapf(i,j,2,
i_xy)*j23g(k,i,j-1,
i_xvz)*f2h(k-1,i,j-1,2)*0.5_rp*rfdy(j)*rfdz(k) &
452 + j23g(k,i,j,
i_xyz)*mapf(i,j,2,
i_xy)*f2h(k-1,i,j-1,2)*0.5_rp*rfdy(j)*rfdz(k)
456 - mapf(i,j,2,
i_xy)*j23g(k,i,j,
i_xvz)*f2h(k-1,i,j+1,2)*0.5_rp*rfdy(j)*rfdz(k) &
457 - j23g(k,i,j,
i_xyz)*mapf(i,j,2,
i_xy)*f2h(k-1,i,j+1,2)*0.5_rp*rfdy(j)*rfdz(k)
461 - mapf(i,j,1,
i_xy)*j13g(k,i-1,j,
i_uyz)*f2h(k,i-1,j,1)*0.5_rp*rfdx(i)*rfdz(k) &
462 - j13g(k,i,j,
i_xyz)*mapf(i,j,1,
i_xy)*f2h(k,i-1,j,1)*0.5_rp*rfdx(i)*rfdz(k)
466 mapf(i,j,1,
i_xy)*j13g(k,i,j,
i_uyz)*f2h(k,i+1,j,1)*0.5_rp*rfdx(i)*rfdz(k) &
467 + j13g(k,i,j,
i_xyz)*mapf(i,j,1,
i_xy)*f2h(k,i+1,j,1)*0.5_rp*rfdx(i)*rfdz(k)
471 - mapf(i,j,2,
i_xy)*j23g(k,i,j-1,
i_xvz)*f2h(k,i,j-1,1)*0.5_rp*rfdy(j)*rfdz(k) &
472 - j23g(k,i,j,
i_xyz)*mapf(i,j,2,
i_xy)*f2h(k,i,j-1,1)*0.5_rp*rfdy(j)*rfdz(k)
476 mapf(i,j,2,
i_xy)*j23g(k,i,j,
i_xvz)*f2h(k,i,j+1,1)*0.5_rp*rfdy(j)*rfdz(k) &
477 + j23g(k,i,j,
i_xyz)*mapf(i,j,2,
i_xy)*f2h(k,i,j+1,1)*0.5_rp*rfdy(j)*rfdz(k)
493 deallocate( d_qcrg_tot )
494 deallocate( lt_path_tot )
495 deallocate( fls_int_p_tot )
497 deallocate( b_f2013_tot )
498 deallocate( g_f2013 )
531 file_history_query, &
535 integer,
intent(in) :: ka, ks, ke
536 integer,
intent(in) :: ia, is, ie
537 integer,
intent(in) :: ja, js, je
538 integer,
intent(in) :: kijmax
539 integer,
intent(in) :: imax
540 integer,
intent(in) :: jmax
542 integer,
intent(in) :: qa_lt
543 real(rp),
intent(in) :: dens(ka,ia,ja)
544 real(rp),
intent(in) :: rhot(ka,ia,ja)
545 real(rp),
intent(in) :: qhyd(ka,ia,ja)
546 real(rp),
intent(in) :: sarea(ka,ia,ja,qa_lt)
547 real(
dp),
intent(in) :: dt_lt
548 real(rp),
intent(inout) :: qtrc(ka,ia,ja,qa_lt)
549 real(rp),
intent(inout) :: epot(ka,ia,ja)
551 real(rp) :: qhyd_mass(ka,ia,ja)
552 real(rp) :: qcrg(ka,ia,ja)
553 real(rp) :: efield(ka,ia,ja,i_lt_abs)
554 real(rp) :: num_end(ka,ia,ja,3)
555 real(rp) :: d_qcrg(ka,ia,ja)
556 real(rp) :: lt_path(ka,ia,ja)
557 real(rp) :: fls_int_p(ka,ia,ja)
558 real(rp) :: total_sarea1, total_sarea2
559 real(rp) :: r_totalsarea1, r_totalsarea2
560 real(rp) :: neg_crg, pos_crg
562 real(rp) :: dqneut(ka,ia,ja,qa_lt)
563 real(rp) :: dqneut_real(ka,ia,ja,qa_lt)
564 real(rp) :: dqneut_real_tot(ka,ia,ja)
565 logical :: flg_chrged(qa_lt)
566 real(rp) :: emax, emax_old
567 logical :: output_step
568 integer :: flg_lt_neut
569 integer :: i, j, k, m, n, countbin, ip
570 real(rp) :: sw, zerosw, positive, negative
571 integer :: count_neut
573 logical :: hist_sw(w_nmax)
574 real(rp) :: w3d(ka,ia,ja)
576 real(rp) :: diff_qcrg(0:1), lack(0:1), sum_crg(0:1)
577 real(rp) :: crg_rate(qa_lt), qcrg_before(qa_lt)
578 real(rp) :: b_f2013(ia,ja)
580 real(rp) :: iprod, buf, tmp_qcrg, tmp_dqcrg
591 num_end(:,:,:,:) = 0.0_rp
592 b_f2013(:,:) = 0.0_rp
606 tmp_qcrg = tmp_qcrg + qtrc(k,i,j,n)
608 qcrg(k,i,j) = tmp_qcrg * dens(k,i,j) * 1.e-6_rp
612 qhyd_mass(k,i,j) = qhyd(k,i,j) * dens(k,i,j)
626 iprod = iprod + abs( qcrg(k,i,j) )
634 if( buf <= small )
then
643 efield(k,i,j,i_lt_x) = 0.0_rp
644 efield(k,i,j,i_lt_y) = 0.0_rp
645 efield(k,i,j,i_lt_z) = 0.0_rp
661 efield(:,:,:,i_lt_x:i_lt_z) )
671 efield(k,i,j,i_lt_abs) = sqrt( efield(k,i,j,i_lt_x)*efield(k,i,j,i_lt_x) &
672 + efield(k,i,j,i_lt_y)*efield(k,i,j,i_lt_y) &
673 + efield(k,i,j,i_lt_z)*efield(k,i,j,i_lt_z) )
675 lt_path(k,i,j) = 0.0_rp
682 if ( lt_do_lightning )
then
685 d_qcrg_tot(:,:,:) = 0.0_rp
686 fls_int_p_tot(:,:,:) = 0.0_rp
687 lt_path_tot(:,:,:,:) = 0.0_rp
688 b_f2013_tot(:,:) = 0.0_rp
695 efield(:,:,:,i_lt_abs), &
700 do while( flg_lt_neut > 0 )
704 call comm_vars8( efield(:,:,:,i_lt_x), 1 )
705 call comm_vars8( efield(:,:,:,i_lt_y), 2 )
706 call comm_vars8( efield(:,:,:,i_lt_z), 3 )
707 call comm_vars8( efield(:,:,:,i_lt_abs), 4 )
708 call comm_vars8( qhyd_mass(:,:,:), 5 )
709 call comm_vars8( qcrg(:,:,:), 6 )
710 call comm_vars8( epot(:,:,:), 7 )
711 call comm_wait ( efield(:,:,:,i_lt_x), 1 )
712 call comm_wait ( efield(:,:,:,i_lt_y), 2 )
713 call comm_wait ( efield(:,:,:,i_lt_z), 3 )
714 call comm_wait ( efield(:,:,:,i_lt_abs), 4 )
715 call comm_wait ( qhyd_mass(:,:,:), 5 )
716 call comm_wait ( qcrg(:,:,:), 6 )
717 call comm_wait ( epot(:,:,:), 7 )
720 if( nutr_type ==
'MG2001' )
then
726 kijmax, imax, jmax, &
737 elseif( nutr_type ==
'F2013' )
then
755 call comm_vars8( lt_path(:,:,:),1 )
756 call comm_vars8( d_qcrg(:,:,:),2 )
757 call comm_wait ( lt_path(:,:,:),1 )
758 call comm_wait ( d_qcrg(:,:,:),2 )
761 dqneut(:,:,:,:) = 0.0_rp
762 dqneut_real(:,:,:,:) = 0.0_rp
766 select case( nutr_qhyd )
776 if( abs( d_qcrg(k,i,j) ) > 0.0_rp )
then
777 total_sarea1 = 0.0_rp
780 total_sarea1 = total_sarea1 + sarea(k,i,j,n)
782 zerosw = 0.5_rp - sign( 0.5_rp, total_sarea1-small )
783 r_totalsarea1 = 1.0_rp / ( total_sarea1 + zerosw ) * ( 1.0_rp - zerosw )
786 dqneut(k,i,j,n) = d_qcrg(k,i,j)*1.0e+6_rp &
787 * sarea(k,i,j,n) * r_totalsarea1 / dens(k,i,j)
788 qtrc(k,i,j,n) = qtrc(k,i,j,n) + dqneut(k,i,j,n)
789 dqneut_real(k,i,j,n) = dqneut(k,i,j,n)
797 case (
'Each_POLARITY',
'Each_POLARITY2' )
810 if( abs( d_qcrg(k,i,j) ) > 0.0_rp )
then
815 flg_chrged(n) = abs(qtrc(k,i,j,n)) >= small
818 total_sarea1 = 0.0_rp
819 total_sarea2 = 0.0_rp
824 if ( flg_chrged(n) )
then
825 positive = 0.5_rp + sign( 0.5_rp, qtrc(k,i,j,n) )
826 negative = 1.0_rp - positive
828 pos_crg = pos_crg + qtrc(k,i,j,n) * positive
830 neg_crg = neg_crg + qtrc(k,i,j,n) * negative
832 total_sarea1 = total_sarea1 + sarea(k,i,j,n) * positive
834 total_sarea2 = total_sarea2 + sarea(k,i,j,n) * negative
838 zerosw = 0.5_rp - sign( 0.5_rp, abs( qcrg(k,i,j) ) - small )
839 frac = d_qcrg(k,i,j) / ( qcrg(k,i,j) + zerosw ) * ( 1.0_rp - zerosw )
840 pos_crg = frac * pos_crg
841 neg_crg = frac * neg_crg
844 zerosw = 0.5_rp - sign( 0.5_rp, total_sarea1 - small )
845 r_totalsarea1 = 1.0_rp / ( total_sarea1 + zerosw ) * ( 1.0_rp - zerosw )
846 zerosw = 0.5_rp - sign( 0.5_rp, total_sarea2 - small )
847 r_totalsarea2 = 1.0_rp / ( total_sarea2 + zerosw ) * ( 1.0_rp - zerosw )
849 diff_qcrg(:) = 0.0_rp
857 if ( flg_chrged(n) )
then
858 sw = 0.5_rp + sign( 0.5_rp, qtrc(k,i,j,n) )
860 + pos_crg * sarea(k,i,j,n) * r_totalsarea1 &
862 + neg_crg * sarea(k,i,j,n) * r_totalsarea2 &
864 qcrg_before(n) = qtrc(k,i,j,n)
866 if( sw == 1.0_rp )
then
867 qtrc(k,i,j,n) = max( qtrc(k,i,j,n) + dqneut(k,i,j,n), 0.0_rp )
868 elseif( sw == 0.0_rp )
then
869 qtrc(k,i,j,n) = min( qtrc(k,i,j,n) + dqneut(k,i,j,n), 0.0_rp )
873 diff_qcrg(int_sw) = diff_qcrg(int_sw) &
874 + ( qtrc(k,i,j,n) - qcrg_before(n) )
875 sum_crg(int_sw) = sum_crg(int_sw) + qtrc(k,i,j,n)
879 if( nutr_qhyd ==
'Each_POLARITY2' )
then
880 lack(0) = neg_crg - diff_qcrg(0)
881 lack(1) = pos_crg - diff_qcrg(1)
883 if( lack(0) > 0.0_rp .and. abs(lack(0)/diff_qcrg(0)) > 1.0e-10_rp )
then
884 log_info(
"ATMOS_PHY_LT_sato2019_adjustment",
'(A,4E15.7)') &
885 "Large negative for lack(0) ", lack(0)/diff_qcrg(0), neg_crg, lack(0), diff_qcrg(0)
887 if( lack(1) < 0.0_rp .and. abs(lack(1)/diff_qcrg(1)) > 1.0e-10_rp )
then
888 log_info(
"ATMOS_PHY_LT_sato2019_adjustment",
'(A,4E15.7)') &
889 "Large positive for lack(1) ", lack(1)/diff_qcrg(1), pos_crg, lack(1), diff_qcrg(1)
892 lack(0) = max( lack(0), 0.0_rp )
893 lack(1) = min( lack(1), 0.0_rp )
896 if ( flg_chrged(n) )
then
897 sw = 0.5_rp + sign( 0.5_rp, qtrc(k,i,j,n) )
899 if( sum_crg(int_sw) /= 0.0_rp )
then
900 crg_rate(n) = qtrc(k,i,j,n)/sum_crg(int_sw)
904 qtrc(k,i,j,n) = qtrc(k,i,j,n) + crg_rate(n) * lack(int_sw)
911 if ( flg_chrged(n) )
then
912 dqneut_real(k,i,j,n) = qtrc(k,i,j,n) - qcrg_before(n)
936 tmp_qcrg = tmp_qcrg + qtrc(k,i,j,n)
937 tmp_dqcrg = tmp_dqcrg + dqneut_real(k,i,j,n)
939 qcrg(k,i,j) = tmp_qcrg * dens(k,i,j) * 1.e-6_rp
940 dqneut_real_tot(k,i,j) = tmp_dqcrg
954 iprod = iprod + abs( qcrg(k,i,j) )
962 if( buf <= small )
then
971 efield(k,i,j,i_lt_x) = 0.0_rp
972 efield(k,i,j,i_lt_y) = 0.0_rp
973 efield(k,i,j,i_lt_z) = 0.0_rp
989 efield(:,:,:,i_lt_x:i_lt_z) )
1000 efield(k,i,j,i_lt_abs) = sqrt( efield(k,i,j,i_lt_x)*efield(k,i,j,i_lt_x) &
1001 + efield(k,i,j,i_lt_y)*efield(k,i,j,i_lt_y) &
1002 + efield(k,i,j,i_lt_z)*efield(k,i,j,i_lt_z) )
1009 if ( hist_id(i_qneut) > 0 )
then
1015 d_qcrg_tot(k,i,j) = d_qcrg_tot(k,i,j) + dqneut_real_tot(k,i,j)*1.e-6_rp
1021 if ( hist_id(i_flashpoint) > 0 )
then
1027 fls_int_p_tot(k,i,j) = fls_int_p_tot(k,i,j) + fls_int_p(k,i,j)
1034 if ( hist_id(i_posflash) > 0 )
then
1040 lt_path_tot(k,i,j,1) = lt_path_tot(k,i,j,1) &
1041 + 0.5_rp + sign( 0.5_rp,-dqneut_real_tot(k,i,j)-small )
1047 if ( hist_id(i_negflash) > 0 )
then
1053 lt_path_tot(k,i,j,2) = lt_path_tot(k,i,j,2) &
1054 + 0.5_rp + sign( 0.5_rp, dqneut_real_tot(k,i,j)-small )
1060 if ( hist_id(i_ltpath) > 0 )
then
1066 lt_path_tot(k,i,j,3) = lt_path_tot(k,i,j,3) + lt_path(k,i,j)
1072 if ( hist_id(i_fod) > 0 )
then
1076 b_f2013_tot(i,j) = b_f2013_tot(i,j) + g_f2013(i,j)/c_f2013*b_f2013(i,j)
1086 efield(:,:,:,i_lt_abs), &
1090 count_neut = count_neut + 1
1092 log_info(
"ATMOS_PHY_LT_sato2019_adjustment",
'(A,F15.7,A,F15.7,1X,I0)') &
1094 emax_old*1.e-3_rp,
' [kV/m] -> ', emax*1.e-3_rp, count_neut
1097 if( flg_lt_neut == 1 .and. emax == emax_old )
then
1100 log_info(
"ATMOS_PHY_LT_sato2019_adjustment",
'(A,2(E15.7,A),1X,I0)') &
1101 'Eabs value after neutralization is same as previous value, Finish', &
1102 emax_old*1.e-3_rp,
' [kV/m] -> ', emax*1.e-3_rp, count_neut
1104 elseif( flg_lt_neut == 1 .and. count_neut == max_nutr )
then
1107 log_info(
"ATMOS_PHY_LT_sato2019_adjustment",
'(2(E15.7,A),1X,I0)') &
1108 emax_old*1.e-3_rp,
' [kV/m] -> ', emax*1.e-3_rp, &
1109 ' [kV/m], reach maximum neutralization count, Finish', count_neut
1111 elseif( flg_lt_neut == 1 .and. emax > emax_old )
then
1114 log_info(
"ATMOS_PHY_LT_sato2019_adjustment",
'(2(E15.7,A),1X,I0)') &
1115 emax_old*1.e-3_rp,
' [kV/m] -> ', emax*1.e-3_rp, &
1116 ' [kV/m] larger than previous one by neutralization, back to previous step, Finish', &
1127 qtrc(k,i,j,n) = qtrc(k,i,j,n) - dqneut_real(k,i,j,n)
1129 d_qcrg_tot(k,i,j) = d_qcrg_tot(k,i,j) - dqneut_real_tot(k,i,j)*1.e-6_rp
1130 d_qcrg(k,i,j) = 0.0_rp
1135 elseif( flg_lt_neut == 2 )
then
1138 log_info(
"ATMOS_PHY_LT_sato2019_adjustment",
'(2(E15.7,A),1X,I0)') &
1139 emax_old*1.e-3_rp,
' [kV/m] -> ', emax*1.e-3_rp, &
1140 '[kV/m] After neutralization, Finish' , count_neut
1142 elseif( flg_lt_neut == 0 )
then
1144 log_info(
"ATMOS_PHY_LT_sato2019_adjustment",
'(2(F15.7,A),1X,I0)') &
1145 emax_old*1.e-3_rp,
' [kV/m] -> ', emax*1.e-3_rp, &
1146 '[kV/m] After neutralization, Finish', count_neut
1160 d_qcrg(k,i,j) = 0.0_rp
1170 call file_history_query( hist_id(ip), hist_sw(ip) )
1173 if ( hist_sw(i_ex ) )
then
1180 w3d(k,i,j) = efield(k,i,j,i_lt_x )*1.0e-3_rp
1185 call file_history_put( hist_id(i_ex ), w3d(:,:,:) )
1187 if ( hist_sw(i_ey ) )
then
1194 w3d(k,i,j) = efield(k,i,j,i_lt_y )*1.0e-3_rp
1199 call file_history_put( hist_id(i_ey ), w3d(:,:,:) )
1201 if ( hist_sw(i_ez ) )
then
1208 w3d(k,i,j) = efield(k,i,j,i_lt_z )*1.0e-3_rp
1213 call file_history_put( hist_id(i_ez ), w3d(:,:,:) )
1215 if ( hist_sw(i_eabs) )
then
1222 w3d(k,i,j) = efield(k,i,j,i_lt_abs)*1.0e-3_rp
1227 call file_history_put( hist_id(i_eabs), w3d(:,:,:) )
1229 if ( hist_sw(i_epot) )
then
1230 call file_history_put( hist_id(i_epot), epot(:,:,:) )
1232 if ( hist_sw(i_qneut) )
then
1238 w3d(k,i,j) = d_qcrg_tot(k,i,j)/dt_lt
1243 call file_history_put( hist_id(i_qneut), w3d(:,:,:) )
1245 if ( hist_sw(i_ltpath) )
then
1251 w3d(k,i,j) = lt_path_tot(k,i,j,3)/dt_lt
1256 call file_history_put( hist_id(i_ltpath), w3d(:,:,:) )
1258 if ( hist_sw(i_posflash) )
then
1264 w3d(k,i,j) = lt_path_tot(k,i,j,1)/dt_lt
1269 call file_history_put( hist_id(i_posflash), w3d(:,:,:) )
1271 if ( hist_sw(i_negflash) )
then
1277 w3d(k,i,j) = lt_path_tot(k,i,j,2)/dt_lt
1282 call file_history_put( hist_id(i_negflash), w3d(:,:,:) )
1284 if ( hist_sw(i_flashpoint) )
then
1290 w3d(k,i,j) = fls_int_p_tot(k,i,j)/dt_lt
1295 call file_history_put( hist_id(i_flashpoint), w3d(:,:,:) )
1297 if ( hist_sw(i_fod) )
then
1302 w3d(1,i,j) = b_f2013_tot(i,j)/dt_lt
1306 call file_history_put( hist_id(i_fod), w3d(1,:,:) )
1318 KA, KS, KE, & ! [IN]
1319 IA, IS, IE, & ! [IN]
1320 JA, JS, JE, & ! [IN]
1371 integer,
intent(in) :: KA, KS, KE
1372 integer,
intent(in) :: IA, IS, IE
1373 integer,
intent(in) :: JA, JS, JE
1374 real(RP),
intent(in) :: QCRG (KA,IA,JA)
1375 real(RP),
intent(in) :: DENS (KA,IA,JA)
1376 real(RP),
intent(in) :: RHOT (KA,IA,JA)
1377 real(RP),
intent(inout) :: E_pot (KA,IA,JA)
1378 real(RP),
intent(inout) :: Efield(KA,IA,JA,3)
1382 real(RP) :: B(KA,IA,JA)
1383 real(RP) :: E_pot_N(KA,IA,JA)
1385 integer :: i, j, k, ijk, ierror
1386 real(RP) :: iprod, buf
1402 e_pot_n(k,i,j) = e_pot(k,i,j)
1408 call comm_vars8( e_pot_n, 1 )
1416 eps_air = epsvac * epsair
1417 b(k,i,j) = - qcrg(k,i,j)/eps_air * 1.0e-9_rp
1423 call comm_wait ( e_pot_n, 1 )
1434 call comm_vars8( e_pot, 1 )
1435 call comm_wait ( e_pot, 1, .true. )
1443 e_pot(k,i,j) = 0.0_rp
1446 e_pot(k,i,j) = 0.0_rp
1458 efield(k,i,j,i_lt_x) = - mapf(i,j,1,
i_xyz)/gsqrt(k,i,j,
i_xyz) * &
1460 ( gsqrt(k,i+1,j,
i_xyz)*e_pot(k,i+1,j) - gsqrt(k,i-1,j,
i_xyz)*e_pot(k,i-1,j) ) &
1461 * rcdx(i) * 0.5_rp &
1462 + ( j13g(k+1,i,j,
i_xyz)*gsqrt(k+1,i,j,
i_xyz)*e_pot(k+1,i,j) &
1463 - j13g(k-1,i,j,
i_xyz)*gsqrt(k-1,i,j,
i_xyz)*e_pot(k-1,i,j) &
1465 * rfdz(k) * 0.5_rp &
1467 efield(k,i,j,i_lt_y) = - mapf(i,j,2,
i_xyz)/gsqrt(k,i,j,
i_xyz) * &
1469 ( gsqrt(k,i,j+1,
i_xyz)*e_pot(k,i,j+1) - gsqrt(k,i,j-1,
i_xyz)*e_pot(k,i,j-1) ) &
1470 * rcdy(j) * 0.5_rp &
1471 + ( j23g(k+1,i,j,
i_xyz)*gsqrt(k+1,i,j,
i_xyz)*e_pot(k+1,i,j) &
1472 - j23g(k-1,i,j,
i_xyz)*gsqrt(k-1,i,j,
i_xyz)*e_pot(k-1,i,j) &
1474 * rfdz(k) * 0.5_rp &
1476 efield(k,i,j,i_lt_z) = - 1.0_rp/gsqrt(k,i,j,
i_xyz) * &
1477 ( j33g*e_pot(k+1,i ,j )*gsqrt(k+1,i,j,
i_xyz) &
1478 - j33g*e_pot(k-1,i ,j )*gsqrt(k-1,i,j,
i_xyz) &
1494 KA, KS, KE, & ! [IN]
1495 IA, IS, IE, & ! [IN]
1496 JA, JS, JE, & ! [IN]
1509 integer,
intent(in) :: KA, KS, KE
1510 integer,
intent(in) :: IA, IS, IE
1511 integer,
intent(in) :: JA, JS, JE
1512 real(RP),
intent(out) :: PHI_N(KA,IA,JA)
1513 real(RP),
intent(in) :: PHI(KA,IA,JA)
1514 real(RP),
intent(in) :: M(KA,15,IA,JA)
1515 real(RP),
intent(in) :: B(KA,IA,JA)
1517 real(RP) :: r0(KA,IA,JA)
1519 real(RP) :: p(KA,IA,JA)
1520 real(RP) :: Mp(KA,IA,JA)
1521 real(RP) :: s(KA,IA,JA)
1522 real(RP) :: Ms(KA,IA,JA)
1523 real(RP) :: al, be, w
1525 real(RP),
pointer :: r(:,:,:), rn(:,:,:), swap(:,:,:)
1526 real(RP),
target :: rbuf1(KA,IA,JA)
1527 real(RP),
target :: rbuf2(KA,IA,JA)
1528 real(RP) :: v1(KA,IA,JA)
1531 real(RP) :: norm, error, error2
1533 real(RP) :: iprod1, iprod2
1536 real(RP):: diag(KA,IA,JA)
1537 real(RP):: z1(KA,IA,JA)
1538 real(RP):: z2(KA,IA,JA)
1539 real(RP):: Mz1(KA,IA,JA)
1540 real(RP):: Mz2(KA,IA,JA)
1543 integer :: iis, iie, jjs, jje
1555 if( flag_preprocessing == 3 )
then
1564 call mul_matrix( ka, ks, ke, &
1576 norm = norm + b(k,i,j)**2
1588 r(k,i,j) = b(k,i,j) - v1(k,i,j)
1599 r0(k,i,j) = r(k,i,j)
1613 r0r = r0r + r0(k,i,j) * r(k,i,j)
1624 phi_n(k,i,j) = phi(k,i,j)
1639 call comm_vars8( p, 1 )
1648 error = error + r(k,i,j)**2
1656 call comm_wait ( p, 1 )
1658 if ( sqrt(error/norm) < epsilon )
then
1659 log_info(
"ATMOS_PHY_LT_Efield",
'(a,1x,i0,1x,2e15.7)')
"Bi-CGSTAB converged:", iter, sqrt(error/norm),norm
1664 if( flag_preprocessing == 0 )
then
1666 call mul_matrix( ka, ks, ke, &
1678 iprod1 = iprod1 + r0(k,i,j) * mp(k,i,j)
1686 if( flag_preprocessing == 1 )
then
1688 call gs( ka, ks, ke, &
1693 elseif( flag_preprocessing == 2 )
then
1695 call sgs( ka, ks, ke, &
1700 elseif( flag_preprocessing == 3 )
then
1703 call solve_ilu( ka, ks, ke, &
1711 call comm_vars8( z1, 1 )
1713 call mul_matrix( ka, ks, ke, &
1718 call comm_wait ( z1, 1 )
1720 call mul_matrix( ka, ks, ke, &
1732 iprod1 = iprod1 + r0(k,i,j) * mz1(k,i,j)
1742 if ( iprod1 == 0.0_rp )
then
1743 log_info(
"ATMOS_PHY_LT_Efield",
'(a,1x,e15.7,1x,i10)')
'Iprod1 is zero(Bi-CGSTAB) skip:', iprod1, iter
1748 if( flag_preprocessing == 0 )
then
1754 s(k,i,j) = r(k,i,j) - al*mp(k,i,j)
1765 s(k,i,j) = r(k,i,j) - al*mz1(k,i,j)
1772 call comm_vars8( s, 1 )
1773 call comm_wait ( s, 1 )
1774 if( flag_preprocessing == 0 )
then
1776 call mul_matrix( ka, ks, ke, &
1789 iprod1 = iprod1 + ms(k,i,j) * s(k,i,j)
1790 iprod2 = iprod2 + ms(k,i,j) * ms(k,i,j)
1798 if( flag_preprocessing == 1 )
then
1800 call gs( ka, ks, ke, &
1805 elseif( flag_preprocessing == 2 )
then
1807 call sgs( ka, is, ke, &
1812 elseif( flag_preprocessing == 3 )
then
1815 call solve_ilu( ka, ks, ke, &
1822 call comm_vars8( z2, 1 )
1823 call comm_wait ( z2, 1 )
1824 call mul_matrix( ka, ks, ke, &
1837 iprod1 = iprod1 + mz2(k,i,j) * s(k,i,j)
1838 iprod2 = iprod2 + mz2(k,i,j) * mz2(k,i,j)
1850 if ( buf(2) == 0.0_rp )
then
1851 log_info(
"ATMOS_PHY_LT_Efield",
'(a,1x,e15.7,1x,i10)')
'Buf(2) is zero(Bi-CGSTAB) skip:', buf(2), iter
1856 if( flag_preprocessing == 0 )
then
1863 phi_n(k,i,j) = phi_n(k,i,j) + al*p(k,i,j) + w*s(k,i,j)
1874 rn(k,i,j) = s(k,i,j) - w*ms(k,i,j)
1887 phi_n(k,i,j) = phi_n(k,i,j) + al*z1(k,i,j) + w*z2(k,i,j)
1898 rn(k,i,j) = s(k,i,j) - w*mz2(k,i,j)
1913 iprod1 = iprod1 + r0(k,i,j) * rn(k,i,j)
1925 if( flag_preprocessing == 0 )
then
1931 p(k,i,j) = rn(k,i,j) + be * ( p(k,i,j) - w*mp(k,i,j) )
1942 p(k,i,j) = rn(k,i,j) + be * ( p(k,i,j) - w*mz1(k,i,j) )
1953 if ( r0r == 0.0_rp )
then
1954 log_info(
"ATMOS_PHY_LT_Efield",
'(a,1x,i0,1x,3e15.7)')
"Inner product of r0 and r_itr is zero(Bi-CGSTAB) :", &
1955 iter, r0r, sqrt(error/norm), norm
1961 if ( iter >= itmax )
then
1963 log_warn(
"ATMOS_PHY_LT_solve_bicgstab",
'(a,1x,2e15.7)')
'Bi-CGSTAB not converged:', error, norm
1964 log_warn_cont(
'(a,1x,2e15.7)')
'Bi-CGSTAB not converged:', epsilon, sqrt(error/norm)
1965 log_warn_cont(
'(a,1x,2e15.7)')
'xxx epsilon(set,last)=', epsilon, sqrt(error/norm)
1966 if( error /= error )
then
1967 log_error(
"ATMOS_PHY_LT_solve_bicgstab",*)
'xxx error or norm is NaN Stop!'
1983 integer,
intent(in) :: KA, KS, KE
1984 integer,
intent(in) :: IA, IS, IE
1985 integer,
intent(in) :: JA, JS, JE
1986 real(RP),
intent(in) :: M(KA,15,IA,JA)
1987 real(RP),
intent(out) :: diag(KA,IA,JA)
1995 diag(k,i,j)=m(k,1,i,j)
2005 diag(k+1,i,j) = diag(k+1,i,j) + m(k,3,i,j)*m(k+1,2,i,j)/diag(k,i,j)
2007 diag(k+1,i+1,j) = diag(k+1,i+1,j) + m(k,13,i,j)*m(k+1,8,i+1,j)/diag(k,i,j)
2010 diag(k+1,i,j+1) = diag(k+1,i,j+1) + m(k,15,i,j)*m(k+1,10,i,j+1)/diag(k,i,j)
2014 diag(k,i+1,j) = diag(k,i+1,j) +m(k,5,i,j)*m(k,4,i+1,j)/diag(k,i,j)
2016 diag(k-1,i+1,j) = diag(k-1,i+1,j) + m(k,9,i,j)*m(k-1,12,i+1,j)/diag(k,i,j)
2020 diag(k,i,j+1)=diag(k,i,j+1) + m(k,7,i,j)*m(k,6,i,j+1)/diag(k,i,j)
2022 diag(k-1,i,j+1) = diag(k-1,i,j+1) + m(k,11,i,j)*m(k-1,14,i,j+1)/diag(k,i,j)
2033 subroutine solve_ilu( KA,KS,KE, &
2041 integer,
intent(in) :: KA, KS, KE
2042 integer,
intent(in) :: IA, IS, IE
2043 integer,
intent(in) :: JA, JS, JE
2044 real(RP),
intent(in) :: M(KA,15,IA,JA)
2045 real(RP),
intent(in) :: diag(KA,IA,JA)
2046 real(RP),
intent(in) :: V(KA,IA,JA)
2047 real(RP),
intent(out) :: Z(KA,IA,JA)
2049 real(RP):: Y(KA,IA,JA)
2052 call gs_ilu(ka, ks, ke, &
2061 y(k,i,j)=diag(k,i,j)*y(k,i,j)
2073 end subroutine solve_ilu
2084 integer,
intent(in) :: KA, KS, KE
2085 integer,
intent(in) :: IA, IS, IE
2086 integer,
intent(in) :: JA, JS, JE
2087 real(RP),
intent(in) :: V(KA,IA,JA)
2088 real(RP),
intent(in) :: M(KA,15,IA,JA)
2089 real(RP),
intent(in) :: diag(KA,IA,JA)
2090 real(RP),
intent(out) :: Z(KA,IA,JA)
2099 z(ke,i,j) = ( v(ke,i,j) &
2100 -( m(ke,2,i,j) * z(ke-1,i ,j ) &
2101 + m(ke,4,i,j) * z(ke ,i-1,j ) &
2102 + m(ke,5,i,j) * z(ke ,i+1,j ) &
2103 + m(ke,6,i,j) * z(ke ,i ,j-1) &
2104 + m(ke,7,i,j) * z(ke ,i ,j+1) &
2105 + m(ke,8,i,j) * z(ke-1,i-1,j ) &
2106 + m(ke,9,i,j) * z(ke-1,i+1,j ) &
2107 + m(ke,10,i,j)* z(ke-1,i ,j-1) &
2108 + m(ke,11,i,j)* z(ke-1,i ,j+1) ) )/diag(ke,i,j)
2110 do k = ke-1, ks+1,-1
2111 z(k,i,j) = (v(k,i,j) &
2112 -( m(k,2,i,j) * z(k-1,i ,j ) &
2113 + m(k,3,i,j) * z(k+1,i ,j ) &
2114 + m(k,4,i,j) * z(k ,i-1,j ) &
2115 + m(k,5,i,j) * z(k ,i+1,j ) &
2116 + m(k,6,i,j) * z(k ,i ,j-1) &
2117 + m(k,7,i,j) * z(k ,i ,j+1) &
2118 + m(k,8,i,j) * z(k-1,i-1,j ) &
2119 + m(k,9,i,j) * z(k-1,i+1,j ) &
2120 + m(k,10,i,j)* z(k-1,i ,j-1) &
2121 + m(k,11,i,j)* z(k-1,i ,j+1) &
2122 + m(k,12,i,j)* z(k+1,i-1,j ) &
2123 + m(k,13,i,j)* z(k+1,i+1,j ) &
2124 + m(k,14,i,j)* z(k+1,i ,j-1) &
2125 + m(k,15,i,j)* z(k+1,i ,j+1) ) )/diag(k,i,j)
2128 z(ks,i,j) = (v(ks,i,j) &
2129 -( m(ks,3,i,j) * z(ks+1,i ,j ) &
2130 + m(ks,4,i,j) * z(ks ,i-1,j ) &
2131 + m(ks,5,i,j) * z(ks ,i+1,j ) &
2132 + m(ks,6,i,j) * z(ks ,i ,j-1) &
2133 + m(ks,7,i,j) * z(ks ,i ,j+1) &
2134 + m(ks,12,i,j)* z(ks+1,i-1,j ) &
2135 + m(ks,13,i,j)* z(ks+1,i+1,j ) &
2136 + m(ks,14,i,j)* z(ks+1,i ,j-1) &
2137 + m(ks,15,i,j)* z(ks+1,i ,j+1) ) ) /diag(ks,i,j)
2146 subroutine gs_ilu( KA, KS, KE, &
2152 integer,
intent(in) :: KA, KS, KE
2153 integer,
intent(in) :: IA, IS, IE
2154 integer,
intent(in) :: JA, JS, JE
2155 real(RP),
intent(in) :: V(KA,IA,JA)
2156 real(RP),
intent(in) :: M(KA,15,IA,JA)
2157 real(RP),
intent(in) :: diag(KA,IA,JA)
2158 real(RP),
intent(out) :: Z(KA,IA,JA)
2167 z(ks,i,j) = (v(ks,i,j) &
2168 -( m(ks,3,i,j) * z(ks+1,i ,j ) &
2169 + m(ks,4,i,j) * z(ks ,i-1,j ) &
2170 + m(ks,5,i,j) * z(ks ,i+1,j ) &
2171 + m(ks,6,i,j) * z(ks ,i ,j-1) &
2172 + m(ks,7,i,j) * z(ks ,i ,j+1) &
2173 + m(ks,12,i,j)* z(ks+1,i-1,j ) &
2174 + m(ks,13,i,j)* z(ks+1,i+1,j ) &
2175 + m(ks,14,i,j)* z(ks+1,i ,j-1) &
2176 + m(ks,15,i,j)* z(ks+1,i ,j+1) ) ) /diag(ks,i,j)
2179 z(k,i,j) = (v(k,i,j) &
2180 -( m(k,2,i,j) * z(k-1,i ,j ) &
2181 + m(k,3,i,j) * z(k+1,i ,j ) &
2182 + m(k,4,i,j) * z(k ,i-1,j ) &
2183 + m(k,5,i,j) * z(k ,i+1,j ) &
2184 + m(k,6,i,j) * z(k ,i ,j-1) &
2185 + m(k,7,i,j) * z(k ,i ,j+1) &
2186 + m(k,8,i,j) * z(k-1,i-1,j ) &
2187 + m(k,9,i,j) * z(k-1,i+1,j ) &
2188 + m(k,10,i,j)* z(k-1,i ,j-1) &
2189 + m(k,11,i,j)* z(k-1,i ,j+1) &
2190 + m(k,12,i,j)* z(k+1,i-1,j ) &
2191 + m(k,13,i,j)* z(k+1,i+1,j ) &
2192 + m(k,14,i,j)* z(k+1,i ,j-1) &
2193 + m(k,15,i,j)* z(k+1,i ,j+1) ) )/diag(k,i,j)
2196 z(ke,i,j) = ( v(ke,i,j) &
2197 -( m(ke,2,i,j) * z(ke-1,i ,j ) &
2198 + m(ke,4,i,j) * z(ke ,i-1,j ) &
2199 + m(ke,5,i,j) * z(ke ,i+1,j ) &
2200 + m(ke,6,i,j) * z(ke ,i ,j-1) &
2201 + m(ke,7,i,j) * z(ke ,i ,j+1) &
2202 + m(ke,8,i,j) * z(ke-1,i-1,j ) &
2203 + m(ke,9,i,j) * z(ke-1,i+1,j ) &
2204 + m(ke,10,i,j)* z(ke-1,i ,j-1) &
2205 + m(ke,11,i,j)* z(ke-1,i ,j+1) ) )/diag(ke,i,j)
2214 subroutine sgs( KA, KS, KE, &
2219 integer,
intent(in) :: KA, KS, KE
2220 integer,
intent(in) :: IA, IS, IE
2221 integer,
intent(in) :: JA, JS, JE
2222 real(RP),
intent(in) :: M(KA,15,IA,JA)
2223 real(RP),
intent(in) :: V(KA,IA,JA)
2224 real(RP),
intent(out) :: Z(KA,IA,JA)
2225 real(RP):: Y(KA,IA,JA)
2230 call gs( ka, ks, ke, &
2240 y(k,i,j)=m(k,1,i,j)*y(k,i,j)
2246 call back_sub(ka, ks, ke, &
2257 subroutine back_sub ( KA, KS, KE, &
2262 integer,
intent(in) :: KA, KS, KE
2263 integer,
intent(in) :: IA, IS, IE
2264 integer,
intent(in) :: JA, JS, JE
2265 real(RP),
intent(in) :: V(KA,IA,JA)
2266 real(RP),
intent(in) :: M(KA,15,IA,JA)
2267 real(RP),
intent(out) :: Z(KA,IA,JA)
2281 z(k,i,js-1) = 0.0_rp
2282 z(k,i,je+1) = 0.0_rp
2290 z(k,is-1,j) = 0.0_rp
2291 z(k,ie+1,j) = 0.0_rp
2305 if ( mod((ie-i)+(je-j),2)==0 )
then
2307 z(ke,i,j) = ( v(ke,i,j) )/m(ke,1,i,j)
2310 z(k,i,j) = (v(k,i,j) &
2311 -( m(k,3,i,j) * z(k+1,i ,j ) ) )/m(k,1,i,j)
2323 z(ke,i,j) = ( v(ke,i,j) &
2324 -( m(ke,5,i,j) * z(ke ,i+1,j ) ) )/m(ke,1,i,j)
2327 z(k,i,j) = (v(k,i,j) &
2328 -( m(k,3,i,j) * z(k+1,i ,j ) &
2329 + m(k,5,i,j) * z(k ,i+1,j ) &
2330 + m(k,13,i,j)* z(k+1,i+1,j ) ) )/m(k,1,i,j)
2339 z(ke,i,j) = ( v(ke,i,j) &
2340 -( m(ke,5,i,j) * z(ke ,i+1,j ) &
2341 + m(ke,7,i,j) * z(ke ,i ,j+1) ) )/m(ke,1,i,j)
2344 z(k,i,j) = (v(k,i,j) &
2345 -( m(k,3,i,j) * z(k+1,i ,j ) &
2346 + m(k,5,i,j) * z(k ,i+1,j ) &
2347 + m(k,7,i,j) * z(k ,i ,j+1) &
2348 + m(k,13,i,j)* z(k+1,i+1,j ) &
2349 + m(k,15,i,j)* z(k+1,i ,j+1) ) )/m(k,1,i,j)
2364 if ( mod((ie-i)+(je-j),2)==1 )
then
2366 z(ke,i,j) = ( v(ke,i,j) &
2367 -( m(ke,4,i,j) * z(ke ,i-1,j ) &
2368 + m(ke,5,i,j) * z(ke ,i+1,j ) &
2369 + m(ke,6,i,j) * z(ke ,i ,j-1) &
2370 + m(ke,7,i,j) * z(ke ,i ,j+1) &
2371 + m(ke,8,i,j) * z(ke-1,i-1,j ) &
2372 + m(ke,9,i,j) * z(ke-1,i+1,j ) &
2373 + m(ke,10,i,j)* z(ke-1,i ,j-1) &
2374 + m(ke,11,i,j)* z(ke-1,i ,j+1) ) )/m(ke,1,i,j)
2376 do k = ke-1, ks+1,-1
2377 z(k,i,j) = (v(k,i,j) &
2378 -( m(k,3,i,j) * z(k+1,i ,j ) &
2379 + m(k,4,i,j) * z(k ,i-1,j ) &
2380 + m(k,5,i,j) * z(k ,i+1,j ) &
2381 + m(k,6,i,j) * z(k ,i ,j-1) &
2382 + m(k,7,i,j) * z(k ,i ,j+1) &
2383 + m(k,8,i,j) * z(k-1,i-1,j ) &
2384 + m(k,9,i,j) * z(k-1,i+1,j ) &
2385 + m(k,10,i,j)* z(k-1,i ,j-1) &
2386 + m(k,11,i,j)* z(k-1,i ,j+1) &
2387 + m(k,12,i,j)* z(k+1,i-1,j ) &
2388 + m(k,13,i,j)* z(k+1,i+1,j ) &
2389 + m(k,14,i,j)* z(k+1,i ,j-1) &
2390 + m(k,15,i,j)* z(k+1,i ,j+1) ) )/m(k,1,i,j)
2393 z(ks,i,j) = (v(ks,i,j) &
2394 -( m(ks,3,i,j) * z(ks+1,i ,j ) &
2395 + m(ks,4,i,j) * z(ks ,i-1,j ) &
2396 + m(ks,5,i,j) * z(ks ,i+1,j ) &
2397 + m(ks,6,i,j) * z(ks ,i ,j-1) &
2398 + m(ks,7,i,j) * z(ks ,i ,j+1) &
2399 + m(ks,12,i,j)* z(ks+1,i-1,j ) &
2400 + m(ks,13,i,j)* z(ks+1,i+1,j ) &
2401 + m(ks,14,i,j)* z(ks+1,i ,j-1) &
2402 + m(ks,15,i,j)* z(ks+1,i ,j+1) ) ) /m(ks,1,i,j)
2411 z(ke,i,j) = ( v(ke,i,j) &
2412 -( m(ke,5,i,j) * z(ke ,i+1,j ) &
2413 + m(ke,6,i,j) * z(ke ,i ,j-1) &
2414 + m(ke,7,i,j) * z(ke ,i ,j+1) &
2415 + m(ke,9,i,j) * z(ke-1,i+1,j ) &
2416 + m(ke,10,i,j)* z(ke-1,i ,j-1) &
2417 + m(ke,11,i,j)* z(ke-1,i ,j+1) ) )/m(ke,1,i,j)
2419 do k = ke-1, ks+1,-1
2420 z(k,i,j) = (v(k,i,j) &
2421 -( m(k,3,i,j) * z(k+1,i ,j ) &
2422 + m(k,5,i,j) * z(k ,i+1,j ) &
2423 + m(k,6,i,j) * z(k ,i ,j-1) &
2424 + m(k,7,i,j) * z(k ,i ,j+1) &
2425 + m(k,9,i,j) * z(k-1,i+1,j ) &
2426 + m(k,10,i,j)* z(k-1,i ,j-1) &
2427 + m(k,11,i,j)* z(k-1,i ,j+1) &
2428 + m(k,13,i,j)* z(k+1,i+1,j ) &
2429 + m(k,14,i,j)* z(k+1,i ,j-1) &
2430 + m(k,15,i,j)* z(k+1,i ,j+1) ) )/m(k,1,i,j)
2433 z(ks,i,j) = (v(ks,i,j) &
2434 -( m(ks,3,i,j) * z(ks+1,i ,j ) &
2435 + m(ks,5,i,j) * z(ks ,i+1,j ) &
2436 + m(ks,6,i,j) * z(ks ,i ,j-1) &
2437 + m(ks,7,i,j) * z(ks ,i ,j+1) &
2438 + m(ks,13,i,j)* z(ks+1,i+1,j ) &
2439 + m(ks,14,i,j)* z(ks+1,i ,j-1) &
2440 + m(ks,15,i,j)* z(ks+1,i ,j+1) ) ) /m(ks,1,i,j)
2450 end subroutine back_sub
2453 subroutine gs ( KA, KS, KE, &
2458 integer,
intent(in) :: KA, KS, KE
2459 integer,
intent(in) :: IA, IS, IE
2460 integer,
intent(in) :: JA, JS, JE
2461 real(RP),
intent(in) :: V(KA,IA,JA)
2462 real(RP),
intent(in) :: M(KA,15,IA,JA)
2463 real(RP),
intent(out) :: Z(KA,IA,JA)
2465 integer :: k, i, j, n
2474 z(k,i,js-1) = 0.0_rp
2475 z(k,i,je+1) = 0.0_rp
2483 z(k,is-1,j) = 0.0_rp
2484 z(k,ie+1,j) = 0.0_rp
2498 if ( mod((i-is)+(j-js),2)==0 )
then
2500 z(ks,i,j) = (v(ks,i,j) ) /m(ks,1,i,j)
2503 z(k,i,j) = (v(k,i,j) &
2504 -( m(k,2,i,j) * z(k-1,i ,j ) ) )/m(k,1,i,j)
2516 z(ks,i,j) = (v(ks,i,j) &
2517 -( m(ks,4,i,j) * z(ks ,i-1,j ) ) ) /m(ks,1,i,j)
2520 z(k,i,j) = (v(k,i,j) &
2521 -( m(k,2,i,j) * z(k-1,i ,j ) &
2522 + m(k,4,i,j) * z(k ,i-1,j ) &
2523 + m(k,8,i,j) * z(k-1,i-1,j ) ) )/m(k,1,i,j)
2532 z(ks,i,j) = (v(ks,i,j) &
2533 -( m(ks,4,i,j) * z(ks ,i-1,j ) &
2534 + m(ks,6,i,j) * z(ks ,i ,j-1) ) ) /m(ks,1,i,j)
2537 z(k,i,j) = (v(k,i,j) &
2538 -( m(k,2,i,j) * z(k-1,i ,j ) &
2539 + m(k,4,i,j) * z(k ,i-1,j ) &
2540 + m(k,6,i,j) * z(k ,i ,j-1) &
2541 + m(k,8,i,j) * z(k-1,i-1,j ) &
2542 + m(k,10,i,j)* z(k-1,i ,j-1) ) )/m(k,1,i,j)
2557 if ( mod((i-is)+(j-js),2)==1 )
then
2559 z(ks,i,j) = (v(ks,i,j) &
2560 -( m(ks,4,i,j) * z(ks ,i-1,j ) &
2561 + m(ks,5,i,j) * z(ks ,i+1,j ) &
2562 + m(ks,6,i,j) * z(ks ,i ,j-1) &
2563 + m(ks,7,i,j) * z(ks ,i ,j+1) &
2564 + m(ks,12,i,j)* z(ks+1,i-1,j ) &
2565 + m(ks,13,i,j)* z(ks+1,i+1,j ) &
2566 + m(ks,14,i,j)* z(ks+1,i ,j-1) &
2567 + m(ks,15,i,j)* z(ks+1,i ,j+1) ) ) /m(ks,1,i,j)
2570 z(k,i,j) = (v(k,i,j) &
2571 -( m(k,2,i,j) * z(k-1,i ,j ) &
2572 + m(k,4,i,j) * z(k ,i-1,j ) &
2573 + m(k,5,i,j) * z(k ,i+1,j ) &
2574 + m(k,6,i,j) * z(k ,i ,j-1) &
2575 + m(k,7,i,j) * z(k ,i ,j+1) &
2576 + m(k,8,i,j) * z(k-1,i-1,j ) &
2577 + m(k,9,i,j) * z(k-1,i+1,j ) &
2578 + m(k,10,i,j)* z(k-1,i ,j-1) &
2579 + m(k,11,i,j)* z(k-1,i ,j+1) &
2580 + m(k,12,i,j)* z(k+1,i-1,j ) &
2581 + m(k,13,i,j)* z(k+1,i+1,j ) &
2582 + m(k,14,i,j)* z(k+1,i ,j-1) &
2583 + m(k,15,i,j)* z(k+1,i ,j+1) ) )/m(k,1,i,j)
2586 z(ke,i,j) = ( v(ke,i,j) &
2587 -( m(ke,2,i,j) * z(ke-1,i ,j ) &
2588 + m(ke,4,i,j) * z(ke ,i-1,j ) &
2589 + m(ke,5,i,j) * z(ke ,i+1,j ) &
2590 + m(ke,6,i,j) * z(ke ,i ,j-1) &
2591 + m(ke,7,i,j) * z(ke ,i ,j+1) &
2592 + m(ke,8,i,j) * z(ke-1,i-1,j ) &
2593 + m(ke,9,i,j) * z(ke-1,i+1,j ) &
2594 + m(ke,10,i,j)* z(ke-1,i ,j-1) &
2595 + m(ke,11,i,j)* z(ke-1,i ,j+1) ) )/m(ke,1,i,j)
2604 z(ks,i,j) = (v(ks,i,j) &
2605 -( m(ks,4,i,j) * z(ks ,i-1,j ) &
2606 + m(ks,6,i,j) * z(ks ,i ,j-1) &
2607 + m(ks,7,i,j) * z(ks ,i ,j+1) &
2608 + m(ks,12,i,j)* z(ks+1,i-1,j ) &
2609 + m(ks,14,i,j)* z(ks+1,i ,j-1) &
2610 + m(ks,15,i,j)* z(ks+1,i ,j+1) ) ) /m(ks,1,i,j)
2613 z(k,i,j) = (v(k,i,j) &
2614 -( m(k,2,i,j) * z(k-1,i ,j ) &
2615 + m(k,4,i,j) * z(k ,i-1,j ) &
2616 + m(k,6,i,j) * z(k ,i ,j-1) &
2617 + m(k,7,i,j) * z(k ,i ,j+1) &
2618 + m(k,8,i,j) * z(k-1,i-1,j ) &
2619 + m(k,10,i,j)* z(k-1,i ,j-1) &
2620 + m(k,11,i,j)* z(k-1,i ,j+1) &
2621 + m(k,12,i,j)* z(k+1,i-1,j ) &
2622 + m(k,14,i,j)* z(k+1,i ,j-1) &
2623 + m(k,15,i,j)* z(k+1,i ,j+1) ) )/m(k,1,i,j)
2626 z(ke,i,j) = ( v(ke,i,j) &
2627 -( m(ke,2,i,j) * z(ke-1,i ,j ) &
2628 + m(ke,4,i,j) * z(ke ,i-1,j ) &
2629 + m(ke,6,i,j) * z(ke ,i ,j-1) &
2630 + m(ke,7,i,j) * z(ke ,i ,j+1) &
2631 + m(ke,8,i,j) * z(ke-1,i-1,j ) &
2632 + m(ke,10,i,j)* z(ke-1,i ,j-1) &
2633 + m(ke,11,i,j)* z(ke-1,i ,j+1) ) )/m(ke,1,i,j)
2645 subroutine mul_matrix( KA,KS,KE, &
2650 integer,
intent(in) :: KA, KS, KE
2651 integer,
intent(in) :: IA, IS, IE
2652 integer,
intent(in) :: JA, JS, JE
2653 real(RP),
intent(out) :: V(KA,IA,JA)
2654 real(RP),
intent(in) :: M(KA,15,IA,JA)
2655 real(RP),
intent(in) :: C(KA,IA,JA)
2663 v(ks,i,j) = m(ks,1,i,j) * c(ks ,i ,j ) &
2664 + m(ks,3,i,j) * c(ks+1,i ,j ) &
2665 + m(ks,4,i,j) * c(ks ,i-1,j ) &
2666 + m(ks,5,i,j) * c(ks ,i+1,j ) &
2667 + m(ks,6,i,j) * c(ks ,i ,j-1) &
2668 + m(ks,7,i,j) * c(ks ,i ,j+1) &
2669 + m(ks,12,i,j)* c(ks+1,i-1,j ) &
2670 + m(ks,13,i,j)* c(ks+1,i+1,j ) &
2671 + m(ks,14,i,j)* c(ks+1,i ,j-1) &
2672 + m(ks,15,i,j)* c(ks+1,i ,j+1)
2674 v(k,i,j) = m(k,1,i,j) * c(k ,i ,j ) &
2675 + m(k,2,i,j) * c(k-1,i ,j ) &
2676 + m(k,3,i,j) * c(k+1,i ,j ) &
2677 + m(k,4,i,j) * c(k ,i-1,j ) &
2678 + m(k,5,i,j) * c(k ,i+1,j ) &
2679 + m(k,6,i,j) * c(k ,i ,j-1) &
2680 + m(k,7,i,j) * c(k ,i ,j+1) &
2681 + m(k,8,i,j) * c(k-1,i-1,j ) &
2682 + m(k,9,i,j) * c(k-1,i+1,j ) &
2683 + m(k,10,i,j)* c(k-1,i ,j-1) &
2684 + m(k,11,i,j)* c(k-1,i ,j+1) &
2685 + m(k,12,i,j)* c(k+1,i-1,j ) &
2686 + m(k,13,i,j)* c(k+1,i+1,j ) &
2687 + m(k,14,i,j)* c(k+1,i ,j-1) &
2688 + m(k,15,i,j)* c(k+1,i ,j+1)
2690 v(ke,i,j) = m(ke,1,i,j) * c(ke ,i ,j ) &
2691 + m(ke,2,i,j) * c(ke-1,i ,j ) &
2692 + m(ke,4,i,j) * c(ke ,i-1,j ) &
2693 + m(ke,5,i,j) * c(ke ,i+1,j ) &
2694 + m(ke,6,i,j) * c(ke ,i ,j-1) &
2695 + m(ke,7,i,j) * c(ke ,i ,j+1) &
2696 + m(ke,8,i,j) * c(ke-1,i-1,j ) &
2697 + m(ke,9,i,j) * c(ke-1,i+1,j ) &
2698 + m(ke,10,i,j)* c(ke-1,i ,j-1) &
2699 + m(ke,11,i,j)* c(ke-1,i ,j+1)
2705 end subroutine mul_matrix
2708 function f2h( k,i,j,p )
2720 integer,
intent(in) :: k, i, j, p
2722 f2h = (cdz(k+p-1)*gsqrt(k+p-1,i,j,
i_xyz) &
2723 / (cdz(k)*gsqrt(k,i,j,
i_xyz)+cdz(k+1)*gsqrt(k+1,i,j,
i_xyz)))
2730 KA, KS, KE, & ! [IN]
2731 IA, IS, IE, & ! [IN]
2732 JA, JS, JE, & ! [IN]
2741 NUM_end, & ! [INOUT]
2742 LT_path, & ! [INOUT]
2743 fls_int_p, & ! [OUT]
2793 integer,
intent(in) :: KA, KS, KE
2794 integer,
intent(in) :: IA, IS, IE
2795 integer,
intent(in) :: JA, JS, JE
2796 integer,
intent(in) :: KIJMAX, IMAX, JMAX
2797 real(RP),
intent(in) :: Efield (KA,IA,JA,4)
2798 real(RP),
intent(in) :: E_pot (KA,IA,JA)
2799 real(RP),
intent(in) :: QCRG (KA,IA,JA)
2800 real(RP),
intent(in) :: DENS (KA,IA,JA)
2801 real(RP),
intent(in) :: QHYD (KA,IA,JA)
2802 real(RP),
intent(inout) :: NUM_end (KA,IA,JA,3)
2803 real(RP),
intent(inout) :: LT_path (KA,IA,JA)
2804 real(RP),
intent(out) :: fls_int_p(KA,IA,JA)
2805 real(RP),
intent(out) :: d_QCRG (KA,IA,JA)
2807 real(RP) :: E_det, E_x, E_y, E_z, E_max
2808 real(RP) :: dqrho_pls(KA,IA,JA), dqrho_mns(KA,IA,JA)
2809 real(RP) :: L_path(KA,IA,JA)
2810 real(RP) :: sumdqrho_pls, sumdqrho_mns
2811 real(RP) :: Ncrit, dqrho_cor
2812 real(RP) :: randnum(1)
2813 real(RP) :: rprod1, rprod2, rbuf, rbuf2, phi_end(2)
2814 integer :: Eovid(4,KIJMAX)
2815 integer :: Npls, Nmns, Ntot
2816 integer :: count1(PRC_nprocs)
2817 integer :: countindx(PRC_nprocs+1)
2818 integer :: own_prc_total
2819 integer :: iprod(2), ibuf(6), status(MPI_STATUS_SIZE)
2820 integer :: init_point, rank_initpoint, grid_initpoint
2821 integer :: current_prc
2822 integer :: comm_flag, comm_target, stop_flag, corr_flag(2)
2823 integer :: end_grid(4), wild_grid(6)
2825 integer :: k, i, j, ipp, iq, direction, ierr
2826 integer :: k1, i1, j1, k2, i2, j2, sign_flash
2827 integer :: wild_flag, count_path
2828 integer :: flg_num_end(KA,IA,JA,3)
2829 real(RP) :: Eint_hgt(KA,IA,JA)
2837 fls_int_p(k,i,j) = 0.0_rp
2842 do count_path = 1, nutr_itmax
2850 eint_hgt(k,i,j) = min( eint*dens(k,i,j)/rho0,eint )*flg_eint_hgt &
2851 + ( eint-deleint )*( 1.0_rp-flg_eint_hgt )
2852 if( flg_eint_hgt == 1.0_rp .and. eint_hgt(k,i,j) < estop )
then
2853 eint_hgt(k,i,j) = large_num
2855 e_det = efield(k,i,j,i_lt_abs) - eint_hgt(k,i,j)
2856 if( e_det > 0.0_rp )
then
2857 own_prc_total = own_prc_total + 1
2858 eovid(1,own_prc_total) = i
2859 eovid(2,own_prc_total) = j
2860 eovid(3,own_prc_total) = k
2867 call mpi_allgather( own_prc_total, 1, mpi_integer, &
2868 count1, 1, mpi_integer, &
2873 do ipp = 1, prc_nprocs
2874 countindx(ipp+1) = countindx(ipp) + count1(ipp)
2881 call random_uniform(randnum)
2882 init_point = int( randnum(1) * countindx(prc_nprocs+1) ) + 1
2883 do ipp = 1, prc_nprocs
2884 if ( countindx(ipp+1) >= init_point )
then
2885 rank_initpoint = ipp-1
2889 grid_initpoint = init_point - countindx(rank_initpoint+1)
2890 ibuf(1) = rank_initpoint
2891 ibuf(2) = grid_initpoint
2894 call comm_bcast( 2, ibuf )
2896 rank_initpoint = ibuf(1)
2897 grid_initpoint = ibuf(2)
2906 l_path(k,i,j) = 0.0_rp
2907 flg_num_end(k,i,j,:) = 0
2917 elseif( iq == 2 )
then
2921 current_prc = rank_initpoint
2925 i = eovid(1,grid_initpoint)
2926 j = eovid(2,grid_initpoint)
2927 k = eovid(3,grid_initpoint)
2929 if( iq == 1 ) fls_int_p(k,i,j) = fls_int_p(k,i,j) + 1.0_rp
2930 sign_flash = 2 + int( sign( 1.0_rp, qcrg(k,i,j) ) )
2937 loop_path :
do ipp = 1, kijmaxg
2943 e_x = abs( efield(k,i,j,i_lt_x) )/cdx(i)
2944 e_y = abs( efield(k,i,j,i_lt_y) )/cdy(j)
2945 e_z = abs( efield(k,i,j,i_lt_z) )/cdz(k)
2946 e_det = max( e_x,e_y,e_z )
2951 if( e_det == e_x )
then
2952 direction = int( sign( 1.0_rp,efield(k,i,j,i_lt_x) ) * pm )
2954 elseif( e_det == e_y )
then
2955 direction = int( sign( 1.0_rp,efield(k,i,j,i_lt_y) ) * pm )
2957 elseif( e_det == e_z )
then
2958 direction = int( sign( 1.0_rp,efield(k,i,j,i_lt_z) ) * pm )
2963 if( efield(k1,i1,j1,i_lt_abs) <= estop )
then
2965 phi_end(iq) = qcrg(k,i,j)
2967 num_end(k,i,j,sign_flash) = num_end(k,i,j,sign_flash) + 1.0_rp
2968 flg_num_end(k,i,j,sign_flash) = 1
2975 if( qhyd(k,i,j) < eps )
then
2980 elseif( efield(k1,i1,j1,i_lt_abs) > estop )
then
2982 l_path(k, i ,j ) = pm
2983 l_path(k1,i1,j1) = pm
2989 num_end(k,i,j,sign_flash) = num_end(k,i,j,sign_flash) + 1.0_rp
2990 flg_num_end(k,i,j,sign_flash) = 1
2997 if( qhyd(k,i,j) < eps )
then
3002 elseif( cz(k1) < zcg )
then
3004 num_end(k,i,j,2) = num_end(k,i,j,2) + 1.0_rp
3005 flg_num_end(k,i,j,2) = 1
3012 if( qhyd(k,i,j) < eps )
then
3019 if( stop_flag /= 1 )
then
3021 if( i1 == is-1 .and. .not.
prc_has_w )
then
3023 num_end(k,i,j,sign_flash) = num_end(k,i,j,sign_flash) + 1.0_rp
3024 flg_num_end(k,i,j,sign_flash) = 1
3026 l_path(k1,i1,j1) = pm
3032 if( qhyd(k,i,j) < eps )
then
3037 elseif( i1 == is-1 .and.
prc_has_w )
then
3040 l_path(k1,i1,j1) = pm
3044 elseif( i1 == ie+1 .and. .not.
prc_has_e )
then
3046 num_end(k,i,j,sign_flash) = num_end(k,i,j,sign_flash) + 1.0_rp
3047 flg_num_end(k,i,j,sign_flash) = 1
3049 l_path(k1,i1,j1) = pm
3055 if( qhyd(k,i,j) < eps )
then
3060 elseif( i1 == ie+1 .and.
prc_has_e )
then
3063 l_path(k1,i1,j1) = pm
3070 if( j1 == js-1 .and. .not.
prc_has_s )
then
3072 num_end(k,i,j,sign_flash) = num_end(k,i,j,sign_flash) + 1.0_rp
3073 flg_num_end(k,i,j,sign_flash) = 1
3075 l_path(k1,i1,j1) = pm
3081 if( qhyd(k,i,j) < eps )
then
3086 elseif( j1 == js-1 .and.
prc_has_s )
then
3089 l_path(k1,i1,j1) = pm
3093 elseif( j1 == je+1 .and. .not.
prc_has_n )
then
3095 num_end(k,i,j,sign_flash) = num_end(k,i,j,sign_flash) + 1.0_rp
3096 flg_num_end(k,i,j,sign_flash) = 1
3098 l_path(k1,i1,j1) = pm
3105 if( qhyd(k,i,j) < eps )
then
3110 elseif( j1 == je+1 .and.
prc_has_n )
then
3113 l_path(k1,i1,j1) = pm
3123 call mpi_bcast(stop_flag, 1, mpi_integer, current_prc,
comm_world, ierr)
3125 if( stop_flag == 1 )
then
3127 call mpi_bcast(wild_flag, 1, mpi_integer, current_prc,
comm_world, ierr)
3130 ibuf(1:4) = end_grid(:)
3131 ibuf(5:6) = corr_flag(:)
3133 call mpi_bcast(ibuf, 6, mpi_integer, current_prc,
comm_world, ierr)
3134 end_grid(:) = ibuf(1:4)
3135 corr_flag(:) = ibuf(5:6)
3143 call mpi_bcast(comm_flag, 1, mpi_integer, current_prc,
comm_world, ierr)
3146 if( comm_flag == 1 )
then
3147 call mpi_bcast(comm_target, 1, mpi_integer, current_prc,
comm_world, ierr)
3150 call mpi_recv(ibuf, 6, mpi_integer, current_prc, 1,
comm_world, status, ierr)
3154 corr_flag(:) = ibuf(4:5)
3155 sign_flash = ibuf(6)
3162 ibuf(4:5) = corr_flag(:)
3163 ibuf(6) = sign_flash
3164 call mpi_send(ibuf, 6, mpi_integer, comm_target, 1,
comm_world, ierr)
3168 current_prc = comm_target
3182 if( wild_flag == 1 .and. end_grid(4) ==
prc_myrank )
then
3189 if( abs( qcrg(k2,i2,j2) ) > qrho_chan/dens(k2,i2,j2) .and. &
3190 abs( e_pot(k2,i2,j2) ) > abs( phi_end(iq) ) )
then
3191 l_path( k2,i2,j2 ) = l_path( k1,i1,j1 )
3199 if( abs( qcrg(k2,i2,j2) ) > qrho_chan/dens(k2,i2,j2) .and. &
3200 abs( e_pot(k2,i2,j2) ) > abs( phi_end(iq) ) )
then
3201 l_path( k2,i2,j2 ) = l_path( k1,i1,j1 )
3209 if( abs( qcrg(k2,i2,j2) ) > qrho_chan/dens(k2,i2,j2) .and. &
3210 abs( e_pot(k2,i2,j2) ) > abs( phi_end(iq) ) )
then
3211 l_path( k2,i2,j2 ) = l_path( k1,i1,j1 )
3219 if( abs( qcrg(k2,i2,j2) ) > qrho_chan/dens(k2,i2,j2) .and. &
3220 abs( e_pot(k2,i2,j2) ) > abs( phi_end(iq) ) )
then
3221 l_path( k2,i2,j2 ) = l_path( k1,i1,j1 )
3229 if( abs( qcrg(k2,i2,j2) ) > qrho_chan/dens(k2,i2,j2) .and. &
3230 abs( e_pot(k2,i2,j2) ) > abs( phi_end(iq) ) )
then
3231 l_path( k2,i2,j2 ) = l_path( k1,i1,j1 )
3239 if( abs( qcrg(k2,i2,j2) ) > qrho_chan/dens(k2,i2,j2) .and. &
3240 abs( e_pot(k2,i2,j2) ) > abs( phi_end(iq) ) )
then
3241 l_path( k2,i2,j2 ) = l_path( k1,i1,j1 )
3255 sumdqrho_pls = 0.0_rp
3256 sumdqrho_mns = 0.0_rp
3263 if( l_path(k,i,j) /= 0.0_rp .and. abs( qcrg(k,i,j) ) > qrho_chan )
then
3264 if ( qcrg(k,i,j) >= 0.0_rp )
then
3266 dqrho_pls(k,i,j) = fp * ( abs( qcrg(k,i,j) )-qrho_neut )
3267 sumdqrho_pls = sumdqrho_pls &
3268 + fp * ( abs( qcrg(k,i,j) )-qrho_neut )
3269 dqrho_mns(k,i,j) = 0.0_rp
3272 dqrho_mns(k,i,j) = fp * ( abs( qcrg(k,i,j) )-qrho_neut )
3273 sumdqrho_mns = sumdqrho_mns &
3274 + fp * ( abs( qcrg(k,i,j) )-qrho_neut )
3275 dqrho_pls(k,i,j) = 0.0_rp
3278 dqrho_pls(k,i,j) = 0.0_rp
3279 dqrho_mns(k,i,j) = 0.0_rp
3287 call mpi_allreduce(iprod, ibuf, 2, mpi_integer, mpi_sum,
comm_world, ierr)
3293 if ( ntot > 0 )
exit
3297 if ( count_path > nutr_itmax )
then
3298 log_info(
"ATMOS_PHY_LT_Efield",*)
"Reach limit iteration for searching flash path", count_path, npls, nmns, current_prc
3301 if( corr_flag(1) == 1 .and. corr_flag(2) == 1 )
then
3302 dqrho_cor = sumdqrho_pls - sumdqrho_mns
3307 dqrho_cor = dqrho_cor / ntot
3316 d_qcrg(k,i,j) = 0.0_rp
3323 if(
prc_num_x == 1 .and. imax == 2 )
then
3328 if( l_path(k,is,j) /= 0.0_rp )
then
3329 l_path(k,ie,j) = l_path(k,is,j)
3330 if( dqrho_pls(k,is,j) /= 0.0_rp )
then
3331 d_qcrg(k,is,j) = - dqrho_pls(k,is,j) - dqrho_cor
3332 d_qcrg(k,ie,j) = d_qcrg(k,is,j)
3333 elseif( dqrho_mns(k,is,j) /= 0.0_rp )
then
3334 d_qcrg(k,is,j) = dqrho_mns(k,is,j) - dqrho_cor
3335 d_qcrg(k,ie,j) = d_qcrg(k,is,j)
3337 elseif( l_path(k,ie,j) /= 0.0_rp )
then
3338 l_path(k,is,j) = l_path(k,ie,j)
3339 if( dqrho_pls(k,ie,j) /= 0.0_rp )
then
3340 d_qcrg(k,ie,j) = - dqrho_pls(k,ie,j) - dqrho_cor
3341 d_qcrg(k,is,j) = d_qcrg(k,ie,j)
3342 elseif( dqrho_mns(k,ie,j) /= 0.0_rp )
then
3343 d_qcrg(k,ie,j) = dqrho_mns(k,ie,j) - dqrho_cor
3344 d_qcrg(k,is,j) = d_qcrg(k,ie,j)
3349 if( flg_num_end(k,is,j,iq) == 1 )
then
3350 num_end(k,ie,j,iq) = num_end(k,ie,j,iq) + 1.0_rp
3352 if( flg_num_end(k,ie,j,iq) == 1 )
then
3353 num_end(k,is,j,iq) = num_end(k,is,j,iq) + 1.0_rp
3361 elseif(
prc_num_y == 1 .and. jmax == 2 )
then
3366 if( l_path(k,i,js) /= 0.0_rp )
then
3367 l_path(k,i,je) = l_path(k,i,js)
3368 if( dqrho_pls(k,i,js) /= 0.0_rp )
then
3369 d_qcrg(k,i,js) = - dqrho_pls(k,i,js) - dqrho_cor
3370 d_qcrg(k,i,je) = d_qcrg(k,i,js)
3371 elseif( dqrho_mns(k,i,js) /= 0.0_rp )
then
3372 d_qcrg(k,i,js) = dqrho_mns(k,i,js) - dqrho_cor
3373 d_qcrg(k,i,je) = d_qcrg(k,i,js)
3375 elseif( l_path(k,i,je) /= 0.0_rp )
then
3376 l_path(k,i,js) = l_path(k,i,je)
3377 if( dqrho_pls(k,i,je) /= 0.0_rp )
then
3378 d_qcrg(k,i,je) = - dqrho_pls(k,i,je) - dqrho_cor
3379 d_qcrg(k,i,js) = d_qcrg(k,i,je)
3380 elseif( dqrho_mns(k,i,je) /= 0.0_rp )
then
3381 d_qcrg(k,i,je) = dqrho_mns(k,i,je) - dqrho_cor
3382 d_qcrg(k,i,js) = d_qcrg(k,i,je)
3387 if( flg_num_end(k,i,js,iq) == 1 )
then
3388 num_end(k,i,je,iq) = num_end(k,i,je,iq) + 1.0_rp
3390 if( flg_num_end(k,i,je,iq) == 1 )
then
3391 num_end(k,i,js,iq) = num_end(k,i,js,iq) + 1.0_rp
3404 if( l_path(k,i,j) /= 0.0_rp .and. dqrho_pls(k,i,j) /= 0.0_rp )
then
3405 d_qcrg(k,i,j) = - dqrho_pls(k,i,j) - dqrho_cor
3406 elseif( l_path(k,i,j) /= 0.0_rp .and. dqrho_mns(k,i,j) /= 0.0_rp )
then
3407 d_qcrg(k,i,j) = dqrho_mns(k,i,j) - dqrho_cor
3419 lt_path(k,i,j) = lt_path(k,i,j) + l_path(k,i,j)
3433 KA, KS, KE, & ! [IN]
3434 IA, IS, IE, & ! [IN]
3435 JA, JS, JE, & ! [IN]
3442 NUM_end, & ! [INOUT]
3443 LT_path, & ! [INOUT]
3444 fls_int_p, & ! [OUT]
3492 integer,
intent(in) :: KA, KS, KE
3493 integer,
intent(in) :: IA, IS, IE
3494 integer,
intent(in) :: JA, JS, JE
3495 integer,
intent(in) :: KIJMAX
3496 real(RP),
intent(in) :: Efield (KA,IA,JA,4)
3497 real(RP),
intent(in) :: E_pot (KA,IA,JA)
3498 real(RP),
intent(in) :: QCRG (KA,IA,JA)
3499 real(RP),
intent(in) :: DENS (KA,IA,JA)
3500 real(RP),
intent(in) :: QHYD (KA,IA,JA)
3501 real(RP),
intent(inout) :: NUM_end (KA,IA,JA,3)
3502 real(RP),
intent(inout) :: LT_path (KA,IA,JA)
3503 real(RP),
intent(out) :: fls_int_p(KA,IA,JA)
3504 real(RP),
intent(out) :: d_QCRG (KA,IA,JA)
3505 real(RP),
intent(out) :: B_OUT (IA,JA)
3507 real(RP),
parameter :: q_thre = 0.1_rp
3509 real(RP) :: B(IA,JA)
3511 real(RP) :: Q_d, Fpls, Fmns
3512 real(RP) :: Spls, Smns
3513 real(RP) :: Spls_g, Smns_g
3514 real(RP) :: distance
3515 real(RP) :: Edif(KS:KE), Edif_max, abs_qcrg_max
3519 real(RP),
allocatable :: E_exce_x(:), E_exce_x_g(:)
3520 real(RP),
allocatable :: E_exce_y(:), E_exce_y_g(:)
3521 real(RP) :: exce_grid(2,KIJMAX)
3522 integer :: count1(PRC_nprocs)
3523 integer :: countindx(PRC_nprocs+1)
3525 integer :: num_total
3526 real(RP) :: rbuf1, rbuf2
3527 integer :: k, i, j, ipp, iq, ierr
3542 num_end(k,i,j,iq) = 0.0_rp
3558 edif(k) = efield(k,i,j,i_lt_abs) - ( eint-deleint )
3559 edif_max = max( edif_max, edif(k) )
3561 if ( edif_max > 0.0_rp )
then
3563 num_own = num_own + 1
3565 exce_grid(1,num_own) = cx(i)
3566 exce_grid(2,num_own) = cy(j)
3568 fls_int_p(k,i,j) = 0.5_rp + sign( 0.5_rp, edif(k)-eps )
3572 fls_int_p(k,i,j) = 0.0_rp
3583 allocate(e_exce_x(num_own))
3584 allocate(e_exce_y(num_own))
3587 e_exce_x(1:num_own) = exce_grid(1,1:num_own)
3588 e_exce_y(1:num_own) = exce_grid(2,1:num_own)
3590 call mpi_allgather( num_own, 1, mpi_integer, &
3591 count1(:), 1, mpi_integer, &
3595 do ipp = 1, prc_nprocs
3596 countindx(ipp+1) = countindx(ipp) + count1(ipp)
3602 num_total = countindx(prc_nprocs+1)
3603 allocate(e_exce_x_g(num_total))
3604 allocate(e_exce_y_g(num_total))
3618 do ipp = 1, num_total
3621 distance = sqrt( ( cx(i)-e_exce_x_g(ipp) )**2 &
3622 + ( cy(j)-e_exce_y_g(ipp) )**2 )
3623 if( distance <= r_neut )
then
3643 if ( c(i,j) == 1 )
then
3644 abs_qcrg_max = 0.0_rp
3647 abs_qcrg_max = max( abs_qcrg_max, abs( qcrg(k,i,j) ) )
3649 if ( abs_qcrg_max >= q_thre )
then
3652 sw = 0.5_rp + sign( 0.5_rp, qcrg(k,i,j) )
3653 spls = spls + qcrg(k,i,j) * sw
3654 smns = smns - qcrg(k,i,j) * ( 1.0_rp - sw )
3673 if( max( spls_g,smns_g )*0.3_rp < min( spls_g,smns_g ) )
then
3674 q_d = 0.3_rp * max( spls_g,smns_g )
3676 q_d = min( spls_g,smns_g )
3679 if( spls_g /= 0.0_rp )
then
3685 if( smns_g /= 0.0_rp )
then
3697 if( qcrg(k,i,j) > q_thre )
then
3698 d_qcrg(k,i,j) = - fpls * ( qcrg(k,i,j) - q_thre ) * b(i,j)
3699 lt_path(k,i,j) = lt_path(k,i,j) + b(i,j)
3700 elseif( qcrg(k,i,j) < -q_thre )
then
3701 d_qcrg(k,i,j) = + fmns * ( - qcrg(k,i,j) - q_thre ) * b(i,j)
3702 lt_path(k,i,j) = lt_path(k,i,j) - b(i,j)
3704 d_qcrg(k,i,j) = 0.0_rp
3719 deallocate(e_exce_x)
3720 deallocate(e_exce_y)
3721 deallocate(e_exce_x_g)
3722 deallocate(e_exce_y_g)
3734 KA, KS, KE, & ! [IN]
3735 IA, IS, IE, & ! [IN]
3736 JA, JS, JE, & ! [IN]
3748 integer,
intent(in) :: KA, KS, KE
3749 integer,
intent(in) :: IA, IS, IE
3750 integer,
intent(in) :: JA, JS, JE
3751 real(RP),
intent(in) :: DENS (KA,IA,JA)
3752 real(RP),
intent(in) :: Efield (KA,IA,JA)
3753 real(RP),
intent(out) :: Emax
3754 integer,
intent(out) :: flg_lt_neut
3756 real(RP) :: Eint_hgt(KA,IA,JA)
3757 real(RP) :: E_det, rbuf, rprod1
3758 integer :: own_prc_total, iprod1, buf
3759 integer :: k, i, j, ierr
3767 if( flg_eint_hgt == 1.0_rp )
then
3776 eint_hgt(k,i,j) = min( eint*dens(k,i,j)/rho0,eint )
3777 if( eint_hgt(k,i,j) < estop )
then
3778 eint_hgt(k,i,j) = large_num
3780 e_det = efield(k,i,j) - eint_hgt(k,i,j)
3781 if( e_det > 0.0_rp )
then
3782 own_prc_total = own_prc_total + 1
3797 e_det = efield(k,i,j) - ( eint-deleint )
3798 if( e_det > 0.0_rp )
then
3799 own_prc_total = own_prc_total + 1
3808 iprod1 = own_prc_total
3809 call mpi_allreduce(iprod1, buf, 1, mpi_integer, mpi_sum,
comm_world, ierr)
3816 rprod1 = max(rprod1,efield(k,i,j))
3828 if( emax < eint .and. emax >= eint-deleint .and. flg_eint_hgt == 0.0_rp )
then
3840 KA, KS, KE, & ! [IN]
3841 IA, IS, IE, & ! [IN]
3842 JA, JS, JE, & ! [IN]
3853 integer,
intent(in) :: ka, ks, ke
3854 integer,
intent(in) :: ia, is, ie
3855 integer,
intent(in) :: ja, js, je
3856 integer,
intent(in) :: nliq
3857 real(rp),
intent(in) :: temp(ka,ia,ja)
3858 real(rp),
intent(in) :: dens(ka,ia,ja)
3859 real(rp),
intent(in) :: qliq(ka,ia,ja,nliq)
3860 real(rp),
intent(out) :: dqcrg(ka,ia,ja)
3861 real(rp),
intent(out) :: beta_crg(ka,ia,ja)
3863 integer :: i, j, k, pp, qq, iq
3864 integer :: grid1, grid2
3866 real(rp) :: diffx, diffy, tmp
3876 if( temp(k,i,j) <= t00 .and. temp(k,i,j) >= tcrglimit )
then
3880 cwc = cwc + qliq(k,i,j,iq) * dens(k,i,j) * 1.0e+3_rp
3882 diffx = abs( grid_lut_t(1)-temp(k,i,j) )
3886 tmp = abs( grid_lut_t(pp)-temp(k,i,j) )
3887 if ( tmp < diffx )
then
3892 diffy = abs( grid_lut_l(1)-cwc )
3896 tmp = abs( grid_lut_l(qq)-cwc )
3897 if ( tmp < diffy )
then
3902 dqcrg(k,i,j) = dq_chrg( grid1, grid2 ) &
3903 *( 0.5_rp + sign( 0.5_rp,cwc-1.0e-2_rp ) )
3905 dqcrg(k,i,j) = 0.0_rp
3907 if( temp(k,i,j) >= -30.0_rp+t00 )
then
3908 beta_crg(k,i,j) = 1.0_rp
3909 elseif( temp(k,i,j) < -30.0_rp+t00 .and. temp(k,i,j) >= -43.0_rp+t00 )
then
3910 beta_crg(k,i,j) = 1.0_rp - ( ( temp(k,i,j)-t00+30.0_rp )/13.0_rp )**2
3913 beta_crg(k,i,j) = 0.0_rp