← Back to Documentation Home
CCPP SciDoc v8.0.0  v8.0.0
Common Community Physics Package Developed at DTC
 
Loading...
Searching...
No Matches
mynnedmf_wrapper_post.F90
1! #########################################################################################
4! #########################################################################################
5module mynnedmf_wrapper_post
6 use machine, only: kind_phys
7 implicit none
8contains
9
10! #########################################################################################
14! #########################################################################################
15 subroutine mynnedmf_wrapper_post_run (tend_opt_pbl, im, levs, ntrac, &
16 dtp, ten_t, ten_u, ten_v, ten_q, ten_t_pbl, ten_q_pbl, gt0, gu0, gv0, gq0, dtdt, dudt, dvdt, dqdt, &
17 errmsg, errflg)
18
19 ! Inputs
20 integer, intent(in) :: tend_opt_pbl, im, levs, ntrac
21 real(kind=kind_phys), intent(in) :: dtp
22 real(kind=kind_phys), intent(in), dimension(:,:) :: ten_u, ten_v, ten_t
23 real(kind=kind_phys), intent(out),dimension(:,:) :: ten_t_pbl,ten_q_pbl
24 real(kind=kind_phys), intent(in), dimension(:,:,:) :: ten_q
25 real(kind=kind_phys), intent(inout), dimension(:,:) :: gt0, gu0, gv0
26 real(kind=kind_phys), intent(inout), dimension(:,:,:) :: gq0
27 real(kind=kind_phys), intent(inout), dimension(:,:) :: dtdt, dudt, dvdt
28 real(kind=kind_phys), intent(inout), dimension(:,:,:) :: dqdt
29
30 ! Outputs
31 character(len=*), intent(out) :: &
32 errmsg ! CCPP Error message.
33 integer, intent(out) :: &
34 errflg ! CCPP Error flag.
35
36 ! Locals
37 integer :: i,k,n
38
39 ! Initialize CCPP error handling variables
40 errmsg = ''
41 errflg = 0
42
43 case_pbl_ten: select case (tend_opt_pbl)
44 case (1) !immediately apply tendencies
45 !Current state = current state + dt*current tendency
46 !Accumulated tendency unchanged
47 do k=1,levs
48 do i=1,im
49 gt0(i,k) = gt0(i,k) + dtp*ten_t(i,k)
50 gu0(i,k) = gu0(i,k) + dtp*ten_u(i,k)
51 gv0(i,k) = gv0(i,k) + dtp*ten_v(i,k)
52 do n = 1, ntrac
53 gq0(i,k,n) = gq0(i,k,n) + dtp*ten_q(i,k,n)
54 end do
55 end do
56 end do
57 case (2) !add tendencies to sum
58 !Accumulated tendency = accumulated tendency + current tendency
59 !Current state unchanged
60 do k=1,levs
61 do i=1,im
62 dtdt(i,k) = dtdt(i,k) + ten_t(i,k)
63 dudt(i,k) = dudt(i,k) + ten_u(i,k)
64 dvdt(i,k) = dvdt(i,k) + ten_v(i,k)
65 do n = 1, ntrac
66 dqdt(i,k,n) = dqdt(i,k,n) + ten_q(i,k,n)
67 end do
68 end do
69 end do
70 case (3) !add tendencies to sum and apply
71 !Current state = current state + dt*(accumulated tendency + current tendency)
72 !Accumulated tendency = 0
73 do k=1,levs
74 do i=1,im
75 gt0(i,k) = gt0(i,k) + dtp*(dtdt(i,k) + ten_t(i,k))
76 dtdt(i,k) = 0.0
77 gu0(i,k) = gu0(i,k) + dtp*(dudt(i,k) + ten_u(i,k))
78 dudt(i,k) = 0.0
79 gv0(i,k) = gv0(i,k) + dtp*(dvdt(i,k) + ten_v(i,k))
80 dvdt(i,k) = 0.0
81 do n = 1, ntrac
82 gq0(i,k,n) = gq0(i,k,n) + dtp*(dqdt(i,k,n) + ten_q(i,k,n))
83 dqdt(i,k,n) = 0.0
84 end do
85 end do
86 end do
87 case (4) !Current state unchanged
88 !Accumulated tendency unchanged
89 !Current tendency unchanged (but will be overwritten during next primary scheme)
90 exit case_pbl_ten
91 case default
92 errflg = 1
93 errmsg = 'A tendency application control was outside of the acceptable range (1-4)'
94 return
95 end select case_pbl_ten
96
97 ten_t_pbl(:,:)=0.
98 ten_q_pbl(:,:)=0.
99
100 !Output t and q tenedncies for PBL only to be used
101 !as input in other schemes
102 do k=1,levs
103 do i=1,im
104 ten_t_pbl(i,k)=ten_t(i,k)
105 ten_q_pbl(i,k)=ten_q(i,k,1)
106 end do
107 end do
108
109 end subroutine mynnedmf_wrapper_post_run
110
111end module mynnedmf_wrapper_post