1 | !> @file advec_w_up.f90 |
---|
2 | !------------------------------------------------------------------------------! |
---|
3 | ! This file is part of the PALM model system. |
---|
4 | ! |
---|
5 | ! PALM is free software: you can redistribute it and/or modify it under the |
---|
6 | ! terms of the GNU General Public License as published by the Free Software |
---|
7 | ! Foundation, either version 3 of the License, or (at your option) any later |
---|
8 | ! version. |
---|
9 | ! |
---|
10 | ! PALM is distributed in the hope that it will be useful, but WITHOUT ANY |
---|
11 | ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR |
---|
12 | ! A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
---|
13 | ! |
---|
14 | ! You should have received a copy of the GNU General Public License along with |
---|
15 | ! PALM. If not, see <http://www.gnu.org/licenses/>. |
---|
16 | ! |
---|
17 | ! Copyright 1997-2019 Leibniz Universitaet Hannover |
---|
18 | !------------------------------------------------------------------------------! |
---|
19 | ! |
---|
20 | ! Current revisions: |
---|
21 | ! ----------------- |
---|
22 | ! |
---|
23 | ! |
---|
24 | ! Former revisions: |
---|
25 | ! ----------------- |
---|
26 | ! $Id: advec_w_up.f90 4180 2019-08-21 14:37:54Z scharf $ |
---|
27 | ! variables documented |
---|
28 | ! |
---|
29 | ! |
---|
30 | ! Description: |
---|
31 | ! ------------ |
---|
32 | !> Advection term for the w velocity-component using upstream scheme. |
---|
33 | !> NOTE: vertical advection at k=1 still has wrong grid spacing for w>0 |
---|
34 | !> The same problem occurs for all topography boundaries! |
---|
35 | !------------------------------------------------------------------------------! |
---|
36 | MODULE advec_w_up_mod |
---|
37 | |
---|
38 | |
---|
39 | PRIVATE |
---|
40 | PUBLIC advec_w_up |
---|
41 | |
---|
42 | INTERFACE advec_w_up |
---|
43 | MODULE PROCEDURE advec_w_up |
---|
44 | MODULE PROCEDURE advec_w_up_ij |
---|
45 | END INTERFACE advec_w_up |
---|
46 | |
---|
47 | CONTAINS |
---|
48 | |
---|
49 | |
---|
50 | !------------------------------------------------------------------------------! |
---|
51 | ! Description: |
---|
52 | ! ------------ |
---|
53 | !> Call for all grid points |
---|
54 | !------------------------------------------------------------------------------! |
---|
55 | SUBROUTINE advec_w_up |
---|
56 | |
---|
57 | USE arrays_3d, & |
---|
58 | ONLY: ddzw, tend, u, v, w |
---|
59 | |
---|
60 | USE control_parameters, & |
---|
61 | ONLY: u_gtrans, v_gtrans |
---|
62 | |
---|
63 | USE grid_variables, & |
---|
64 | ONLY: ddx, ddy |
---|
65 | |
---|
66 | USE indices, & |
---|
67 | ONLY: nxl, nxr, nyn, nys, nzb, nzt |
---|
68 | |
---|
69 | USE kinds |
---|
70 | |
---|
71 | |
---|
72 | IMPLICIT NONE |
---|
73 | |
---|
74 | INTEGER(iwp) :: i !< grid index along x-direction |
---|
75 | INTEGER(iwp) :: j !< grid index along y-direction |
---|
76 | INTEGER(iwp) :: k !< grid index along z-direction |
---|
77 | |
---|
78 | REAL(wp) :: ukomp !< advection velocity along x-direction |
---|
79 | REAL(wp) :: vkomp !< advection velocity along y-direction |
---|
80 | |
---|
81 | |
---|
82 | DO i = nxl, nxr |
---|
83 | DO j = nys, nyn |
---|
84 | DO k = nzb+1, nzt-1 |
---|
85 | ! |
---|
86 | !-- x-direction |
---|
87 | ukomp = 0.25_wp * ( u(k,j,i) + u(k,j,i+1) + & |
---|
88 | u(k+1,j,i) + u(k+1,j,i+1) ) - u_gtrans |
---|
89 | IF ( ukomp > 0.0_wp ) THEN |
---|
90 | tend(k,j,i) = tend(k,j,i) - ukomp * & |
---|
91 | ( w(k,j,i) - w(k,j,i-1) ) * ddx |
---|
92 | ELSE |
---|
93 | tend(k,j,i) = tend(k,j,i) - ukomp * & |
---|
94 | ( w(k,j,i+1) - w(k,j,i) ) * ddx |
---|
95 | ENDIF |
---|
96 | ! |
---|
97 | !-- y-direction |
---|
98 | vkomp = 0.25_wp * ( v(k,j,i) + v(k,j+1,i) + & |
---|
99 | v(k+1,j,i) + v(k+1,j+1,i) ) - v_gtrans |
---|
100 | IF ( vkomp > 0.0_wp ) THEN |
---|
101 | tend(k,j,i) = tend(k,j,i) - vkomp * & |
---|
102 | ( w(k,j,i) - w(k,j-1,i) ) * ddy |
---|
103 | ELSE |
---|
104 | tend(k,j,i) = tend(k,j,i) - vkomp * & |
---|
105 | ( w(k,j+1,i) - w(k,j,i) ) * ddy |
---|
106 | ENDIF |
---|
107 | ! |
---|
108 | !-- z-direction |
---|
109 | IF ( w(k,j,i) > 0.0_wp ) THEN |
---|
110 | tend(k,j,i) = tend(k,j,i) - w(k,j,i) * & |
---|
111 | ( w(k,j,i) - w(k-1,j,i) ) * ddzw(k) |
---|
112 | ELSE |
---|
113 | tend(k,j,i) = tend(k,j,i) - w(k,j,i) * & |
---|
114 | ( w(k+1,j,i) - w(k,j,i) ) * ddzw(k+1) |
---|
115 | ENDIF |
---|
116 | |
---|
117 | ENDDO |
---|
118 | ENDDO |
---|
119 | ENDDO |
---|
120 | |
---|
121 | END SUBROUTINE advec_w_up |
---|
122 | |
---|
123 | |
---|
124 | !------------------------------------------------------------------------------! |
---|
125 | ! Description: |
---|
126 | ! ------------ |
---|
127 | !> Call for grid point i,j |
---|
128 | !------------------------------------------------------------------------------! |
---|
129 | SUBROUTINE advec_w_up_ij( i, j ) |
---|
130 | |
---|
131 | USE arrays_3d, & |
---|
132 | ONLY: ddzw, tend, u, v, w |
---|
133 | |
---|
134 | USE control_parameters, & |
---|
135 | ONLY: u_gtrans, v_gtrans |
---|
136 | |
---|
137 | USE grid_variables, & |
---|
138 | ONLY: ddx, ddy |
---|
139 | |
---|
140 | USE indices, & |
---|
141 | ONLY: nzb, nzt |
---|
142 | |
---|
143 | USE kinds |
---|
144 | |
---|
145 | |
---|
146 | IMPLICIT NONE |
---|
147 | |
---|
148 | INTEGER(iwp) :: i !< grid index along x-direction |
---|
149 | INTEGER(iwp) :: j !< grid index along y-direction |
---|
150 | INTEGER(iwp) :: k !< grid index along z-direction |
---|
151 | |
---|
152 | REAL(wp) :: ukomp !< advection velocity along x-direction |
---|
153 | REAL(wp) :: vkomp !< advection velocity along y-direction |
---|
154 | |
---|
155 | |
---|
156 | DO k = nzb+1, nzt-1 |
---|
157 | ! |
---|
158 | !-- x-direction |
---|
159 | ukomp = 0.25_wp * ( u(k,j,i) + u(k,j,i+1) + u(k+1,j,i) + u(k+1,j,i+1) & |
---|
160 | ) - u_gtrans |
---|
161 | IF ( ukomp > 0.0_wp ) THEN |
---|
162 | tend(k,j,i) = tend(k,j,i) - ukomp * & |
---|
163 | ( w(k,j,i) - w(k,j,i-1) ) * ddx |
---|
164 | ELSE |
---|
165 | tend(k,j,i) = tend(k,j,i) - ukomp * & |
---|
166 | ( w(k,j,i+1) - w(k,j,i) ) * ddx |
---|
167 | ENDIF |
---|
168 | ! |
---|
169 | !-- y-direction |
---|
170 | vkomp = 0.25_wp * ( v(k,j,i) + v(k,j+1,i) + v(k+1,j,i) + v(k+1,j+1,i) & |
---|
171 | ) - v_gtrans |
---|
172 | IF ( vkomp > 0.0_wp ) THEN |
---|
173 | tend(k,j,i) = tend(k,j,i) - vkomp * & |
---|
174 | ( w(k,j,i) - w(k,j-1,i) ) * ddy |
---|
175 | ELSE |
---|
176 | tend(k,j,i) = tend(k,j,i) - vkomp * & |
---|
177 | ( w(k,j+1,i) - w(k,j,i) ) * ddy |
---|
178 | ENDIF |
---|
179 | ! |
---|
180 | !-- z-direction |
---|
181 | IF ( w(k,j,i) > 0.0_wp ) THEN |
---|
182 | tend(k,j,i) = tend(k,j,i) - w(k,j,i) * & |
---|
183 | ( w(k,j,i) - w(k-1,j,i) ) * ddzw(k) |
---|
184 | ELSE |
---|
185 | tend(k,j,i) = tend(k,j,i) - w(k,j,i) * & |
---|
186 | ( w(k+1,j,i) - w(k,j,i) ) * ddzw(k+1) |
---|
187 | ENDIF |
---|
188 | |
---|
189 | ENDDO |
---|
190 | |
---|
191 | END SUBROUTINE advec_w_up_ij |
---|
192 | |
---|
193 | END MODULE advec_w_up_mod |
---|