Set the Morton range for each processor
subroutine get_Morton_range use mod_forest use mod_global_parameters integer :: ipe, blocks_left, procs_left, num_blocks if (allocated(sfc_to_igrid)) deallocate(sfc_to_igrid) blocks_left = nleafs do ipe = 0, npe-1 if (ipe == 0) then Morton_start(ipe) = 1 else Morton_start(ipe) = Morton_stop(ipe-1) + 1 end if ! Compute how many blocks this cpu should take procs_left = npe - ipe num_blocks = ceiling(blocks_left / dble(procs_left)) Morton_stop(ipe) = Morton_start(ipe) + num_blocks - 1 blocks_left = blocks_left - num_blocks end do allocate(sfc_to_igrid(Morton_start(mype):Morton_stop(mype))) end subroutine get_Morton_range