Skip to content

Commit

Permalink
PW: Prevent halos from overlapping with each other
Browse files Browse the repository at this point in the history
  • Loading branch information
oschuett committed Jun 24, 2020
1 parent 99be82d commit e7c6bfc
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions src/pw/realspace_grid_types.F
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,8 @@ SUBROUTINE rs_grid_create_descriptor(desc, pw_grid, input_settings, border_point
routineP = moduleN//':'//routineN

INTEGER :: border_size, dir, handle, i, j, k, l, &
lb(2), n_slices(3), n_slices_tmp(3), &
neighbours(3), nmin
lb(2), min_npts_real, n_slices(3), &
n_slices_tmp(3), nmin
LOGICAL :: overlap
REAL(KIND=dp) :: ratio, ratio_best, volume, volume_dist

Expand Down Expand Up @@ -310,23 +310,17 @@ SUBROUTINE rs_grid_create_descriptor(desc, pw_grid, input_settings, border_point
(/-1, -1, -1/) /= input_settings%distribution_layout) &
)) CYCLE

! we currently can not work with a grid that has borders that overlaps with the local data of the grid itself
! We can not work with a grid that has more local than global grid points.
! This can happen when a halo region wraps around and overlaps with the other halo.
overlap = .FALSE.
DO dir = 1, 3
IF (n_slices_tmp(dir) > 1) THEN
neighbours(dir) = HUGE(0)
DO l = 0, n_slices_tmp(dir) - 1
lb = get_limit(desc%npts(dir), n_slices_tmp(dir), l)
neighbours(dir) = MIN(lb(2) - lb(1) + 1, neighbours(dir))
IF (lb(2) - lb(1) + 1 + 2*nmin > desc%npts(dir)) overlap = .TRUE.
ENDDO
desc%neighbours(dir) = (nmin + neighbours(dir) - 1)/neighbours(dir)
IF (desc%neighbours(dir) .GE. n_slices_tmp(dir)) overlap = .TRUE.
ELSE
neighbours(dir) = 0
ENDIF
ENDDO
! XXXXXXX I think the overlap criterion / neighbour calculation is too conservative
! write(*,*) n_slices_tmp,desc % neighbours, overlap
IF (overlap) CYCLE

! a heuristic optimisation to reduce the memory usage
Expand Down Expand Up @@ -459,12 +453,12 @@ SUBROUTINE rs_grid_create_descriptor(desc, pw_grid, input_settings, border_point
DO dir = 1, 3
desc%neighbours(dir) = 0
IF ((n_slices(dir) > 1) .OR. (border_size > 0)) THEN
neighbours(dir) = HUGE(0)
min_npts_real = HUGE(0)
DO l = 0, n_slices(dir) - 1
lb = get_limit(desc%npts(dir), n_slices(dir), l)
neighbours(dir) = MIN(lb(2) - lb(1) + 1, neighbours(dir))
min_npts_real = MIN(lb(2) - lb(1) + 1, min_npts_real)
END DO
desc%neighbours(dir) = (desc%border + neighbours(dir) - 1)/neighbours(dir)
desc%neighbours(dir) = (desc%border + min_npts_real - 1)/min_npts_real
END IF
END DO

Expand Down

0 comments on commit e7c6bfc

Please sign in to comment.