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