47 private :: atmos_refstate_generate_isa
48 private :: atmos_refstate_generate_uniform
49 private :: atmos_refstate_generate_zero
55 character(len=H_LONG),
private :: atmos_refstate_in_basename =
''
56 logical,
private :: atmos_refstate_in_check_coordinates = .true.
57 character(len=H_LONG),
private :: atmos_refstate_out_basename =
''
58 character(len=H_MID),
private :: atmos_refstate_out_title =
'SCALE-RM RefState'
59 character(len=H_SHORT),
private :: atmos_refstate_out_dtype =
'DEFAULT'
61 character(len=H_SHORT),
private :: atmos_refstate_type =
'UNIFORM'
62 real(
rp),
private :: atmos_refstate_temp_sfc = 300.0_rp
63 real(
rp),
private :: atmos_refstate_rh = 0.0_rp
64 real(
rp),
private :: atmos_refstate_pott_uniform = 300.0_rp
65 real(
dp),
private :: atmos_refstate_update_dt = -1.0_dp
66 logical,
private :: atmos_refstate_update_flag = .false.
68 real(
dp),
private :: last_updated
70 real(
rp),
private,
allocatable :: atmos_refstate1d_pres(:)
71 real(
rp),
private,
allocatable :: atmos_refstate1d_temp(:)
72 real(
rp),
private,
allocatable :: atmos_refstate1d_dens(:)
73 real(
rp),
private,
allocatable :: atmos_refstate1d_pott(:)
74 real(
rp),
private,
allocatable :: atmos_refstate1d_qv (:)
81 KA, KS, KE, IA, IS, IE, JA, JS, JE, &
82 CZ, FZ, REAL_CZ, REAL_FZ, REAL_PHI )
88 integer,
intent(in) :: ka, ks, ke
89 integer,
intent(in) :: ia, is, ie
90 integer,
intent(in) :: ja, js, je
92 real(
rp),
intent(in) :: cz ( ka)
93 real(
rp),
intent(in) :: fz (0:ka)
94 real(
rp),
intent(in) :: real_cz ( ka,ia,ja)
95 real(
rp),
intent(in) :: real_fz (0:ka,ia,ja)
96 real(
rp),
intent(in) :: real_phi( ka,ia,ja)
98 namelist / param_atmos_refstate / &
99 atmos_refstate_in_basename, &
100 atmos_refstate_out_basename, &
101 atmos_refstate_out_title, &
102 atmos_refstate_out_dtype, &
103 atmos_refstate_type, &
104 atmos_refstate_temp_sfc, &
106 atmos_refstate_pott_uniform, &
107 atmos_refstate_update_dt
113 log_info(
"ATMOS_REFSTATE_setup",*)
'Setup'
117 read(
io_fid_conf,nml=param_atmos_refstate,iostat=ierr)
119 log_info(
"ATMOS_REFSTATE_setup",*)
'Not found namelist. Default used.'
120 elseif( ierr > 0 )
then
121 log_error(
"ATMOS_REFSTATE_setup",*)
'Not appropriate names in namelist PARAM_ATMOS_REFSTATE. Check!'
124 log_nml(param_atmos_refstate)
138 allocate( atmos_refstate1d_pres(ka) )
139 allocate( atmos_refstate1d_temp(ka) )
140 allocate( atmos_refstate1d_dens(ka) )
141 allocate( atmos_refstate1d_pott(ka) )
142 allocate( atmos_refstate1d_qv(ka) )
143 atmos_refstate1d_pres(:) = undef
144 atmos_refstate1d_temp(:) = undef
145 atmos_refstate1d_dens(:) = undef
146 atmos_refstate1d_pott(:) = undef
147 atmos_refstate1d_qv(:) = undef
151 log_info(
"ATMOS_REFSTATE_setup",*)
'Reference state settings'
152 if ( atmos_refstate_in_basename /=
'' )
then
153 log_info_cont(*)
'Input file of reference state : ', trim(atmos_refstate_in_basename)
155 log_info_cont(*)
'Input file of reference state : Nothing, generate internally'
158 if ( atmos_refstate_out_basename /=
'' )
then
159 log_info_cont(*)
'Output file of reference state : ', trim(atmos_refstate_out_basename)
161 log_info_cont(*)
'Output file of reference state : No output'
164 atmos_refstate_update_flag = .false.
167 if ( atmos_refstate_in_basename /=
'' )
then
173 if ( atmos_refstate_type ==
'ISA' )
then
175 log_info_cont(*)
'Reference type : ISA'
176 log_info_cont(*)
'Surface temperature [K] : ', atmos_refstate_temp_sfc
177 log_info_cont(*)
'Surface & environment RH [%] : ', atmos_refstate_rh
179 call atmos_refstate_generate_isa( ka, ks, ke, ia, is, ie, ja, js, je, &
181 real_cz(:,:,:), real_fz(:,:,:), &
184 elseif ( atmos_refstate_type ==
'UNIFORM' )
then
186 log_info_cont(*)
'Reference type : UNIFORM POTT'
187 log_info_cont(*)
'Potential temperature : ', atmos_refstate_pott_uniform
189 call atmos_refstate_generate_uniform( ka, ks, ke, ia, is, ie, ja, js, je, &
191 real_cz(:,:,:), real_fz(:,:,:), &
194 elseif ( atmos_refstate_type ==
'ZERO' )
then
196 log_info_cont(*)
'Reference type : ZERO'
198 call atmos_refstate_generate_zero( ka, ia, ja )
200 elseif ( atmos_refstate_type ==
'INIT' )
then
202 atmos_refstate_update_flag = .true.
204 log_info_cont(*)
'Reference type : Generate from initial data'
205 log_info_cont(*)
'Update interval [sec] : ', atmos_refstate_update_dt
208 log_error(
"ATMOS_REFSTATE_setup",*)
'ATMOS_REFSTATE_TYPE must be "ISA", "UNIFORM", "ZERO", or "INIT". Check! : ', trim(atmos_refstate_type)
214 last_updated = -1.0_rp
230 deallocate( atmos_refstate1d_pres )
231 deallocate( atmos_refstate1d_temp )
232 deallocate( atmos_refstate1d_dens )
233 deallocate( atmos_refstate1d_pott )
234 deallocate( atmos_refstate1d_qv )
242 KA, KS, KE, IA, IS, IE, JA, JS, JE, &
246 file_cartesc_check_coordinates, &
252 integer,
intent(in) :: ka, ks, ke
253 integer,
intent(in) :: ia, is, ie
254 integer,
intent(in) :: ja, js, je
255 real(
rp),
intent(in) :: real_phi(ka,ia,ja)
261 log_info(
"ATMOS_REFSTATE_read",*)
'Input reference state profile '
263 if ( atmos_refstate_in_basename /=
'' )
then
267 call file_cartesc_read( fid,
'PRES_ref',
'Z', atmos_refstate1d_pres(:) )
268 call file_cartesc_read( fid,
'TEMP_ref',
'Z', atmos_refstate1d_temp(:) )
269 call file_cartesc_read( fid,
'DENS_ref',
'Z', atmos_refstate1d_dens(:) )
270 call file_cartesc_read( fid,
'POTT_ref',
'Z', atmos_refstate1d_pott(:) )
271 call file_cartesc_read( fid,
'QV_ref',
'Z', atmos_refstate1d_qv(:) )
276 if ( atmos_refstate_in_check_coordinates )
then
277 call file_cartesc_check_coordinates( fid, atmos=.true. )
287 log_error(
"ATMOS_REFSTATE_read",*)
'refstate file is not specified.'
294 call atmos_refstate_fillhalo( ka, ks, ke, ia, is, ie, ja, js, je, real_phi(:,:,:) )
306 logical,
save :: first = .true.
309 if ( .not. first )
return
312 if ( atmos_refstate_out_basename /=
'' )
then
318 log_info(
"ATMOS_REFSTATE_write",*)
'Output reference state profile '
321 call file_cartesc_write( atmos_refstate1d_pres(:), atmos_refstate_out_basename, atmos_refstate_out_title, &
322 'PRES_ref',
'Reference profile of pres.',
'Pa',
'Z', atmos_refstate_out_dtype )
323 call file_cartesc_write( atmos_refstate1d_temp(:), atmos_refstate_out_basename, atmos_refstate_out_title, &
324 'TEMP_ref',
'Reference profile of temp.',
'K',
'Z', atmos_refstate_out_dtype )
325 call file_cartesc_write( atmos_refstate1d_dens(:), atmos_refstate_out_basename, atmos_refstate_out_title, &
326 'DENS_ref',
'Reference profile of rho',
'kg/m3',
'Z', atmos_refstate_out_dtype )
327 call file_cartesc_write( atmos_refstate1d_pott(:), atmos_refstate_out_basename, atmos_refstate_out_title, &
328 'POTT_ref',
'Reference profile of theta',
'K',
'Z', atmos_refstate_out_dtype )
329 call file_cartesc_write( atmos_refstate1d_qv(:), atmos_refstate_out_basename, atmos_refstate_out_title, &
330 'QV_ref',
'Reference profile of qv',
'kg/kg',
'Z', atmos_refstate_out_dtype )
333 call file_cartesc_write(
atmos_refstate_pres(:,:,:), atmos_refstate_out_basename, atmos_refstate_out_title, &
334 'PRES_ref3D',
'Reference profile of pres.',
'Pa',
'ZXY', atmos_refstate_out_dtype )
335 call file_cartesc_write(
atmos_refstate_temp(:,:,:), atmos_refstate_out_basename, atmos_refstate_out_title, &
336 'TEMP_ref3D',
'Reference profile of temp.',
'K',
'ZXY', atmos_refstate_out_dtype )
337 call file_cartesc_write(
atmos_refstate_dens(:,:,:), atmos_refstate_out_basename, atmos_refstate_out_title, &
338 'DENS_ref3D',
'Reference profile of rho',
'kg/m3',
'ZXY', atmos_refstate_out_dtype )
339 call file_cartesc_write(
atmos_refstate_pott(:,:,:), atmos_refstate_out_basename, atmos_refstate_out_title, &
340 'POTT_ref3D',
'Reference profile of theta',
'K',
'ZXY', atmos_refstate_out_dtype )
341 call file_cartesc_write(
atmos_refstate_qv(:,:,:), atmos_refstate_out_basename, atmos_refstate_out_title, &
342 'QV_ref3D',
'Reference profile of qv',
'kg/kg',
'ZXY', atmos_refstate_out_dtype )
351 subroutine atmos_refstate_generate_isa( &
352 KA, KS, KE, IA, IS, IE, JA, JS, JE, &
353 CZ, FZ, REAL_CZ, REAL_FZ, REAL_PHI )
360 profile_isa => atmos_profile_isa
362 hydrostatic_buildrho => atmos_hydrostatic_buildrho
364 saturation_psat_all => atmos_saturation_psat_all, &
365 saturation_dens2qsat_all => atmos_saturation_dens2qsat_all
367 integer,
intent(in) :: ka, ks, ke
368 integer,
intent(in) :: ia, is, ie
369 integer,
intent(in) :: ja, js, je
371 real(
rp),
intent(in) :: cz ( ka)
372 real(
rp),
intent(in) :: fz (0:ka)
373 real(
rp),
intent(in) :: real_cz ( ka,ia,ja)
374 real(
rp),
intent(in) :: real_fz (0:ka,ia,ja)
375 real(
rp),
intent(in) :: real_phi( ka,ia,ja)
394 real(
rp) :: work1(ka)
395 real(
rp) :: work2(ka)
396 real(
rp) :: work3(ka)
403 pott_sfc = atmos_refstate_temp_sfc
406 call profile_isa( ka, ks, ke, &
407 pott_sfc, pres_sfc, &
417 call hydrostatic_buildrho( ka, ks, ke, &
418 pott(:), qv(:), qc(:), &
419 pres_sfc, pott_sfc, qv_sfc, qc_sfc, &
422 work1(:), work2(:), work3(:), &
424 dens(:), temp(:), pres(:), &
428 if ( .not. converged )
then
429 log_error(
"ATMOS_REFSTATE_generate_isa",*)
"not converged"
434 call saturation_psat_all( temp_sfc, psat_sfc )
435 call saturation_dens2qsat_all( ka, ks, ke, &
439 psat_sfc = atmos_refstate_rh * 1.e-2_rp * psat_sfc
440 qv_sfc = epsvap * psat_sfc / ( pres_sfc - (1.0_rp-epsvap) * psat_sfc )
442 qv(k) = atmos_refstate_rh * 1.e-2_rp * qsat(k)
446 call hydrostatic_buildrho( ka, ks, ke, &
447 pott(:), qv(:), qc(:), &
448 pres_sfc, pott_sfc, qv_sfc, qc_sfc, &
451 work1(:), work2(:), work3(:), &
453 dens(:), temp(:), pres(:), &
457 if ( .not. converged )
then
458 log_error(
"ATMOS_REFSTATE_generate_isa",*)
"not converged"
462 atmos_refstate1d_pres(:) = pres(:)
463 atmos_refstate1d_temp(:) = temp(:)
464 atmos_refstate1d_dens(:) = dens(:)
465 atmos_refstate1d_pott(:) = pott(:)
466 atmos_refstate1d_qv(:) = qv(:)
471 cz(:), fz(:), real_cz(:,:,:), real_fz(:,:,:), real_phi(:,:,:) )
474 end subroutine atmos_refstate_generate_isa
478 subroutine atmos_refstate_generate_uniform( &
479 KA, KS, KE, IA, IS, IE, JA, JS, JE, &
480 CZ, FZ, REAL_CZ, REAL_FZ, REAL_PHI )
487 hydrostatic_buildrho => atmos_hydrostatic_buildrho
489 saturation_psat_all => atmos_saturation_psat_all, &
490 saturation_dens2qsat_all => atmos_saturation_dens2qsat_all
492 integer,
intent(in) :: ka, ks, ke
493 integer,
intent(in) :: ia, is, ie
494 integer,
intent(in) :: ja, js, je
496 real(
rp),
intent(in) :: cz ( ka)
497 real(
rp),
intent(in) :: fz (0:ka)
498 real(
rp),
intent(in) :: real_cz ( ka,ia,ja)
499 real(
rp),
intent(in) :: real_fz (0:ka,ia,ja)
500 real(
rp),
intent(in) :: real_phi( ka,ia,ja)
519 real(
rp) :: work1(ka)
520 real(
rp) :: work2(ka)
521 real(
rp) :: work3(ka)
529 pott_sfc = atmos_refstate_temp_sfc
534 pott(k) = atmos_refstate_pott_uniform
540 call hydrostatic_buildrho( ka, ks, ke, &
541 pott(:), qv(:), qc(:), &
542 pres_sfc, pott_sfc, qv_sfc, qc_sfc, &
545 work1(:), work2(:), work3(:), &
547 dens(:), temp(:), pres(:), &
550 if ( .not. converged )
then
551 log_error(
"ATMOS_REFSTATE_generate_uniform",*)
"not converged"
556 call saturation_psat_all( temp_sfc, psat_sfc )
557 call saturation_dens2qsat_all( ka, ks, ke, &
561 psat_sfc = atmos_refstate_rh * 1.e-2_rp * psat_sfc
562 qv_sfc = epsvap * psat_sfc / ( pres_sfc - (1.0_rp - epsvap) * psat_sfc )
564 qv(k) = atmos_refstate_rh * 1.e-2_rp * qsat(k)
568 call hydrostatic_buildrho( ka, ks, ke, &
569 pott(:), qv(:), qc(:), &
570 pres_sfc, pott_sfc, qv_sfc, qc_sfc, &
573 work1(:), work2(:), work3(:), &
575 dens(:), temp(:), pres(:), &
578 if ( .not. converged )
then
579 log_error(
"ATMOS_REFSTATE_generate_uniform",*)
"not converged"
584 atmos_refstate1d_pres(k) = pres(k)
585 atmos_refstate1d_temp(k) = temp(k)
586 atmos_refstate1d_dens(k) = dens(k)
587 atmos_refstate1d_pott(k) = pott(k)
588 atmos_refstate1d_qv(k) = qv(k)
594 cz(:), fz(:), real_cz(:,:,:), real_fz(:,:,:), real_phi(:,:,:) )
597 end subroutine atmos_refstate_generate_uniform
601 subroutine atmos_refstate_generate_zero( KA, IA, JA )
603 integer,
intent(in) :: ka, ia, ja
610 atmos_refstate1d_pres(k) = 0.0_rp
611 atmos_refstate1d_temp(k) = 0.0_rp
612 atmos_refstate1d_dens(k) = 0.0_rp
613 atmos_refstate1d_pott(k) = 0.0_rp
614 atmos_refstate1d_qv(k) = 0.0_rp
635 end subroutine atmos_refstate_generate_zero
640 KA, KS, KE, IA, IS, IE, ISB, IEB, JA, JS, JE, JSB, JEB, &
641 DENS, POTT, TEMP, PRES, QV, &
642 CZ, FZ, FDZ, RCDZ, REAL_CZ, REAL_FZ, REAL_PHI, AREA, &
645 statistics_horizontal_mean
650 integer,
intent(in) :: ka, ks, ke
651 integer,
intent(in) :: ia, is, ie, isb, ieb
652 integer,
intent(in) :: ja, js, je, jsb, jeb
653 real(
rp),
intent(in) :: dens (ka,ia,ja)
654 real(
rp),
intent(in) :: pott (ka,ia,ja)
655 real(
rp),
intent(in) :: temp (ka,ia,ja)
656 real(
rp),
intent(in) :: pres (ka,ia,ja)
657 real(
rp),
intent(in) :: qv (ka,ia,ja)
658 real(
rp),
intent(in) :: cz ( ka)
659 real(
rp),
intent(in) :: fz (0:ka)
660 real(
rp),
intent(in) :: fdz ( ka-1)
661 real(
rp),
intent(in) :: rcdz ( ka)
662 real(
rp),
intent(in) :: real_cz ( ka,ia,ja)
663 real(
rp),
intent(in) :: real_fz (0:ka,ia,ja)
664 real(
rp),
intent(in) :: real_phi( ka,ia,ja)
665 real(
rp),
intent(in) :: area ( ia,ja)
666 real(
dp),
intent(in) :: nowsec
668 real(
rp) :: work(ka,ia,ja)
673 if ( .not. atmos_refstate_update_flag )
return
675 if ( last_updated < 0.0_rp .or. ( nowsec - last_updated >= atmos_refstate_update_dt ) )
then
679 log_info(
"ATMOS_REFSTATE_update",*)
'update reference state'
682 cz(:), real_cz(:,:,:), temp(:,:,:), &
684 call statistics_horizontal_mean( ka, ks, ke, ia, is, ie, ja, js, je, &
685 work(:,:,:), area(:,:), &
686 atmos_refstate1d_temp(:) )
689 cz(:), real_cz(:,:,:), pres(:,:,:), &
691 call statistics_horizontal_mean( ka, ks, ke, ia, is, ie, ja, js, je, &
692 work(:,:,:), area(:,:), &
693 atmos_refstate1d_pres(:) )
696 cz(:), real_cz(:,:,:), dens(:,:,:), &
698 call statistics_horizontal_mean( ka, ks, ke, ia, is, ie, ja, js, je, &
699 work(:,:,:), area(:,:), &
700 atmos_refstate1d_dens(:) )
703 cz(:), real_cz(:,:,:), pott(:,:,:), &
705 call statistics_horizontal_mean( ka, ks, ke, ia, is, ie, ja, js, je, &
706 work(:,:,:), area(:,:), &
707 atmos_refstate1d_pott(:) )
710 cz(:), real_cz(:,:,:), qv(:,:,:), &
712 call statistics_horizontal_mean( ka, ks, ke, ia, is, ie, ja, js, je, &
713 work(:,:,:), area(:,:), &
714 atmos_refstate1d_qv(:) )
719 if( atmos_refstate1d_dens(k) <= 0.0_rp ) atmos_refstate1d_dens(k) = atmos_refstate1d_dens(k+1)
720 if( atmos_refstate1d_temp(k) <= 0.0_rp ) atmos_refstate1d_temp(k) = atmos_refstate1d_temp(k+1)
721 if( atmos_refstate1d_pres(k) <= 0.0_rp ) atmos_refstate1d_pres(k) = atmos_refstate1d_pres(k+1)
722 if( atmos_refstate1d_pott(k) <= 0.0_rp ) atmos_refstate1d_pott(k) = atmos_refstate1d_pott(k+1)
723 if( atmos_refstate1d_qv(k) <= 0.0_rp ) atmos_refstate1d_qv(k) = atmos_refstate1d_qv(k+1)
732 cz(:), fz(:), real_cz(:,:,:), real_fz(:,:,:), real_phi(:,:,:) )
734 last_updated = nowsec
738 log_info(
"ATMOS_REFSTATE_update",*)
'Generated reference state of atmosphere:'
739 log_info_cont(*)
'============================================================================='
740 log_info_cont(*)
' z*-coord.: pressure: temperature: density: pot.temp.: water vapor'
742 log_info_cont(
'(6F13.5)') cz(k), &
743 atmos_refstate1d_pres(k), &
744 atmos_refstate1d_temp(k), &
745 atmos_refstate1d_dens(k), &
746 atmos_refstate1d_pott(k), &
747 atmos_refstate1d_qv(k)
749 log_info_cont(*)
'============================================================================='
758 if ( atmos_refstate_update_dt < 0.0_rp ) atmos_refstate_update_flag = .false.
766 KA, KS, KE, IA, IS, IE, JA, JS, JE, &
767 CZ, FZ, REAL_CZ, REAL_FZ, REAL_PHI )
773 hydrostatic_buildrho_atmos => atmos_hydrostatic_buildrho_atmos, &
774 hydrostatic_buildrho_atmos_rev => atmos_hydrostatic_buildrho_atmos_rev
776 integer,
intent(in) :: KA, KS, KE
777 integer,
intent(in) :: IA, IS, IE
778 integer,
intent(in) :: JA, JS, JE
780 real(RP),
intent(in) :: CZ ( KA)
781 real(RP),
intent(in) :: FZ (0:KA)
782 real(RP),
intent(in) :: REAL_CZ ( KA,IA,JA)
783 real(RP),
intent(in) :: REAL_FZ (0:KA,IA,JA)
784 real(RP),
intent(in) :: REAL_PHI( KA,IA,JA)
786 real(RP) :: dens(KA,IA,JA)
787 real(RP) :: temp(KA,IA,JA)
788 real(RP) :: pres(KA,IA,JA)
789 real(RP) :: pott(KA,IA,JA)
790 real(RP) :: qv (KA,IA,JA)
791 real(RP) :: qc (KA,IA,JA)
792 real(RP) :: dz (KA,IA,JA)
794 real(RP) :: pott1(IA,JA)
795 real(RP) :: pott2(IA,JA)
796 real(RP) :: dens1(IA,JA)
797 real(RP) :: dens2(IA,JA)
798 real(RP) :: temp1(IA,JA)
799 real(RP) :: pres1(IA,JA)
800 real(RP) :: qv1 (IA,JA)
801 real(RP) :: qv2 (IA,JA)
802 real(RP) :: qc1 (IA,JA)
803 real(RP) :: qc2 (IA,JA)
804 real(RP) :: dz1 (IA,JA)
806 real(RP) :: dens_toa_1D
807 real(RP) :: temp_toa_1D
808 real(RP) :: pres_toa_1D
812 real(RP) :: work(KA,IA,JA)
825 work(:,i,j) = atmos_refstate1d_pott(:)
831 real_cz(:,:,:), cz(:), &
839 work(:,i,j) = atmos_refstate1d_qv(:)
845 real_cz(:,:,:), cz(:), &
851 dz_1d = fz(ke) - cz(ke)
853 call hydrostatic_buildrho_atmos( atmos_refstate1d_pott(ke), &
854 atmos_refstate1d_qv(ke), &
856 atmos_refstate1d_dens(ke), &
857 atmos_refstate1d_pott(ke), &
858 atmos_refstate1d_qv(ke), &
867 if ( .not. converged )
then
868 log_error(
"ATMOS_REFSTATE_calc3D",*)
"not converged"
876 dz(ks-1,i,j) = real_cz(ks,i,j) - real_fz(ks-1,i,j)
878 dz(k,i,j) = real_cz(k+1,i,j) - real_cz(k,i,j)
880 dz(ke,i,j) = real_fz(ke,i,j) - real_cz(ke,i,j)
888 dens(ke+1,i,j) = dens_toa_1d
889 temp(ke+1,i,j) = temp_toa_1d
890 pres(ke+1,i,j) = pres_toa_1d
891 pott(ke+1,i,j) = pott(ke,i,j)
892 qv(ke+1,i,j) = qv(ke,i,j)
900 pott(ks-1,i,j) = pott(ks,i,j)
901 qv(ks-1,i,j) = qv(ks,i,j)
914 pott1(i,j) = pott(ke,i,j)
915 qv1(i,j) = qv(ke,i,j)
916 qc1(i,j) = qc(ke,i,j)
917 dens2(i,j) = dens(ke+1,i,j)
918 pott2(i,j) = pott(ke+1,i,j)
919 qv2(i,j) = qv(ke+1,i,j)
920 qc2(i,j) = qc(ke+1,i,j)
921 dz1(i,j) = dz(ke,i,j)
925 call hydrostatic_buildrho_atmos_rev( ia, is, ie, ja, js, je, &
926 pott1(:,:), qv1(:,:), qc1(:,:), &
927 dens2(:,:), pott2(:,:), qv2(:,:), qc2(:,:), &
929 dens1(:,:), temp1(:,:), pres1(:,:) )
933 dens(ke,i,j) = dens1(i,j)
934 temp(ke,i,j) = temp1(i,j)
935 pres(ke,i,j) = pres1(i,j)
940 call hydrostatic_buildrho_atmos_rev( ka, ks, ke, ia, is, ie, ja, js, je, &
941 pott(:,:,:), qv(:,:,:), qc(:,:,:), &
944 temp(:,:,:), pres(:,:,:) )
962 call atmos_refstate_fillhalo( ka, ks, ke, ia, is, ie, ja, js, je, real_phi(:,:,:) )
969 KA, KS, KE, IA, IS, IE, JA, JS, JE, &
979 integer,
intent(in) :: KA, KS, KE
980 integer,
intent(in) :: IA, IS, IE
981 integer,
intent(in) :: JA, JS, JE
982 real(RP),
intent(in) :: REAL_PHI(KA,IA,JA)
1075 integer,
intent(in) :: KA, KS, KE
1077 real(RP),
intent(in) :: FDZ (KA-1)
1078 real(RP),
intent(in) :: RCDZ(KA)
1080 real(RP),
intent(inout) :: phi(KA)
1082 real(RP) :: dev (KA)
1083 real(RP) :: correction(KA)
1084 real(RP) :: fact(KA)
1086 integer,
parameter :: iter_max = 100
1087 real(RP) :: sig0, sig1, zerosw
1095 correction(ks-1:ks+1) = 0.0_rp
1096 correction(ke-1:ke+1) = 0.0_rp
1098 fact(ks-1:ks+1) = 0.0_rp
1099 fact(ke-1:ke+1) = 0.0_rp
1101 do iter = 1, iter_max
1105 dev(k) = phi(k) - ( fdz(k-1)*phi(k+1) + fdz(k)*phi(k-1) ) / ( fdz(k) + fdz(k-1) )
1109 sig0 = dev(k) * dev(k-1)
1110 sig1 = dev(k) * dev(k+1)
1111 if ( sig0 < -eps .and. sig1 < -eps )
then
1112 correction(k) = dev(k) &
1113 / ( 2.0_rp*rcdz(k) + ( fdz(k-1)*rcdz(k+1) + fdz(k)*rcdz(k-1) ) / ( fdz(k) + fdz(k-1) ) )
1116 correction(k) = 0.0_rp
1120 sig1 = dev(ks+1) * dev(ks+2)
1121 if ( sig1 < -eps )
then
1122 correction(ks+1) = dev(ks+1) &
1123 / ( 2.0_rp*rcdz(ks+1) + (fdz(ks)*rcdz(ks+2)+fdz(ks+1)*rcdz(ks))/(fdz(ks+1)+fdz(ks)) )
1126 correction(ks+1) = 0.0_rp
1129 sig0 = dev(ke-1) * dev(ke-2)
1130 if ( sig0 < -eps )
then
1131 correction(ke-1) = dev(ke-1) &
1132 / ( 2.0_rp*rcdz(ke-1) + (fdz(ke-2)*rcdz(ke)+fdz(ke-1)*rcdz(ke-2))/(fdz(ke-1)+fdz(ke-2)) )
1135 correction(ke-1) = 0.0_rp
1138 if ( .NOT. updated )
exit
1141 zerosw = 0.5_rp - sign( 0.5_rp, abs(correction(k))-eps )
1142 fact(k) = correction(k) / ( correction(k) - correction(k+1) - correction(k-1) + zerosw )
1146 phi(k) = phi(k) + ( correction(k+1) * fact(k+1) &
1147 - correction(k ) * fact(k ) * 2.0_rp &
1148 + correction(k-1) * fact(k-1) ) * rcdz(k)
1151 if ( iter == iter_max )
then
1152 log_info(
"ATMOS_REFSTATE_smoothing",*)
"iteration not converged!", phi