def _build_fname_templ(n):
    """
    Create a template to parse for the file name, based on the dataset-__version
    separation rule from globals.

    Parameters
    ----------
    n : int
        Total number of (reference and candidate) values sets in the file.

    Returns
    -------
    fname_templ : str
        Template for the file name to parse.
    """
    parts = [globals.ds_fn_templ.format(i='{i_ref:d}', ds='{ref}', var=
        '{ref_var}')]
    for i in range(1, n):
        parts += [globals.ds_fn_templ.format(i='{i_ds%i:d}' % i, ds=
            '{ds%i}' % i, var='{var%i}' % i)]
    return globals.ds_fn_sep.join(parts) + '.nc'
