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