Changeset 2305 for palm/trunk/SOURCE


Ignore:
Timestamp:
Jul 6, 2017 11:18:47 AM (7 years ago)
Author:
hoffmann
Message:

Improved calculation of particle IDs.

Location:
palm/trunk/SOURCE
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • palm/trunk/SOURCE/lpm_exchange_horiz.f90

    r2245 r2305  
    2525! -----------------
    2626! $Id$
     27! Improved calculation of particle IDs.
     28!
     29! 2245 2017-06-02 14:37:10Z schwenkel
    2730! Bugfix in Add_particles_to_gridcell:
    2831! Apply boundary conditions also in y-direction
     
    106109 MODULE lpm_exchange_horiz_mod
    107110 
     111    USE, INTRINSIC ::  ISO_C_BINDING
    108112
    109113    USE control_parameters,                                                    &
     
    130134        ONLY:  alloc_factor, deleted_particles, grid_particles,                &
    131135               ibc_par_lr, ibc_par_ns, min_nr_particle,                        &
    132                mpi_particle_type, number_of_particles,                         &
     136               number_of_particles,                                            &
    133137               offset_ocean_nzt, offset_ocean_nzt_m1, particles,               &
    134138               particle_type, prt_count, trlp_count_sum,                       &
     
    195199    INTEGER(iwp) ::  kp                !< index variable along z
    196200    INTEGER(iwp) ::  n                 !< particle index variable
     201    INTEGER(iwp) ::  par_size          !< Particle size in bytes
    197202    INTEGER(iwp) ::  trlp_count        !< number of particles send to left PE
    198203    INTEGER(iwp) ::  trlp_count_recv   !< number of particles receive from right PE
     
    419424
    420425       ALLOCATE(rvrp(MAX(1,trrp_count_recv)))
    421 
    422        CALL MPI_SENDRECV( trlp(1)%radius, max(1,trlp_count), mpi_particle_type,&
    423                           pleft, 1, rvrp(1)%radius,                            &
    424                           max(1,trrp_count_recv), mpi_particle_type, pright, 1,&
     426!     
     427!--    This MPI_SENDRECV should work even with odd mixture on 32 and 64 Bit
     428!--    variables in structure particle_type (due to the calculation of par_size)
     429       par_size = c_sizeof(trlp(1))
     430       CALL MPI_SENDRECV( trlp, max(1,trlp_count)*par_size, MPI_BYTE,&
     431                          pleft, 1, rvrp,                            &
     432                          max(1,trrp_count_recv)*par_size, MPI_BYTE, pright, 1,&
    425433                          comm2d, status, ierr )
    426434
     
    436444
    437445       ALLOCATE(rvlp(MAX(1,trlp_count_recv)))
    438 
    439        CALL MPI_SENDRECV( trrp(1)%radius, max(1,trrp_count), mpi_particle_type,&
    440                           pright, 1, rvlp(1)%radius,                           &
    441                           max(1,trlp_count_recv), mpi_particle_type, pleft, 1, &
     446!     
     447!--    This MPI_SENDRECV should work even with odd mixture on 32 and 64 Bit
     448!--    variables in structure particle_type (due to the calculation of par_size)
     449       par_size = c_sizeof(trrp(1))
     450       CALL MPI_SENDRECV( trrp, max(1,trrp_count)*par_size, MPI_BYTE,&
     451                          pright, 1, rvlp,                           &
     452                          max(1,trlp_count_recv)*par_size, MPI_BYTE, pleft, 1, &
    442453                          comm2d, status, ierr )
    443454
     
    641652
    642653       ALLOCATE(rvnp(MAX(1,trnp_count_recv)))
    643  
    644        CALL MPI_SENDRECV( trsp(1)%radius, trsp_count, mpi_particle_type,      &
    645                           psouth, 1, rvnp(1)%radius,                             &
    646                           trnp_count_recv, mpi_particle_type, pnorth, 1,   &
     654!     
     655!--    This MPI_SENDRECV should work even with odd mixture on 32 and 64 Bit
     656!--    variables in structure particle_type (due to the calculation of par_size)
     657       par_size = c_sizeof(trsp(1))
     658       CALL MPI_SENDRECV( trsp, trsp_count*par_size, MPI_BYTE,      &
     659                          psouth, 1, rvnp,                             &
     660                          trnp_count_recv*par_size, MPI_BYTE, pnorth, 1,   &
    647661                          comm2d, status, ierr )
    648662
     
    658672
    659673       ALLOCATE(rvsp(MAX(1,trsp_count_recv)))
    660 
    661        CALL MPI_SENDRECV( trnp(1)%radius, trnp_count, mpi_particle_type,      &
    662                           pnorth, 1, rvsp(1)%radius,                          &
    663                           trsp_count_recv, mpi_particle_type, psouth, 1,   &
     674!     
     675!--    This MPI_SENDRECV should work even with odd mixture on 32 and 64 Bit
     676!--    variables in structure particle_type (due to the calculation of par_size)
     677       par_size = c_sizeof(trnp(1))
     678       CALL MPI_SENDRECV( trnp, trnp_count*par_size, MPI_BYTE,      &
     679                          pnorth, 1, rvsp,                          &
     680                          trsp_count_recv*par_size, MPI_BYTE, psouth, 1,   &
    664681                          comm2d, status, ierr )
    665682
  • palm/trunk/SOURCE/lpm_init.f90

    r2274 r2305  
    2525! -----------------
    2626! $Id$
     27! Improved calculation of particle IDs.
     28!
     29! 2274 2017-06-09 13:27:48Z Giersch
    2730!  Changed error messages
    2831!
     
    4447! 2182 2017-03-17 14:27:40Z schwenkel
    4548! Added parameters for simplified particle initialization.
    46 ! 
     49!
    4750! 2122 2017-01-18 12:22:54Z hoffmann
    4851! Improved initialization of equilibrium aerosol radii
     
    157160 MODULE lpm_init_mod
    158161 
     162    USE, INTRINSIC ::  ISO_C_BINDING
    159163
    160164    USE arrays_3d,                                                             &
     
    187191                ibc_par_lr, ibc_par_ns, ibc_par_t, iran_part, log_z_z0,        &
    188192                max_number_of_particle_groups, min_nr_particle,                &
    189                 mpi_particle_type, number_concentration,                       &
     193                number_concentration,                                          &
    190194                number_particles_per_gridbox,  number_of_particles,            &
    191195                number_of_particle_groups, number_of_sublayers,                &
     
    243247    INTEGER(iwp) ::  k                           !<
    244248
    245 #if defined( __parallel )
    246     INTEGER(iwp), DIMENSION(3) ::  blocklengths  !<
    247     INTEGER(iwp), DIMENSION(3) ::  displacements !<
    248     INTEGER(iwp), DIMENSION(3) ::  types         !<
    249 #endif
    250 
    251249    REAL(wp) ::  div                             !<
    252250    REAL(wp) ::  height_int                      !<
     
    255253    REAL(wp) ::  z0_av_local                     !<
    256254
    257 #if defined( __parallel )
    258 !
    259 !-- Define MPI derived datatype for FORTRAN datatype particle_type (see module
    260 !-- particle_attributes). Integer length is 4 byte, Real is 8 byte
    261     blocklengths(1)  = 19;  blocklengths(2)  =   6;  blocklengths(3)  =   1
    262     displacements(1) =  0;  displacements(2) = 152;  displacements(3) = 176
    263 
    264     types(1) = MPI_REAL
    265     types(2) = MPI_INTEGER
    266     types(3) = MPI_UB
    267     CALL MPI_TYPE_STRUCT( 3, blocklengths, displacements, types, &
    268                           mpi_particle_type, ierr )
    269     CALL MPI_TYPE_COMMIT( mpi_particle_type, ierr )
    270 #endif
    271255
    272256!
     
    541525!
    542526!--    initialize counter for particle IDs
    543        grid_particles%id_counter = 0
     527       grid_particles%id_counter = 1
    544528
    545529!
     
    551535                                      0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp,  &
    552536                                      0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp,          &
    553                                       0, 0, 0, 0, .FALSE., -1 )
     537                                      0, 0, 0_idp, .FALSE., -1 )
    554538
    555539       particle_groups = particle_groups_type( 0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp )
     
    697681
    698682                            DO  j = 1, particles_per_point
     683
    699684
    700685                               n = n + 1
     
    731716                               tmp_particle%class         = 1
    732717                               tmp_particle%group         = i
    733                                tmp_particle%id1           = 0
    734                                tmp_particle%id2           = 0
     718                               tmp_particle%id            = 0_idp
    735719                               tmp_particle%particle_mask = .TRUE.
    736720                               tmp_particle%block_nr      = -1
     
    858842             DO  n = local_start(kp,jp,ip), number_of_particles  !only new particles
    859843
    860                 particles(n)%id1 = 10000_iwp * grid_particles(kp,jp,ip)%id_counter + kp
    861                 particles(n)%id2 = 10000_iwp * jp + ip
    862 
     844                particles(n)%id = 10000_idp**3 * grid_particles(kp,jp,ip)%id_counter + &
     845                                  10000_idp**2 * kp + 10000_idp * jp + ip
     846!
     847!--             Count the number of particles that have been released before
    863848                grid_particles(kp,jp,ip)%id_counter =                          &
    864849                                         grid_particles(kp,jp,ip)%id_counter + 1
  • palm/trunk/SOURCE/lpm_read_restart_file.f90

    r2265 r2305  
    2525! -----------------
    2626! $Id$
     27! Improved calculation of particle IDs.
     28!
     29! 2265 2017-06-08 16:58:28Z schwenkel
    2730! Unused variables removed.
    2831!
     
    122125                                   0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp,  &
    123126                                   0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp,  &
    124                                    0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, 0, 0, 0, &
    125                                    0, .FALSE., -1)
     127                                   0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp,         &
     128                                   0, 0, 0_idp, .FALSE., -1 )
    126129!
    127130!-- Read some particle parameters and the size of the particle arrays,
  • palm/trunk/SOURCE/mod_particle_attributes.f90

    r2278 r2305  
    2525! -----------------
    2626! $Id$
     27! Improved calculation of particle IDs.
     28!
     29! 2278 2017-06-12 13:08:18Z schwenkel
    2730! Added comments
    2831!
     
    111114    INTEGER(iwp) ::  merge_drp = 0                                !< number of merged droplets
    112115    INTEGER(iwp) ::  min_nr_particle = 50                         !< namelist parameter (see documentation)         
    113     INTEGER(iwp) ::  mpi_particle_type                            !< parameter for particle PE particle exchange
    114116    INTEGER(iwp) ::  new_particles = 0                            !< number of new particles
    115117    INTEGER(iwp) ::  n_max = 100                                  !< number of radii bin for splitting functions     
     
    210212   
    211213    TYPE particle_type
    212         SEQUENCE
    213214        REAL(wp)     ::  radius        !< radius of particle
    214215        REAL(wp)     ::  age           !< age of particle
     
    232233        INTEGER(iwp) ::  class         !< radius class needed for collision
    233234        INTEGER(iwp) ::  group         !< number of particle group
    234         INTEGER(iwp) ::  id1           !< first part of particle id
    235         INTEGER(iwp) ::  id2           !< second part of particle id
     235        INTEGER(idp) ::  id            !< particle ID (64 bit integer)
    236236        LOGICAL      ::  particle_mask !< if this parameter is set to false the particle will be deleted
    237237        INTEGER(iwp) ::  block_nr      !< number for sorting (removable?)
     
    255255        INTEGER(iwp), DIMENSION(0:7)               ::  start_index        !< start particle index for current block
    256256        INTEGER(iwp), DIMENSION(0:7)               ::  end_index          !< end particle index for current block
    257         INTEGER(iwp)                               ::  id_counter         !< particle id counter (removeable?)
     257        INTEGER(iwp)                               ::  id_counter         !< particle id counter
    258258        LOGICAL                                    ::  time_loop_done     !< timestep loop for particle advection
    259259        TYPE(particle_type), POINTER, DIMENSION(:) ::  particles          !< Particle array for this grid cell
Note: See TracChangeset for help on using the changeset viewer.