84 type(model_state_type),
target,
intent(inout) :: current_state
86 integer :: total_points, inc
164 total_points=(current_state%local_grid%size(y_index) * current_state%local_grid%size(x_index))
166 if (.not. current_state%passive_q .and. current_state%number_q_fields .gt. 0)
then
167 iqv =get_q_index(standard_q_names%VAPOUR,
'profile_diags')
168 iql =get_q_index(standard_q_names%CLOUD_LIQUID_MASS,
'profile_diags')
169 iqi =get_q_index(standard_q_names%ICE_MASS,
'profile_diags')
170 iqr =get_q_index(standard_q_names%RAIN_MASS,
'profile_diags')
171 iqs =get_q_index(standard_q_names%SNOW_MASS,
'profile_diags')
172 iqg =get_q_index(standard_q_names%GRAUPEL_MASS,
'profile_diags')
174 qlcrit =options_get_real(current_state%options_database,
"qlcrit")
175 qicrit =options_get_real(current_state%options_database,
"qicrit")
176 qpptcrit =options_get_real(current_state%options_database,
"qpptcrit")
177 vpptcrit =options_get_real(current_state%options_database,
"vpptcrit")
181 l_qi_qr_qs_qg = (.not. current_state%passive_q .and. current_state%number_q_fields .ge. 11)
183 x_size =options_get_integer(current_state%options_database,
"x_size")
184 y_size =options_get_integer(current_state%options_database,
"y_size")
185 thvprcrit =options_get_real(current_state%options_database,
"thvprcrit")
186 wsdwncrit =options_get_real(current_state%options_database,
"wSdwncrit")
187 wsupcrit =options_get_real(current_state%options_database,
"wSupcrit")
188 wupcrit =options_get_real(current_state%options_database,
"wupcrit")
189 wdwncrit =options_get_real(current_state%options_database,
"wdwncrit")
190 ncond =options_get_array_size(current_state%options_database,
"cond_request")
191 ndiag =options_get_array_size(current_state%options_database,
"diag_request")
197 if (
ncond .lt. 1 .or.
ndiag .lt. 1)
call log_master_log(log_error, &
198 "When conditional_diagnostics_column are enabled, condition and diagnostic request lists must be provided.")
200 if (current_state%th%active)
then
201 allocate(
conddiags_tot(current_state%local_grid%size(z_index), &
218 cond_request(inc) = trim(options_get_string(current_state%options_database,
"cond_request", inc))
222 call log_master_log(log_error, &
223 "Condition '"//trim(
cond_request(inc))//
"' has not been set up.")
276 diag_request(inc) = trim(options_get_string(current_state%options_database,
"diag_request", inc))
281 call log_master_log(log_error, &
282 "Diagnostic '"//trim(
diag_request(inc))//
"' has not been set up.")
349 "The diagnostic 'area' must be provided to complete the conditional diagnostics process.")
361 type(model_state_type),
target,
intent(inout) :: current_state
375 type(model_state_type),
target,
intent(inout) :: current_state
378 real(kind=default_precision),
dimension(size(master_diagnostics_list)) :: local_diag
380 real(kind=default_precision) :: qi, ql,qv,qli,qsat,qppt,qvl
381 real(kind=default_precision) :: qi_pr, ql_pr,qv_pr,qli_pr,qvli, qvli_pr, qppt_pr
382 real(kind=default_precision) :: thv_pr,thv,exner,tdegk,th_pr,th_pr2
383 real(kind=default_precision) :: tmp_th
384 real(kind=default_precision) :: pottemp
385 real(kind=default_precision) :: relhum,pmb,wth,wthsg, wthv_pr, wth_pr
386 real(kind=default_precision) :: w_zn
387 real(kind=default_precision) :: tmp_u,tmp_v
388 real(kind=default_precision) :: w_zn2, w_zn3, wu, wv, wusg, wvsg, wqvli_pr,wqppt_pr
389 real(kind=default_precision) :: th_h,th_h_pr1,th_h_pr2
390 real(kind=default_precision) :: qvli_pr2, qppt_pr2
392 real(kind=default_precision) :: qv_jip1,qv_jim1,qv_jp1i,qv_jm1i,qv_pr_jip1,qv_pr_jim1,qv_pr_jp1i,qv_pr_jm1i
393 real(kind=default_precision) :: qi_jip1,qi_jim1,qi_jp1i,qi_jm1i
394 real(kind=default_precision) :: ql_jip1,ql_jim1,ql_jp1i,ql_jm1i
395 real(kind=default_precision) :: qli_jip1,qli_jim1,qli_jp1i,qli_jm1i,qli_pr_jip1,qli_pr_jim1,qli_pr_jp1i,qli_pr_jm1i
396 real(kind=default_precision) :: w_zn_jip1,w_zn_jim1,w_zn_jp1i,w_zn_jm1i
397 real(kind=default_precision) :: thv_pr_jip1,thv_pr_jim1,thv_pr_jp1i,thv_pr_jm1i
398 real(kind=default_precision) :: tmp_th_jip1,tmp_th_jim1,tmp_th_jp1i,tmp_th_jm1i
399 real(kind=default_precision) :: th_pr_jip1,th_pr_jim1,th_pr_jp1i,th_pr_jm1i
403 integer :: local_y, locaL_x, target_x_index, target_y_index
405 j=current_state%column_local_y
406 i=current_state%column_local_x
409 if (current_state%first_timestep_column)
then
414 if (current_state%halo_column)
return
415 if ( .not. (current_state%th%active .and. &
416 .not. current_state%passive_q .and. &
417 current_state%number_q_fields .gt. 0) )
return
424 do k = 2, current_state%local_grid%size(z_index)-1
427 qv = current_state%zq(
iqv)%data(k,j,i)
428 ql = current_state%zq(
iql)%data(k,j,i)
430 qv_pr = qv - current_state%global_grid%configuration%vertical%olzqbar(k,
iqv)
431 ql_pr = ql - current_state%global_grid%configuration%vertical%olzqbar(k,
iql)
440 qvli_pr = qv_pr + ql_pr
445 qi = current_state%zq(
iqi)%data(k,j,i)
448 qppt = current_state%zq(
iqr)%data(k,j,i) + current_state%zq(
iqs)%data(k,j,i)+current_state%zq(
iqg)%data(k,j,i)
449 qi_pr = qli - current_state%global_grid%configuration%vertical%olzqbar(k,
iqi)
450 qli_pr = ql_pr + qi_pr
451 qvli_pr = qv_pr + qli_pr
452 qppt_pr = current_state%zq(
iqr)%data(k,j,i) - current_state%global_grid%configuration%vertical%olzqbar(k,
iqr)+ &
453 current_state%zq(
iqs)%data(k,j,i) - current_state%global_grid%configuration%vertical%olzqbar(k,
iqs)+ &
454 current_state%zq(
iqg)%data(k,j,i) - current_state%global_grid%configuration%vertical%olzqbar(k,
iqg)
457 w_zn = 0.5 * (current_state%zw%data(k,j,i) + current_state%zw%data(k-1,j,i))
459 w_zn3 = w_zn * w_zn * w_zn
461 qvli_pr2 = qvli_pr * qvli_pr
462 qppt_pr2 = qppt_pr * qppt_pr
463 wqvli_pr = w_zn * qvli_pr
464 wqppt_pr = w_zn * qppt_pr
466 tmp_u = 0.5 * (current_state%zu%data(k,j,i-1) + current_state%zu%data(k,j,i)) + current_state%ugal
467 tmp_v = 0.5 * (current_state%zv%data(k,j-1,i) + current_state%zv%data(k,j,i)) + current_state%vgal
470 tmp_th = current_state%global_grid%configuration%vertical%thref(k) + current_state%zth%data(k,j,i)
472 wthsg = -0.5 * current_state%diff_coefficient%data(k,j,i) * (current_state%zth%data(k+1,j,i) + &
473 current_state%global_grid%configuration%vertical%thref(k+1) - current_state%zth%data(k,j,i) - &
474 current_state%global_grid%configuration%vertical%thref(k)) * &
475 current_state%global_grid%configuration%vertical%rdzn(k+1) &
476 -0.5 * current_state%diff_coefficient%data(k-1,j,i) * (current_state%zth%data(k,j,i) + &
477 current_state%global_grid%configuration%vertical%thref(k) - current_state%zth%data(k-1,j,i) - &
478 current_state%global_grid%configuration%vertical%thref(k-1)) * &
479 current_state%global_grid%configuration%vertical%rdzn(k)
481 wusg = -0.25 * current_state%vis_coefficient%data(k ,j,i-1) * &
482 (current_state%zu%data(k+1,j,i-1) - current_state%zu%data(k ,j,i-1)) * &
483 current_state%global_grid%configuration%vertical%rdzn(k+1) &
484 -0.25 * current_state%vis_coefficient%data(k ,j,i ) * &
485 (current_state%zu%data(k+1,j,i ) - current_state%zu%data(k ,j,i )) * &
486 current_state%global_grid%configuration%vertical%rdzn(k+1) &
487 -0.25 * current_state%vis_coefficient%data(k-1,j,i-1) * &
488 (current_state%zu%data(k ,j,i-1) - current_state%zu%data(k-1,j,i-1)) * &
489 current_state%global_grid%configuration%vertical%rdzn(k) &
490 -0.25 * current_state%vis_coefficient%data(k-1,j,i ) * &
491 (current_state%zu%data(k ,j,i ) - current_state%zu%data(k-1,j,i )) * &
492 current_state%global_grid%configuration%vertical%rdzn(k)
494 wvsg = -0.25 * current_state%vis_coefficient%data(k ,j-1,i) * &
495 (current_state%zv%data(k+1,j-1,i) - current_state%zv%data(k ,j-1,i)) * &
496 current_state%global_grid%configuration%vertical%rdzn(k+1) &
497 -0.25 * current_state%vis_coefficient%data(k ,j ,i) * &
498 (current_state%zv%data(k+1,j ,i) - current_state%zv%data(k ,j ,i)) * &
499 current_state%global_grid%configuration%vertical%rdzn(k+1) &
500 -0.25 * current_state%vis_coefficient%data(k-1,j-1,i) * &
501 (current_state%zv%data(k ,j-1,i) - current_state%zv%data(k-1,j-1,i)) * &
502 current_state%global_grid%configuration%vertical%rdzn(k) &
503 -0.25 * current_state%vis_coefficient%data(k-1,j ,i) * &
504 (current_state%zv%data(k ,j ,i) - current_state%zv%data(k-1,j ,i)) * &
505 current_state%global_grid%configuration%vertical%rdzn(k)
507 pottemp = current_state%global_grid%configuration%vertical%thref(k) + &
508 current_state%global_grid%configuration%vertical%olzthbar(k)
510 th_pr = current_state%zth%data(k,j,i) - current_state%global_grid%configuration%vertical%olzthbar(k)
511 wth_pr = w_zn * th_pr
512 th_pr2 = th_pr * th_pr
513 exner = current_state%global_grid%configuration%vertical%rprefrcp(k)
514 tdegk = (current_state%global_grid%configuration%vertical%thref(k) + current_state%zth%data(k,j,i)) * exner
515 pmb = current_state%global_grid%configuration%vertical%prefn(k) / 100.
516 qsat = qsaturation(tdegk,pmb)
518 th_h = tmp_th + rlvap * qv / cp
519 th_h_pr1 = th_pr + rlvap * qv_pr / cp
520 th_h_pr2 = th_h_pr1 * th_h_pr1
524 qv_jip1 = current_state%zq(
iqv)%data(k,j,i+1)
525 qv_jim1 = current_state%zq(
iqv)%data(k,j,i-1)
526 qv_jp1i = current_state%zq(
iqv)%data(k,j+1,i)
527 qv_jm1i = current_state%zq(
iqv)%data(k,j-1,i)
528 ql_jip1 = current_state%zq(
iql)%data(k,j,i+1)
529 ql_jim1 = current_state%zq(
iql)%data(k,j,i-1)
530 ql_jp1i = current_state%zq(
iql)%data(k,j+1,i)
531 ql_jm1i = current_state%zq(
iql)%data(k,j-1,i)
532 qv_pr_jip1 = current_state%zq(
iqv)%data(k,j,i+1)-current_state%global_grid%configuration%vertical%olzqbar(k,
iqv)
533 qv_pr_jim1 = current_state%zq(
iqv)%data(k,j,i-1)-current_state%global_grid%configuration%vertical%olzqbar(k,
iqv)
534 qv_pr_jp1i = current_state%zq(
iqv)%data(k,j+1,i)-current_state%global_grid%configuration%vertical%olzqbar(k,
iqv)
535 qv_pr_jm1i = current_state%zq(
iqv)%data(k,j-1,i)-current_state%global_grid%configuration%vertical%olzqbar(k,
iqv)
542 qli_jip1 = current_state%zq(
iql)%data(k,j,i+1)+0.0
543 qli_jim1 = current_state%zq(
iql)%data(k,j,i-1)+0.0
544 qli_jp1i = current_state%zq(
iql)%data(k,j+1,i)+0.0
545 qli_jm1i = current_state%zq(
iql)%data(k,j-1,i)+0.0
546 qli_pr_jip1 = current_state%zq(
iql)%data(k,j,i+1)-current_state%global_grid%configuration%vertical%olzqbar(k,
iql)+0.0
547 qli_pr_jim1 = current_state%zq(
iql)%data(k,j,i-1)-current_state%global_grid%configuration%vertical%olzqbar(k,
iql)+0.0
548 qli_pr_jp1i = current_state%zq(
iql)%data(k,j+1,i)-current_state%global_grid%configuration%vertical%olzqbar(k,
iql)+0.0
549 qli_pr_jm1i = current_state%zq(
iql)%data(k,j-1,i)-current_state%global_grid%configuration%vertical%olzqbar(k,
iql)+0.0
553 qi_jip1 = current_state%zq(
iqi)%data(k,j,i+1)
554 qi_jim1 = current_state%zq(
iqi)%data(k,j,i-1)
555 qi_jp1i = current_state%zq(
iqi)%data(k,j+1,i)
556 qi_jm1i = current_state%zq(
iqi)%data(k,j-1,i)
557 qli_jip1 = current_state%zq(
iql)%data(k,j,i+1)+current_state%zq(
iqi)%data(k,j,i+1)
558 qli_jim1 = current_state%zq(
iql)%data(k,j,i-1)+current_state%zq(
iqi)%data(k,j,i-1)
559 qli_jp1i = current_state%zq(
iql)%data(k,j+1,i)+current_state%zq(
iqi)%data(k,j+1,i)
560 qli_jm1i = current_state%zq(
iql)%data(k,j-1,i)+current_state%zq(
iqi)%data(k,j-1,i)
561 qli_pr_jip1 = current_state%zq(
iql)%data(k,j,i+1)-current_state%global_grid%configuration%vertical%olzqbar(k,
iql)+ &
562 current_state%zq(
iqi)%data(k,j,i+1)-current_state%global_grid%configuration%vertical%olzqbar(k,
iqi)
563 qli_pr_jim1 = current_state%zq(
iql)%data(k,j,i-1)-current_state%global_grid%configuration%vertical%olzqbar(k,
iql)+ &
564 current_state%zq(
iqi)%data(k,j,i-1)-current_state%global_grid%configuration%vertical%olzqbar(k,
iqi)
565 qli_pr_jp1i = current_state%zq(
iql)%data(k,j+1,i)-current_state%global_grid%configuration%vertical%olzqbar(k,
iql)+ &
566 current_state%zq(
iqi)%data(k,j+1,i)-current_state%global_grid%configuration%vertical%olzqbar(k,
iqi)
567 qli_pr_jm1i = current_state%zq(
iql)%data(k,j-1,i)-current_state%global_grid%configuration%vertical%olzqbar(k,
iql)+ &
568 current_state%zq(
iqi)%data(k,j-1,i)-current_state%global_grid%configuration%vertical%olzqbar(k,
iqi)
571 tmp_th_jip1 = current_state%global_grid%configuration%vertical%thref(k) + current_state%zth%data(k,j,i+1)
572 tmp_th_jim1 = current_state%global_grid%configuration%vertical%thref(k) + current_state%zth%data(k,j,i-1)
573 tmp_th_jp1i = current_state%global_grid%configuration%vertical%thref(k) + current_state%zth%data(k,j+1,i)
574 tmp_th_jm1i = current_state%global_grid%configuration%vertical%thref(k) + current_state%zth%data(k,j-1,i)
575 th_pr_jip1 = current_state%zth%data(k,j,i+1)-current_state%global_grid%configuration%vertical%olzthbar(k)
576 th_pr_jim1 = current_state%zth%data(k,j,i-1)-current_state%global_grid%configuration%vertical%olzthbar(k)
577 th_pr_jp1i = current_state%zth%data(k,j-1,i)-current_state%global_grid%configuration%vertical%olzthbar(k)
578 th_pr_jm1i = current_state%zth%data(k,j+1,i)-current_state%global_grid%configuration%vertical%olzthbar(k)
579 w_zn_jip1 = 0.5*(current_state%zw%data(k,j,i+1)+current_state%zw%data(k-1,j,i+1))
580 w_zn_jim1 = 0.5*(current_state%zw%data(k,j,i-1)+current_state%zw%data(k-1,j,i-1))
581 w_zn_jp1i = 0.5*(current_state%zw%data(k,j+1,i)+current_state%zw%data(k-1,j+1,i))
582 w_zn_jm1i = 0.5*(current_state%zw%data(k,j-1,i)+current_state%zw%data(k-1,j-1,i))
585 thv = tmp_th*(1.0+0.61*qv-qli)
587 thv_pr = th_pr+tmp_th*(0.61*qv_pr-qli_pr)+th_pr*(0.61*qv-qli)
588 wthv_pr = w_zn*thv_pr
590 thv_pr_jip1 = th_pr_jip1+tmp_th_jip1*(0.61*qv_pr_jip1-qli_pr_jip1)+th_pr_jip1*(0.61*qv_jip1-qli_jip1)
591 thv_pr_jim1 = th_pr_jim1+tmp_th_jim1*(0.61*qv_pr_jim1-qli_pr_jim1)+th_pr_jim1*(0.61*qv_jim1-qli_jim1)
592 thv_pr_jp1i = th_pr_jp1i+tmp_th_jp1i*(0.61*qv_pr_jp1i-qli_pr_jp1i)+th_pr_jp1i*(0.61*qv_jp1i-qli_jp1i)
593 thv_pr_jm1i = th_pr_jm1i+tmp_th_jm1i*(0.61*qv_pr_jm1i-qli_pr_jm1i)+th_pr_jm1i*(0.61*qv_jm1i-qli_jm1i)
597 thv = tmp_th*(1.0+0.61*qv)
599 thv_pr = th_pr + 0.61 * tmp_th * qv_pr + 0.61 * qv * th_pr
600 wthv_pr = w_zn * thv_pr
601 thv_pr_jip1 = th_pr_jip1+0.61*tmp_th_jip1*qv_pr_jip1+0.61*qv_jip1*th_pr_jip1
602 thv_pr_jim1 = th_pr_jim1+0.61*tmp_th_jim1*qv_pr_jim1+0.61*qv_jim1*th_pr_jim1
603 thv_pr_jp1i = th_pr_jp1i+0.61*tmp_th_jp1i*qv_pr_jp1i+0.61*qv_jp1i*th_pr_jp1i
604 thv_pr_jm1i = th_pr_jm1i+0.61*tmp_th_jm1i*qv_pr_jm1i+0.61*qv_jm1i*th_pr_jm1i
612 local_diag(1) = 1.0_default_precision
614 local_diag(3) = w_zn2
615 local_diag(4) = tmp_th
617 local_diag(6) = th_pr
618 local_diag(7) = wth_pr
619 local_diag(8) = thv_pr
620 local_diag(9) = wthv_pr
621 local_diag(10) = th_pr2
622 local_diag(11) = wthsg
623 local_diag(12) = w_zn3
624 local_diag(13) = relhum
625 local_diag(14) = tmp_u
626 local_diag(15) = tmp_v
629 local_diag(18) = wusg
630 local_diag(19) = wvsg
631 local_diag(20) = tdegk
632 local_diag(21) = th_h
633 local_diag(22) = th_h_pr1
634 local_diag(23) = th_h_pr2
635 local_diag(24) = qvli
636 local_diag(25) = qvli_pr
637 local_diag(26) = qvli_pr2
638 local_diag(27) = qppt
639 local_diag(28) = qppt_pr
640 local_diag(29) = qppt_pr2
641 local_diag(30) = wqvli_pr
642 local_diag(31) = wqppt_pr
653 call log_master_log(log_error, &
654 "Condition '"//trim(
cond_request(inc))//
"' has not been set up.")
671 l_cond = ( ( (w_zn_jip1 .gt.
wupcrit .and. thv_pr_jip1 .gt.
thvprcrit) .and. &
689 l_cond = ( (w_zn .gt.
wupcrit) .and. &
693 l_cond = ( (w_zn .lt.
wdwncrit) .and. &
718 l_cond = ( ql .gt.
qlcrit )
721 l_cond = ( qi .gt.
qicrit )
733 l_cond = ( (w_zn .gt.
wupcrit) .and. (qvl .gt. qsat) )
736 l_cond = ( (w_zn .gt.
wupcrit) .and. (thv_pr .gt.
thvprcrit) .and. (qvl .gt. qsat) )
739 l_cond = ( (ql .lt.
qlcrit) .and. (qi .lt.
qicrit) .and. &
743 l_cond = ( (ql .lt.
qlcrit) .and. (qi .lt.
qicrit) .and. &
769 type(model_state_type),
target,
intent(inout) :: current_state
770 character(len=*),
intent(in) :: name
771 type(component_field_information_type),
intent(out) :: field_information
774 field_information%field_type=component_array_field_type
775 field_information%number_dimensions=3
776 field_information%dimension_sizes(1) = current_state%local_grid%size(z_index)
777 field_information%dimension_sizes(2) =
ncond * 2
778 field_information%dimension_sizes(3) =
ndiag
780 field_information%data_type = component_double_data_type
782 if (name .eq.
"CondDiags_tot")
then
794 type(model_state_type),
target,
intent(inout) :: current_state
795 character(len=*),
intent(in) :: name
796 type(component_field_value_type),
intent(out) :: field_value
798 if (name .eq.
"CondDiags_tot")
then
799 allocate(field_value%real_3d_array(current_state%local_grid%size(z_index), &