def main(dataset, blockl, local_dir=None, clobber=True):
    """
    Split dataset into time chunks

    Parameters
    ----------
    dataset : str
        Name of MS file to split
    blockl : int
        Number of time slots per chunk
    local_dir : str, optional
        Path to local directory for output of t1.copy(). The file is then
        copied to the original output directory
    clobber : bool, optional
        If True, existing files are overwritten

    """
    if type(clobber) is str:
        if clobber.lower() == 'true':
            clobber = True
        else:
            clobber = False

    blockl = int(blockl)
    if blockl < 1:
        blockl = 1

    # Get time per sample and number of samples
    t = pt.table(dataset, readonly=True, ack=False)
    for t2 in t.iter(["ANTENNA1","ANTENNA2"]):
        if (t2.getcell('ANTENNA1',0)) < (t2.getcell('ANTENNA2',0)):
            timepersample = t2[1]['TIME']-t2[0]['TIME'] # sec
            nsamples = t2.nrows()
            break
    t.close()

    nchunks = int(np.ceil((np.float(nsamples) / np.float(blockl))))

    # Don't allow more than 15 chunks for performance reasons
    while nchunks > 15:
        blockl *= 2
        nchunks = int(np.ceil((np.float(nsamples) / np.float(blockl))))

    tlen = timepersample * np.float(blockl) / 3600.0 # length of block in hours
    tobs = timepersample * nsamples / 3600.0 # length of obs in hours

    # Copy to local directory if needed
    dataset_original = dataset
    if local_dir is not None:
        dataset = os.path.join(local_dir, os.path.basename(dataset_original))
        os.system('/usr/bin/rsync -a {0} {1}'.format(dataset_original, local_dir))

    files = []
    for c in range(nchunks):
        chunk_file = '{0}_chunk{1}.ms'.format(os.path.splitext(dataset_original)[0], c)
        files.append(chunk_file)
        t0 = tlen * np.float(c) # hours
        t1 = t0 + tlen # hours
        if c == 0:
            t0 = -0.1 # make sure first chunk gets first slot
        if c == nchunks-1 and t1 < tobs:
            t1 = tobs + 0.1 # make sure last chunk gets all that remains
        split_ms(dataset, chunk_file, t0, t1, local_dir, clobber=clobber)

    if local_dir is not None and not os.path.samefile(dataset, dataset_original):
        shutil.rmtree(dataset)

    return {'files': '[{0}]'.format(','.join(files))}