code: def _get_rank_limits(comm, arrlen):
      
  
      rank = comm.Get_rank()  # Id of this process
      size = comm.Get_size()  # Total number of processes in communicator
      end = 0
      # The scan should be done with ints, not floats
      ranklen = int(arrlen / size)
      if rank < arrlen % size:
          ranklen += 1
      # Compute upper limit based on the sizes covered by the processes
      # with less rank
      end = comm.scan(sendobj=ranklen, op=MPI.SUM)
      begin = end - ranklen
  
      return (begin, end)
docs: Determine the chunk of the grid that has to be computed per
      process. The grid has been 'flattened' and has arrlen length. The
      chunk assigned to each process depends on its rank in the MPI
      communicator.
  
      Parameters
      ----------
      comm : MPI communicator object
        Describes topology of network: number of processes, rank
      arrlen : int
        Number of points in grid search.
  
      Returns
      -------
      begin : int
        Index, with respect to 'flattened' grid, where the chunk
        for this process starts.
      end : int
        Index, with respect to 'flattened' grid, where the chunk
        for this process ends.