def _parse_mpi(exec_host):
    """
    Return (nodes, total-cores) given a dict from a PBS record.
    """
    # exec_host is of the form <hostname>/core_no[+<hostname>/core_no]
    # e.g. wn1.rl.ac.uk/0+wn1.rl.ac.uk/1+wn2.rl.ac.uk/0+wn2.rl.ac.uk/1
    # The 'exec_host' in Torque >= 5.1.0 reads like 'b391/0-1,5,11'

    core_info = exec_host.split('+')
    # Split hostname and core_no into seperate lists.
    hostnames, core_no = zip(*[x.split('/') for x in core_info])

    # Split any comma separated fields into a flat list.
    core_no = [core for cores in core_no for core in cores.split(',')]
    ncores = 0
    for no in core_no:
        if '-' in no:
            # Calculate the number of cores in the closed set.
            ncores += int(no.split('-')[1]) - int(no.split('-')[0]) + 1
        else:
            ncores += 1

    # get number of unique hostnames
    nnodes = len(set(hostnames))

    return nnodes, ncores