diff --git a/src/mesh/aabb_tree.f90 b/src/mesh/aabb_tree.f90 index 83cd2e7e5dc..87b506d0758 100644 --- a/src/mesh/aabb_tree.f90 +++ b/src/mesh/aabb_tree.f90 @@ -439,8 +439,9 @@ function sort(array) result(indices) minidx = -1 do imin = 1, size(array) if (.not. visited(imin) .and. minidx .eq. -1) minidx = imin - - if (visited(imin) .and. array(imin) .lt. array(minidx)) minidx = imin + if (minidx .gt. -1) then + if (visited(imin) .and. array(imin) .lt. array(minidx)) minidx = imin + end if end do indices(i) = minidx @@ -641,6 +642,7 @@ subroutine aabb_tree_query_overlaps(this, object, object_index, overlaps) end if end if end do + call simple_stack%free() end subroutine aabb_tree_query_overlaps ! -------------------------------------------------------------------------- ! diff --git a/src/mesh/search_tree/aabb.f90 b/src/mesh/search_tree/aabb.f90 index 854c1c555dc..0b326621a4d 100644 --- a/src/mesh/search_tree/aabb.f90 +++ b/src/mesh/search_tree/aabb.f90 @@ -187,6 +187,8 @@ function get_aabb(object, padding) result(box) select type(object) + type is (aabb_t) + call box%init(object%get_min(), object%get_max()) type is (tri_t) box = get_aabb_element(object) type is (hex_t)