def cloud_radiative_effect(base, pert):
    """Calculate the cloud radiative effect intended for longwave fluxes.

    Parameters
    ----------
    base, pert: dict of array_like
        CMIP diagnostics required to calculate longwave cloud radiative effect. The
        dicts should contain two keys:

        rlut    : top-of-atmosphere outgoing longwave flux
        rlutcs  : top-of-atmosphere longwave flux assuming clear sky

    Returns
    -------
    erfari_lw, erfaci_lw : array_like
        Longwave ERFari and ERFaci estimates.
    """
    # check all required diagnostics are present
    check_vars = ["rlut", "rlutcs"]
    for var_dict in [base, pert]:
        for check_var in check_vars:
            if check_var not in var_dict.keys():
                raise ValueError(f"{check_var} not present in {var_dict}")
        var_dict["rlut"] = var_dict["rlut"]
        var_dict["rlutcs"] = var_dict["rlutcs"]

    erf_lw = -pert["rlut"] - (-base["rlut"])
    erfaci_lw = erf_lw - (-pert["rlutcs"] - (-base["rlutcs"]))
    erfari_lw = erf_lw - erfaci_lw
    return erfari_lw, erfaci_lw