[1682] | 1 | !> @file diffusivities.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 | ! |
---|
[484] | 20 | ! Current revisions: |
---|
[1] | 21 | ! ----------------- |
---|
[2001] | 22 | ! |
---|
[2119] | 23 | ! |
---|
[1321] | 24 | ! Former revisions: |
---|
| 25 | ! ----------------- |
---|
| 26 | ! $Id: diffusivities.f90 2119 2017-01-17 16:51:50Z hellstea $ |
---|
| 27 | ! |
---|
[2119] | 28 | ! 2118 2017-01-17 16:38:49Z raasch |
---|
| 29 | ! OpenACC directives removed |
---|
| 30 | ! |
---|
[2032] | 31 | ! 2031 2016-10-21 15:11:58Z knoop |
---|
| 32 | ! renamed variable rho to rho_ocean |
---|
| 33 | ! |
---|
[2001] | 34 | ! 2000 2016-08-20 18:09:15Z knoop |
---|
| 35 | ! Forced header and separation lines into 80 columns |
---|
| 36 | ! |
---|
[1712] | 37 | ! 1711 2015-11-05 07:38:04Z raasch |
---|
| 38 | ! bugfix: loop moved into IF block to avoid usage of l without being defined |
---|
| 39 | ! |
---|
[1683] | 40 | ! 1682 2015-10-07 23:56:08Z knoop |
---|
| 41 | ! Code annotations made doxygen readable |
---|
| 42 | ! |
---|
[1375] | 43 | ! 1374 2014-04-25 12:55:07Z raasch |
---|
| 44 | ! rif removed from acc-present-list |
---|
| 45 | ! |
---|
[1354] | 46 | ! 1353 2014-04-08 15:21:23Z heinze |
---|
| 47 | ! REAL constants provided with KIND-attribute |
---|
| 48 | ! |
---|
[1341] | 49 | ! 1340 2014-03-25 19:45:13Z kanani |
---|
| 50 | ! REAL constants defined as wp-kind |
---|
| 51 | ! |
---|
[1323] | 52 | ! 1322 2014-03-20 16:38:49Z raasch |
---|
| 53 | ! REAL constants defined as wp-kind |
---|
| 54 | ! |
---|
[1321] | 55 | ! 1320 2014-03-20 08:40:49Z raasch |
---|
[1320] | 56 | ! ONLY-attribute added to USE-statements, |
---|
| 57 | ! kind-parameters added to all INTEGER and REAL declaration statements, |
---|
| 58 | ! kinds are defined in new module kinds, |
---|
| 59 | ! revision history before 2012 removed, |
---|
| 60 | ! comment fields (!:) to be used for variable explanations added to |
---|
| 61 | ! all variable declaration statements |
---|
[1017] | 62 | ! |
---|
[1182] | 63 | ! 1179 2013-06-14 05:57:58Z raasch |
---|
| 64 | ! use_reference renamed use_single_reference_value |
---|
| 65 | ! |
---|
[1037] | 66 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
| 67 | ! code put under GPL (PALM 3.9) |
---|
| 68 | ! |
---|
[1017] | 69 | ! 1015 2012-09-27 09:23:24Z raasch |
---|
| 70 | ! OpenACC statements added + code changes required for GPU optimization, |
---|
| 71 | ! adjustment of mixing length to the Prandtl mixing length at first grid point |
---|
| 72 | ! above ground removed |
---|
| 73 | ! |
---|
[1] | 74 | ! Revision 1.1 1997/09/19 07:41:10 raasch |
---|
| 75 | ! Initial revision |
---|
| 76 | ! |
---|
| 77 | ! |
---|
| 78 | ! Description: |
---|
| 79 | ! ------------ |
---|
[1682] | 80 | !> Computation of the turbulent diffusion coefficients for momentum and heat |
---|
| 81 | !> according to Prandtl-Kolmogorov |
---|
[1] | 82 | !------------------------------------------------------------------------------! |
---|
[1682] | 83 | SUBROUTINE diffusivities( var, var_reference ) |
---|
| 84 | |
---|
[1] | 85 | |
---|
[1320] | 86 | USE arrays_3d, & |
---|
| 87 | ONLY: dd2zu, e, kh, km, l_grid, l_wall |
---|
| 88 | |
---|
| 89 | USE control_parameters, & |
---|
| 90 | ONLY: atmos_ocean_sign, e_min, g, outflow_l, outflow_n, outflow_r, & |
---|
| 91 | outflow_s, use_single_reference_value, wall_adjustment |
---|
| 92 | |
---|
| 93 | USE indices, & |
---|
| 94 | ONLY: nxl, nxlg, nxr, nxrg, nyn, nyng, nys, nysg, nzb_s_inner, nzb, nzt |
---|
| 95 | USE kinds |
---|
| 96 | |
---|
[1] | 97 | USE pegrid |
---|
[1320] | 98 | |
---|
| 99 | USE statistics, & |
---|
| 100 | ONLY : rmask, statistic_regions, sums_l_l |
---|
[1] | 101 | |
---|
| 102 | IMPLICIT NONE |
---|
| 103 | |
---|
[1682] | 104 | INTEGER(iwp) :: i !< |
---|
| 105 | INTEGER(iwp) :: j !< |
---|
| 106 | INTEGER(iwp) :: k !< |
---|
| 107 | INTEGER(iwp) :: omp_get_thread_num !< |
---|
| 108 | INTEGER(iwp) :: sr !< |
---|
| 109 | INTEGER(iwp) :: tn !< |
---|
[1] | 110 | |
---|
[1682] | 111 | REAL(wp) :: dvar_dz !< |
---|
| 112 | REAL(wp) :: l !< |
---|
| 113 | REAL(wp) :: ll !< |
---|
| 114 | REAL(wp) :: l_stable !< |
---|
| 115 | REAL(wp) :: sqrt_e !< |
---|
| 116 | REAL(wp) :: var_reference !< |
---|
[1] | 117 | |
---|
[1682] | 118 | REAL(wp) :: var(nzb:nzt+1,nysg:nyng,nxlg:nxrg) !< |
---|
[97] | 119 | |
---|
[1] | 120 | |
---|
| 121 | ! |
---|
| 122 | !-- Default thread number in case of one thread |
---|
| 123 | tn = 0 |
---|
| 124 | |
---|
| 125 | ! |
---|
| 126 | !-- Initialization for calculation of the mixing length profile |
---|
[1340] | 127 | sums_l_l = 0.0_wp |
---|
[1] | 128 | |
---|
| 129 | ! |
---|
| 130 | !-- Compute the turbulent diffusion coefficient for momentum |
---|
[1015] | 131 | !$OMP PARALLEL PRIVATE (dvar_dz,i,j,k,l,ll,l_stable,sqrt_e,sr,tn) |
---|
[1] | 132 | !$ tn = omp_get_thread_num() |
---|
| 133 | |
---|
[1015] | 134 | ! |
---|
| 135 | !-- Introduce an optional minimum tke |
---|
[1340] | 136 | IF ( e_min > 0.0_wp ) THEN |
---|
[1015] | 137 | !$OMP DO |
---|
| 138 | DO i = nxlg, nxrg |
---|
| 139 | DO j = nysg, nyng |
---|
| 140 | DO k = 1, nzt |
---|
| 141 | IF ( k > nzb_s_inner(j,i) ) THEN |
---|
| 142 | e(k,j,i) = MAX( e(k,j,i), e_min ) |
---|
| 143 | ENDIF |
---|
| 144 | ENDDO |
---|
| 145 | ENDDO |
---|
| 146 | ENDDO |
---|
| 147 | ENDIF |
---|
| 148 | |
---|
[1] | 149 | !$OMP DO |
---|
[667] | 150 | DO i = nxlg, nxrg |
---|
| 151 | DO j = nysg, nyng |
---|
[1015] | 152 | DO k = 1, nzt |
---|
[1] | 153 | |
---|
[1015] | 154 | IF ( k > nzb_s_inner(j,i) ) THEN |
---|
[1] | 155 | |
---|
[1015] | 156 | sqrt_e = SQRT( e(k,j,i) ) |
---|
[1] | 157 | ! |
---|
[1015] | 158 | !-- Determine the mixing length |
---|
[2031] | 159 | dvar_dz = atmos_ocean_sign * & ! inverse effect of pt/rho_ocean gradient |
---|
[1015] | 160 | ( var(k+1,j,i) - var(k-1,j,i) ) * dd2zu(k) |
---|
[1340] | 161 | IF ( dvar_dz > 0.0_wp ) THEN |
---|
[1179] | 162 | IF ( use_single_reference_value ) THEN |
---|
[1322] | 163 | l_stable = 0.76_wp * sqrt_e / & |
---|
[1340] | 164 | SQRT( g / var_reference * dvar_dz ) + 1E-5_wp |
---|
[1015] | 165 | ELSE |
---|
[1322] | 166 | l_stable = 0.76_wp * sqrt_e / & |
---|
[1340] | 167 | SQRT( g / var(k,j,i) * dvar_dz ) + 1E-5_wp |
---|
[1015] | 168 | ENDIF |
---|
| 169 | ELSE |
---|
| 170 | l_stable = l_grid(k) |
---|
| 171 | ENDIF |
---|
[1] | 172 | ! |
---|
[1015] | 173 | !-- Adjustment of the mixing length |
---|
| 174 | IF ( wall_adjustment ) THEN |
---|
| 175 | l = MIN( l_wall(k,j,i), l_grid(k), l_stable ) |
---|
| 176 | ll = MIN( l_wall(k,j,i), l_grid(k) ) |
---|
[57] | 177 | ELSE |
---|
[1015] | 178 | l = MIN( l_grid(k), l_stable ) |
---|
| 179 | ll = l_grid(k) |
---|
[57] | 180 | ENDIF |
---|
[1015] | 181 | |
---|
| 182 | ! |
---|
| 183 | !-- Compute diffusion coefficients for momentum and heat |
---|
[1322] | 184 | km(k,j,i) = 0.1_wp * l * sqrt_e |
---|
| 185 | kh(k,j,i) = ( 1.0_wp + 2.0_wp * l / ll ) * km(k,j,i) |
---|
[1015] | 186 | |
---|
[1] | 187 | ! |
---|
[1711] | 188 | !-- Summation for averaged profile (cf. flow_statistics) |
---|
| 189 | DO sr = 0, statistic_regions |
---|
| 190 | sums_l_l(k,sr,tn) = sums_l_l(k,sr,tn) + l * rmask(j,i,sr) |
---|
| 191 | ENDDO |
---|
[2118] | 192 | |
---|
[1711] | 193 | ENDIF |
---|
[1] | 194 | |
---|
| 195 | ENDDO |
---|
| 196 | ENDDO |
---|
| 197 | ENDDO |
---|
| 198 | |
---|
| 199 | sums_l_l(nzt+1,:,tn) = sums_l_l(nzt,:,tn) ! quasi boundary-condition for |
---|
[2118] | 200 | ! data output |
---|
| 201 | !$OMP END PARALLEL |
---|
[1] | 202 | |
---|
| 203 | ! |
---|
| 204 | !-- Set vertical boundary values (Neumann conditions both at bottom and top). |
---|
| 205 | !-- Horizontal boundary conditions at vertical walls are not set because |
---|
| 206 | !-- so far vertical walls require usage of a Prandtl-layer where the boundary |
---|
| 207 | !-- values of the diffusivities are not needed |
---|
| 208 | !$OMP PARALLEL DO |
---|
[667] | 209 | DO i = nxlg, nxrg |
---|
| 210 | DO j = nysg, nyng |
---|
[1] | 211 | km(nzb_s_inner(j,i),j,i) = km(nzb_s_inner(j,i)+1,j,i) |
---|
| 212 | km(nzt+1,j,i) = km(nzt,j,i) |
---|
| 213 | kh(nzb_s_inner(j,i),j,i) = kh(nzb_s_inner(j,i)+1,j,i) |
---|
| 214 | kh(nzt+1,j,i) = kh(nzt,j,i) |
---|
| 215 | ENDDO |
---|
| 216 | ENDDO |
---|
| 217 | |
---|
| 218 | ! |
---|
| 219 | !-- Set Neumann boundary conditions at the outflow boundaries in case of |
---|
| 220 | !-- non-cyclic lateral boundaries |
---|
| 221 | IF ( outflow_l ) THEN |
---|
| 222 | km(:,:,nxl-1) = km(:,:,nxl) |
---|
| 223 | kh(:,:,nxl-1) = kh(:,:,nxl) |
---|
| 224 | ENDIF |
---|
| 225 | IF ( outflow_r ) THEN |
---|
| 226 | km(:,:,nxr+1) = km(:,:,nxr) |
---|
| 227 | kh(:,:,nxr+1) = kh(:,:,nxr) |
---|
| 228 | ENDIF |
---|
| 229 | IF ( outflow_s ) THEN |
---|
| 230 | km(:,nys-1,:) = km(:,nys,:) |
---|
| 231 | kh(:,nys-1,:) = kh(:,nys,:) |
---|
| 232 | ENDIF |
---|
| 233 | IF ( outflow_n ) THEN |
---|
| 234 | km(:,nyn+1,:) = km(:,nyn,:) |
---|
| 235 | kh(:,nyn+1,:) = kh(:,nyn,:) |
---|
| 236 | ENDIF |
---|
| 237 | |
---|
| 238 | END SUBROUTINE diffusivities |
---|