156 type(model_state_type),
target,
intent(inout) :: current_state
160 vertical_grid=current_state%global_grid%configuration%vertical
162 total_points=(current_state%local_grid%size(y_index) * current_state%local_grid%size(x_index))
165 allocate(
u_wind_tot(current_state%local_grid%size(z_index)) &
166 ,
v_wind_tot(current_state%local_grid%size(z_index)) &
167 ,
ww_tot(current_state%local_grid%size(z_index)) &
168 ,
w_wind_tot(current_state%local_grid%size(z_index)) &
169 ,
prefn(current_state%local_grid%size(z_index)) &
170 ,
rho(current_state%local_grid%size(z_index)) &
171 ,
rhon(current_state%local_grid%size(z_index)) &
172 ,
uinit(current_state%local_grid%size(z_index)) &
173 ,
vinit(current_state%local_grid%size(z_index)))
174 allocate(
uw_tot(current_state%local_grid%size(z_index)) &
175 ,
vw_tot(current_state%local_grid%size(z_index)) &
176 ,
uv_tot(current_state%local_grid%size(z_index)) &
177 ,
wwww_tot(current_state%local_grid%size(z_index)) &
178 ,
www_tot(current_state%local_grid%size(z_index)) )
180 if (
allocated(current_state%global_grid%configuration%vertical%olubar))
then
181 allocate(
uprime_tot(current_state%local_grid%size(z_index)), &
182 uprime(current_state%local_grid%size(z_index)))
185 if (
allocated(current_state%global_grid%configuration%vertical%olvbar))
then
186 allocate(
vprime_tot(current_state%local_grid%size(z_index)), &
187 vprime(current_state%local_grid%size(z_index)))
191 allocate(
wke_tot(current_state%local_grid%size(z_index)))
194 if (current_state%th%active)
then
195 allocate(
theta_tot(current_state%local_grid%size(z_index)) &
196 ,
thref(current_state%local_grid%size(z_index)) &
197 ,
thinit(current_state%local_grid%size(z_index)) &
200 ,
th2_tot(current_state%local_grid%size(z_index)) )
204 advect_flow = options_get_string(current_state%options_database,
"advection_flow_fields")
205 advect_theta = options_get_string(current_state%options_database,
"advection_theta_field")
206 advect_q = options_get_string(current_state%options_database,
"advection_q_fields")
208 if (.not. current_state%passive_q .and. current_state%number_q_fields .gt. 0)
then
209 iqv=get_q_index(standard_q_names%VAPOUR,
'profile_diags')
210 iql=get_q_index(standard_q_names%CLOUD_LIQUID_MASS,
'profile_diags')
211 qlcrit=options_get_real(current_state%options_database,
"qlcrit")
212 qicrit=options_get_real(current_state%options_database,
"qicrit")
214 allocate(
qv_tot(current_state%local_grid%size(z_index)) &
215 ,
ql_tot(current_state%local_grid%size(z_index)), &
216 q_temp(current_state%local_grid%size(z_index)), &
217 wqv_cn_tot(current_state%local_grid%size(z_index)), &
218 wqv_ad_tot(current_state%local_grid%size(z_index)), &
219 wql_cn_tot(current_state%local_grid%size(z_index)), &
220 wql_ad_tot(current_state%local_grid%size(z_index)))
221 if (current_state%th%active) &
222 allocate(
rh_tot(current_state%local_grid%size(z_index)))
226 if (current_state%rain_water_mixing_ratio_index > 0)
then
227 iqr = current_state%rain_water_mixing_ratio_index
228 allocate(
qr_tot(current_state%local_grid%size(z_index)))
229 allocate(
wqr_cn_tot(current_state%local_grid%size(z_index)))
230 allocate(
wqr_ad_tot(current_state%local_grid%size(z_index)))
232 if (current_state%ice_water_mixing_ratio_index > 0)
then
233 iqi = current_state%ice_water_mixing_ratio_index
234 allocate(
qi_tot(current_state%local_grid%size(z_index)))
235 allocate(
wqi_cn_tot(current_state%local_grid%size(z_index)))
236 allocate(
wqi_ad_tot(current_state%local_grid%size(z_index)))
238 if (current_state%snow_water_mixing_ratio_index > 0)
then
239 iqs = current_state%snow_water_mixing_ratio_index
240 allocate(
qs_tot(current_state%local_grid%size(z_index)))
241 allocate(
wqs_cn_tot(current_state%local_grid%size(z_index)))
242 allocate(
wqs_ad_tot(current_state%local_grid%size(z_index)))
244 if (current_state%graupel_water_mixing_ratio_index > 0)
then
245 iqg = current_state%graupel_water_mixing_ratio_index
246 allocate(
qg_tot(current_state%local_grid%size(z_index)))
247 allocate(
wqg_cn_tot(current_state%local_grid%size(z_index)))
248 allocate(
wqg_ad_tot(current_state%local_grid%size(z_index)))
253 options_get_string(current_state%options_database,
"cloud_mask_method")
256 call log_master_log(log_error, &
257 "Requested cloud_mask_method is invalid. Check profile_diagnostics.F90")
259 if (options_get_logical(current_state%options_database,
"l_cloud_mask")) &
260 allocate(
cloud_mask(current_state%local_grid%size(z_index), &
261 current_state%local_grid%size(y_index), &
262 current_state%local_grid%size(x_index)))
267 options_get_logical(current_state%options_database,
"l_partial_liq_ice")
270 call allocate_tvd_diagnostic_terms(current_state, tvd_dgs_terms)
275 type(model_state_type),
target,
intent(inout) :: current_state
277 integer :: k, i, iq_tmp, km1, kp1, icol, jcol
278 real(kind=default_precision) :: cltop_col, clbas_col, qv, qc, tdegk, pmb &
280 real(kind=default_precision) :: uprime_w_local, vprime_w_local &
281 , thprime_w_local, qprime_w_local
284 icol=current_state%column_local_x
285 jcol=current_state%column_local_y
287 if (current_state%first_timestep_column)
then
290 if (
allocated(
uprime))
uprime(:) = 0.0_default_precision
293 if (
allocated(
vprime))
vprime(:) = 0.0_default_precision
297 ww_tot(:) = 0.0_default_precision
299 www_tot(:) = 0.0_default_precision
300 uw_tot(:) = 0.0_default_precision
301 vw_tot(:) = 0.0_default_precision
302 uv_tot(:) = 0.0_default_precision
304 if (current_state%th%active)
then
307 th2_tot(:) = 0.0_default_precision
310 if (.not. current_state%passive_q .and. &
311 current_state%number_q_fields .gt. 0)
then
312 q_temp(:)=0.0_default_precision
313 qv_tot(:)=0.0_default_precision
314 ql_tot(:)=0.0_default_precision
319 if (current_state%th%active) &
320 rh_tot(:) = 0.0_default_precision
322 qr_tot(:) = 0.0_default_precision
327 qi_tot(:) = 0.0_default_precision
332 qs_tot(:) = 0.0_default_precision
337 qg_tot(:) = 0.0_default_precision
350 if (.not. current_state%halo_column)
then
352 do k=1, current_state%local_grid%size(z_index)
354 (current_state%u%data(k,jcol,icol) &
355 + current_state%ugal)
358 (current_state%u%data(k, jcol, icol) &
359 - (current_state%global_grid%configuration%vertical%olubar(k) - current_state%ugal))
366 (current_state%v%data(k,jcol,icol) &
367 + current_state%vgal)
370 (current_state%v%data(k, jcol, icol) &
371 - (current_state%global_grid%configuration%vertical%olvbar(k) - current_state%vgal))
383 (current_state%w%data(:,jcol,icol)**2.)
385 do k=2, current_state%local_grid%size(z_index)
387 ((current_state%w%data(k-1,jcol,icol) + current_state%w%data(k,jcol,icol)) * &
388 tvd_dgs_terms%adv_w_dgs(k,jcol,icol))
392 do k=2, current_state%local_grid%size(z_index)
394 (current_state%w%data(k,jcol,icol)**3.)
396 (current_state%w%data(k,jcol,icol)**4.)
398 (current_state%w%data(k,jcol,icol))
404 do k=1, current_state%local_grid%size(z_index)-1
406 0.25 * ( current_state%u%data(k,jcol,icol) + &
407 current_state%u%data(k,jcol,icol-1) + &
408 current_state%u%data(k+1,jcol,icol) + &
409 current_state%u%data(k+1,jcol,icol-1) ) + &
411 if (
allocated(current_state%global_grid%configuration%vertical%olubar)) &
412 uprime_w_local = uprime_w_local - &
413 0.5 * ( current_state%global_grid%configuration%vertical%olubar(k) + &
414 current_state%global_grid%configuration%vertical%olubar(k+1) )
416 current_state%w%data(k,jcol,icol)
419 do k=2, current_state%local_grid%size(z_index)-1
421 (current_state%w%data(k,jcol,icol) + current_state%w%data(k,jcol,icol+1)) * &
422 tvd_dgs_terms%adv_u_dgs(k+1,jcol,icol))
427 do k=1, current_state%local_grid%size(z_index)-1
429 0.25 * ( current_state%v%data(k,jcol,icol) + &
430 current_state%v%data(k,jcol-1,icol) + &
431 current_state%v%data(k+1,jcol,icol) + &
432 current_state%v%data(k+1,jcol-1,icol) ) + &
434 if (
allocated(current_state%global_grid%configuration%vertical%olvbar)) &
435 vprime_w_local = vprime_w_local - &
436 0.5 * ( current_state%global_grid%configuration%vertical%olvbar(k) + &
437 current_state%global_grid%configuration%vertical%olvbar(k+1) )
439 current_state%w%data(k,jcol,icol)
442 do k=2, current_state%local_grid%size(z_index)-1
444 (current_state%w%data(k,jcol,icol) + current_state%w%data(k,jcol+1,icol)) * &
445 tvd_dgs_terms%adv_v_dgs(k+1,jcol,icol))
449 if (
allocated(current_state%global_grid%configuration%vertical%olvbar) .and. &
450 allocated(current_state%global_grid%configuration%vertical%olubar))
then
454 do k=1, current_state%local_grid%size(z_index)-1
456 + (current_state%v%data(k,jcol,icol+1)) &
458 + (current_state%v%data(k,jcol-1,icol) &
459 - (current_state%global_grid%configuration%vertical%olvbar(k) - current_state%vgal)) &
460 + (current_state%v%data(k,jcol-1,icol+1)))
465 do k=1, current_state%local_grid%size(z_index)
466 kp1=min(k+1,current_state%local_grid%size(z_index))
469 current_state%global_grid%configuration%vertical%rho(k) * &
470 ( (current_state%v%data(k,jcol,icol) &
471 + current_state%v%data(k,jcol,icol+1)) &
473 + (current_state%v%data(k,jcol,icol) &
474 + current_state%v%data(k,jcol+1,icol)) &
476 + 0.5_default_precision * ( &
477 (current_state%w%data(k,jcol,icol) &
478 + current_state%w%data(kp1,jcol,icol)) &
479 * current_state%w%data(k,jcol,icol) &
480 * current_state%w%data(kp1,jcol,icol) &
481 * current_state%global_grid%configuration%vertical%rhon(kp1) &
482 +(current_state%w%data(k,jcol,icol) &
483 + current_state%w%data(km1,jcol,icol)) &
484 * current_state%w%data(k,jcol,icol) &
485 * current_state%w%data(km1,jcol,icol) &
486 * current_state%global_grid%configuration%vertical%rhon(k) ) &
491 if (current_state%th%active)
then
492 do k=1, current_state%local_grid%size(z_index)
494 (current_state%th%data(k,jcol,icol) &
495 + current_state%global_grid%configuration%vertical%thref(k))
497 (current_state%th%data(k,jcol,icol) - &
498 current_state%global_grid%configuration%vertical%olthbar(k) )**2
506 do k=1, current_state%local_grid%size(z_index)-1
507 thprime_w_local = 0.5 * ( &
508 current_state%th%data(k,jcol,icol) + &
509 current_state%th%data(k+1,jcol,icol) )
511 (current_state%w%data(k,jcol,icol) * &
516 do k=2, current_state%local_grid%size(z_index)-1
517 thprime_w_local = 0.5 * ( &
518 current_state%th%data(k,jcol,icol) + &
519 current_state%th%data(k+1,jcol,icol) )
521 current_state%w%data(k,jcol,icol) * &
524 current_state%w%data(k,jcol,icol) * &
525 tvd_dgs_terms%adv_th_dgs(k+1,jcol,icol)
530 if (.not. current_state%passive_q .and. current_state%number_q_fields .gt. 0)
then
533 if (current_state%th%active)
then
535 do k=1, current_state%local_grid%size(z_index)
536 exner = current_state%global_grid%configuration%vertical%rprefrcp(k)
537 pmb = (current_state%global_grid%configuration%vertical%prefn(k)/100.)
538 qv = current_state%q(
iqv)%data(k, jcol,icol)
539 qc = current_state%q(
iql)%data(k, jcol,icol)
540 tdegk = (current_state%th%data(k,jcol,icol) &
541 + current_state%global_grid%configuration%vertical%thref(k))*exner
542 qs = qsaturation(tdegk, pmb)
594 type(model_state_type),
target,
intent(inout) :: current_state
595 character(len=*),
intent(in) :: name
596 type(component_field_information_type),
intent(out) :: field_information
598 field_information%field_type=component_array_field_type
599 field_information%number_dimensions=1
600 field_information%dimension_sizes(1)=current_state%local_grid%size(z_index)
601 field_information%data_type=component_double_data_type
602 if (name .eq.
"theta_total_local")
then
603 field_information%enabled=current_state%th%active
604 else if (name .eq.
"vapour_mmr_total_local" .or. name .eq.
"liquid_mmr_total_local" &
605 .or. name .eq.
"wqv_ad_total_local" .or. name .eq.
"wqv_cn_total_local" &
606 .or. name .eq.
"wql_ad_total_local" .or. name .eq.
"wql_cn_total_local" )
then
607 field_information%enabled=.not. current_state%passive_q .and. current_state%number_q_fields .gt. 0
608 else if (name .eq.
"rain_mmr_total_local" .or. name .eq.
"wqr_ad_total_local" &
609 .or. name .eq.
"wqr_cn_total_local" )
then
610 field_information%enabled= current_state%rain_water_mixing_ratio_index .gt. 0
611 else if (name .eq.
"ice_mmr_total_local" .or. name .eq.
"wqi_ad_total_local" &
612 .or. name .eq.
"wqi_cn_total_local" )
then
613 field_information%enabled= current_state%ice_water_mixing_ratio_index .gt. 0
614 else if (name .eq.
"snow_mmr_total_local" .or. name .eq.
"wqs_ad_total_local" &
615 .or. name .eq.
"wqs_cn_total_local" )
then
616 field_information%enabled= current_state%snow_water_mixing_ratio_index .gt. 0
617 else if (name .eq.
"graupel_mmr_total_local" .or. name .eq.
"wqg_ad_total_local" &
618 .or. name .eq.
"wqg_cn_total_local" )
then
619 field_information%enabled= current_state%graupel_water_mixing_ratio_index .gt. 0
620 else if (name .eq.
"rh_total_local")
then
621 field_information%enabled=current_state%th%active .and. .not. current_state%passive_q .and. &
622 current_state%number_q_fields .gt. 0
623 else if (name .eq.
"uu_total_local")
then
624 field_information%enabled=
allocated(
uprime_tot)
625 else if (name .eq.
"vv_total_local")
then
626 field_information%enabled=
allocated(
vprime_tot)
627 else if (name .eq.
"wtheta_ad_total_local" .or. name .eq.
"wtheta_cn_total_local")
then
628 field_information%enabled=current_state%th%active
629 else if (name .eq.
"th2_total_local")
then
630 field_information%enabled=current_state%th%active
633 else if (name .eq.
"i_theta_total_local")
then
634 field_information%enabled=current_state%th%active
635 else if (name .eq.
"i_vapour_mmr_total_local" .or. name .eq.
"i_liquid_mmr_total_local")
then
636 field_information%enabled=.not. current_state%passive_q .and. current_state%number_q_fields .gt. 0
637 else if (name .eq.
"i_rain_mmr_total_local" )
then
638 field_information%enabled= current_state%rain_water_mixing_ratio_index .gt. 0
639 else if (name .eq.
"i_ice_mmr_total_local" )
then
640 field_information%enabled= current_state%ice_water_mixing_ratio_index .gt. 0
641 else if (name .eq.
"i_snow_mmr_total_local" )
then
642 field_information%enabled= current_state%snow_water_mixing_ratio_index .gt. 0
643 else if (name .eq.
"i_graupel_mmr_total_local" )
then
644 field_information%enabled= current_state%graupel_water_mixing_ratio_index .gt. 0
645 else if (name .eq.
"i_rh_total_local")
then
646 field_information%enabled=current_state%th%active .and. .not. current_state%passive_q .and. &
647 current_state%number_q_fields .gt. 0
648 else if (name .eq.
"i_uu_total_local")
then
649 field_information%enabled=
allocated(
uprime_tot)
650 else if (name .eq.
"i_vv_total_local")
then
651 field_information%enabled=
allocated(
vprime_tot)
652 else if (name .eq.
"i_wtheta_cn_total_local")
then
653 field_information%enabled=current_state%th%active
654 else if (name .eq.
"i_th2_total_local")
then
655 field_information%enabled=current_state%th%active
657 else if (name .eq.
"cloud_mask")
then
658 field_information%number_dimensions=3
659 field_information%dimension_sizes(1)=current_state%local_grid%size(z_index)
660 field_information%dimension_sizes(2)=current_state%local_grid%size(y_index)
661 field_information%dimension_sizes(3)=current_state%local_grid%size(x_index)
662 field_information%enabled=
allocated(
cloud_mask)
663 else if (name .eq.
"cloud_mask_total_local")
then
665 else if (name .eq.
"cloud_liq_mask_total_local")
then
667 else if (name .eq.
"cloud_ice_mask_total_local")
then
671 field_information%enabled=.true.
680 type(model_state_type),
target,
intent(inout) :: current_state
681 character(len=*),
intent(in) :: name
682 type(component_field_value_type),
intent(out) :: field_value
686 if (name .eq.
"prefn_local")
then
687 allocate(field_value%real_1d_array(current_state%local_grid%size(z_index)))
688 do k = 1, current_state%local_grid%size(z_index)
689 field_value%real_1d_array(k)=current_state%global_grid%configuration%vertical%prefn(k)
691 else if (name .eq.
"rho_local")
then
692 allocate(field_value%real_1d_array(current_state%local_grid%size(z_index)))
693 do k = 1, current_state%local_grid%size(z_index)
694 field_value%real_1d_array(k)=current_state%global_grid%configuration%vertical%rho(k)
696 else if (name .eq.
"rhon_local")
then
697 allocate(field_value%real_1d_array(current_state%local_grid%size(z_index)))
698 do k = 1, current_state%local_grid%size(z_index)
699 field_value%real_1d_array(k)=current_state%global_grid%configuration%vertical%rhon(k)
701 else if (name .eq.
"thref_local")
then
702 allocate(field_value%real_1d_array(current_state%local_grid%size(z_index)))
703 do k = 1, current_state%local_grid%size(z_index)
704 field_value%real_1d_array(k)=current_state%global_grid%configuration%vertical%thref(k)
706 else if (name .eq.
"thinit_local")
then
707 allocate(field_value%real_1d_array(current_state%local_grid%size(z_index)))
708 do k = 1, current_state%local_grid%size(z_index)
709 field_value%real_1d_array(k)=current_state%global_grid%configuration%vertical%theta_init(k)
711 elseif (name .eq.
"u_wind_total_local")
then
712 allocate(field_value%real_1d_array(current_state%local_grid%size(z_index)))
713 do k = 1, current_state%local_grid%size(z_index)
716 else if (name .eq.
"uu_total_local")
then
717 allocate(field_value%real_1d_array(current_state%local_grid%size(z_index)))
718 do k = 1, current_state%local_grid%size(z_index)
721 else if (name .eq.
"v_wind_total_local")
then
722 allocate(field_value%real_1d_array(current_state%local_grid%size(z_index)))
723 do k = 1, current_state%local_grid%size(z_index)
726 else if (name .eq.
"vv_total_local")
then
727 allocate(field_value%real_1d_array(current_state%local_grid%size(z_index)))
728 do k = 1, current_state%local_grid%size(z_index)
731 else if (name .eq.
"ww_total_local")
then
732 allocate(field_value%real_1d_array(current_state%local_grid%size(z_index)))
733 do k = 1, current_state%local_grid%size(z_index)
734 field_value%real_1d_array(k)=
ww_tot(k)
736 else if (name .eq.
"www_total_local")
then
737 allocate(field_value%real_1d_array(current_state%local_grid%size(z_index)))
738 do k = 1, current_state%local_grid%size(z_index)
739 field_value%real_1d_array(k)=
www_tot(k)
741 else if (name .eq.
"wwww_total_local")
then
742 allocate(field_value%real_1d_array(current_state%local_grid%size(z_index)))
743 do k = 1, current_state%local_grid%size(z_index)
744 field_value%real_1d_array(k)=
wwww_tot(k)
746 else if (name .eq.
"theta_total_local")
then
747 allocate(field_value%real_1d_array(current_state%local_grid%size(z_index)))
748 do k = 1, current_state%local_grid%size(z_index)
749 field_value%real_1d_array(k)=
theta_tot(k)
751 else if (name .eq.
"vapour_mmr_total_local")
then
752 allocate(field_value%real_1d_array(current_state%local_grid%size(z_index)))
753 do k = 1, current_state%local_grid%size(z_index)
754 field_value%real_1d_array(k)=
qv_tot(k)
756 else if (name .eq.
"liquid_mmr_total_local")
then
757 allocate(field_value%real_1d_array(current_state%local_grid%size(z_index)))
758 do k = 1, current_state%local_grid%size(z_index)
759 field_value%real_1d_array(k)=
ql_tot(k)
761 else if (name .eq.
"rain_mmr_total_local" )
then
762 allocate(field_value%real_1d_array(current_state%local_grid%size(z_index)))
763 do k = 1, current_state%local_grid%size(z_index)
764 field_value%real_1d_array(k)=
qr_tot(k)
766 else if (name .eq.
"ice_mmr_total_local" )
then
767 allocate(field_value%real_1d_array(current_state%local_grid%size(z_index)))
768 do k = 1, current_state%local_grid%size(z_index)
769 field_value%real_1d_array(k)=
qi_tot(k)
771 else if (name .eq.
"snow_mmr_total_local" )
then
772 allocate(field_value%real_1d_array(current_state%local_grid%size(z_index)))
773 do k = 1, current_state%local_grid%size(z_index)
774 field_value%real_1d_array(k)=
qs_tot(k)
776 else if (name .eq.
"graupel_mmr_total_local" )
then
777 allocate(field_value%real_1d_array(current_state%local_grid%size(z_index)))
778 do k = 1, current_state%local_grid%size(z_index)
779 field_value%real_1d_array(k)=
qg_tot(k)
781 else if (name .eq.
"w_wind_total_local")
then
782 allocate(field_value%real_1d_array(current_state%local_grid%size(z_index)))
783 do k = 1, current_state%local_grid%size(z_index)
786 else if (name .eq.
"rh_total_local")
then
787 allocate(field_value%real_1d_array(current_state%local_grid%size(z_index)))
788 do k = 1, current_state%local_grid%size(z_index)
789 field_value%real_1d_array(k)=
rh_tot(k)
791 else if (name .eq.
"wtheta_cn_total_local")
then
792 allocate(field_value%real_1d_array(current_state%local_grid%size(z_index)))
793 do k = 1, current_state%local_grid%size(z_index)
796 else if (name .eq.
"wtheta_ad_total_local")
then
797 allocate(field_value%real_1d_array(current_state%local_grid%size(z_index)))
798 do k = 1, current_state%local_grid%size(z_index)
801 else if (name .eq.
"uw_total_local")
then
802 allocate(field_value%real_1d_array(current_state%local_grid%size(z_index)))
803 do k = 1, current_state%local_grid%size(z_index)
804 field_value%real_1d_array(k)=
uw_tot(k)
806 else if (name .eq.
"vw_total_local")
then
807 allocate(field_value%real_1d_array(current_state%local_grid%size(z_index)))
808 do k = 1, current_state%local_grid%size(z_index)
809 field_value%real_1d_array(k)=
vw_tot(k)
811 else if (name .eq.
"uv_total_local")
then
812 allocate(field_value%real_1d_array(current_state%local_grid%size(z_index)))
813 do k = 1, current_state%local_grid%size(z_index)
814 field_value%real_1d_array(k)=
uv_tot(k)
816 else if (name .eq.
"wke_total_local")
then
817 allocate(field_value%real_1d_array(current_state%local_grid%size(z_index)))
818 do k = 1, current_state%local_grid%size(z_index)
819 field_value%real_1d_array(k)=
wke_tot(k)
821 else if (name .eq.
"th2_total_local")
then
822 allocate(field_value%real_1d_array(current_state%local_grid%size(z_index)))
823 do k = 1, current_state%local_grid%size(z_index)
824 field_value%real_1d_array(k)=
th2_tot(k)
826 else if (name .eq.
"wqv_cn_total_local")
then
827 allocate(field_value%real_1d_array(current_state%local_grid%size(z_index)))
828 do k = 1, current_state%local_grid%size(z_index)
831 else if (name .eq.
"wqv_ad_total_local")
then
832 allocate(field_value%real_1d_array(current_state%local_grid%size(z_index)))
833 do k = 1, current_state%local_grid%size(z_index)
836 else if (name .eq.
"wql_cn_total_local")
then
837 allocate(field_value%real_1d_array(current_state%local_grid%size(z_index)))
838 do k = 1, current_state%local_grid%size(z_index)
841 else if (name .eq.
"wql_ad_total_local")
then
842 allocate(field_value%real_1d_array(current_state%local_grid%size(z_index)))
843 do k = 1, current_state%local_grid%size(z_index)
846 else if (name .eq.
"wqr_cn_total_local")
then
847 allocate(field_value%real_1d_array(current_state%local_grid%size(z_index)))
848 do k = 1, current_state%local_grid%size(z_index)
851 else if (name .eq.
"wqr_ad_total_local")
then
852 allocate(field_value%real_1d_array(current_state%local_grid%size(z_index)))
853 do k = 1, current_state%local_grid%size(z_index)
856 else if (name .eq.
"wqi_cn_total_local")
then
857 allocate(field_value%real_1d_array(current_state%local_grid%size(z_index)))
858 do k = 1, current_state%local_grid%size(z_index)
861 else if (name .eq.
"wqi_ad_total_local")
then
862 allocate(field_value%real_1d_array(current_state%local_grid%size(z_index)))
863 do k = 1, current_state%local_grid%size(z_index)
866 else if (name .eq.
"wqs_cn_total_local")
then
867 allocate(field_value%real_1d_array(current_state%local_grid%size(z_index)))
868 do k = 1, current_state%local_grid%size(z_index)
871 else if (name .eq.
"wqs_ad_total_local")
then
872 allocate(field_value%real_1d_array(current_state%local_grid%size(z_index)))
873 do k = 1, current_state%local_grid%size(z_index)
876 else if (name .eq.
"wqg_cn_total_local")
then
877 allocate(field_value%real_1d_array(current_state%local_grid%size(z_index)))
878 do k = 1, current_state%local_grid%size(z_index)
881 else if (name .eq.
"wqg_ad_total_local")
then
882 allocate(field_value%real_1d_array(current_state%local_grid%size(z_index)))
883 do k = 1, current_state%local_grid%size(z_index)
888 else if (name .eq.
"i_prefn_local")
then
889 allocate(field_value%real_1d_array(current_state%local_grid%size(z_index)))
890 do k = 1, current_state%local_grid%size(z_index)
891 field_value%real_1d_array(k)=current_state%global_grid%configuration%vertical%prefn(k)
893 else if (name .eq.
"i_rho_local")
then
894 allocate(field_value%real_1d_array(current_state%local_grid%size(z_index)))
895 do k = 1, current_state%local_grid%size(z_index)
896 field_value%real_1d_array(k)=current_state%global_grid%configuration%vertical%rho(k)
898 else if (name .eq.
"i_rhon_local")
then
899 allocate(field_value%real_1d_array(current_state%local_grid%size(z_index)))
900 do k = 1, current_state%local_grid%size(z_index)
901 field_value%real_1d_array(k)=current_state%global_grid%configuration%vertical%rhon(k)
903 else if (name .eq.
"i_thref_local")
then
904 allocate(field_value%real_1d_array(current_state%local_grid%size(z_index)))
905 do k = 1, current_state%local_grid%size(z_index)
906 field_value%real_1d_array(k)=current_state%global_grid%configuration%vertical%thref(k)
908 else if (name .eq.
"i_thinit_local")
then
909 allocate(field_value%real_1d_array(current_state%local_grid%size(z_index)))
910 do k = 1, current_state%local_grid%size(z_index)
911 field_value%real_1d_array(k)=current_state%global_grid%configuration%vertical%theta_init(k)
913 else if (name .eq.
"i_uinit_local")
then
914 allocate(field_value%real_1d_array(current_state%local_grid%size(z_index)))
915 do k = 1, current_state%local_grid%size(z_index)
916 field_value%real_1d_array(k)=current_state%global_grid%configuration%vertical%u_init(k)
918 else if (name .eq.
"i_vinit_local")
then
919 allocate(field_value%real_1d_array(current_state%local_grid%size(z_index)))
920 do k = 1, current_state%local_grid%size(z_index)
921 field_value%real_1d_array(k)=current_state%global_grid%configuration%vertical%v_init(k)
923 elseif (name .eq.
"i_u_wind_total_local")
then
924 allocate(field_value%real_1d_array(current_state%local_grid%size(z_index)))
925 do k = 1, current_state%local_grid%size(z_index)
928 else if (name .eq.
"i_uu_total_local")
then
929 allocate(field_value%real_1d_array(current_state%local_grid%size(z_index)))
930 do k = 1, current_state%local_grid%size(z_index)
933 else if (name .eq.
"i_v_wind_total_local")
then
934 allocate(field_value%real_1d_array(current_state%local_grid%size(z_index)))
935 do k = 1, current_state%local_grid%size(z_index)
938 else if (name .eq.
"i_vv_total_local")
then
939 allocate(field_value%real_1d_array(current_state%local_grid%size(z_index)))
940 do k = 1, current_state%local_grid%size(z_index)
943 else if (name .eq.
"i_ww_total_local")
then
944 allocate(field_value%real_1d_array(current_state%local_grid%size(z_index)))
945 do k = 1, current_state%local_grid%size(z_index)
946 field_value%real_1d_array(k)=
ww_tot(k)
948 else if (name .eq.
"i_theta_total_local")
then
949 allocate(field_value%real_1d_array(current_state%local_grid%size(z_index)))
950 do k = 1, current_state%local_grid%size(z_index)
951 field_value%real_1d_array(k)=
theta_tot(k)
953 else if (name .eq.
"i_vapour_mmr_total_local")
then
954 allocate(field_value%real_1d_array(current_state%local_grid%size(z_index)))
955 do k = 1, current_state%local_grid%size(z_index)
956 field_value%real_1d_array(k)=
qv_tot(k)
958 else if (name .eq.
"i_liquid_mmr_total_local")
then
959 allocate(field_value%real_1d_array(current_state%local_grid%size(z_index)))
960 do k = 1, current_state%local_grid%size(z_index)
961 field_value%real_1d_array(k)=
ql_tot(k)
963 else if (name .eq.
"rain_mmr_total_local" )
then
964 allocate(field_value%real_1d_array(current_state%local_grid%size(z_index)))
965 do k = 1, current_state%local_grid%size(z_index)
966 field_value%real_1d_array(k)=
qr_tot(k)
968 else if (name .eq.
"ice_mmr_total_local" )
then
969 allocate(field_value%real_1d_array(current_state%local_grid%size(z_index)))
970 do k = 1, current_state%local_grid%size(z_index)
971 field_value%real_1d_array(k)=
qi_tot(k)
973 else if (name .eq.
"snow_mmr_total_local" )
then
974 allocate(field_value%real_1d_array(current_state%local_grid%size(z_index)))
975 do k = 1, current_state%local_grid%size(z_index)
976 field_value%real_1d_array(k)=
qs_tot(k)
978 else if (name .eq.
"graupel_mmr_total_local" )
then
979 allocate(field_value%real_1d_array(current_state%local_grid%size(z_index)))
980 do k = 1, current_state%local_grid%size(z_index)
981 field_value%real_1d_array(k)=
qg_tot(k)
983 else if (name .eq.
"i_w_wind_total_local")
then
984 allocate(field_value%real_1d_array(current_state%local_grid%size(z_index)))
985 do k = 1, current_state%local_grid%size(z_index)
988 else if (name .eq.
"i_rh_total_local")
then
989 allocate(field_value%real_1d_array(current_state%local_grid%size(z_index)))
990 do k = 1, current_state%local_grid%size(z_index)
991 field_value%real_1d_array(k)=
rh_tot(k)
993 else if (name .eq.
"i_wtheta_ad_total_local")
then
994 allocate(field_value%real_1d_array(current_state%local_grid%size(z_index)))
995 do k = 1, current_state%local_grid%size(z_index)
998 else if (name .eq.
"i_uw_total_local")
then
999 allocate(field_value%real_1d_array(current_state%local_grid%size(z_index)))
1000 do k = 1, current_state%local_grid%size(z_index)
1001 field_value%real_1d_array(k)=
uw_tot(k)
1003 else if (name .eq.
"i_vw_total_local")
then
1004 allocate(field_value%real_1d_array(current_state%local_grid%size(z_index)))
1005 do k = 1, current_state%local_grid%size(z_index)
1006 field_value%real_1d_array(k)=
vw_tot(k)
1008 else if (name .eq.
"i_th2_total_local")
then
1009 allocate(field_value%real_1d_array(current_state%local_grid%size(z_index)))
1010 do k = 1, current_state%local_grid%size(z_index)
1011 field_value%real_1d_array(k)=
th2_tot(k)
1014 else if (name .eq.
"cloud_mask")
then
1015 allocate(field_value%real_3d_array( &
1018 else if (name .eq.
"cloud_mask_total_local")
then
1019 allocate(field_value%real_1d_array(current_state%local_grid%size(z_index)))
1020 do k = 1, current_state%local_grid%size(z_index)
1023 else if (name .eq.
"cloud_liq_mask_total_local")
then
1024 allocate(field_value%real_1d_array(current_state%local_grid%size(z_index)))
1025 do k = 1, current_state%local_grid%size(z_index)
1028 else if (name .eq.
"cloud_ice_mask_total_local")
then
1029 allocate(field_value%real_1d_array(current_state%local_grid%size(z_index)))
1030 do k = 1, current_state%local_grid%size(z_index)
1036 subroutine calculate_wq(current_state, jcol, icol, iq, wq_cn, wq_ad, advect_q)
1038 type(model_state_type),
target,
intent(inout) :: current_state
1040 real(kind=default_precision),
intent(inout) :: wq_cn(:), wq_ad(:)
1041 character(len=*),
intent(in) :: advect_q
1042 integer,
intent(in) :: jcol, icol, iq
1046 if (trim(advect_q) .eq.
"pw")
then
1047 do k=1, current_state%local_grid%size(z_index)-1
1048 wq_ad(k) = wq_ad(k) + ( 0.5 * ( &
1049 current_state%q(iq)%data(k,jcol,icol) + &
1050 current_state%q(iq)%data(k+1,jcol,icol)) * &
1051 current_state%w%data(k,jcol,icol))
1054 else if (trim(advect_q) .eq.
"tvd")
then
1055 do k=2, current_state%local_grid%size(z_index)-1
1056 wq_ad(k) = wq_ad(k) + (current_state%w%data(k,jcol,icol) &
1057 * tvd_dgs_terms%adv_q_dgs(k+1, jcol, icol, iq) )
1058 wq_cn(k) = wq_cn(k) + ( 0.5 * ( &
1059 current_state%q(iq)%data(k,jcol,icol) + &
1060 current_state%q(iq)%data(k+1,jcol,icol)) * &
1061 current_state%w%data(k,jcol,icol) )
1108 type(model_state_type),
target,
intent(inout) :: current_state
1109 integer,
intent(in) :: jcol, icol
1110 integer :: k, target_y_index, target_x_index
1111 logical :: l_prepare_3d_mask, cloud_present
1115 real(kind=default_precision) :: &
1121 real(kind=default_precision) :: templ, tempi, tempt
1123 target_y_index = jcol - current_state%local_grid%halo_size(y_index)
1124 target_x_index = icol - current_state%local_grid%halo_size(x_index)
1126 templ = 0.0_default_precision
1127 tempi = 0.0_default_precision
1128 tempt = 0.0_default_precision
1132 do k=1, current_state%local_grid%size(z_index)
1136 templ = current_state%q(
iql)%data(k, jcol, icol)
1138 tempi = current_state%q(
iqi)%data(k, jcol, icol)
1145 templ = templ + rainfac * current_state%q(
iqr)%data(k, jcol, icol)
1147 tempi = tempi + snowfac * current_state%q(
iqs)%data(k, jcol, icol)
1149 tempi = tempi + graupfac * current_state%q(
iqg)%data(k, jcol, icol)
1153 tempt = templ + tempi
1155 cloud_present = (tempt > epsilon(tempt))
1160 if (cloud_present)
then
1161 if (l_prepare_3d_mask) &
1162 cloud_mask(k, target_y_index, target_x_index) = 1.0_default_precision