[1873] | 1 | !> @file buoyancy.f90 |
---|
[4542] | 2 | !--------------------------------------------------------------------------------------------------! |
---|
[2696] | 3 | ! This file is part of the PALM model system. |
---|
[1036] | 4 | ! |
---|
[4542] | 5 | ! PALM is free software: you can redistribute it and/or modify it under the terms of the GNU General |
---|
| 6 | ! Public License as published by the Free Software Foundation, either version 3 of the License, or |
---|
| 7 | ! (at your option) any later version. |
---|
[1036] | 8 | ! |
---|
[4542] | 9 | ! PALM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the |
---|
| 10 | ! implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General |
---|
| 11 | ! Public License for more details. |
---|
[1036] | 12 | ! |
---|
[4542] | 13 | ! You should have received a copy of the GNU General Public License along with PALM. If not, see |
---|
| 14 | ! <http://www.gnu.org/licenses/>. |
---|
[1036] | 15 | ! |
---|
[4542] | 16 | ! |
---|
[4360] | 17 | ! Copyright 1997-2020 Leibniz Universitaet Hannover |
---|
[4542] | 18 | !--------------------------------------------------------------------------------------------------! |
---|
[1036] | 19 | ! |
---|
[1328] | 20 | ! Current revisions: |
---|
[1179] | 21 | ! ------------------ |
---|
[1354] | 22 | ! |
---|
[2233] | 23 | ! |
---|
[1321] | 24 | ! Former revisions: |
---|
| 25 | ! ----------------- |
---|
| 26 | ! $Id: buoyancy.f90 4542 2020-05-19 15:45:12Z schwenkel $ |
---|
[4542] | 27 | ! file re-formatted to follow the PALM coding standard |
---|
| 28 | ! |
---|
| 29 | ! 4360 2020-01-07 11:25:50Z suehring |
---|
[4182] | 30 | ! Corrected "Former revisions" section |
---|
[4542] | 31 | ! |
---|
[4182] | 32 | ! 3725 2019-02-07 10:11:02Z raasch |
---|
[3725] | 33 | ! unused variables removed |
---|
[4542] | 34 | ! |
---|
[3725] | 35 | ! 3655 2019-01-07 16:51:22Z knoop |
---|
[3636] | 36 | ! nopointer option removed |
---|
[3241] | 37 | ! |
---|
[4182] | 38 | ! Revision 1.1 1997/08/29 08:56:48 raasch |
---|
| 39 | ! Initial revision |
---|
| 40 | ! |
---|
| 41 | ! |
---|
[1] | 42 | ! Description: |
---|
| 43 | ! ------------ |
---|
[1682] | 44 | !> Buoyancy term of the third component of the equation of motion. |
---|
| 45 | !> @attention Humidity is not regarded when using a sloping surface! |
---|
[4542] | 46 | !--------------------------------------------------------------------------------------------------! |
---|
[1682] | 47 | MODULE buoyancy_mod |
---|
[1] | 48 | |
---|
[4542] | 49 | USE basic_constants_and_equations_mod, & |
---|
[3274] | 50 | ONLY: g |
---|
| 51 | |
---|
[4542] | 52 | USE arrays_3d, & |
---|
[3294] | 53 | ONLY: pt, pt_slope_ref, ref_state, tend |
---|
| 54 | |
---|
[4542] | 55 | USE control_parameters, & |
---|
| 56 | ONLY: atmos_ocean_sign, cos_alpha_surface, message_string, pt_surface, sin_alpha_surface, & |
---|
| 57 | sloping_surface |
---|
[3294] | 58 | |
---|
| 59 | USE kinds |
---|
| 60 | |
---|
[1] | 61 | PRIVATE |
---|
[2118] | 62 | PUBLIC buoyancy |
---|
[1] | 63 | |
---|
| 64 | INTERFACE buoyancy |
---|
| 65 | MODULE PROCEDURE buoyancy |
---|
| 66 | MODULE PROCEDURE buoyancy_ij |
---|
| 67 | END INTERFACE buoyancy |
---|
| 68 | |
---|
| 69 | CONTAINS |
---|
| 70 | |
---|
| 71 | |
---|
[4542] | 72 | !--------------------------------------------------------------------------------------------------! |
---|
[1682] | 73 | ! Description: |
---|
| 74 | ! ------------ |
---|
| 75 | !> Call for all grid points |
---|
[4542] | 76 | !--------------------------------------------------------------------------------------------------! |
---|
[1179] | 77 | SUBROUTINE buoyancy( var, wind_component ) |
---|
[1] | 78 | |
---|
[4542] | 79 | USE indices, & |
---|
[3725] | 80 | ONLY: nxl, nxlu, nxr, nyn, nys, nzb, nzt |
---|
[1320] | 81 | |
---|
| 82 | |
---|
[1] | 83 | IMPLICIT NONE |
---|
| 84 | |
---|
[1682] | 85 | INTEGER(iwp) :: i !< |
---|
| 86 | INTEGER(iwp) :: j !< |
---|
| 87 | INTEGER(iwp) :: k !< |
---|
| 88 | INTEGER(iwp) :: wind_component !< |
---|
[4542] | 89 | |
---|
[1320] | 90 | REAL(wp), DIMENSION(:,:,:), POINTER :: var |
---|
[1] | 91 | |
---|
| 92 | |
---|
| 93 | IF ( .NOT. sloping_surface ) THEN |
---|
| 94 | ! |
---|
| 95 | !-- Normal case: horizontal surface |
---|
[3634] | 96 | !$ACC PARALLEL LOOP COLLAPSE(3) PRIVATE(i, j, k) & |
---|
| 97 | !$ACC PRESENT(var) & |
---|
| 98 | !$ACC PRESENT(ref_state) & |
---|
| 99 | !$ACC PRESENT(tend) |
---|
[1179] | 100 | DO i = nxl, nxr |
---|
| 101 | DO j = nys, nyn |
---|
[2232] | 102 | DO k = nzb+1, nzt-1 |
---|
[4542] | 103 | tend(k,j,i) = tend(k,j,i) + atmos_ocean_sign * g * 0.5_wp * & |
---|
| 104 | ( & |
---|
| 105 | ( var(k,j,i) - ref_state(k) ) / ref_state(k) + & |
---|
| 106 | ( var(k+1,j,i) - ref_state(k+1) ) / ref_state(k+1) & |
---|
| 107 | ) |
---|
[57] | 108 | ENDDO |
---|
| 109 | ENDDO |
---|
[1179] | 110 | ENDDO |
---|
[1] | 111 | |
---|
| 112 | ELSE |
---|
| 113 | ! |
---|
[4542] | 114 | !-- Buoyancy term for a surface with a slope in x-direction. The equations for both the u and |
---|
| 115 | ! w velocity-component contain proportionate terms. |
---|
[1] | 116 | !-- Temperature field at time t=0 serves as environmental temperature. |
---|
[4542] | 117 | !-- Reference temperature (pt_surface) is the one at the lower left corner of the total |
---|
| 118 | !-- domain. |
---|
[1] | 119 | IF ( wind_component == 1 ) THEN |
---|
| 120 | |
---|
[106] | 121 | DO i = nxlu, nxr |
---|
[1] | 122 | DO j = nys, nyn |
---|
[2232] | 123 | DO k = nzb+1, nzt-1 |
---|
[4542] | 124 | tend(k,j,i) = tend(k,j,i) + g * sin_alpha_surface * & |
---|
| 125 | 0.5_wp * ( ( pt(k,j,i-1) + pt(k,j,i) ) & |
---|
| 126 | - ( pt_slope_ref(k,i-1) + pt_slope_ref(k,i) ) & |
---|
| 127 | ) / pt_surface |
---|
[1] | 128 | ENDDO |
---|
| 129 | ENDDO |
---|
| 130 | ENDDO |
---|
| 131 | |
---|
| 132 | ELSEIF ( wind_component == 3 ) THEN |
---|
| 133 | |
---|
| 134 | DO i = nxl, nxr |
---|
| 135 | DO j = nys, nyn |
---|
[2232] | 136 | DO k = nzb+1, nzt-1 |
---|
[4542] | 137 | tend(k,j,i) = tend(k,j,i) + g * cos_alpha_surface * & |
---|
| 138 | 0.5_wp * ( ( pt(k,j,i) + pt(k+1,j,i) ) & |
---|
| 139 | - ( pt_slope_ref(k,i) + pt_slope_ref(k+1,i) ) & |
---|
| 140 | ) / pt_surface |
---|
[1] | 141 | ENDDO |
---|
| 142 | ENDDO |
---|
| 143 | ENDDO |
---|
| 144 | |
---|
| 145 | ELSE |
---|
[4542] | 146 | |
---|
| 147 | WRITE( message_string, * ) 'no term for component "', wind_component, '"' |
---|
[247] | 148 | CALL message( 'buoyancy', 'PA0159', 1, 2, 0, 6, 0 ) |
---|
[1] | 149 | |
---|
| 150 | ENDIF |
---|
| 151 | |
---|
| 152 | ENDIF |
---|
| 153 | |
---|
| 154 | END SUBROUTINE buoyancy |
---|
| 155 | |
---|
| 156 | |
---|
[4542] | 157 | !--------------------------------------------------------------------------------------------------! |
---|
[1682] | 158 | ! Description: |
---|
| 159 | ! ------------ |
---|
| 160 | !> Call for grid point i,j |
---|
[4542] | 161 | !> @attention PGI-compiler creates SIGFPE if opt>1 is used! Therefore, opt=1 is forced by |
---|
| 162 | !> compiler-directive. |
---|
| 163 | !--------------------------------------------------------------------------------------------------! |
---|
[515] | 164 | !pgi$r opt=1 |
---|
[1179] | 165 | SUBROUTINE buoyancy_ij( i, j, var, wind_component ) |
---|
[1] | 166 | |
---|
[1320] | 167 | |
---|
[4542] | 168 | USE indices, & |
---|
[3725] | 169 | ONLY: nzb, nzt |
---|
[1320] | 170 | |
---|
[1] | 171 | IMPLICIT NONE |
---|
| 172 | |
---|
[1682] | 173 | INTEGER(iwp) :: i !< |
---|
| 174 | INTEGER(iwp) :: j !< |
---|
| 175 | INTEGER(iwp) :: k !< |
---|
| 176 | INTEGER(iwp) :: wind_component !< |
---|
[4542] | 177 | |
---|
[1320] | 178 | REAL(wp), DIMENSION(:,:,:), POINTER :: var |
---|
[1] | 179 | |
---|
| 180 | |
---|
| 181 | IF ( .NOT. sloping_surface ) THEN |
---|
| 182 | ! |
---|
| 183 | !-- Normal case: horizontal surface |
---|
[2232] | 184 | DO k = nzb+1, nzt-1 |
---|
[4542] | 185 | tend(k,j,i) = tend(k,j,i) + atmos_ocean_sign * g * 0.5_wp * ( & |
---|
| 186 | ( var(k,j,i) - ref_state(k) ) / ref_state(k) + & |
---|
| 187 | ( var(k+1,j,i) - ref_state(k+1) ) / ref_state(k+1) & |
---|
[3538] | 188 | ) |
---|
[1179] | 189 | ENDDO |
---|
[1] | 190 | |
---|
| 191 | ELSE |
---|
| 192 | ! |
---|
[4542] | 193 | !-- Buoyancy term for a surface with a slope in x-direction. The equations for both the u and |
---|
| 194 | !-- w velocity-component contain proportionate terms. |
---|
[1] | 195 | !-- Temperature field at time t=0 serves as environmental temperature. |
---|
[4542] | 196 | !-- Reference temperature (pt_surface) is the one at the lower left corner of the total |
---|
| 197 | !-- domain. |
---|
[1] | 198 | IF ( wind_component == 1 ) THEN |
---|
| 199 | |
---|
[2232] | 200 | DO k = nzb+1, nzt-1 |
---|
[4542] | 201 | tend(k,j,i) = tend(k,j,i) + g * sin_alpha_surface * & |
---|
| 202 | 0.5_wp * ( ( pt(k,j,i-1) + pt(k,j,i) ) & |
---|
| 203 | - ( pt_slope_ref(k,i-1) + pt_slope_ref(k,i) ) & |
---|
| 204 | ) / pt_surface |
---|
[1] | 205 | ENDDO |
---|
| 206 | |
---|
| 207 | ELSEIF ( wind_component == 3 ) THEN |
---|
| 208 | |
---|
[2232] | 209 | DO k = nzb+1, nzt-1 |
---|
[4542] | 210 | tend(k,j,i) = tend(k,j,i) + g * cos_alpha_surface * & |
---|
| 211 | 0.5_wp * ( ( pt(k,j,i) + pt(k+1,j,i) ) & |
---|
| 212 | - ( pt_slope_ref(k,i) + pt_slope_ref(k+1,i) ) & |
---|
| 213 | ) / pt_surface |
---|
[1] | 214 | ENDDO |
---|
| 215 | |
---|
| 216 | ELSE |
---|
| 217 | |
---|
[4542] | 218 | WRITE( message_string, * ) 'no term for component "', wind_component, '"' |
---|
[247] | 219 | CALL message( 'buoyancy', 'PA0159', 1, 2, 0, 6, 0 ) |
---|
[1] | 220 | |
---|
| 221 | ENDIF |
---|
| 222 | |
---|
| 223 | ENDIF |
---|
| 224 | |
---|
| 225 | END SUBROUTINE buoyancy_ij |
---|
| 226 | |
---|
| 227 | END MODULE buoyancy_mod |
---|