1 | !> @file buoyancy.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-2018 Leibniz Universitaet Hannover |
---|
18 | !------------------------------------------------------------------------------! |
---|
19 | ! |
---|
20 | ! Current revisions: |
---|
21 | ! ------------------ |
---|
22 | ! |
---|
23 | ! |
---|
24 | ! Former revisions: |
---|
25 | ! ----------------- |
---|
26 | ! $Id: buoyancy.f90 3294 2018-10-01 02:37:10Z raasch $ |
---|
27 | ! module use statements moved to global declaration section |
---|
28 | ! |
---|
29 | ! 3274 2018-09-24 15:42:55Z knoop |
---|
30 | ! Modularization of all bulk cloud physics code components |
---|
31 | ! |
---|
32 | ! 3241 2018-09-12 15:02:00Z raasch |
---|
33 | ! unused Variable removed |
---|
34 | ! |
---|
35 | ! 2718 2018-01-02 08:49:38Z maronga |
---|
36 | ! Corrected "Former revisions" section |
---|
37 | ! |
---|
38 | ! 2696 2017-12-14 17:12:51Z kanani |
---|
39 | ! Change in file header (GPL part) |
---|
40 | ! |
---|
41 | ! 2233 2017-05-30 18:08:54Z suehring |
---|
42 | ! |
---|
43 | ! 2232 2017-05-30 17:47:52Z suehring |
---|
44 | ! Adjustments to new topography concept |
---|
45 | ! |
---|
46 | ! 2118 2017-01-17 16:38:49Z raasch |
---|
47 | ! OpenACC version of subroutine removed |
---|
48 | ! |
---|
49 | ! 2000 2016-08-20 18:09:15Z knoop |
---|
50 | ! Forced header and separation lines into 80 columns |
---|
51 | ! |
---|
52 | ! 1873 2016-04-18 14:50:06Z maronga |
---|
53 | ! Module renamed (removed _mod) |
---|
54 | ! |
---|
55 | ! |
---|
56 | ! 1850 2016-04-08 13:29:27Z maronga |
---|
57 | ! Module renamed |
---|
58 | ! |
---|
59 | ! 1682 2015-10-07 23:56:08Z knoop |
---|
60 | ! Code annotations made doxygen readable |
---|
61 | ! |
---|
62 | ! 1374 2014-04-25 12:55:07Z raasch |
---|
63 | ! missing variables added to ONLY list |
---|
64 | ! |
---|
65 | ! 1365 2014-04-22 15:03:56Z boeske |
---|
66 | ! Calculation of reference state in subroutine calc_mean_profile moved to |
---|
67 | ! subroutine time_integration, |
---|
68 | ! subroutine calc_mean_profile moved to new file calc_mean_profile.f90 |
---|
69 | ! |
---|
70 | ! 1353 2014-04-08 15:21:23Z heinze |
---|
71 | ! REAL constants provided with KIND-attribute |
---|
72 | ! |
---|
73 | ! 1320 2014-03-20 08:40:49Z raasch |
---|
74 | ! ONLY-attribute added to USE-statements, |
---|
75 | ! kind-parameters added to all INTEGER and REAL declaration statements, |
---|
76 | ! kinds are defined in new module kinds, |
---|
77 | ! revision history before 2012 removed, |
---|
78 | ! comment fields (!:) to be used for variable explanations added to |
---|
79 | ! all variable declaration statements |
---|
80 | ! |
---|
81 | ! 1257 2013-11-08 15:18:40Z raasch |
---|
82 | ! vector length (32) removed from openacc clause |
---|
83 | ! |
---|
84 | ! 1241 2013-10-30 11:36:58Z heinze |
---|
85 | ! Generalize calc_mean_profile for wider use: use additional steering |
---|
86 | ! character loc |
---|
87 | ! |
---|
88 | ! 1179 2013-06-14 05:57:58Z raasch |
---|
89 | ! steering of reference state revised (var_reference and pr removed from |
---|
90 | ! parameter list), use_reference renamed use_single_reference_value |
---|
91 | ! |
---|
92 | ! 1171 2013-05-30 11:27:45Z raasch |
---|
93 | ! openacc statements added to use_reference-case in accelerator version |
---|
94 | ! |
---|
95 | ! 1153 2013-05-10 14:33:08Z raasch |
---|
96 | ! code adjustments of accelerator version required by PGI 12.3 / CUDA 5.0 |
---|
97 | ! |
---|
98 | ! 1128 2013-04-12 06:19:32Z raasch |
---|
99 | ! loop index bounds in accelerator version replaced by i_left, i_right, j_south, |
---|
100 | ! j_north |
---|
101 | ! |
---|
102 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
103 | ! code put under GPL (PALM 3.9) |
---|
104 | ! |
---|
105 | ! 1015 2012-09-27 09:23:24Z raasch |
---|
106 | ! accelerator version (*_acc) added |
---|
107 | ! |
---|
108 | ! 1010 2012-09-20 07:59:54Z raasch |
---|
109 | ! cpp switch __nopointer added for pointer free version |
---|
110 | ! |
---|
111 | ! Revision 1.1 1997/08/29 08:56:48 raasch |
---|
112 | ! Initial revision |
---|
113 | ! |
---|
114 | ! |
---|
115 | ! Description: |
---|
116 | ! ------------ |
---|
117 | !> Buoyancy term of the third component of the equation of motion. |
---|
118 | !> @attention Humidity is not regarded when using a sloping surface! |
---|
119 | !------------------------------------------------------------------------------! |
---|
120 | MODULE buoyancy_mod |
---|
121 | |
---|
122 | USE basic_constants_and_equations_mod, & |
---|
123 | ONLY: g |
---|
124 | |
---|
125 | USE arrays_3d, & |
---|
126 | ONLY: pt, pt_slope_ref, ref_state, tend |
---|
127 | |
---|
128 | USE control_parameters, & |
---|
129 | ONLY: atmos_ocean_sign, cos_alpha_surface, message_string, pt_surface,& |
---|
130 | sin_alpha_surface, sloping_surface |
---|
131 | |
---|
132 | USE kinds |
---|
133 | |
---|
134 | PRIVATE |
---|
135 | PUBLIC buoyancy |
---|
136 | |
---|
137 | INTERFACE buoyancy |
---|
138 | MODULE PROCEDURE buoyancy |
---|
139 | MODULE PROCEDURE buoyancy_ij |
---|
140 | END INTERFACE buoyancy |
---|
141 | |
---|
142 | CONTAINS |
---|
143 | |
---|
144 | |
---|
145 | !------------------------------------------------------------------------------! |
---|
146 | ! Description: |
---|
147 | ! ------------ |
---|
148 | !> Call for all grid points |
---|
149 | !------------------------------------------------------------------------------! |
---|
150 | SUBROUTINE buoyancy( var, wind_component ) |
---|
151 | |
---|
152 | USE indices, & |
---|
153 | ONLY: nxl, nxlg, nxlu, nxr, nxrg, nyn, nyng, nys, nysg, nzb, & |
---|
154 | nzt, wall_flags_0 |
---|
155 | |
---|
156 | |
---|
157 | IMPLICIT NONE |
---|
158 | |
---|
159 | INTEGER(iwp) :: i !< |
---|
160 | INTEGER(iwp) :: j !< |
---|
161 | INTEGER(iwp) :: k !< |
---|
162 | INTEGER(iwp) :: wind_component !< |
---|
163 | |
---|
164 | #if defined( __nopointer ) |
---|
165 | REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg) :: var !< |
---|
166 | #else |
---|
167 | REAL(wp), DIMENSION(:,:,:), POINTER :: var |
---|
168 | #endif |
---|
169 | |
---|
170 | |
---|
171 | IF ( .NOT. sloping_surface ) THEN |
---|
172 | ! |
---|
173 | !-- Normal case: horizontal surface |
---|
174 | DO i = nxl, nxr |
---|
175 | DO j = nys, nyn |
---|
176 | DO k = nzb+1, nzt-1 |
---|
177 | tend(k,j,i) = tend(k,j,i) + atmos_ocean_sign * g * 0.5_wp * & |
---|
178 | ( & |
---|
179 | ( var(k,j,i) - ref_state(k) ) / ref_state(k) + & |
---|
180 | ( var(k+1,j,i) - ref_state(k+1) ) / ref_state(k+1) & |
---|
181 | ) * MERGE( 1.0_wp, 0.0_wp, & |
---|
182 | BTEST( wall_flags_0(k,j,i), 0 ) ) |
---|
183 | ENDDO |
---|
184 | ENDDO |
---|
185 | ENDDO |
---|
186 | |
---|
187 | ELSE |
---|
188 | ! |
---|
189 | !-- Buoyancy term for a surface with a slope in x-direction. The equations |
---|
190 | !-- for both the u and w velocity-component contain proportionate terms. |
---|
191 | !-- Temperature field at time t=0 serves as environmental temperature. |
---|
192 | !-- Reference temperature (pt_surface) is the one at the lower left corner |
---|
193 | !-- of the total domain. |
---|
194 | IF ( wind_component == 1 ) THEN |
---|
195 | |
---|
196 | DO i = nxlu, nxr |
---|
197 | DO j = nys, nyn |
---|
198 | DO k = nzb+1, nzt-1 |
---|
199 | tend(k,j,i) = tend(k,j,i) + g * sin_alpha_surface * & |
---|
200 | 0.5_wp * ( ( pt(k,j,i-1) + pt(k,j,i) ) & |
---|
201 | - ( pt_slope_ref(k,i-1) + pt_slope_ref(k,i) ) & |
---|
202 | ) / pt_surface & |
---|
203 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
204 | BTEST( wall_flags_0(k,j,i), 0 ) ) |
---|
205 | ENDDO |
---|
206 | ENDDO |
---|
207 | ENDDO |
---|
208 | |
---|
209 | ELSEIF ( wind_component == 3 ) THEN |
---|
210 | |
---|
211 | DO i = nxl, nxr |
---|
212 | DO j = nys, nyn |
---|
213 | DO k = nzb+1, nzt-1 |
---|
214 | tend(k,j,i) = tend(k,j,i) + g * cos_alpha_surface * & |
---|
215 | 0.5_wp * ( ( pt(k,j,i) + pt(k+1,j,i) ) & |
---|
216 | - ( pt_slope_ref(k,i) + pt_slope_ref(k+1,i) ) & |
---|
217 | ) / pt_surface & |
---|
218 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
219 | BTEST( wall_flags_0(k,j,i), 0 ) ) |
---|
220 | ENDDO |
---|
221 | ENDDO |
---|
222 | ENDDO |
---|
223 | |
---|
224 | ELSE |
---|
225 | |
---|
226 | WRITE( message_string, * ) 'no term for component "', & |
---|
227 | wind_component,'"' |
---|
228 | CALL message( 'buoyancy', 'PA0159', 1, 2, 0, 6, 0 ) |
---|
229 | |
---|
230 | ENDIF |
---|
231 | |
---|
232 | ENDIF |
---|
233 | |
---|
234 | END SUBROUTINE buoyancy |
---|
235 | |
---|
236 | |
---|
237 | !------------------------------------------------------------------------------! |
---|
238 | ! Description: |
---|
239 | ! ------------ |
---|
240 | !> Call for grid point i,j |
---|
241 | !> @attention PGI-compiler creates SIGFPE if opt>1 is used! Therefore, opt=1 is |
---|
242 | !> forced by compiler-directive. |
---|
243 | !------------------------------------------------------------------------------! |
---|
244 | !pgi$r opt=1 |
---|
245 | SUBROUTINE buoyancy_ij( i, j, var, wind_component ) |
---|
246 | |
---|
247 | |
---|
248 | USE indices, & |
---|
249 | ONLY: nxlg, nxrg, nyng, nysg, nzb, nzt, wall_flags_0 |
---|
250 | |
---|
251 | IMPLICIT NONE |
---|
252 | |
---|
253 | INTEGER(iwp) :: i !< |
---|
254 | INTEGER(iwp) :: j !< |
---|
255 | INTEGER(iwp) :: k !< |
---|
256 | INTEGER(iwp) :: wind_component !< |
---|
257 | |
---|
258 | #if defined( __nopointer ) |
---|
259 | REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg) :: var !< |
---|
260 | #else |
---|
261 | REAL(wp), DIMENSION(:,:,:), POINTER :: var |
---|
262 | #endif |
---|
263 | |
---|
264 | |
---|
265 | IF ( .NOT. sloping_surface ) THEN |
---|
266 | ! |
---|
267 | !-- Normal case: horizontal surface |
---|
268 | DO k = nzb+1, nzt-1 |
---|
269 | tend(k,j,i) = tend(k,j,i) + atmos_ocean_sign * g * 0.5_wp * ( & |
---|
270 | ( var(k,j,i) - ref_state(k) ) / ref_state(k) + & |
---|
271 | ( var(k+1,j,i) - ref_state(k+1) ) / ref_state(k+1) & |
---|
272 | ) & |
---|
273 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
274 | BTEST( wall_flags_0(k,j,i), 0 ) ) |
---|
275 | ENDDO |
---|
276 | |
---|
277 | ELSE |
---|
278 | ! |
---|
279 | !-- Buoyancy term for a surface with a slope in x-direction. The equations |
---|
280 | !-- for both the u and w velocity-component contain proportionate terms. |
---|
281 | !-- Temperature field at time t=0 serves as environmental temperature. |
---|
282 | !-- Reference temperature (pt_surface) is the one at the lower left corner |
---|
283 | !-- of the total domain. |
---|
284 | IF ( wind_component == 1 ) THEN |
---|
285 | |
---|
286 | DO k = nzb+1, nzt-1 |
---|
287 | tend(k,j,i) = tend(k,j,i) + g * sin_alpha_surface * & |
---|
288 | 0.5_wp * ( ( pt(k,j,i-1) + pt(k,j,i) ) & |
---|
289 | - ( pt_slope_ref(k,i-1) + pt_slope_ref(k,i) ) & |
---|
290 | ) / pt_surface & |
---|
291 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
292 | BTEST( wall_flags_0(k,j,i), 0 ) ) |
---|
293 | ENDDO |
---|
294 | |
---|
295 | ELSEIF ( wind_component == 3 ) THEN |
---|
296 | |
---|
297 | DO k = nzb+1, nzt-1 |
---|
298 | tend(k,j,i) = tend(k,j,i) + g * cos_alpha_surface * & |
---|
299 | 0.5_wp * ( ( pt(k,j,i) + pt(k+1,j,i) ) & |
---|
300 | - ( pt_slope_ref(k,i) + pt_slope_ref(k+1,i) ) & |
---|
301 | ) / pt_surface & |
---|
302 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
303 | BTEST( wall_flags_0(k,j,i), 0 ) ) |
---|
304 | ENDDO |
---|
305 | |
---|
306 | ELSE |
---|
307 | |
---|
308 | WRITE( message_string, * ) 'no term for component "', & |
---|
309 | wind_component,'"' |
---|
310 | CALL message( 'buoyancy', 'PA0159', 1, 2, 0, 6, 0 ) |
---|
311 | |
---|
312 | ENDIF |
---|
313 | |
---|
314 | ENDIF |
---|
315 | |
---|
316 | END SUBROUTINE buoyancy_ij |
---|
317 | |
---|
318 | END MODULE buoyancy_mod |
---|