@@ -235,6 +235,7 @@ SUBROUTINE run_file_injection(injector)
235235 REAL (num) :: next_time, time_to_bdy
236236 REAL (num) :: vx, vy, gamma, inv_gamma_mass, iabs_p
237237 REAL (num) :: x_start, y_start
238+ REAL (num) :: low_in, high_in
238239 TYPE (particle), POINTER :: new
239240 TYPE (particle_list) :: plist
240241 LOGICAL :: no_particles_added, skip_processor
@@ -375,13 +376,25 @@ SUBROUTINE run_file_injection(injector)
375376 ! particle
376377 IF (boundary == c_bd_x_min .OR. boundary == c_bd_x_max) THEN
377378 ! Skip all processors which are at the wrong y position
378- IF (y_in <= y_min_local .OR. y_in > y_max_local) THEN
379+ low_in = y_grid_mins(y_coords) - 0.5_num * dy
380+ IF (y_coords == nprocy-1 ) THEN
381+ high_in = y_grid_maxs(y_coords) + 0.5_num * dy
382+ ELSE
383+ high_in = y_grid_mins(y_coords+1 ) - 0.5_num * dy
384+ END IF
385+ IF (y_in <= low_in .OR. y_in > high_in) THEN
379386 skip_processor = .TRUE.
380387 END IF
381388
382389 ELSE IF (boundary == c_bd_y_min .OR. boundary == c_bd_y_max) THEN
383390 ! Skip all processors which are at the wrong x position
384- IF (x_in <= x_min_local .OR. x_in > x_max_local) THEN
391+ low_in = x_grid_mins(x_coords) - 0.5_num * dx
392+ IF (x_coords == nprocx-1 ) THEN
393+ high_in = x_grid_maxs(x_coords) + 0.5_num * dx
394+ ELSE
395+ high_in = x_grid_mins(x_coords+1 ) - 0.5_num * dx
396+ END IF
397+ IF (x_in <= low_in .OR. x_in > high_in) THEN
385398 skip_processor = .TRUE.
386399 END IF
387400 END IF
0 commit comments