SUBROUTINE lpm_release_set !------------------------------------------------------------------------------! ! Current revisions: ! ------------------ ! ! ! Former revisions: ! ----------------- ! $Id: lpm_release_set.f90 850 2012-03-15 12:09:25Z letzel $ ! ! 849 2012-03-15 10:35:09Z raasch ! initial revision (former part of advec_particles) ! ! ! Description: ! ------------ ! Release a new set of particles and, if required, particle tails. These ! particles/tails are added at the end of the existing arrays. Extend the ! respective particle and tail arrays, if neccessary. !------------------------------------------------------------------------------! USE control_parameters USE grid_variables USE indices USE particle_attributes USE random_function_mod IMPLICIT NONE INTEGER :: ie, is, n, nn ! !-- Check, if particle storage must be extended IF ( number_of_particles + number_of_initial_particles > & maximum_number_of_particles ) THEN IF ( netcdf_output .AND. netcdf_data_format < 3 ) THEN message_string = 'maximum_number_of_particles needs to be increa' // & 'sed &but this is not allowed with netcdf_data_' // & 'format < 3' CALL message( 'lpm_release_set', 'PA0146', 2, 2, -1, 6, 1 ) ELSE CALL lpm_extend_particle_array( number_of_initial_particles ) ENDIF ENDIF ! !-- Check, if tail storage must be extended IF ( use_particle_tails ) THEN IF ( number_of_tails + number_of_initial_tails > & maximum_number_of_tails ) THEN IF ( netcdf_output .AND. netcdf_data_format < 3 ) THEN message_string = 'maximum_number_of_tails needs to be increas' // & 'ed &but this is not allowed with netcdf_dat' // & 'a_format < 3' CALL message( 'lpm_release_set', 'PA0147', 2, 2, -1, 6, 1 ) ELSE CALL lpm_extend_tail_array( number_of_initial_tails ) ENDIF ENDIF ENDIF IF ( number_of_initial_particles /= 0 ) THEN is = number_of_particles + 1 ie = number_of_particles + number_of_initial_particles particles(is:ie) = initial_particles(1:number_of_initial_particles) ! !-- Add random fluctuation to particle positions. Particles should !-- remain in the subdomain. IF ( random_start_position ) THEN DO n = is, ie IF ( psl(particles(n)%group) /= psr(particles(n)%group) ) THEN particles(n)%x = particles(n)%x + & ( random_function( iran_part ) - 0.5 ) * & pdx(particles(n)%group) IF ( particles(n)%x <= ( nxl - 0.5 ) * dx ) THEN particles(n)%x = ( nxl - 0.4999999999 ) * dx ELSEIF ( particles(n)%x >= ( nxr + 0.5 ) * dx ) THEN particles(n)%x = ( nxr + 0.4999999999 ) * dx ENDIF ENDIF IF ( pss(particles(n)%group) /= psn(particles(n)%group) ) THEN particles(n)%y = particles(n)%y + & ( random_function( iran_part ) - 0.5 ) * & pdy(particles(n)%group) IF ( particles(n)%y <= ( nys - 0.5 ) * dy ) THEN particles(n)%y = ( nys - 0.4999999999 ) * dy ELSEIF ( particles(n)%y >= ( nyn + 0.5 ) * dy ) THEN particles(n)%y = ( nyn + 0.4999999999 ) * dy ENDIF ENDIF IF ( psb(particles(n)%group) /= pst(particles(n)%group) ) THEN particles(n)%z = particles(n)%z + & ( random_function( iran_part ) - 0.5 ) * & pdz(particles(n)%group) ENDIF ENDDO ENDIF ! !-- Set the beginning of the new particle tails and their age IF ( use_particle_tails ) THEN DO n = is, ie ! !-- New particles which should have a tail, already have got a !-- provisional tail id unequal zero (see lpm_init) IF ( particles(n)%tail_id /= 0 ) THEN number_of_tails = number_of_tails + 1 nn = number_of_tails particles(n)%tail_id = nn ! set the final tail id particle_tail_coordinates(1,1,nn) = particles(n)%x particle_tail_coordinates(1,2,nn) = particles(n)%y particle_tail_coordinates(1,3,nn) = particles(n)%z particle_tail_coordinates(1,4,nn) = particles(n)%class particles(n)%tailpoints = 1 IF ( minimum_tailpoint_distance /= 0.0 ) THEN particle_tail_coordinates(2,1,nn) = particles(n)%x particle_tail_coordinates(2,2,nn) = particles(n)%y particle_tail_coordinates(2,3,nn) = particles(n)%z particle_tail_coordinates(2,4,nn) = particles(n)%class particle_tail_coordinates(1:2,5,nn) = 0.0 particles(n)%tailpoints = 2 ENDIF ENDIF ENDDO ENDIF number_of_particles = number_of_particles + number_of_initial_particles ENDIF END SUBROUTINE lpm_release_set