Changeset 2609 for palm/trunk
- Timestamp:
- Nov 14, 2017 2:14:44 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
palm/trunk/SOURCE/lpm_pack_arrays.f90
r2606 r2609 25 25 ! ----------------- 26 26 ! $Id$ 27 ! Integrated subroutine pack_and_sort into lpm_sort_in_subboxes 28 ! 29 ! 2606 2017-11-10 10:36:31Z schwenkel 27 30 ! Changed particle box locations: center of particle box now coincides 28 31 ! with scalar grid point of same index. … … 124 127 IMPLICIT NONE 125 128 129 INTEGER(iwp) :: i !< 126 130 INTEGER(iwp) :: ip !< 131 INTEGER(iwp) :: is !< 132 INTEGER(iwp) :: j !< 127 133 INTEGER(iwp) :: jp !< 134 INTEGER(iwp) :: k !< 128 135 INTEGER(iwp) :: kp !< 136 INTEGER(iwp) :: m !< 137 INTEGER(iwp) :: n !< 138 INTEGER(iwp) :: nn !< 139 INTEGER(iwp) :: sort_index !< 140 141 INTEGER(iwp), DIMENSION(0:7) :: sort_count !< 142 143 TYPE(particle_type), DIMENSION(:,:), ALLOCATABLE :: sort_particles !< 129 144 130 145 CALL cpu_log( log_point_s(51), 'lpm_sort_in_subboxes', 'start' ) … … 135 150 IF ( number_of_particles <= 0 ) CYCLE 136 151 particles => grid_particles(kp,jp,ip)%particles(1:number_of_particles) 152 153 nn = 0 154 sort_count = 0 155 ALLOCATE( sort_particles(number_of_particles, 0:7) ) 137 156 138 CALL lpm_pack_and_sort(ip,jp,kp) 139 157 DO n = 1, number_of_particles 158 sort_index = 0 159 160 IF ( particles(n)%particle_mask ) THEN 161 nn = nn + 1 162 ! 163 !-- Sorting particles with a binary scheme 164 !-- sort_index=111_2=7_10 -> particle at the left,south,bottom subgridbox 165 !-- sort_index=000_2=0_10 -> particle at the right,north,top subgridbox 166 !-- For this the center of the gridbox is calculated 167 i = (particles(n)%x + 0.5_wp * dx) * ddx 168 j = (particles(n)%y + 0.5_wp * dy) * ddy 169 k = ( particles(n)%z+ 0.5_wp *dz ) / dz+1 + offset_ocean_nzt 170 171 IF ( i == ip ) sort_index = sort_index + 4 172 IF ( j == jp ) sort_index = sort_index + 2 173 IF ( k == kp ) sort_index = sort_index + 1 174 175 sort_count(sort_index) = sort_count(sort_index) + 1 176 m = sort_count(sort_index) 177 sort_particles(m,sort_index) = particles(n) 178 sort_particles(m,sort_index)%block_nr = sort_index 179 ENDIF 180 ENDDO 181 182 nn = 0 183 DO is = 0,7 184 grid_particles(kp,jp,ip)%start_index(is) = nn + 1 185 DO n = 1,sort_count(is) 186 nn = nn + 1 187 particles(nn) = sort_particles(n,is) 188 ENDDO 189 grid_particles(kp,jp,ip)%end_index(is) = nn 190 ENDDO 191 192 number_of_particles = nn 140 193 prt_count(kp,jp,ip) = number_of_particles 194 DEALLOCATE(sort_particles) 141 195 ENDDO 142 196 ENDDO … … 190 244 191 245 END SUBROUTINE lpm_pack 192 193 SUBROUTINE lpm_pack_and_sort (ip,jp,kp)194 195 USE control_parameters, &196 ONLY: dz197 198 USE kinds199 200 USE grid_variables, &201 ONLY: dx,dy,ddx, ddy202 203 IMPLICIT NONE204 205 INTEGER(iwp), INTENT(IN) :: ip206 INTEGER(iwp), INTENT(IN) :: jp207 INTEGER(iwp), INTENT(IN) :: kp208 209 INTEGER(iwp) :: i210 INTEGER(iwp) :: is211 INTEGER(iwp) :: j212 INTEGER(iwp) :: k213 INTEGER(iwp) :: n214 INTEGER(iwp) :: nn215 INTEGER(iwp) :: m216 INTEGER(iwp) :: sort_index217 218 INTEGER(iwp), DIMENSION(0:7) :: sort_count219 220 TYPE(particle_type), DIMENSION(number_of_particles,0:7) :: sort_particles221 222 nn = 0223 sort_count = 0224 225 DO n = 1, number_of_particles226 sort_index = 0227 228 IF ( particles(n)%particle_mask ) THEN229 nn = nn + 1230 !231 !-- Sorting particles with a binary scheme232 !-- sort_index=111_2=7_10 -> particle at the left,south,bottom subgridbox233 !-- sort_index=000_2=0_10 -> particle at the right,north,top subgridbox234 !-- For this the center of the gridbox is calculated235 i = (particles(n)%x + 0.5_wp * dx) * ddx236 j = (particles(n)%y + 0.5_wp * dy) * ddy237 k = ( particles(n)%z+ 0.5_wp *dz ) / dz+1 + offset_ocean_nzt238 239 IF ( i == ip ) sort_index = sort_index + 4240 IF ( j == jp ) sort_index = sort_index + 2241 IF ( k == kp ) sort_index = sort_index + 1242 243 sort_count(sort_index) = sort_count(sort_index) + 1244 m = sort_count(sort_index)245 sort_particles(m,sort_index) = particles(n)246 sort_particles(m,sort_index)%block_nr = sort_index247 ENDIF248 249 ENDDO250 251 nn = 0252 253 DO is = 0,7254 grid_particles(kp,jp,ip)%start_index(is) = nn + 1255 DO n = 1,sort_count(is)256 nn = nn + 1257 particles(nn) = sort_particles(n,is)258 ENDDO259 grid_particles(kp,jp,ip)%end_index(is) = nn260 ENDDO261 262 number_of_particles = nn263 264 END SUBROUTINE lpm_pack_and_sort265 246 266 247 !------------------------------------------------------------------------------!
Note: See TracChangeset
for help on using the changeset viewer.