diff --git a/src/opt_delete.f90 b/src/opt_delete.f90 index f631693..b2f79bf 100644 --- a/src/opt_delete.f90 +++ b/src/opt_delete.f90 @@ -126,13 +126,24 @@ module opt_delete end if !Now zero out the larger index - if(i < nei) then - which_cell(:,i) = 0 - cycle atom_loop + if(first) then + if(i > nei) then + which_cell(:,i) = 0 + cycle atom_loop + else + which_cell(:,nei) = 0 + cell_list(num_nei,c(1) + ck, c(2) + cj, c(3) + ci) = 0 + end if else - which_cell(:,nei) = 0 - cell_list(num_nei,c(1) + ck, c(2) + cj, c(3) + ci) = 0 + if(i < nei) then + which_cell(:,i) = 0 + cycle atom_loop + else + which_cell(:,nei) = 0 + cell_list(num_nei,c(1) + ck, c(2) + cj, c(3) + ci) = 0 + end if end if + end if end if end do