import copy


def create_model_diag_conf(rose_conf, templ_conf, model, diag, index):
    """
    Add model and diag sections to configuration

    rose_conf   : original rose configuration
    templ_conf  : template configuration, will be copied
    model       : model name
    diag        : diag name
    index       : processor id

    returns a configuration
    """

    conf = copy.deepcopy(templ_conf)

    mname = 'namelist:models(' + model + ')'
    dname = 'namelist:diags(' + diag + ')'
    conf[mname] = rose_conf[mname]
    conf[dname] = rose_conf[dname]

    conf['general']['clear_netcdf_cache'] = 'false'

    return conf