def _set_netcdf_grid_mapping_variable(root, grid_mapping):
    """Create grid mapping variable, if necessary."""
    name = grid_mapping.pop('name')
    var = root.createVariable(name, 'S1', dimensions=())
    for attr in grid_mapping.keys():
        setattr(var, attr, grid_mapping[attr])
