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