Index: palm/trunk/SOURCE/data_output_2d.f90
===================================================================
--- palm/trunk/SOURCE/data_output_2d.f90	(revision 1354)
+++ palm/trunk/SOURCE/data_output_2d.f90	(revision 1359)
@@ -20,5 +20,5 @@
 ! Current revisions:
 ! -----------------
-! 
+! New particle structure integrated. 
 ! 
 ! Former revisions:
@@ -128,6 +128,6 @@
 
     USE particle_attributes,                                                   &
-        ONLY:  particle_advection_start, particles, prt_count,                 &
-               prt_start_index
+        ONLY:  grid_particles, number_of_particles, particle_advection_start,  &
+               particles, prt_count
     
     USE pegrid
@@ -163,16 +163,17 @@
     LOGICAL ::  two_d          !: 
     
-    REAL(wp) ::  mean_r         !:
-    REAL(wp) ::  s_r3           !:
-    REAL(wp) ::  s_r4           !:
+    REAL(wp) ::  mean_r        !:
+    REAL(wp) ::  s_r2          !:
+    REAL(wp) ::  s_r3          !:
     
-    REAL(wp), DIMENSION(:), ALLOCATABLE ::      level_z     !:
-    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::    local_2d    !:
-    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::    local_2d_l  !:
-    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  local_pf    !:
+    REAL(wp), DIMENSION(:), ALLOCATABLE     ::  level_z             !:
+    REAL(wp), DIMENSION(:,:), ALLOCATABLE   ::  local_2d            !:
+    REAL(wp), DIMENSION(:,:), ALLOCATABLE   ::  local_2d_l          !:
+    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  local_pf            !:
     REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  local_2d_sections   !:
     REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  local_2d_sections_l !:
+
 #if defined( __parallel )
-    REAL(wp), DIMENSION(:,:),   ALLOCATABLE ::  total_2d  !:
+    REAL(wp), DIMENSION(:,:),   ALLOCATABLE ::  total_2d    !:
 #endif
     REAL(wp), DIMENSION(:,:,:), POINTER ::  to_be_resorted  !: 
@@ -418,5 +419,5 @@
                 ENDIF
 
-             CASE ( 'pr_xy', 'pr_xz', 'pr_yz' )  ! mean particle radius
+             CASE ( 'pr_xy', 'pr_xz', 'pr_yz' )  ! mean particle radius (effective radius)
                 IF ( av == 0 )  THEN
                    IF ( simulated_time >= particle_advection_start )  THEN
@@ -424,15 +425,19 @@
                          DO  j = nys, nyn
                             DO  k = nzb, nzt+1
-                               psi = prt_start_index(k,j,i)
+                               number_of_particles = prt_count(k,j,i)
+                               IF (number_of_particles <= 0)  CYCLE
+                               particles => grid_particles(k,j,i)%particles(1:number_of_particles)
+                               s_r2 = 0.0_wp
                                s_r3 = 0.0_wp
-                               s_r4 = 0.0_wp
-                               DO  n = psi, psi+prt_count(k,j,i)-1
-                                  s_r3 = s_r3 + particles(n)%radius**3 *       &
-                                                particles(n)%weight_factor
-                                  s_r4 = s_r4 + particles(n)%radius**4 *       &
-                                                particles(n)%weight_factor
+                               DO  n = 1, number_of_particles
+                                  IF ( particles(n)%particle_mask )  THEN
+                                     s_r2 = s_r2 + particles(n)%radius**2 * &
+                                            particles(n)%weight_factor
+                                     s_r3 = s_r3 + particles(n)%radius**3 * &
+                                            particles(n)%weight_factor
+                                  ENDIF
                                ENDDO
-                               IF ( s_r3 /= 0.0_wp )  THEN
-                                  mean_r = s_r4 / s_r3
+                               IF ( s_r2 > 0.0_wp )  THEN
+                                  mean_r = s_r3 / s_r2
                                ELSE
                                   mean_r = 0.0_wp
@@ -445,5 +450,5 @@
                    ELSE
                       tend = 0.0_wp
-                   END IF
+                   ENDIF
                    DO  i = nxlg, nxrg
                       DO  j = nysg, nyng
@@ -600,9 +605,13 @@
                          DO  j = nys, nyn
                             DO  k = nzb, nzt+1
-                               psi = prt_start_index(k,j,i)
-                               DO  n = psi, psi+prt_count(k,j,i)-1
-                                  tend(k,j,i) =  tend(k,j,i) +                 &
-                                                 particles(n)%weight_factor /  &
-                                                 prt_count(k,j,i)
+                               number_of_particles = prt_count(k,j,i)
+                               IF (number_of_particles <= 0)  CYCLE
+                               particles => grid_particles(k,j,i)%particles(1:number_of_particles)
+                               DO  n = 1, number_of_particles
+                                  IF ( particles(n)%particle_mask )  THEN
+                                     tend(k,j,i) =  tend(k,j,i) +                 &
+                                                    particles(n)%weight_factor /  &
+                                                    prt_count(k,j,i)
+                                  ENDIF
                                ENDDO
                             ENDDO
@@ -612,5 +621,5 @@
                    ELSE
                       tend = 0.0_wp
-                   END IF
+                   ENDIF
                    DO  i = nxlg, nxrg
                       DO  j = nysg, nyng
