49 integer,
private :: ITMAX = 3000
50 real(RP),
private :: epsilon = 0.1_rp ** (rp*2)
51 character(len=64),
private :: NUTR_TYPE=
'F2013'
52 character(len=64),
private,
save :: NUTR_qhyd=
'Each_POLARITY2'
53 integer,
private :: MAX_NUTR = 100
54 real(RP),
private :: Eint = 150.0e+3_rp
55 real(RP),
private :: delEint = 10.0e+3_rp
56 real(RP),
private :: Estop = 15.0e+3_rp
57 real(RP),
private :: qrho_chan = 0.5_rp
58 real(RP),
private :: qrho_neut = 0.5_rp
59 real(RP),
private :: fp = 0.3_rp
60 real(RP),
private :: zcg = 0.0_rp
61 integer,
private :: NUTR_ITMAX = 1000
62 integer,
private :: KIJMAXG
63 character(len=H_LONG) :: ATMOS_PHY_LT_LUT_FILENAME
64 character(len=H_LONG) :: fname_lut_lt=
"LUT_TK1978_v.txt"
65 integer,
save :: fid_lut_lt
66 real(RP),
private :: R_neut = 2000.0_rp
67 real(RP),
private :: rho0 = 1.225_rp
68 real(RP),
save :: flg_eint_hgt
69 logical,
private :: LT_DO_Lightning = .true.
72 real(RP),
allocatable,
private :: d_QCRG_TOT(:,:,:)
73 real(RP),
allocatable,
private :: LT_PATH_TOT(:,:,:,:)
74 real(RP),
allocatable,
private :: fls_int_p_tot(:,:,:)
77 integer,
parameter,
private :: nxlut_lt = 200, nylut_lt = 200
78 real(RP),
private :: dq_chrg( nxlut_lt,nylut_lt )
79 real(RP),
private :: grid_lut_t( nxlut_lt )
80 real(RP),
private :: grid_lut_l( nylut_lt )
81 real(RP),
private :: tcrglimit
82 logical,
private :: Hgt_dependency_Eint = .false.
85 integer,
private,
parameter :: I_lt_x = 1
86 integer,
private,
parameter :: I_lt_y = 2
87 integer,
private,
parameter :: I_lt_z = 3
88 integer,
private,
parameter :: I_lt_abs = 4
91 integer,
private,
parameter :: w_nmax = 10
92 integer,
private,
parameter :: I_Ex = 1
93 integer,
private,
parameter :: I_Ey = 2
94 integer,
private,
parameter :: I_Ez = 3
95 integer,
private,
parameter :: I_Eabs = 4
96 integer,
private,
parameter :: I_Epot = 5
97 integer,
private,
parameter :: I_Qneut = 6
98 integer,
private,
parameter :: I_LTpath = 7
99 integer,
private,
parameter :: I_PosFLASH = 8
100 integer,
private,
parameter :: I_NegFLASH = 9
101 integer,
private,
parameter :: I_FlashPoint = 10
102 integer,
private :: HIST_id(w_nmax)
103 character(len=H_SHORT),
private :: w_name(w_nmax)
104 character(len=H_MID),
private :: w_longname(w_nmax)
105 character(len=H_SHORT),
private :: w_unit(w_nmax)
106 data w_name /
'Ex', &
117 'X component of Electrical Field', &
118 'Y component of Electrical Field', &
119 'Z component of Electrical Field', &
120 'Absolute value of Electrical Field', &
121 'Electric Potential', &
122 'Cumulative Neutralizated charge', &
123 'Cumulative Number of flash path', &
124 'Cumulative Number of Positive flash', &
125 'Cumulative Number of Negative flash', &
126 'Cumulative Number of Flash point' /
163 integer,
intent(in) :: ka, ks, ke
164 integer,
intent(in) :: ia, is, ie
165 integer,
intent(in) :: ja, js, je
166 integer,
intent(in) :: imaxg
167 integer,
intent(in) :: jmaxg
168 integer,
intent(in) :: kmax
170 character(len=*),
intent(in) :: mp_type
171 real(rp),
intent(in) :: cdx(ia)
172 real(rp),
intent(in) :: cdy(ja)
174 integer :: n, myu, ip
177 namelist / param_atmos_phy_lt_sato2019 / &
179 atmos_phy_lt_lut_filename, &
193 hgt_dependency_eint, &
198 read(
io_fid_conf,nml=param_atmos_phy_lt_sato2019,iostat=ierr)
201 log_info(
"ATMOS_PHY_LT_sato2019_setup",*)
'*** Not found namelist. Default used.'
202 elseif( ierr > 0 )
then
203 log_error(
"ATMOS_PHY_LT_sato2019_setup",*)
'xxx Not appropriate names in namelist PARAM_ATMOS_PHY_LT_SATO2019. Check!'
206 log_nml(param_atmos_phy_lt_sato2019)
209 if( zcg <= cz(ks) )
then
213 if( r_neut <= minval( cdx,1 ) .or. r_neut <= minval( cdy,1 ) )
then
214 r_neut = 2.d0 * min( minval( cdx,1 ), minval( cdy,1 ) )
218 fname_lut_lt = atmos_phy_lt_lut_filename
221 open ( fid_lut_lt, file = fname_lut_lt, form =
'formatted', status =
'old', iostat=ierr )
223 if ( ierr == 0 )
then
224 log_info(
"ATMOS_PHY_LT_sato2019_setup",
'(2A)')
'Read LUT of TK78 table from ', trim(fname_lut_lt)
228 read( fid_lut_lt,* ) grid_lut_t( myu ), grid_lut_l( n ), dq_chrg( myu,n )
233 log_error(
"ATMOS_PHY_LT_sato2019_setup",*)
'xxx LUT for LT is requied when ATMOS_PHY_LT_TYPE = SATO2019, stop!'
237 if( nutr_type /=
'MG2001' .and. nutr_type /=
'F2013' )
then
238 log_error(
"ATMOS_PHY_LT_sato2019_setup",*)
'xxx NUTR_TYPE should be MG2001 or F2013 stop!'
243 call comm_bcast( dq_chrg, nxlut_lt,nylut_lt )
244 call comm_bcast( grid_lut_t,nxlut_lt )
245 call comm_bcast( grid_lut_l,nylut_lt )
248 kijmaxg = imaxg*jmaxg*kmax
251 allocate( d_qcrg_tot(ka,ia,ja) )
252 allocate( lt_path_tot(ka,ia,ja,3) )
253 allocate( fls_int_p_tot(ka,ia,ja) )
254 d_qcrg_tot(:,:,:) = 0.0_rp
255 lt_path_tot(:,:,:,:) = 0.0_rp
256 fls_int_p_tot(:,:,:) = 0.0_rp
258 tcrglimit = -60.0_rp+t00
260 if( nutr_type ==
'F2013' )
then
261 log_info(
"ATMOS_PHY_LT_sato2019_setup",
'(A,F15.7,A)')
'Radius of neutralization is ', r_neut,
"[m]"
264 flg_eint_hgt = 0.0_rp
265 if( hgt_dependency_eint .and. nutr_type ==
'MG2001')
then
266 flg_eint_hgt = 1.0_rp
269 if( nutr_qhyd /=
'TOTAL' .and. nutr_qhyd /=
'Each_POLARITY' .and. nutr_qhyd /=
'Each_POLARITY2' )
then
270 log_error(
"ATMOS_PHY_LT_sato2019_setup",*)
'xxx NUTR_qhyd should be TOTAL, or Each_POLARITY, or Each_POLARITY2, stop!'
313 file_history_query, &
317 integer,
intent(in) :: ka, ks, ke
318 integer,
intent(in) :: ia, is, ie
319 integer,
intent(in) :: ja, js, je
320 integer,
intent(in) :: kijmax
321 integer,
intent(in) :: imax
322 integer,
intent(in) :: jmax
324 integer,
intent(in) :: qa_lt
325 real(rp),
intent(in) :: dens(ka,ia,ja)
326 real(rp),
intent(in) :: rhot(ka,ia,ja)
327 real(rp),
intent(in) :: qhyd(ka,ia,ja)
328 real(rp),
intent(in) :: sarea(ka,ia,ja,qa_lt)
329 real(
dp),
intent(in) :: dt_lt
330 real(rp),
intent(inout) :: qtrc(ka,ia,ja,qa_lt)
331 real(rp),
intent(inout) :: epot(ka,ia,ja)
333 real(rp) :: qhyd_mass(ka,ia,ja)
335 real(rp) :: qcrg(ka,ia,ja)
336 real(rp) :: efield(ka,ia,ja,i_lt_abs)
337 real(rp) :: num_end(ka,ia,ja,3)
338 real(rp) :: d_qcrg(ka,ia,ja)
339 real(rp) :: lt_path(ka,ia,ja)
340 real(rp) :: fls_int_p(ka,ia,ja)
341 real(rp) :: total_sarea(2)
342 real(rp) :: neg_crg, pos_crg
343 real(rp) :: frac, r_totalsarea(2)
344 real(rp) :: dqneut(ka,ia,ja,qa_lt)
345 real(rp) :: dqneut_real(ka,ia,ja,qa_lt)
346 real(rp) :: dqneut_real_tot(ka,ia,ja)
347 logical :: flg_chrged(qa_lt)
348 real(rp) :: emax, emax_old
349 logical :: output_step
350 integer :: flg_lt_neut
351 integer :: i, j, k, m, n, countbin, ip
352 real(rp) :: sw, zerosw, positive, negative
353 integer :: count_neut
355 logical :: hist_sw(w_nmax)
356 real(rp) :: w3d(ka,ia,ja)
358 real(rp) :: diff_qcrg(0:1), lack(0:1), sum_crg(0:1)
359 real(rp) :: crg_rate(qa_lt), qcrg_before(qa_lt)
362 num_end(:,:,:,:) = 0.0_rp
373 qcrg(k,i,j) = qcrg(k,i,j) + qtrc(k,i,j,n)
375 qcrg(k,i,j) = qcrg(k,i,j) * dens(k,i,j) * 1.e-6_rp
379 qhyd_mass(k,i,j) = qhyd(k,i,j) * dens(k,i,j)
393 efield(:,:,:,i_lt_x:i_lt_z) )
399 efield(k,i,j,i_lt_abs) = sqrt( efield(k,i,j,i_lt_x)*efield(k,i,j,i_lt_x) &
400 + efield(k,i,j,i_lt_y)*efield(k,i,j,i_lt_y) &
401 + efield(k,i,j,i_lt_z)*efield(k,i,j,i_lt_z) )
404 lt_path(k,i,j) = 0.0_rp
410 if ( lt_do_lightning )
then
416 efield(:,:,:,i_lt_abs), &
422 do while( flg_lt_neut > 0 )
426 call comm_vars8( efield(:,:,:,i_lt_x), 1 )
427 call comm_vars8( efield(:,:,:,i_lt_y), 2 )
428 call comm_vars8( efield(:,:,:,i_lt_z), 3 )
429 call comm_vars8( efield(:,:,:,i_lt_abs), 4 )
430 call comm_vars8( qhyd_mass(:,:,:), 5 )
431 call comm_vars8( qcrg(:,:,:), 6 )
432 call comm_vars8( epot(:,:,:), 7 )
433 call comm_wait ( efield(:,:,:,i_lt_x), 1 )
434 call comm_wait ( efield(:,:,:,i_lt_y), 2 )
435 call comm_wait ( efield(:,:,:,i_lt_z), 3 )
436 call comm_wait ( efield(:,:,:,i_lt_abs), 4 )
437 call comm_wait ( qhyd_mass(:,:,:), 5 )
438 call comm_wait ( qcrg(:,:,:), 6 )
439 call comm_wait ( epot(:,:,:), 7 )
442 if( nutr_type ==
'MG2001' )
then
447 kijmax, imax, jmax, &
457 elseif( nutr_type ==
'F2013' )
then
474 call comm_vars8( lt_path(:,:,:),1 )
475 call comm_vars8( d_qcrg(:,:,:),2 )
476 call comm_wait ( lt_path(:,:,:),1 )
477 call comm_wait ( d_qcrg(:,:,:),2 )
479 dqneut(:,:,:,:) = 0.0_rp
480 dqneut_real(:,:,:,:) = 0.0_rp
482 select case( nutr_qhyd )
490 if( abs( d_qcrg(k,i,j) ) > 0.0_rp )
then
491 total_sarea(1) = 0.0_rp
493 total_sarea(1) = total_sarea(1) + sarea(k,i,j,n)
495 zerosw = 0.5_rp - sign( 0.5_rp, total_sarea(1)-small )
496 r_totalsarea(1) = 1.0_rp / ( total_sarea(1) + zerosw ) * ( 1.0_rp - zerosw )
498 dqneut(k,i,j,n) = d_qcrg(k,i,j)*1.0e+6_rp &
499 * sarea(k,i,j,n) * r_totalsarea(1) / dens(k,i,j)
500 qtrc(k,i,j,n) = qtrc(k,i,j,n) + dqneut(k,i,j,n)
501 dqneut_real(k,i,j,n) = dqneut(k,i,j,n)
508 case (
'Each_POLARITY',
'Each_POLARITY2' )
518 if( abs( d_qcrg(k,i,j) ) > 0.0_rp )
then
522 flg_chrged(n) = abs(qtrc(k,i,j,n)) >= small
525 total_sarea(:) = 0.0_rp
529 if ( flg_chrged(n) )
then
530 positive = 0.5_rp + sign( 0.5_rp, qtrc(k,i,j,n) )
531 negative = 1.0_rp - positive
533 pos_crg = pos_crg + qtrc(k,i,j,n) * positive
535 neg_crg = neg_crg + qtrc(k,i,j,n) * negative
537 total_sarea(1) = total_sarea(1) + sarea(k,i,j,n) * positive
539 total_sarea(2) = total_sarea(2) + sarea(k,i,j,n) * negative
543 zerosw = 0.5_rp - sign( 0.5_rp, abs( qcrg(k,i,j) ) - small )
544 frac = d_qcrg(k,i,j) / ( qcrg(k,i,j) + zerosw ) * ( 1.0_rp - zerosw )
545 pos_crg = frac * pos_crg
546 neg_crg = frac * neg_crg
549 zerosw = 0.5_rp - sign( 0.5_rp, total_sarea(1) - small )
550 r_totalsarea(1) = 1.0_rp / ( total_sarea(1) + zerosw ) * ( 1.0_rp - zerosw )
551 zerosw = 0.5_rp - sign( 0.5_rp, total_sarea(2) - small )
552 r_totalsarea(2) = 1.0_rp / ( total_sarea(2) + zerosw ) * ( 1.0_rp - zerosw )
554 diff_qcrg(:) = 0.0_rp
558 if ( flg_chrged(n) )
then
559 sw = 0.5_rp + sign( 0.5_rp, qtrc(k,i,j,n) )
561 + pos_crg * sarea(k,i,j,n) * r_totalsarea(1) &
563 + neg_crg * sarea(k,i,j,n) * r_totalsarea(2) &
565 qcrg_before(n) = qtrc(k,i,j,n)
567 if( sw == 1.0_rp )
then
568 qtrc(k,i,j,n) = max( qtrc(k,i,j,n) + dqneut(k,i,j,n), 0.0_rp )
569 elseif( sw == 0.0_rp )
then
570 qtrc(k,i,j,n) = min( qtrc(k,i,j,n) + dqneut(k,i,j,n), 0.0_rp )
574 diff_qcrg(int_sw) = diff_qcrg(int_sw) &
575 + ( qtrc(k,i,j,n) - qcrg_before(n) )
576 sum_crg(int_sw) = sum_crg(int_sw) + qtrc(k,i,j,n)
580 if( nutr_qhyd ==
'Each_POLARITY2' )
then
581 lack(0) = neg_crg - diff_qcrg(0)
582 lack(1) = pos_crg - diff_qcrg(1)
584 if( lack(0) > 0.0_rp .and. abs(lack(0)/diff_qcrg(0)) > 1.0e-10_rp )
then
585 log_info(
"ATMOS_PHY_LT_sato2019_adjustment",
'(A,4E15.7)') &
586 "Large negative for lack(0) ", lack(0)/diff_qcrg(0), neg_crg, lack(0), diff_qcrg(0)
588 if( lack(1) < 0.0_rp .and. abs(lack(1)/diff_qcrg(1)) > 1.0e-10_rp )
then
589 log_info(
"ATMOS_PHY_LT_sato2019_adjustment",
'(A,4E15.7)') &
590 "Large positive for lack(1) ", lack(1)/diff_qcrg(1), pos_crg, lack(1), diff_qcrg(1)
593 lack(0) = max( lack(0), 0.0_rp )
594 lack(1) = min( lack(1), 0.0_rp )
596 if ( flg_chrged(n) )
then
597 sw = 0.5_rp + sign( 0.5_rp, qtrc(k,i,j,n) )
599 if( sum_crg(int_sw) /= 0.0_rp )
then
600 crg_rate(n) = qtrc(k,i,j,n)/sum_crg(int_sw)
604 qtrc(k,i,j,n) = qtrc(k,i,j,n) + crg_rate(n) * lack(int_sw)
610 if ( flg_chrged(n) )
then
611 dqneut_real(k,i,j,n) = qtrc(k,i,j,n) - qcrg_before(n)
630 dqneut_real_tot(k,i,j) = 0.0_rp
632 qcrg(k,i,j) = qcrg(k,i,j) + qtrc(k,i,j,n)
633 dqneut_real_tot(k,i,j) = dqneut_real_tot(k,i,j) + dqneut_real(k,i,j,n)
635 qcrg(k,i,j) = qcrg(k,i,j) * dens(k,i,j) * 1.e-6_rp
649 efield(:,:,:,i_lt_x:i_lt_z) )
656 efield(k,i,j,i_lt_abs) = sqrt( efield(k,i,j,i_lt_x)*efield(k,i,j,i_lt_x) &
657 + efield(k,i,j,i_lt_y)*efield(k,i,j,i_lt_y) &
658 + efield(k,i,j,i_lt_z)*efield(k,i,j,i_lt_z) )
664 if ( hist_id(i_qneut) > 0 )
then
669 d_qcrg_tot(k,i,j) = d_qcrg_tot(k,i,j) + dqneut_real_tot(k,i,j)*1.e-6_rp
674 if ( hist_id(i_flashpoint) > 0 )
then
679 fls_int_p_tot(k,i,j) = fls_int_p_tot(k,i,j) + fls_int_p(k,i,j)
685 if ( hist_id(i_posflash) > 0 )
then
690 lt_path_tot(k,i,j,1) = lt_path_tot(k,i,j,1) &
691 + 0.5_rp + sign( 0.5_rp,-dqneut_real_tot(k,i,j)-small )
696 if ( hist_id(i_negflash) > 0 )
then
701 lt_path_tot(k,i,j,2) = lt_path_tot(k,i,j,2) &
702 + 0.5_rp + sign( 0.5_rp, dqneut_real_tot(k,i,j)-small )
707 if ( hist_id(i_ltpath) > 0 )
then
712 lt_path_tot(k,i,j,3) = lt_path_tot(k,i,j,3) + lt_path(k,i,j)
722 efield(:,:,:,i_lt_abs), &
726 count_neut = count_neut + 1
728 log_info(
"ATMOS_PHY_LT_sato2019_adjustment",
'(A,F15.7,A,F15.7,1X,I0)') &
730 emax_old*1.e-3_rp,
' [kV/m] -> ', emax*1.e-3_rp, count_neut
733 if( flg_lt_neut == 1 .and. emax == emax_old )
then
736 log_info(
"ATMOS_PHY_LT_sato2019_adjustment",
'(A,2E15.7,1X,I0)') &
737 'Eabs value after neutralization is same as previous value, Finish', &
738 emax_old*1.e-3_rp,
' [kV/m] -> ', emax*1.e-3_rp, count_neut
740 elseif( flg_lt_neut == 1 .and. count_neut == max_nutr )
then
743 log_info(
"ATMOS_PHY_LT_sato2019_adjustment",
'(2(E15.7,A),1X,I0)') &
744 emax_old*1.e-3_rp,
' [kV/m] -> ', emax*1.e-3_rp, &
745 ' [kV/m], reach maximum neutralization count, Finish', count_neut
747 elseif( flg_lt_neut == 1 .and. emax > emax_old )
then
750 log_info(
"ATMOS_PHY_LT_sato2019_adjustment",
'(2(E15.7,A),1X,I0)') &
751 emax_old*1.e-3_rp,
' [kV/m] -> ', emax*1.e-3_rp, &
752 ' [kV/m] larger than previous one by neutralization, back to previous step, Finish', &
760 qtrc(k,i,j,n) = qtrc(k,i,j,n) - dqneut_real(k,i,j,n)
762 d_qcrg_tot(k,i,j) = d_qcrg_tot(k,i,j) - dqneut_real_tot(k,i,j)*1.e-6_rp
763 d_qcrg(k,i,j) = 0.0_rp
767 elseif( flg_lt_neut == 2 )
then
770 log_info(
"ATMOS_PHY_LT_sato2019_adjustment",
'(2(E15.7,A),1X,I0)') &
771 emax_old*1.e-3_rp,
' [kV/m] -> ', emax*1.e-3_rp, &
772 '[kV/m] After neutralization, Finish' , count_neut
774 elseif( flg_lt_neut == 0 )
then
776 log_info(
"ATMOS_PHY_LT_sato2019_adjustment",
'(2(F15.7,A),1X,I0)') &
777 emax_old*1.e-3_rp,
' [kV/m] -> ', emax*1.e-3_rp, &
778 '[kV/m] After neutralization, Finish', count_neut
790 d_qcrg(k,i,j) = 0.0_rp
799 call file_history_query( hist_id(ip), hist_sw(ip) )
802 if ( hist_sw(i_ex ) )
then
807 w3d(k,i,j) = efield(k,i,j,i_lt_x )*1.0e-3_rp
811 call file_history_put( hist_id(i_ex ), w3d(:,:,:) )
813 if ( hist_sw(i_ey ) )
then
818 w3d(k,i,j) = efield(k,i,j,i_lt_y )*1.0e-3_rp
822 call file_history_put( hist_id(i_ey ), w3d(:,:,:) )
824 if ( hist_sw(i_ez ) )
then
829 w3d(k,i,j) = efield(k,i,j,i_lt_z )*1.0e-3_rp
833 call file_history_put( hist_id(i_ez ), w3d(:,:,:) )
835 if ( hist_sw(i_eabs) )
then
840 w3d(k,i,j) = efield(k,i,j,i_lt_abs)*1.0e-3_rp
844 call file_history_put( hist_id(i_eabs), w3d(:,:,:) )
846 if ( hist_sw(i_epot) )
then
847 call file_history_put( hist_id(i_epot), epot(:,:,:) )
849 if ( hist_sw(i_qneut) )
then
850 call file_history_put( hist_id(i_qneut), d_qcrg_tot(:,:,:) )
855 d_qcrg_tot(k,i,j) = 0.0_rp
860 if ( hist_sw(i_ltpath) )
then
861 call file_history_put( hist_id(i_ltpath), lt_path_tot(:,:,:,3) )
866 lt_path_tot(k,i,j,3) = 0.0_rp
871 if ( hist_sw(i_posflash) )
then
872 call file_history_put( hist_id(i_posflash), lt_path_tot(:,:,:,1) )
877 lt_path_tot(k,i,j,1) = 0.0_rp
882 if ( hist_sw(i_negflash) )
then
883 call file_history_put( hist_id(i_negflash), lt_path_tot(:,:,:,2) )
888 lt_path_tot(k,i,j,2) = 0.0_rp
893 if ( hist_sw(i_flashpoint) )
then
894 call file_history_put( hist_id(i_flashpoint), fls_int_p_tot(:,:,:) )
899 fls_int_p_tot(k,i,j) = 0.0_rp
966 integer,
intent(in) :: KA, KS, KE
967 integer,
intent(in) :: IA, IS, IE
968 integer,
intent(in) :: JA, JS, JE
969 real(RP),
intent(in) :: QCRG (KA,IA,JA)
970 real(RP),
intent(in) :: DENS (KA,IA,JA)
971 real(RP),
intent(in) :: RHOT (KA,IA,JA)
972 real(RP),
intent(inout) :: E_pot (KA,IA,JA)
973 real(RP),
intent(out) :: Efield(KA,IA,JA,3)
975 real(RP) :: eps_air(KA,IA,JA)
977 real(RP) :: A(KA,15,IA,JA)
978 real(RP) :: B(KA,IA,JA)
979 real(RP) :: E_pot_N(KA,IA,JA)
981 integer :: i, j, k, ijk, ierror
982 real(RP) :: iprod, buf
991 iprod = iprod + abs( qcrg(k,i,j) )
998 if( buf <= eps )
then
1003 e_pot(k,i,j) = 0.0_rp
1004 efield(k,i,j,1:3) = 0.0_rp
1016 eps_air(k,i,j) = epsvac * epsair
1017 b(k,i,j) = - qcrg(k,i,j)/eps_air(k,i,j) * 1.0e-9_rp
1023 call comm_vars8( eps_air,1 )
1024 call comm_vars8( b, 2 )
1033 - mapf(i,j ,1,
i_xy)*mapf(i,j ,1,
i_xy)*rcdx(i )*rfdx(i) &
1034 - mapf(i,j ,1,
i_xy)*mapf(i,j ,1,
i_xy)*rcdx(i-1)*rfdx(i) &
1035 + mapf(i,j ,1,
i_xy)*j13g(k,i ,j,
i_uyz)*f2h(k ,i,j,2)*0.5_rp*rfdx(i)*rfdz(k) &
1036 - 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) &
1037 - 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) &
1038 + 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) &
1039 - j13g(k,i,j,
i_xyz)*j13g(k ,i,j,
i_xyw)*rcdz(k)*rfdz(k) &
1040 - j13g(k,i,j,
i_xyz)*j13g(k-1,i,j,
i_xyw)*rcdz(k)*rfdz(k) &
1041 - mapf(i,j ,2,
i_xy)*mapf(i,j ,2,
i_xy)*rcdy(j )*rfdy(j) &
1042 - mapf(i,j ,2,
i_xy)*mapf(i,j ,2,
i_xy)*rcdy(j-1)*rfdy(j) &
1043 + mapf(i,j ,2,
i_xy)*j23g(k,i,j ,
i_xvz)*f2h(k ,i,j,2)*0.5_rp*rfdy(j)*rfdz(k) &
1044 - 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) &
1045 - 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) &
1046 + mapf(i,j ,2,
i_xy)*j23g(k,i,j-1,
i_xvz)*f2h(k-1,i,j,1)*0.5_rp*r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*0.5_rp*rfdy(j)*rfdz(k)
1121 - 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) &
1122 - 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)
1126 - 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) &
1127 - 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)
1131 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) &
1132 + 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)
1136 - 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) &
1137 - 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)
1141 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) &
1142 + 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)
1153 e_pot_n(k,i,j) = e_pot(k,i,j)
1157 call comm_vars8( e_pot_n, 3 )
1160 call comm_wait ( eps_air, 1 )
1161 call comm_wait ( b, 2 )
1162 call comm_wait ( e_pot_n, 3 )
1173 call comm_vars8( e_pot, 1 )
1174 call comm_wait ( e_pot, 1, .true. )
1179 e_pot(1:ks-1,i,j) = 0.0_rp
1180 e_pot(ke+1:ka,i,j) = 0.0_rp
1189 efield(k,i,j,i_lt_x) = - mapf(i,j,1,
i_xyz)/gsqrt(k,i,j,
i_xyz) * &
1191 ( 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) ) &
1192 * rcdx(i) * 0.5_rp &
1193 + ( j13g(k+1,i,j,
i_uyw)*gsqrt(k+1,i,j,
i_uyw)*e_pot(k+1,i,j) &
1194 - j13g(k-1,i,j,
i_uyw)*gsqrt(k-1,i,j,
i_uyw)*e_pot(k-1,i,j) &
1196 * rfdz(k) * 0.5_rp &
1198 efield(k,i,j,i_lt_y) = - mapf(i,j,2,
i_xyz)/gsqrt(k,i,j,
i_xyz) * &
1200 ( 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) ) &
1201 * rcdy(j) * 0.5_rp &
1202 + ( j23g(k+1,i,j,
i_uyw)*gsqrt(k+1,i,j,
i_uyw)*e_pot(k+1,i,j) &
1203 - j23g(k-1,i,j,
i_uyw)*gsqrt(k-1,i,j,
i_uyw)*e_pot(k-1,i,j) &
1205 * rfdz(k) * 0.5_rp &
1207 efield(k,i,j,i_lt_z) = - 1.0_rp/gsqrt(k,i,j,
i_xyz) * &
1208 ( j33g*e_pot(k+1,i ,j )*gsqrt(k+1,i,j,
i_xyz) &
1209 - j33g*e_pot(k-1,i ,j )*gsqrt(k-1,i,j,
i_xyz) &
1222 KA, KS, KE, & ! [IN]
1223 IA, IS, IE, & ! [IN]
1224 JA, JS, JE, & ! [IN]
1237 integer,
intent(in) :: KA, KS, KE
1238 integer,
intent(in) :: IA, IS, IE
1239 integer,
intent(in) :: JA, JS, JE
1240 real(RP),
intent(out) :: PHI_N(KA,IA,JA)
1241 real(RP),
intent(in) :: PHI(KA,IA,JA)
1242 real(RP),
intent(in) :: M(KA,15,IA,JA)
1243 real(RP),
intent(in) :: B(KA,IA,JA)
1245 real(RP) :: r0(KA,IA,JA)
1247 real(RP) :: p(KA,IA,JA)
1248 real(RP) :: Mp(KA,IA,JA)
1249 real(RP) :: s(KA,IA,JA)
1250 real(RP) :: Ms(KA,IA,JA)
1251 real(RP) :: al, be, w
1253 real(RP),
pointer :: r(:,:,:)
1254 real(RP),
pointer :: rn(:,:,:)
1255 real(RP),
pointer :: swap(:,:,:)
1256 real(RP),
target :: v0(KA,IA,JA)
1257 real(RP),
target :: v1(KA,IA,JA)
1259 real(RP) :: norm, error, error2
1261 real(RP) :: iprod(2)
1265 integer :: iis, iie, jjs, jje
1282 norm = norm + b(k,i,j)**2
1292 r(k,i,j) = b(k,i,j) - v1(k,i,j)
1301 r0(k,i,j) = r(k,i,j)
1312 r0r = r0r + r0(k,i,j) * r(k,i,j)
1321 phi_n(k,i,j) = phi(k,i,j)
1342 error = error + r(k,i,j)**2
1349 if ( sqrt(error/norm) < epsilon )
then
1350 log_info(
"ATMOS_PHY_LT_Efield",
'(a,1x,i0,1x,2e15.7)')
"Bi-CGSTAB converged:", iter, sqrt(error/norm),norm
1355 call comm_vars8( p, 1 )
1356 call comm_wait ( p, 1 )
1367 iprod(1) = iprod(1) + r0(k,i,j) * mp(k,i,j)
1372 if ( buf(1) == 0.0_rp )
then
1373 log_info(
"ATMOS_PHY_LT_Efield",
'(a,1x,e15.7,1x,i10)')
'Buf(1) is zero(Bi-CGSTAB) skip:', buf(1), iter
1382 s(k,i,j) = r(k,i,j) - al*mp(k,i,j)
1387 call comm_vars8( s, 1 )
1388 call comm_wait ( s, 1 )
1399 iprod(1) = iprod(1) + ms(k,i,j) * s(k,i,j)
1400 iprod(2) = iprod(2) + ms(k,i,j) * ms(k,i,j)
1405 if ( buf(2) == 0.0_rp )
then
1406 log_info(
"ATMOS_PHY_LT_Efield",
'(a,1x,e15.7,1x,i10)')
'Buf(2) is zero(Bi-CGSTAB) skip:', buf(2), iter
1415 phi_n(k,i,j) = phi_n(k,i,j) + al*p(k,i,j) + w*s(k,i,j)
1424 rn(k,i,j) = s(k,i,j) - w*ms(k,i,j)
1434 iprod(1) = iprod(1) + r0(k,i,j) * rn(k,i,j)
1449 p(k,i,j) = rn(k,i,j) + be * ( p(k,i,j) - w*mp(k,i,j) )
1458 if ( r0r == 0.0_rp )
then
1459 log_info(
"ATMOS_PHY_LT_Efield",
'(a,1x,i0,1x,3e15.7)')
"Inner product of r0 and r_itr is zero(Bi-CGSTAB) :", &
1460 iter, r0r, sqrt(error/norm), norm
1466 if ( iter >= itmax )
then
1468 log_warn(
"ATMOS_PHY_LT_solve_bicgstab",
'(a,1x,2e15.7)')
'Bi-CGSTAB not converged:', error, norm
1469 log_warn_cont(
'(a,1x,2e15.7)')
'Bi-CGSTAB not converged:', epsilon, sqrt(error/norm)
1470 log_warn_cont(
'(a,1x,2e15.7)')
'xxx epsilon(set,last)=', epsilon, sqrt(error/norm)
1471 if( error /= error )
then
1472 log_error(
"ATMOS_PHY_LT_solve_bicgstab",*)
'xxx error or norm is NaN Stop!'
1486 integer,
intent(in) :: KA, KS, KE
1487 integer,
intent(in) :: IA, IS, IE
1488 integer,
intent(in) :: JA, JS, JE
1489 real(RP),
intent(out) :: V(KA,IA,JA)
1490 real(RP),
intent(in) :: M(KA,15,IA,JA)
1491 real(RP),
intent(in) :: C(KA,IA,JA)
1499 v(k,i,j) = m(k,1,i,j) * c(k ,i ,j ) &
1500 + m(k,2,i,j) * c(k-1,i ,j ) &
1501 + m(k,3,i,j) * c(k+1,i ,j ) &
1502 + m(k,4,i,j) * c(k ,i-1,j ) &
1503 + m(k,5,i,j) * c(k ,i+1,j ) &
1504 + m(k,6,i,j) * c(k ,i ,j-1) &
1505 + m(k,7,i,j) * c(k ,i ,j+1) &
1506 + m(k,8,i,j) * c(k-1,i-1,j ) &
1507 + m(k,9,i,j) * c(k-1,i+1,j ) &
1508 + m(k,10,i,j)* c(k-1,i ,j-1) &
1509 + m(k,11,i,j)* c(k-1,i ,j+1) &
1510 + m(k,12,i,j)* c(k+1,i-1,j ) &
1511 + m(k,13,i,j)* c(k+1,i+1,j ) &
1512 + m(k,14,i,j)* c(k+1,i ,j-1) &
1513 + m(k,15,i,j)* c(k+1,i ,j+1)
1515 v(ks,i,j) = m(ks,1,i,j) * c(ks ,i ,j ) &
1516 + m(ks,3,i,j) * c(ks+1,i ,j ) &
1517 + m(ks,4,i,j) * c(ks ,i-1,j ) &
1518 + m(ks,5,i,j) * c(ks ,i+1,j ) &
1519 + m(ks,6,i,j) * c(ks ,i ,j-1) &
1520 + m(ks,7,i,j) * c(ks ,i ,j+1) &
1521 + m(ks,12,i,j)* c(ks+1,i-1,j ) &
1522 + m(ks,13,i,j)* c(ks+1,i+1,j ) &
1523 + m(ks,14,i,j)* c(ks+1,i ,j-1) &
1524 + m(ks,15,i,j)* c(ks+1,i ,j+1)
1525 v(ke,i,j) = m(ke,1,i,j) * c(ke ,i ,j ) &
1526 + m(ke,2,i,j) * c(ke-1,i ,j ) &
1527 + m(ke,4,i,j) * c(ke ,i-1,j ) &
1528 + m(ke,5,i,j) * c(ke ,i+1,j ) &
1529 + m(ke,6,i,j) * c(ke ,i ,j-1) &
1530 + m(ke,7,i,j) * c(ke ,i ,j+1) &
1531 + m(ke,8,i,j) * c(ke-1,i-1,j ) &
1532 + m(ke,9,i,j) * c(ke-1,i+1,j ) &
1533 + m(ke,10,i,j)* c(ke-1,i ,j-1) &
1534 + m(ke,11,i,j)* c(ke-1,i ,j+1)
1541 function f2h( k,i,j,p )
1553 integer,
intent(in) :: k, i, j, p
1555 f2h = (cdz(k+p-1)*gsqrt(k+p-1,i,j,
i_xyz) &
1556 / (cdz(k)*gsqrt(k,i,j,
i_xyz)+cdz(k+1)*gsqrt(k+1,i,j,
i_xyz)))
1563 KA, KS, KE, & ! [IN]
1564 IA, IS, IE, & ! [IN]
1565 JA, JS, JE, & ! [IN]
1574 NUM_end, & ! [INOUT]
1575 LT_path, & ! [INOUT]
1576 fls_int_p, & ! [OUT]
1626 integer,
intent(in) :: KA, KS, KE
1627 integer,
intent(in) :: IA, IS, IE
1628 integer,
intent(in) :: JA, JS, JE
1629 integer,
intent(in) :: KIJMAX, IMAX, JMAX
1630 real(RP),
intent(in) :: Efield (KA,IA,JA,4)
1631 real(RP),
intent(in) :: E_pot (KA,IA,JA)
1632 real(RP),
intent(in) :: QCRG (KA,IA,JA)
1633 real(RP),
intent(in) :: DENS (KA,IA,JA)
1634 real(RP),
intent(in) :: QHYD (KA,IA,JA)
1635 real(RP),
intent(inout) :: NUM_end (KA,IA,JA,3)
1636 real(RP),
intent(inout) :: LT_path (KA,IA,JA)
1637 real(RP),
intent(out) :: fls_int_p(KA,IA,JA)
1638 real(RP),
intent(out) :: d_QCRG (KA,IA,JA)
1640 real(RP) :: E_det, E_x, E_y, E_z, E_max
1641 real(RP) :: dqrho_pls(KA,IA,JA), dqrho_mns(KA,IA,JA)
1642 real(RP) :: L_path(KA,IA,JA)
1643 real(RP) :: sumdqrho_pls, sumdqrho_mns
1644 real(RP) :: Ncrit, dqrho_cor
1645 real(RP) :: randnum(1)
1646 real(RP) :: rprod1, rprod2, rbuf, rbuf2, phi_end(2)
1647 integer :: Eovid(4,KIJMAX)
1648 integer :: Npls, Nmns, Ntot
1649 integer :: count1(PRC_nprocs)
1650 integer :: countindx(PRC_nprocs+1)
1651 integer :: own_prc_total
1652 integer :: iprod(2), ibuf(6), status(MPI_STATUS_SIZE)
1653 integer :: init_point, rank_initpoint, grid_initpoint
1654 integer :: current_prc
1655 integer :: comm_flag, comm_target, stop_flag, corr_flag(2)
1656 integer :: end_grid(4), wild_grid(6)
1658 integer :: k, i, j, ipp, iq, direction, ierr
1659 integer :: k1, i1, j1, k2, i2, j2, sign_flash
1660 integer :: wild_flag, count_path
1661 integer :: flg_num_end(KA,IA,JA,3)
1662 real(RP) :: Eint_hgt(KA,IA,JA)
1670 fls_int_p(k,i,j) = 0.0_rp
1675 do count_path = 1, nutr_itmax
1683 eint_hgt(k,i,j) = min( eint*dens(k,i,j)/rho0,eint )*flg_eint_hgt &
1684 + ( eint-deleint )*( 1.0_rp-flg_eint_hgt )
1685 if( flg_eint_hgt == 1.0_rp .and. eint_hgt(k,i,j) < estop )
then
1686 eint_hgt(k,i,j) = large_num
1688 e_det = efield(k,i,j,i_lt_abs) - eint_hgt(k,i,j)
1689 if( e_det > 0.0_rp )
then
1690 own_prc_total = own_prc_total + 1
1691 eovid(1,own_prc_total) = i
1692 eovid(2,own_prc_total) = j
1693 eovid(3,own_prc_total) = k
1700 call mpi_allgather( own_prc_total, 1, mpi_integer, &
1701 count1, 1, mpi_integer, &
1706 do ipp = 1, prc_nprocs
1707 countindx(ipp+1) = countindx(ipp) + count1(ipp)
1714 call random_uniform(randnum)
1715 init_point = int( randnum(1) * countindx(prc_nprocs+1) ) + 1
1716 do ipp = 1, prc_nprocs
1717 if ( countindx(ipp+1) >= init_point )
then
1718 rank_initpoint = ipp-1
1722 grid_initpoint = init_point - countindx(rank_initpoint+1)
1723 ibuf(1) = rank_initpoint
1724 ibuf(2) = grid_initpoint
1727 call comm_bcast( ibuf, 2 )
1729 rank_initpoint = ibuf(1)
1730 grid_initpoint = ibuf(2)
1739 l_path(k,i,j) = 0.0_rp
1740 flg_num_end(k,i,j,:) = 0
1750 elseif( iq == 2 )
then
1754 current_prc = rank_initpoint
1758 i = eovid(1,grid_initpoint)
1759 j = eovid(2,grid_initpoint)
1760 k = eovid(3,grid_initpoint)
1762 if( iq == 1 ) fls_int_p(k,i,j) = fls_int_p(k,i,j) + 1.0_rp
1763 sign_flash = 2 + int( sign( 1.0_rp, qcrg(k,i,j) ) )
1770 loop_path :
do ipp = 1, kijmaxg
1776 e_x = abs( efield(k,i,j,i_lt_x) )/cdx(i)
1777 e_y = abs( efield(k,i,j,i_lt_y) )/cdy(j)
1778 e_z = abs( efield(k,i,j,i_lt_z) )/cdz(k)
1779 e_det = max( e_x,e_y,e_z )
1784 if( e_det == e_x )
then
1785 direction = int( sign( 1.0_rp,efield(k,i,j,i_lt_x) ) * pm )
1787 elseif( e_det == e_y )
then
1788 direction = int( sign( 1.0_rp,efield(k,i,j,i_lt_y) ) * pm )
1790 elseif( e_det == e_z )
then
1791 direction = int( sign( 1.0_rp,efield(k,i,j,i_lt_z) ) * pm )
1796 if( efield(k1,i1,j1,i_lt_abs) <= estop )
then
1798 phi_end(iq) = qcrg(k,i,j)
1800 num_end(k,i,j,sign_flash) = num_end(k,i,j,sign_flash) + 1.0_rp
1801 flg_num_end(k,i,j,sign_flash) = 1
1808 if( qhyd(k,i,j) < eps )
then
1813 elseif( efield(k1,i1,j1,i_lt_abs) > estop )
then
1815 l_path(k, i ,j ) = pm
1816 l_path(k1,i1,j1) = pm
1822 num_end(k,i,j,sign_flash) = num_end(k,i,j,sign_flash) + 1.0_rp
1823 flg_num_end(k,i,j,sign_flash) = 1
1830 if( qhyd(k,i,j) < eps )
then
1835 elseif( cz(k1) < zcg )
then
1837 num_end(k,i,j,2) = num_end(k,i,j,2) + 1.0_rp
1838 flg_num_end(k,i,j,2) = 1
1845 if( qhyd(k,i,j) < eps )
then
1852 if( stop_flag /= 1 )
then
1854 if( i1 == is-1 .and. .not.
prc_has_w )
then
1856 num_end(k,i,j,sign_flash) = num_end(k,i,j,sign_flash) + 1.0_rp
1857 flg_num_end(k,i,j,sign_flash) = 1
1859 l_path(k1,i1,j1) = pm
1865 if( qhyd(k,i,j) < eps )
then
1870 elseif( i1 == is-1 .and.
prc_has_w )
then
1873 l_path(k1,i1,j1) = pm
1877 elseif( i1 == ie+1 .and. .not.
prc_has_e )
then
1879 num_end(k,i,j,sign_flash) = num_end(k,i,j,sign_flash) + 1.0_rp
1880 flg_num_end(k,i,j,sign_flash) = 1
1882 l_path(k1,i1,j1) = pm
1888 if( qhyd(k,i,j) < eps )
then
1893 elseif( i1 == ie+1 .and.
prc_has_e )
then
1896 l_path(k1,i1,j1) = pm
1903 if( j1 == js-1 .and. .not.
prc_has_s )
then
1905 num_end(k,i,j,sign_flash) = num_end(k,i,j,sign_flash) + 1.0_rp
1906 flg_num_end(k,i,j,sign_flash) = 1
1908 l_path(k1,i1,j1) = pm
1914 if( qhyd(k,i,j) < eps )
then
1919 elseif( j1 == js-1 .and.
prc_has_s )
then
1922 l_path(k1,i1,j1) = pm
1926 elseif( j1 == je+1 .and. .not.
prc_has_n )
then
1928 num_end(k,i,j,sign_flash) = num_end(k,i,j,sign_flash) + 1.0_rp
1929 flg_num_end(k,i,j,sign_flash) = 1
1931 l_path(k1,i1,j1) = pm
1938 if( qhyd(k,i,j) < eps )
then
1943 elseif( j1 == je+1 .and.
prc_has_n )
then
1946 l_path(k1,i1,j1) = pm
1956 call mpi_bcast(stop_flag, 1, mpi_integer, current_prc,
comm_world, ierr)
1958 if( stop_flag == 1 )
then
1960 call mpi_bcast(wild_flag, 1, mpi_integer, current_prc,
comm_world, ierr)
1963 ibuf(1:4) = end_grid(:)
1964 ibuf(5:6) = corr_flag(:)
1966 call mpi_bcast(ibuf, 6, mpi_integer, current_prc,
comm_world, ierr)
1967 end_grid(:) = ibuf(1:4)
1968 corr_flag(:) = ibuf(5:6)
1976 call mpi_bcast(comm_flag, 1, mpi_integer, current_prc,
comm_world, ierr)
1979 if( comm_flag == 1 )
then
1980 call mpi_bcast(comm_target, 1, mpi_integer, current_prc,
comm_world, ierr)
1983 call mpi_recv(ibuf, 6, mpi_integer, current_prc, 1,
comm_world, status, ierr)
1987 corr_flag(:) = ibuf(4:5)
1988 sign_flash = ibuf(6)
1995 ibuf(4:5) = corr_flag(:)
1996 ibuf(6) = sign_flash
1997 call mpi_send(ibuf, 6, mpi_integer, comm_target, 1,
comm_world, ierr)
2001 current_prc = comm_target
2015 if( wild_flag == 1 .and. end_grid(4) ==
prc_myrank )
then
2022 if( abs( qcrg(k2,i2,j2) ) > qrho_chan/dens(k2,i2,j2) .and. &
2023 abs( e_pot(k2,i2,j2) ) > abs( phi_end(iq) ) )
then
2024 l_path( k2,i2,j2 ) = l_path( k1,i1,j1 )
2032 if( abs( qcrg(k2,i2,j2) ) > qrho_chan/dens(k2,i2,j2) .and. &
2033 abs( e_pot(k2,i2,j2) ) > abs( phi_end(iq) ) )
then
2034 l_path( k2,i2,j2 ) = l_path( k1,i1,j1 )
2042 if( abs( qcrg(k2,i2,j2) ) > qrho_chan/dens(k2,i2,j2) .and. &
2043 abs( e_pot(k2,i2,j2) ) > abs( phi_end(iq) ) )
then
2044 l_path( k2,i2,j2 ) = l_path( k1,i1,j1 )
2052 if( abs( qcrg(k2,i2,j2) ) > qrho_chan/dens(k2,i2,j2) .and. &
2053 abs( e_pot(k2,i2,j2) ) > abs( phi_end(iq) ) )
then
2054 l_path( k2,i2,j2 ) = l_path( k1,i1,j1 )
2062 if( abs( qcrg(k2,i2,j2) ) > qrho_chan/dens(k2,i2,j2) .and. &
2063 abs( e_pot(k2,i2,j2) ) > abs( phi_end(iq) ) )
then
2064 l_path( k2,i2,j2 ) = l_path( k1,i1,j1 )
2072 if( abs( qcrg(k2,i2,j2) ) > qrho_chan/dens(k2,i2,j2) .and. &
2073 abs( e_pot(k2,i2,j2) ) > abs( phi_end(iq) ) )
then
2074 l_path( k2,i2,j2 ) = l_path( k1,i1,j1 )
2088 sumdqrho_pls = 0.0_rp
2089 sumdqrho_mns = 0.0_rp
2096 if( l_path(k,i,j) /= 0.0_rp .and. abs( qcrg(k,i,j) ) > qrho_chan )
then
2097 if ( qcrg(k,i,j) >= 0.0_rp )
then
2099 dqrho_pls(k,i,j) = fp * ( abs( qcrg(k,i,j) )-qrho_neut )
2100 sumdqrho_pls = sumdqrho_pls &
2101 + fp * ( abs( qcrg(k,i,j) )-qrho_neut )
2102 dqrho_mns(k,i,j) = 0.0_rp
2105 dqrho_mns(k,i,j) = fp * ( abs( qcrg(k,i,j) )-qrho_neut )
2106 sumdqrho_mns = sumdqrho_mns &
2107 + fp * ( abs( qcrg(k,i,j) )-qrho_neut )
2108 dqrho_pls(k,i,j) = 0.0_rp
2111 dqrho_pls(k,i,j) = 0.0_rp
2112 dqrho_mns(k,i,j) = 0.0_rp
2121 call mpi_allreduce(iprod, ibuf, 2, mpi_integer, mpi_sum,
comm_world, ierr)
2127 if ( ntot > 0 )
exit
2131 if ( count_path > nutr_itmax )
then
2132 log_info(
"ATMOS_PHY_LT_Efield",*)
"Reach limit iteration for searching flash path", count_path, npls, nmns, current_prc
2135 if( corr_flag(1) == 1 .and. corr_flag(2) == 1 )
then
2136 dqrho_cor = sumdqrho_pls - sumdqrho_mns
2141 dqrho_cor = dqrho_cor / ntot
2150 d_qcrg(k,i,j) = 0.0_rp
2157 if(
prc_num_x == 1 .and. imax == 2 )
then
2162 if( l_path(k,is,j) /= 0.0_rp )
then
2163 l_path(k,ie,j) = l_path(k,is,j)
2164 if( dqrho_pls(k,is,j) /= 0.0_rp )
then
2165 d_qcrg(k,is,j) = - dqrho_pls(k,is,j) - dqrho_cor
2166 d_qcrg(k,ie,j) = d_qcrg(k,is,j)
2167 elseif( dqrho_mns(k,is,j) /= 0.0_rp )
then
2168 d_qcrg(k,is,j) = dqrho_mns(k,is,j) - dqrho_cor
2169 d_qcrg(k,ie,j) = d_qcrg(k,is,j)
2171 elseif( l_path(k,ie,j) /= 0.0_rp )
then
2172 l_path(k,is,j) = l_path(k,ie,j)
2173 if( dqrho_pls(k,ie,j) /= 0.0_rp )
then
2174 d_qcrg(k,ie,j) = - dqrho_pls(k,ie,j) - dqrho_cor
2175 d_qcrg(k,is,j) = d_qcrg(k,ie,j)
2176 elseif( dqrho_mns(k,ie,j) /= 0.0_rp )
then
2177 d_qcrg(k,ie,j) = dqrho_mns(k,ie,j) - dqrho_cor
2178 d_qcrg(k,is,j) = d_qcrg(k,ie,j)
2183 if( flg_num_end(k,is,j,iq) == 1 )
then
2184 num_end(k,ie,j,iq) = num_end(k,ie,j,iq) + 1.0_rp
2186 if( flg_num_end(k,ie,j,iq) == 1 )
then
2187 num_end(k,is,j,iq) = num_end(k,is,j,iq) + 1.0_rp
2195 elseif(
prc_num_y == 1 .and. jmax == 2 )
then
2200 if( l_path(k,i,js) /= 0.0_rp )
then
2201 l_path(k,i,je) = l_path(k,i,js)
2202 if( dqrho_pls(k,i,js) /= 0.0_rp )
then
2203 d_qcrg(k,i,js) = - dqrho_pls(k,i,js) - dqrho_cor
2204 d_qcrg(k,i,je) = d_qcrg(k,i,js)
2205 elseif( dqrho_mns(k,i,js) /= 0.0_rp )
then
2206 d_qcrg(k,i,js) = dqrho_mns(k,i,js) - dqrho_cor
2207 d_qcrg(k,i,je) = d_qcrg(k,i,js)
2209 elseif( l_path(k,i,je) /= 0.0_rp )
then
2210 l_path(k,i,js) = l_path(k,i,je)
2211 if( dqrho_pls(k,i,je) /= 0.0_rp )
then
2212 d_qcrg(k,i,je) = - dqrho_pls(k,i,je) - dqrho_cor
2213 d_qcrg(k,i,js) = d_qcrg(k,i,je)
2214 elseif( dqrho_mns(k,i,je) /= 0.0_rp )
then
2215 d_qcrg(k,i,je) = dqrho_mns(k,i,je) - dqrho_cor
2216 d_qcrg(k,i,js) = d_qcrg(k,i,je)
2221 if( flg_num_end(k,i,js,iq) == 1 )
then
2222 num_end(k,i,je,iq) = num_end(k,i,je,iq) + 1.0_rp
2224 if( flg_num_end(k,i,je,iq) == 1 )
then
2225 num_end(k,i,js,iq) = num_end(k,i,js,iq) + 1.0_rp
2238 if( l_path(k,i,j) /= 0.0_rp .and. dqrho_pls(k,i,j) /= 0.0_rp )
then
2239 d_qcrg(k,i,j) = - dqrho_pls(k,i,j) - dqrho_cor
2240 elseif( l_path(k,i,j) /= 0.0_rp .and. dqrho_mns(k,i,j) /= 0.0_rp )
then
2241 d_qcrg(k,i,j) = dqrho_mns(k,i,j) - dqrho_cor
2253 lt_path(k,i,j) = lt_path(k,i,j) + l_path(k,i,j)
2267 KA, KS, KE, & ! [IN]
2268 IA, IS, IE, & ! [IN]
2269 JA, JS, JE, & ! [IN]
2276 NUM_end, & ! [INOUT]
2277 LT_path, & ! [INOUT]
2278 fls_int_p, & ! [OUT]
2325 integer,
intent(in) :: KA, KS, KE
2326 integer,
intent(in) :: IA, IS, IE
2327 integer,
intent(in) :: JA, JS, JE
2328 integer,
intent(in) :: KIJMAX
2329 real(RP),
intent(in) :: Efield (KA,IA,JA,4)
2330 real(RP),
intent(in) :: E_pot (KA,IA,JA)
2331 real(RP),
intent(in) :: QCRG (KA,IA,JA)
2332 real(RP),
intent(in) :: DENS (KA,IA,JA)
2333 real(RP),
intent(in) :: QHYD (KA,IA,JA)
2334 real(RP),
intent(inout) :: NUM_end (KA,IA,JA,3)
2335 real(RP),
intent(inout) :: LT_path (KA,IA,JA)
2336 real(RP),
intent(out) :: fls_int_p(KA,IA,JA)
2337 real(RP),
intent(out) :: d_QCRG (KA,IA,JA)
2339 real(RP),
parameter :: q_thre = 0.1_rp
2341 real(RP) :: B(IA,JA)
2343 real(RP) :: Q_d, Fpls, Fmns
2344 real(RP) :: Spls, Smns
2345 real(RP) :: Spls_g, Smns_g
2346 real(RP) :: distance
2347 real(RP) :: Edif(KS:KE), Edif_max, abs_qcrg_max
2350 integer,
allocatable :: proc_num(:), proc_numg(:)
2351 real(RP),
allocatable :: E_exce_x(:), E_exce_x_g(:)
2352 real(RP),
allocatable :: E_exce_y(:), E_exce_y_g(:)
2353 real(RP) :: exce_grid(2,KIJMAX)
2354 integer :: count1(PRC_nprocs)
2355 integer :: countindx(PRC_nprocs+1)
2357 integer :: num_total
2358 real(RP) :: rbuf1(2), rbuf2(2)
2359 integer :: k, i, j, ipp, iq, ierr
2367 num_end(k,i,j,:) = 0.0_rp
2377 edif(k) = efield(k,i,j,i_lt_abs) - ( eint-deleint )
2378 edif_max = max( edif_max, edif(k) )
2380 if ( edif_max > 0.0_rp )
then
2381 num_own = num_own + 1
2382 exce_grid(1,num_own) = cx(i)
2383 exce_grid(2,num_own) = cy(j)
2385 fls_int_p(k,i,j) = 0.5_rp + sign( 0.5_rp, edif(k)-eps )
2389 fls_int_p(k,i,j) = 0.0_rp
2397 allocate(e_exce_x(num_own))
2398 allocate(e_exce_y(num_own))
2401 e_exce_x(1:num_own) = exce_grid(1,1:num_own)
2402 e_exce_y(1:num_own) = exce_grid(2,1:num_own)
2404 call mpi_allgather( num_own, 1, mpi_integer, &
2405 count1, 1, mpi_integer, &
2409 do ipp = 1, prc_nprocs
2410 countindx(ipp+1) = countindx(ipp) + count1(ipp)
2416 num_total = countindx(prc_nprocs+1)
2417 allocate(e_exce_x_g(num_total))
2418 allocate(e_exce_y_g(num_total))
2429 do ipp = 1, num_total
2432 distance = sqrt( ( cx(i)-e_exce_x_g(ipp) )**2 &
2433 + ( cy(j)-e_exce_y_g(ipp) )**2 )
2434 if( distance <= r_neut )
then
2449 if ( c(i,j) == 1 )
then
2450 abs_qcrg_max = abs( qcrg(ks,i,j) )
2452 abs_qcrg_max = max( abs_qcrg_max, abs( qcrg(k,i,j) ) )
2454 if ( abs_qcrg_max >= q_thre )
then
2457 sw = 0.5_rp + sign( 0.5_rp, qcrg(k,i,j) )
2458 spls = spls + qcrg(k,i,j) * sw
2459 smns = smns - qcrg(k,i,j) * ( 1.0_rp - sw )
2477 if( max( spls_g,smns_g )*0.3_rp < min( spls_g,smns_g ) )
then
2478 q_d = 0.3_rp * max( spls_g,smns_g )
2480 q_d = min( spls_g,smns_g )
2483 if( spls_g /= 0.0_rp )
then
2489 if( smns_g /= 0.0_rp )
then
2500 if( qcrg(k,i,j) > q_thre )
then
2501 d_qcrg(k,i,j) = - fpls * ( qcrg(k,i,j) - q_thre ) * b(i,j)
2502 lt_path(k,i,j) = lt_path(k,i,j) + b(i,j)
2503 elseif( qcrg(k,i,j) < -q_thre )
then
2504 d_qcrg(k,i,j) = + fmns * ( - qcrg(k,i,j) - q_thre ) * b(i,j)
2505 lt_path(k,i,j) = lt_path(k,i,j) - b(i,j)
2507 d_qcrg(k,i,j) = 0.0_rp
2514 deallocate(e_exce_x)
2515 deallocate(e_exce_y)
2516 deallocate(e_exce_x_g)
2517 deallocate(e_exce_y_g)
2528 KA, KS, KE, & ! [IN]
2529 IA, IS, IE, & ! [IN]
2530 JA, JS, JE, & ! [IN]
2542 integer,
intent(in) :: KA, KS, KE
2543 integer,
intent(in) :: IA, IS, IE
2544 integer,
intent(in) :: JA, JS, JE
2545 real(RP),
intent(in) :: DENS (KA,IA,JA)
2546 real(RP),
intent(in) :: Efield (KA,IA,JA)
2547 real(RP),
intent(out) :: Emax
2548 integer,
intent(out) :: flg_lt_neut
2550 real(RP) :: Eint_hgt(KA,IA,JA)
2551 real(RP) :: E_det, rbuf, rprod1
2552 integer :: own_prc_total, iprod1, buf
2553 integer :: k, i, j, ierr
2557 if( flg_eint_hgt == 1.0_rp )
then
2564 eint_hgt(k,i,j) = min( eint*dens(k,i,j)/rho0,eint )
2565 if( eint_hgt(k,i,j) < estop )
then
2566 eint_hgt(k,i,j) = large_num
2568 e_det = efield(k,i,j) - eint_hgt(k,i,j)
2569 if( e_det > 0.0_rp )
then
2570 own_prc_total = own_prc_total + 1
2582 e_det = efield(k,i,j) - ( eint-deleint )
2583 if( e_det > 0.0_rp )
then
2584 own_prc_total = own_prc_total + 1
2592 iprod1 = own_prc_total
2593 call mpi_allreduce(iprod1, buf, 1, mpi_integer, mpi_sum,
comm_world, ierr)
2594 rprod1 = maxval(efield(ks:ke,is:ie,js:je))
2602 if( emax < eint .and. emax >= eint-deleint .and. flg_eint_hgt == 0.0_rp )
then
2612 KA, KS, KE, & ! [IN]
2613 IA, IS, IE, & ! [IN]
2614 JA, JS, JE, & ! [IN]
2625 integer,
intent(in) :: ka, ks, ke
2626 integer,
intent(in) :: ia, is, ie
2627 integer,
intent(in) :: ja, js, je
2628 integer,
intent(in) :: nliq
2629 real(rp),
intent(in) :: temp(ka,ia,ja)
2630 real(rp),
intent(in) :: dens(ka,ia,ja)
2631 real(rp),
intent(in) :: qliq(ka,ia,ja,nliq)
2632 real(rp),
intent(out) :: dqcrg(ka,ia,ja)
2633 real(rp),
intent(out) :: beta_crg(ka,ia,ja)
2635 integer :: i, j, k, pp, qq, iq
2638 real(rp) :: diffx(nxlut_lt), diffy(nylut_lt)
2645 if( temp(k,i,j) <= t00 .and. temp(k,i,j) >= tcrglimit )
then
2648 cwc = cwc + qliq(k,i,j,iq) * dens(k,i,j) * 1.0e+3_rp
2651 diffx(pp) = abs( grid_lut_t(pp)-temp(k,i,j) )
2653 grid(1) = minloc( diffx,1 )
2655 diffy(qq) = abs( grid_lut_l(qq)-cwc )
2657 grid(2) = minloc( diffy,1 )
2658 dqcrg(k,i,j) = dq_chrg( grid(1), grid(2) ) &
2659 *( 0.5_rp + sign( 0.5_rp,cwc-1.0e-2_rp ) )
2661 dqcrg(k,i,j) = 0.0_rp
2663 if( temp(k,i,j) >= -30.0_rp+t00 )
then
2664 beta_crg(k,i,j) = 1.0_rp
2665 elseif( temp(k,i,j) < -30.0_rp+t00 .and. temp(k,i,j) >= -43.0_rp+t00 )
then
2666 beta_crg(k,i,j) = 1.0_rp - ( ( temp(k,i,j)-t00+30.0_rp )/13.0_rp )**2
2669 beta_crg(k,i,j) = 0.0_rp