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