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