module tree use typedef, only: & int64 implicit none save integer(kind=int64) :: & nstar = -1 integer(kind=int64), dimension(:), allocatable :: & order, hierarchy contains subroutine clear_order() if (allocated(order)) deallocate(order) if (allocated(hierarchy)) deallocate(hierarchy) nstar = -1 end subroutine clear_order subroutine set_order(order_, hierarchy_) use typedef, only: & int64 integer(kind=int64), dimension(:), intent(in) :: & order_, hierarchy_ integer(kind=int64) :: & nstar_ nstar_ = size(order_, 1) if (size(hierarchy_, 1) /= nstar_) & error stop 'dimension mismatch for order and hierarchy' if (nstar /= nstar_) then if (allocated(order)) deallocate(order) if (allocated(hierarchy)) deallocate(hierarchy) nstar = nstar_ allocate(order(nstar), hierarchy(nstar)) endif order(:) = order_(:) hierarchy(:) = hierarchy_(:) end subroutine set_order end module tree