Index: palm/trunk/SOURCE/lpm_data_output_particles.f90
===================================================================
--- palm/trunk/SOURCE/lpm_data_output_particles.f90	(revision 2119)
+++ palm/trunk/SOURCE/lpm_data_output_particles.f90	(revision 2122)
@@ -20,5 +20,5 @@
 ! Current revisions:
 ! ------------------
-! 
+! Calculation of particle ID
 ! 
 ! Former revisions:
@@ -136,6 +136,6 @@
 !     CALL netcdf_handle_error( 'lpm_data_output_particles', 3 )
 ! 
-!     nc_stat = NF90_PUT_VAR( id_set_prt, id_var_prt(2), particles%dvrp_psize,&
-!                             start = (/ 1, prt_time_count /),                &
+!     nc_stat = NF90_PUT_VAR( id_set_prt, id_var_prt(2), particles%user,     &
+!                             start = (/ 1, prt_time_count /),               &
 !                             count = (/ maximum_number_of_particles /) )
 !     CALL netcdf_handle_error( 'lpm_data_output_particles', 4 )
@@ -208,10 +208,10 @@
 ! 
 !     nc_stat = NF90_PUT_VAR( id_set_prt, id_var_prt(16),                    &
-!                             particles%tailpoints,                          &
+!                             particles%id2,                                 &
 !                             start = (/ 1, prt_time_count /),               &
 !                             count = (/ maximum_number_of_particles /) )
 !     CALL netcdf_handle_error( 'lpm_data_output_particles', 18 )
 ! 
-!     nc_stat = NF90_PUT_VAR( id_set_prt, id_var_prt(17), particles%tail_id, &
+!     nc_stat = NF90_PUT_VAR( id_set_prt, id_var_prt(17), particles%id1,     &
 !                             start = (/ 1, prt_time_count /),               &
 !                             count = (/ maximum_number_of_particles /) )
Index: palm/trunk/SOURCE/lpm_droplet_collision.f90
===================================================================
--- palm/trunk/SOURCE/lpm_droplet_collision.f90	(revision 2119)
+++ palm/trunk/SOURCE/lpm_droplet_collision.f90	(revision 2122)
@@ -20,6 +20,6 @@
 ! Current revisions:
 ! ------------------
-! 
-! 
+! Some reformatting of the code.
+!
 ! Former revisions:
 ! -----------------
@@ -445,7 +445,7 @@
 
                       IF ( collection_probability .GT. random_function( iran_part ) )  THEN
-                         mass(n) = mass(n) + weight(n) * xm  
-                         weight(m)    = weight(m)    - weight(n)
-                         mass(m) = mass(m) - weight(n) * xm
+                         mass(n)   = mass(n)   + weight(n) * xm  
+                         weight(m) = weight(m) - weight(n)
+                         mass(m)   = mass(m)   - weight(n) * xm
                       ENDIF
 
@@ -457,7 +457,7 @@
 
                       IF ( collection_probability .GT. random_function( iran_part ) )  THEN
-                         mass(m) = mass(m) + weight(m) * xn
-                         weight(n)    = weight(n)    - weight(m)
-                         mass(n) = mass(n) - weight(m) * xn
+                         mass(m)   = mass(m)   + weight(m) * xn
+                         weight(n) = weight(n) - weight(m)
+                         mass(n)   = mass(n)   - weight(m) * xn
                       ENDIF
                    ELSE
Index: palm/trunk/SOURCE/lpm_init.f90
===================================================================
--- palm/trunk/SOURCE/lpm_init.f90	(revision 2119)
+++ palm/trunk/SOURCE/lpm_init.f90	(revision 2122)
@@ -20,5 +20,6 @@
 ! Current revisions:
 ! -----------------
-! 
+! Improved initialization of equilibrium aerosol radii 
+! Calculation of particle ID
 ! 
 ! Former revisions:
@@ -44,5 +45,4 @@
 ! 1873 2016-04-18 14:50:06Z maronga
 ! Module renamed (removed _mod
-
 ! 
 ! 1871 2016-04-15 11:46:09Z hoffmann
@@ -236,6 +236,13 @@
 !-- Define MPI derived datatype for FORTRAN datatype particle_type (see module
 !-- particle_attributes). Integer length is 4 byte, Real is 8 byte
+!    blocklengths(1)  = 20;  blocklengths(2)  =   5;  blocklengths(3)  =   1
+!    displacements(1) =  0;  displacements(2) = 160;  displacements(3) = 180
     blocklengths(1)  = 19;  blocklengths(2)  =   6;  blocklengths(3)  =   1
     displacements(1) =  0;  displacements(2) = 152;  displacements(3) = 176
+
+!
+!-- WARNING: the double precision integer 'id' is treated as a double precision 
+!-- integer here, i.e., there are 20 real variables and only 5 integer variables 
+!-- instead of 19 and 6, respectively. 
 
     types(1) = MPI_REAL
@@ -452,4 +459,8 @@
 
 !
+!--    initialize counter for particle IDs 
+       grid_particles%id_counter = 0
+
+!
 !--    Initialize all particles with dummy values (otherwise errors may
 !--    occur within restart runs). The reason for this is still not clear
@@ -458,6 +469,6 @@
                                       0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp,  &
                                       0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp,  &
-                                      0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, 0, 0, 0, &
-                                      0, .FALSE., -1 )
+                                      0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp,          &
+                                      0, 0, 0, 0, .FALSE., -1 )
 
        particle_groups = particle_groups_type( 0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp )
@@ -602,5 +613,5 @@
                             tmp_particle%age_m         = 0.0_wp
                             tmp_particle%dt_sum        = 0.0_wp
-                            tmp_particle%dvrp_psize    = 0.0_wp !unused
+                            tmp_particle%user          = 0.0_wp !unused, free for the user
                             tmp_particle%e_m           = 0.0_wp
                             IF ( curvature_solution_effects )  THEN
@@ -610,5 +621,5 @@
                                tmp_particle%rvar1      = 1.0E-6_wp     !last Rosenbrock timestep
                                tmp_particle%rvar2      = 0.1E-6_wp     !dry aerosol radius
-                               tmp_particle%rvar3      = -9999999.9_wp !unused
+                               tmp_particle%rvar3      = -9999999.9_wp !unused in this configuration
                             ELSE
 !
@@ -628,9 +639,8 @@
                             tmp_particle%class         = 1
                             tmp_particle%group         = i
-                            tmp_particle%tailpoints    = 0     !unused
+                            tmp_particle%id1           = 0 
+                            tmp_particle%id2           = 0 
                             tmp_particle%particle_mask = .TRUE.
-                            tmp_particle%tail_id       = 0     !unused
-
-
+                            tmp_particle%block_nr      = -1
 !
 !--                         Determine the grid indices of the particle position
@@ -722,4 +732,27 @@
     local_start = prt_count+1
     prt_count   = local_count
+
+!
+!-- Calculate particle IDs
+    DO  ip = nxl, nxr
+       DO  jp = nys, nyn
+          DO  kp = nzb+1, nzt
+             number_of_particles = prt_count(kp,jp,ip)
+             IF ( number_of_particles <= 0 )  CYCLE
+             particles => grid_particles(kp,jp,ip)%particles(1:number_of_particles)
+
+             DO  n = local_start(kp,jp,ip), number_of_particles  !only new particles 
+
+                particles(n)%id1 = 10000 * grid_particles(kp,jp,ip)%id_counter + kp
+                particles(n)%id2 = 10000 * jp + ip
+
+                grid_particles(kp,jp,ip)%id_counter =                          &
+                                         grid_particles(kp,jp,ip)%id_counter + 1
+
+             ENDDO
+
+          ENDDO
+       ENDDO
+    ENDDO
 
 !
@@ -837,5 +870,5 @@
 
     USE cloud_parameters,                                                      &
-        ONLY: l_d_rv, rho_l
+        ONLY: l_d_rv, rho_l, r_v
 
     USE constants,                                                             &
@@ -854,4 +887,5 @@
     REAL(wp), DIMENSION(:), ALLOCATABLE ::  r_temp  !< dry aerosol radius spectrum
 
+    REAL(wp)  :: afactor            !< curvature effects
     REAL(wp)  :: bfactor            !< solute effects
     REAL(wp)  :: dr                 !< width of radius bin
@@ -864,4 +898,5 @@
     REAL(wp)  :: rs_rand            !< random number
     REAL(wp)  :: r_mid              !< mean radius
+    REAL(wp)  :: sigma              !< surface tension
     REAL(wp)  :: t_int              !< temperature
     REAL(wp)  :: weight_sum         !< sum of all weighting factors
@@ -1035,34 +1070,26 @@
              e_a = q(kp,jp,ip) * hyp(kp) / ( 0.378_wp * q(kp,jp,ip) + 0.622_wp )
 
+             sigma   = 0.0761_wp - 0.000155_wp * ( t_int - 273.15_wp )
+             afactor = 2.0_wp * sigma / ( rho_l * r_v * t_int )
+
+             bfactor = vanthoff * molecular_weight_of_water *    &
+                       rho_s / ( molecular_weight_of_solute * rho_l )
 !
 !--          The formula is only valid for subsaturated environments. For 
-!--          supersaturations higher than -1 %, the supersaturation is set to -1%.
-             IF ( e_a / e_s < 0.99_wp )  THEN
-
-                DO  n = local_start(kp,jp,ip), number_of_particles  !only new particles 
-
-                   bfactor             = vanthoff * molecular_weight_of_water *    &
-                                         rho_s * particles(n)%rvar2**3 /           &
-                                         ( molecular_weight_of_solute * rho_l )
-                   particles(n)%radius = particles(n)%rvar2 * ( bfactor /          &
-                                         particles(n)%rvar2**3 )**(1.0_wp/3.0_wp) *&
-                                         ( 1.0_wp - e_a / e_s )**(-1.0_wp/3.0_wp)
-
-                ENDDO
-
-             ELSE
-
-                DO  n = local_start(kp,jp,ip), number_of_particles  !only new particles 
-
-                   bfactor             = vanthoff * molecular_weight_of_water *    &
-                                         rho_s * particles(n)%rvar2**3 /           &
-                                         ( molecular_weight_of_solute * rho_l )
-                   particles(n)%radius = particles(n)%rvar2 * ( bfactor /          &
-                                         particles(n)%rvar2**3 )**(1.0_wp/3.0_wp) *&
-                                         0.01_wp**(-1.0_wp/3.0_wp)
-
-                ENDDO
-
-             ENDIF
+!--          supersaturations higher than -5 %, the supersaturation is set to -5%.
+             IF ( e_a / e_s >= 0.95_wp )  e_a = 0.95_wp * e_s
+
+             DO  n = local_start(kp,jp,ip), number_of_particles  !only new particles 
+!
+!--             For details on this equation, see Eq. (14) of Khvorostyanov and 
+!--             Curry (2007, JGR) 
+                particles(n)%radius = bfactor**0.3333333_wp *                  &
+                   particles(n)%rvar2 / ( 1.0_wp - e_a / e_s )**0.3333333_wp / &
+                   ( 1.0_wp + ( afactor / ( 3.0_wp * bfactor**0.3333333_wp *   &
+                     particles(n)%rvar2 ) ) /                                  &
+                     ( 1.0_wp - e_a / e_s )**0.6666666_wp                      &
+                   )
+
+             ENDDO
 
           ENDDO
Index: palm/trunk/SOURCE/lpm_set_attributes.f90
===================================================================
--- palm/trunk/SOURCE/lpm_set_attributes.f90	(revision 2119)
+++ palm/trunk/SOURCE/lpm_set_attributes.f90	(revision 2122)
@@ -20,5 +20,5 @@
 ! Current revisions:
 ! -----------------
-! 
+! DVRP routine removed
 ! 
 ! Former revisions:
@@ -397,82 +397,4 @@
     ENDIF
 
-!
-!-- Set particle size for dvrp graphics
-    IF ( particle_dvrpsize == 'absw' )  THEN
-
-       DO  ip = nxl, nxr
-          DO  jp = nys, nyn
-             DO  kp = nzb+1, nzt
-
-                number_of_particles = prt_count(kp,jp,ip)
-                particles => grid_particles(kp,jp,ip)%particles(1:number_of_particles)
-                IF ( number_of_particles <= 0 )  CYCLE
-                start_index = grid_particles(kp,jp,ip)%start_index
-                end_index   = grid_particles(kp,jp,ip)%end_index
-
-                ALLOCATE( xv(1:number_of_particles), &
-                          yv(1:number_of_particles) )
-
-                xv = particles(1:number_of_particles)%x
-                yv = particles(1:number_of_particles)%y
-                zv = particles(1:number_of_particles)%z
-
-                DO  nb = 0,7
-
-                   i = ip + block_offset(nb)%i_off
-                   j = jp + block_offset(nb)%j_off
-                   k = kp-1
-
-                   DO  n = start_index(nb), end_index(nb)
-!
-!--                   Interpolate w-component to the current particle position
-                      x  = xv(n) - i * dx
-                      y  = yv(n) - j * dy
-                      aa = x**2          + y**2
-                      bb = ( dx - x )**2 + y**2
-                      cc = x**2          + ( dy - y )**2
-                      dd = ( dx - x )**2 + ( dy - y )**2
-                      gg = aa + bb + cc + dd
-
-                      w_int_l = ( ( gg - aa ) * w(k,j,i)   + ( gg - bb ) *     &
-                                  w(k,j,i+1) + ( gg - cc ) * w(k,j+1,i) +      &
-                                  ( gg - dd ) * w(k,j+1,i+1)                   &
-                                ) / ( 3.0_wp * gg )
-
-                      IF ( k+1 == nzt+1 )  THEN
-                         w_int = w_int_l
-                      ELSE
-                         w_int_u = ( ( gg - aa ) * w(k+1,j,i)   + ( gg - bb ) *  &
-                                     w(k+1,j,i+1) + ( gg - cc ) * w(k+1,j+1,i) + &
-                                     ( gg - dd ) * w(k+1,j+1,i+1)                &
-                                   ) / ( 3.0_wp * gg )
-                         w_int = w_int_l + ( zv(n) - zw(k) ) / dz *     &
-                                           ( w_int_u - w_int_l )
-                      ENDIF
-
-!
-!--                   Limit values by the given interval and normalize to
-!--                   interval [0,1]
-                      w_int = ABS( w_int )
-                      w_int = MIN( w_int, dvrpsize_interval(2) )
-                      w_int = MAX( w_int, dvrpsize_interval(1) )
-
-                      w_int = ( w_int - dvrpsize_interval(1) ) / &
-                              ( dvrpsize_interval(2) - dvrpsize_interval(1) )
-
-                      particles(n)%dvrp_psize = ( 0.25_wp + w_int * 0.6_wp ) * &
-                                                dx
-
-                   ENDDO
-                ENDDO
-
-                DEALLOCATE( xv, yv, zv )
-
-             ENDDO
-          ENDDO
-       ENDDO
-
-    ENDIF
-
     CALL cpu_log( log_point_s(49), 'lpm_set_attributes', 'stop' )
 
Index: palm/trunk/SOURCE/mod_particle_attributes.f90
===================================================================
--- palm/trunk/SOURCE/mod_particle_attributes.f90	(revision 2119)
+++ palm/trunk/SOURCE/mod_particle_attributes.f90	(revision 2122)
@@ -20,5 +20,7 @@
 ! Current revisions:
 ! ------------------
-! 
+! Calculation of particle ID
+! Particle attribute dvrp_psize renamed to user: this attribute can be used by
+! by the user to store any variable
 ! 
 ! Former revisions:
@@ -134,8 +136,8 @@
     TYPE particle_type
         SEQUENCE
-        REAL(wp)     ::  radius, age, age_m, dt_sum, dvrp_psize, e_m,          &
+        REAL(wp)     ::  radius, age, age_m, dt_sum, user, e_m,                &
                          origin_x, origin_y, origin_z, rvar1, rvar2, rvar3,    &
                          speed_x, speed_y, speed_z, weight_factor, x, y, z
-        INTEGER(iwp) ::  class, group, tailpoints, tail_id
+        INTEGER(iwp) ::  class, group, id1, id2
         LOGICAL      ::  particle_mask
         INTEGER(iwp) ::  block_nr
@@ -156,4 +158,5 @@
         INTEGER(iwp), DIMENSION(0:7)               ::  start_index
         INTEGER(iwp), DIMENSION(0:7)               ::  end_index
+        INTEGER(iwp)                               ::  id_counter
         LOGICAL                                    ::  time_loop_done
         TYPE(particle_type), POINTER, DIMENSION(:) ::  particles                !Particle array for this grid cell
