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