[1682] | 1 | !> @file diffusivities.f90 |
---|
[1036] | 2 | !--------------------------------------------------------------------------------! |
---|
| 3 | ! This file is part of PALM. |
---|
| 4 | ! |
---|
| 5 | ! PALM is free software: you can redistribute it and/or modify it under the terms |
---|
| 6 | ! of the GNU General Public License as published by the Free Software Foundation, |
---|
| 7 | ! either version 3 of the License, or (at your option) any later version. |
---|
| 8 | ! |
---|
| 9 | ! PALM is distributed in the hope that it will be useful, but WITHOUT ANY |
---|
| 10 | ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR |
---|
| 11 | ! A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
---|
| 12 | ! |
---|
| 13 | ! You should have received a copy of the GNU General Public License along with |
---|
| 14 | ! PALM. If not, see <http://www.gnu.org/licenses/>. |
---|
| 15 | ! |
---|
[1310] | 16 | ! Copyright 1997-2014 Leibniz Universitaet Hannover |
---|
[1036] | 17 | !--------------------------------------------------------------------------------! |
---|
| 18 | ! |
---|
[484] | 19 | ! Current revisions: |
---|
[1] | 20 | ! ----------------- |
---|
[1682] | 21 | ! Code annotations made doxygen readable |
---|
[1341] | 22 | ! |
---|
[1321] | 23 | ! Former revisions: |
---|
| 24 | ! ----------------- |
---|
| 25 | ! $Id: diffusivities.f90 1682 2015-10-07 23:56:08Z knoop $ |
---|
| 26 | ! |
---|
[1375] | 27 | ! 1374 2014-04-25 12:55:07Z raasch |
---|
| 28 | ! rif removed from acc-present-list |
---|
| 29 | ! |
---|
[1354] | 30 | ! 1353 2014-04-08 15:21:23Z heinze |
---|
| 31 | ! REAL constants provided with KIND-attribute |
---|
| 32 | ! |
---|
[1341] | 33 | ! 1340 2014-03-25 19:45:13Z kanani |
---|
| 34 | ! REAL constants defined as wp-kind |
---|
| 35 | ! |
---|
[1323] | 36 | ! 1322 2014-03-20 16:38:49Z raasch |
---|
| 37 | ! REAL constants defined as wp-kind |
---|
| 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 |
---|
[1017] | 46 | ! |
---|
[1182] | 47 | ! 1179 2013-06-14 05:57:58Z raasch |
---|
| 48 | ! use_reference renamed use_single_reference_value |
---|
| 49 | ! |
---|
[1037] | 50 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
| 51 | ! code put under GPL (PALM 3.9) |
---|
| 52 | ! |
---|
[1017] | 53 | ! 1015 2012-09-27 09:23:24Z raasch |
---|
| 54 | ! OpenACC statements added + code changes required for GPU optimization, |
---|
| 55 | ! adjustment of mixing length to the Prandtl mixing length at first grid point |
---|
| 56 | ! above ground removed |
---|
| 57 | ! |
---|
[1] | 58 | ! Revision 1.1 1997/09/19 07:41:10 raasch |
---|
| 59 | ! Initial revision |
---|
| 60 | ! |
---|
| 61 | ! |
---|
| 62 | ! Description: |
---|
| 63 | ! ------------ |
---|
[1682] | 64 | !> Computation of the turbulent diffusion coefficients for momentum and heat |
---|
| 65 | !> according to Prandtl-Kolmogorov |
---|
[1] | 66 | !------------------------------------------------------------------------------! |
---|
[1682] | 67 | SUBROUTINE diffusivities( var, var_reference ) |
---|
| 68 | |
---|
[1] | 69 | |
---|
[1320] | 70 | USE arrays_3d, & |
---|
| 71 | ONLY: dd2zu, e, kh, km, l_grid, l_wall |
---|
| 72 | |
---|
| 73 | USE control_parameters, & |
---|
| 74 | ONLY: atmos_ocean_sign, e_min, g, outflow_l, outflow_n, outflow_r, & |
---|
| 75 | outflow_s, use_single_reference_value, wall_adjustment |
---|
| 76 | |
---|
| 77 | USE indices, & |
---|
| 78 | ONLY: nxl, nxlg, nxr, nxrg, nyn, nyng, nys, nysg, nzb_s_inner, nzb, nzt |
---|
| 79 | USE kinds |
---|
| 80 | |
---|
[1] | 81 | USE pegrid |
---|
[1320] | 82 | |
---|
| 83 | USE statistics, & |
---|
| 84 | ONLY : rmask, statistic_regions, sums_l_l |
---|
[1] | 85 | |
---|
| 86 | IMPLICIT NONE |
---|
| 87 | |
---|
[1682] | 88 | INTEGER(iwp) :: i !< |
---|
| 89 | INTEGER(iwp) :: j !< |
---|
| 90 | INTEGER(iwp) :: k !< |
---|
| 91 | INTEGER(iwp) :: omp_get_thread_num !< |
---|
| 92 | INTEGER(iwp) :: sr !< |
---|
| 93 | INTEGER(iwp) :: tn !< |
---|
[1] | 94 | |
---|
[1682] | 95 | REAL(wp) :: dvar_dz !< |
---|
| 96 | REAL(wp) :: l !< |
---|
| 97 | REAL(wp) :: ll !< |
---|
| 98 | REAL(wp) :: l_stable !< |
---|
| 99 | REAL(wp) :: sqrt_e !< |
---|
| 100 | REAL(wp) :: var_reference !< |
---|
[1] | 101 | |
---|
[1682] | 102 | REAL(wp) :: var(nzb:nzt+1,nysg:nyng,nxlg:nxrg) !< |
---|
[97] | 103 | |
---|
[1] | 104 | |
---|
| 105 | ! |
---|
| 106 | !-- Default thread number in case of one thread |
---|
| 107 | tn = 0 |
---|
| 108 | |
---|
| 109 | ! |
---|
| 110 | !-- Initialization for calculation of the mixing length profile |
---|
[1340] | 111 | sums_l_l = 0.0_wp |
---|
[1] | 112 | |
---|
| 113 | ! |
---|
| 114 | !-- Compute the turbulent diffusion coefficient for momentum |
---|
[1015] | 115 | !$OMP PARALLEL PRIVATE (dvar_dz,i,j,k,l,ll,l_stable,sqrt_e,sr,tn) |
---|
[1] | 116 | !$ tn = omp_get_thread_num() |
---|
| 117 | |
---|
[1015] | 118 | ! |
---|
| 119 | !-- Data declerations for accelerators |
---|
[1374] | 120 | !$acc data present( dd2zu, e, km, kh, l_grid, l_wall, nzb_s_inner, var ) |
---|
[1015] | 121 | !$acc kernels |
---|
| 122 | |
---|
| 123 | ! |
---|
| 124 | !-- Introduce an optional minimum tke |
---|
[1340] | 125 | IF ( e_min > 0.0_wp ) THEN |
---|
[1015] | 126 | !$OMP DO |
---|
| 127 | !$acc loop |
---|
| 128 | DO i = nxlg, nxrg |
---|
| 129 | DO j = nysg, nyng |
---|
| 130 | !$acc loop vector( 32 ) |
---|
| 131 | DO k = 1, nzt |
---|
| 132 | IF ( k > nzb_s_inner(j,i) ) THEN |
---|
| 133 | e(k,j,i) = MAX( e(k,j,i), e_min ) |
---|
| 134 | ENDIF |
---|
| 135 | ENDDO |
---|
| 136 | ENDDO |
---|
| 137 | ENDDO |
---|
| 138 | ENDIF |
---|
| 139 | |
---|
[1] | 140 | !$OMP DO |
---|
[1015] | 141 | !$acc loop |
---|
[667] | 142 | DO i = nxlg, nxrg |
---|
| 143 | DO j = nysg, nyng |
---|
[1015] | 144 | !$acc loop vector( 32 ) |
---|
| 145 | DO k = 1, nzt |
---|
[1] | 146 | |
---|
[1015] | 147 | IF ( k > nzb_s_inner(j,i) ) THEN |
---|
[1] | 148 | |
---|
[1015] | 149 | sqrt_e = SQRT( e(k,j,i) ) |
---|
[1] | 150 | ! |
---|
[1015] | 151 | !-- Determine the mixing length |
---|
| 152 | dvar_dz = atmos_ocean_sign * & ! inverse effect of pt/rho gradient |
---|
| 153 | ( var(k+1,j,i) - var(k-1,j,i) ) * dd2zu(k) |
---|
[1340] | 154 | IF ( dvar_dz > 0.0_wp ) THEN |
---|
[1179] | 155 | IF ( use_single_reference_value ) THEN |
---|
[1322] | 156 | l_stable = 0.76_wp * sqrt_e / & |
---|
[1340] | 157 | SQRT( g / var_reference * dvar_dz ) + 1E-5_wp |
---|
[1015] | 158 | ELSE |
---|
[1322] | 159 | l_stable = 0.76_wp * sqrt_e / & |
---|
[1340] | 160 | SQRT( g / var(k,j,i) * dvar_dz ) + 1E-5_wp |
---|
[1015] | 161 | ENDIF |
---|
| 162 | ELSE |
---|
| 163 | l_stable = l_grid(k) |
---|
| 164 | ENDIF |
---|
[1] | 165 | ! |
---|
[1015] | 166 | !-- Adjustment of the mixing length |
---|
| 167 | IF ( wall_adjustment ) THEN |
---|
| 168 | l = MIN( l_wall(k,j,i), l_grid(k), l_stable ) |
---|
| 169 | ll = MIN( l_wall(k,j,i), l_grid(k) ) |
---|
[57] | 170 | ELSE |
---|
[1015] | 171 | l = MIN( l_grid(k), l_stable ) |
---|
| 172 | ll = l_grid(k) |
---|
[57] | 173 | ENDIF |
---|
[1015] | 174 | |
---|
| 175 | ! |
---|
| 176 | !-- Compute diffusion coefficients for momentum and heat |
---|
[1322] | 177 | km(k,j,i) = 0.1_wp * l * sqrt_e |
---|
| 178 | kh(k,j,i) = ( 1.0_wp + 2.0_wp * l / ll ) * km(k,j,i) |
---|
[1015] | 179 | |
---|
[1] | 180 | ENDIF |
---|
| 181 | |
---|
[1015] | 182 | #if ! defined( __openacc ) |
---|
[1] | 183 | ! |
---|
[1015] | 184 | !++ Statistics still have to be realized for accelerators |
---|
| 185 | !-- Summation for averaged profile (cf. flow_statistics) |
---|
| 186 | DO sr = 0, statistic_regions |
---|
| 187 | sums_l_l(k,sr,tn) = sums_l_l(k,sr,tn) + l * rmask(j,i,sr) |
---|
| 188 | ENDDO |
---|
| 189 | #endif |
---|
[1] | 190 | |
---|
| 191 | ENDDO |
---|
| 192 | ENDDO |
---|
| 193 | ENDDO |
---|
| 194 | |
---|
[1015] | 195 | #if ! defined( __openacc ) |
---|
| 196 | ! |
---|
| 197 | !++ Statistics still have to be realized for accelerators |
---|
[1] | 198 | sums_l_l(nzt+1,:,tn) = sums_l_l(nzt,:,tn) ! quasi boundary-condition for |
---|
[667] | 199 | ! data output |
---|
[1015] | 200 | #endif |
---|
[1] | 201 | !$OMP END PARALLEL |
---|
| 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 |
---|
[1015] | 209 | !$acc loop |
---|
[667] | 210 | DO i = nxlg, nxrg |
---|
| 211 | DO j = nysg, nyng |
---|
[1] | 212 | km(nzb_s_inner(j,i),j,i) = km(nzb_s_inner(j,i)+1,j,i) |
---|
| 213 | km(nzt+1,j,i) = km(nzt,j,i) |
---|
| 214 | kh(nzb_s_inner(j,i),j,i) = kh(nzb_s_inner(j,i)+1,j,i) |
---|
| 215 | kh(nzt+1,j,i) = kh(nzt,j,i) |
---|
| 216 | ENDDO |
---|
| 217 | ENDDO |
---|
| 218 | |
---|
| 219 | ! |
---|
| 220 | !-- Set Neumann boundary conditions at the outflow boundaries in case of |
---|
| 221 | !-- non-cyclic lateral boundaries |
---|
| 222 | IF ( outflow_l ) THEN |
---|
| 223 | km(:,:,nxl-1) = km(:,:,nxl) |
---|
| 224 | kh(:,:,nxl-1) = kh(:,:,nxl) |
---|
| 225 | ENDIF |
---|
| 226 | IF ( outflow_r ) THEN |
---|
| 227 | km(:,:,nxr+1) = km(:,:,nxr) |
---|
| 228 | kh(:,:,nxr+1) = kh(:,:,nxr) |
---|
| 229 | ENDIF |
---|
| 230 | IF ( outflow_s ) THEN |
---|
| 231 | km(:,nys-1,:) = km(:,nys,:) |
---|
| 232 | kh(:,nys-1,:) = kh(:,nys,:) |
---|
| 233 | ENDIF |
---|
| 234 | IF ( outflow_n ) THEN |
---|
| 235 | km(:,nyn+1,:) = km(:,nyn,:) |
---|
| 236 | kh(:,nyn+1,:) = kh(:,nyn,:) |
---|
| 237 | ENDIF |
---|
| 238 | |
---|
[1015] | 239 | !$acc end kernels |
---|
| 240 | !$acc end data |
---|
[1] | 241 | |
---|
| 242 | END SUBROUTINE diffusivities |
---|