11#include "scaleFElib.h"
21 use scale_tracer,
only: &
22 qa, tracer_name, tracer_desc, tracer_unit
23 use scale_atmos_hydrometeor,
only: &
76 integer :: prog_vars_commid
81 integer :: qtrc_vars_commid
86 integer :: aux_vars_commid
102 integer :: phytends_commid
103 integer :: phytend_num_tot
106 integer,
allocatable :: diagvars2d_histid(:)
107 integer,
allocatable :: diagvars3d_histid(:)
111 logical :: check_range
112 logical :: check_total
115 procedure :: init => atmosvars_init
116 procedure :: final => atmosvars_final
117 procedure :: calc_diagnostics => atmosvars_calculatediagnostics
118 procedure :: calc_diagvar => atmosvars_calcdiagvar
119 procedure :: calc_diagvar2d => atmosvars_calcdiagvar2d
120 procedure :: history => atmosvars_history
121 procedure :: check => atmosvars_check
122 procedure :: monitor => atmosvars_monitor
123 procedure :: read_restart_file => atmosvar_read_restart_file
124 procedure :: write_restart_file => atmosvar_write_restart_file
125 procedure :: regist_physvar_manager => atmosvars_regist_physvar_manager
143 real(rp),
parameter :: progvars_check_max(
prgvar_num) = (/ 1.0_rp, 100.0_rp, 200.0_rp, 200.0_rp, 200.0_rp /)
154 variableinfo(
atmos_auxvars2d_prec_id ,
'PREC',
'surface precipitaion flux' ,
'kg/m2/s', 2,
'XY',
'precipitation_flux' ), &
181 variableinfo(
atmos_diagvars_w_id ,
'W' ,
'velocity w' ,
'm/s' , 3,
'XYZ',
'upward_air_velocity' ), &
182 variableinfo(
atmos_diagvars_t_id ,
'T' ,
'temperature' ,
'K' , 3,
'XYZ',
'air_temperature' ), &
186 variableinfo(
atmos_diagvars_rh_id ,
'RH',
'relative humidity(liq)',
'%', 3,
'XYZ',
'relative_humidity' ), &
199 variableinfo(
atmos_diagvars_rain_id,
'RAIN',
'surface rain flux' ,
'kg/m2/s', 2,
'XY',
'rainfall_flux' ), &
200 variableinfo(
atmos_diagvars_snow_id,
'SNOW',
'surface snow flux' ,
'kg/m2/s', 2,
'XY',
'snowfall_flux' ) /
208 private :: vars_calc_diagnosevar_lc
209 private :: vars_calc_diagnosevar2d_lc
213 integer,
private,
parameter :: im_qdry = 1
214 integer,
private,
parameter :: im_qtot = 2
215 integer,
private,
parameter :: im_engt = 3
216 integer,
private,
parameter :: im_engp = 4
217 integer,
private,
parameter :: im_engk = 5
218 integer,
private,
parameter :: im_engi = 6
219 integer,
private,
parameter :: dvm_nmax = 6
220 integer,
private :: dv_monit_id(dvm_nmax)
225 subroutine atmosvars_init( this, atm_mesh )
226 use scale_atmos_hydrometeor,
only: &
227 atmos_hydrometeor_dry
229 monitor_reg => file_monitor_meshfield_reg
236 class(
atmosvars),
target,
intent(inout) :: this
237 class(
atmosmesh),
target,
intent(inout) :: atm_mesh
242 logical :: reg_file_hist
248 logical :: check_range = .false.
249 logical :: check_total = .false.
251 namelist / param_atmos_vars / &
255 character(len=H_LONG) :: in_basename =
''
256 logical :: in_postfix_timelabel = .false.
257 character(len=H_LONG) :: out_basename =
''
258 logical :: out_postfix_timelabel = .true.
259 character(len=H_MID) :: out_title =
''
260 character(len=H_SHORT) :: out_dtype =
'DEFAULT'
262 namelist / param_atmos_vars_restart / &
264 in_postfix_timelabel, &
266 out_postfix_timelabel, &
271 logical :: is_specified
279 log_info(
'AtmosVars_Init',*)
283 read(io_fid_conf,nml=param_atmos_vars,iostat=ierr)
285 log_info(
"ATMOS_vars_setup",*)
'Not found namelist. Default used.'
286 elseif( ierr > 0 )
then
287 log_error(
"ATMOS_vars_setup",*)
'Invalid names in namelist PARAM_ATMOS_VARS. Check!'
290 log_nml(param_atmos_vars)
293 this%mesh => atm_mesh
294 mesh3d => atm_mesh%ptr_mesh
295 call mesh3d%GetMesh2D( mesh2d )
300 call this%PROGVARS_manager%Init()
301 call this%QTRCVARS_manager%Init()
302 call this%AUXVARS_manager%Init()
303 call this%PHYTENDS_manager%Init()
306 allocate( this%QTRC_VARS(0:qa) )
309 this%PHYTEND_NUM_TOT = phytend_num1 + max(1,qa)
310 allocate( this%PHY_TEND(this%PHYTEND_NUM_TOT) )
313 this%PROG_VARS, this%QTRC_VARS, this%AUX_VARS, this%PHY_TEND, &
314 this%PROGVARS_manager, this%QTRCVARS_manager, this%AUXVARS_manager, this%PHYTENDS_manager, &
315 this%PHYTEND_NUM_TOT, mesh3d, &
320 call atm_mesh%Create_communicator( &
322 this%PROGVARS_manager, &
324 this%PROG_VARS_commID )
326 if ( .not. atmos_hydrometeor_dry )
then
327 call atm_mesh%Create_communicator( &
329 this%QTRCVARS_manager, &
330 this%QTRC_VARS(1:qa), &
331 this%QTRC_VARS_commID )
334 call atm_mesh%Create_communicator( &
336 this%AUXVARS_manager, &
338 this%AUX_VARS_commID )
343 log_info(
"ATMOS_vars_setup",*)
'List of prognostic variables (ATMOS) '
344 log_info_cont(
'(1x,A,A24,A,A48,A,A12,A)') &
345 ' |',
'VARNAME ',
'|', &
346 'DESCRIPTION ',
'[',
'UNIT ',
']'
348 log_info_cont(
'(1x,A,I3,A,A24,A,A48,A,A12,A)') &
349 'NO.',iv,
'|',prgvar_info(iv)%NAME,
'|', prgvar_info(iv)%DESC,
'[', prgvar_info(iv)%UNIT,
']'
352 log_info_cont(
'(1x,A,I3,A,A24,A,A48,A,A12,A)') &
353 'NO.',
prgvar_num+iv,
'|',tracer_name(iv),
'|', tracer_desc(iv),
'[', tracer_unit(iv),
']'
359 call this%AUXVARS2D_manager%Init()
362 reg_file_hist = .true.
364 call this%AUXVARS2D_manager%Regist( &
366 this%AUX_VARS2D(iv), &
367 reg_file_hist, fill_zero=.true. )
374 call diagvar_manager%Init()
377 reg_file_hist = .true.
379 call diagvar_manager%Regist( &
381 diag_vars3d(iv), reg_file_hist )
383 this%DIAGVARS3D_HISTID(iv) = diag_vars3d(iv)%hist_id
385 call diagvar_manager%Final()
388 call diagvar_manager%Init()
391 reg_file_hist = .true.
393 call diagvar_manager%Regist( &
395 diag_vars2d(iv), reg_file_hist )
397 this%DIAGVARS2D_HISTID(iv) = diag_vars2d(iv)%hist_id
399 call diagvar_manager%Final()
403 is_specified = .true.
406 read(io_fid_conf,nml=param_atmos_vars_restart,iostat=ierr)
408 log_info(
"AtmosVars_Init",*)
'Not found namelist PARAM_ATMOS_VARS_RESTART. Default used.'
409 is_specified = .false.
410 elseif( ierr > 0 )
then
411 log_error(
"AtmosVars_Init",*)
'Not appropriate names in namelist PARAM_ATMOS_VARS_RESTART. Check!'
414 log_nml(param_atmos_vars_restart)
416 if (is_specified)
then
417 call atm_mesh%Setup_restartfile( this%restart_file, &
418 in_basename, in_postfix_timelabel, &
419 out_basename, out_postfix_timelabel, out_dtype, out_title, &
422 call atm_mesh%Setup_restartfile( this%restart_file, &
428 call monitor_reg(
'QTOT',
'water mass',
'kg', &
429 dv_monit_id(im_qtot), &
430 dim_type=
'ATM3D', is_tendency=.false. )
432 call monitor_reg(
'ENGT',
'total energy',
'J', &
433 dv_monit_id(im_engt), &
434 dim_type=
'ATM3D', is_tendency=.false. )
435 call monitor_reg(
'ENGP',
'potential energy',
'J', &
436 dv_monit_id(im_engp), &
437 dim_type=
'ATM3D', is_tendency=.false. )
438 call monitor_reg(
'ENGK',
'kinetic energy',
'J', &
439 dv_monit_id(im_engk), &
440 dim_type=
'ATM3D', is_tendency=.false. )
441 call monitor_reg(
'ENGI',
'internal energy',
'J', &
442 dv_monit_id(im_engi), &
443 dim_type=
'ATM3D', is_tendency=.false. )
448 this%check_range = check_range
449 this%check_total = check_total
450 log_info(
"ATMOS_vars_setup",*)
'Check value range of variables? : ', check_range
451 log_info(
"ATMOS_vars_setup",*)
'Check total value of variables? : ', check_total
454 end subroutine atmosvars_init
457 subroutine atmosvars_final( this )
463 log_info(
'AtmosVars_Final',*)
465 call this%restart_file%Final()
467 call this%PROGVARS_manager%Final()
468 deallocate( this%PROG_VARS )
470 call this%QTRCVARS_manager%Final()
471 deallocate( this%QTRC_VARS )
473 call this%AUXVARS_manager%Final()
474 deallocate( this%AUX_VARS )
476 call this%AUXVARS2D_manager%Final()
477 deallocate( this%AUX_VARS2D )
479 call this%PHYTENDS_manager%Final()
480 deallocate( this%PHY_TEND )
482 deallocate( this%DIAGVARS3D_HISTID )
485 end subroutine atmosvars_final
488 subroutine atmosvars_regist_physvar_manager( this, &
489 mp_AUXVARS2D_manager )
492 class(
atmosvars),
target,
intent(inout) :: this
496 this%ptr_MP_AUXVARS2D_manager => mp_auxvars2d_manager
499 end subroutine atmosvars_regist_physvar_manager
502 subroutine atmosvars_history( this )
517 mesh3d => this%PROG_VARS(1)%mesh
518 call mesh3d%GetMesh2D(mesh2d)
521 hst_id = this%PROG_VARS(v)%hist_id
526 hst_id = this%QTRC_VARS(v)%hist_id
530 call this%Calc_diagnostics()
533 hst_id = this%AUX_VARS(v)%hist_id
537 hst_id = this%AUX_VARS2D(v)%hist_id
541 do v = 1, this%PHYTEND_NUM_TOT
542 hst_id = this%PHY_TEND(v)%hist_id
549 call tmp_field3d%Init(
"tmp_field",
"", mesh3d)
551 hst_id = this%DIAGVARS3D_HISTID(v)
552 if ( hst_id > 0 )
then
557 call tmp_field3d%Final()
560 call tmp_field2d%Init(
"tmp_field",
"", mesh2d)
562 hst_id = this%DIAGVARS2D_HISTID(v)
563 if ( hst_id > 0 )
then
568 call tmp_field2d%Final()
571 end subroutine atmosvars_history
574 subroutine atmosvar_read_restart_file( this, atmos_mesh, dyncore )
584 class(
atmosvars),
intent(inout),
target :: this
585 class(
atmosmesh),
intent(in) :: atmos_mesh
598 log_info(
"ATMOSVar_read_restart_file",*)
'Open restart file (ATMOS) '
601 call this%restart_file%Open()
606 call this%restart_file%Read_var( dimtype_xyz, this%PROG_VARS(iv)%varname, &
610 call this%restart_file%Read_var( dimtype_xyz, this%AUX_VARS(iv)%varname, &
614 call this%restart_file%Read_var( dimtype_xyz, this%QTRC_VARS(iv)%varname, &
619 log_info(
"ATMOSVar_read_restart_file",*)
'Close restart file (ATMOS) '
620 call this%restart_file%Close()
623 call vars_calc_specific_heat( this )
626 this%PROGVARS_manager, this%AUXVARS_manager )
630 mesh3d => phyd_ref%mesh
631 do domid=1, mesh3d%LOCAL_MESH_NUM
632 lcmesh3d => mesh3d%lcmesh_list(domid)
634 do ke=lcmesh3d%NeS, lcmesh3d%NeE
635 phyd_ref%local(domid)%val(:,ke) = 0.0_rp
640 call this%Check( force = .true. )
643 call this%Calc_diagnostics()
646 call this%AUXVARS_manager%MeshFieldComm_Exchange()
650 mesh3d, atmos_mesh%element3D_operation )
653 end subroutine atmosvar_read_restart_file
656 subroutine atmosvar_write_restart_file( this )
666 integer :: iv, rf_vid
670 log_info(
"ATMOSVar_write_restart_file",*)
'Create restart file (ATMOS) '
673 call this%Check( force = .true. )
676 call this%restart_file%Create()
677 call prc_mpibarrier()
685 call this%restart_file%Def_var( this%PROG_VARS(iv), &
686 prgvar_info(iv)%DESC, rf_vid, dimtype_xyz )
690 call this%restart_file%Def_var( this%AUX_VARS(iv), &
691 auxvar_info(iv)%DESC, rf_vid, dimtype_xyz )
695 call this%restart_file%Def_var( this%QTRC_VARS(iv), &
696 tracer_desc(iv), rf_vid, dimtype_xyz )
699 call this%restart_file%End_def()
704 call this%restart_file%Write_var(rf_vid, this%PROG_VARS(iv) )
708 call this%restart_file%Write_var(rf_vid, this%AUX_VARS(iv) )
712 call this%restart_file%Write_var(rf_vid, this%QTRC_VARS(iv) )
716 log_info(
"ATMOSVar_write_restart_file",*)
'Close restart file (ATMOS) '
717 call this%restart_file%Close()
720 end subroutine atmosvar_write_restart_file
723 subroutine atmosvars_check( this, force )
731 logical,
intent(in),
optional :: force
742 character(len=H_MID) :: varname
748 if (
present(force) )
then
751 check = this%check_range
756 if ( iv == prgvar_therm_id ) cycle
758 mesh3d => this%PROG_VARS(iv)%mesh
759 do n=1, mesh3d%LOCAL_MESH_NUM
760 lcmesh => mesh3d%lcmesh_list(n)
761 elem => lcmesh%refElem
762 call this%PROG_VARS(iv)%GetLocalMeshField(n, lcfield)
763 write(varname,
'(a,i3.3,a)') this%PROG_VARS(iv)%varname//
'(domID=', n,
')'
764 call valcheck( elem%Np, 1, elem%Np, lcmesh%NeA, lcmesh%NeS, lcmesh%NeE, lcfield%val(:,:), &
769 mesh3d => this%PROG_VARS(1)%mesh
773 call atmosvars_calcdiagvar( this, vel_fields(iv)%varname, vel_fields(iv) )
777 call vel_fields(iv)%Final()
781 if (
present(force) )
then
784 check = this%check_total
787 mesh3d => this%PROG_VARS(1)%mesh
788 call work%Init(
"tmp",
"", mesh3d)
793 end subroutine atmosvars_check
796 subroutine atmosvars_monitor( this )
812 mesh3d => this%PROG_VARS(1)%mesh
813 call work%Init(
"tmp",
"", mesh3d)
820 if ( this%QTRC_VARS(iv)%monitor_id > 0 )
then
821 do n=1, mesh3d%LOCAL_MESH_NUM
822 lcmesh => mesh3d%lcmesh_list(n)
824 do ke=lcmesh%NeS, lcmesh%NeE
825 work%local(n)%val(:,ke) = ( this%AUX_VARS(auxvar_denshydro_id)%local(n)%val(:,ke) &
826 + this%PROG_VARS(prgvar_ddens_id )%local(n)%val(:,ke) &
827 ) * this%QTRC_VARS(iv)%local(n)%val(:,ke)
833 if ( dv_monit_id(im_qtot) > 0 )
then
834 do n=1, mesh3d%LOCAL_MESH_NUM
835 lcmesh => mesh3d%lcmesh_list(n)
837 do ke=lcmesh%NeS, lcmesh%NeE
838 work%local(n)%val(:,ke) = ( this%AUX_VARS(auxvar_denshydro_id)%local(n)%val(:,ke) &
839 + this%PROG_VARS(prgvar_ddens_id )%local(n)%val(:,ke) &
840 ) * ( 1.0_rp - this%AUX_VARS(auxvar_qdry_id)%local(n)%val(:,ke) )
848 if ( dv_monit_id(im_engt) > 0 )
then
849 call atmosvars_calcdiagvar( this,
'ENGT', work )
852 if ( dv_monit_id(im_engp) > 0 )
then
853 call atmosvars_calcdiagvar( this,
'ENGP', work )
856 if ( dv_monit_id(im_engk) > 0 )
then
857 call atmosvars_calcdiagvar( this,
'ENGK', work )
860 if ( dv_monit_id(im_engi) > 0 )
then
861 call atmosvars_calcdiagvar( this,
'ENGI', work )
868 end subroutine atmosvars_monitor
875 var, DENS_hyd, PRES_hyd, lcmesh3D )
879 integer,
intent(in) :: domid
883 integer,
intent(in) :: varid
886 class(
localmesh3d),
pointer,
intent(out),
optional :: lcmesh3d
893 call prgvars_list%Get(varid, field)
894 call field%GetLocalMeshField(domid, var)
896 if (
present(dens_hyd))
then
897 call auxvars_list%Get(auxvar_denshydro_id, field)
898 call field%GetLocalMeshField(domid, dens_hyd)
900 if (
present(pres_hyd))
then
901 call auxvars_list%Get(auxvar_preshydro_id, field)
902 call field%GetLocalMeshField(domid, pres_hyd)
905 if (
present(lcmesh3d))
then
906 call mesh%GetLocalMesh( domid, lcmesh )
911 if (
present(lcmesh3d)) lcmesh3d => lcmesh
920 DDENS, MOMX, MOMY, MOMZ, THERM, &
921 DENS_hyd, PRES_hyd, Rtot, CVtot, CPtot, &
924 integer,
intent(in) :: domid
931 class(
localmesh3d),
pointer,
intent(out),
optional :: lcmesh3d
938 call prgvars_list%Get(prgvar_ddens_id, field)
939 call field%GetLocalMeshField(domid, ddens)
941 call prgvars_list%Get(prgvar_momx_id, field)
942 call field%GetLocalMeshField(domid, momx)
944 call prgvars_list%Get(prgvar_momy_id, field)
945 call field%GetLocalMeshField(domid, momy)
947 call prgvars_list%Get(prgvar_momz_id, field)
948 call field%GetLocalMeshField(domid, momz)
950 call prgvars_list%Get(prgvar_therm_id, field)
951 call field%GetLocalMeshField(domid, therm)
954 call auxvars_list%Get(auxvar_denshydro_id, field)
955 call field%GetLocalMeshField(domid, dens_hyd)
957 call auxvars_list%Get(auxvar_preshydro_id, field)
958 call field%GetLocalMeshField(domid, pres_hyd)
960 call auxvars_list%Get(auxvar_rtot_id, field)
961 call field%GetLocalMeshField(domid, rtot)
963 call auxvars_list%Get(auxvar_cvtot_id, field)
964 call field%GetLocalMeshField(domid, cvtot)
966 call auxvars_list%Get(auxvar_cptot_id, field)
967 call field%GetLocalMeshField(domid, cptot)
971 if (
present(lcmesh3d) )
then
972 call mesh%GetLocalMesh( domid, lcmesh )
977 if (
present(lcmesh3d)) lcmesh3d => lcmesh
986 PREC, PREC_ENGI, lcmesh2D )
989 integer,
intent(in) :: domid
993 class(
localmesh2d),
pointer,
intent(out),
optional :: lcmesh2d
1001 call field%GetLocalMeshField(domid, prec)
1004 call field%GetLocalMeshField(domid, prec_engi)
1006 if (
present(lcmesh2d))
then
1007 call mesh%GetLocalMesh( domid, lcmesh )
1012 if (
present(lcmesh2d)) lcmesh2d => lcmesh
1025 integer,
intent(in) :: domid
1026 class(
meshbase),
intent(in) :: mesh
1028 integer,
intent(in) :: varid
1030 class(
localmesh3d),
pointer,
intent(out),
optional :: lcmesh3d
1037 call trcvars_list%Get(varid, field)
1038 call field%GetLocalMeshField(domid, var)
1040 if (
present(lcmesh3d))
then
1041 call mesh%GetLocalMesh( domid, lcmesh )
1046 if (
present(lcmesh3d)) lcmesh3d => lcmesh
1055 var, var_tp, lcmesh3D )
1057 use scale_atmos_hydrometeor,
only: &
1058 atmos_hydrometeor_dry, &
1061 integer,
intent(in) :: domid
1062 class(
meshbase),
intent(in) :: mesh
1067 class(
localmesh3d),
pointer,
intent(out),
optional :: lcmesh3d
1072 integer :: iq, tend_iq
1076 if ( atmos_hydrometeor_dry )
then
1077 iq =0; tend_iq = phytend_num1+1
1079 iq = i_qv; tend_iq = phytend_num1 + i_qv
1082 call trcvars_list%Get(iq, field)
1083 call field%GetLocalMeshField(domid, var)
1085 call forcing_list%Get(tend_iq, field)
1086 call field%GetLocalMeshField(domid, var_tp)
1088 if (
present(lcmesh3d))
then
1089 call mesh%GetLocalMesh( domid, lcmesh )
1094 if (
present(lcmesh3d)) lcmesh3d => lcmesh
1104 var_list, lcmesh3D )
1107 integer,
intent(in) :: domid
1108 class(
meshbase),
intent(in) :: mesh
1110 integer,
intent(in) :: varid_s
1112 class(
localmesh3d),
pointer,
intent(out),
optional :: lcmesh3d
1121 do iq = varid_s, varid_s +
size(var_list) - 1
1122 call trcvars_list%Get(iq, field)
1123 call field%GetLocalMeshField(domid, var_list(iq-varid_s+1)%ptr)
1125 if (
present(lcmesh3d))
then
1126 call mesh%GetLocalMesh( domid, lcmesh )
1131 if (
present(lcmesh3d)) lcmesh3d => lcmesh
1144 integer,
intent(in) :: domid
1145 class(
meshbase),
intent(in) :: mesh
1148 class(
localmesh3d),
pointer,
intent(out),
optional :: lcmesh3d
1155 call phyauxvars_list%Get(auxvar_pres_id, field)
1156 call field%GetLocalMeshField(domid, pres)
1158 call phyauxvars_list%Get(auxvar_pt_id, field)
1159 call field%GetLocalMeshField(domid, pt)
1163 if (
present(lcmesh3d))
then
1164 call mesh%GetLocalMesh( domid, lcmesh )
1169 if (
present(lcmesh3d)) lcmesh3d => lcmesh
1178 DENS_tp, MOMX_tp, MOMY_tp, MOMZ_tp, RHOT_tp, RHOH_p, &
1183 integer,
intent(in) :: domid
1184 class(
meshbase),
intent(in) :: mesh
1186 class(
localmeshfieldbase),
pointer,
intent(out) :: dens_tp, momx_tp, momy_tp, momz_tp, rhot_tp
1189 class(
localmesh3d),
pointer,
intent(out),
optional :: lcmesh3d
1198 call phytends_list%Get(phytend_dens_id, field)
1199 call field%GetLocalMeshField(domid, dens_tp)
1201 call phytends_list%Get(phytend_momx_id, field)
1202 call field%GetLocalMeshField(domid, momx_tp)
1204 call phytends_list%Get(phytend_momy_id, field)
1205 call field%GetLocalMeshField(domid, momy_tp)
1207 call phytends_list%Get(phytend_momz_id, field)
1208 call field%GetLocalMeshField(domid, momz_tp)
1210 call phytends_list%Get(phytend_rhot_id, field)
1211 call field%GetLocalMeshField(domid, rhot_tp)
1213 call phytends_list%Get(phytend_rhoh_id, field)
1214 call field%GetLocalMeshField(domid, rhoh_p)
1216 if (
present(rhoq_tp) )
then
1218 call phytends_list%Get(phytend_num1+iq, field)
1219 call field%GetLocalMeshField(domid, rhoq_tp(iq)%ptr)
1224 if (
present(lcmesh3d) )
then
1225 call mesh%GetLocalMesh( domid, lcmesh )
1230 if (
present(lcmesh3d) ) lcmesh3d => lcmesh
1243 integer,
intent(in) :: domid
1244 class(
meshbase),
intent(in) :: mesh
1246 integer,
intent(in) :: qtrcid
1253 call phytends_list%Get(phytend_num1 + qtrcid, field)
1254 call field%GetLocalMeshField(domid, rhoq_tp)
1262 subroutine atmosvars_calculatediagnostics( this )
1263 use scale_const,
only: &
1264 rdry => const_rdry, &
1265 cpdry => const_cpdry, &
1266 cvdry => const_cvdry, &
1267 pres00 => const_pre00
1268 use scale_tracer,
only: &
1269 tracer_mass, tracer_r, tracer_cv, tracer_cp
1270 use scale_atmos_thermodyn,
only: &
1271 atmos_thermodyn_specific_heat
1273 class(
atmosvars),
intent(inout),
target :: this
1287 call vars_calc_specific_heat( this )
1290 do varid=auxvar_denshydro_id+1, auxvar_pt_id
1291 field => this%AUX_VARS(varid)
1292 do n=1, field%mesh%LOCAL_MESH_NUM
1294 field%mesh, this%QTRCVARS_manager, &
1297 elem3d => lcmesh3d%refElem3D
1299 call vars_calc_diagnosevar_lc( &
1300 field%varname, field%local(n)%val, &
1301 this%PROG_VARS(prgvar_ddens_id)%local(n)%val, &
1302 this%PROG_VARS(prgvar_momx_id)%local(n)%val, &
1303 this%PROG_VARS(prgvar_momy_id)%local(n)%val, &
1304 this%PROG_VARS(prgvar_momz_id)%local(n)%val, &
1305 this%AUX_VARS(auxvar_pres_id)%local(n)%val, &
1306 this%AUX_VARS(auxvar_qdry_id)%local(n)%val, &
1308 this%AUX_VARS(auxvar_denshydro_id)%local(n)%val, &
1309 this%AUX_VARS(auxvar_preshydro_id)%local(n)%val, &
1310 this%AUX_VARS(auxvar_rtot_id )%local(n)%val, &
1311 this%AUX_VARS(auxvar_cvtot_id)%local(n)%val, &
1312 this%AUX_VARS(auxvar_cptot_id)%local(n)%val, &
1313 lcmesh3d, lcmesh3d%refElem3D )
1318 end subroutine atmosvars_calculatediagnostics
1321 subroutine atmosvars_calcdiagvar( this, field_name, field_work )
1322 use scale_const,
only: &
1323 rdry => const_rdry, &
1324 cpdry => const_cpdry, &
1325 cvdry => const_cvdry, &
1326 pres00 => const_pre00
1327 use scale_tracer,
only: &
1328 tracer_mass, tracer_r, tracer_cv, tracer_cp
1329 use scale_atmos_thermodyn,
only: &
1330 atmos_thermodyn_specific_heat
1334 character(*),
intent(in) :: field_name
1351 if ( field_name ==
'Umet' )
then
1352 is_uvmet = .true.; uvmet_i = 1
1353 else if ( field_name ==
'Vmet' )
then
1354 is_uvmet = .true.; uvmet_i = 2
1357 field_work%varname = field_name
1359 do n=1, field_work%mesh%LOCAL_MESH_NUM
1361 field_work%mesh, this%QTRCVARS_manager, &
1364 if ( .not. is_uvmet )
then
1365 call vars_calc_diagnosevar_lc( field_name, field_work%local(n)%val, &
1366 this%PROG_VARS(prgvar_ddens_id)%local(n)%val, &
1367 this%PROG_VARS(prgvar_momx_id)%local(n)%val, &
1368 this%PROG_VARS(prgvar_momy_id)%local(n)%val, &
1369 this%PROG_VARS(prgvar_momz_id)%local(n)%val, &
1370 this%AUX_VARS(auxvar_pres_id)%local(n)%val, &
1371 this%AUX_VARS(auxvar_qdry_id)%local(n)%val, &
1373 this%AUX_VARS(auxvar_denshydro_id)%local(n)%val, &
1374 this%AUX_VARS(auxvar_preshydro_id)%local(n)%val, &
1375 this%AUX_VARS(auxvar_rtot_id )%local(n)%val, &
1376 this%AUX_VARS(auxvar_cvtot_id)%local(n)%val, &
1377 this%AUX_VARS(auxvar_cptot_id)%local(n)%val, &
1378 lcmesh3d, lcmesh3d%refElem3D )
1380 call field_work_uvmet(1)%Init(
'Umet',
'', field_work%mesh )
1381 call field_work_uvmet(2)%Init(
'Vmet',
'', field_work%mesh )
1382 call this%mesh%Calc_UVmet( &
1383 this%PROG_VARS(prgvar_momx_id), this%PROG_VARS(prgvar_momy_id), &
1384 field_work_uvmet(1), field_work_uvmet(2) )
1386 do ke=lcmesh3d%NeS, lcmesh3d%NeE
1387 field_work%local(n)%val(:,ke) = field_work_uvmet(uvmet_i)%local(n)%val(:,ke) &
1388 / ( this%AUX_VARS (auxvar_denshydro_id)%local(n)%val(:,ke) &
1389 + this%PROG_VARS(prgvar_ddens_id )%local(n)%val(:,ke) )
1391 call field_work_uvmet(1)%Final()
1392 call field_work_uvmet(2)%Final()
1397 end subroutine atmosvars_calcdiagvar
1400 subroutine atmosvars_calcdiagvar2d( this, field_name, field_work )
1403 character(*),
intent(in) :: field_name
1404 type(
meshfield2d),
intent(inout),
target :: field_work
1412 field_work%varname = field_name
1414 do n=1, field_work%mesh%LOCAL_MESH_NUM
1415 lcmesh2d => field_work%mesh%lcmesh_list(n)
1416 call vars_calc_diagnosevar2d_lc( field_name, field_work%local(n)%val, &
1417 this%ptr_MP_AUXVARS2D_manager, &
1418 field_work%mesh, lcmesh2d, lcmesh2d%refElem2D )
1422 end subroutine atmosvars_calcdiagvar2d
1427 subroutine vars_calc_diagnosevar_lc( field_name, var_out, &
1428 DDENS_, MOMX_, MOMY_, MOMZ_, PRES_, QDRY_, QTRC, &
1429 DENS_hyd, PRES_hyd, Rtot, CVtot, CPTot, &
1432 use scale_const,
only: &
1433 grav => const_grav, &
1434 rdry => const_rdry, &
1435 rvap => const_rvap, &
1436 cpdry => const_cpdry, &
1437 cvdry => const_cvdry, &
1438 pres00 => const_pre00
1439 use scale_tracer,
only: &
1441 tracer_cv, tracer_engi0
1442 use scale_atmos_saturation,
only: &
1443 atmos_saturation_psat_liq
1448 character(*),
intent(in) :: field_name
1449 real(rp),
intent(out) :: var_out(elem%np,lcmesh%nea)
1450 real(rp),
intent(in) :: ddens_(elem%np,lcmesh%nea)
1451 real(rp),
intent(in) :: momx_(elem%np,lcmesh%nea)
1452 real(rp),
intent(in) :: momy_(elem%np,lcmesh%nea)
1453 real(rp),
intent(in) :: momz_(elem%np,lcmesh%nea)
1454 real(rp),
intent(in) :: pres_(elem%np,lcmesh%nea)
1455 real(rp),
intent(in) :: qdry_(elem%np,lcmesh%nea)
1457 real(rp),
intent(in) :: dens_hyd(elem%np,lcmesh%nea)
1458 real(rp),
intent(in) :: pres_hyd(elem%np,lcmesh%nea)
1459 real(rp),
intent(in) :: rtot (elem%np,lcmesh%nea)
1460 real(rp),
intent(in) :: cvtot(elem%np,lcmesh%nea)
1461 real(rp),
intent(in) :: cptot(elem%np,lcmesh%nea)
1465 real(rp) :: dens(elem%np), temp(elem%np)
1466 real(rp) :: mom_u1(elem%np), mom_u2(elem%np), g_11(elem%np), g_12(elem%np), g_22(elem%np)
1467 real(rp) :: psat(elem%np)
1472 select case(trim(field_name))
1476 var_out(:,ke) = ddens_(:,ke) + dens_hyd(:,ke)
1482 dens(:) = ddens_(:,ke) + dens_hyd(:,ke)
1483 var_out(:,ke) = momx_(:,ke) / dens(:)
1489 dens(:) = ddens_(:,ke) + dens_hyd(:,ke)
1490 var_out(:,ke) = momy_(:,ke) / dens(:)
1496 dens(:) = ddens_(:,ke) + dens_hyd(:,ke)
1497 var_out(:,ke) = momz_(:,ke) / dens(:)
1504 var_out(:,ke) = pres_(:,ke) - pres_hyd(:,ke)
1510 var_out(:,ke) = pres_(:,ke) / (rtot(:,ke) * (ddens_(:,ke) + dens_hyd(:,ke)) )
1516 var_out(:,ke) = pres_(:,ke) / ( rtot(:,ke) * (ddens_(:,ke) + dens_hyd(:,ke)) ) &
1517 - pres_hyd(:,ke) / ( rdry * dens_hyd(:,ke) )
1523 dens(:) = ddens_(:,ke) + dens_hyd(:,ke)
1524 var_out(:,ke) = pres_(:,ke) / (rtot(:,ke) * dens(:) ) * ( pres00 / pres_(:,ke) )**( rtot(:,ke) / cptot(:,ke) )
1530 dens(:) = ddens_(:,ke) + dens_hyd(:,ke)
1531 var_out(:,ke) = pres_(:,ke) / (rtot(:,ke) * dens(:) ) * ( pres00 / pres_(:,ke) )**( rtot(:,ke) / cptot(:,ke) ) &
1532 - pres00/rdry * (pres_hyd(:,ke)/pres00)**(cvdry/cpdry) / dens_hyd(:,ke)
1536 if ( atmos_hydrometeor_dry )
then
1537 var_out(:,ke) = 0.0_rp
1539 call tracer_inq_id(
"QV", iq_qv )
1543 temp(:) = pres_(:,ke) / (rtot(:,ke) * (ddens_(:,ke) + dens_hyd(:,ke)) )
1545 call atmos_saturation_psat_liq( &
1546 elem%Np, 1, elem%Np, temp(:), &
1549 var_out(:,ke) = ( ddens_(:,ke) + dens_hyd(:,ke) ) * qtrc(iq_qv)%ptr%val(:,ke) &
1550 / psat(:) * rvap * temp(:) * 100.0_rp
1557 ke2d = lcmesh%EMap3Dto2D(ke)
1559 dens(:) = ddens_(:,ke) + dens_hyd(:,ke)
1560 g_11(:) = lcmesh%G_ij(elem%IndexH2Dto3D,ke2d,1,1)
1561 g_12(:) = lcmesh%G_ij(elem%IndexH2Dto3D,ke2d,1,2)
1562 g_22(:) = lcmesh%G_ij(elem%IndexH2Dto3D,ke2d,2,2)
1564 mom_u1(:) = g_11(:) * momx_(:,ke) + g_12(:) * momy_(:,ke)
1565 mom_u2(:) = g_12(:) * momx_(:,ke) + g_22(:) * momy_(:,ke)
1567 var_out(:,ke) = 0.5_rp * ( momx_(:,ke) * mom_u1(:) + momy_(:,ke) * mom_u2(:) + momz_(:,ke)**2 ) / dens(:)
1573 dens(:) = ddens_(:,ke) + dens_hyd(:,ke)
1574 var_out(:,ke) = dens(:) * grav * lcmesh%zlev(:,ke)
1580 dens(:) = ddens_(:,ke) + dens_hyd(:,ke)
1581 var_out(:,ke) = qdry_(:,ke) * pres_(:,ke) / rtot(:,ke) * cvdry
1583 var_out(:,ke) = var_out(:,ke) &
1584 + qtrc(iq)%ptr%val(:,ke) * ( pres_(:,ke) / rtot(:,ke) * tracer_cv(iq) + dens(:) * tracer_engi0(iq) )
1591 ke2d = lcmesh%EMap3Dto2D(ke)
1593 dens(:) = ddens_(:,ke) + dens_hyd(:,ke)
1595 g_11(:) = lcmesh%G_ij(elem%IndexH2Dto3D,ke2d,1,1)
1596 g_12(:) = lcmesh%G_ij(elem%IndexH2Dto3D,ke2d,1,2)
1597 g_22(:) = lcmesh%G_ij(elem%IndexH2Dto3D,ke2d,2,2)
1598 mom_u1(:) = g_11(:) * momx_(:,ke) + g_12(:) * momy_(:,ke)
1599 mom_u2(:) = g_12(:) * momx_(:,ke) + g_22(:) * momy_(:,ke)
1602 var_out(:,ke) = qdry_(:,ke) * pres_(:,ke) / rtot(:,ke) * cvdry
1604 var_out(:,ke) = var_out(:,ke) &
1605 + qtrc(iq)%ptr%val(:,ke) * ( pres_(:,ke) / rtot(:,ke) * tracer_cv(iq) + dens(:) * tracer_engi0(iq) )
1609 0.5_rp * ( momx_(:,ke) * mom_u1(:) + momy_(:,ke) * mom_u2(:) + momz_(:,ke)**2 ) / dens(:) &
1611 + dens(:) * grav * lcmesh%pos_en(:,ke,3)
1615 log_error(
"AtmosVars_calc_diagnoseVar_lc",*)
'The name of diagnostic variable is not suported. Check!', field_name
1621 end subroutine vars_calc_diagnosevar_lc
1624 subroutine vars_calc_diagnosevar2d_lc( field_name, & ! (in)
1626 mp_auxvars2d, mesh2d, lcmesh, elem )
1634 character(*),
intent(in) :: field_name
1635 real(rp),
intent(out) :: var_out(elem%np,lcmesh%nea)
1644 select case(trim(field_name))
1645 case(
'RAIN',
'SNOW')
1647 lcmesh%lcdomID, mesh2d, mp_auxvars2d, &
1648 sflx_rain_mp, sflx_snow_mp, sflx_engi_mp )
1651 select case(trim(field_name))
1654 do ke=lcmesh%NeS, lcmesh%NeE
1655 var_out(:,ke) = sflx_rain_mp%val(:,ke)
1659 do ke=lcmesh%NeS, lcmesh%NeE
1660 var_out(:,ke) = sflx_snow_mp%val(:,ke)
1663 log_error(
"AtmosVars_calc_diagnoseVar2D_lc",*)
'The name of diagnostic variable is not suported. Check!', field_name
1668 end subroutine vars_calc_diagnosevar2d_lc
1671 subroutine vars_calc_specific_heat( this )
1672 use scale_const,
only: &
1673 rdry => const_rdry, &
1674 cpdry => const_cpdry, &
1675 cvdry => const_cvdry, &
1676 pres00 => const_pre00
1677 use scale_tracer,
only: &
1678 tracer_mass, tracer_r, tracer_cv, tracer_cp
1679 use scale_atmos_thermodyn,
only: &
1680 atmos_thermodyn_specific_heat
1682 class(
atmosvars),
intent(inout),
target :: this
1692 real(rp),
allocatable :: q_tmp(:,:)
1696 do n=1, this%AUX_VARS(1)%mesh%LOCAL_MESH_NUM
1697 lcmesh3d => this%AUX_VARS(1)%mesh%lcmesh_list(n)
1698 elem3d => lcmesh3d%refElem3D
1699 allocate( q_tmp(elem3d%Np,qa) )
1702 do ke = lcmesh3d%NeS, lcmesh3d%NeE
1704 q_tmp(:,iq) = this%QTRC_VARS(iq)%local(n)%val(:,ke)
1706 call atmos_thermodyn_specific_heat( &
1707 elem3d%Np, 1, elem3d%Np, qa, &
1708 q_tmp(:,:), tracer_mass(:), tracer_r(:), tracer_cv(:), tracer_cp(:), &
1709 this%AUX_VARS(auxvar_qdry_id )%local(n)%val(:,ke), &
1710 this%AUX_VARS(auxvar_rtot_id )%local(n)%val(:,ke), &
1711 this%AUX_VARS(auxvar_cvtot_id)%local(n)%val(:,ke), &
1712 this%AUX_VARS(auxvar_cptot_id)%local(n)%val(:,ke) )
1716 end subroutine vars_calc_specific_heat
1718end module mod_atmos_vars
module ATMOSPHERE physics / Cloud Microphysics
subroutine, public atmosphympvars_getlocalmeshfields_sfcflx(domid, mesh, sfcflx_list, sflx_rain, sflx_snow, sflx_engi)
module ATMOSPHERE / Variables
integer, parameter, public atmos_diagvars2d_num
real(rp), dimension(prgvar_num), parameter progvars_check_min
integer, parameter, public atmos_diagvars_dens_id
integer, parameter, public atmos_diagvars_w_id
subroutine, public atmosvars_getlocalmeshsfcvar(domid, mesh, auxvars2d_list, prec, prec_engi, lcmesh2d)
type(variableinfo), dimension(atmos_diagvars3d_num), public atmos_diagvars3d_vinfo
subroutine, public atmosvars_getlocalmeshqtrc_qv(domid, mesh, trcvars_list, forcing_list, var, var_tp, lcmesh3d)
subroutine, public atmosvars_getlocalmeshprgvar(domid, mesh, prgvars_list, auxvars_list, varid, var, dens_hyd, pres_hyd, lcmesh3d)
integer, parameter, public atmos_auxvars2d_prec_id
integer, parameter, public atmos_diagvars3d_num
subroutine, public atmosvars_getlocalmeshprgvars(domid, mesh, prgvars_list, auxvars_list, ddens, momx, momy, momz, therm, dens_hyd, pres_hyd, rtot, cvtot, cptot, lcmesh3d)
integer, parameter, public atmos_diagvars_vmet_id
integer, parameter, public atmos_diagvars_rh_id
integer, parameter, public atmos_diagvars_engi_id
integer, parameter, public atmos_diagvars_umet_id
integer, parameter, public atmos_diagvars_qdry_id
subroutine, public atmosvars_getlocalmeshqtrcvarlist(domid, mesh, trcvars_list, varid_s, var_list, lcmesh3d)
integer, parameter, public atmos_auxvars2d_prec_engi_id
integer, parameter, public atmos_diagvars_engk_id
type(variableinfo), dimension(atmos_diagvars2d_num), public atmos_diagvars2d_vinfo
integer, parameter, public atmos_diagvars_v_id
integer, parameter, public atmos_auxvars2d_num
type(variableinfo), dimension(atmos_auxvars2d_num), public atmos_auxvars2d_vinfo
subroutine, public atmosvars_getlocalmeshphytends(domid, mesh, phytends_list, dens_tp, momx_tp, momy_tp, momz_tp, rhot_tp, rhoh_p, rhoq_tp, lcmesh3d)
subroutine, public atmosvars_getlocalmeshqtrcphytend(domid, mesh, phytends_list, qtrcid, rhoq_tp)
integer, parameter, public atmos_diagvars_t_id
subroutine, public atmosvars_getlocalmeshqtrcvar(domid, mesh, trcvars_list, varid, var, lcmesh3d)
subroutine, public atmosvars_getlocalmeshphyauxvars(domid, mesh, phyauxvars_list, pres, pt, lcmesh3d)
integer, parameter, public atmos_diagvars_snow_id
integer, parameter, public atmos_diagvars_engt_id
integer, parameter, public atmos_diagvars_engp_id
integer, parameter, public atmos_diagvars_rain_id
integer, parameter, public atmos_diagvars_u_id
module FElib / Fluid dyn solver / Atmosphere / driver (3D nonhydrostatic model)
module FElib / Fluid dyn solver / Atmosphere / Nonhydrostatic model / Common
integer, parameter, public prgvar_scalar_num
integer, parameter, public phytend_momz_id
integer, parameter, public prgvar_momy_id
integer, parameter, public auxvar_cptot_id
integer, parameter, public prgvar_therm_id
integer, parameter, public auxvar_qdry_id
integer, parameter, public auxvar_cvtot_id
integer, parameter, public prgvar_ddens_id
integer, parameter, public prgvar_momz_id
integer, parameter, public phytend_rhot_id
integer, parameter, public phytend_momx_id
integer, parameter, public phytend_num
integer, parameter, public phytend_momy_id
integer, parameter, public prgvar_momx_id
integer, parameter, public auxvar_num
subroutine, public atm_dyn_dgm_nonhydro3d_common_get_varinfo(prgvar_info, auxvar_info, phytend_info)
integer, parameter, public auxvar_pt_id
integer, parameter, public prgvar_hvec_num
integer, parameter, public prgvar_num
integer, parameter, public phytend_rhoh_id
integer, parameter, public auxvar_preshydro_id
integer, parameter, public auxvar_denshydro_id
integer, parameter, public phytend_dens_id
integer, parameter, public auxvar_rtot_id
subroutine, public atm_dyn_dgm_nonhydro3d_common_setup_variables(prgvars, qtrcvars, auxvars, phytends, prgvar_manager, qtrcvar_manager, auxvar_manager, phytend_manager, phytend_num_tot, mesh3d, prgvar_varinfo)
integer, parameter, public auxvar_preshydro_ref_id
integer, parameter, public auxvar_pres_id
module FElib / Element / Base
module FElib / File / History
module FElib / File / Monitor
module FElib / File / Restart
type(file_restart_meshfield), public restart_file
module FElib / Mesh / Local 2D
module FElib / Mesh / Local 3D
module FElib / Mesh / Local, Base
module FElib / Data / base
module FElib / Mesh / Base 2D
module FElib / Mesh / Base 3D
integer, public meshbase3d_dimtypeid_xyz
module FElib / Mesh / Base
module FElib / Data / base
module FElib / Data / Statistics
module FElib / Data / Communication base
module FElib / Data / Communication 3D cubic domain
FElib / model framework / variable manager.
Derived type to provide a driver of dynamical core with the atmospheric nonhydrostatic equations.