Near it, but not it.
Record the value for this diagnostic meeting this condition and its complement by adding to cumulative sum
375 type(model_state_type),
target,
intent(inout) :: current_state
378 real(kind=
default_precision),
dimension(size(master_diagnostics_list)) :: local_diag
388 real(kind=
default_precision) :: w_zn2, w_zn3, wu, wv, wusg, wvsg, wqvli_pr,wqppt_pr
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
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
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
410 conddiags_tot(:,:,:) = 0.0_default_precision
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
418 if (.not. mod(current_state%timestep, diagnostic_generation_frequency) == 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)
433 if (.not. l_qi_qr_qs_qg) then
440 qvli_pr = qv_pr + ql_pr
444 if (l_qi_qr_qs_qg) then
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)
537 if (.not. l_qi_qr_qs_qg) then
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
552 if (l_qi_qr_qs_qg) then
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))
584 if (thv_from_th_with_liqice)
then
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)
596 if (.not. thv_from_th_with_liqice)
then
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
650 SELECT CASE ( trim(cond_request(inc)) )
654 "Condition '"//trim(cond_request(inc))//
"' has not been set up.")
660 l_cond = ( (w_zn .gt. wupcrit) .and. (thv_pr .gt. thvprcrit) )
663 l_cond = ( (w_zn .gt. wupcrit .and. thv_pr .gt. thvprcrit ) .and. &
664 ( ql .gt. qlcrit .or. qi .gt. qicrit ) )
668 if ( .not. ( (w_zn .gt. wupcrit .and. thv_pr .gt. thvprcrit ) .and. &
669 ( ql .gt. qlcrit .or. qi .gt. qicrit ) ) ) then
671 l_cond = ( ( (w_zn_jip1 .gt. wupcrit .and. thv_pr_jip1 .gt. thvprcrit) .and. &
672 (ql_jip1 .gt. qlcrit .or. qi_jip1 .gt. qicrit) ) &
674 ( (w_zn_jim1 .gt. wupcrit .and. thv_pr_jim1 .gt. thvprcrit) .and. &
675 (ql_jim1 .gt. qlcrit .or. qi_jim1 .gt. qicrit) ) &
677 ( (w_zn_jp1i .gt. wupcrit .and. thv_pr_jp1i .gt. thvprcrit) .and. &
678 (ql_jp1i .gt. qlcrit .or. qi_jp1i .gt. qicrit) ) &
680 ( (w_zn_jm1i .gt. wupcrit .and. thv_pr_jm1i .gt. thvprcrit) .and. &
681 (ql_jm1i .gt. qlcrit .or. qi_jm1i .gt. qicrit) ) )
686 l_cond = ( (ql .gt. qlcrit) .or. (qi .gt. qicrit) )
689 l_cond = ( (w_zn .gt. wupcrit) .and. &
690 ( (ql .gt. qlcrit) .or. (qi .gt. qicrit) ) )
693 l_cond = ( (w_zn .lt. wdwncrit) .and. &
694 ( (ql .gt. qlcrit) .or. (qi .gt. qicrit) ) )
697 l_cond = ( w_zn .gt. wsupcrit )
700 l_cond = ( w_zn .lt. wsdwncrit )
703 l_cond = ( w_zn .gt. wupcrit )
706 l_cond = ( w_zn .lt. wdwncrit )
709 l_cond = ( (w_zn .gt. wupcrit) .and. (ql .gt. qlcrit) )
712 l_cond = ( (w_zn .lt. wdwncrit) .and. (ql .gt. qlcrit) )
715 l_cond = ( (ql .gt. qlcrit) .or. (qi .gt. qicrit) .or. (qppt .gt. qpptcrit) )
718 l_cond = ( ql .gt. qlcrit )
721 l_cond = ( qi .gt. qicrit )
724 l_cond = ( (w_zn .lt. wdwncrit) .and. (qppt .gt. qpptcrit) )
727 l_cond = ( (w_zn .lt. wdwncrit) .and. (qppt .gt. vpptcrit) )
730 l_cond = ( (w_zn .lt. wsdwncrit) .and. (qppt .gt. qpptcrit) )
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. &
740 (w_zn .lt. wdwncrit) .and. (qppt .gt. qpptcrit) )
743 l_cond = ( (ql .lt. qlcrit) .and. (qi .lt. qicrit) .and. &
744 (w_zn .lt. wdwncrit) .and. (qppt .gt. vpptcrit) )
751 conddiags_tot(k,inc,:) = conddiags_tot(k,inc,:) + local_diag(diag_locations)
753 conddiags_tot(k,ncond+inc,:) = conddiags_tot(k,ncond+inc,:) + local_diag(diag_locations)