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