[849] | 1 | SUBROUTINE lpm_set_attributes |
---|
[264] | 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 | ! |
---|
| 17 | ! Copyright 1997-2012 Leibniz University Hannover |
---|
| 18 | !--------------------------------------------------------------------------------! |
---|
| 19 | ! |
---|
[484] | 20 | ! Current revisions: |
---|
[264] | 21 | ! ----------------- |
---|
[850] | 22 | ! |
---|
[264] | 23 | ! |
---|
| 24 | ! Former revisions: |
---|
| 25 | ! ----------------- |
---|
| 26 | ! $Id: lpm_set_attributes.f90 1037 2012-10-22 14:10:22Z heinze $ |
---|
| 27 | ! |
---|
[1037] | 28 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
| 29 | ! code put under GPL (PALM 3.9) |
---|
| 30 | ! |
---|
[850] | 31 | ! 849 2012-03-15 10:35:09Z raasch |
---|
| 32 | ! routine renamed: set_particle_attributes -> lpm_set_attributes |
---|
| 33 | ! |
---|
[829] | 34 | ! 828 2012-02-21 12:00:36Z raasch |
---|
| 35 | ! particle feature color renamed class |
---|
| 36 | ! |
---|
[623] | 37 | ! 622 2010-12-10 08:08:13Z raasch |
---|
| 38 | ! optional barriers included in order to speed up collective operations |
---|
| 39 | ! |
---|
[392] | 40 | ! 271 2009-03-26 00:47:14Z raasch |
---|
| 41 | ! Initial version |
---|
[264] | 42 | ! |
---|
| 43 | ! Description: |
---|
| 44 | ! ------------ |
---|
| 45 | ! This routine sets certain particle attributes depending on the values that |
---|
| 46 | ! other PALM variables have at the current particle position. |
---|
| 47 | !------------------------------------------------------------------------------! |
---|
| 48 | |
---|
| 49 | USE arrays_3d |
---|
| 50 | USE control_parameters |
---|
| 51 | USE cpulog |
---|
| 52 | USE dvrp_variables |
---|
| 53 | USE grid_variables |
---|
| 54 | USE indices |
---|
| 55 | USE interfaces |
---|
| 56 | USE particle_attributes |
---|
| 57 | USE pegrid |
---|
| 58 | USE statistics |
---|
| 59 | |
---|
| 60 | IMPLICIT NONE |
---|
| 61 | |
---|
| 62 | INTEGER :: i, j, k, n |
---|
[268] | 63 | REAL :: aa, absuv, bb, cc, dd, gg, height, pt_int, pt_int_l, pt_int_u, & |
---|
| 64 | u_int, u_int_l, u_int_u, v_int, v_int_l, v_int_u, w_int, & |
---|
| 65 | w_int_l, w_int_u, x, y |
---|
[264] | 66 | |
---|
| 67 | |
---|
[849] | 68 | CALL cpu_log( log_point_s(49), 'lpm_set_attributes', 'start' ) |
---|
[264] | 69 | |
---|
| 70 | ! |
---|
| 71 | !-- Set particle color |
---|
| 72 | IF ( particle_color == 'absuv' ) THEN |
---|
| 73 | |
---|
[266] | 74 | ! |
---|
| 75 | !-- Set particle color depending on the absolute value of the horizontal |
---|
| 76 | !-- velocity |
---|
| 77 | DO n = 1, number_of_particles |
---|
| 78 | ! |
---|
| 79 | !-- Interpolate u velocity-component, determine left, front, bottom |
---|
| 80 | !-- index of u-array |
---|
| 81 | i = ( particles(n)%x + 0.5 * dx ) * ddx |
---|
| 82 | j = particles(n)%y * ddy |
---|
| 83 | k = ( particles(n)%z + 0.5 * dz * atmos_ocean_sign ) / dz & |
---|
| 84 | + offset_ocean_nzt ! only exact if equidistant |
---|
| 85 | |
---|
| 86 | ! |
---|
| 87 | !-- Interpolation of the velocity components in the xy-plane |
---|
| 88 | x = particles(n)%x + ( 0.5 - i ) * dx |
---|
| 89 | y = particles(n)%y - j * dy |
---|
| 90 | aa = x**2 + y**2 |
---|
| 91 | bb = ( dx - x )**2 + y**2 |
---|
| 92 | cc = x**2 + ( dy - y )**2 |
---|
| 93 | dd = ( dx - x )**2 + ( dy - y )**2 |
---|
| 94 | gg = aa + bb + cc + dd |
---|
| 95 | |
---|
| 96 | u_int_l = ( ( gg - aa ) * u(k,j,i) + ( gg - bb ) * u(k,j,i+1) & |
---|
| 97 | + ( gg - cc ) * u(k,j+1,i) + ( gg - dd ) * u(k,j+1,i+1) & |
---|
| 98 | ) / ( 3.0 * gg ) - u_gtrans |
---|
| 99 | IF ( k+1 == nzt+1 ) THEN |
---|
| 100 | u_int = u_int_l |
---|
| 101 | ELSE |
---|
| 102 | u_int_u = ( ( gg-aa ) * u(k+1,j,i) + ( gg-bb ) * u(k+1,j,i+1) & |
---|
| 103 | + ( gg-cc ) * u(k+1,j+1,i) + ( gg-dd ) * u(k+1,j+1,i+1) & |
---|
| 104 | ) / ( 3.0 * gg ) - u_gtrans |
---|
| 105 | u_int = u_int_l + ( particles(n)%z - zu(k) ) / dz * & |
---|
| 106 | ( u_int_u - u_int_l ) |
---|
| 107 | ENDIF |
---|
| 108 | |
---|
| 109 | ! |
---|
| 110 | !-- Same procedure for interpolation of the v velocity-component (adopt |
---|
| 111 | !-- index k from u velocity-component) |
---|
| 112 | i = particles(n)%x * ddx |
---|
| 113 | j = ( particles(n)%y + 0.5 * dy ) * ddy |
---|
| 114 | |
---|
| 115 | x = particles(n)%x - i * dx |
---|
| 116 | y = particles(n)%y + ( 0.5 - j ) * dy |
---|
| 117 | aa = x**2 + y**2 |
---|
| 118 | bb = ( dx - x )**2 + y**2 |
---|
| 119 | cc = x**2 + ( dy - y )**2 |
---|
| 120 | dd = ( dx - x )**2 + ( dy - y )**2 |
---|
| 121 | gg = aa + bb + cc + dd |
---|
| 122 | |
---|
| 123 | v_int_l = ( ( gg - aa ) * v(k,j,i) + ( gg - bb ) * v(k,j,i+1) & |
---|
| 124 | + ( gg - cc ) * v(k,j+1,i) + ( gg - dd ) * v(k,j+1,i+1) & |
---|
| 125 | ) / ( 3.0 * gg ) - v_gtrans |
---|
| 126 | IF ( k+1 == nzt+1 ) THEN |
---|
| 127 | v_int = v_int_l |
---|
| 128 | ELSE |
---|
| 129 | v_int_u = ( ( gg-aa ) * v(k+1,j,i) + ( gg-bb ) * v(k+1,j,i+1) & |
---|
| 130 | + ( gg-cc ) * v(k+1,j+1,i) + ( gg-dd ) * v(k+1,j+1,i+1) & |
---|
| 131 | ) / ( 3.0 * gg ) - v_gtrans |
---|
| 132 | v_int = v_int_l + ( particles(n)%z - zu(k) ) / dz * & |
---|
| 133 | ( v_int_u - v_int_l ) |
---|
| 134 | ENDIF |
---|
| 135 | |
---|
| 136 | absuv = SQRT( u_int**2 + v_int**2 ) |
---|
| 137 | |
---|
| 138 | ! |
---|
| 139 | !-- Limit values by the given interval and normalize to interval [0,1] |
---|
| 140 | absuv = MIN( absuv, color_interval(2) ) |
---|
| 141 | absuv = MAX( absuv, color_interval(1) ) |
---|
| 142 | |
---|
| 143 | absuv = ( absuv - color_interval(1) ) / & |
---|
| 144 | ( color_interval(2) - color_interval(1) ) |
---|
| 145 | |
---|
| 146 | ! |
---|
| 147 | !-- Number of available colors is defined in init_dvrp |
---|
[828] | 148 | particles(n)%class = 1 + absuv * ( dvrp_colortable_entries_prt - 1 ) |
---|
[266] | 149 | |
---|
| 150 | ENDDO |
---|
| 151 | |
---|
[264] | 152 | ELSEIF ( particle_color == 'pt*' ) THEN |
---|
| 153 | ! |
---|
| 154 | !-- Set particle color depending on the resolved scale temperature |
---|
| 155 | !-- fluctuation. |
---|
| 156 | !-- First, calculate the horizontal average of the potential temperature |
---|
| 157 | !-- (This is also done in flow_statistics, but flow_statistics is called |
---|
| 158 | !-- after this routine.) |
---|
| 159 | sums_l(:,4,0) = 0.0 |
---|
| 160 | DO i = nxl, nxr |
---|
| 161 | DO j = nys, nyn |
---|
| 162 | DO k = nzb, nzt+1 |
---|
| 163 | sums_l(k,4,0) = sums_l(k,4,0) + pt(k,j,i) |
---|
| 164 | ENDDO |
---|
| 165 | ENDDO |
---|
| 166 | ENDDO |
---|
| 167 | |
---|
| 168 | #if defined( __parallel ) |
---|
| 169 | |
---|
[622] | 170 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
[264] | 171 | CALL MPI_ALLREDUCE( sums_l(nzb,4,0), sums(nzb,4), nzt+2-nzb, & |
---|
| 172 | MPI_REAL, MPI_SUM, comm2d, ierr ) |
---|
| 173 | |
---|
| 174 | #else |
---|
| 175 | |
---|
| 176 | sums(:,4) = sums_l(:,4,0) |
---|
| 177 | |
---|
| 178 | #endif |
---|
| 179 | |
---|
| 180 | sums(:,4) = sums(:,4) / ngp_2dh(0) |
---|
| 181 | |
---|
| 182 | DO n = 1, number_of_particles |
---|
| 183 | ! |
---|
| 184 | !-- Interpolate temperature to the current particle position |
---|
| 185 | i = particles(n)%x * ddx |
---|
| 186 | j = particles(n)%y * ddy |
---|
| 187 | k = ( particles(n)%z + 0.5 * dz * atmos_ocean_sign ) / dz & |
---|
| 188 | + offset_ocean_nzt ! only exact if equidistant |
---|
| 189 | |
---|
| 190 | x = particles(n)%x - i * dx |
---|
| 191 | y = particles(n)%y - j * dy |
---|
| 192 | aa = x**2 + y**2 |
---|
| 193 | bb = ( dx - x )**2 + y**2 |
---|
| 194 | cc = x**2 + ( dy - y )**2 |
---|
| 195 | dd = ( dx - x )**2 + ( dy - y )**2 |
---|
| 196 | gg = aa + bb + cc + dd |
---|
| 197 | |
---|
| 198 | pt_int_l = ( ( gg - aa ) * pt(k,j,i) + ( gg - bb ) * pt(k,j,i+1) & |
---|
| 199 | + ( gg - cc ) * pt(k,j+1,i) + ( gg - dd ) * pt(k,j+1,i+1) & |
---|
| 200 | ) / ( 3.0 * gg ) - sums(k,4) |
---|
| 201 | |
---|
| 202 | pt_int_u = ( ( gg-aa ) * pt(k+1,j,i) + ( gg-bb ) * pt(k+1,j,i+1) & |
---|
| 203 | + ( gg-cc ) * pt(k+1,j+1,i) + ( gg-dd ) * pt(k+1,j+1,i+1) & |
---|
| 204 | ) / ( 3.0 * gg ) - sums(k,4) |
---|
| 205 | |
---|
| 206 | pt_int = pt_int_l + ( particles(n)%z - zu(k) ) / dz * & |
---|
| 207 | ( pt_int_u - pt_int_l ) |
---|
| 208 | |
---|
| 209 | ! |
---|
| 210 | !-- Limit values by the given interval and normalize to interval [0,1] |
---|
| 211 | pt_int = MIN( pt_int, color_interval(2) ) |
---|
| 212 | pt_int = MAX( pt_int, color_interval(1) ) |
---|
| 213 | |
---|
| 214 | pt_int = ( pt_int - color_interval(1) ) / & |
---|
| 215 | ( color_interval(2) - color_interval(1) ) |
---|
| 216 | |
---|
| 217 | ! |
---|
| 218 | !-- Number of available colors is defined in init_dvrp |
---|
[828] | 219 | particles(n)%class = 1 + pt_int * ( dvrp_colortable_entries_prt - 1 ) |
---|
[264] | 220 | |
---|
[266] | 221 | ENDDO |
---|
[264] | 222 | |
---|
| 223 | ELSEIF ( particle_color == 'z' ) THEN |
---|
[266] | 224 | ! |
---|
| 225 | !-- Set particle color depending on the height above the bottom |
---|
| 226 | !-- boundary (z=0) |
---|
| 227 | DO n = 1, number_of_particles |
---|
[264] | 228 | |
---|
[266] | 229 | height = particles(n)%z |
---|
| 230 | ! |
---|
| 231 | !-- Limit values by the given interval and normalize to interval [0,1] |
---|
| 232 | height = MIN( height, color_interval(2) ) |
---|
| 233 | height = MAX( height, color_interval(1) ) |
---|
| 234 | |
---|
| 235 | height = ( height - color_interval(1) ) / & |
---|
| 236 | ( color_interval(2) - color_interval(1) ) |
---|
| 237 | |
---|
| 238 | ! |
---|
| 239 | !-- Number of available colors is defined in init_dvrp |
---|
[828] | 240 | particles(n)%class = 1 + height * ( dvrp_colortable_entries_prt - 1 ) |
---|
[266] | 241 | |
---|
| 242 | ENDDO |
---|
| 243 | |
---|
[264] | 244 | ENDIF |
---|
| 245 | |
---|
| 246 | ! |
---|
| 247 | !-- Set particle size for dvrp graphics |
---|
| 248 | IF ( particle_dvrpsize == 'absw' ) THEN |
---|
| 249 | |
---|
| 250 | DO n = 1, number_of_particles |
---|
| 251 | ! |
---|
| 252 | !-- Interpolate w-component to the current particle position |
---|
| 253 | i = particles(n)%x * ddx |
---|
| 254 | j = particles(n)%y * ddy |
---|
| 255 | k = particles(n)%z / dz |
---|
| 256 | |
---|
| 257 | x = particles(n)%x - i * dx |
---|
| 258 | y = particles(n)%y - j * dy |
---|
| 259 | aa = x**2 + y**2 |
---|
| 260 | bb = ( dx - x )**2 + y**2 |
---|
| 261 | cc = x**2 + ( dy - y )**2 |
---|
| 262 | dd = ( dx - x )**2 + ( dy - y )**2 |
---|
| 263 | gg = aa + bb + cc + dd |
---|
| 264 | |
---|
| 265 | w_int_l = ( ( gg - aa ) * w(k,j,i) + ( gg - bb ) * w(k,j,i+1) & |
---|
| 266 | + ( gg - cc ) * w(k,j+1,i) + ( gg - dd ) * w(k,j+1,i+1) & |
---|
| 267 | ) / ( 3.0 * gg ) |
---|
| 268 | |
---|
| 269 | IF ( k+1 == nzt+1 ) THEN |
---|
| 270 | w_int = w_int_l |
---|
| 271 | ELSE |
---|
| 272 | w_int_u = ( ( gg-aa ) * w(k+1,j,i) + ( gg-bb ) * w(k+1,j,i+1) & |
---|
| 273 | + ( gg-cc ) * w(k+1,j+1,i) + ( gg-dd ) * w(k+1,j+1,i+1) & |
---|
| 274 | ) / ( 3.0 * gg ) |
---|
| 275 | w_int = w_int_l + ( particles(n)%z - zw(k) ) / dz * & |
---|
| 276 | ( w_int_u - w_int_l ) |
---|
| 277 | ENDIF |
---|
| 278 | |
---|
[266] | 279 | ! |
---|
| 280 | !-- Limit values by the given interval and normalize to interval [0,1] |
---|
| 281 | w_int = ABS( w_int ) |
---|
| 282 | w_int = MIN( w_int, dvrpsize_interval(2) ) |
---|
| 283 | w_int = MAX( w_int, dvrpsize_interval(1) ) |
---|
[264] | 284 | |
---|
[266] | 285 | w_int = ( w_int - dvrpsize_interval(1) ) / & |
---|
| 286 | ( dvrpsize_interval(2) - dvrpsize_interval(1) ) |
---|
| 287 | |
---|
| 288 | particles(n)%dvrp_psize = ( 0.25 + w_int * 0.6 ) * dx |
---|
| 289 | |
---|
[264] | 290 | ENDDO |
---|
| 291 | |
---|
| 292 | ENDIF |
---|
| 293 | |
---|
[849] | 294 | CALL cpu_log( log_point_s(49), 'lpm_set_attributes', 'stop' ) |
---|
[264] | 295 | |
---|
| 296 | |
---|
[849] | 297 | END SUBROUTINE lpm_set_attributes |
---|