diff --git a/src/encounter/encounter_check.f90 b/src/encounter/encounter_check.f90 index e8bd7987e..bbfa98ba3 100644 --- a/src/encounter/encounter_check.f90 +++ b/src/encounter/encounter_check.f90 @@ -289,6 +289,12 @@ subroutine encounter_check_reduce_broadphase(n, nenc, index1, index2, lencounter logical, dimension(:), allocatable :: ltmp nenc = count(lencounter(:)) ! Count the true number of encounters + if (nenc == 0) then + if (allocated(index1)) deallocate(index1) + if (allocated(index2)) deallocate(index2) + if (allocated(lvdotr)) deallocate(lvdotr) + return + end if allocate(itmp(nenc)) itmp(:) = pack(index1(:), lencounter(:))