def _calculate_ranges(config, start, stop):
    """Calculate which part of a give range should belong to which process


    Parameters
    ----------
    
    config : DistributedConfiguration 
        object holding information about the parallel environment of quantarhei
   
    start : int
        start of the integer range
        
    stop : int
        end of the integer range
    
    """
    whole_range = stop - start
    per_worker = whole_range // config.size
    remainder = whole_range % config.size
    ranges = [None] * config.size
    for rank in range(config.size):
        N1_local = rank * per_worker
        N2_local = N1_local + per_worker
        if rank <= remainder:
            if rank != 0:
                N1_local += rank - 1
                N2_local += rank
        else:
            N1_local += remainder
            N2_local += remainder
        rng = list()
        rng.append(N1_local)
        rng.append(N2_local)
        ranges[rank] = rng
    config.ranges = ranges
    return ranges[config.rank]
