[97] | 1 | SUBROUTINE diffusivities( var, var_reference ) |
---|
[1] | 2 | |
---|
[1036] | 3 | !--------------------------------------------------------------------------------! |
---|
| 4 | ! This file is part of PALM. |
---|
| 5 | ! |
---|
| 6 | ! PALM is free software: you can redistribute it and/or modify it under the terms |
---|
| 7 | ! of the GNU General Public License as published by the Free Software Foundation, |
---|
| 8 | ! either version 3 of the License, or (at your option) any later version. |
---|
| 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 | ! |
---|
[1310] | 17 | ! Copyright 1997-2014 Leibniz Universitaet Hannover |
---|
[1036] | 18 | !--------------------------------------------------------------------------------! |
---|
| 19 | ! |
---|
[484] | 20 | ! Current revisions: |
---|
[1] | 21 | ! ----------------- |
---|
[1341] | 22 | ! |
---|
[1375] | 23 | ! |
---|
[1321] | 24 | ! Former revisions: |
---|
| 25 | ! ----------------- |
---|
| 26 | ! $Id: diffusivities.f90 1375 2014-04-25 13:07:08Z witha $ |
---|
| 27 | ! |
---|
[1375] | 28 | ! 1374 2014-04-25 12:55:07Z raasch |
---|
| 29 | ! rif removed from acc-present-list |
---|
| 30 | ! |
---|
[1354] | 31 | ! 1353 2014-04-08 15:21:23Z heinze |
---|
| 32 | ! REAL constants provided with KIND-attribute |
---|
| 33 | ! |
---|
[1341] | 34 | ! 1340 2014-03-25 19:45:13Z kanani |
---|
| 35 | ! REAL constants defined as wp-kind |
---|
| 36 | ! |
---|
[1323] | 37 | ! 1322 2014-03-20 16:38:49Z raasch |
---|
| 38 | ! REAL constants defined as wp-kind |
---|
| 39 | ! |
---|
[1321] | 40 | ! 1320 2014-03-20 08:40:49Z raasch |
---|
[1320] | 41 | ! ONLY-attribute added to USE-statements, |
---|
| 42 | ! kind-parameters added to all INTEGER and REAL declaration statements, |
---|
| 43 | ! kinds are defined in new module kinds, |
---|
| 44 | ! revision history before 2012 removed, |
---|
| 45 | ! comment fields (!:) to be used for variable explanations added to |
---|
| 46 | ! all variable declaration statements |
---|
[1017] | 47 | ! |
---|
[1182] | 48 | ! 1179 2013-06-14 05:57:58Z raasch |
---|
| 49 | ! use_reference renamed use_single_reference_value |
---|
| 50 | ! |
---|
[1037] | 51 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
| 52 | ! code put under GPL (PALM 3.9) |
---|
| 53 | ! |
---|
[1017] | 54 | ! 1015 2012-09-27 09:23:24Z raasch |
---|
| 55 | ! OpenACC statements added + code changes required for GPU optimization, |
---|
| 56 | ! adjustment of mixing length to the Prandtl mixing length at first grid point |
---|
| 57 | ! above ground removed |
---|
| 58 | ! |
---|
[1] | 59 | ! Revision 1.1 1997/09/19 07:41:10 raasch |
---|
| 60 | ! Initial revision |
---|
| 61 | ! |
---|
| 62 | ! |
---|
| 63 | ! Description: |
---|
| 64 | ! ------------ |
---|
| 65 | ! Computation of the turbulent diffusion coefficients for momentum and heat |
---|
| 66 | ! according to Prandtl-Kolmogorov |
---|
| 67 | !------------------------------------------------------------------------------! |
---|
| 68 | |
---|
[1320] | 69 | USE arrays_3d, & |
---|
| 70 | ONLY: dd2zu, e, kh, km, l_grid, l_wall |
---|
| 71 | |
---|
| 72 | USE control_parameters, & |
---|
| 73 | ONLY: atmos_ocean_sign, e_min, g, outflow_l, outflow_n, outflow_r, & |
---|
| 74 | outflow_s, use_single_reference_value, wall_adjustment |
---|
| 75 | |
---|
| 76 | USE indices, & |
---|
| 77 | ONLY: nxl, nxlg, nxr, nxrg, nyn, nyng, nys, nysg, nzb_s_inner, nzb, nzt |
---|
| 78 | USE kinds |
---|
| 79 | |
---|
[1] | 80 | USE pegrid |
---|
[1320] | 81 | |
---|
| 82 | USE statistics, & |
---|
| 83 | ONLY : rmask, statistic_regions, sums_l_l |
---|
[1] | 84 | |
---|
| 85 | IMPLICIT NONE |
---|
| 86 | |
---|
[1320] | 87 | INTEGER(iwp) :: i !: |
---|
| 88 | INTEGER(iwp) :: j !: |
---|
| 89 | INTEGER(iwp) :: k !: |
---|
| 90 | INTEGER(iwp) :: omp_get_thread_num !: |
---|
| 91 | INTEGER(iwp) :: sr !: |
---|
| 92 | INTEGER(iwp) :: tn !: |
---|
[1] | 93 | |
---|
[1320] | 94 | REAL(wp) :: dvar_dz !: |
---|
| 95 | REAL(wp) :: l !: |
---|
| 96 | REAL(wp) :: ll !: |
---|
| 97 | REAL(wp) :: l_stable !: |
---|
| 98 | REAL(wp) :: sqrt_e !: |
---|
| 99 | REAL(wp) :: var_reference !: |
---|
[1] | 100 | |
---|
[1320] | 101 | REAL(wp) :: var(nzb:nzt+1,nysg:nyng,nxlg:nxrg) !: |
---|
[97] | 102 | |
---|
[1] | 103 | |
---|
| 104 | ! |
---|
| 105 | !-- Default thread number in case of one thread |
---|
| 106 | tn = 0 |
---|
| 107 | |
---|
| 108 | ! |
---|
| 109 | !-- Initialization for calculation of the mixing length profile |
---|
[1340] | 110 | sums_l_l = 0.0_wp |
---|
[1] | 111 | |
---|
| 112 | ! |
---|
| 113 | !-- Compute the turbulent diffusion coefficient for momentum |
---|
[1015] | 114 | !$OMP PARALLEL PRIVATE (dvar_dz,i,j,k,l,ll,l_stable,sqrt_e,sr,tn) |
---|
[1] | 115 | !$ tn = omp_get_thread_num() |
---|
| 116 | |
---|
[1015] | 117 | ! |
---|
| 118 | !-- Data declerations for accelerators |
---|
[1374] | 119 | !$acc data present( dd2zu, e, km, kh, l_grid, l_wall, nzb_s_inner, var ) |
---|
[1015] | 120 | !$acc kernels |
---|
| 121 | |
---|
| 122 | ! |
---|
| 123 | !-- Introduce an optional minimum tke |
---|
[1340] | 124 | IF ( e_min > 0.0_wp ) THEN |
---|
[1015] | 125 | !$OMP DO |
---|
| 126 | !$acc loop |
---|
| 127 | DO i = nxlg, nxrg |
---|
| 128 | DO j = nysg, nyng |
---|
| 129 | !$acc loop vector( 32 ) |
---|
| 130 | DO k = 1, nzt |
---|
| 131 | IF ( k > nzb_s_inner(j,i) ) THEN |
---|
| 132 | e(k,j,i) = MAX( e(k,j,i), e_min ) |
---|
| 133 | ENDIF |
---|
| 134 | ENDDO |
---|
| 135 | ENDDO |
---|
| 136 | ENDDO |
---|
| 137 | ENDIF |
---|
| 138 | |
---|
[1] | 139 | !$OMP DO |
---|
[1015] | 140 | !$acc loop |
---|
[667] | 141 | DO i = nxlg, nxrg |
---|
| 142 | DO j = nysg, nyng |
---|
[1015] | 143 | !$acc loop vector( 32 ) |
---|
| 144 | DO k = 1, nzt |
---|
[1] | 145 | |
---|
[1015] | 146 | IF ( k > nzb_s_inner(j,i) ) THEN |
---|
[1] | 147 | |
---|
[1015] | 148 | sqrt_e = SQRT( e(k,j,i) ) |
---|
[1] | 149 | ! |
---|
[1015] | 150 | !-- Determine the mixing length |
---|
| 151 | dvar_dz = atmos_ocean_sign * & ! inverse effect of pt/rho gradient |
---|
| 152 | ( var(k+1,j,i) - var(k-1,j,i) ) * dd2zu(k) |
---|
[1340] | 153 | IF ( dvar_dz > 0.0_wp ) THEN |
---|
[1179] | 154 | IF ( use_single_reference_value ) THEN |
---|
[1322] | 155 | l_stable = 0.76_wp * sqrt_e / & |
---|
[1340] | 156 | SQRT( g / var_reference * dvar_dz ) + 1E-5_wp |
---|
[1015] | 157 | ELSE |
---|
[1322] | 158 | l_stable = 0.76_wp * sqrt_e / & |
---|
[1340] | 159 | SQRT( g / var(k,j,i) * dvar_dz ) + 1E-5_wp |
---|
[1015] | 160 | ENDIF |
---|
| 161 | ELSE |
---|
| 162 | l_stable = l_grid(k) |
---|
| 163 | ENDIF |
---|
[1] | 164 | ! |
---|
[1015] | 165 | !-- Adjustment of the mixing length |
---|
| 166 | IF ( wall_adjustment ) THEN |
---|
| 167 | l = MIN( l_wall(k,j,i), l_grid(k), l_stable ) |
---|
| 168 | ll = MIN( l_wall(k,j,i), l_grid(k) ) |
---|
[57] | 169 | ELSE |
---|
[1015] | 170 | l = MIN( l_grid(k), l_stable ) |
---|
| 171 | ll = l_grid(k) |
---|
[57] | 172 | ENDIF |
---|
[1015] | 173 | |
---|
| 174 | ! |
---|
| 175 | !-- Compute diffusion coefficients for momentum and heat |
---|
[1322] | 176 | km(k,j,i) = 0.1_wp * l * sqrt_e |
---|
| 177 | kh(k,j,i) = ( 1.0_wp + 2.0_wp * l / ll ) * km(k,j,i) |
---|
[1015] | 178 | |
---|
[1] | 179 | ENDIF |
---|
| 180 | |
---|
[1015] | 181 | #if ! defined( __openacc ) |
---|
[1] | 182 | ! |
---|
[1015] | 183 | !++ Statistics still have to be realized for accelerators |
---|
| 184 | !-- Summation for averaged profile (cf. flow_statistics) |
---|
| 185 | DO sr = 0, statistic_regions |
---|
| 186 | sums_l_l(k,sr,tn) = sums_l_l(k,sr,tn) + l * rmask(j,i,sr) |
---|
| 187 | ENDDO |
---|
| 188 | #endif |
---|
[1] | 189 | |
---|
| 190 | ENDDO |
---|
| 191 | ENDDO |
---|
| 192 | ENDDO |
---|
| 193 | |
---|
[1015] | 194 | #if ! defined( __openacc ) |
---|
| 195 | ! |
---|
| 196 | !++ Statistics still have to be realized for accelerators |
---|
[1] | 197 | sums_l_l(nzt+1,:,tn) = sums_l_l(nzt,:,tn) ! quasi boundary-condition for |
---|
[667] | 198 | ! data output |
---|
[1015] | 199 | #endif |
---|
[1] | 200 | !$OMP END PARALLEL |
---|
| 201 | |
---|
| 202 | ! |
---|
| 203 | !-- Set vertical boundary values (Neumann conditions both at bottom and top). |
---|
| 204 | !-- Horizontal boundary conditions at vertical walls are not set because |
---|
| 205 | !-- so far vertical walls require usage of a Prandtl-layer where the boundary |
---|
| 206 | !-- values of the diffusivities are not needed |
---|
| 207 | !$OMP PARALLEL DO |
---|
[1015] | 208 | !$acc loop |
---|
[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 | |
---|
[1015] | 238 | !$acc end kernels |
---|
| 239 | !$acc end data |
---|
[1] | 240 | |
---|
| 241 | END SUBROUTINE diffusivities |
---|