Index: /palm/trunk/SOURCE/lpm_exchange_horiz.f90
===================================================================
--- /palm/trunk/SOURCE/lpm_exchange_horiz.f90	(revision 2304)
+++ /palm/trunk/SOURCE/lpm_exchange_horiz.f90	(revision 2305)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Improved calculation of particle IDs.
+! 
+! 2245 2017-06-02 14:37:10Z schwenkel
 ! Bugfix in Add_particles_to_gridcell:
 ! Apply boundary conditions also in y-direction
@@ -106,4 +109,5 @@
  MODULE lpm_exchange_horiz_mod
  
+    USE, INTRINSIC ::  ISO_C_BINDING
 
     USE control_parameters,                                                    &
@@ -130,5 +134,5 @@
         ONLY:  alloc_factor, deleted_particles, grid_particles,                &
                ibc_par_lr, ibc_par_ns, min_nr_particle,                        &
-               mpi_particle_type, number_of_particles,                         &
+               number_of_particles,                                            &
                offset_ocean_nzt, offset_ocean_nzt_m1, particles,               &
                particle_type, prt_count, trlp_count_sum,                       &
@@ -195,4 +199,5 @@
     INTEGER(iwp) ::  kp                !< index variable along z
     INTEGER(iwp) ::  n                 !< particle index variable 
+    INTEGER(iwp) ::  par_size          !< Particle size in bytes
     INTEGER(iwp) ::  trlp_count        !< number of particles send to left PE
     INTEGER(iwp) ::  trlp_count_recv   !< number of particles receive from right PE
@@ -419,8 +424,11 @@
 
        ALLOCATE(rvrp(MAX(1,trrp_count_recv)))
-
-       CALL MPI_SENDRECV( trlp(1)%radius, max(1,trlp_count), mpi_particle_type,&
-                          pleft, 1, rvrp(1)%radius,                            &
-                          max(1,trrp_count_recv), mpi_particle_type, pright, 1,&
+!      
+!--    This MPI_SENDRECV should work even with odd mixture on 32 and 64 Bit 
+!--    variables in structure particle_type (due to the calculation of par_size)
+       par_size = c_sizeof(trlp(1))
+       CALL MPI_SENDRECV( trlp, max(1,trlp_count)*par_size, MPI_BYTE,&
+                          pleft, 1, rvrp,                            &
+                          max(1,trrp_count_recv)*par_size, MPI_BYTE, pright, 1,&
                           comm2d, status, ierr )
 
@@ -436,8 +444,11 @@
 
        ALLOCATE(rvlp(MAX(1,trlp_count_recv)))
-
-       CALL MPI_SENDRECV( trrp(1)%radius, max(1,trrp_count), mpi_particle_type,&
-                          pright, 1, rvlp(1)%radius,                           &
-                          max(1,trlp_count_recv), mpi_particle_type, pleft, 1, &
+!      
+!--    This MPI_SENDRECV should work even with odd mixture on 32 and 64 Bit 
+!--    variables in structure particle_type (due to the calculation of par_size)
+       par_size = c_sizeof(trrp(1))
+       CALL MPI_SENDRECV( trrp, max(1,trrp_count)*par_size, MPI_BYTE,&
+                          pright, 1, rvlp,                           &
+                          max(1,trlp_count_recv)*par_size, MPI_BYTE, pleft, 1, &
                           comm2d, status, ierr )
 
@@ -641,8 +652,11 @@
 
        ALLOCATE(rvnp(MAX(1,trnp_count_recv)))
- 
-       CALL MPI_SENDRECV( trsp(1)%radius, trsp_count, mpi_particle_type,      &
-                          psouth, 1, rvnp(1)%radius,                             &
-                          trnp_count_recv, mpi_particle_type, pnorth, 1,   &
+!      
+!--    This MPI_SENDRECV should work even with odd mixture on 32 and 64 Bit 
+!--    variables in structure particle_type (due to the calculation of par_size)
+       par_size = c_sizeof(trsp(1))
+       CALL MPI_SENDRECV( trsp, trsp_count*par_size, MPI_BYTE,      &
+                          psouth, 1, rvnp,                             &
+                          trnp_count_recv*par_size, MPI_BYTE, pnorth, 1,   &
                           comm2d, status, ierr )
 
@@ -658,8 +672,11 @@
 
        ALLOCATE(rvsp(MAX(1,trsp_count_recv)))
-
-       CALL MPI_SENDRECV( trnp(1)%radius, trnp_count, mpi_particle_type,      &
-                          pnorth, 1, rvsp(1)%radius,                          &
-                          trsp_count_recv, mpi_particle_type, psouth, 1,   &
+!      
+!--    This MPI_SENDRECV should work even with odd mixture on 32 and 64 Bit 
+!--    variables in structure particle_type (due to the calculation of par_size)
+       par_size = c_sizeof(trnp(1))
+       CALL MPI_SENDRECV( trnp, trnp_count*par_size, MPI_BYTE,      &
+                          pnorth, 1, rvsp,                          &
+                          trsp_count_recv*par_size, MPI_BYTE, psouth, 1,   &
                           comm2d, status, ierr )
 
Index: /palm/trunk/SOURCE/lpm_init.f90
===================================================================
--- /palm/trunk/SOURCE/lpm_init.f90	(revision 2304)
+++ /palm/trunk/SOURCE/lpm_init.f90	(revision 2305)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Improved calculation of particle IDs.
+! 
+! 2274 2017-06-09 13:27:48Z Giersch
 !  Changed error messages
 ! 
@@ -44,5 +47,5 @@
 ! 2182 2017-03-17 14:27:40Z schwenkel
 ! Added parameters for simplified particle initialization.
-! 
+!
 ! 2122 2017-01-18 12:22:54Z hoffmann
 ! Improved initialization of equilibrium aerosol radii 
@@ -157,4 +160,5 @@
  MODULE lpm_init_mod
  
+    USE, INTRINSIC ::  ISO_C_BINDING
 
     USE arrays_3d,                                                             &
@@ -187,5 +191,5 @@
                 ibc_par_lr, ibc_par_ns, ibc_par_t, iran_part, log_z_z0,        &
                 max_number_of_particle_groups, min_nr_particle,                &
-                mpi_particle_type, number_concentration,                       &
+                number_concentration,                                          &
                 number_particles_per_gridbox,  number_of_particles,            &
                 number_of_particle_groups, number_of_sublayers,                &
@@ -243,10 +247,4 @@
     INTEGER(iwp) ::  k                           !<
 
-#if defined( __parallel )
-    INTEGER(iwp), DIMENSION(3) ::  blocklengths  !<
-    INTEGER(iwp), DIMENSION(3) ::  displacements !<
-    INTEGER(iwp), DIMENSION(3) ::  types         !<
-#endif
-
     REAL(wp) ::  div                             !< 
     REAL(wp) ::  height_int                      !<
@@ -255,18 +253,4 @@
     REAL(wp) ::  z0_av_local                     !<
 
-#if defined( __parallel )
-!
-!-- Define MPI derived datatype for FORTRAN datatype particle_type (see module
-!-- particle_attributes). Integer length is 4 byte, Real is 8 byte
-    blocklengths(1)  = 19;  blocklengths(2)  =   6;  blocklengths(3)  =   1
-    displacements(1) =  0;  displacements(2) = 152;  displacements(3) = 176
-
-    types(1) = MPI_REAL
-    types(2) = MPI_INTEGER
-    types(3) = MPI_UB
-    CALL MPI_TYPE_STRUCT( 3, blocklengths, displacements, types, &
-                          mpi_particle_type, ierr )
-    CALL MPI_TYPE_COMMIT( mpi_particle_type, ierr )
-#endif
 
 !
@@ -541,5 +525,5 @@
 !
 !--    initialize counter for particle IDs 
-       grid_particles%id_counter = 0
+       grid_particles%id_counter = 1
 
 !
@@ -551,5 +535,5 @@
                                       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, 0_idp, .FALSE., -1 )
 
        particle_groups = particle_groups_type( 0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp )
@@ -697,4 +681,5 @@
 
                             DO  j = 1, particles_per_point
+
 
                                n = n + 1
@@ -731,6 +716,5 @@
                                tmp_particle%class         = 1
                                tmp_particle%group         = i
-                               tmp_particle%id1           = 0 
-                               tmp_particle%id2           = 0 
+                               tmp_particle%id            = 0_idp
                                tmp_particle%particle_mask = .TRUE.
                                tmp_particle%block_nr      = -1
@@ -858,7 +842,8 @@
              DO  n = local_start(kp,jp,ip), number_of_particles  !only new particles 
 
-                particles(n)%id1 = 10000_iwp * grid_particles(kp,jp,ip)%id_counter + kp
-                particles(n)%id2 = 10000_iwp * jp + ip
-
+                particles(n)%id = 10000_idp**3 * grid_particles(kp,jp,ip)%id_counter + &
+                                  10000_idp**2 * kp + 10000_idp * jp + ip
+!
+!--             Count the number of particles that have been released before
                 grid_particles(kp,jp,ip)%id_counter =                          &
                                          grid_particles(kp,jp,ip)%id_counter + 1
Index: /palm/trunk/SOURCE/lpm_read_restart_file.f90
===================================================================
--- /palm/trunk/SOURCE/lpm_read_restart_file.f90	(revision 2304)
+++ /palm/trunk/SOURCE/lpm_read_restart_file.f90	(revision 2305)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Improved calculation of particle IDs.
+! 
+! 2265 2017-06-08 16:58:28Z schwenkel
 ! Unused variables removed.
 ! 
@@ -122,6 +125,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_idp, .FALSE., -1 )
 !
 !-- Read some particle parameters and the size of the particle arrays,
Index: /palm/trunk/SOURCE/mod_particle_attributes.f90
===================================================================
--- /palm/trunk/SOURCE/mod_particle_attributes.f90	(revision 2304)
+++ /palm/trunk/SOURCE/mod_particle_attributes.f90	(revision 2305)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Improved calculation of particle IDs.
+! 
+! 2278 2017-06-12 13:08:18Z schwenkel
 ! Added comments
 ! 
@@ -111,5 +114,4 @@
     INTEGER(iwp) ::  merge_drp = 0                                !< number of merged droplets
     INTEGER(iwp) ::  min_nr_particle = 50                         !< namelist parameter (see documentation)         
-    INTEGER(iwp) ::  mpi_particle_type                            !< parameter for particle PE particle exchange
     INTEGER(iwp) ::  new_particles = 0                            !< number of new particles
     INTEGER(iwp) ::  n_max = 100                                  !< number of radii bin for splitting functions     
@@ -210,5 +212,4 @@
     
     TYPE particle_type
-        SEQUENCE
         REAL(wp)     ::  radius        !< radius of particle
         REAL(wp)     ::  age           !< age of particle
@@ -232,6 +233,5 @@
         INTEGER(iwp) ::  class         !< radius class needed for collision
         INTEGER(iwp) ::  group         !< number of particle group
-        INTEGER(iwp) ::  id1           !< first part of particle id
-        INTEGER(iwp) ::  id2           !< second part of particle id
+        INTEGER(idp) ::  id            !< particle ID (64 bit integer)
         LOGICAL      ::  particle_mask !< if this parameter is set to false the particle will be deleted
         INTEGER(iwp) ::  block_nr      !< number for sorting (removable?)
@@ -255,5 +255,5 @@
         INTEGER(iwp), DIMENSION(0:7)               ::  start_index        !< start particle index for current block
         INTEGER(iwp), DIMENSION(0:7)               ::  end_index          !< end particle index for current block
-        INTEGER(iwp)                               ::  id_counter         !< particle id counter (removeable?)
+        INTEGER(iwp)                               ::  id_counter         !< particle id counter
         LOGICAL                                    ::  time_loop_done     !< timestep loop for particle advection
         TYPE(particle_type), POINTER, DIMENSION(:) ::  particles          !< Particle array for this grid cell
